summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2016-04-12 08:35:44 -0700
committerMichael Pavone <pavone@retrodev.com>2016-04-12 08:35:44 -0700
commitac4d11e004b3ae64bf1c275b9083c45cf6458d77 (patch)
treed01b95414f192332cd13814daad4713a99536140
parentd62ce280764beb725bf03b6e4508c73f3c23d224 (diff)
Fix VDP interrupt ack. Big thanks to Eke-Eke or whoever left that helpful comment in Genesis Plus GX. Fixes Fatal Rewind
-rw-r--r--vdp.c11
1 files changed, 9 insertions, 2 deletions
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;
}
}