From fa18382757d1934d465a3a6ee1ca508cac53094c Mon Sep 17 00:00:00 2001 From: tomcw Date: Mon, 18 Oct 2021 21:45:45 +0100 Subject: [PATCH] Core emulation: simplify NMI & IRQ handling --- source/CPU.cpp | 1 - source/CPU/cpu6502.h | 14 ++++---------- source/CPU/cpu65C02.h | 14 ++++---------- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/source/CPU.cpp b/source/CPU.cpp index 865710a3..cd39707b 100644 --- a/source/CPU.cpp +++ b/source/CPU.cpp @@ -446,7 +446,6 @@ static __forceinline bool IRQ(ULONG& uExecutedCycles, BOOL& flagc, BOOL& flagn, (g_bmIRQ & 8) ? "MOUSE" : "UNKNOWN"; LogOutput("IRQ (%08X) (%s)\n", (UINT)g_nCycleIrqStart, pSrc); #endif - CheckSynchronousInterruptSources(7, uExecutedCycles); g_interruptInLastExecutionBatch = true; irqTaken = true; } diff --git a/source/CPU/cpu6502.h b/source/CPU/cpu6502.h index 96c7a58d..6887fbc2 100644 --- a/source/CPU/cpu6502.h +++ b/source/CPU/cpu6502.h @@ -50,18 +50,12 @@ static DWORD Cpu6502(DWORD uTotalCycles, const bool bVideoUpdate) { const UINT uZ80Cycles = z80_mainloop(uTotalCycles, uExecutedCycles); CYC(uZ80Cycles) } + else if (NMI(uExecutedCycles, flagc, flagn, flagv, flagz) || IRQ(uExecutedCycles, flagc, flagn, flagv, flagz)) + { + // Allow AppleWin debugger's single-stepping to just step the pending IRQ + } else { - if (IRQ(uExecutedCycles, flagc, flagn, flagv, flagz) || NMI(uExecutedCycles, flagc, flagn, flagv, flagz)) - { - if (bVideoUpdate) - { - ULONG uElapsedCycles = uExecutedCycles - uPreviousCycles; - NTSC_VideoUpdateCycles(uElapsedCycles); - } - continue; // Allow AppleWin debugger's single-stepping to just step the pending IRQ - } - HEATMAP_X( regs.pc ); Fetch(iOpcode, uExecutedCycles); diff --git a/source/CPU/cpu65C02.h b/source/CPU/cpu65C02.h index fa1b4ff7..f9eb55f2 100644 --- a/source/CPU/cpu65C02.h +++ b/source/CPU/cpu65C02.h @@ -50,18 +50,12 @@ static DWORD Cpu65C02(DWORD uTotalCycles, const bool bVideoUpdate) { const UINT uZ80Cycles = z80_mainloop(uTotalCycles, uExecutedCycles); CYC(uZ80Cycles) } + else if (NMI(uExecutedCycles, flagc, flagn, flagv, flagz) || IRQ(uExecutedCycles, flagc, flagn, flagv, flagz)) + { + // Allow AppleWin debugger's single-stepping to just step the pending IRQ + } else { - if (IRQ(uExecutedCycles, flagc, flagn, flagv, flagz) || NMI(uExecutedCycles, flagc, flagn, flagv, flagz)) - { - if (bVideoUpdate) - { - ULONG uElapsedCycles = uExecutedCycles - uPreviousCycles; - NTSC_VideoUpdateCycles(uElapsedCycles); - } - continue; // Allow AppleWin debugger's single-stepping to just step the pending IRQ - } - HEATMAP_X( regs.pc ); Fetch(iOpcode, uExecutedCycles);