From 300494c47010cc2ff857183a32a2d85617e2dc7e Mon Sep 17 00:00:00 2001 From: tomcw Date: Fri, 6 Sep 2019 19:59:28 +0100 Subject: [PATCH] Mockingboard: only do multi-TIMER1 support update when 6502 interrupts are enabled. (#685) --- source/CPU.cpp | 5 +++++ source/CPU.h | 2 ++ source/Mockingboard.cpp | 6 ++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/source/CPU.cpp b/source/CPU.cpp index 0c284b3d..39ca060b 100644 --- a/source/CPU.cpp +++ b/source/CPU.cpp @@ -188,6 +188,11 @@ void SetActiveCpu(eCpuType cpu) g_ActiveCPU = cpu; } +bool Is6502InterruptEnabled(void) +{ + return !(regs.ps & AF_INTERRUPT); +} + // #include "CPU/cpu_general.inl" diff --git a/source/CPU.h b/source/CPU.h index 98f58d0a..ca8e649d 100644 --- a/source/CPU.h +++ b/source/CPU.h @@ -42,3 +42,5 @@ eCpuType ProbeMainCpuDefault(eApple2Type apple2Type); void SetMainCpuDefault(eApple2Type apple2Type); eCpuType GetActiveCpu(void); void SetActiveCpu(eCpuType cpu); + +bool Is6502InterruptEnabled(void); diff --git a/source/Mockingboard.cpp b/source/Mockingboard.cpp index 8c660053..4f43297a 100644 --- a/source/Mockingboard.cpp +++ b/source/Mockingboard.cpp @@ -1797,7 +1797,7 @@ static bool CheckTimerUnderflowAndIrq(USHORT& timerCounter, int& timerIrqDelay, // Called by: // . CpuExecute() every ~1000 @ 1MHz -// . CheckInterruptSources() every 128 cycles +// . CheckInterruptSources() every opcode (or every 40 opcodes at full-speed) // . MB_Read() / MB_Write() void MB_UpdateCycles(ULONG uExecutedCycles) { @@ -1847,7 +1847,9 @@ void MB_UpdateCycles(ULONG uExecutedCycles) } else // GH#685: Multiple TIMER1 interrupts { - g_waitFirstAYWriteAfterTimer1Int = true; // Defer MB_Update() until MB_Write() + // Only allow when not in interrupt handler (ie. only allow when interrupts are enabled) + if (Is6502InterruptEnabled()) + g_waitFirstAYWriteAfterTimer1Int = true; // Defer MB_Update() until MB_Write() } if ((pMB->sy6522.ACR & RUNMODE) == RM_ONESHOT)