diff --git a/source/Applewin.cpp b/source/Applewin.cpp index 96141144..de6ce2e6 100644 --- a/source/Applewin.cpp +++ b/source/Applewin.cpp @@ -110,7 +110,6 @@ bool g_bDisableDirectSound = false; bool g_bDisableDirectSoundMockingboard = false; int g_nMemoryClearType = MIP_FF_FF_00_00; // Note: -1 = random MIP in Memory.cpp MemReset() -CardManager g_CardMgr; IPropertySheet& sg_PropertySheet = * new CPropertySheet; SynchronousEventManager g_SynchronousEventMgr; @@ -235,6 +234,12 @@ bool GetHookAltGrControl(void) return g_bHookAltGrControl; } +CardManager& GetCardMgr(void) +{ + static CardManager g_CardMgr; // singleton + return g_CardMgr; +} + static void ResetToLogoMode(void) { g_nAppMode = MODE_LOGO; @@ -321,7 +326,7 @@ static void ContinueExecution(void) const bool bWasFullSpeed = g_bFullSpeed; g_bFullSpeed = (g_dwSpeed == SPEED_MAX) || bScrollLock_FullSpeed || - (g_CardMgr.GetDisk2CardMgr().IsConditionForFullSpeed() && !Spkr_IsActive() && !MB_IsActive()) || + (GetCardMgr().GetDisk2CardMgr().IsConditionForFullSpeed() && !Spkr_IsActive() && !MB_IsActive()) || IsDebugSteppingAtFullSpeed(); if (g_bFullSpeed) @@ -368,7 +373,7 @@ static void ContinueExecution(void) const DWORD uActualCyclesExecuted = CpuExecute(uCyclesToExecute, bVideoUpdate); g_dwCyclesThisFrame += uActualCyclesExecuted; - g_CardMgr.GetDisk2CardMgr().UpdateDriveState(uActualCyclesExecuted); + GetCardMgr().GetDisk2CardMgr().UpdateDriveState(uActualCyclesExecuted); JoyUpdateButtonLatch(nExecutionPeriodUsec); // Button latch time is independent of CPU clock frequency PrintUpdate(uActualCyclesExecuted); MB_PeriodicUpdate(uActualCyclesExecuted); @@ -702,8 +707,8 @@ void LoadConfiguration(void) serialPortName, CSuperSerialCard::SIZEOF_SERIALCHOICE_ITEM)) { - if (g_CardMgr.IsSSCInstalled()) - g_CardMgr.GetSSC()->SetSerialPortName(serialPortName); + if (GetCardMgr().IsSSCInstalled()) + GetCardMgr().GetSSC()->SetSerialPortName(serialPortName); } REGLOAD_DEFAULT(TEXT(REGVALUE_EMULATION_SPEED), &g_dwSpeed, SPEED_NORMAL); @@ -712,7 +717,7 @@ void LoadConfiguration(void) DWORD dwEnhanceDisk; REGLOAD_DEFAULT(TEXT(REGVALUE_ENHANCE_DISK_SPEED), &dwEnhanceDisk, 1); - g_CardMgr.GetDisk2CardMgr().SetEnhanceDisk(dwEnhanceDisk ? true : false); + GetCardMgr().GetDisk2CardMgr().SetEnhanceDisk(dwEnhanceDisk ? true : false); // @@ -773,9 +778,9 @@ void LoadConfiguration(void) sg_PropertySheet.SetMouseRestrictToWindow(dwTmp); if(REGLOAD(TEXT(REGVALUE_SLOT4), &dwTmp)) - g_CardMgr.Insert(4, (SS_CARDTYPE)dwTmp); + GetCardMgr().Insert(4, (SS_CARDTYPE)dwTmp); if(REGLOAD(TEXT(REGVALUE_SLOT5), &dwTmp)) - g_CardMgr.Insert(5, (SS_CARDTYPE)dwTmp); + GetCardMgr().Insert(5, (SS_CARDTYPE)dwTmp); // @@ -797,7 +802,7 @@ void LoadConfiguration(void) GetCurrentDirectory(sizeof(szFilename), szFilename); SetCurrentImageDir(szFilename); - g_CardMgr.GetDisk2CardMgr().LoadLastDiskImage(); + GetCardMgr().GetDisk2CardMgr().LoadLastDiskImage(); // @@ -1169,7 +1174,7 @@ static void SetCurrentDir(std::string pathname) static bool DoDiskInsert(const UINT slot, const int nDrive, LPCSTR szFileName) { - Disk2InterfaceCard& disk2Card = dynamic_cast(g_CardMgr.GetRef(slot)); + Disk2InterfaceCard& disk2Card = dynamic_cast(GetCardMgr().GetRef(slot)); std::string strPathName = GetFullPath(szFileName); if (strPathName.empty()) return false; @@ -1417,7 +1422,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) MB_Reset(); LogFileOutput("Main: MB_Reset()\n"); - CMouseInterface* pMouseCard = g_CardMgr.GetMouseCard(); + CMouseInterface* pMouseCard = GetCardMgr().GetMouseCard(); if (pMouseCard) { pMouseCard->Reset(); // Deassert any pending IRQs - GH#514 @@ -1742,8 +1747,8 @@ static bool ProcessCmdLine(LPSTR lpCmdLine) } else if ((strcmp(lpCmdLine, "-dcd") == 0) || (strcmp(lpCmdLine, "-modem") == 0)) // GH#386 { - if (g_CardMgr.IsSSCInstalled()) - g_CardMgr.GetSSC()->SupportDCD(true); + if (GetCardMgr().IsSSCInstalled()) + GetCardMgr().GetSSC()->SupportDCD(true); } else if (strcmp(lpCmdLine, "-alt-enter=toggle-full-screen") == 0) // GH#556 { @@ -2058,23 +2063,23 @@ static void RepeatInitialization(void) // NB. this state is not persisted to the Registry/conf.ini (just as '-s7 empty' isn't) // TODO: support bSlotEmpty[] for slots: 0,4,5 if (g_cmdLine.bSlotEmpty[SLOT1]) - g_CardMgr.Remove(SLOT1); + GetCardMgr().Remove(SLOT1); if (g_cmdLine.bSlotEmpty[SLOT2]) - g_CardMgr.Remove(SLOT2); + GetCardMgr().Remove(SLOT2); if (g_cmdLine.bSlotEmpty[SLOT3]) - g_CardMgr.Remove(SLOT3); + GetCardMgr().Remove(SLOT3); if (g_cmdLine.bSlotEmpty[SLOT6]) - g_CardMgr.Remove(SLOT6); + GetCardMgr().Remove(SLOT6); if (g_cmdLine.slotInsert[SLOT5] != CT_Empty) { - if (g_CardMgr.QuerySlot(SLOT4) == CT_MockingboardC && g_cmdLine.slotInsert[SLOT5] != CT_MockingboardC) // Currently MB occupies slot4+5 when enabled + if (GetCardMgr().QuerySlot(SLOT4) == CT_MockingboardC && g_cmdLine.slotInsert[SLOT5] != CT_MockingboardC) // Currently MB occupies slot4+5 when enabled { - g_CardMgr.Remove(SLOT4); - g_CardMgr.Remove(SLOT5); + GetCardMgr().Remove(SLOT4); + GetCardMgr().Remove(SLOT5); } - g_CardMgr.Insert(SLOT5, g_cmdLine.slotInsert[SLOT5]); + GetCardMgr().Insert(SLOT5, g_cmdLine.slotInsert[SLOT5]); } // Pre: may need g_hFrameWindow for MessageBox errors @@ -2126,7 +2131,7 @@ static void RepeatInitialization(void) } // Need to test if it's safe to call ResetMachineState(). In the meantime, just call Disk2Card's Reset(): - g_CardMgr.GetDisk2CardMgr().Reset(true); // Switch from a booting A][+ to a non-autostart A][, so need to turn off floppy motor + GetCardMgr().GetDisk2CardMgr().Reset(true); // Switch from a booting A][+ to a non-autostart A][, so need to turn off floppy motor LogFileOutput("Main: DiskReset()\n"); HD_Reset(); // GH#515 LogFileOutput("Main: HDDReset()\n"); diff --git a/source/Applewin.h b/source/Applewin.h index 34c8f1d3..18f12e8a 100644 --- a/source/Applewin.h +++ b/source/Applewin.h @@ -52,7 +52,7 @@ extern bool g_bDisableDirectSound; // Cmd line switch: don't init DS (s extern bool g_bDisableDirectSoundMockingboard; // Cmd line switch: don't init MB support extern int g_nMemoryClearType; // Cmd line switch: use specific MIP (Memory Initialization Pattern) -extern class CardManager g_CardMgr; +extern class CardManager& GetCardMgr(void); extern class SynchronousEventManager g_SynchronousEventMgr; extern HANDLE g_hCustomRomF8; // INVALID_HANDLE_VALUE if no custom F8 rom diff --git a/source/Configuration/Config.h b/source/Configuration/Config.h index 2acb64b4..c9d9830c 100644 --- a/source/Configuration/Config.h +++ b/source/Configuration/Config.h @@ -20,9 +20,9 @@ public: m_bEnableTheFreezesF8Rom = bEnableTheFreezesF8Rom; memset(&m_Slot, 0, sizeof(m_Slot)); m_SlotAux = CT_Empty; - m_Slot[SLOT4] = g_CardMgr.QuerySlot(SLOT4); - m_Slot[SLOT5] = g_CardMgr.QuerySlot(SLOT5); - m_Slot[SLOT7] = g_CardMgr.QuerySlot(SLOT7); + m_Slot[SLOT4] = GetCardMgr().QuerySlot(SLOT4); + m_Slot[SLOT5] = GetCardMgr().QuerySlot(SLOT5); + m_Slot[SLOT7] = GetCardMgr().QuerySlot(SLOT7); } const CConfigNeedingRestart& operator= (const CConfigNeedingRestart& other) diff --git a/source/Configuration/PageConfig.cpp b/source/Configuration/PageConfig.cpp index 929a6796..847301b0 100644 --- a/source/Configuration/PageConfig.cpp +++ b/source/Configuration/PageConfig.cpp @@ -206,9 +206,9 @@ BOOL CPageConfig::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM CheckDlgButton(hWnd, IDC_CHECK_VERTICAL_BLEND, IsVideoStyle(VS_COLOR_VERTICAL_BLEND) ? BST_CHECKED : BST_UNCHECKED); EnableWindow(GetDlgItem(hWnd, IDC_CHECK_VERTICAL_BLEND), (GetVideoType() == VT_COLOR_MONITOR_RGB) ? TRUE : FALSE); - if (g_CardMgr.IsSSCInstalled()) + if (GetCardMgr().IsSSCInstalled()) { - CSuperSerialCard* pSSC = g_CardMgr.GetSSC(); + CSuperSerialCard* pSSC = GetCardMgr().GetSSC(); m_PropertySheetHelper.FillComboBox(hWnd, IDC_SERIALPORT, pSSC->GetSerialPortChoices(), pSSC->GetSerialPort()); EnableWindow(GetDlgItem(hWnd, IDC_SERIALPORT), !pSSC->IsActive() ? TRUE : FALSE); } @@ -344,9 +344,9 @@ void CPageConfig::DlgOK(HWND hWnd) // - if (g_CardMgr.IsSSCInstalled()) + if (GetCardMgr().IsSSCInstalled()) { - CSuperSerialCard* pSSC = g_CardMgr.GetSSC(); + CSuperSerialCard* pSSC = GetCardMgr().GetSSC(); const DWORD uNewSerialPort = (DWORD) SendDlgItemMessage(hWnd, IDC_SERIALPORT, CB_GETCURSEL, 0, 0); pSSC->CommSetSerialPort(hWnd, uNewSerialPort); RegSaveString( TEXT(REG_CONFIG), diff --git a/source/Configuration/PageDisk.cpp b/source/Configuration/PageDisk.cpp index 424bdd58..2f8b1c64 100644 --- a/source/Configuration/PageDisk.cpp +++ b/source/Configuration/PageDisk.cpp @@ -131,9 +131,9 @@ BOOL CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM l case WM_INITDIALOG: { - m_PropertySheetHelper.FillComboBox(hWnd, IDC_DISKTYPE, m_discchoices, g_CardMgr.GetDisk2CardMgr().GetEnhanceDisk() ? 1 : 0); + m_PropertySheetHelper.FillComboBox(hWnd, IDC_DISKTYPE, m_discchoices, GetCardMgr().GetDisk2CardMgr().GetEnhanceDisk() ? 1 : 0); - if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) + if (GetCardMgr().QuerySlot(SLOT6) == CT_Disk2) InitComboFloppyDrive(hWnd, SLOT6); else EnableFloppyDrive(hWnd, FALSE); @@ -160,7 +160,7 @@ BOOL CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM l void CPageDisk::InitComboFloppyDrive(HWND hWnd, UINT slot) { - Disk2InterfaceCard& disk2Card = dynamic_cast(g_CardMgr.GetRef(slot)); + Disk2InterfaceCard& disk2Card = dynamic_cast(GetCardMgr().GetRef(slot)); m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK1, m_defaultDiskOptions, -1); m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK2, m_defaultDiskOptions, -1); @@ -199,9 +199,9 @@ void CPageDisk::InitComboHDD(HWND hWnd, UINT /*slot*/) void CPageDisk::DlgOK(HWND hWnd) { const bool bNewEnhanceDisk = SendDlgItemMessage(hWnd, IDC_DISKTYPE,CB_GETCURSEL, 0, 0) ? true : false; - if (bNewEnhanceDisk != g_CardMgr.GetDisk2CardMgr().GetEnhanceDisk()) + if (bNewEnhanceDisk != GetCardMgr().GetDisk2CardMgr().GetEnhanceDisk()) { - g_CardMgr.GetDisk2CardMgr().SetEnhanceDisk(bNewEnhanceDisk); + GetCardMgr().GetDisk2CardMgr().SetEnhanceDisk(bNewEnhanceDisk); REGSAVE(TEXT(REGVALUE_ENHANCE_DISK_SPEED), (DWORD)bNewEnhanceDisk); } @@ -302,13 +302,13 @@ void CPageDisk::HandleHDDCombo(HWND hWnd, UINT driveSelected, UINT comboSelected void CPageDisk::HandleFloppyDriveCombo(HWND hWnd, UINT driveSelected, UINT comboSelected) { - if (g_CardMgr.QuerySlot(SLOT6) != CT_Disk2) + if (GetCardMgr().QuerySlot(SLOT6) != CT_Disk2) { _ASSERT(0); // Shouldn't come here, as the combo is disabled return; } - Disk2InterfaceCard& disk2Card = dynamic_cast(g_CardMgr.GetRef(SLOT6)); + Disk2InterfaceCard& disk2Card = dynamic_cast(GetCardMgr().GetRef(SLOT6)); // Search from "select floppy drive" DWORD dwOpenDialogIndex = (DWORD)SendDlgItemMessage(hWnd, comboSelected, CB_FINDSTRINGEXACT, -1, (LPARAM)&m_defaultDiskOptions[0]); diff --git a/source/Configuration/PageSound.cpp b/source/Configuration/PageSound.cpp index e876f0d3..806d75f8 100644 --- a/source/Configuration/PageSound.cpp +++ b/source/Configuration/PageSound.cpp @@ -117,7 +117,7 @@ BOOL CPageSound::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM SendDlgItemMessage(hWnd,IDC_MB_VOLUME,TBM_SETTICFREQ,10,0); SendDlgItemMessage(hWnd,IDC_MB_VOLUME,TBM_SETPOS,1,MB_GetVolume()); - if (g_CardMgr.QuerySlot(SLOT5) == CT_SAM) + if (GetCardMgr().QuerySlot(SLOT5) == CT_SAM) m_NewCardType = CT_SAM; else m_NewCardType = MB_GetSoundcardType(); // Reinit 1st time page is activated (fires before PSN_SETACTIVE) diff --git a/source/Configuration/PropertySheetHelper.cpp b/source/Configuration/PropertySheetHelper.cpp index 730ab15d..3e687098 100644 --- a/source/Configuration/PropertySheetHelper.cpp +++ b/source/Configuration/PropertySheetHelper.cpp @@ -128,8 +128,8 @@ void CPropertySheetHelper::SetSlot(UINT slot, SS_CARDTYPE newCardType) // Two paths: // 1) Via Config dialog: card not inserted yet // 2) Snapshot_LoadState_v2(): card already inserted - if (g_CardMgr.QuerySlot(slot) != newCardType) - g_CardMgr.Insert(slot, newCardType); + if (GetCardMgr().QuerySlot(slot) != newCardType) + GetCardMgr().Insert(slot, newCardType); std::string slotText; switch (slot) @@ -214,10 +214,10 @@ void CPropertySheetHelper::SaveStateUpdate() void CPropertySheetHelper::GetDiskBaseNameWithAWS(std::string & pszFilename) { - if (g_CardMgr.QuerySlot(SLOT6) != CT_Disk2) + if (GetCardMgr().QuerySlot(SLOT6) != CT_Disk2) return; - const std::string& diskName = dynamic_cast(g_CardMgr.GetRef(SLOT6)).GetBaseName(DRIVE_1); + const std::string& diskName = dynamic_cast(GetCardMgr().GetRef(SLOT6)).GetBaseName(DRIVE_1); if (!diskName.empty()) { pszFilename = diskName + ".aws.yaml"; @@ -453,8 +453,8 @@ void CPropertySheetHelper::SaveCurrentConfig(void) // NB. clone-type is encoded in g_Apple2Type m_ConfigOld.m_Apple2Type = GetApple2Type(); m_ConfigOld.m_CpuType = GetMainCpu(); - m_ConfigOld.m_Slot[SLOT4] = g_CardMgr.QuerySlot(SLOT4); - m_ConfigOld.m_Slot[SLOT5] = g_CardMgr.QuerySlot(SLOT5); + m_ConfigOld.m_Slot[SLOT4] = GetCardMgr().QuerySlot(SLOT4); + m_ConfigOld.m_Slot[SLOT5] = GetCardMgr().QuerySlot(SLOT5); m_ConfigOld.m_bEnableHDD = HD_CardIsEnabled(); m_ConfigOld.m_bEnableTheFreezesF8Rom = sg_PropertySheet.GetTheFreezesF8Rom(); m_ConfigOld.m_videoRefreshRate = GetVideoRefreshRate(); @@ -472,8 +472,8 @@ void CPropertySheetHelper::RestoreCurrentConfig(void) // NB. clone-type is encoded in g_Apple2Type SetApple2Type(m_ConfigOld.m_Apple2Type); SetMainCpu(m_ConfigOld.m_CpuType); - g_CardMgr.Insert(SLOT4, m_ConfigOld.m_Slot[SLOT4]); - g_CardMgr.Insert(SLOT5, m_ConfigOld.m_Slot[SLOT5]); + GetCardMgr().Insert(SLOT4, m_ConfigOld.m_Slot[SLOT4]); + GetCardMgr().Insert(SLOT5, m_ConfigOld.m_Slot[SLOT5]); HD_SetEnabled(m_ConfigOld.m_bEnableHDD); sg_PropertySheet.SetTheFreezesF8Rom(m_ConfigOld.m_bEnableTheFreezesF8Rom); SetVideoRefreshRate(m_ConfigOld.m_videoRefreshRate); diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index ff7a34d7..abe1b28f 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -3768,10 +3768,10 @@ Update_t CmdDisk ( int nArgs) if (! nArgs) return HelpLastCommand(); - if (g_CardMgr.QuerySlot(SLOT6) != CT_Disk2) + if (GetCardMgr().QuerySlot(SLOT6) != CT_Disk2) return ConsoleDisplayError("No DiskII card in slot-6"); - Disk2InterfaceCard& diskCard = dynamic_cast(g_CardMgr.GetRef(SLOT6)); + Disk2InterfaceCard& diskCard = dynamic_cast(GetCardMgr().GetRef(SLOT6)); // check for info command int iParam = 0; diff --git a/source/Disk2CardManager.cpp b/source/Disk2CardManager.cpp index 05d56580..0f7c7bcd 100644 --- a/source/Disk2CardManager.cpp +++ b/source/Disk2CardManager.cpp @@ -38,9 +38,9 @@ bool Disk2CardManager::IsConditionForFullSpeed(void) { for (UINT i = 0; i < NUM_SLOTS; i++) { - if (g_CardMgr.QuerySlot(i) == CT_Disk2) + if (GetCardMgr().QuerySlot(i) == CT_Disk2) { - if (dynamic_cast(g_CardMgr.GetRef(i)).IsConditionForFullSpeed()) + if (dynamic_cast(GetCardMgr().GetRef(i)).IsConditionForFullSpeed()) return true; // if any card is true then the condition for full-speed is true } } @@ -52,9 +52,9 @@ void Disk2CardManager::UpdateDriveState(UINT cycles) { for (UINT i = 0; i < NUM_SLOTS; i++) { - if (g_CardMgr.QuerySlot(i) == CT_Disk2) + if (GetCardMgr().QuerySlot(i) == CT_Disk2) { - dynamic_cast(g_CardMgr.GetRef(i)).UpdateDriveState(cycles); + dynamic_cast(GetCardMgr().GetRef(i)).UpdateDriveState(cycles); } } } @@ -63,9 +63,9 @@ void Disk2CardManager::Reset(const bool powerCycle /*=false*/) { for (UINT i = 0; i < NUM_SLOTS; i++) { - if (g_CardMgr.QuerySlot(i) == CT_Disk2) + if (GetCardMgr().QuerySlot(i) == CT_Disk2) { - dynamic_cast(g_CardMgr.GetRef(i)).Reset(powerCycle); + dynamic_cast(GetCardMgr().GetRef(i)).Reset(powerCycle); } } } @@ -74,10 +74,10 @@ bool Disk2CardManager::GetEnhanceDisk(void) { for (UINT i = 0; i < NUM_SLOTS; i++) { - if (g_CardMgr.QuerySlot(i) == CT_Disk2) + if (GetCardMgr().QuerySlot(i) == CT_Disk2) { // All Disk2 cards should have the same setting, so just return the state of the first card - return dynamic_cast(g_CardMgr.GetRef(i)).GetEnhanceDisk(); + return dynamic_cast(GetCardMgr().GetRef(i)).GetEnhanceDisk(); } } return false; @@ -87,9 +87,9 @@ void Disk2CardManager::SetEnhanceDisk(bool enhanceDisk) { for (UINT i = 0; i < NUM_SLOTS; i++) { - if (g_CardMgr.QuerySlot(i) == CT_Disk2) + if (GetCardMgr().QuerySlot(i) == CT_Disk2) { - dynamic_cast(g_CardMgr.GetRef(i)).SetEnhanceDisk(enhanceDisk); + dynamic_cast(GetCardMgr().GetRef(i)).SetEnhanceDisk(enhanceDisk); } } } @@ -100,10 +100,10 @@ void Disk2CardManager::LoadLastDiskImage(void) { if (i != SLOT6) continue; // FIXME - if (g_CardMgr.QuerySlot(i) == CT_Disk2) + if (GetCardMgr().QuerySlot(i) == CT_Disk2) { - dynamic_cast(g_CardMgr.GetRef(i)).LoadLastDiskImage(DRIVE_1); - dynamic_cast(g_CardMgr.GetRef(i)).LoadLastDiskImage(DRIVE_2); + dynamic_cast(GetCardMgr().GetRef(i)).LoadLastDiskImage(DRIVE_1); + dynamic_cast(GetCardMgr().GetRef(i)).LoadLastDiskImage(DRIVE_2); } } } @@ -112,9 +112,9 @@ void Disk2CardManager::Destroy(void) { for (UINT i = 0; i < NUM_SLOTS; i++) { - if (g_CardMgr.QuerySlot(i) == CT_Disk2) + if (GetCardMgr().QuerySlot(i) == CT_Disk2) { - dynamic_cast(g_CardMgr.GetRef(i)).Destroy(); + dynamic_cast(GetCardMgr().GetRef(i)).Destroy(); } } } @@ -123,10 +123,10 @@ bool Disk2CardManager::IsAnyFirmware13Sector(void) { for (UINT i = 0; i < NUM_SLOTS; i++) { - if (g_CardMgr.QuerySlot(i) == CT_Disk2) + if (GetCardMgr().QuerySlot(i) == CT_Disk2) { // If any Disk2 card has 13-sector firmware then return true - if (dynamic_cast(g_CardMgr.GetRef(i)).GetCurrentFirmware() == 13) + if (dynamic_cast(GetCardMgr().GetRef(i)).GetCurrentFirmware() == 13) return true; } } diff --git a/source/Frame.cpp b/source/Frame.cpp index 95abc0e7..3bf6cae7 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -281,7 +281,7 @@ static void GetAppleWindowTitle() g_pAppTitle += VideoGetAppWindowTitle(); - if (g_CardMgr.GetDisk2CardMgr().IsAnyFirmware13Sector()) + if (GetCardMgr().GetDisk2CardMgr().IsAnyFirmware13Sector()) g_pAppTitle += " (S6-13) "; if (g_hCustomRomF8 != INVALID_HANDLE_VALUE) @@ -328,7 +328,7 @@ static void FrameShowCursor(BOOL bShow) // . AppleWin's main window is activated/deactivated static void RevealCursor() { - CMouseInterface* pMouseCard = g_CardMgr.GetMouseCard(); + CMouseInterface* pMouseCard = GetCardMgr().GetMouseCard(); if (!pMouseCard || !pMouseCard->IsActiveAndEnabled()) return; @@ -355,7 +355,7 @@ static void FullScreenRevealCursor(void) if (!g_bIsFullScreen) return; - if (g_CardMgr.IsMouseCardInstalled()) + if (GetCardMgr().IsMouseCardInstalled()) return; if (!g_bUsingCursor && !g_bShowingCursor) @@ -521,8 +521,8 @@ static void DrawButton (HDC passdc, int number) { SetTextAlign(dc,TA_CENTER | TA_TOP); SetBkMode(dc,TRANSPARENT); - LPCTSTR pszBaseName = (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) - ? dynamic_cast(g_CardMgr.GetRef(SLOT6)).GetBaseName(number-BTN_DRIVE1).c_str() + LPCTSTR pszBaseName = (GetCardMgr().QuerySlot(SLOT6) == CT_Disk2) + ? dynamic_cast(GetCardMgr().GetRef(SLOT6)).GetBaseName(number-BTN_DRIVE1).c_str() : ""; ExtTextOut(dc,x+offset+22,rect.top,ETO_CLIPPED,&rect, @@ -717,15 +717,15 @@ void FrameDrawDiskLEDS( HDC passdc ) g_eStatusDrive2 = DISK_STATUS_OFF; // Slot6 drive takes priority unless it's off: - if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) - dynamic_cast(g_CardMgr.GetRef(SLOT6)).GetLightStatus(&g_eStatusDrive1, &g_eStatusDrive2); + if (GetCardMgr().QuerySlot(SLOT6) == CT_Disk2) + dynamic_cast(GetCardMgr().GetRef(SLOT6)).GetLightStatus(&g_eStatusDrive1, &g_eStatusDrive2); // Slot5: { Disk_Status_e eDrive1StatusSlot5 = DISK_STATUS_OFF; Disk_Status_e eDrive2StatusSlot5 = DISK_STATUS_OFF; - if (g_CardMgr.QuerySlot(SLOT5) == CT_Disk2) - dynamic_cast(g_CardMgr.GetRef(SLOT5)).GetLightStatus(&eDrive1StatusSlot5, &eDrive2StatusSlot5); + if (GetCardMgr().QuerySlot(SLOT5) == CT_Disk2) + dynamic_cast(GetCardMgr().GetRef(SLOT5)).GetLightStatus(&eDrive1StatusSlot5, &eDrive2StatusSlot5); if (g_eStatusDrive1 == DISK_STATUS_OFF) g_eStatusDrive1 = eDrive1StatusSlot5; if (g_eStatusDrive2 == DISK_STATUS_OFF) g_eStatusDrive2 = eDrive2StatusSlot5; @@ -783,10 +783,10 @@ void FrameDrawDiskStatus( HDC passdc ) // Sector $B7ED LC1 $D357 // RWTS LC1 $D300 - if (g_CardMgr.QuerySlot(SLOT6) != CT_Disk2) + if (GetCardMgr().QuerySlot(SLOT6) != CT_Disk2) return; - Disk2InterfaceCard& disk2Card = dynamic_cast(g_CardMgr.GetRef(SLOT6)); + Disk2InterfaceCard& disk2Card = dynamic_cast(GetCardMgr().GetRef(SLOT6)); int nActiveFloppy = disk2Card.GetCurrentDrive(); int nDisk1Track = disk2Card.GetTrack(DRIVE_1); int nDisk2Track = disk2Card.GetTrack(DRIVE_2); @@ -1149,13 +1149,13 @@ LRESULT CALLBACK FrameWndProc ( Snapshot_Shutdown(); DebugDestroy(); if (!g_bRestart) { - g_CardMgr.GetDisk2CardMgr().Destroy(); + GetCardMgr().GetDisk2CardMgr().Destroy(); ImageDestroy(); HD_Destroy(); } PrintDestroy(); - if (g_CardMgr.IsSSCInstalled()) - g_CardMgr.GetSSC()->CommDestroy(); + if (GetCardMgr().IsSSCInstalled()) + GetCardMgr().GetSSC()->CommDestroy(); CpuDestroy(); MemDestroy(); SpkrDestroy(); @@ -1207,9 +1207,9 @@ LRESULT CALLBACK FrameWndProc ( case WM_DDE_EXECUTE: { LogFileOutput("WM_DDE_EXECUTE\n"); - if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) + if (GetCardMgr().QuerySlot(SLOT6) == CT_Disk2) { - Disk2InterfaceCard& disk2Card = dynamic_cast(g_CardMgr.GetRef(SLOT6)); + Disk2InterfaceCard& disk2Card = dynamic_cast(GetCardMgr().GetRef(SLOT6)); LPTSTR filename = (LPTSTR)GlobalLock((HGLOBAL)lparam); ImageError_e Error = disk2Card.InsertDisk(DRIVE_1, filename, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); if (Error == eIMAGE_ERROR_NONE) @@ -1235,9 +1235,9 @@ LRESULT CALLBACK FrameWndProc ( case WM_DROPFILES: { - if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) + if (GetCardMgr().QuerySlot(SLOT6) == CT_Disk2) { - Disk2InterfaceCard& disk2Card = dynamic_cast(g_CardMgr.GetRef(SLOT6)); + Disk2InterfaceCard& disk2Card = dynamic_cast(GetCardMgr().GetRef(SLOT6)); TCHAR filename[MAX_PATH]; DragQueryFile((HDROP)wparam,0,filename,sizeof(filename)); POINT point; @@ -1569,7 +1569,7 @@ LRESULT CALLBACK FrameWndProc ( DrawButton((HDC)0,buttonactive); SetCapture(window); } - else if (g_bUsingCursor && !g_CardMgr.IsMouseCardInstalled()) + else if (g_bUsingCursor && !GetCardMgr().IsMouseCardInstalled()) { if (wparam & (MK_CONTROL | MK_SHIFT)) { @@ -1584,7 +1584,7 @@ LRESULT CALLBACK FrameWndProc ( { SetUsingCursor(TRUE); } - else if (g_CardMgr.IsMouseCardInstalled()) + else if (GetCardMgr().IsMouseCardInstalled()) { if (wparam & (MK_CONTROL | MK_SHIFT)) { @@ -1592,7 +1592,7 @@ LRESULT CALLBACK FrameWndProc ( } else if (g_nAppMode == MODE_RUNNING || g_nAppMode == MODE_STEPPING) { - CMouseInterface* pMouseCard = g_CardMgr.GetMouseCard(); + CMouseInterface* pMouseCard = GetCardMgr().GetMouseCard(); if (pMouseCard) { @@ -1634,13 +1634,13 @@ LRESULT CALLBACK FrameWndProc ( } buttonactive = -1; } - else if (g_bUsingCursor && !g_CardMgr.IsMouseCardInstalled()) + else if (g_bUsingCursor && !GetCardMgr().IsMouseCardInstalled()) { JoySetButton(BUTTON0, BUTTON_UP); } - else if (g_CardMgr.IsMouseCardInstalled()) + else if (GetCardMgr().IsMouseCardInstalled()) { - g_CardMgr.GetMouseCard()->SetButton(BUTTON0, BUTTON_UP); + GetCardMgr().GetMouseCard()->SetButton(BUTTON0, BUTTON_UP); } RelayEvent(WM_LBUTTONUP,wparam,lparam); break; @@ -1668,12 +1668,12 @@ LRESULT CALLBACK FrameWndProc ( if (buttonover != -1) DrawButton((HDC)0,buttonover); } - else if (g_bUsingCursor && !g_CardMgr.IsMouseCardInstalled()) + else if (g_bUsingCursor && !GetCardMgr().IsMouseCardInstalled()) { DrawCrosshairs(x,y); JoySetPosition(x-viewportx-2, g_nViewportCX-4, y-viewporty-2, g_nViewportCY-4); } - else if (g_CardMgr.IsMouseCardInstalled() && g_CardMgr.GetMouseCard()->IsActiveAndEnabled() && (g_nAppMode == MODE_RUNNING || g_nAppMode == MODE_STEPPING)) + else if (GetCardMgr().IsMouseCardInstalled() && GetCardMgr().GetMouseCard()->IsActiveAndEnabled() && (g_nAppMode == MODE_RUNNING || g_nAppMode == MODE_STEPPING)) { if (g_bLastCursorInAppleViewport) break; @@ -1706,7 +1706,7 @@ LRESULT CALLBACK FrameWndProc ( if (wparam == IDEVENT_TIMER_MOUSE) { // NB. Need to check /g_bAppActive/ since WM_TIMER events still occur after AppleWin app has lost focus - if (g_bAppActive && g_CardMgr.IsMouseCardInstalled() && g_CardMgr.GetMouseCard()->IsActiveAndEnabled() && (g_nAppMode == MODE_RUNNING || g_nAppMode == MODE_STEPPING)) + if (g_bAppActive && GetCardMgr().IsMouseCardInstalled() && GetCardMgr().GetMouseCard()->IsActiveAndEnabled() && (g_nAppMode == MODE_RUNNING || g_nAppMode == MODE_STEPPING)) { if (!g_bLastCursorInAppleViewport) break; @@ -1717,7 +1717,7 @@ LRESULT CALLBACK FrameWndProc ( long dX,dY; if (DIMouse::ReadImmediateData(&dX, &dY) == S_OK) - g_CardMgr.GetMouseCard()->SetPositionRel(dX, dY, &iOutOfBoundsX, &iOutOfBoundsY); + GetCardMgr().GetMouseCard()->SetPositionRel(dX, dY, &iOutOfBoundsX, &iOutOfBoundsY); UpdateMouseInAppleViewport(iOutOfBoundsX, iOutOfBoundsY); } @@ -1725,7 +1725,7 @@ LRESULT CALLBACK FrameWndProc ( else if (wparam == IDEVENT_TIMER_100MSEC) // GH#504 { if (g_bIsFullScreen - && !g_CardMgr.IsMouseCardInstalled() // Don't interfere if there's a mousecard present! + && !GetCardMgr().IsMouseCardInstalled() // Don't interfere if there's a mousecard present! && !g_bUsingCursor // Using mouse for joystick emulation (or mousecard restricted to window) && g_bShowingCursor && g_bFrameActive) // Frame inactive when eg. Config or 'Select Disk Image' dialogs are opened @@ -1766,10 +1766,10 @@ LRESULT CALLBACK FrameWndProc ( Disk2InterfaceCard *pDisk2Slot5 = NULL, *pDisk2Slot6 = NULL; - if (g_CardMgr.QuerySlot(SLOT5) == CT_Disk2) - pDisk2Slot5 = dynamic_cast(g_CardMgr.GetObj(SLOT5)); - if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) - pDisk2Slot6 = dynamic_cast(g_CardMgr.GetObj(SLOT6)); + if (GetCardMgr().QuerySlot(SLOT5) == CT_Disk2) + pDisk2Slot5 = dynamic_cast(GetCardMgr().GetObj(SLOT5)); + if (GetCardMgr().QuerySlot(SLOT6) == CT_Disk2) + pDisk2Slot6 = dynamic_cast(GetCardMgr().GetObj(SLOT6)); std::string slot5 = pDisk2Slot5 ? pDisk2Slot5->GetFullDiskFilename(((LPNMTTDISPINFO)lparam)->hdr.idFrom) : ""; std::string slot6 = pDisk2Slot6 ? pDisk2Slot6->GetFullDiskFilename(((LPNMTTDISPINFO)lparam)->hdr.idFrom) : ""; @@ -1845,10 +1845,10 @@ LRESULT CALLBACK FrameWndProc ( } } - if (g_bUsingCursor && !g_CardMgr.IsMouseCardInstalled()) + if (g_bUsingCursor && !GetCardMgr().IsMouseCardInstalled()) JoySetButton(BUTTON1, (message == WM_RBUTTONDOWN) ? BUTTON_DOWN : BUTTON_UP); - else if (g_CardMgr.IsMouseCardInstalled()) - g_CardMgr.GetMouseCard()->SetButton(BUTTON1, (message == WM_RBUTTONDOWN) ? BUTTON_DOWN : BUTTON_UP); + else if (GetCardMgr().IsMouseCardInstalled()) + GetCardMgr().GetMouseCard()->SetButton(BUTTON1, (message == WM_RBUTTONDOWN) ? BUTTON_DOWN : BUTTON_UP); RelayEvent(message,wparam,lparam); break; @@ -1948,13 +1948,13 @@ LRESULT CALLBACK FrameWndProc ( case WSAECONNRESET: case WSAENOTCONN: case WSAETIMEDOUT: - if (g_CardMgr.IsSSCInstalled()) - g_CardMgr.GetSSC()->CommTcpSerialClose(); + if (GetCardMgr().IsSSCInstalled()) + GetCardMgr().GetSSC()->CommTcpSerialClose(); break; default: - if (g_CardMgr.IsSSCInstalled()) - g_CardMgr.GetSSC()->CommTcpSerialCleanup(); + if (GetCardMgr().IsSSCInstalled()) + GetCardMgr().GetSSC()->CommTcpSerialCleanup(); break; } } @@ -1964,18 +1964,18 @@ LRESULT CALLBACK FrameWndProc ( switch(wSelectEvent) { case FD_ACCEPT: - if (g_CardMgr.IsSSCInstalled()) - g_CardMgr.GetSSC()->CommTcpSerialAccept(); + if (GetCardMgr().IsSSCInstalled()) + GetCardMgr().GetSSC()->CommTcpSerialAccept(); break; case FD_CLOSE: - if (g_CardMgr.IsSSCInstalled()) - g_CardMgr.GetSSC()->CommTcpSerialClose(); + if (GetCardMgr().IsSSCInstalled()) + GetCardMgr().GetSSC()->CommTcpSerialClose(); break; case FD_READ: - if (g_CardMgr.IsSSCInstalled()) - g_CardMgr.GetSSC()->CommTcpSerialReceive(); + if (GetCardMgr().IsSSCInstalled()) + GetCardMgr().GetSSC()->CommTcpSerialReceive(); break; } } @@ -2090,8 +2090,8 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) if (g_nAppMode == MODE_LOGO) { - if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) - dynamic_cast(g_CardMgr.GetRef(SLOT6)).Boot(); + if (GetCardMgr().QuerySlot(SLOT6) == CT_Disk2) + dynamic_cast(GetCardMgr().GetRef(SLOT6)).Boot(); LogFileTimeUntilFirstKeyReadReset(); g_nAppMode = MODE_RUNNING; @@ -2115,18 +2115,18 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) case BTN_DRIVE1: case BTN_DRIVE2: - if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) + if (GetCardMgr().QuerySlot(SLOT6) == CT_Disk2) { - dynamic_cast(g_CardMgr.GetRef(SLOT6)).UserSelectNewDiskImage(button-BTN_DRIVE1); + dynamic_cast(GetCardMgr().GetRef(SLOT6)).UserSelectNewDiskImage(button-BTN_DRIVE1); if (!g_bIsFullScreen) DrawButton((HDC)0,button); } break; case BTN_DRIVESWAP: - if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) + if (GetCardMgr().QuerySlot(SLOT6) == CT_Disk2) { - dynamic_cast(g_CardMgr.GetRef(SLOT6)).DriveSwap(); + dynamic_cast(GetCardMgr().GetRef(SLOT6)).DriveSwap(); } break; @@ -2182,10 +2182,10 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) { - if (g_CardMgr.QuerySlot(SLOT6) != CT_Disk2) + if (GetCardMgr().QuerySlot(SLOT6) != CT_Disk2) return; - Disk2InterfaceCard& disk2Card = dynamic_cast(g_CardMgr.GetRef(SLOT6)); + Disk2InterfaceCard& disk2Card = dynamic_cast(GetCardMgr().GetRef(SLOT6)); // This is the default installation path of CiderPress. // It shall not be left blank, otherwise an explorer window will be open. @@ -2324,24 +2324,24 @@ void RelayEvent (UINT message, WPARAM wparam, LPARAM lparam) { // todo: consolidate CtrlReset() and ResetMachineState() void ResetMachineState () { - g_CardMgr.GetDisk2CardMgr().Reset(true); + GetCardMgr().GetDisk2CardMgr().Reset(true); HD_Reset(); g_bFullSpeed = 0; // Might've hit reset in middle of InternalCpuExecute() - so beep may get (partially) muted MemReset(); // calls CpuInitialize(), CNoSlotClock.Reset() PravetsReset(); - if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) - dynamic_cast(g_CardMgr.GetRef(SLOT6)).Boot(); + if (GetCardMgr().QuerySlot(SLOT6) == CT_Disk2) + dynamic_cast(GetCardMgr().GetRef(SLOT6)).Boot(); VideoResetState(); KeybReset(); - if (g_CardMgr.IsSSCInstalled()) - g_CardMgr.GetSSC()->CommReset(); + if (GetCardMgr().IsSSCInstalled()) + GetCardMgr().GetSSC()->CommReset(); PrintReset(); JoyReset(); MB_Reset(); SpkrReset(); - if (g_CardMgr.IsMouseCardInstalled()) - g_CardMgr.GetMouseCard()->Reset(); + if (GetCardMgr().IsMouseCardInstalled()) + GetCardMgr().GetMouseCard()->Reset(); SetActiveCpu( GetMainCpu() ); #ifdef USE_SPEECH_API g_Speech.Reset(); @@ -2379,14 +2379,14 @@ void CtrlReset() } PravetsReset(); - g_CardMgr.GetDisk2CardMgr().Reset(); + GetCardMgr().GetDisk2CardMgr().Reset(); HD_Reset(); KeybReset(); - if (g_CardMgr.IsSSCInstalled()) - g_CardMgr.GetSSC()->CommReset(); + if (GetCardMgr().IsSSCInstalled()) + GetCardMgr().GetSSC()->CommReset(); MB_Reset(); - if (g_CardMgr.IsMouseCardInstalled()) - g_CardMgr.GetMouseCard()->Reset(); // Deassert any pending IRQs - GH#514 + if (GetCardMgr().IsMouseCardInstalled()) + GetCardMgr().GetMouseCard()->Reset(); // Deassert any pending IRQs - GH#514 #ifdef USE_SPEECH_API g_Speech.Reset(); #endif @@ -2792,8 +2792,8 @@ static bool FileExists(std::string strFilename) // . UpdateMouseInAppleViewport() is called and inside Apple screen void FrameSetCursorPosByMousePos() { -// _ASSERT(g_CardMgr.IsMouseCardInstalled()); // CMouseInterface::ctor calls this function, ie. before g_CardMgr::m_pMouseCard is setup - if (!g_CardMgr.IsMouseCardInstalled()) +// _ASSERT(GetCardMgr().IsMouseCardInstalled()); // CMouseInterface::ctor calls this function, ie. before GetCardMgr()::m_pMouseCard is setup + if (!GetCardMgr().IsMouseCardInstalled()) return; if (!g_hFrameWindow || g_bShowingCursor) @@ -2801,7 +2801,7 @@ void FrameSetCursorPosByMousePos() int iX, iMinX, iMaxX; int iY, iMinY, iMaxY; - g_CardMgr.GetMouseCard()->GetXY(iX, iMinX, iMaxX, iY, iMinY, iMaxY); + GetCardMgr().GetMouseCard()->GetXY(iX, iMinX, iMaxX, iY, iMinY, iMaxY); float fScaleX = (float)(iX-iMinX) / ((float)(iMaxX-iMinX)); float fScaleY = (float)(iY-iMinY) / ((float)(iMaxY-iMinY)); @@ -2831,8 +2831,8 @@ void FrameSetCursorPosByMousePos() // . NB. Not called when leaving & mouse clipped to Apple screen area static void FrameSetCursorPosByMousePos(int x, int y, int dx, int dy, bool bLeavingAppleScreen) { - _ASSERT(g_CardMgr.IsMouseCardInstalled()); - if (!g_CardMgr.IsMouseCardInstalled()) + _ASSERT(GetCardMgr().IsMouseCardInstalled()); + if (!GetCardMgr().IsMouseCardInstalled()) return; // char szDbg[200]; @@ -2841,7 +2841,7 @@ static void FrameSetCursorPosByMousePos(int x, int y, int dx, int dy, bool bLeav int iX, iMinX, iMaxX; int iY, iMinY, iMaxY; - g_CardMgr.GetMouseCard()->GetXY(iX, iMinX, iMaxX, iY, iMinY, iMaxY); + GetCardMgr().GetMouseCard()->GetXY(iX, iMinX, iMaxX, iY, iMinY, iMaxY); if (bLeavingAppleScreen) { @@ -2879,7 +2879,7 @@ static void FrameSetCursorPosByMousePos(int x, int y, int dx, int dy, bool bLeav int iAppleX = iMinX + (int)(fScaleX * (float)(iMaxX-iMinX)); int iAppleY = iMinY + (int)(fScaleY * (float)(iMaxY-iMinY)); - g_CardMgr.GetMouseCard()->SetCursorPos(iAppleX, iAppleY); // Set new entry position + GetCardMgr().GetMouseCard()->SetCursorPos(iAppleX, iAppleY); // Set new entry position // Dump initial deltas (otherwise can get big deltas since last read when entering Apple screen area) DIMouse::ReadImmediateData(); @@ -2888,8 +2888,8 @@ static void FrameSetCursorPosByMousePos(int x, int y, int dx, int dy, bool bLeav static void DrawCrosshairsMouse() { - _ASSERT(g_CardMgr.IsMouseCardInstalled()); - if (!g_CardMgr.IsMouseCardInstalled()) + _ASSERT(GetCardMgr().IsMouseCardInstalled()); + if (!GetCardMgr().IsMouseCardInstalled()) return; if (!sg_PropertySheet.GetMouseShowCrosshair()) @@ -2897,7 +2897,7 @@ static void DrawCrosshairsMouse() int iX, iMinX, iMaxX; int iY, iMinY, iMaxY; - g_CardMgr.GetMouseCard()->GetXY(iX, iMinX, iMaxX, iY, iMinY, iMaxY); + GetCardMgr().GetMouseCard()->GetXY(iX, iMinX, iMaxX, iY, iMinY, iMaxY); _ASSERT(iMinX == 0 && iMinY == 0); float fScaleX = (float)(iX-iMinX) / ((float)(iMaxX-iMinX)); diff --git a/source/Harddisk.cpp b/source/Harddisk.cpp index ecb3ac59..d3ee00b1 100644 --- a/source/Harddisk.cpp +++ b/source/Harddisk.cpp @@ -279,9 +279,9 @@ void HD_SetEnabled(const bool bEnabled) g_bHD_Enabled = bEnabled; if (bEnabled) - g_CardMgr.Insert(SLOT7, CT_GenericHDD); + GetCardMgr().Insert(SLOT7, CT_GenericHDD); else - g_CardMgr.Remove(SLOT7); + GetCardMgr().Remove(SLOT7); #if 0 // FIXME: For LoadConfiguration(), g_uSlot=7 (see definition at start of file) diff --git a/source/Memory.cpp b/source/Memory.cpp index 68d23bcd..ce4ed3ea 100644 --- a/source/Memory.cpp +++ b/source/Memory.cpp @@ -305,8 +305,8 @@ void SetExpansionMemType(const SS_CARDTYPE type) newSlotAuxCard = type; } - g_CardMgr.Insert(SLOT0, newSlot0Card); - g_CardMgr.InsertAux(newSlotAuxCard); + GetCardMgr().Insert(SLOT0, newSlot0Card); + GetCardMgr().InsertAux(newSlotAuxCard); } void CreateLanguageCard(void) @@ -316,9 +316,9 @@ void CreateLanguageCard(void) if (IsApple2PlusOrClone(GetApple2Type())) { - if (g_CardMgr.QuerySlot(SLOT0) == CT_Saturn128K) + if (GetCardMgr().QuerySlot(SLOT0) == CT_Saturn128K) g_pLanguageCard = new Saturn128K(g_uSaturnBanksFromCmdLine); - else if (g_CardMgr.QuerySlot(SLOT0) == CT_LanguageCard) + else if (GetCardMgr().QuerySlot(SLOT0) == CT_LanguageCard) g_pLanguageCard = new LanguageCardSlot0; else g_pLanguageCard = NULL; @@ -332,9 +332,9 @@ void CreateLanguageCard(void) SS_CARDTYPE GetCurrentExpansionMemType(void) { if (IsApple2PlusOrClone(GetApple2Type())) - return g_CardMgr.QuerySlot(SLOT0); + return GetCardMgr().QuerySlot(SLOT0); else - return g_CardMgr.QueryAux(); + return GetCardMgr().QueryAux(); } // @@ -1077,7 +1077,7 @@ static void ResetPaging(BOOL initialize) { SetLastRamWrite(0); - if (IsApple2PlusOrClone(GetApple2Type()) && g_CardMgr.QuerySlot(SLOT0) == CT_Empty) + if (IsApple2PlusOrClone(GetApple2Type()) && GetCardMgr().QuerySlot(SLOT0) == CT_Empty) SetMemMode(0); else SetMemMode(LanguageCardUnit::kMemModeInitialState); @@ -1495,7 +1495,7 @@ void MemInitialize() SetExpansionMemTypeDefault(); #ifdef RAMWORKS - if (g_CardMgr.QueryAux() == CT_RamWorksIII) + if (GetCardMgr().QueryAux() == CT_RamWorksIII) { // allocate memory for RAMWorks III - up to 8MB g_uActiveBank = 0; @@ -1606,7 +1606,7 @@ void MemInitializeCustomF8ROM(void) const UINT F8RomSize = 0x800; const UINT F8RomOffset = Apple2RomSize-F8RomSize; - if (IsApple2Original(GetApple2Type()) && g_CardMgr.QuerySlot(SLOT0) == CT_LanguageCard) + if (IsApple2Original(GetApple2Type()) && GetCardMgr().QuerySlot(SLOT0) == CT_LanguageCard) { try { @@ -1729,13 +1729,13 @@ void MemInitializeIO(void) else RegisterIoHandler(LanguageCardUnit::kSlot0, IO_Null, IO_Null, NULL, NULL, NULL, NULL); - if (g_CardMgr.QuerySlot(SLOT1) == CT_GenericPrinter) + if (GetCardMgr().QuerySlot(SLOT1) == CT_GenericPrinter) PrintLoadRom(pCxRomPeripheral, SLOT1); // $C100 : Parallel printer f/w - if (g_CardMgr.QuerySlot(SLOT2) == CT_SSC) - dynamic_cast(g_CardMgr.GetRef(SLOT2)).CommInitialize(pCxRomPeripheral, SLOT2); // $C200 : SSC + if (GetCardMgr().QuerySlot(SLOT2) == CT_SSC) + dynamic_cast(GetCardMgr().GetRef(SLOT2)).CommInitialize(pCxRomPeripheral, SLOT2); // $C200 : SSC - if (g_CardMgr.QuerySlot(SLOT3) == CT_Uthernet) + if (GetCardMgr().QuerySlot(SLOT3) == CT_Uthernet) { // Slot 3 contains the Uthernet card (which can coexist with an 80-col+Ram card in AUX slot) // . Uthernet card has no ROM and only IO mapped at $C0Bx @@ -1744,40 +1744,40 @@ void MemInitializeIO(void) // Apple//e: Auxilary slot contains Extended 80 Column card or RamWorksIII card - if (g_CardMgr.QuerySlot(SLOT4) == CT_MouseInterface) + if (GetCardMgr().QuerySlot(SLOT4) == CT_MouseInterface) { - dynamic_cast(g_CardMgr.GetRef(SLOT4)).Initialize(pCxRomPeripheral, SLOT4); // $C400 : Mouse f/w + dynamic_cast(GetCardMgr().GetRef(SLOT4)).Initialize(pCxRomPeripheral, SLOT4); // $C400 : Mouse f/w } - else if (g_CardMgr.QuerySlot(SLOT4) == CT_MockingboardC || g_CardMgr.QuerySlot(SLOT4) == CT_Phasor) + else if (GetCardMgr().QuerySlot(SLOT4) == CT_MockingboardC || GetCardMgr().QuerySlot(SLOT4) == CT_Phasor) { MB_InitializeIO(pCxRomPeripheral, SLOT4, SLOT5); } - else if (g_CardMgr.QuerySlot(SLOT4) == CT_Z80) + else if (GetCardMgr().QuerySlot(SLOT4) == CT_Z80) { ConfigureSoftcard(pCxRomPeripheral, SLOT4); // $C400 : Z80 card } -// else if (g_CardMgr.QuerySlot(SLOT4) == CT_GenericClock) +// else if (GetCardMgr().QuerySlot(SLOT4) == CT_GenericClock) // { // LoadRom_Clock_Generic(pCxRomPeripheral, SLOT4); // } - if (g_CardMgr.QuerySlot(SLOT5) == CT_Z80) + if (GetCardMgr().QuerySlot(SLOT5) == CT_Z80) { ConfigureSoftcard(pCxRomPeripheral, SLOT5); // $C500 : Z80 card } - else if (g_CardMgr.QuerySlot(SLOT5) == CT_SAM) + else if (GetCardMgr().QuerySlot(SLOT5) == CT_SAM) { ConfigureSAM(pCxRomPeripheral, SLOT5); // $C500 : Z80 card } - else if (g_CardMgr.QuerySlot(SLOT5) == CT_Disk2) + else if (GetCardMgr().QuerySlot(SLOT5) == CT_Disk2) { - dynamic_cast(g_CardMgr.GetRef(SLOT5)).Initialize(pCxRomPeripheral, SLOT5); // $C500 : Disk][ card + dynamic_cast(GetCardMgr().GetRef(SLOT5)).Initialize(pCxRomPeripheral, SLOT5); // $C500 : Disk][ card } - if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) - dynamic_cast(g_CardMgr.GetRef(SLOT6)).Initialize(pCxRomPeripheral, SLOT6); // $C600 : Disk][ card + if (GetCardMgr().QuerySlot(SLOT6) == CT_Disk2) + dynamic_cast(GetCardMgr().GetRef(SLOT6)).Initialize(pCxRomPeripheral, SLOT6); // $C600 : Disk][ card - if (g_CardMgr.QuerySlot(SLOT7) == CT_GenericHDD) + if (GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD) HD_Load_Rom(pCxRomPeripheral, SLOT7); // $C700 : HDD f/w } @@ -2475,8 +2475,8 @@ static void MemLoadSnapshotAuxCommon(YamlLoadHelper& yamlLoadHelper, const std:: yamlLoadHelper.PopMap(); } - g_CardMgr.Remove(SLOT0); - g_CardMgr.InsertAux(type); + GetCardMgr().Remove(SLOT0); + GetCardMgr().InsertAux(type); memaux = RWpages[g_uActiveBank]; // NB. MemUpdatePaging(TRUE) called at end of Snapshot_LoadState_v2() diff --git a/source/Mockingboard.cpp b/source/Mockingboard.cpp index e405a2d5..8dfc65f7 100644 --- a/source/Mockingboard.cpp +++ b/source/Mockingboard.cpp @@ -1933,21 +1933,21 @@ void MB_InitializeIO(LPBYTE pCxRomPeripheral, UINT uSlot4, UINT uSlot5) // Phasor : Slot 4 // : Slot 4 & 5 - if (g_CardMgr.QuerySlot(SLOT4) != CT_MockingboardC && g_CardMgr.QuerySlot(SLOT4) != CT_Phasor) + if (GetCardMgr().QuerySlot(SLOT4) != CT_MockingboardC && GetCardMgr().QuerySlot(SLOT4) != CT_Phasor) { MB_SetSoundcardType(CT_Empty); return; } - if (g_CardMgr.QuerySlot(SLOT4) == CT_MockingboardC) + if (GetCardMgr().QuerySlot(SLOT4) == CT_MockingboardC) RegisterIoHandler(uSlot4, IO_Null, IO_Null, MB_Read, MB_Write, NULL, NULL); else // Phasor RegisterIoHandler(uSlot4, PhasorIO, PhasorIO, MB_Read, MB_Write, NULL, NULL); - if (g_CardMgr.QuerySlot(SLOT5) == CT_MockingboardC) + if (GetCardMgr().QuerySlot(SLOT5) == CT_MockingboardC) RegisterIoHandler(uSlot5, IO_Null, IO_Null, MB_Read, MB_Write, NULL, NULL); - MB_SetSoundcardType(g_CardMgr.QuerySlot(SLOT4)); + MB_SetSoundcardType(GetCardMgr().QuerySlot(SLOT4)); if (g_bDisableDirectSound || g_bDisableDirectSoundMockingboard) return; diff --git a/source/MouseInterface.cpp b/source/MouseInterface.cpp index 6b4c3520..6d08cdbe 100644 --- a/source/MouseInterface.cpp +++ b/source/MouseInterface.cpp @@ -490,7 +490,7 @@ void CMouseInterface::OnMouseEvent(bool bEventVBL) int CMouseInterface::SyncEventCallback(int id, int cycles, ULONG /*uExecutedCycles*/) { - g_CardMgr.GetMouseCard()->OnMouseEvent(true); + GetCardMgr().GetMouseCard()->OnMouseEvent(true); return NTSC_GetCyclesUntilVBlank(cycles); } diff --git a/source/SaveState.cpp b/source/SaveState.cpp index e2d88170..2fabd05d 100644 --- a/source/SaveState.cpp +++ b/source/SaveState.cpp @@ -283,14 +283,14 @@ static void ParseSlots(YamlLoadHelper& yamlLoadHelper, UINT unitVersion) else if (card == CSuperSerialCard::GetSnapshotCardName()) { type = CT_SSC; - g_CardMgr.Insert(slot, type); - bRes = dynamic_cast(g_CardMgr.GetRef(slot)).LoadSnapshot(yamlLoadHelper, slot, cardVersion); + GetCardMgr().Insert(slot, type); + bRes = dynamic_cast(GetCardMgr().GetRef(slot)).LoadSnapshot(yamlLoadHelper, slot, cardVersion); } else if (card == CMouseInterface::GetSnapshotCardName()) { type = CT_MouseInterface; - g_CardMgr.Insert(slot, type); - bRes = dynamic_cast(g_CardMgr.GetRef(slot)).LoadSnapshot(yamlLoadHelper, slot, cardVersion); + GetCardMgr().Insert(slot, type); + bRes = dynamic_cast(GetCardMgr().GetRef(slot)).LoadSnapshot(yamlLoadHelper, slot, cardVersion); } else if (card == Z80_GetSnapshotCardName()) { @@ -310,8 +310,8 @@ static void ParseSlots(YamlLoadHelper& yamlLoadHelper, UINT unitVersion) else if (card == Disk2InterfaceCard::GetSnapshotCardName()) { type = CT_Disk2; - g_CardMgr.Insert(slot, type); - bRes = dynamic_cast(g_CardMgr.GetRef(slot)).LoadSnapshot(yamlLoadHelper, slot, cardVersion); + GetCardMgr().Insert(slot, type); + bRes = dynamic_cast(GetCardMgr().GetRef(slot)).LoadSnapshot(yamlLoadHelper, slot, cardVersion); } else if (card == HD_GetSnapshotCardName()) { @@ -423,23 +423,23 @@ static void Snapshot_LoadState_v2(void) MemReset(); // Also calls CpuInitialize() PravetsReset(); - if (g_CardMgr.IsSSCInstalled()) + if (GetCardMgr().IsSSCInstalled()) { - g_CardMgr.GetSSC()->CommReset(); + GetCardMgr().GetSSC()->CommReset(); } else { - _ASSERT(g_CardMgr.QuerySlot(SLOT2) == CT_Empty); + _ASSERT(GetCardMgr().QuerySlot(SLOT2) == CT_Empty); ConfigOld.m_Slot[2] = CT_Empty; } - if (g_CardMgr.QuerySlot(SLOT4) == CT_MouseInterface) - g_CardMgr.Remove(SLOT4); // Remove Mouse card from slot-4 + if (GetCardMgr().QuerySlot(SLOT4) == CT_MouseInterface) + GetCardMgr().Remove(SLOT4); // Remove Mouse card from slot-4 - if (g_CardMgr.QuerySlot(SLOT5) == CT_Disk2) - g_CardMgr.Remove(SLOT5); // Remove Disk2 card from slot-5 + if (GetCardMgr().QuerySlot(SLOT5) == CT_Disk2) + GetCardMgr().Remove(SLOT5); // Remove Disk2 card from slot-5 - g_CardMgr.GetDisk2CardMgr().Reset(false); + GetCardMgr().GetDisk2CardMgr().Reset(false); HD_Reset(); HD_SetEnabled(false); @@ -550,43 +550,43 @@ void Snapshot_SaveState(void) yamlSaveHelper.UnitHdr(GetSnapshotUnitSlotsName(), UNIT_SLOTS_VER); YamlSaveHelper::Label state(yamlSaveHelper, "%s:\n", SS_YAML_KEY_STATE); - if (g_CardMgr.QuerySlot(SLOT0) != CT_Empty && IsApple2PlusOrClone(GetApple2Type())) + if (GetCardMgr().QuerySlot(SLOT0) != CT_Empty && IsApple2PlusOrClone(GetApple2Type())) GetLanguageCard()->SaveSnapshot(yamlSaveHelper); // Language Card or Saturn 128K - if (g_CardMgr.QuerySlot(SLOT1) == CT_GenericPrinter) + if (GetCardMgr().QuerySlot(SLOT1) == CT_GenericPrinter) Printer_SaveSnapshot(yamlSaveHelper); - if (g_CardMgr.QuerySlot(SLOT2) == CT_SSC) - dynamic_cast(g_CardMgr.GetRef(SLOT2)).SaveSnapshot(yamlSaveHelper); + if (GetCardMgr().QuerySlot(SLOT2) == CT_SSC) + dynamic_cast(GetCardMgr().GetRef(SLOT2)).SaveSnapshot(yamlSaveHelper); -// if (g_CardMgr.QuerySlot(SLOT3) == CT_Uthernet) +// if (GetCardMgr().QuerySlot(SLOT3) == CT_Uthernet) // sg_Uthernet.SaveSnapshot(yamlSaveHelper); - if (g_CardMgr.QuerySlot(SLOT4) == CT_MouseInterface) - dynamic_cast(g_CardMgr.GetRef(SLOT4)).SaveSnapshot(yamlSaveHelper); + if (GetCardMgr().QuerySlot(SLOT4) == CT_MouseInterface) + dynamic_cast(GetCardMgr().GetRef(SLOT4)).SaveSnapshot(yamlSaveHelper); - if (g_CardMgr.QuerySlot(SLOT4) == CT_Z80) + if (GetCardMgr().QuerySlot(SLOT4) == CT_Z80) Z80_SaveSnapshot(yamlSaveHelper, SLOT4); - if (g_CardMgr.QuerySlot(SLOT5) == CT_Z80) + if (GetCardMgr().QuerySlot(SLOT5) == CT_Z80) Z80_SaveSnapshot(yamlSaveHelper, SLOT5); - if (g_CardMgr.QuerySlot(SLOT4) == CT_MockingboardC) + if (GetCardMgr().QuerySlot(SLOT4) == CT_MockingboardC) MB_SaveSnapshot(yamlSaveHelper, SLOT4); - if (g_CardMgr.QuerySlot(SLOT5) == CT_MockingboardC) + if (GetCardMgr().QuerySlot(SLOT5) == CT_MockingboardC) MB_SaveSnapshot(yamlSaveHelper, SLOT5); - if (g_CardMgr.QuerySlot(SLOT4) == CT_Phasor) + if (GetCardMgr().QuerySlot(SLOT4) == CT_Phasor) Phasor_SaveSnapshot(yamlSaveHelper, SLOT4); - if (g_CardMgr.QuerySlot(SLOT5) == CT_Disk2) - dynamic_cast(g_CardMgr.GetRef(SLOT5)).SaveSnapshot(yamlSaveHelper); + if (GetCardMgr().QuerySlot(SLOT5) == CT_Disk2) + dynamic_cast(GetCardMgr().GetRef(SLOT5)).SaveSnapshot(yamlSaveHelper); - if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) - dynamic_cast(g_CardMgr.GetRef(SLOT6)).SaveSnapshot(yamlSaveHelper); + if (GetCardMgr().QuerySlot(SLOT6) == CT_Disk2) + dynamic_cast(GetCardMgr().GetRef(SLOT6)).SaveSnapshot(yamlSaveHelper); - if (g_CardMgr.QuerySlot(SLOT7) == CT_GenericHDD) + if (GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD) HD_SaveSnapshot(yamlSaveHelper); } diff --git a/source/Video.cpp b/source/Video.cpp index 13036808..9831fa14 100644 --- a/source/Video.cpp +++ b/source/Video.cpp @@ -310,7 +310,7 @@ void VideoBenchmark () { while (cycles > 0) { DWORD executedcycles = CpuExecute(103, true); cycles -= executedcycles; - g_CardMgr.GetDisk2CardMgr().UpdateDriveState(executedcycles); + GetCardMgr().GetDisk2CardMgr().UpdateDriveState(executedcycles); JoyUpdateButtonLatch(executedcycles); } }