comparison vdp.c @ 952:7f4a7f07f325

Fix VDP interrupt ack. Big thanks to Eke-Eke or whoever left that helpful comment in Genesis Plus GX. Fixes Fatal Rewind
author Michael Pavone <pavone@retrodev.com>
date Tue, 12 Apr 2016 08:35:44 -0700
parents 1b86268a4cb3
children 08346262990b
comparison
equal deleted inserted replaced
951:fec4a59ae5d7 952:7f4a7f07f325
1933 return context->cycles + cycles_to_vint; 1933 return context->cycles + cycles_to_vint;
1934 } 1934 }
1935 1935
1936 void vdp_int_ack(vdp_context * context, uint16_t int_num) 1936 void vdp_int_ack(vdp_context * context, uint16_t int_num)
1937 { 1937 {
1938 if (int_num == 6) { 1938 //Apparently the VDP interrupt controller is not very smart
1939 //Instead of paying attention to what interrupt is being acknowledged it just
1940 //clears the pending flag for whatever interrupt it is currently asserted
1941 //which may be different from the interrupt it was asserting when the 68k
1942 //started the interrupt process. The window for this is narrow and depends
1943 //on the latency between the int enable register write and the interrupt being
1944 //asserted, but Fatal Rewind depends on this due to some buggy code
1945 if ((context->flags2 & FLAG2_VINT_PENDING) && (context->regs[REG_MODE_2] & BIT_VINT_EN)) {
1939 context->flags2 &= ~FLAG2_VINT_PENDING; 1946 context->flags2 &= ~FLAG2_VINT_PENDING;
1940 } else if(int_num ==4) { 1947 } else if((context->flags2 & FLAG2_HINT_PENDING) && (context->regs[REG_MODE_1] & BIT_HINT_EN)) {
1941 context->flags2 &= ~FLAG2_HINT_PENDING; 1948 context->flags2 &= ~FLAG2_HINT_PENDING;
1942 } 1949 }
1943 } 1950 }
1944 1951