From 04edb1b5543d7b961f51b96bdb6a3ee3be91465b Mon Sep 17 00:00:00 2001 From: hap Date: Sun, 30 Mar 2025 14:44:55 +0200 Subject: [PATCH] minx: don't crash mame on divide by 0 --- src/devices/cpu/minx/minx.cpp | 2 +- src/devices/cpu/minx/minxopce.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/devices/cpu/minx/minx.cpp b/src/devices/cpu/minx/minx.cpp index 436cbf038ea..59c47039f13 100644 --- a/src/devices/cpu/minx/minx.cpp +++ b/src/devices/cpu/minx/minx.cpp @@ -41,7 +41,7 @@ TODO: - Add support for O and C flags in NEG8 instruction - Verify MUL (CE D8) and DIV (CE D9) - Doublecheck behaviour of CMPN instructions ( CF 60 .. CF 63 ) -- DIV (CE D9) division by zero handling - is supposed to raise a EX4 exception. A real Pokemini unit will freeze. MAME currently will crash. +- DIV (CE D9) division by zero handling - is supposed to raise a EX4 exception. A real Pokemini unit will freeze. */ diff --git a/src/devices/cpu/minx/minxopce.h b/src/devices/cpu/minx/minxopce.h index ee322d668cb..f792e7898fa 100644 --- a/src/devices/cpu/minx/minxopce.h +++ b/src/devices/cpu/minx/minxopce.h @@ -454,7 +454,7 @@ void minx_cpu_device::execute_one_ce() break; case 0xD8: { m_HL = ( m_HL & 0x00FF ) * ( m_BA & 0x00FF ); } break; - case 0xD9: { int d = m_HL / ( m_BA & 0x00FF ); m_HL = ( ( m_HL - ( ( m_BA & 0x00FF ) * d ) ) << 8 ) | d; } + case 0xD9: { if ( m_BA & 0x00FF ) { int d = m_HL / ( m_BA & 0x00FF ); m_HL = ( ( m_HL - ( ( m_BA & 0x00FF ) * d ) ) << 8 ) | d; } } break; case 0xDA: { /* illegal operation? */ } break;