Fix a couple IRQ problems.

This commit is contained in:
Brandon Wright 2018-05-19 16:53:15 -05:00
parent c96f6cd913
commit d27d9b6dbd
3 changed files with 10 additions and 4 deletions

View File

@ -266,7 +266,7 @@ static void S9xSoftResetCPU (void)
Timings.H_Max = Timings.H_Max_Master;
Timings.V_Max = Timings.V_Max_Master;
Timings.NMITriggerPos = 0xffff;
Timings.NextIRQTimer = 0xffff;
Timings.NextIRQTimer = 0x0fffffff;
if (Model->_5A22 == 2)
Timings.WRAMRefreshPos = SNES_WRAM_REFRESH_HC_v2;
else

View File

@ -417,7 +417,7 @@ void S9xDoHEventProcessing (void)
CPU.Cycles -= Timings.H_Max;
if (Timings.NMITriggerPos != 0xffff)
Timings.NMITriggerPos -= Timings.H_Max;
if (Timings.NextIRQTimer != 0xffff)
if (Timings.NextIRQTimer != 0xffffffff)
Timings.NextIRQTimer -= Timings.H_Max;
S9xAPUSetReferenceTime(CPU.Cycles);

10
ppu.cpp
View File

@ -329,13 +329,19 @@ void S9xUpdateIRQPositions (void)
if (!PPU.HTimerEnabled && !PPU.VTimerEnabled)
{
Timings.NextIRQTimer = 0xffff;
Timings.NextIRQTimer = 0x0fffffff;
}
else if (PPU.HTimerEnabled && !PPU.VTimerEnabled)
{
Timings.NextIRQTimer = PPU.HTimerPosition - CPU.Cycles;
if (Timings.NextIRQTimer < 0)
Timings.NextIRQTimer += Timings.H_Max;
}
else
{
Timings.NextIRQTimer =
CyclesUntilNext (PPU.HTimerEnabled ? PPU.HTimerPosition : 0,
PPU.VTimerEnabled ? PPU.VTimerPosition : 0);
PPU.VTimerPosition);
}
#ifdef DEBUGGER
S9xTraceFormattedMessage("--- IRQ Timer set HTimer:%d Pos:%04d VTimer:%d Pos:%03d",