Fix IRQ edge cases

This commit is contained in:
OV2 2012-06-02 17:30:35 +02:00
parent ea09fef2b9
commit 0c74e2c437
1 changed files with 5 additions and 4 deletions

View File

@ -278,10 +278,11 @@ static inline void S9xCheckInterrupts (void)
if (CPU.IRQLine && thisIRQ)
CPU.IRQTransition = TRUE;
if (PPU.HTimerEnabled)
int32 htimepos = PPU.HTimerEnabled ? PPU.HTimerPosition : 10;
if (thisIRQ)
{
int32 htimepos = PPU.HTimerPosition;
if (CPU.Cycles >= Timings.H_Max)
if (CPU.Cycles >= Timings.H_Max && htimepos < CPU.PrevCycles)
htimepos += Timings.H_Max;
if (CPU.PrevCycles >= htimepos || CPU.Cycles < htimepos)
@ -291,7 +292,7 @@ static inline void S9xCheckInterrupts (void)
if (PPU.VTimerEnabled)
{
int32 vcounter = CPU.V_Counter;
if (CPU.Cycles >= Timings.H_Max)
if (htimepos >= Timings.H_Max)
vcounter++;
if (vcounter != PPU.VTimerPosition)