From d896e1cec22f1a871110db438c049734f14998eb Mon Sep 17 00:00:00 2001 From: tomcw Date: Mon, 18 Nov 2024 21:27:56 +0000 Subject: [PATCH] MB: Fix for SSI263 phoneme blocking enhanced disk II full-speed mode. (Fixes #1340) --- source/Mockingboard.cpp | 19 ++++++++++++++++--- source/Mockingboard.h | 2 +- source/MockingboardCardManager.cpp | 4 ++-- source/MockingboardCardManager.h | 2 +- source/SSI263.cpp | 9 +++++++-- source/SSI263.h | 8 +++++++- source/Windows/AppleWin.cpp | 2 +- 7 files changed, 35 insertions(+), 11 deletions(-) diff --git a/source/Mockingboard.cpp b/source/Mockingboard.cpp index 375c8783..30d21541 100644 --- a/source/Mockingboard.cpp +++ b/source/Mockingboard.cpp @@ -998,20 +998,33 @@ int MockingboardCard::MB_SyncEventCallbackInternal(int id, int /*cycles*/, ULONG //----------------------------------------------------------------------------- -bool MockingboardCard::IsActive(void) +bool MockingboardCard::IsActive(const bool isFullSpeedCheck) { + // Full-speed check ignores SSI263::IsPhonemeActive(), because: + // . Once an SSI263 has started playing a phoneme (and the chip isn't powered-down) then it'll repeat it indefinitely. + // . Typically a SSI263 is "disabled" by disabling ints & setting phoneme=PAUSE(0x00) and leaving the chip powered-up. + // . So if we also checked SSI263::IsPhonemeActive(), then it'd always report the SSI263 as active, and so prohibit full-speed. + if (isFullSpeedCheck) + return m_isActive; + + // Currently this codepath isn't taken - ie. isFullSpeedCheck==false (so remove this codepath for now) +#if 1 + _ASSERT(0); + return m_isActive; +#else bool isSSI263Active = false; - for (UINT i = 0; i (GetCardMgr().GetRef(i)).IsActive()) + if (dynamic_cast(GetCardMgr().GetRef(i)).IsActive(isFullSpeedCheck)) return true; // if any card is true then the condition for active is true } diff --git a/source/MockingboardCardManager.h b/source/MockingboardCardManager.h index 36f4777c..7d18273e 100644 --- a/source/MockingboardCardManager.h +++ b/source/MockingboardCardManager.h @@ -29,7 +29,7 @@ public: void SetCumulativeCycles(void); void UpdateCycles(ULONG executedCycles); void UpdateIRQ(void); - bool IsActive(void); + bool IsActive(const bool isFullSpeedCheck); DWORD GetVolume(void); void SetVolume(DWORD volume, DWORD volumeMax); void OutputToRiff(void) { m_outputToRiff = true; } diff --git a/source/SSI263.cpp b/source/SSI263.cpp index b2e2875a..d687872c 100644 --- a/source/SSI263.cpp +++ b/source/SSI263.cpp @@ -417,7 +417,7 @@ void SSI263::Update(void) if (!SSI263SingleVoice.bActive) return; - if (g_bFullSpeed) // ie. only true when IsPhonemeActive() is true + if (g_bFullSpeed) // NB. if true, then it's irrespective of IsPhonemeActive() { if (m_phonemeLengthRemaining) { @@ -697,9 +697,14 @@ void SSI263::Update(void) if (m_phonemeLeadoutLength == 0) { if (!m_isVotraxPhoneme) - Play(m_durationPhoneme & PHONEME_MASK); // Repeat this phoneme again + { + if ((m_ctrlArtAmp & CONTROL_MASK) == 0) + Play(m_durationPhoneme & PHONEME_MASK); // Repeat this phoneme again + } // else // GH#1318 - remove for now, as TR v5.1 can start with repeating phoneme in debugger 'g' mode! +// { // Play(m_Votrax2SSI263[m_votraxPhoneme]); // Votrax phoneme repeats too (tested in MAME 0.262) +// } } } diff --git a/source/SSI263.h b/source/SSI263.h index a153428f..13b3720a 100644 --- a/source/SSI263.h +++ b/source/SSI263.h @@ -74,7 +74,13 @@ public: void DSUninit(void); void Reset(const bool powerCycle, const bool isPhasorCard); - bool IsPhonemeActive(void) { return m_currentActivePhoneme >= 0; } + bool IsPhonemeActive(void) + { + if (!m_isVotraxPhoneme) + return (m_ctrlArtAmp & CONTROL_MASK) == 0 && m_currentActivePhoneme >= 0; + else + return m_currentActivePhoneme >= 0; + } BYTE Read(ULONG nExecutedCycles); void Write(BYTE nReg, BYTE nValue); diff --git a/source/Windows/AppleWin.cpp b/source/Windows/AppleWin.cpp index ab6d1a08..7b50920f 100644 --- a/source/Windows/AppleWin.cpp +++ b/source/Windows/AppleWin.cpp @@ -179,7 +179,7 @@ static void ContinueExecution(void) const bool bWasFullSpeed = g_bFullSpeed; g_bFullSpeed = (g_dwSpeed == SPEED_MAX) || bScrollLock_FullSpeed || - (GetCardMgr().GetDisk2CardMgr().IsConditionForFullSpeed() && !Spkr_IsActive() && !GetCardMgr().GetMockingboardCardMgr().IsActive()) || + (GetCardMgr().GetDisk2CardMgr().IsConditionForFullSpeed() && !Spkr_IsActive() && !GetCardMgr().GetMockingboardCardMgr().IsActive(true)) || IsDebugSteppingAtFullSpeed(); if (g_bFullSpeed)