mirror of https://github.com/snes9xgit/snes9x.git
Fixed IRQ handling. Dumb me.
This commit is contained in:
parent
7dec8a1f9e
commit
a74fe2f623
26
ppu.cpp
26
ppu.cpp
|
@ -274,14 +274,6 @@ static int CyclesUntilNext (int hc, int vc)
|
||||||
int32 total = 0;
|
int32 total = 0;
|
||||||
int vpos = CPU.V_Counter;
|
int vpos = CPU.V_Counter;
|
||||||
|
|
||||||
// Advance to next hc
|
|
||||||
total = (hc - CPU.Cycles);
|
|
||||||
if (total < 0)
|
|
||||||
{
|
|
||||||
total += Timings.H_Max;
|
|
||||||
vpos++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vc - vpos >= 0)
|
if (vc - vpos >= 0)
|
||||||
{
|
{
|
||||||
// It's still in this frame */
|
// It's still in this frame */
|
||||||
|
@ -302,6 +294,8 @@ static int CyclesUntilNext (int hc, int vc)
|
||||||
total -= ONE_DOT_CYCLE;
|
total -= ONE_DOT_CYCLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
total += hc;
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,16 +327,22 @@ void S9xUpdateIRQPositions (void)
|
||||||
}
|
}
|
||||||
else if (PPU.HTimerEnabled && !PPU.VTimerEnabled)
|
else if (PPU.HTimerEnabled && !PPU.VTimerEnabled)
|
||||||
{
|
{
|
||||||
Timings.NextIRQTimer = PPU.HTimerPosition - CPU.Cycles;
|
Timings.NextIRQTimer = PPU.HTimerPosition;
|
||||||
if (Timings.NextIRQTimer < 0)
|
if (CPU.Cycles > Timings.NextIRQTimer)
|
||||||
Timings.NextIRQTimer += Timings.H_Max;
|
Timings.NextIRQTimer += Timings.H_Max;
|
||||||
}
|
}
|
||||||
|
else if (!PPU.HTimerEnabled && PPU.VTimerEnabled)
|
||||||
|
{
|
||||||
|
if (CPU.V_Counter == PPU.VTimerPosition)
|
||||||
|
Timings.NextIRQTimer = 0;
|
||||||
|
else
|
||||||
|
Timings.NextIRQTimer = CyclesUntilNext (0, PPU.VTimerPosition);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Timings.NextIRQTimer =
|
Timings.NextIRQTimer = CyclesUntilNext (PPU.HTimerPosition, PPU.VTimerPosition);
|
||||||
CyclesUntilNext (PPU.HTimerEnabled ? PPU.HTimerPosition : 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",
|
||||||
PPU.HTimerEnabled, PPU.HTimerPosition, PPU.VTimerEnabled, PPU.VTimerPosition);
|
PPU.HTimerEnabled, PPU.HTimerPosition, PPU.VTimerEnabled, PPU.VTimerPosition);
|
||||||
|
|
Loading…
Reference in New Issue