From 5ff43789ddd51cbe098a7699fb3852e47268b433 Mon Sep 17 00:00:00 2001 From: tomcw Date: Tue, 30 Jan 2024 18:22:45 +0000 Subject: [PATCH] Set busState for 6522-A for AY_INACTIVE state --- source/Mockingboard.cpp | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/source/Mockingboard.cpp b/source/Mockingboard.cpp index 9ebb6cf6..f64e2dba 100644 --- a/source/Mockingboard.cpp +++ b/source/Mockingboard.cpp @@ -292,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; @@ -317,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 { @@ -332,11 +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))); } } - - if (QueryType() != CT_SDMusic) - pMB->SetBusState(busState); - else - m_MBSubUnit[0].SetBusState(busState); } break; @@ -387,13 +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. - { - if (QueryType() != CT_SDMusic) - pMB->SetBusState(false); - else - m_MBSubUnit[0].SetBusState(false); - } + if (QueryType() == CT_SDMusic) + m_MBSubUnit[0].SetBusState(busState); + else + pMB->SetBusState(busState); } //-----------------------------------------------------------------------------