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.H_Max = Timings.H_Max_Master;
Timings.V_Max = Timings.V_Max_Master; Timings.V_Max = Timings.V_Max_Master;
Timings.NMITriggerPos = 0xffff; Timings.NMITriggerPos = 0xffff;
Timings.NextIRQTimer = 0xffff; Timings.NextIRQTimer = 0x0fffffff;
if (Model->_5A22 == 2) if (Model->_5A22 == 2)
Timings.WRAMRefreshPos = SNES_WRAM_REFRESH_HC_v2; Timings.WRAMRefreshPos = SNES_WRAM_REFRESH_HC_v2;
else else

View File

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

10
ppu.cpp
View File

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