From ed9b70c108e765bda8ac5f2d692f8a8d97677151 Mon Sep 17 00:00:00 2001 From: tomcw Date: Mon, 24 Nov 2025 20:49:49 +0000 Subject: [PATCH] VidHD: permit in any slot --- source/CardManager.cpp | 12 +++++++----- source/CardManager.h | 3 +++ source/Memory.cpp | 20 ++++++++++---------- source/Video.cpp | 4 ++-- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/source/CardManager.cpp b/source/CardManager.cpp index e18be6a5..8fe2b041 100644 --- a/source/CardManager.cpp +++ b/source/CardManager.cpp @@ -111,7 +111,9 @@ void CardManager::InsertInternal(UINT slot, SS_CARDTYPE type) m_slot[slot] = new SNESMAXCard(slot); break; case CT_VidHD: - m_slot[slot] = new VidHDCard(slot); + _ASSERT(m_pVidHDCard == NULL); + if (m_pVidHDCard) break; // Only support one VidHD card + m_slot[slot] = m_pVidHDCard = new VidHDCard(slot); break; case CT_Uthernet2: m_slot[slot] = new Uthernet2(slot); @@ -177,6 +179,9 @@ void CardManager::RemoveInternal(UINT slot) if (slot == SLOT0) GetLanguageCardMgr().SetLanguageCard(CT_Empty); break; + case CT_VidHD: + m_pVidHDCard = NULL; + break; case CT_Z80: m_pZ80Card = NULL; break; @@ -369,7 +374,7 @@ void CardManager::GetCardChoicesForSlot(const UINT slot, const SS_CARDTYPE currC // (continue with alphabetic) CT_Uthernet, CT_Uthernet2, - CT_VidHD, // Slot 3 only + CT_VidHD, CT_Z80, // CT_GenericClock, // CT_Echo, @@ -409,9 +414,6 @@ void CardManager::GetCardChoicesForSlot(const UINT slot, const SS_CARDTYPE currC { const SS_CARDTYPE thisCard = cards[i]; - if (thisCard == CT_VidHD && slot != SLOT3) - continue; - // Prevent both Uthernet & Uthernet2 cards being plugged in at the same time if (thisCard == CT_Uthernet && haveCard[CT_Uthernet2] != kInvalidSlot && haveCard[CT_Uthernet2] != slot) continue; // Already have a Uthernet2 card selected in another slot, so prevent Uthernet diff --git a/source/CardManager.h b/source/CardManager.h index 03cec4ef..5a4172e2 100644 --- a/source/CardManager.h +++ b/source/CardManager.h @@ -13,6 +13,7 @@ public: m_pMouseCard(NULL), m_pSSC(NULL), m_pParallelPrinterCard(NULL), + m_pVidHDCard(NULL), m_pZ80Card(NULL) { // LoadConfiguration() now sets up default cards for a new install @@ -62,6 +63,7 @@ public: bool IsSSCInstalled(void) { return m_pSSC != NULL; } class ParallelPrinterCard* GetParallelPrinterCard(void) { return m_pParallelPrinterCard; } bool IsParallelPrinterCardInstalled(void) { return m_pParallelPrinterCard != NULL; } + class VidHDCard* GetVidHDCard(void) { return m_pVidHDCard; } void GetCardChoicesForSlot(const UINT slot, const SS_CARDTYPE currConfig[NUM_SLOTS], std::string& choices, std::vector& choicesList); void InitializeIO(LPBYTE pCxRomPeripheral); @@ -85,5 +87,6 @@ private: class CMouseInterface* m_pMouseCard; class CSuperSerialCard* m_pSSC; class ParallelPrinterCard* m_pParallelPrinterCard; + class VidHDCard* m_pVidHDCard; class Z80Card* m_pZ80Card; }; diff --git a/source/Memory.cpp b/source/Memory.cpp index 803c4cb7..09b1f6d9 100644 --- a/source/Memory.cpp +++ b/source/Memory.cpp @@ -615,7 +615,7 @@ static BYTE __stdcall IORead_C02x(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG static BYTE __stdcall IOWrite_C02x(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles) { - if (GetCardMgr().QuerySlot(SLOT3) == CT_VidHD) + if (GetCardMgr().GetVidHDCard()) { if (addr == 0xC022 || addr == 0xC029) GetVideo().VideoSetMode(pc, addr, bWrite, d, nExecutedCycles); @@ -633,7 +633,7 @@ static BYTE __stdcall IORead_C03x(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG static BYTE __stdcall IOWrite_C03x(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles) { - if (GetCardMgr().QuerySlot(SLOT3) == CT_VidHD) + if (GetCardMgr().GetVidHDCard()) { // NB. Writes to $C03x addresses will still toggle the speaker, even with a VidHD present if (addr == 0xC034 || addr == 0xC035) @@ -2258,12 +2258,12 @@ void MemInitializeFromSnapshot(void) memVidHD = NULL; - if ((GetCardMgr().QuerySlot(SLOT3) == CT_VidHD)) + if (GetCardMgr().GetVidHDCard()) { if (IsApple2PlusOrClone(GetApple2Type()) || IsIIeWithoutAuxMem()) { - VidHDCard& vidHD = dynamic_cast(GetCardMgr().GetRef(SLOT3)); - memVidHD = vidHD.IsWriteAux() ? memaux : NULL; + VidHDCard* vidHD = GetCardMgr().GetVidHDCard(); + memVidHD = vidHD->IsWriteAux() ? memaux : NULL; } } } @@ -2550,7 +2550,7 @@ BYTE __stdcall MemSetPaging(WORD programcounter, WORD address, BYTE write, BYTE #endif } - if (GetCardMgr().QuerySlot(SLOT3) == CT_VidHD && GetCardMgr().QueryAux() == CT_80Col) + if (GetCardMgr().GetVidHDCard() && GetCardMgr().QueryAux() == CT_80Col) { // NB. if aux slot is empty, then writes already occur to memaux memVidHD = MemIsWriteAux(g_memmode) ? memaux : NULL; @@ -2558,11 +2558,11 @@ BYTE __stdcall MemSetPaging(WORD programcounter, WORD address, BYTE write, BYTE } else // Apple ][,][+,][J-Plus or clone ][,][+ { - if (GetCardMgr().QuerySlot(SLOT3) == CT_VidHD) + if (GetCardMgr().GetVidHDCard()) { - VidHDCard& vidHD = dynamic_cast(GetCardMgr().GetRef(SLOT3)); - vidHD.VideoIOWrite(programcounter, address, write, value, nExecutedCycles); - memVidHD = vidHD.IsWriteAux() ? memaux : NULL; + VidHDCard* vidHD = GetCardMgr().GetVidHDCard(); + vidHD->VideoIOWrite(programcounter, address, write, value, nExecutedCycles); + memVidHD = vidHD->IsWriteAux() ? memaux : NULL; } } diff --git a/source/Video.cpp b/source/Video.cpp index d2e65e01..538578b0 100644 --- a/source/Video.cpp +++ b/source/Video.cpp @@ -179,8 +179,8 @@ BYTE Video::VideoSetMode(WORD pc, WORD address, BYTE write, BYTE d, ULONG uExecu const uint32_t oldVideoMode = g_uVideoMode; VidHDCard* vidHD = NULL; - if (GetCardMgr().QuerySlot(SLOT3) == CT_VidHD) - vidHD = dynamic_cast(GetCardMgr().GetObj(SLOT3)); + if (GetCardMgr().GetVidHDCard()) + vidHD = dynamic_cast(GetCardMgr().GetVidHDCard()); address &= 0xFF; switch (address)