# HG changeset patch # User Michael Pavone # Date 1582689784 28800 # Node ID 62166274e6c0b3299dd2031769032e243e399bdb # Parent 32a3aa7b4a45e821c7f2efe536ce75c7370ed86e Fix edge case in Z80 interrupt handling. Fixes music in Metal Blast 2277 diff -r 32a3aa7b4a45 -r 62166274e6c0 z80_to_x86.c --- a/z80_to_x86.c Mon Feb 24 20:06:29 2020 -0800 +++ b/z80_to_x86.c Tue Feb 25 20:03:04 2020 -0800 @@ -3413,6 +3413,9 @@ 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);