mirror of https://github.com/snes9xgit/snes9x.git
Add IRQ transition.
This commit is contained in:
parent
15f76f7eca
commit
c932d4e37a
1
cpu.cpp
1
cpu.cpp
|
@ -229,6 +229,7 @@ static void S9xSoftResetCPU (void)
|
|||
CPU.PCBase = NULL;
|
||||
CPU.NMIPending = FALSE;
|
||||
CPU.IRQLine = FALSE;
|
||||
CPU.IRQTransition = FALSE;
|
||||
CPU.IRQExternal = FALSE;
|
||||
CPU.IRQPending = Timings.IRQPendCount;
|
||||
CPU.MemSpeed = SLOW_ONE_CYCLE;
|
||||
|
|
20
cpuexec.cpp
20
cpuexec.cpp
|
@ -223,7 +223,7 @@ void S9xMainLoop (void)
|
|||
{
|
||||
CPU.WaitingForInterrupt = FALSE;
|
||||
Registers.PCw++;
|
||||
CPU.Cycles += 14;
|
||||
CPU.Cycles += ONE_CYCLE;
|
||||
while (CPU.Cycles >= CPU.NextEvent)
|
||||
S9xDoHEventProcessing();
|
||||
}
|
||||
|
@ -232,25 +232,31 @@ void S9xMainLoop (void)
|
|||
}
|
||||
}
|
||||
|
||||
if ((CPU.Cycles >= Timings.NextIRQTimer || CPU.IRQExternal) && !CPU.IRQLine)
|
||||
{
|
||||
if (CPU.IRQPending)
|
||||
CPU.IRQPending--;
|
||||
else
|
||||
if (CPU.IRQTransition)
|
||||
{
|
||||
if (CPU.WaitingForInterrupt)
|
||||
{
|
||||
CPU.WaitingForInterrupt = FALSE;
|
||||
Registers.PCw++;
|
||||
CPU.Cycles += 14;
|
||||
CPU.Cycles += ONE_CYCLE;
|
||||
while (CPU.Cycles >= CPU.NextEvent)
|
||||
S9xDoHEventProcessing();
|
||||
}
|
||||
|
||||
S9xUpdateIRQPositions();
|
||||
CPU.IRQPending = Timings.IRQPendCount;
|
||||
CPU.IRQTransition = FALSE;
|
||||
CPU.IRQLine = TRUE;
|
||||
}
|
||||
|
||||
if ((CPU.Cycles >= Timings.NextIRQTimer || CPU.IRQExternal) && !CPU.IRQLine && !CPU.IRQTransition)
|
||||
{
|
||||
if (CPU.IRQPending)
|
||||
CPU.IRQPending--;
|
||||
else
|
||||
{
|
||||
CPU.IRQTransition = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (CPU.IRQLine && !CheckFlag(IRQ))
|
||||
|
|
6
ppu.cpp
6
ppu.cpp
|
@ -334,7 +334,7 @@ void S9xUpdateIRQPositions (void)
|
|||
else if (!PPU.HTimerEnabled && PPU.VTimerEnabled)
|
||||
{
|
||||
if (CPU.V_Counter == PPU.VTimerPosition)
|
||||
Timings.NextIRQTimer = 0;
|
||||
Timings.NextIRQTimer = Timings.IRQTriggerCycles;
|
||||
else
|
||||
Timings.NextIRQTimer = CyclesUntilNext (Timings.IRQTriggerCycles, PPU.VTimerPosition);
|
||||
}
|
||||
|
@ -1556,7 +1556,10 @@ void S9xSetCPU (uint8 Byte, uint16 Address)
|
|||
PPU.HTimerEnabled = FALSE;
|
||||
|
||||
if (!(Byte & 0x10) && !(Byte & 0x20))
|
||||
{
|
||||
CPU.IRQLine = FALSE;
|
||||
CPU.IRQTransition = FALSE;
|
||||
}
|
||||
|
||||
S9xUpdateIRQPositions();
|
||||
|
||||
|
@ -1842,6 +1845,7 @@ uint8 S9xGetCPU (uint16 Address)
|
|||
case 0x4211: // TIMEUP
|
||||
byte = CPU.IRQLine ? 0x80 : 0;
|
||||
CPU.IRQLine = FALSE;
|
||||
CPU.IRQTransition = FALSE;
|
||||
S9xUpdateIRQPositions();
|
||||
|
||||
return (byte | (OpenBus & 0x7f));
|
||||
|
|
Loading…
Reference in New Issue