The flag pushed on to the stack before IRQ is the updated one.

This commit is contained in:
Brandon Wright 2018-06-01 14:05:00 -05:00
parent 382db4d9d4
commit 1dd2501e98
1 changed files with 15 additions and 8 deletions

View File

@ -207,6 +207,16 @@ static inline void S9xReschedule (void);
void S9xMainLoop (void) void S9xMainLoop (void)
{ {
#define CHECK_FOR_IRQ_CHANGE() \
if (Timings.IRQFlagChanging) \
{ \
if (Timings.IRQFlagChanging == IRQ_CLEAR_FLAG) \
ClearIRQ(); \
else if (Timings.IRQFlagChanging == IRQ_SET_FLAG) \
SetIRQ(); \
Timings.IRQFlagChanging = IRQ_NONE; \
}
for (;;) for (;;)
{ {
if (CPU.NMIPending) if (CPU.NMIPending)
@ -258,17 +268,14 @@ void S9xMainLoop (void)
} }
if ((CPU.IRQLine || CPU.IRQExternal) && !CheckFlag(IRQ)) if ((CPU.IRQLine || CPU.IRQExternal) && !CheckFlag(IRQ))
{
/* The flag pushed onto the stack is the new value */
CHECK_FOR_IRQ_CHANGE();
S9xOpcode_IRQ(); S9xOpcode_IRQ();
}
/* Change IRQ flag for instructions that set it only on last cycle */ /* Change IRQ flag for instructions that set it only on last cycle */
if (Timings.IRQFlagChanging) CHECK_FOR_IRQ_CHANGE();
{
if (Timings.IRQFlagChanging == IRQ_CLEAR_FLAG)
ClearIRQ();
else if (Timings.IRQFlagChanging == IRQ_SET_FLAG)
SetIRQ();
Timings.IRQFlagChanging = IRQ_NONE;
}
#ifdef DEBUGGER #ifdef DEBUGGER