From a8de7f2030ddf6c9d560a667b3bc3f122769d029 Mon Sep 17 00:00:00 2001 From: tomcw Date: Fri, 29 Dec 2023 10:16:51 +0000 Subject: [PATCH] 6522: fix reading IRB - used as MB detection by Werewolf! (#1260) --- source/6522.cpp | 8 ++++---- source/6522.h | 1 + source/Mockingboard.cpp | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/source/6522.cpp b/source/6522.cpp index 16f7cc8c..d0a741b8 100644 --- a/source/6522.cpp +++ b/source/6522.cpp @@ -349,11 +349,11 @@ BYTE SY6522::Read(BYTE nReg) switch (nReg) { - case 0x00: // ORB - nValue = m_regs.ORB; + case 0x00: // IRB + nValue = m_regs.ORB | (m_regs.DDRB ^ 0xff); // Input bits read back as 1's (GH#1260) break; - case 0x01: // ORA - nValue = m_regs.ORA; + case 0x01: // IRA + nValue = m_regs.ORA; // NB. Inputs bits driven by AY8913 break; case 0x02: // DDRB nValue = m_regs.DDRB; diff --git a/source/6522.h b/source/6522.h index fae30944..508276a3 100644 --- a/source/6522.h +++ b/source/6522.h @@ -49,6 +49,7 @@ public: _ASSERT(0); return 0; } + BYTE GetBusViewOfORB(void) { return m_regs.ORB & m_regs.DDRB; } // Return how the AY8913 sees ORB on the bus (ie. not CPU's view which will be OR'd with !DDRB) USHORT GetRegT1C(void) { return m_regs.TIMER1_COUNTER.w; } USHORT GetRegT2C(void) { return m_regs.TIMER2_COUNTER.w; } void GetRegs(BYTE regs[SIZE_6522_REGS]) { memcpy(®s[0], (BYTE*)&m_regs, SIZE_6522_REGS); } // For debugger diff --git a/source/Mockingboard.cpp b/source/Mockingboard.cpp index 41c7375a..c37698f2 100644 --- a/source/Mockingboard.cpp +++ b/source/Mockingboard.cpp @@ -208,7 +208,7 @@ void MockingboardCard::Get6522IrqDescription(std::string& desc) void MockingboardCard::WriteToORB(BYTE subunit, BYTE subunitForAY/*=0*/) { - BYTE value = m_MBSubUnit[subunit].sy6522.Read(SY6522::rORB); + BYTE value = m_MBSubUnit[subunit].sy6522.GetBusViewOfORB(); if ((QueryType() == CT_MockingboardC || QueryType() == CT_Phasor) && // Not CT_MegaAudio/CT_SDMusic subunit == 0 && // SC01 only at $Cn00 (not $Cn80)