diff --git a/source/Configuration/Config.cpp b/source/Configuration/Config.cpp index 9e3bb6d4..48d2c8da 100644 --- a/source/Configuration/Config.cpp +++ b/source/Configuration/Config.cpp @@ -62,16 +62,17 @@ CConfigNeedingRestart::CConfigNeedingRestart() m_swapButtons0and1 = false; // Slots - memset(m_Slot, 0, sizeof(m_Slot)); + for (UINT slot = SLOT0; slot < NUM_SLOTS; slot++) + { + m_Slot[slot] = CT_Empty; + ResetAllCardOptions(slot); + } m_SlotAux = CT_Empty; m_tfeVirtualDNS = false; m_RamWorksMemorySize = 0; - memset(m_SaturnMemorySize, 0, sizeof(m_SaturnMemorySize)); m_serialPortItem = 0; m_mouseShowCrosshair = 0; m_mouseRestrictToWindow = 0; - memset(m_diskII13SectorFirmware, 0, sizeof(m_diskII13SectorFirmware)); - memset(m_Mockingboard, 0, sizeof(m_Mockingboard)); m_disk2Card.ForbidSaveDiskImageToRegistry(); m_harddiskCard.ForbidSaveDiskImageToRegistry(); @@ -83,6 +84,22 @@ CConfigNeedingRestart::CConfigNeedingRestart() m_NoSlotClock = false; } +void CConfigNeedingRestart::ResetAllCardOptions(UINT slot) +{ + m_diskII13SectorFirmware[slot] = false; + for (UINT i = DRIVE_1; i < NUM_DRIVES; i++) + m_slotInfoForFDC[slot].pathname[i] = ""; + + for (UINT i = HARDDISK_1; i < NUM_HARDDISKS; i++) + m_slotInfoForHDC[slot].pathname[i] = ""; + + m_SaturnMemorySize[slot] = 0; + + m_Mockingboard[slot].ssi263A = SSI263Empty; + m_Mockingboard[slot].ssi263B = SSI263Empty; + m_Mockingboard[slot].sc01 = SSI263Empty; +} + // Update from current global configuration void CConfigNeedingRestart::Reload() { @@ -146,6 +163,10 @@ void CConfigNeedingRestart::Reload() m_Mockingboard[slot].ssi263B = dynamic_cast(cardManager.GetRef(slot)).GetSocketSSI263(1); m_Mockingboard[slot].sc01 = dynamic_cast(cardManager.GetRef(slot)).GetSocketSC01(); } + else if (m_Slot[slot] == CT_Empty) + { + ResetAllCardOptions(slot); + } } m_RamWorksMemorySize = GetRamWorksMemorySize(); diff --git a/source/Configuration/Config.h b/source/Configuration/Config.h index 7347da31..db107b96 100644 --- a/source/Configuration/Config.h +++ b/source/Configuration/Config.h @@ -30,6 +30,9 @@ struct SlotInfoForMB class CConfigNeedingRestart { +private: + void ResetAllCardOptions(UINT slot); + public: CConfigNeedingRestart(); // zero initialise diff --git a/source/Configuration/PageSlots.cpp b/source/Configuration/PageSlots.cpp index 1fa74bed..ec6ea161 100644 --- a/source/Configuration/PageSlots.cpp +++ b/source/Configuration/PageSlots.cpp @@ -114,7 +114,8 @@ INT_PTR CPageSlots::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPAR case IDC_SLOT5: case IDC_SLOT6: case IDC_SLOT7: - if (HIWORD(wparam) == CBN_SELCHANGE) + // Use CBN_CLOSEUP (instead of CBN_SELCHANGE - which fires for each cursor up/down) + if (HIWORD(wparam) == CBN_CLOSEUP) { const UINT slot = LOWORD(wparam) - IDC_SLOT0; const uint32_t newChoiceItem = (uint32_t)SendDlgItemMessage(hWnd, LOWORD(wparam), CB_GETCURSEL, 0, 0); @@ -125,9 +126,12 @@ INT_PTR CPageSlots::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPAR else _ASSERT(0); - m_PropertySheetHelper.GetConfigNew().m_Slot[slot] = newCard; - - InitOptions(hWnd); + if (m_PropertySheetHelper.GetConfigNew().m_Slot[slot] != newCard) + { + m_PropertySheetHelper.GetConfigNew().m_Slot[slot] = newCard; + ResetCardOptionsToDefault(slot); + InitOptions(hWnd); + } } break; @@ -142,14 +146,12 @@ INT_PTR CPageSlots::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPAR else _ASSERT(0); - m_PropertySheetHelper.GetConfigNew().m_SlotAux = newCard; - - if (newCard == CT_RamWorksIII) - m_PropertySheetHelper.GetConfigNew().m_RamWorksMemorySize = kDefaultExMemoryBanksRealRW3; - else - m_PropertySheetHelper.GetConfigNew().m_RamWorksMemorySize = 1; // Must be 1 for all others (Empty, 80Col, Extended80Col) - - InitOptions(hWnd); // Needed to enable/disable the options button (depending on card) + if (m_PropertySheetHelper.GetConfigNew().m_SlotAux != newCard) + { + m_PropertySheetHelper.GetConfigNew().m_SlotAux = newCard; + ResetCardOptionsToDefault(SLOT_AUX); + InitOptions(hWnd); // Needed to enable/disable the options button (depending on card) + } } break; @@ -442,8 +444,6 @@ void CPageSlots::ApplyConfigAfterClose() void CPageSlots::ResetToDefault() { - // TODO: each card needs setting to its default config too - CConfigNeedingRestart& configNew = m_PropertySheetHelper.GetConfigNew(); for (UINT slot = SLOT0; slot < NUM_SLOTS; slot++) @@ -452,16 +452,29 @@ void CPageSlots::ResetToDefault() if (IsAppleIIe(m_PropertySheetHelper.GetConfigNew().m_Apple2Type)) configNew.m_SlotAux = GetCardMgr().QueryDefaultCardForSlot(SLOT_AUX, configNew.m_Apple2Type); - memset(configNew.m_diskII13SectorFirmware, 0, sizeof(configNew.m_diskII13SectorFirmware)); - for (UINT slot = SLOT0; slot < NUM_SLOTS; slot++) + ResetCardOptionsToDefault(slot); + + ResetCardOptionsToDefault(SLOT_AUX); +} + +void CPageSlots::ResetCardOptionsToDefault(UINT slot) +{ + if (slot < NUM_SLOTS) { - if (configNew.m_Slot[slot] == CT_MockingboardC || configNew.m_Slot[slot] == CT_Phasor) - { - configNew.m_Mockingboard[slot].ssi263A = kSSI263A_Default; - configNew.m_Mockingboard[slot].ssi263B = kSSI263B_Default; - configNew.m_Mockingboard[slot].sc01 = kSC01_Default; - } + ConfigResetDisk2(slot); + ConfigResetHarddisk(slot); + ConfigResetSSC(slot); + ConfigResetPrinter(slot); + ConfigResetMouseCard(slot); + ConfigResetSaturn(slot); + ConfigResetMockingboard(slot); + } + else + { + _ASSERT(slot == SLOT_AUX); + m_PropertySheetHelper.GetConfigNew().m_RamWorksMemorySize = 1; // Must be 1 for all others (Empty, 80Col, Extended80Col) + ConfigResetRamWorks(); } } @@ -699,6 +712,17 @@ void CPageSlots::DlgDisk2OK(HWND hWnd) m_PropertySheetHelper.GetConfigNew().m_diskII13SectorFirmware[ms_slot] = newDiskii13SectorFW; } +void CPageSlots::ConfigResetDisk2(UINT slot) +{ + CConfigNeedingRestart& configNew = m_PropertySheetHelper.GetConfigNew(); + if (configNew.m_Slot[slot] == CT_Disk2) + { + configNew.m_diskII13SectorFirmware[slot] = false; + for (UINT i = DRIVE_1; i < NUM_DRIVES; i++) + configNew.m_slotInfoForFDC[slot].pathname[i] = ""; + } +} + //=========================================================================== INT_PTR CALLBACK CPageSlots::DlgProcHarddisk(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam) @@ -860,14 +884,21 @@ void CPageSlots::HandleHDDCombo(HWND hWnd, UINT driveSelected, UINT comboSelecte SendDlgItemMessage(hWnd, comboSelected, CB_INSERTSTRING, 0, (LPARAM)card.GetFullName(driveSelected).c_str()); SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, 0, 0); - // If the HD was in the other combo, remove now - const uint32_t comboOther = (comboSelected == IDC_SLOT_OPT_COMBO_HDD1) ? IDC_SLOT_OPT_COMBO_HDD2 : IDC_SLOT_OPT_COMBO_HDD1; - - const uint32_t duplicated = (uint32_t)SendDlgItemMessage(hWnd, comboOther, CB_FINDSTRINGEXACT, -1, (LPARAM)card.GetFullName(driveSelected).c_str()); - if (duplicated != CB_ERR) + // If the HD was in any other combo, remove now + for (UINT comboOther = IDC_SLOT_OPT_COMBO_HDD1; comboOther <= IDC_SLOT_OPT_COMBO_HDD8; comboOther++) { - SendDlgItemMessage(hWnd, comboOther, CB_DELETESTRING, duplicated, 0); - SendDlgItemMessage(hWnd, comboOther, CB_SETCURSEL, -1, 0); + if (comboOther == comboSelected) + continue; + + const uint32_t duplicated = (uint32_t)SendDlgItemMessage(hWnd, comboOther, CB_FINDSTRINGEXACT, -1, (LPARAM)card.GetFullName(driveSelected).c_str()); + if (duplicated != CB_ERR) + { + SendDlgItemMessage(hWnd, comboOther, CB_DELETESTRING, duplicated, 0); + SendDlgItemMessage(hWnd, comboOther, CB_SETCURSEL, -1, 0); + + card.Unplug(driveSelected); + m_PropertySheetHelper.GetConfigNew().m_slotInfoForHDC[ms_slot].pathname[driveSelected] = ""; + } } } else if (dwComboSelection == (dwOpenDialogIndex + 1)) @@ -914,6 +945,16 @@ void CPageSlots::DlgHarddiskOK(HWND hWnd) { } +void CPageSlots::ConfigResetHarddisk(UINT slot) +{ + CConfigNeedingRestart& configNew = m_PropertySheetHelper.GetConfigNew(); + if (configNew.m_Slot[slot] == CT_GenericHDD) + { + for (UINT i = HARDDISK_1; i < NUM_HARDDISKS; i++) + configNew.m_slotInfoForHDC[slot].pathname[i] = ""; + } +} + //=========================================================================== UINT CPageSlots::RemovalConfirmation(UINT command) @@ -1011,6 +1052,15 @@ INT_PTR CPageSlots::DlgProcSSCInternal(HWND hWnd, UINT message, WPARAM wparam, L return TRUE; } +void CPageSlots::ConfigResetSSC(UINT slot) +{ + CConfigNeedingRestart& configNew = m_PropertySheetHelper.GetConfigNew(); + if (configNew.m_Slot[slot] == CT_SSC) + { + configNew.m_serialPortItem = 0; // "None" + } +} + //=========================================================================== INT_PTR CALLBACK CPageSlots::DlgProcPrinter(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam) @@ -1103,6 +1153,15 @@ void CPageSlots::DlgPrinterOK(HWND hWnd) card.SetIdleLimit((short)SendDlgItemMessage(hWnd, IDC_SPIN_PRINTER_IDLE, UDM_GETPOS, 0, 0)); } +void CPageSlots::ConfigResetPrinter(UINT slot) +{ + CConfigNeedingRestart& configNew = m_PropertySheetHelper.GetConfigNew(); + if (configNew.m_Slot[slot] == CT_GenericPrinter) + { + configNew.m_parallelPrinterCard.ResetDefaultOptions(); + } +} + //=========================================================================== INT_PTR CALLBACK CPageSlots::DlgProcMouseCard(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam) @@ -1156,6 +1215,16 @@ void CPageSlots::DlgMouseCardOK(HWND hWnd) m_PropertySheetHelper.GetConfigNew().m_mouseRestrictToWindow = IsDlgButtonChecked(hWnd, IDC_MOUSE_RESTRICT_TO_WINDOW) ? 1 : 0; } +void CPageSlots::ConfigResetMouseCard(UINT slot) +{ + CConfigNeedingRestart& configNew = m_PropertySheetHelper.GetConfigNew(); + if (configNew.m_Slot[slot] == CT_MouseInterface) + { + configNew.m_mouseShowCrosshair = 0; + configNew.m_mouseRestrictToWindow = 0; + } +} + //=========================================================================== INT_PTR CALLBACK CPageSlots::DlgProcSaturn(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam) @@ -1216,6 +1285,15 @@ void CPageSlots::DlgSaturnOK(HWND hWnd) m_PropertySheetHelper.GetConfigNew().m_SaturnMemorySize[ms_slot] = size; } +void CPageSlots::ConfigResetSaturn(UINT slot) +{ + CConfigNeedingRestart& configNew = m_PropertySheetHelper.GetConfigNew(); + if (configNew.m_Slot[slot] == CT_Saturn128K) + { + configNew.m_SaturnMemorySize[slot] = Saturn128K::kMaxSaturnBanks; + } +} + //=========================================================================== INT_PTR CALLBACK CPageSlots::DlgProcMockingboard(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam) @@ -1286,6 +1364,17 @@ void CPageSlots::DlgMockingboardOK(HWND hWnd) m_PropertySheetHelper.GetConfigNew().m_Mockingboard[ms_slot].sc01 = sc01; } +void CPageSlots::ConfigResetMockingboard(UINT slot) +{ + CConfigNeedingRestart& configNew = m_PropertySheetHelper.GetConfigNew(); + if (configNew.m_Slot[slot] == CT_MockingboardC || configNew.m_Slot[slot] == CT_Phasor) + { + configNew.m_Mockingboard[slot].ssi263A = kSSI263A_Default; + configNew.m_Mockingboard[slot].ssi263B = kSSI263B_Default; + configNew.m_Mockingboard[slot].sc01 = kSC01_Default; + } +} + //=========================================================================== INT_PTR CALLBACK CPageSlots::DlgProcRamWorks3(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam) @@ -1346,3 +1435,12 @@ void CPageSlots::DlgRamWorks3OK(HWND hWnd) const uint32_t size = (uint32_t)SendDlgItemMessage(hWnd, IDC_SLIDER_RW3_SIZE, TBM_GETPOS, 0, 0); m_PropertySheetHelper.GetConfigNew().m_RamWorksMemorySize = size * 16; // Convert from MB to 64K banks } + +void CPageSlots::ConfigResetRamWorks() +{ + CConfigNeedingRestart& configNew = m_PropertySheetHelper.GetConfigNew(); + if (configNew.m_SlotAux == CT_RamWorksIII) + { + configNew.m_RamWorksMemorySize = kDefaultExMemoryBanksRealRW3; + } +} diff --git a/source/Configuration/PageSlots.h b/source/Configuration/PageSlots.h index 496a5db0..2dfd8214 100644 --- a/source/Configuration/PageSlots.h +++ b/source/Configuration/PageSlots.h @@ -39,6 +39,7 @@ protected: private: void InitOptions(HWND hWnd); + void ResetCardOptionsToDefault(UINT slot); void DiskCardCleanup(); int CardTypeToComboItem(UINT slot); BOOL CardTypeHasOptions(SS_CARDTYPE card); @@ -82,6 +83,15 @@ private: void DlgMockingboardOK(HWND hWnd); void DlgRamWorks3OK(HWND hWnd); + void ConfigResetDisk2(UINT slot); + void ConfigResetHarddisk(UINT slot); + void ConfigResetSSC(UINT slot); + void ConfigResetPrinter(UINT slot); + void ConfigResetMouseCard(UINT slot); + void ConfigResetSaturn(UINT slot); + void ConfigResetMockingboard(UINT slot); + void ConfigResetRamWorks(); + UINT RemovalConfirmation(UINT command); static CPageSlots* ms_this; diff --git a/source/Harddisk.cpp b/source/Harddisk.cpp index 6ed7f06d..0648f59e 100644 --- a/source/Harddisk.cpp +++ b/source/Harddisk.cpp @@ -416,18 +416,22 @@ bool HarddiskInterfaceCard::Insert(const int iDrive, const std::string& pathname else m_hardDiskDrive[iDrive].m_bWriteProtected = (dwAttributes & FILE_ATTRIBUTE_READONLY) ? true : false; - // Check if image is being used by the other HDD, and unplug it in order to be swapped + // Check if image is being used by any other HDD, and unplug it in order to be swapped + for (UINT i = HARDDISK_1; i < NUM_HARDDISKS; i++) { - const std::string & pszOtherPathname = HarddiskGetFullPathName(!iDrive); + if (i == iDrive) + continue; - char szCurrentPathname[MAX_PATH]; + const std::string& pszOtherPathname = HarddiskGetFullPathName(i); + + char szCurrentPathname[MAX_PATH]; DWORD uNameLen = GetFullPathName(pathname.c_str(), MAX_PATH, szCurrentPathname, NULL); if (uNameLen == 0 || uNameLen >= MAX_PATH) strcpy_s(szCurrentPathname, MAX_PATH, pathname.c_str()); if (!strcmp(pszOtherPathname.c_str(), szCurrentPathname)) { - Unplug(!iDrive); + Unplug(i); GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_DISK_STATUS); } } diff --git a/source/ParallelPrinter.cpp b/source/ParallelPrinter.cpp index ef78da71..979860b8 100644 --- a/source/ParallelPrinter.cpp +++ b/source/ParallelPrinter.cpp @@ -174,16 +174,6 @@ void ParallelPrinterCard::SetFilename(const std::string& prtFilename) } } -UINT ParallelPrinterCard::GetIdleLimit(void) -{ - return m_printerIdleLimit; -} - -void ParallelPrinterCard::SetIdleLimit(UINT Duration) -{ - m_printerIdleLimit = Duration; -} - //=========================================================================== void ParallelPrinterCard::GetRegistryConfig(void) diff --git a/source/ParallelPrinter.h b/source/ParallelPrinter.h index 3406d7ea..8a336e80 100644 --- a/source/ParallelPrinter.h +++ b/source/ParallelPrinter.h @@ -12,14 +12,9 @@ public: ThrowErrorInvalidSlot(); m_inactivity = 0; - m_printerIdleLimit = 10; m_file = NULL; - m_bDumpToPrinter = false; - m_bConvertEncoding = false; - m_bFilterUnprintable = false; - m_bPrinterAppend = false; - m_bEnableDumpToRealPrinter = false; + ResetDefaultOptions(); } virtual ~ParallelPrinterCard(void) {} @@ -52,9 +47,8 @@ public: const std::string& GetFilename(void); void SetFilename(const std::string& prtFilename); - UINT GetIdleLimit(void); - void SetIdleLimit(UINT Duration); - + UINT GetIdleLimit(void) { return m_printerIdleLimit; } + void SetIdleLimit(UINT value) { m_printerIdleLimit = value; } bool GetDumpToPrinter(void) { return m_bDumpToPrinter; } void SetDumpToPrinter(bool value) { m_bDumpToPrinter = value; } bool GetConvertEncoding(void) { return m_bConvertEncoding; } @@ -64,7 +58,17 @@ public: bool GetPrinterAppend(void) { return m_bPrinterAppend; } void SetPrinterAppend(bool value) { m_bPrinterAppend = value; } bool GetEnableDumpToRealPrinter(void) { return m_bEnableDumpToRealPrinter; } - void SetEnableDumpToRealPrinter(bool value) { m_bEnableDumpToRealPrinter = value; } + void SetEnableDumpToRealPrinter(bool value) { m_bEnableDumpToRealPrinter = value; } // Set by cmd-line only + + void ResetDefaultOptions() + { + m_printerIdleLimit = 10; + m_bDumpToPrinter = false; + m_bConvertEncoding = false; + m_bFilterUnprintable = false; + m_bPrinterAppend = false; + m_bEnableDumpToRealPrinter = false; + } void GetRegistryConfig(void); void SetRegistryConfig(void); @@ -74,10 +78,10 @@ private: void ClosePrint(void); uint32_t m_inactivity; - UINT m_printerIdleLimit; FILE* m_file; std::string m_szPrintFilename; + UINT m_printerIdleLimit; bool m_bDumpToPrinter; bool m_bConvertEncoding; bool m_bFilterUnprintable;