# HG changeset patch # User Michael Pavone # Date 1460475344 25200 # Node ID 7f4a7f07f32554485e2fcf34bb8529a8843dff13 # Parent fec4a59ae5d738cb6d4edbb5f1a89a72a96647cf Fix VDP interrupt ack. Big thanks to Eke-Eke or whoever left that helpful comment in Genesis Plus GX. Fixes Fatal Rewind diff -r fec4a59ae5d7 -r 7f4a7f07f325 vdp.c --- a/vdp.c Mon Apr 11 20:56:54 2016 -0700 +++ b/vdp.c Tue Apr 12 08:35:44 2016 -0700 @@ -1935,9 +1935,16 @@ 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; } }