From 89eb0cb07b229e9edf6e03db7a26c3bdee5fc28c Mon Sep 17 00:00:00 2001 From: tomcw Date: Wed, 1 Mar 2023 21:01:59 +0000 Subject: [PATCH] Mockingboard: After AY is reset, then latched addr isn't valid . Save-state: save all 8 bits of latched addr. . Debugger: for mini-AY dump, show latched addr (current register shown in white) --- source/Debugger/Debugger_Display.cpp | 18 ++++++++++++++---- source/Mockingboard.cpp | 16 ++++++++++++---- source/Mockingboard.h | 6 ++++-- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/source/Debugger/Debugger_Display.cpp b/source/Debugger/Debugger_Display.cpp index bf40598e..2ce9b0be 100644 --- a/source/Debugger/Debugger_Display.cpp +++ b/source/Debugger/Debugger_Display.cpp @@ -2094,11 +2094,21 @@ void DrawMemory ( int line, int iMemDump ) { if (SS_MB.Hdr.UnitHdr.hdr.v2.Type == UT_Card) { - sText = StrFormat("%02X ", (unsigned)SS_MB.Unit[nAddr & 1].RegsAY8910[iAddress]); - if (iCol & 1) - DebuggerSetColorFG(DebuggerGetColor(iForeground)); + if (iAddress <= 13) + sText = StrFormat("%02X ", (unsigned)SS_MB.Unit[nAddr & 1].RegsAY8910[iAddress]); else - DebuggerSetColorFG(DebuggerGetColor(FG_INFO_ADDRESS)); + sText = "-- "; // regs 14 & 15 aren't supported by AY-3-8913 + if (SS_MB.Unit[nAddr & 1].nAYCurrentRegister == iAddress) + { + DebuggerSetColorFG(DebuggerGetColor(FG_INFO_TITLE)); // if latched address then draw in white + } + else + { + if (iCol & 1) + DebuggerSetColorFG(DebuggerGetColor(iForeground)); + else + DebuggerSetColorFG(DebuggerGetColor(FG_INFO_ADDRESS)); + } } else { diff --git a/source/Mockingboard.cpp b/source/Mockingboard.cpp index 92f432a8..4d29e927 100644 --- a/source/Mockingboard.cpp +++ b/source/Mockingboard.cpp @@ -240,6 +240,9 @@ void MockingboardCard::AY8910_Write(BYTE subunit, BYTE ay, BYTE value) { // RESET: Reset AY8910 only AY8910_reset(subunit, ay); + pMB->nAYCurrentRegister = 0; // not valid + pMB->state = pMB->stateB = AY_INACTIVE; + pMB->isAYLatchedAddressValid[0] = pMB->isAYLatchedAddressValid[1] = false; } else { @@ -270,7 +273,9 @@ void MockingboardCard::AY8910_Write(BYTE subunit, BYTE ay, BYTE value) break; case AY_WRITE: // 6: WRITE TO PSG - _AYWriteReg(subunit, ay, pMB->nAYCurrentRegister, r6522.GetReg(SY6522::rORA)); + if (pMB->isAYLatchedAddressValid[ay]) + _AYWriteReg(subunit, ay, pMB->nAYCurrentRegister, r6522.GetReg(SY6522::rORA)); + // else if invalid then just ignore break; case AY_LATCH: // 7: LATCH ADDRESS @@ -279,7 +284,10 @@ void MockingboardCard::AY8910_Write(BYTE subunit, BYTE ay, BYTE value) // any values written to the data/address bus are ignored, but can be read back // within a few tens of thousands of cycles before they decay to zero. if (r6522.GetReg(SY6522::rORA) <= 0x0F) + { pMB->nAYCurrentRegister = r6522.GetReg(SY6522::rORA) & 0x0F; + pMB->isAYLatchedAddressValid[ay] = true; + } // else Pro-Mockingboard (clone from HK) break; } @@ -929,7 +937,7 @@ void MockingboardCard::GetSnapshot_v1(SS_CARD_MOCKINGBOARD_v1* const pSS) } memset(&pSS->Unit[i].RegsSSI263, 0, sizeof(SSI263A)); // Not used by debugger - pSS->Unit[i].nAYCurrentRegister = pMB->nAYCurrentRegister; + pSS->Unit[i].nAYCurrentRegister = pMB->isAYLatchedAddressValid[0] ? pMB->nAYCurrentRegister : 0xff; pSS->Unit[i].bTimer1Active = pMB->sy6522.IsTimer1Active(); pSS->Unit[i].bTimer2Active = pMB->sy6522.IsTimer2Active(); pSS->Unit[i].bSpeechIrqPending = false; @@ -1092,7 +1100,7 @@ void MockingboardCard::SaveSnapshot(YamlSaveHelper& yamlSaveHelper) pMB->ssi263.SaveSnapshot(yamlSaveHelper); yamlSaveHelper.SaveHexUint4(SS_YAML_KEY_MB_UNIT_STATE, pMB->state); - yamlSaveHelper.SaveHexUint4(SS_YAML_KEY_AY_CURR_REG, pMB->nAYCurrentRegister); + yamlSaveHelper.SaveHexUint8(SS_YAML_KEY_AY_CURR_REG, pMB->nAYCurrentRegister); // save all 8 bits (even though top 4 bits should be 0) } } @@ -1185,7 +1193,7 @@ void MockingboardCard::Phasor_SaveSnapshot(YamlSaveHelper& yamlSaveHelper) yamlSaveHelper.SaveHexUint4(SS_YAML_KEY_MB_UNIT_STATE, pMB->state); yamlSaveHelper.SaveHexUint4(SS_YAML_KEY_MB_UNIT_STATE_B, pMB->stateB); - yamlSaveHelper.SaveHexUint4(SS_YAML_KEY_AY_CURR_REG, pMB->nAYCurrentRegister); + yamlSaveHelper.SaveHexUint8(SS_YAML_KEY_AY_CURR_REG, pMB->nAYCurrentRegister); // save all 8 bits (even though top 4 bits should be 0) } } diff --git a/source/Mockingboard.h b/source/Mockingboard.h index 6299e8ef..7400902a 100644 --- a/source/Mockingboard.h +++ b/source/Mockingboard.h @@ -66,13 +66,15 @@ private: BYTE nAYCurrentRegister; MockingboardUnitState_e state; // Where a unit is a 6522+AY8910 pair MockingboardUnitState_e stateB; // Phasor: 6522 & 2nd AY8910 + bool isAYLatchedAddressValid[2]; MB_SUBUNIT(UINT slot) : sy6522(slot), ssi263(slot) { nAY8910Number = 0; nAYCurrentRegister = 0; - state = AY_NOP0; - stateB = AY_NOP0; + state = AY_INACTIVE; + stateB = AY_INACTIVE; + isAYLatchedAddressValid[0] = isAYLatchedAddressValid[1] = false; // after AY reset // sy6522 & ssi263 have already been default constructed } };