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)
This commit is contained in:
TomCh 2024-01-30 20:48:34 +01:00 committed by GitHub
parent fbc22fa566
commit 53fddfe41a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 9 deletions

View File

@ -258,7 +258,10 @@ void MockingboardCard::WriteToORB(BYTE subunit, BYTE subunitForAY/*=0*/)
{ {
if ((value & 4) == 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; 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 AY8910_reset(subunit, AY8913_DEVICE_B); // GH#1197: Reset both AYs regardless of Phasor mode & chip-select bits
m_MBSubUnit[subunit].Reset(QueryType()); m_MBSubUnit[subunit].Reset(QueryType());
if (QueryType() == CT_SDMusic)
m_MBSubUnit[0].SetBusState(false);
} }
void MockingboardCard::AY8913_Write(BYTE subunit, BYTE ay, BYTE value) 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; m_regAccessedFlag = true;
MB_SUBUNIT* pMB = &m_MBSubUnit[subunit]; MB_SUBUNIT* pMB = &m_MBSubUnit[subunit];
SY6522& r6522 = (QueryType() != CT_SDMusic) ? pMB->sy6522 : m_MBSubUnit[0].sy6522; 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 // Determine the AY8913 inputs
int nBDIR = (value & 2) ? 1 : 0; 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) 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]) if (pMB->isChipSelected[ay] && pMB->isAYLatchedAddressValid[ay])
{
r6522.SetRegIRA(AYReadReg(subunit, ay, pMB->nAYCurrentRegister[ay]) & (r6522.GetReg(SY6522::rDDRA) ^ 0xff)); r6522.SetRegIRA(AYReadReg(subunit, ay, pMB->nAYCurrentRegister[ay]) & (r6522.GetReg(SY6522::rDDRA) ^ 0xff));
else busState = true;
busState = false; }
if (m_phasorEnable && m_phasorMode == PH_Phasor) // GH#1192 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))); 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; break;
@ -378,8 +382,10 @@ void MockingboardCard::AY8913_Write(BYTE subunit, BYTE ay, BYTE value)
state = nAYFunc; state = nAYFunc;
if (state == AY_INACTIVE) // Mockingboard or Phasor(any mode) will read PortA inputs as high. if (QueryType() == CT_SDMusic)
pMB->SetBusState(false); m_MBSubUnit[0].SetBusState(busState);
else
pMB->SetBusState(busState);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------