From 6c031e793002ed8347354aea15f14eb11f5985b8 Mon Sep 17 00:00:00 2001 From: tomcw Date: Sun, 25 Feb 2018 15:09:25 +0000 Subject: [PATCH] Disk II: changing 'enhancedisk' doesn't cause a restart + added accessors (fixes #546) --- source/Applewin.cpp | 7 +++++-- source/Configuration/Config.h | 6 +----- source/Configuration/PageDisk.cpp | 10 ++++++---- source/Configuration/PropertySheetHelper.cpp | 11 +---------- source/Disk.cpp | 13 +++++++------ source/Disk.h | 4 +++- source/DiskImageHelper.cpp | 4 ++-- source/Video.cpp | 1 + 8 files changed, 26 insertions(+), 30 deletions(-) diff --git a/source/Applewin.cpp b/source/Applewin.cpp index dc3bc30c..58eb823a 100644 --- a/source/Applewin.cpp +++ b/source/Applewin.cpp @@ -252,7 +252,7 @@ static void ContinueExecution(void) const bool bWasFullSpeed = g_bFullSpeed; g_bFullSpeed = (g_dwSpeed == SPEED_MAX) || bScrollLock_FullSpeed || - (DiskIsSpinning() && enhancedisk && !Spkr_IsActive() && !MB_IsActive()) || + (DiskIsSpinning() && Disk_GetEnhanceDisk() && !Spkr_IsActive() && !MB_IsActive()) || IsDebugSteppingAtFullSpeed(); if (g_bFullSpeed) @@ -606,7 +606,10 @@ void LoadConfiguration(void) } REGLOAD(TEXT(REGVALUE_EMULATION_SPEED) ,&g_dwSpeed); - REGLOAD(TEXT(REGVALUE_ENHANCE_DISK_SPEED),(DWORD *)&enhancedisk); + + DWORD dwEnhanceDisk; + REGLOAD(TEXT(REGVALUE_ENHANCE_DISK_SPEED), &dwEnhanceDisk); + Disk_SetEnhanceDisk(dwEnhanceDisk ? true : false); Config_Load_Video(); diff --git a/source/Configuration/Config.h b/source/Configuration/Config.h index 657a28e1..e60a3285 100644 --- a/source/Configuration/Config.h +++ b/source/Configuration/Config.h @@ -2,7 +2,7 @@ #include "../Applewin.h" #include "../CPU.h" -#include "../Disk.h" // BOOL enhancedisk +#include "../DiskImage.h" // Disk_Status_e #include "../Harddisk.h" // HD_CardIsEnabled() class CConfigNeedingRestart @@ -11,7 +11,6 @@ public: CConfigNeedingRestart(UINT bEnableTheFreezesF8Rom = false) : m_Apple2Type( GetApple2Type() ), m_CpuType( GetMainCpu() ), - m_bEnhanceDisk(enhancedisk), m_uSaveLoadStateMsg(0) { m_bEnableHDD = HD_CardIsEnabled(); @@ -27,7 +26,6 @@ public: m_Apple2Type = other.m_Apple2Type; m_CpuType = other.m_CpuType; memcpy(m_Slot, other.m_Slot, sizeof(m_Slot)); - m_bEnhanceDisk = other.m_bEnhanceDisk; m_bEnableHDD = other.m_bEnableHDD; m_bEnableTheFreezesF8Rom = other.m_bEnableTheFreezesF8Rom; m_uSaveLoadStateMsg = other.m_uSaveLoadStateMsg; @@ -39,7 +37,6 @@ public: return m_Apple2Type == other.m_Apple2Type && m_CpuType == other.m_CpuType && memcmp(m_Slot, other.m_Slot, sizeof(m_Slot)) == 0 && - m_bEnhanceDisk == other.m_bEnhanceDisk && m_bEnableHDD == other.m_bEnableHDD && m_bEnableTheFreezesF8Rom == other.m_bEnableTheFreezesF8Rom && m_uSaveLoadStateMsg == other.m_uSaveLoadStateMsg; @@ -54,7 +51,6 @@ public: eCpuType m_CpuType; SS_CARDTYPE m_Slot[NUM_SLOTS]; // 0..7 SS_CARDTYPE m_SlotAux; - BOOL m_bEnhanceDisk; bool m_bEnableHDD; UINT m_bEnableTheFreezesF8Rom; UINT m_uSaveLoadStateMsg; diff --git a/source/Configuration/PageDisk.cpp b/source/Configuration/PageDisk.cpp index 00968b67..2e0d97ed 100644 --- a/source/Configuration/PageDisk.cpp +++ b/source/Configuration/PageDisk.cpp @@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "StdAfx.h" #include "../Applewin.h" +#include "../Disk.h" // Drive_e, Disk_Status_e #include "../Frame.h" #include "../Registry.h" #include "../resource/resource.h" @@ -127,7 +128,7 @@ BOOL CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM l case WM_INITDIALOG: { - m_PropertySheetHelper.FillComboBox(hWnd, IDC_DISKTYPE, m_discchoices, enhancedisk); + m_PropertySheetHelper.FillComboBox(hWnd, IDC_DISKTYPE, m_discchoices, Disk_GetEnhanceDisk() ? 1 : 0); m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK1, m_defaultDiskOptions, -1); m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK2, m_defaultDiskOptions, -1); m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_HDD1, m_defaultHDDOptions, -1); @@ -177,10 +178,11 @@ BOOL CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM l void CPageDisk::DlgOK(HWND hWnd) { - const BOOL bNewEnhanceDisk = (BOOL) SendDlgItemMessage(hWnd, IDC_DISKTYPE,CB_GETCURSEL, 0, 0); - if (bNewEnhanceDisk != enhancedisk) + const bool bNewEnhanceDisk = SendDlgItemMessage(hWnd, IDC_DISKTYPE,CB_GETCURSEL, 0, 0) ? true : false; + if (bNewEnhanceDisk != Disk_GetEnhanceDisk()) { - m_PropertySheetHelper.GetConfigNew().m_bEnhanceDisk = bNewEnhanceDisk; + Disk_SetEnhanceDisk(bNewEnhanceDisk); + REGSAVE(TEXT(REGVALUE_ENHANCE_DISK_SPEED), (DWORD)bNewEnhanceDisk); } const bool bNewHDDIsEnabled = IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE) ? true : false; diff --git a/source/Configuration/PropertySheetHelper.cpp b/source/Configuration/PropertySheetHelper.cpp index 35c2bbaf..903013f0 100644 --- a/source/Configuration/PropertySheetHelper.cpp +++ b/source/Configuration/PropertySheetHelper.cpp @@ -45,9 +45,8 @@ Input . Mouse WM_USER_RESTART . CP/M WM_USER_RESTART Sound -. MB/Phasor/SAM/None WM_USER_RESTART +. MB/Phasor/SAM/None WM_USER_RESTART Disk -. Enhanced disk speed WM_USER_RESTART Why? (used to patch Disk][ f/w - but not anymore) . HDD enable WM_USER_RESTART Advanced . Save State WM_USER_SAVESTATE @@ -399,9 +398,6 @@ void CPropertySheetHelper::ApplyNewConfig(const CConfigNeedingRestart& ConfigNew if (CONFIG_CHANGED_LOCAL(m_Slot[5])) SetSlot5(ConfigNew.m_Slot[5]); - if (CONFIG_CHANGED_LOCAL(m_bEnhanceDisk)) - REGSAVE(TEXT(REGVALUE_ENHANCE_DISK_SPEED), ConfigNew.m_bEnhanceDisk); - if (CONFIG_CHANGED_LOCAL(m_bEnableHDD)) { REGSAVE(TEXT(REGVALUE_HDD_ENABLED), ConfigNew.m_bEnableHDD ? 1 : 0); @@ -425,7 +421,6 @@ void CPropertySheetHelper::SaveCurrentConfig(void) m_ConfigOld.m_CpuType = GetMainCpu(); m_ConfigOld.m_Slot[4] = g_Slot4; m_ConfigOld.m_Slot[5] = g_Slot5; - m_ConfigOld.m_bEnhanceDisk = enhancedisk; m_ConfigOld.m_bEnableHDD = HD_CardIsEnabled(); m_ConfigOld.m_bEnableTheFreezesF8Rom = sg_PropertySheet.GetTheFreezesF8Rom(); @@ -444,7 +439,6 @@ void CPropertySheetHelper::RestoreCurrentConfig(void) SetMainCpu(m_ConfigOld.m_CpuType); g_Slot4 = m_ConfigOld.m_Slot[4]; g_Slot5 = m_ConfigOld.m_Slot[5]; - enhancedisk = m_ConfigOld.m_bEnhanceDisk; HD_SetEnabled(m_ConfigOld.m_bEnableHDD); sg_PropertySheet.SetTheFreezesF8Rom(m_ConfigOld.m_bEnableTheFreezesF8Rom); } @@ -503,9 +497,6 @@ bool CPropertySheetHelper::HardwareConfigChanged(HWND hWnd) if (CONFIG_CHANGED(m_Slot[5])) strMsgMain += GetSlot(5); - if (CONFIG_CHANGED(m_bEnhanceDisk)) - strMsgMain += ". Floppy disk speed setting has changed\n"; - if (CONFIG_CHANGED(m_bEnableHDD)) strMsgMain += ". Harddisk(s) have been plugged/unplugged\n"; diff --git a/source/Disk.cpp b/source/Disk.cpp index cc84cedd..3baaa7cf 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -51,10 +51,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA static bool g_bLogDisk_NibblesRW = false; // From VS Debugger, change this to true/false during runtime for precise nibble logging #endif -// Public _________________________________________________________________________________________ - -BOOL enhancedisk = 1; // TODO: Make static & add accessor funcs - // Private ________________________________________________________________________________________ struct Drive_t @@ -102,8 +98,13 @@ static LPCTSTR DiskGetFullPathName(const int iDrive); #define SPINNING_CYCLES (20000*64) // 1280000 cycles = 1.25s #define WRITELIGHT_CYCLES (20000*64) // 1280000 cycles = 1.25s +static bool enhancedisk = true; + //=========================================================================== +bool Disk_GetEnhanceDisk(void) { return enhancedisk; } +void Disk_SetEnhanceDisk(bool bEnhanceDisk) { enhancedisk = bEnhanceDisk; } + int DiskGetCurrentDrive(void) { return currdrive; } int DiskGetCurrentTrack(void) { return g_aFloppyDrive[currdrive].track; } int DiskGetCurrentPhase(void) { return g_aFloppyDrive[currdrive].phase; } @@ -1274,7 +1275,7 @@ int DiskSetSnapshot_v1(const SS_CARD_DISK2* const pSS) phases = pSS->phases; currdrive = pSS->currdrive; //diskaccessed = pSS->diskaccessed; // deprecated - enhancedisk = pSS->enhancedisk; + enhancedisk = pSS->enhancedisk ? true : false; floppylatch = pSS->floppylatch; floppymotoron = pSS->floppymotoron; floppywritemode = pSS->floppywritemode; @@ -1417,7 +1418,7 @@ void DiskSaveSnapshot(class YamlSaveHelper& yamlSaveHelper) yamlSaveHelper.SaveHexUint4(SS_YAML_KEY_PHASES, phases); yamlSaveHelper.SaveUint(SS_YAML_KEY_CURRENT_DRIVE, currdrive); yamlSaveHelper.SaveBool(SS_YAML_KEY_DISK_ACCESSED, false); // deprecated - yamlSaveHelper.SaveBool(SS_YAML_KEY_ENHANCE_DISK, enhancedisk == TRUE); + yamlSaveHelper.SaveBool(SS_YAML_KEY_ENHANCE_DISK, enhancedisk); yamlSaveHelper.SaveHexUint8(SS_YAML_KEY_FLOPPY_LATCH, floppylatch); yamlSaveHelper.SaveBool(SS_YAML_KEY_FLOPPY_MOTOR_ON, floppymotoron == TRUE); yamlSaveHelper.SaveBool(SS_YAML_KEY_FLOPPY_WRITE_MODE, floppywritemode == TRUE); diff --git a/source/Disk.h b/source/Disk.h index 8b08e4d9..7fc8064b 100644 --- a/source/Disk.h +++ b/source/Disk.h @@ -39,7 +39,6 @@ const bool IMAGE_FORCE_WRITE_PROTECTED = true; const bool IMAGE_DONT_CREATE = false; const bool IMAGE_CREATE = true; -extern BOOL enhancedisk; const char* DiskGetDiskPathFilename(const int iDrive); void DiskInitialize(void); // DiskIIManagerStartup() @@ -83,6 +82,9 @@ void Disk_SaveLastDiskImage(const int iDrive); bool Disk_ImageIsWriteProtected(const int iDrive); bool Disk_IsDriveEmpty(const int iDrive); +bool Disk_GetEnhanceDisk(void); +void Disk_SetEnhanceDisk(bool bEnhanceDisk); + // // For sharing with class FormatTrack diff --git a/source/DiskImageHelper.cpp b/source/DiskImageHelper.cpp index b45d2d0e..5aa50d5d 100644 --- a/source/DiskImageHelper.cpp +++ b/source/DiskImageHelper.cpp @@ -635,7 +635,7 @@ public: { ReadTrack(pImageInfo, nTrack, ms_pWorkBuffer, TRACK_DENIBBLIZED_SIZE); *pNibbles = NibblizeTrack(pTrackImageBuffer, eDOSOrder, nTrack); - if (!enhancedisk) + if (!Disk_GetEnhanceDisk()) SkewTrack(nTrack, *pNibbles, pTrackImageBuffer); } @@ -701,7 +701,7 @@ public: { ReadTrack(pImageInfo, nTrack, ms_pWorkBuffer, TRACK_DENIBBLIZED_SIZE); *pNibbles = NibblizeTrack(pTrackImageBuffer, eProDOSOrder, nTrack); - if (!enhancedisk) + if (!Disk_GetEnhanceDisk()) SkewTrack(nTrack, *pNibbles, pTrackImageBuffer); } diff --git a/source/Video.cpp b/source/Video.cpp index 670ce778..549cd5eb 100644 --- a/source/Video.cpp +++ b/source/Video.cpp @@ -30,6 +30,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "Applewin.h" #include "CPU.h" +#include "Disk.h" // DiskUpdateDriveState() #include "Frame.h" #include "Keyboard.h" #include "Memory.h"