From 94c3e706af264bad799db8cc51a51f86356c6481 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Tue, 25 Feb 2020 20:03:04 -0800 Subject: Fix edge case in Z80 interrupt handling. Fixes music in Metal Blast 2277 --- z80_to_x86.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'z80_to_x86.c') diff --git a/z80_to_x86.c b/z80_to_x86.c index 9c77674..d447ee3 100644 --- a/z80_to_x86.c +++ b/z80_to_x86.c @@ -3413,6 +3413,9 @@ void init_z80_opts(z80_options * options, memmap_chunk const * chunks, uint32_t add_rdispr(code, options->gen.context_reg, offsetof(z80_context, target_cycle), options->gen.cycles, SZ_D); cmp_rdispr(code, options->gen.context_reg, offsetof(z80_context, int_cycle), options->gen.cycles, SZ_D); jcc(code, CC_B, skip_int); + //check that we are not past the end of interrupt pulse + cmp_rrdisp(code, options->gen.cycles, options->gen.context_reg, offsetof(z80_context, int_pulse_end), SZ_D); + jcc(code, CC_B, skip_int); //set limit to the cycle limit mov_rdispr(code, options->gen.context_reg, offsetof(z80_context, sync_cycle), options->gen.scratch2, SZ_D); mov_rrdisp(code, options->gen.scratch2, options->gen.context_reg, offsetof(z80_context, target_cycle), SZ_D); -- cgit v1.2.3