From 53fddfe41ab0d29d3080811600cd7e5abfb245a3 Mon Sep 17 00:00:00 2001 From: TomCh Date: Tue, 30 Jan 2024 20:48:34 +0100 Subject: [PATCH] Fix SD Music card for mb-audit v1.50 (PR #1275) . Fix for mb-audit's TestAYReadHiZ (bus-state wasn't being set correctly for SD Music's 6522 accessed via $Cs8x) --- source/Mockingboard.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/source/Mockingboard.cpp b/source/Mockingboard.cpp index 068e8dbe..f64e2dba 100644 --- a/source/Mockingboard.cpp +++ b/source/Mockingboard.cpp @@ -258,7 +258,10 @@ void MockingboardCard::WriteToORB(BYTE subunit, BYTE subunitForAY/*=0*/) { if ((value & 4) == 0) { - AY8913_Reset(subunit); + if (QueryType() == CT_SDMusic) + AY8913_Reset(subunitForAY); // to do: check that AYs can be independently reset + else + AY8913_Reset(subunit); return; } @@ -279,6 +282,9 @@ void MockingboardCard::AY8913_Reset(BYTE subunit) AY8910_reset(subunit, AY8913_DEVICE_B); // GH#1197: Reset both AYs regardless of Phasor mode & chip-select bits m_MBSubUnit[subunit].Reset(QueryType()); + + if (QueryType() == CT_SDMusic) + m_MBSubUnit[0].SetBusState(false); } void MockingboardCard::AY8913_Write(BYTE subunit, BYTE ay, BYTE value) @@ -286,6 +292,7 @@ void MockingboardCard::AY8913_Write(BYTE subunit, BYTE ay, BYTE value) m_regAccessedFlag = true; MB_SUBUNIT* pMB = &m_MBSubUnit[subunit]; SY6522& r6522 = (QueryType() != CT_SDMusic) ? pMB->sy6522 : m_MBSubUnit[0].sy6522; + bool busState = false; // Default: Mockingboard or Phasor(any mode) will read PortA inputs as high. // Determine the AY8913 inputs int nBDIR = (value & 2) ? 1 : 0; @@ -311,12 +318,11 @@ void MockingboardCard::AY8913_Write(BYTE subunit, BYTE ay, BYTE value) case AY_READ: // 5: READ FROM PSG (need to set DDRA to input) { - bool busState = true; // Initially default to true - if (pMB->isChipSelected[ay] && pMB->isAYLatchedAddressValid[ay]) + { r6522.SetRegIRA(AYReadReg(subunit, ay, pMB->nAYCurrentRegister[ay]) & (r6522.GetReg(SY6522::rDDRA) ^ 0xff)); - else - busState = false; + busState = true; + } if (m_phasorEnable && m_phasorMode == PH_Phasor) // GH#1192 { @@ -326,8 +332,6 @@ void MockingboardCard::AY8913_Write(BYTE subunit, BYTE ay, BYTE value) r6522.SetRegIRA(r6522.GetReg(SY6522::rORA) | (AYReadReg(subunit, AY8913_DEVICE_B, pMB->nAYCurrentRegister[AY8913_DEVICE_B]) & (r6522.GetReg(SY6522::rDDRA) ^ 0xff))); } } - - pMB->SetBusState(busState); } break; @@ -378,8 +382,10 @@ void MockingboardCard::AY8913_Write(BYTE subunit, BYTE ay, BYTE value) state = nAYFunc; - if (state == AY_INACTIVE) // Mockingboard or Phasor(any mode) will read PortA inputs as high. - pMB->SetBusState(false); + if (QueryType() == CT_SDMusic) + m_MBSubUnit[0].SetBusState(busState); + else + pMB->SetBusState(busState); } //-----------------------------------------------------------------------------