From ac4d11e004b3ae64bf1c275b9083c45cf6458d77 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Tue, 12 Apr 2016 08:35:44 -0700 Subject: Fix VDP interrupt ack. Big thanks to Eke-Eke or whoever left that helpful comment in Genesis Plus GX. Fixes Fatal Rewind --- vdp.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'vdp.c') diff --git a/vdp.c b/vdp.c index c76f099..f4a64c0 100644 --- a/vdp.c +++ b/vdp.c @@ -1935,9 +1935,16 @@ uint32_t vdp_next_vint_z80(vdp_context * context) void vdp_int_ack(vdp_context * context, uint16_t int_num) { - if (int_num == 6) { + //Apparently the VDP interrupt controller is not very smart + //Instead of paying attention to what interrupt is being acknowledged it just + //clears the pending flag for whatever interrupt it is currently asserted + //which may be different from the interrupt it was asserting when the 68k + //started the interrupt process. The window for this is narrow and depends + //on the latency between the int enable register write and the interrupt being + //asserted, but Fatal Rewind depends on this due to some buggy code + if ((context->flags2 & FLAG2_VINT_PENDING) && (context->regs[REG_MODE_2] & BIT_VINT_EN)) { context->flags2 &= ~FLAG2_VINT_PENDING; - } else if(int_num ==4) { + } else if((context->flags2 & FLAG2_HINT_PENDING) && (context->regs[REG_MODE_1] & BIT_HINT_EN)) { context->flags2 &= ~FLAG2_HINT_PENDING; } } -- cgit v1.2.3