From 7cd0eb4a4ba06e073470dc039e2553cd0d32a04f Mon Sep 17 00:00:00 2001 From: ekeeke31 Date: Thu, 28 Apr 2011 00:13:23 +0000 Subject: [PATCH] improved HINT accuracy in Master System Compatibility mode. --- source/system.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/system.c b/source/system.c index a36f406..5753c0c 100644 --- a/source/system.c +++ b/source/system.c @@ -757,6 +757,14 @@ static void system_frame_sms(int do_skip) hint_pending = 0x10; if (reg[0] & 0x10) { + /* IRQ line is latched between instructions, on instruction last cycle */ + /* This means that if Z80 cycle count is exactly a multiple of MCYCLES_PER_LINE, */ + /* interrupt should be triggered AFTER the next instruction. */ + if ((mcycles_z80 % MCYCLES_PER_LINE) == 0) + { + z80_run(mcycles_z80 + 1); + } + Z80.irq_state = ASSERT_LINE; } }