From cf722ff0ccaecc10154ae2a2f9a267fa237736fd Mon Sep 17 00:00:00 2001 From: tomcw Date: Sun, 29 Jan 2023 13:32:55 +0000 Subject: [PATCH] Fix so that MockingboardCardMgr asserts IRQ based on the wired-OR sum of all MB card's 6522s. (Fixes #1173) --- source/6522.cpp | 2 +- source/Mockingboard.cpp | 11 ++++------- source/Mockingboard.h | 2 +- source/MockingboardCardManager.cpp | 16 ++++++++++++++++ source/MockingboardCardManager.h | 1 + 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/source/6522.cpp b/source/6522.cpp index 5c43fc21..8922773d 100644 --- a/source/6522.cpp +++ b/source/6522.cpp @@ -128,7 +128,7 @@ void SY6522::UpdateIFR(BYTE clr_ifr, BYTE set_ifr /*= 0*/) m_regs.IFR &= ~IFR_IRQ; if (GetCardMgr().GetObj(m_slot)) // If called from MockingboardCard ctor, then CardManager::m_slot[slot] == NULL - dynamic_cast(GetCardMgr().GetRef(m_slot)).UpdateIRQ(); + GetCardMgr().GetMockingboardCardMgr().UpdateIRQ(); } //----------------------------------------------------------------------------- diff --git a/source/Mockingboard.cpp b/source/Mockingboard.cpp index 6738d1f8..86aa6879 100644 --- a/source/Mockingboard.cpp +++ b/source/Mockingboard.cpp @@ -288,13 +288,13 @@ void MockingboardCard::UpdateIFRandIRQ(MB_SUBUNIT* pMB, BYTE clr_mask, BYTE set_ //--------------------------------------------------------------------------- // Called from class SY6522 -void MockingboardCard::UpdateIRQ(void) +bool MockingboardCard::Is6522IRQ(void) { // Now update the IRQ signal from all 6522s // . OR-sum of all active TIMER1, TIMER2 & SPEECH sources (from all 6522s) - UINT bIRQ = 0; + bool irq = false; for (UINT i = 0; i < NUM_SUBUNITS_PER_MB; i++) - bIRQ |= m_MBSubUnit[i].sy6522.GetReg(SY6522::rIFR) & 0x80; + irq |= m_MBSubUnit[i].sy6522.GetReg(SY6522::rIFR) & 0x80 ? true : false; // NB. Mockingboard generates IRQ on both 6522s: // . SSI263's IRQ (A/!R) is routed via the 2nd 6522 (at $Cn80) and must generate a 6502 IRQ (not NMI) @@ -302,10 +302,7 @@ void MockingboardCard::UpdateIRQ(void) // . SC-01's IRQ (A/!R) is routed via the 6522 at $Cn00 (NB. Only the Mockingboard "Sound/Speech I" card supports the SC-01) // Phasor's SSI263 IRQ (A/!R) line is *also* wired directly to the 6502's IRQ (as well as the 6522's CA1) - if (bIRQ) - CpuIrqAssert(IS_6522); - else - CpuIrqDeassert(IS_6522); + return irq; } //--------------------------------------------------------------------------- diff --git a/source/Mockingboard.h b/source/Mockingboard.h index 081b5281..6299e8ef 100644 --- a/source/Mockingboard.h +++ b/source/Mockingboard.h @@ -43,7 +43,7 @@ public: void Get6522IrqDescription(std::string& desc); #endif - void UpdateIRQ(void); + bool Is6522IRQ(void); UINT64 GetLastCumulativeCycles(void); void UpdateIFR(BYTE nDevice, BYTE clr_mask, BYTE set_mask); BYTE GetPCR(BYTE nDevice); diff --git a/source/MockingboardCardManager.cpp b/source/MockingboardCardManager.cpp index 48935f09..c08bfded 100644 --- a/source/MockingboardCardManager.cpp +++ b/source/MockingboardCardManager.cpp @@ -32,6 +32,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "MockingboardCardManager.h" #include "Core.h" #include "CardManager.h" +#include "CPU.h" #include "Mockingboard.h" #include "MockingboardDefs.h" #include "Riff.h" @@ -108,6 +109,21 @@ void MockingboardCardManager::UpdateCycles(ULONG executedCycles) } } +void MockingboardCardManager::UpdateIRQ(void) +{ + bool irq = false; + for (UINT i = SLOT0; i < NUM_SLOTS; i++) + { + if (IsMockingboard(i)) + irq |= dynamic_cast(GetCardMgr().GetRef(i)).Is6522IRQ(); + } + + if (irq) + CpuIrqAssert(IS_6522); + else + CpuIrqDeassert(IS_6522); +} + bool MockingboardCardManager::IsActive(void) { if (!m_mockingboardVoice.bActive) diff --git a/source/MockingboardCardManager.h b/source/MockingboardCardManager.h index 10172d4e..8e6e7681 100644 --- a/source/MockingboardCardManager.h +++ b/source/MockingboardCardManager.h @@ -26,6 +26,7 @@ public: void MuteControl(bool mute); void SetCumulativeCycles(void); void UpdateCycles(ULONG executedCycles); + void UpdateIRQ(void); bool IsActive(void); DWORD GetVolume(void); void SetVolume(DWORD volume, DWORD volumeMax);