Fix #366 (IRQ erroreously deducting extra cycles)

This commit is contained in:
tomcw 2016-10-22 19:50:35 +01:00
parent 7f3cc09217
commit 58671545bb
5 changed files with 12 additions and 10 deletions

View File

@ -398,7 +398,7 @@ static __forceinline int Fetch(BYTE& iOpcode, ULONG uExecutedCycles)
} }
//#define ENABLE_NMI_SUPPORT // Not used - so don't enable //#define ENABLE_NMI_SUPPORT // Not used - so don't enable
static __forceinline void NMI(ULONG& uExecutedCycles, UINT& uExtraCycles, BOOL& flagc, BOOL& flagn, BOOL& flagv, BOOL& flagz) static __forceinline void NMI(ULONG& uExecutedCycles, BOOL& flagc, BOOL& flagn, BOOL& flagv, BOOL& flagz)
{ {
#ifdef ENABLE_NMI_SUPPORT #ifdef ENABLE_NMI_SUPPORT
if(g_bNmiFlank) if(g_bNmiFlank)
@ -414,12 +414,13 @@ static __forceinline void NMI(ULONG& uExecutedCycles, UINT& uExtraCycles, BOOL&
PUSH(regs.ps & ~AF_BREAK) PUSH(regs.ps & ~AF_BREAK)
regs.ps = regs.ps | AF_INTERRUPT & ~AF_DECIMAL; regs.ps = regs.ps | AF_INTERRUPT & ~AF_DECIMAL;
regs.pc = * (WORD*) (mem+0xFFFA); regs.pc = * (WORD*) (mem+0xFFFA);
UINT uExtraCycles = 0; // Needed for CYC(a) macro
CYC(7) CYC(7)
} }
#endif #endif
} }
static __forceinline void IRQ(ULONG& uExecutedCycles, UINT& uExtraCycles, BOOL& flagc, BOOL& flagn, BOOL& flagv, BOOL& flagz) static __forceinline void IRQ(ULONG& uExecutedCycles, BOOL& flagc, BOOL& flagn, BOOL& flagv, BOOL& flagz)
{ {
if(g_bmIRQ && !(regs.ps & AF_INTERRUPT)) if(g_bmIRQ && !(regs.ps & AF_INTERRUPT))
{ {
@ -433,6 +434,7 @@ static __forceinline void IRQ(ULONG& uExecutedCycles, UINT& uExtraCycles, BOOL&
PUSH(regs.ps & ~AF_BREAK) PUSH(regs.ps & ~AF_BREAK)
regs.ps = regs.ps | AF_INTERRUPT & ~AF_DECIMAL; regs.ps = regs.ps | AF_INTERRUPT & ~AF_DECIMAL;
regs.pc = * (WORD*) (mem+0xFFFE); regs.pc = * (WORD*) (mem+0xFFFE);
UINT uExtraCycles = 0; // Needed for CYC(a) macro
CYC(7) CYC(7)
} }
} }

View File

@ -328,8 +328,8 @@ static DWORD Cpu6502 (DWORD uTotalCycles)
// NTSC_END // NTSC_END
CheckInterruptSources(uExecutedCycles); CheckInterruptSources(uExecutedCycles);
NMI(uExecutedCycles, uExtraCycles, flagc, flagn, flagv, flagz); NMI(uExecutedCycles, flagc, flagn, flagv, flagz);
IRQ(uExecutedCycles, uExtraCycles, flagc, flagn, flagv, flagz); IRQ(uExecutedCycles, flagc, flagn, flagv, flagz);
if ( IsDebugBreakpointHit() ) if ( IsDebugBreakpointHit() )
break; break;

View File

@ -331,8 +331,8 @@ static DWORD Cpu65C02 (DWORD uTotalCycles)
// NTSC_END // NTSC_END
CheckInterruptSources(uExecutedCycles); CheckInterruptSources(uExecutedCycles);
NMI(uExecutedCycles, uExtraCycles, flagc, flagn, flagv, flagz); NMI(uExecutedCycles, flagc, flagn, flagv, flagz);
IRQ(uExecutedCycles, uExtraCycles, flagc, flagn, flagv, flagz); IRQ(uExecutedCycles, flagc, flagn, flagv, flagz);
if( IsDebugBreakpointHit() ) if( IsDebugBreakpointHit() )
break; break;

View File

@ -416,8 +416,8 @@ static DWORD Cpu65D02 (DWORD uTotalCycles)
// NTSC_END // NTSC_END
CheckInterruptSources(uExecutedCycles); CheckInterruptSources(uExecutedCycles);
NMI(uExecutedCycles, uExtraCycles, flagc, flagn, flagv, flagz); NMI(uExecutedCycles, flagc, flagn, flagv, flagz);
IRQ(uExecutedCycles, uExtraCycles, flagc, flagn, flagv, flagz); IRQ(uExecutedCycles, flagc, flagn, flagv, flagz);
if( IsDebugBreakpointHit() ) if( IsDebugBreakpointHit() )
break; break;

View File

@ -72,11 +72,11 @@ static __forceinline void CheckInterruptSources(ULONG uExecutedCycles)
{ {
} }
static __forceinline void NMI(ULONG& uExecutedCycles, UINT& uExtraCycles, BOOL& flagc, BOOL& flagn, BOOL& flagv, BOOL& flagz) static __forceinline void NMI(ULONG& uExecutedCycles, BOOL& flagc, BOOL& flagn, BOOL& flagv, BOOL& flagz)
{ {
} }
static __forceinline void IRQ(ULONG& uExecutedCycles, UINT& uExtraCycles, BOOL& flagc, BOOL& flagn, BOOL& flagv, BOOL& flagz) static __forceinline void IRQ(ULONG& uExecutedCycles, BOOL& flagc, BOOL& flagn, BOOL& flagv, BOOL& flagz)
{ {
} }