From e7d6eac04d4d1fd05c68ada95b791ba95e358dc6 Mon Sep 17 00:00:00 2001 From: tomcw Date: Sun, 7 Apr 2019 14:22:05 +0100 Subject: [PATCH 1/7] Class-ify disk.cpp into DiskIIInterfaceCard --- source/Applewin.cpp | 17 +- source/Configuration/PageDisk.cpp | 22 +-- source/Configuration/PropertySheetHelper.cpp | 2 +- source/Debugger/Debug.cpp | 18 +- source/Disk.cpp | 196 +++++++++---------- source/Disk.h | 108 ++++++---- source/DiskImage.cpp | 5 +- source/DiskImage.h | 2 +- source/DiskImageHelper.cpp | 15 +- source/DiskImageHelper.h | 2 +- source/Frame.cpp | 50 ++--- source/Memory.cpp | 2 +- source/SaveState.cpp | 8 +- source/Video.cpp | 2 +- 14 files changed, 243 insertions(+), 206 deletions(-) diff --git a/source/Applewin.cpp b/source/Applewin.cpp index 4cf53765..402b44de 100644 --- a/source/Applewin.cpp +++ b/source/Applewin.cpp @@ -105,6 +105,7 @@ int g_nMemoryClearType = MIP_FF_FF_00_00; // Note: -1 = random MIP in Memory.c IPropertySheet& sg_PropertySheet = * new CPropertySheet; CSuperSerialCard sg_SSC; CMouseInterface sg_Mouse; +DiskIIInterfaceCard sg_DiskIICard; SS_CARDTYPE g_Slot0 = CT_LanguageCard; // Just for Apple II or II+ or similar clones SS_CARDTYPE g_Slot4 = CT_Empty; @@ -269,7 +270,7 @@ static void ContinueExecution(void) const bool bWasFullSpeed = g_bFullSpeed; g_bFullSpeed = (g_dwSpeed == SPEED_MAX) || bScrollLock_FullSpeed || - (Disk_IsConditionForFullSpeed() && !Spkr_IsActive() && !MB_IsActive()) || + (sg_DiskIICard.Disk_IsConditionForFullSpeed() && !Spkr_IsActive() && !MB_IsActive()) || IsDebugSteppingAtFullSpeed(); if (g_bFullSpeed) @@ -316,7 +317,7 @@ static void ContinueExecution(void) const DWORD uActualCyclesExecuted = CpuExecute(uCyclesToExecute, bVideoUpdate); g_dwCyclesThisFrame += uActualCyclesExecuted; - DiskUpdateDriveState(uActualCyclesExecuted); + sg_DiskIICard.DiskUpdateDriveState(uActualCyclesExecuted); JoyUpdateButtonLatch(nExecutionPeriodUsec); // Button latch time is independent of CPU clock frequency PrintUpdate(uActualCyclesExecuted); @@ -624,7 +625,7 @@ void LoadConfiguration(void) DWORD dwEnhanceDisk; REGLOAD(TEXT(REGVALUE_ENHANCE_DISK_SPEED), &dwEnhanceDisk); - Disk_SetEnhanceDisk(dwEnhanceDisk ? true : false); + sg_DiskIICard.Disk_SetEnhanceDisk(dwEnhanceDisk ? true : false); Config_Load_Video(); @@ -713,8 +714,8 @@ void LoadConfiguration(void) GetCurrentDirectory(sizeof(szFilename), szFilename); SetCurrentImageDir(szFilename); - Disk_LoadLastDiskImage(DRIVE_1); - Disk_LoadLastDiskImage(DRIVE_2); + sg_DiskIICard.Disk_LoadLastDiskImage(DRIVE_1); + sg_DiskIICard.Disk_LoadLastDiskImage(DRIVE_2); // @@ -1061,7 +1062,7 @@ static bool DoDiskInsert(const int nDrive, LPCSTR szFileName) std::string strPathName = GetFullPath(szFileName); if (strPathName.empty()) return false; - ImageError_e Error = DiskInsert(nDrive, strPathName.c_str(), IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); + ImageError_e Error = sg_DiskIICard.DiskInsert(nDrive, strPathName.c_str(), IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); return Error == eIMAGE_ERROR_NONE; } @@ -1521,7 +1522,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) ImageInitialize(); LogFileOutput("Init: ImageInitialize()\n"); - DiskInitialize(); + sg_DiskIICard.DiskInitialize(); LogFileOutput("Init: DiskInitialize()\n"); // @@ -1615,7 +1616,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) } // Need to test if it's safe to call ResetMachineState(). In the meantime, just call DiskReset(): - DiskReset(); // Switch from a booting A][+ to a non-autostart A][, so need to turn off floppy motor + sg_DiskIICard.DiskReset(); // 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/Configuration/PageDisk.cpp b/source/Configuration/PageDisk.cpp index 68b6cd8f..f871ade5 100644 --- a/source/Configuration/PageDisk.cpp +++ b/source/Configuration/PageDisk.cpp @@ -130,19 +130,19 @@ BOOL CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM l case WM_INITDIALOG: { - m_PropertySheetHelper.FillComboBox(hWnd, IDC_DISKTYPE, m_discchoices, Disk_GetEnhanceDisk() ? 1 : 0); + m_PropertySheetHelper.FillComboBox(hWnd, IDC_DISKTYPE, m_discchoices, sg_DiskIICard.Disk_GetEnhanceDisk() ? 1 : 0); m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK1, m_defaultDiskOptions, -1); m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK2, m_defaultDiskOptions, -1); - if (strlen(DiskGetFullName(DRIVE_1)) > 0) + if (strlen(sg_DiskIICard.DiskGetFullName(DRIVE_1)) > 0) { - SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_INSERTSTRING, 0, (LPARAM)DiskGetFullName(DRIVE_1)); + SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_INSERTSTRING, 0, (LPARAM)sg_DiskIICard.DiskGetFullName(DRIVE_1)); SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_SETCURSEL, 0, 0); } - if (strlen(DiskGetFullName(DRIVE_2)) > 0) + if (strlen(sg_DiskIICard.DiskGetFullName(DRIVE_2)) > 0) { - SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_INSERTSTRING, 0, (LPARAM)DiskGetFullName(DRIVE_2)); + SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_INSERTSTRING, 0, (LPARAM)sg_DiskIICard.DiskGetFullName(DRIVE_2)); SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_SETCURSEL, 0, 0); } @@ -187,9 +187,9 @@ void CPageDisk::InitComboHDD(HWND hWnd) void CPageDisk::DlgOK(HWND hWnd) { const bool bNewEnhanceDisk = SendDlgItemMessage(hWnd, IDC_DISKTYPE,CB_GETCURSEL, 0, 0) ? true : false; - if (bNewEnhanceDisk != Disk_GetEnhanceDisk()) + if (bNewEnhanceDisk != sg_DiskIICard.Disk_GetEnhanceDisk()) { - Disk_SetEnhanceDisk(bNewEnhanceDisk); + sg_DiskIICard.Disk_SetEnhanceDisk(bNewEnhanceDisk); REGSAVE(TEXT(REGVALUE_ENHANCE_DISK_SPEED), (DWORD)bNewEnhanceDisk); } @@ -299,7 +299,7 @@ void CPageDisk::HandleDiskCombo(HWND hWnd, UINT driveSelected, UINT comboSelecte if (dwComboSelection == dwOpenDialogIndex) { EnableDisk(hWnd, FALSE); // Prevent multiple Selection dialogs to be triggered - bool bRes = DiskSelect(driveSelected); + bool bRes = sg_DiskIICard.DiskSelect(driveSelected); EnableDisk(hWnd, TRUE); if (!bRes) @@ -316,13 +316,13 @@ void CPageDisk::HandleDiskCombo(HWND hWnd, UINT driveSelected, UINT comboSelecte SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0); } - SendDlgItemMessage(hWnd, comboSelected, CB_INSERTSTRING, 0, (LPARAM)DiskGetFullName(driveSelected)); + SendDlgItemMessage(hWnd, comboSelected, CB_INSERTSTRING, 0, (LPARAM)sg_DiskIICard.DiskGetFullName(driveSelected)); SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, 0, 0); // If the FD was in the other combo, remove now DWORD comboOther = (comboSelected == IDC_COMBO_DISK1) ? IDC_COMBO_DISK2 : IDC_COMBO_DISK1; - DWORD duplicated = (DWORD)SendDlgItemMessage(hWnd, comboOther, CB_FINDSTRINGEXACT, -1, (LPARAM)DiskGetFullName(driveSelected)); + DWORD duplicated = (DWORD)SendDlgItemMessage(hWnd, comboOther, CB_FINDSTRINGEXACT, -1, (LPARAM)sg_DiskIICard.DiskGetFullName(driveSelected)); if (duplicated != CB_ERR) { SendDlgItemMessage(hWnd, comboOther, CB_DELETESTRING, duplicated, 0); @@ -337,7 +337,7 @@ void CPageDisk::HandleDiskCombo(HWND hWnd, UINT driveSelected, UINT comboSelecte if (RemovalConfirmation(uCommand)) { // Eject selected disk - DiskEject(driveSelected); + sg_DiskIICard.DiskEject(driveSelected); // Remove drive from list SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0); } diff --git a/source/Configuration/PropertySheetHelper.cpp b/source/Configuration/PropertySheetHelper.cpp index 903013f0..5f26e5d6 100644 --- a/source/Configuration/PropertySheetHelper.cpp +++ b/source/Configuration/PropertySheetHelper.cpp @@ -198,7 +198,7 @@ void CPropertySheetHelper::SaveStateUpdate() void CPropertySheetHelper::GetDiskBaseNameWithAWS(TCHAR* pszFilename) { - LPCTSTR pDiskName = DiskGetBaseName(DRIVE_1); + LPCTSTR pDiskName = sg_DiskIICard.DiskGetBaseName(DRIVE_1); if (pDiskName && pDiskName[0]) { strcpy(pszFilename, pDiskName); diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index 33ef6e60..cb37c579 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -3727,15 +3727,15 @@ Update_t CmdDisk ( int nArgs) if (nArgs > 2) goto _Help; - int drive = DiskGetCurrentDrive() + 1; + int drive = sg_DiskIICard.DiskGetCurrentDrive() + 1; char buffer[200] = ""; ConsoleBufferPushFormat(buffer, "D%d at T$%X (%d), phase $%X, offset $%X, %s", drive, - DiskGetCurrentTrack(), - DiskGetCurrentTrack(), - DiskGetCurrentPhase(), - DiskGetCurrentOffset(), - DiskGetCurrentState()); + sg_DiskIICard.DiskGetCurrentTrack(), + sg_DiskIICard.DiskGetCurrentTrack(), + sg_DiskIICard.DiskGetCurrentPhase(), + sg_DiskIICard.DiskGetCurrentOffset(), + sg_DiskIICard.DiskGetCurrentState()); return ConsoleUpdate(); } @@ -3762,7 +3762,7 @@ Update_t CmdDisk ( int nArgs) if (nArgs > 2) goto _Help; - DiskEject( iDrive ); + sg_DiskIICard.DiskEject( iDrive ); FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); } else @@ -3776,7 +3776,7 @@ Update_t CmdDisk ( int nArgs) if (nArgs == 3) bProtect = g_aArgs[ 3 ].nValue ? true : false; - DiskSetProtect( iDrive, bProtect ); + sg_DiskIICard.DiskSetProtect( iDrive, bProtect ); FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); } else @@ -3787,7 +3787,7 @@ Update_t CmdDisk ( int nArgs) LPCTSTR pDiskName = g_aArgs[ 3 ].sArg; // DISK # "Diskname" - DiskInsert( iDrive, pDiskName, IMAGE_FORCE_WRITE_PROTECTED, IMAGE_DONT_CREATE ); + sg_DiskIICard.DiskInsert( iDrive, pDiskName, IMAGE_FORCE_WRITE_PROTECTED, IMAGE_DONT_CREATE ); FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); } diff --git a/source/Disk.cpp b/source/Disk.cpp index a7ef7c4b..7ab9ac58 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -99,21 +99,21 @@ static bool enhancedisk = true; //=========================================================================== -bool Disk_GetEnhanceDisk(void) { return enhancedisk; } -void Disk_SetEnhanceDisk(bool bEnhanceDisk) { enhancedisk = bEnhanceDisk; } +bool DiskIIInterfaceCard::Disk_GetEnhanceDisk(void) { return enhancedisk; } +void DiskIIInterfaceCard::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; } -int DiskGetCurrentOffset(void) { return g_aFloppyDrive[currdrive].disk.byte; } -int DiskGetTrack( int drive ) { return g_aFloppyDrive[ drive ].track; } +int DiskIIInterfaceCard::DiskGetCurrentDrive(void) { return currdrive; } +int DiskIIInterfaceCard::DiskGetCurrentTrack(void) { return g_aFloppyDrive[currdrive].track; } +int DiskIIInterfaceCard::DiskGetCurrentPhase(void) { return g_aFloppyDrive[currdrive].phase; } +int DiskIIInterfaceCard::DiskGetCurrentOffset(void) { return g_aFloppyDrive[currdrive].disk.byte; } +int DiskIIInterfaceCard::DiskGetTrack( int drive ) { return g_aFloppyDrive[ drive ].track; } -const char* DiskGetDiskPathFilename(const int iDrive) +const char* DiskIIInterfaceCard::DiskGetDiskPathFilename(const int iDrive) { return g_aFloppyDrive[iDrive].disk.fullname; } -const char* DiskGetCurrentState(void) +const char* DiskIIInterfaceCard::DiskGetCurrentState(void) { if (g_aFloppyDrive[currdrive].disk.imagehandle == NULL) return "Empty"; @@ -148,7 +148,7 @@ const char* DiskGetCurrentState(void) //=========================================================================== -void Disk_LoadLastDiskImage(const int iDrive) +void DiskIIInterfaceCard::Disk_LoadLastDiskImage(const int iDrive) { _ASSERT(iDrive == DRIVE_1 || iDrive == DRIVE_2); @@ -172,7 +172,7 @@ void Disk_LoadLastDiskImage(const int iDrive) //=========================================================================== -void Disk_SaveLastDiskImage(const int iDrive) +void DiskIIInterfaceCard::Disk_SaveLastDiskImage(const int iDrive) { _ASSERT(iDrive == DRIVE_1 || iDrive == DRIVE_2); @@ -201,7 +201,7 @@ void Disk_SaveLastDiskImage(const int iDrive) //=========================================================================== // Called by DiskControlMotor() & DiskEnable() -static void CheckSpinning(const ULONG nExecutedCycles) +void DiskIIInterfaceCard::CheckSpinning(const ULONG nExecutedCycles) { DWORD modechange = (floppymotoron && !g_aFloppyDrive[currdrive].spinning); @@ -221,7 +221,7 @@ static void CheckSpinning(const ULONG nExecutedCycles) //=========================================================================== -static Disk_Status_e GetDriveLightStatus(const int iDrive) +Disk_Status_e DiskIIInterfaceCard::GetDriveLightStatus(const int iDrive) { if (IsDriveValid( iDrive )) { @@ -248,14 +248,14 @@ static Disk_Status_e GetDriveLightStatus(const int iDrive) //=========================================================================== -static bool IsDriveValid(const int iDrive) +bool DiskIIInterfaceCard::IsDriveValid(const int iDrive) { return (iDrive >= 0 && iDrive < NUM_DRIVES); } //=========================================================================== -static void AllocTrack(const int iDrive) +void DiskIIInterfaceCard::AllocTrack(const int iDrive) { Disk_t* pFloppy = &g_aFloppyDrive[iDrive].disk; pFloppy->trackimage = (LPBYTE)VirtualAlloc(NULL, NIBBLES_PER_TRACK, MEM_COMMIT, PAGE_READWRITE); @@ -263,7 +263,7 @@ static void AllocTrack(const int iDrive) //=========================================================================== -static void ReadTrack(const int iDrive) +void DiskIIInterfaceCard::ReadTrack(const int iDrive) { if (! IsDriveValid( iDrive )) return; @@ -290,7 +290,8 @@ static void ReadTrack(const int iDrive) pDrive->track, pDrive->phase, pFloppy->trackimage, - &pFloppy->nibbles); + &pFloppy->nibbles, + enhancedisk); pFloppy->byte = 0; pFloppy->trackimagedata = (pFloppy->nibbles != 0); @@ -299,7 +300,7 @@ static void ReadTrack(const int iDrive) //=========================================================================== -static void RemoveDisk(const int iDrive) +void DiskIIInterfaceCard::RemoveDisk(const int iDrive) { Disk_t* pFloppy = &g_aFloppyDrive[iDrive].disk; @@ -328,7 +329,7 @@ static void RemoveDisk(const int iDrive) //=========================================================================== -static void WriteTrack(const int iDrive) +void DiskIIInterfaceCard::WriteTrack(const int iDrive) { Drive_t* pDrive = &g_aFloppyDrive[ iDrive ]; Disk_t* pFloppy = &pDrive->disk; @@ -355,7 +356,7 @@ static void WriteTrack(const int iDrive) pFloppy->trackimagedirty = false; } -void DiskFlushCurrentTrack(const int iDrive) +void DiskIIInterfaceCard::DiskFlushCurrentTrack(const int iDrive) { Disk_t* pFloppy = &g_aFloppyDrive[iDrive].disk; @@ -363,13 +364,9 @@ void DiskFlushCurrentTrack(const int iDrive) WriteTrack(iDrive); } -// -// ----- ALL GLOBALLY ACCESSIBLE FUNCTIONS ARE BELOW THIS LINE ----- -// - //=========================================================================== -void DiskBoot(void) +void DiskIIInterfaceCard::DiskBoot(void) { // THIS FUNCTION RELOADS A PROGRAM IMAGE IF ONE IS LOADED IN DRIVE ONE. // IF A DISK IMAGE OR NO IMAGE IS LOADED IN DRIVE ONE, IT DOES NOTHING. @@ -379,7 +376,7 @@ void DiskBoot(void) //=========================================================================== -static void __stdcall DiskControlMotor(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles) +void __stdcall DiskIIInterfaceCard::DiskControlMotor(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles) { BOOL newState = address & 1; @@ -397,7 +394,7 @@ static void __stdcall DiskControlMotor(WORD, WORD address, BYTE, BYTE, ULONG uEx //=========================================================================== -static void __stdcall DiskControlStepper(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles) +void __stdcall DiskIIInterfaceCard::DiskControlStepper(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles) { Drive_t* pDrive = &g_aFloppyDrive[currdrive]; Disk_t* pFloppy = &pDrive->disk; @@ -484,7 +481,7 @@ static void __stdcall DiskControlStepper(WORD, WORD address, BYTE, BYTE, ULONG u //=========================================================================== -void DiskDestroy(void) +void DiskIIInterfaceCard::DiskDestroy(void) { g_bSaveDiskImage = false; RemoveDisk(DRIVE_1); @@ -497,7 +494,7 @@ void DiskDestroy(void) //=========================================================================== -static void __stdcall DiskEnable(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles) +void __stdcall DiskIIInterfaceCard::DiskEnable(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles) { currdrive = address & 1; #if LOG_DISK_ENABLE_DRIVE @@ -510,7 +507,7 @@ static void __stdcall DiskEnable(WORD, WORD address, BYTE, BYTE, ULONG uExecuted //=========================================================================== -void DiskEject(const int iDrive) +void DiskIIInterfaceCard::DiskEject(const int iDrive) { if (IsDriveValid(iDrive)) { @@ -522,14 +519,14 @@ void DiskEject(const int iDrive) // Return the file or zip name // . Used by Property Sheet Page (Disk) -LPCTSTR DiskGetFullName(const int iDrive) +LPCTSTR DiskIIInterfaceCard::DiskGetFullName(const int iDrive) { return g_aFloppyDrive[iDrive].disk.fullname; } // Return the filename // . Used by Drive Buttons' tooltips -LPCTSTR DiskGetFullDiskFilename(const int iDrive) +LPCTSTR DiskIIInterfaceCard::DiskGetFullDiskFilename(const int iDrive) { if (!g_aFloppyDrive[iDrive].disk.strFilenameInZip.empty()) return g_aFloppyDrive[iDrive].disk.strFilenameInZip.c_str(); @@ -537,20 +534,20 @@ LPCTSTR DiskGetFullDiskFilename(const int iDrive) return DiskGetFullName(iDrive); } -static LPCTSTR DiskGetFullPathName(const int iDrive) +LPCTSTR DiskIIInterfaceCard::DiskGetFullPathName(const int iDrive) { return ImageGetPathname(g_aFloppyDrive[iDrive].disk.imagehandle); } // Return the imagename // . Used by Drive Button's icons & Property Sheet Page (Save snapshot) -LPCTSTR DiskGetBaseName(const int iDrive) +LPCTSTR DiskIIInterfaceCard::DiskGetBaseName(const int iDrive) { return g_aFloppyDrive[iDrive].disk.imagename; } //=========================================================================== -void DiskGetLightStatus(Disk_Status_e *pDisk1Status, Disk_Status_e *pDisk2Status) +void DiskIIInterfaceCard::DiskGetLightStatus(Disk_Status_e *pDisk1Status, Disk_Status_e *pDisk2Status) { if (pDisk1Status) *pDisk1Status = GetDriveLightStatus(DRIVE_1); @@ -561,7 +558,7 @@ void DiskGetLightStatus(Disk_Status_e *pDisk1Status, Disk_Status_e *pDisk2Status //=========================================================================== -void DiskInitialize(void) +void DiskIIInterfaceCard::DiskInitialize(void) { int loop = NUM_DRIVES; while (loop--) @@ -570,7 +567,7 @@ void DiskInitialize(void) //=========================================================================== -ImageError_e DiskInsert(const int iDrive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary) +ImageError_e DiskIIInterfaceCard::DiskInsert(const int iDrive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary) { Drive_t* pDrive = &g_aFloppyDrive[iDrive]; Disk_t* pFloppy = &pDrive->disk; @@ -646,19 +643,19 @@ ImageError_e DiskInsert(const int iDrive, LPCTSTR pszImageFilename, const bool b //=========================================================================== -bool Disk_IsConditionForFullSpeed(void) +bool DiskIIInterfaceCard::Disk_IsConditionForFullSpeed(void) { return floppymotoron && enhancedisk; } -BOOL DiskIsSpinning(void) +BOOL DiskIIInterfaceCard::DiskIsSpinning(void) { return floppymotoron; } //=========================================================================== -void DiskNotifyInvalidImage(const int iDrive, LPCTSTR pszImageFilename, const ImageError_e Error) +void DiskIIInterfaceCard::DiskNotifyInvalidImage(const int iDrive, LPCTSTR pszImageFilename, const ImageError_e Error) { TCHAR szBuffer[MAX_PATH+128]; szBuffer[sizeof(szBuffer)-1] = 0; @@ -772,7 +769,7 @@ void DiskNotifyInvalidImage(const int iDrive, LPCTSTR pszImageFilename, const Im //=========================================================================== -bool DiskGetProtect(const int iDrive) +bool DiskIIInterfaceCard::DiskGetProtect(const int iDrive) { if (IsDriveValid(iDrive)) { @@ -786,7 +783,7 @@ bool DiskGetProtect(const int iDrive) //=========================================================================== -void DiskSetProtect(const int iDrive, const bool bWriteProtect) +void DiskIIInterfaceCard::DiskSetProtect(const int iDrive, const bool bWriteProtect) { if (IsDriveValid( iDrive )) { @@ -797,7 +794,7 @@ void DiskSetProtect(const int iDrive, const bool bWriteProtect) //=========================================================================== -bool Disk_ImageIsWriteProtected(const int iDrive) +bool DiskIIInterfaceCard::Disk_ImageIsWriteProtected(const int iDrive) { if (!IsDriveValid(iDrive)) return true; @@ -807,7 +804,7 @@ bool Disk_ImageIsWriteProtected(const int iDrive) //=========================================================================== -bool Disk_IsDriveEmpty(const int iDrive) +bool DiskIIInterfaceCard::Disk_IsDriveEmpty(const int iDrive) { if (!IsDriveValid(iDrive)) return true; @@ -821,7 +818,7 @@ bool Disk_IsDriveEmpty(const int iDrive) static UINT64 g_uWriteLastCycle = 0; static UINT g_uSyncFFCount = 0; -static bool LogWriteCheckSyncFF(ULONG& uCycleDelta) +bool DiskIIInterfaceCard::LogWriteCheckSyncFF(ULONG& uCycleDelta) { bool bIsSyncFF = false; @@ -851,7 +848,7 @@ static bool LogWriteCheckSyncFF(ULONG& uCycleDelta) //=========================================================================== -static void __stdcall DiskReadWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles) +void __stdcall DiskIIInterfaceCard::DiskReadWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles) { /* floppyloadmode = 0; */ Drive_t* pDrive = &g_aFloppyDrive[currdrive]; @@ -965,7 +962,7 @@ static void __stdcall DiskReadWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULO //=========================================================================== -void DiskReset(const bool bIsPowerCycle/*=false*/) +void DiskIIInterfaceCard::DiskReset(const bool bIsPowerCycle/*=false*/) { // RESET forces all switches off (UTAIIe Table 9.1) currdrive = 0; @@ -993,7 +990,7 @@ void DiskReset(const bool bIsPowerCycle/*=false*/) //=========================================================================== -static bool DiskSelectImage(const int iDrive, LPCSTR pszFilename) +bool DiskIIInterfaceCard::DiskSelectImage(const int iDrive, LPCSTR pszFilename) { TCHAR directory[MAX_PATH] = TEXT(""); TCHAR filename[MAX_PATH] = TEXT(""); @@ -1044,14 +1041,14 @@ static bool DiskSelectImage(const int iDrive, LPCSTR pszFilename) //=========================================================================== -bool DiskSelect(const int iDrive) +bool DiskIIInterfaceCard::DiskSelect(const int iDrive) { return DiskSelectImage(iDrive, TEXT("")); } //=========================================================================== -static void __stdcall DiskLoadWriteProtect(WORD, WORD, BYTE write, BYTE value, ULONG) +void __stdcall DiskIIInterfaceCard::DiskLoadWriteProtect(WORD, WORD, BYTE write, BYTE value, ULONG) { /* floppyloadmode = 1; */ @@ -1077,7 +1074,7 @@ static void __stdcall DiskLoadWriteProtect(WORD, WORD, BYTE write, BYTE value, U //=========================================================================== -static void __stdcall DiskSetReadMode(WORD, WORD, BYTE, BYTE, ULONG) +void __stdcall DiskIIInterfaceCard::DiskSetReadMode(WORD, WORD, BYTE, BYTE, ULONG) { floppywritemode = 0; @@ -1090,7 +1087,7 @@ static void __stdcall DiskSetReadMode(WORD, WORD, BYTE, BYTE, ULONG) //=========================================================================== -static void __stdcall DiskSetWriteMode(WORD, WORD, BYTE, BYTE, ULONG uExecutedCycles) +void __stdcall DiskIIInterfaceCard::DiskSetWriteMode(WORD, WORD, BYTE, BYTE, ULONG uExecutedCycles) { floppywritemode = 1; @@ -1112,7 +1109,7 @@ static void __stdcall DiskSetWriteMode(WORD, WORD, BYTE, BYTE, ULONG uExecutedCy //=========================================================================== -void DiskUpdateDriveState(DWORD cycles) +void DiskIIInterfaceCard::DiskUpdateDriveState(DWORD cycles) { int loop = NUM_DRIVES; while (loop--) @@ -1145,7 +1142,7 @@ void DiskUpdateDriveState(DWORD cycles) //=========================================================================== -bool DiskDriveSwap(void) +bool DiskIIInterfaceCard::DiskDriveSwap(void) { // Refuse to swap if either Disk][ is active // TODO: if Shift-Click then FORCE drive swap to bypass message @@ -1200,11 +1197,8 @@ bool DiskDriveSwap(void) //=========================================================================== -static BYTE __stdcall Disk_IORead(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles); -static BYTE __stdcall Disk_IOWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles); - // TODO: LoadRom_Disk_Floppy() -void DiskLoadRom(LPBYTE pCxRomPeripheral, UINT uSlot) +void DiskIIInterfaceCard::Initialize(LPBYTE pCxRomPeripheral, UINT uSlot) { const UINT DISK2_FW_SIZE = APPLE_SLOT_SIZE; @@ -1233,33 +1227,36 @@ void DiskLoadRom(LPBYTE pCxRomPeripheral, UINT uSlot) // . Patching the firmware breaks the ADC checksum used by "The CIA Files" (Tricky Dick) // . In this case we can patch to compensate for an ADC or EOR checksum but not both (nickw) - RegisterIoHandler(uSlot, Disk_IORead, Disk_IOWrite, NULL, NULL, NULL, NULL); + RegisterIoHandler(uSlot, &DiskIIInterfaceCard::Disk_IORead, &DiskIIInterfaceCard::Disk_IOWrite, NULL, NULL, this, NULL); g_uSlot = uSlot; } //=========================================================================== -static BYTE __stdcall Disk_IORead(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles) +BYTE __stdcall DiskIIInterfaceCard::Disk_IORead(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles) { + UINT uSlot = ((addr & 0xff) >> 4) - 8; + DiskIIInterfaceCard* pCard = (DiskIIInterfaceCard*) MemGetSlotParameters(uSlot); + switch (addr & 0xF) { - case 0x0: DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x1: DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x2: DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x3: DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x4: DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x5: DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x6: DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x7: DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x8: DiskControlMotor(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x9: DiskControlMotor(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xA: DiskEnable(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xB: DiskEnable(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xC: DiskReadWrite(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xD: DiskLoadWriteProtect(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xE: DiskSetReadMode(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xF: DiskSetWriteMode(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x0: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x1: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x2: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x3: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x4: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x5: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x6: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x7: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x8: pCard->DiskControlMotor(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x9: pCard->DiskControlMotor(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xA: pCard->DiskEnable(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xB: pCard->DiskEnable(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xC: pCard->DiskReadWrite(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xD: pCard->DiskLoadWriteProtect(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xE: pCard->DiskSetReadMode(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xF: pCard->DiskSetWriteMode(pc, addr, bWrite, d, nExecutedCycles); break; } // only even addresses return the latch (UTAIIe Table 9.1) @@ -1269,26 +1266,29 @@ static BYTE __stdcall Disk_IORead(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG return MemReadFloatingBus(nExecutedCycles); } -static BYTE __stdcall Disk_IOWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles) +BYTE __stdcall DiskIIInterfaceCard::Disk_IOWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles) { + UINT uSlot = ((addr & 0xff) >> 4) - 8; + DiskIIInterfaceCard* pCard = (DiskIIInterfaceCard*) MemGetSlotParameters(uSlot); + switch (addr & 0xF) { - case 0x0: DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x1: DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x2: DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x3: DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x4: DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x5: DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x6: DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x7: DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x8: DiskControlMotor(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x9: DiskControlMotor(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xA: DiskEnable(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xB: DiskEnable(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xC: DiskReadWrite(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xD: DiskLoadWriteProtect(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xE: DiskSetReadMode(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xF: DiskSetWriteMode(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x0: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x1: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x2: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x3: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x4: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x5: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x6: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x7: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x8: pCard->DiskControlMotor(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x9: pCard->DiskControlMotor(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xA: pCard->DiskEnable(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xB: pCard->DiskEnable(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xC: pCard->DiskReadWrite(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xD: pCard->DiskLoadWriteProtect(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xE: pCard->DiskSetReadMode(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xF: pCard->DiskSetWriteMode(pc, addr, bWrite, d, nExecutedCycles); break; } // any address writes the latch via sequencer LD command (74LS323 datasheet) @@ -1331,13 +1331,13 @@ static const UINT kUNIT_VERSION = 3; #define SS_YAML_KEY_TRACK_IMAGE_DIRTY "Track Image Dirty" #define SS_YAML_KEY_TRACK_IMAGE "Track Image" -std::string DiskGetSnapshotCardName(void) +std::string DiskIIInterfaceCard::DiskGetSnapshotCardName(void) { static const std::string name(SS_YAML_VALUE_CARD_DISK2); return name; } -static void DiskSaveSnapshotDisk2Unit(YamlSaveHelper& yamlSaveHelper, UINT unit) +void DiskIIInterfaceCard::DiskSaveSnapshotDisk2Unit(YamlSaveHelper& yamlSaveHelper, UINT unit) { YamlSaveHelper::Label label(yamlSaveHelper, "%s%d:\n", SS_YAML_KEY_DISK2UNIT, unit); yamlSaveHelper.SaveString(SS_YAML_KEY_FILENAME, g_aFloppyDrive[unit].disk.fullname); @@ -1358,7 +1358,7 @@ static void DiskSaveSnapshotDisk2Unit(YamlSaveHelper& yamlSaveHelper, UINT unit) } } -void DiskSaveSnapshot(class YamlSaveHelper& yamlSaveHelper) +void DiskIIInterfaceCard::DiskSaveSnapshot(class YamlSaveHelper& yamlSaveHelper) { YamlSaveHelper::Slot slot(yamlSaveHelper, DiskGetSnapshotCardName(), g_uSlot, kUNIT_VERSION); @@ -1378,7 +1378,7 @@ void DiskSaveSnapshot(class YamlSaveHelper& yamlSaveHelper) DiskSaveSnapshotDisk2Unit(yamlSaveHelper, DRIVE_2); } -static void DiskLoadSnapshotDriveUnit(YamlLoadHelper& yamlLoadHelper, UINT unit) +void DiskIIInterfaceCard::DiskLoadSnapshotDriveUnit(YamlLoadHelper& yamlLoadHelper, UINT unit) { std::string disk2UnitName = std::string(SS_YAML_KEY_DISK2UNIT) + (unit == DRIVE_1 ? std::string("0") : std::string("1")); if (!yamlLoadHelper.GetSubMap(disk2UnitName)) @@ -1455,7 +1455,7 @@ static void DiskLoadSnapshotDriveUnit(YamlLoadHelper& yamlLoadHelper, UINT unit) } } -bool DiskLoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version) +bool DiskIIInterfaceCard::DiskLoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version) { if (slot != 6) // fixme throw std::string("Card: wrong slot"); diff --git a/source/Disk.h b/source/Disk.h index e4dc460b..e39631e0 100644 --- a/source/Disk.h +++ b/source/Disk.h @@ -25,6 +25,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "DiskImage.h" +extern class DiskIIInterfaceCard sg_DiskIICard; + // Floppy Disk Drives enum Drive_e @@ -39,51 +41,85 @@ const bool IMAGE_FORCE_WRITE_PROTECTED = true; const bool IMAGE_DONT_CREATE = false; const bool IMAGE_CREATE = true; -const char* DiskGetDiskPathFilename(const int iDrive); +class DiskIIInterfaceCard +{ +public: + DiskIIInterfaceCard(void){}; + virtual ~DiskIIInterfaceCard(void){}; -void DiskInitialize(void); // DiskIIManagerStartup() -void DiskDestroy(void); // no, doesn't "destroy" the disk image. DiskIIManagerShutdown() + const char* DiskGetDiskPathFilename(const int iDrive); -void DiskBoot(void); -void DiskEject(const int iDrive); -void DiskFlushCurrentTrack(const int iDrive); + void DiskInitialize(void); // DiskIIManagerStartup() + void DiskDestroy(void); // no, doesn't "destroy" the disk image. DiskIIManagerShutdown() -LPCTSTR DiskGetFullName(const int iDrive); -LPCTSTR DiskGetFullDiskFilename(const int iDrive); -LPCTSTR DiskGetBaseName(const int iDrive); + void DiskBoot(void); + void DiskEject(const int iDrive); + void DiskFlushCurrentTrack(const int iDrive); -void DiskGetLightStatus (Disk_Status_e* pDisk1Status, Disk_Status_e* pDisk2Status); + LPCTSTR DiskGetFullName(const int iDrive); + LPCTSTR DiskGetFullDiskFilename(const int iDrive); + LPCTSTR DiskGetBaseName(const int iDrive); -ImageError_e DiskInsert(const int iDrive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary); -bool Disk_IsConditionForFullSpeed(void); -BOOL DiskIsSpinning(void); -void DiskNotifyInvalidImage(const int iDrive, LPCTSTR pszImageFilename, const ImageError_e Error); -void DiskReset(const bool bIsPowerCycle=false); -bool DiskGetProtect(const int iDrive); -void DiskSetProtect(const int iDrive, const bool bWriteProtect); -int DiskGetCurrentDrive(); -int DiskGetCurrentTrack(); -int DiskGetTrack( int drive ); -int DiskGetCurrentPhase(); -int DiskGetCurrentOffset(); -const char* DiskGetCurrentState(); -bool DiskSelect(const int iDrive); -void DiskUpdateDriveState(DWORD); -bool DiskDriveSwap(void); -void DiskLoadRom(LPBYTE pCxRomPeripheral, UINT uSlot); + void DiskGetLightStatus (Disk_Status_e* pDisk1Status, Disk_Status_e* pDisk2Status); -std::string DiskGetSnapshotCardName(void); -void DiskSaveSnapshot(class YamlSaveHelper& yamlSaveHelper); -bool DiskLoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version); + ImageError_e DiskInsert(const int iDrive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary); + bool Disk_IsConditionForFullSpeed(void); + BOOL DiskIsSpinning(void); + void DiskNotifyInvalidImage(const int iDrive, LPCTSTR pszImageFilename, const ImageError_e Error); + void DiskReset(const bool bIsPowerCycle=false); + bool DiskGetProtect(const int iDrive); + void DiskSetProtect(const int iDrive, const bool bWriteProtect); + int DiskGetCurrentDrive(); + int DiskGetCurrentTrack(); + int DiskGetTrack( int drive ); + int DiskGetCurrentPhase(); + int DiskGetCurrentOffset(); + const char* DiskGetCurrentState(); + bool DiskSelect(const int iDrive); + void DiskUpdateDriveState(DWORD); + bool DiskDriveSwap(void); + void Initialize(LPBYTE pCxRomPeripheral, UINT uSlot); -void Disk_LoadLastDiskImage(const int iDrive); -void Disk_SaveLastDiskImage(const int iDrive); + std::string DiskGetSnapshotCardName(void); + void DiskSaveSnapshot(class YamlSaveHelper& yamlSaveHelper); + bool DiskLoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version); -bool Disk_ImageIsWriteProtected(const int iDrive); -bool Disk_IsDriveEmpty(const int iDrive); + void Disk_LoadLastDiskImage(const int iDrive); + void Disk_SaveLastDiskImage(const int iDrive); -bool Disk_GetEnhanceDisk(void); -void Disk_SetEnhanceDisk(bool bEnhanceDisk); + bool Disk_ImageIsWriteProtected(const int iDrive); + bool Disk_IsDriveEmpty(const int iDrive); + + bool Disk_GetEnhanceDisk(void); + void Disk_SetEnhanceDisk(bool bEnhanceDisk); + + static BYTE __stdcall DiskIIInterfaceCard::Disk_IORead(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles); + static BYTE __stdcall DiskIIInterfaceCard::Disk_IOWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles); + +private: + void DiskIIInterfaceCard::CheckSpinning(const ULONG nExecutedCycles); + Disk_Status_e DiskIIInterfaceCard::GetDriveLightStatus(const int iDrive); + bool DiskIIInterfaceCard::IsDriveValid(const int iDrive); + void DiskIIInterfaceCard::AllocTrack(const int iDrive); + void DiskIIInterfaceCard::ReadTrack(const int iDrive); + void DiskIIInterfaceCard::RemoveDisk(const int iDrive); + void DiskIIInterfaceCard::WriteTrack(const int iDrive); + LPCTSTR DiskIIInterfaceCard::DiskGetFullPathName(const int iDrive); + bool DiskIIInterfaceCard::DiskSelectImage(const int iDrive, LPCSTR pszFilename); + void DiskIIInterfaceCard::DiskSaveSnapshotDisk2Unit(YamlSaveHelper& yamlSaveHelper, UINT unit); + void DiskIIInterfaceCard::DiskLoadSnapshotDriveUnit(YamlLoadHelper& yamlLoadHelper, UINT unit); + + void __stdcall DiskIIInterfaceCard::DiskControlStepper(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles); + void __stdcall DiskIIInterfaceCard::DiskControlMotor(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles); + void __stdcall DiskIIInterfaceCard::DiskEnable(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles); + void __stdcall DiskIIInterfaceCard::DiskReadWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles); + void __stdcall DiskIIInterfaceCard::DiskLoadWriteProtect(WORD, WORD, BYTE write, BYTE value, ULONG); + void __stdcall DiskIIInterfaceCard::DiskSetReadMode(WORD, WORD, BYTE, BYTE, ULONG); + void __stdcall DiskIIInterfaceCard::DiskSetWriteMode(WORD, WORD, BYTE, BYTE, ULONG uExecutedCycles); + + //#if LOG_DISK_NIBBLES_WRITE + bool DiskIIInterfaceCard::LogWriteCheckSyncFF(ULONG& uCycleDelta); +}; // diff --git a/source/DiskImage.cpp b/source/DiskImage.cpp index 6640124c..be1c1a2c 100644 --- a/source/DiskImage.cpp +++ b/source/DiskImage.cpp @@ -155,7 +155,8 @@ void ImageReadTrack( ImageInfo* const pImageInfo, const int nTrack, const int nQuarterTrack, LPBYTE pTrackImageBuffer, - int* pNibbles) + int* pNibbles, + bool enhancedisk) { _ASSERT(nTrack >= 0); if (nTrack < 0) @@ -163,7 +164,7 @@ void ImageReadTrack( ImageInfo* const pImageInfo, if (pImageInfo->pImageType->AllowRW() && pImageInfo->ValidTrack[nTrack]) { - pImageInfo->pImageType->Read(pImageInfo, nTrack, nQuarterTrack, pTrackImageBuffer, pNibbles); + pImageInfo->pImageType->Read(pImageInfo, nTrack, nQuarterTrack, pTrackImageBuffer, pNibbles, enhancedisk); } else { diff --git a/source/DiskImage.h b/source/DiskImage.h index 76c105ae..ebb6d55f 100644 --- a/source/DiskImage.h +++ b/source/DiskImage.h @@ -71,7 +71,7 @@ BOOL ImageBoot(ImageInfo* const pImageInfo); void ImageDestroy(void); void ImageInitialize(void); -void ImageReadTrack(ImageInfo* const pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles); +void ImageReadTrack(ImageInfo* const pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles, bool enhancedisk); void ImageWriteTrack(ImageInfo* const pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImage, int nNibbles); bool ImageReadBlock(ImageInfo* const pImageInfo, UINT nBlock, LPBYTE pBlockBuffer); bool ImageWriteBlock(ImageInfo* const pImageInfo, UINT nBlock, LPBYTE pBlockBuffer); diff --git a/source/DiskImageHelper.cpp b/source/DiskImageHelper.cpp index 1cd01e24..f26649a7 100644 --- a/source/DiskImageHelper.cpp +++ b/source/DiskImageHelper.cpp @@ -34,7 +34,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "unzip.h" #include "CPU.h" -#include "Disk.h" #include "DiskImage.h" #include "DiskImageHelper.h" #include "Memory.h" @@ -631,11 +630,11 @@ public: return ePossibleMatch; } - virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles) + virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles, bool enhancedisk) { ReadTrack(pImageInfo, nTrack, ms_pWorkBuffer, TRACK_DENIBBLIZED_SIZE); *pNibbles = NibblizeTrack(pTrackImageBuffer, eDOSOrder, nTrack); - if (!Disk_GetEnhanceDisk()) + if (!enhancedisk) SkewTrack(nTrack, *pNibbles, pTrackImageBuffer); } @@ -697,11 +696,11 @@ public: return ePossibleMatch; } - virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles) + virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles, bool enhancedisk) { ReadTrack(pImageInfo, nTrack, ms_pWorkBuffer, TRACK_DENIBBLIZED_SIZE); *pNibbles = NibblizeTrack(pTrackImageBuffer, eProDOSOrder, nTrack); - if (!Disk_GetEnhanceDisk()) + if (!enhancedisk) SkewTrack(nTrack, *pNibbles, pTrackImageBuffer); } @@ -736,7 +735,7 @@ public: return eMatch; } - virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles) + virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles, bool enhancedisk) { ReadTrack(pImageInfo, nTrack, pTrackImageBuffer, NIB1_TRACK_SIZE); *pNibbles = NIB1_TRACK_SIZE; @@ -776,7 +775,7 @@ public: return eMatch; } - virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles) + virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles, bool enhancedisk) { ReadTrack(pImageInfo, nTrack, pTrackImageBuffer, NIB2_TRACK_SIZE); *pNibbles = NIB2_TRACK_SIZE; @@ -852,7 +851,7 @@ public: return eMatch; } - virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles) + virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles, bool enhancedisk) { // IF WE HAVEN'T ALREADY DONE SO, READ THE IMAGE FILE HEADER if (!m_pHeader) diff --git a/source/DiskImageHelper.h b/source/DiskImageHelper.h index 3eaafe23..f79c020f 100644 --- a/source/DiskImageHelper.h +++ b/source/DiskImageHelper.h @@ -54,7 +54,7 @@ public: virtual bool Boot(ImageInfo* pImageInfo) { return false; } virtual eDetectResult Detect(const LPBYTE pImage, const DWORD dwImageSize, const TCHAR* pszExt) = 0; - virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles) { } + virtual void Read(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImageBuffer, int* pNibbles, bool enhancedisk) { } virtual bool Read(ImageInfo* pImageInfo, UINT nBlock, LPBYTE pBlockBuffer) { return false; } virtual void Write(ImageInfo* pImageInfo, int nTrack, int nQuarterTrack, LPBYTE pTrackImage, int nNibbles) { } virtual bool Write(ImageInfo* pImageInfo, UINT nBlock, LPBYTE pBlockBuffer) { return false; } diff --git a/source/Frame.cpp b/source/Frame.cpp index b3328c28..4bf58ed0 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -512,7 +512,7 @@ static void DrawButton (HDC passdc, int number) { SetTextColor(dc,RGB(0,0,0)); SetTextAlign(dc,TA_CENTER | TA_TOP); SetBkMode(dc,TRANSPARENT); - LPCTSTR pszBaseName = DiskGetBaseName(number-BTN_DRIVE1); + LPCTSTR pszBaseName = sg_DiskIICard.DiskGetBaseName(number-BTN_DRIVE1); ExtTextOut(dc,x+offset+22,rect.top,ETO_CLIPPED,&rect, pszBaseName, MIN(8,_tcslen(pszBaseName)), @@ -702,7 +702,7 @@ void FrameDrawDiskLEDS( HDC passdc ) { Disk_Status_e eDrive1Status; Disk_Status_e eDrive2Status; - DiskGetLightStatus(&eDrive1Status, &eDrive2Status); + sg_DiskIICard.DiskGetLightStatus(&eDrive1Status, &eDrive2Status); g_eStatusDrive1 = eDrive1Status; g_eStatusDrive2 = eDrive2Status; @@ -755,10 +755,10 @@ void FrameDrawDiskStatus( HDC passdc ) // Track $B7EC LC1 $D356 // Sector $B7ED LC1 $D357 // RWTS LC1 $D300 - int nActiveFloppy = DiskGetCurrentDrive(); + int nActiveFloppy = sg_DiskIICard.DiskGetCurrentDrive(); - int nDisk1Track = DiskGetTrack(0); - int nDisk2Track = DiskGetTrack(1); + int nDisk1Track = sg_DiskIICard.DiskGetTrack(DRIVE_1); + int nDisk2Track = sg_DiskIICard.DiskGetTrack(DRIVE_2); // Probe known OS's for Track/Sector int isProDOS = mem[ 0xBF00 ] == 0x4C; @@ -1103,7 +1103,7 @@ LRESULT CALLBACK FrameWndProc ( Snapshot_Shutdown(); DebugDestroy(); if (!g_bRestart) { - DiskDestroy(); + sg_DiskIICard.DiskDestroy(); ImageDestroy(); HD_Destroy(); } @@ -1161,7 +1161,7 @@ LRESULT CALLBACK FrameWndProc ( LogFileOutput("WM_DDE_EXECUTE\n"); LPTSTR filename = (LPTSTR)GlobalLock((HGLOBAL)lparam); //MessageBox( g_hFrameWindow, filename, "DDE Exec", MB_OK ); - ImageError_e Error = DiskInsert(DRIVE_1, filename, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); + ImageError_e Error = sg_DiskIICard.DiskInsert(DRIVE_1, filename, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); if (Error == eIMAGE_ERROR_NONE) { if (!g_bIsFullScreen) @@ -1171,7 +1171,7 @@ LRESULT CALLBACK FrameWndProc ( } else { - DiskNotifyInvalidImage(DRIVE_1, filename, Error); + sg_DiskIICard.DiskNotifyInvalidImage(DRIVE_1, filename, Error); } GlobalUnlock((HGLOBAL)lparam); LogFileOutput("WM_DDE_EXECUTE (done)\n"); @@ -1193,7 +1193,7 @@ LRESULT CALLBACK FrameWndProc ( rect.top = buttony+BTN_DRIVE2*BUTTONCY+1; rect.bottom = rect.top+BUTTONCY; const int iDrive = PtInRect(&rect,point) ? DRIVE_2 : DRIVE_1; - ImageError_e Error = DiskInsert(iDrive, filename, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); + ImageError_e Error = sg_DiskIICard.DiskInsert(iDrive, filename, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); if (Error == eIMAGE_ERROR_NONE) { if (!g_bIsFullScreen) @@ -1207,7 +1207,7 @@ LRESULT CALLBACK FrameWndProc ( } else { - DiskNotifyInvalidImage(iDrive, filename, Error); + sg_DiskIICard.DiskNotifyInvalidImage(iDrive, filename, Error); } DragFinish((HDROP)wparam); break; @@ -1653,7 +1653,7 @@ LRESULT CALLBACK FrameWndProc ( if(((LPNMTTDISPINFO)lparam)->hdr.hwndFrom == tooltipwindow && ((LPNMTTDISPINFO)lparam)->hdr.code == TTN_GETDISPINFO) ((LPNMTTDISPINFO)lparam)->lpszText = - (LPTSTR)DiskGetFullDiskFilename(((LPNMTTDISPINFO)lparam)->hdr.idFrom); + (LPTSTR)sg_DiskIICard.DiskGetFullDiskFilename(((LPNMTTDISPINFO)lparam)->hdr.idFrom); break; case WM_PAINT: @@ -1967,7 +1967,7 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) if (g_nAppMode == MODE_LOGO) { - DiskBoot(); + sg_DiskIICard.DiskBoot(); LogFileTimeUntilFirstKeyReadReset(); g_nAppMode = MODE_RUNNING; } @@ -1990,13 +1990,13 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) case BTN_DRIVE1: case BTN_DRIVE2: - DiskSelect(button-BTN_DRIVE1); + sg_DiskIICard.DiskSelect(button-BTN_DRIVE1); if (!g_bIsFullScreen) DrawButton((HDC)0,button); break; case BTN_DRIVESWAP: - DiskDriveSwap(); + sg_DiskIICard.DiskDriveSwap(); break; case BTN_FULLSCR: @@ -2057,7 +2057,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) //TODO: A directory is open if an empty path to CiderPress is set. This has to be fixed. std::string filename1= "\""; - filename1.append( DiskGetDiskPathFilename(iDrive) ); + filename1.append( sg_DiskIICard.DiskGetDiskPathFilename(iDrive) ); filename1.append("\""); std::string sFileNameEmpty = "\""; sFileNameEmpty.append("\""); @@ -2079,16 +2079,16 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) // Check menu depending on current floppy protection { int iMenuItem = ID_DISKMENU_WRITEPROTECTION_OFF; - if (DiskGetProtect( iDrive )) + if (sg_DiskIICard.DiskGetProtect( iDrive )) iMenuItem = ID_DISKMENU_WRITEPROTECTION_ON; CheckMenuItem(hmenu, iMenuItem, MF_CHECKED); } - if (Disk_IsDriveEmpty(iDrive)) + if (sg_DiskIICard.Disk_IsDriveEmpty(iDrive)) EnableMenuItem(hmenu, ID_DISKMENU_EJECT, MF_GRAYED); - if (Disk_ImageIsWriteProtected(iDrive)) + if (sg_DiskIICard.Disk_ImageIsWriteProtected(iDrive)) { // If image-file is read-only (or a gzip) then disable these menu items EnableMenuItem(hmenu, ID_DISKMENU_WRITEPROTECTION_ON, MF_GRAYED); @@ -2104,13 +2104,13 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) , hwnd, NULL ); if (iCommand == ID_DISKMENU_EJECT) - DiskEject( iDrive ); + sg_DiskIICard.DiskEject( iDrive ); else if (iCommand == ID_DISKMENU_WRITEPROTECTION_ON) - DiskSetProtect( iDrive, true ); + sg_DiskIICard.DiskSetProtect( iDrive, true ); else if (iCommand == ID_DISKMENU_WRITEPROTECTION_OFF) - DiskSetProtect( iDrive, false ); + sg_DiskIICard.DiskSetProtect( iDrive, false ); else if (iCommand == ID_DISKMENU_SENDTO_CIDERPRESS) { @@ -2119,7 +2119,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) "Please install CiderPress.\n" "Otherwise set the path to CiderPress from Configuration->Disk."; - DiskFlushCurrentTrack(iDrive); + sg_DiskIICard.DiskFlushCurrentTrack(iDrive); //if(!filename1.compare("\"\"") == false) //Do not use this, for some reason it does not work!!! if(!filename1.compare(sFileNameEmpty) ) @@ -2181,13 +2181,13 @@ void RelayEvent (UINT message, WPARAM wparam, LPARAM lparam) { // todo: consolidate CtrlReset() and ResetMachineState() void ResetMachineState () { - DiskReset(true); + sg_DiskIICard.DiskReset(true); HD_Reset(); g_bFullSpeed = 0; // Might've hit reset in middle of InternalCpuExecute() - so beep may get (partially) muted MemReset(); // calls CpuInitialize() PravetsReset(); - DiskBoot(); + sg_DiskIICard.DiskBoot(); VideoResetState(); sg_SSC.CommReset(); PrintReset(); @@ -2225,7 +2225,7 @@ void CtrlReset() } PravetsReset(); - DiskReset(); + sg_DiskIICard.DiskReset(); HD_Reset(); KeybReset(); sg_SSC.CommReset(); diff --git a/source/Memory.cpp b/source/Memory.cpp index b91a7c58..406fadfd 100644 --- a/source/Memory.cpp +++ b/source/Memory.cpp @@ -1692,7 +1692,7 @@ void MemInitializeIO(void) ConfigureSAM(pCxRomPeripheral, 5); // $C500 : Z80 card } - DiskLoadRom(pCxRomPeripheral, 6); // $C600 : Disk][ f/w + sg_DiskIICard.Initialize(pCxRomPeripheral, 6); // $C600 : Disk][ card HD_Load_Rom(pCxRomPeripheral, 7); // $C700 : HDD f/w // diff --git a/source/SaveState.cpp b/source/SaveState.cpp index 11537916..447423f8 100644 --- a/source/SaveState.cpp +++ b/source/SaveState.cpp @@ -286,9 +286,9 @@ static void ParseSlots(YamlLoadHelper& yamlLoadHelper, UINT unitVersion) bRes = Phasor_LoadSnapshot(yamlLoadHelper, slot, cardVersion); type = CT_Phasor; } - else if (card == DiskGetSnapshotCardName()) + else if (card == sg_DiskIICard.DiskGetSnapshotCardName()) { - bRes = DiskLoadSnapshot(yamlLoadHelper, slot, cardVersion); + bRes = sg_DiskIICard.DiskLoadSnapshot(yamlLoadHelper, slot, cardVersion); type = CT_Disk2; } else if (card == HD_GetSnapshotCardName()) @@ -391,7 +391,7 @@ static void Snapshot_LoadState_v2(void) MemReset(); PravetsReset(); - DiskReset(); + sg_DiskIICard.DiskReset(); HD_Reset(); KeybReset(); VideoResetState(); @@ -519,7 +519,7 @@ void Snapshot_SaveState(void) if (g_Slot4 == CT_Phasor) Phasor_SaveSnapshot(yamlSaveHelper, 4); - DiskSaveSnapshot(yamlSaveHelper); + sg_DiskIICard.DiskSaveSnapshot(yamlSaveHelper); HD_SaveSnapshot(yamlSaveHelper); } diff --git a/source/Video.cpp b/source/Video.cpp index f65d2168..147ce350 100644 --- a/source/Video.cpp +++ b/source/Video.cpp @@ -304,7 +304,7 @@ void VideoBenchmark () { while (cycles > 0) { DWORD executedcycles = CpuExecute(103, true); cycles -= executedcycles; - DiskUpdateDriveState(executedcycles); + sg_DiskIICard.DiskUpdateDriveState(executedcycles); JoyUpdateButtonLatch(executedcycles); } } From bbe0e675845f8cbbb4b8bb07caa8fc5bad0bd504 Mon Sep 17 00:00:00 2001 From: tomcw Date: Sun, 7 Apr 2019 15:32:24 +0100 Subject: [PATCH 2/7] DiskIIInterfaceCard add in private variables --- source/Disk.cpp | 84 ++++++++----------------- source/Disk.h | 123 ++++++++++++++++++++++++++----------- source/DiskFormatTrack.cpp | 2 - source/DiskFormatTrack.h | 6 +- 4 files changed, 114 insertions(+), 101 deletions(-) diff --git a/source/Disk.cpp b/source/Disk.cpp index 7ab9ac58..8af828dc 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -35,8 +35,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "Applewin.h" #include "CPU.h" #include "Disk.h" -#include "DiskLog.h" -#include "DiskFormatTrack.h" #include "DiskImage.h" #include "Frame.h" #include "Log.h" @@ -47,57 +45,29 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "../resource/resource.h" -#if LOG_DISK_NIBBLES_USE_RUNTIME_VAR -static bool g_bLogDisk_NibblesRW = false; // From VS Debugger, change this to true/false during runtime for precise nibble logging -#endif - -// Private ________________________________________________________________________________________ - -struct Drive_t +DiskIIInterfaceCard::DiskIIInterfaceCard(void) { - int phase; - int track; - DWORD spinning; - DWORD writelight; - Disk_t disk; + currdrive = 0; + floppylatch = 0; + floppymotoron = 0; + floppyloadmode = 0; + floppywritemode = 0; + phases = 0; + g_bSaveDiskImage = true; // Save the DiskImage name to Registry + g_uSlot = 0; + g_uDiskLastCycle = 0; + g_uDiskLastReadLatchCycle = 0; + enhancedisk = true; - Drive_t() - { - clear(); - } - - void clear() - { - phase = 0; - track = 0; - spinning = 0; - writelight = 0; - disk.clear(); - } -}; - -static WORD currdrive = 0; -static Drive_t g_aFloppyDrive[NUM_DRIVES]; -static BYTE floppylatch = 0; -static BOOL floppymotoron = 0; -static BOOL floppyloadmode = 0; // for efficiency this is not used; it's extremely unlikely to affect emulation (nickw) -static BOOL floppywritemode = 0; -static WORD phases = 0; // state bits for stepper magnet phases 0 - 3 -static bool g_bSaveDiskImage = true; // Save the DiskImage name to Registry -static UINT g_uSlot = 0; -static unsigned __int64 g_uDiskLastCycle = 0; -static unsigned __int64 g_uDiskLastReadLatchCycle = 0; -static FormatTrack g_formatTrack; - -static bool IsDriveValid( const int iDrive ); -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; - -//=========================================================================== + // Debug: +#if LOG_DISK_NIBBLES_USE_RUNTIME_VAR + g_bLogDisk_NibblesRW = false; +#endif +#if LOG_DISK_NIBBLES_WRITE + g_uWriteLastCycle = 0; + g_uSyncFFCount = 0; +#endif +} bool DiskIIInterfaceCard::Disk_GetEnhanceDisk(void) { return enhancedisk; } void DiskIIInterfaceCard::Disk_SetEnhanceDisk(bool bEnhanceDisk) { enhancedisk = bEnhanceDisk; } @@ -766,7 +736,6 @@ void DiskIIInterfaceCard::DiskNotifyInvalidImage(const int iDrive, LPCTSTR pszIm MB_ICONEXCLAMATION | MB_SETFOREGROUND); } - //=========================================================================== bool DiskIIInterfaceCard::DiskGetProtect(const int iDrive) @@ -780,7 +749,6 @@ bool DiskIIInterfaceCard::DiskGetProtect(const int iDrive) return false; } - //=========================================================================== void DiskIIInterfaceCard::DiskSetProtect(const int iDrive, const bool bWriteProtect) @@ -791,7 +759,6 @@ void DiskIIInterfaceCard::DiskSetProtect(const int iDrive, const bool bWriteProt } } - //=========================================================================== bool DiskIIInterfaceCard::Disk_ImageIsWriteProtected(const int iDrive) @@ -815,9 +782,6 @@ bool DiskIIInterfaceCard::Disk_IsDriveEmpty(const int iDrive) //=========================================================================== #if LOG_DISK_NIBBLES_WRITE -static UINT64 g_uWriteLastCycle = 0; -static UINT g_uSyncFFCount = 0; - bool DiskIIInterfaceCard::LogWriteCheckSyncFF(ULONG& uCycleDelta) { bool bIsSyncFF = false; @@ -1261,7 +1225,7 @@ BYTE __stdcall DiskIIInterfaceCard::Disk_IORead(WORD pc, WORD addr, BYTE bWrite, // only even addresses return the latch (UTAIIe Table 9.1) if (!(addr & 1)) - return floppylatch; + return pCard->floppylatch; else return MemReadFloatingBus(nExecutedCycles); } @@ -1292,9 +1256,9 @@ BYTE __stdcall DiskIIInterfaceCard::Disk_IOWrite(WORD pc, WORD addr, BYTE bWrite } // any address writes the latch via sequencer LD command (74LS323 datasheet) - if (floppywritemode /* && floppyloadmode */) + if (pCard->floppywritemode /* && floppyloadmode */) { - floppylatch = d; + pCard->floppylatch = d; } return 0; } diff --git a/source/Disk.h b/source/Disk.h index e39631e0..a956bc96 100644 --- a/source/Disk.h +++ b/source/Disk.h @@ -23,6 +23,8 @@ along with AppleWin; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "DiskLog.h" +#include "DiskFormatTrack.h" #include "DiskImage.h" extern class DiskIIInterfaceCard sg_DiskIICard; @@ -41,10 +43,68 @@ const bool IMAGE_FORCE_WRITE_PROTECTED = true; const bool IMAGE_DONT_CREATE = false; const bool IMAGE_CREATE = true; +struct Disk_t +{ + TCHAR imagename[ MAX_DISK_IMAGE_NAME + 1 ]; // (ie. no extension) + TCHAR fullname [ MAX_DISK_FULL_NAME + 1 ]; // or : This is persisted to the snapshot file + std::string strFilenameInZip; // "" or + ImageInfo* imagehandle; // Init'd by DiskInsert() -> ImageOpen() + bool bWriteProtected; + // + int byte; + int nibbles; // Init'd by ReadTrack() -> ImageReadTrack() + LPBYTE trackimage; + bool trackimagedata; + bool trackimagedirty; + + Disk_t() + { + clear(); + } + + void clear() + { + ZeroMemory(imagename, sizeof(imagename)); + ZeroMemory(fullname, sizeof(fullname)); + strFilenameInZip.clear(); + imagehandle = NULL; + bWriteProtected = false; + // + byte = 0; + nibbles = 0; + trackimage = NULL; + trackimagedata = false; + trackimagedirty = false; + } +}; + +struct Drive_t +{ + int phase; + int track; + DWORD spinning; + DWORD writelight; + Disk_t disk; + + Drive_t() + { + clear(); + } + + void clear() + { + phase = 0; + track = 0; + spinning = 0; + writelight = 0; + disk.clear(); + } +}; + class DiskIIInterfaceCard { public: - DiskIIInterfaceCard(void){}; + DiskIIInterfaceCard(void); virtual ~DiskIIInterfaceCard(void){}; const char* DiskGetDiskPathFilename(const int iDrive); @@ -117,44 +177,35 @@ private: void __stdcall DiskIIInterfaceCard::DiskSetReadMode(WORD, WORD, BYTE, BYTE, ULONG); void __stdcall DiskIIInterfaceCard::DiskSetWriteMode(WORD, WORD, BYTE, BYTE, ULONG uExecutedCycles); - //#if LOG_DISK_NIBBLES_WRITE +#if LOG_DISK_NIBBLES_WRITE bool DiskIIInterfaceCard::LogWriteCheckSyncFF(ULONG& uCycleDelta); -}; +#endif -// - -// For sharing with class FormatTrack -struct Disk_t -{ - TCHAR imagename[ MAX_DISK_IMAGE_NAME + 1 ]; // (ie. no extension) - TCHAR fullname [ MAX_DISK_FULL_NAME + 1 ]; // or : This is persisted to the snapshot file - std::string strFilenameInZip; // "" or - ImageInfo* imagehandle; // Init'd by DiskInsert() -> ImageOpen() - bool bWriteProtected; // - int byte; - int nibbles; // Init'd by ReadTrack() -> ImageReadTrack() - LPBYTE trackimage; - bool trackimagedata; - bool trackimagedirty; - Disk_t() - { - clear(); - } + WORD currdrive; + Drive_t g_aFloppyDrive[NUM_DRIVES]; + BYTE floppylatch; + BOOL floppymotoron; + BOOL floppyloadmode; // for efficiency this is not used; it's extremely unlikely to affect emulation (nickw) + BOOL floppywritemode; + WORD phases; // state bits for stepper magnet phases 0 - 3 + bool g_bSaveDiskImage; + UINT g_uSlot; + unsigned __int64 g_uDiskLastCycle; + unsigned __int64 g_uDiskLastReadLatchCycle; + FormatTrack g_formatTrack; + bool enhancedisk; - void clear() - { - ZeroMemory(imagename, sizeof(imagename)); - ZeroMemory(fullname, sizeof(fullname)); - strFilenameInZip.clear(); - imagehandle = NULL; - bWriteProtected = false; - // - byte = 0; - nibbles = 0; - trackimage = NULL; - trackimagedata = false; - trackimagedirty = false; - } + static const UINT SPINNING_CYCLES = 20000*64; // 1280000 cycles = 1.25s + static const UINT WRITELIGHT_CYCLES = 20000*64; // 1280000 cycles = 1.25s + + // Debug: +#if LOG_DISK_NIBBLES_USE_RUNTIME_VAR + bool g_bLogDisk_NibblesRW; // From VS Debugger, change this to true/false during runtime for precise nibble logging +#endif +#if LOG_DISK_NIBBLES_WRITE + UINT64 g_uWriteLastCycle; + UINT g_uSyncFFCount; +#endif }; diff --git a/source/DiskFormatTrack.cpp b/source/DiskFormatTrack.cpp index 6f8f05c0..cd55a4b8 100644 --- a/source/DiskFormatTrack.cpp +++ b/source/DiskFormatTrack.cpp @@ -45,8 +45,6 @@ Writes the following: (in 1 continuous write operation) #include "StdAfx.h" #include "Disk.h" -#include "DiskLog.h" -#include "DiskFormatTrack.h" #include "Log.h" #include "YamlHelper.h" diff --git a/source/DiskFormatTrack.h b/source/DiskFormatTrack.h index ad67c0b4..7e1d2ea5 100644 --- a/source/DiskFormatTrack.h +++ b/source/DiskFormatTrack.h @@ -35,15 +35,15 @@ public: void Reset(void); void DriveNotWritingTrack(void); - void DriveSwitchedToReadMode(Disk_t* const pFloppy); + void DriveSwitchedToReadMode(struct Disk_t* const pFloppy); void DriveSwitchedToWriteMode(UINT uTrackIndex); void DecodeLatchNibbleRead(BYTE floppylatch); - void DecodeLatchNibbleWrite(BYTE floppylatch, UINT uSpinNibbleCount, const Disk_t* const pFloppy, bool bIsSyncFF); + void DecodeLatchNibbleWrite(BYTE floppylatch, UINT uSpinNibbleCount, const struct Disk_t* const pFloppy, bool bIsSyncFF); void SaveSnapshot(class YamlSaveHelper& yamlSaveHelper); void LoadSnapshot(class YamlLoadHelper& yamlLoadHelper); private: - void UpdateOnWriteLatch(UINT uSpinNibbleCount, const Disk_t* const pFloppy); + void UpdateOnWriteLatch(UINT uSpinNibbleCount, const struct Disk_t* const pFloppy); void DecodeLatchNibble(BYTE floppylatch, bool bIsWrite, bool bIsSyncFF); BYTE m_VolTrkSecChk[4]; From f755db8516cf226ca8f26332e78dbd8063d0eee7 Mon Sep 17 00:00:00 2001 From: tomcw Date: Sun, 7 Apr 2019 15:54:26 +0100 Subject: [PATCH 3/7] Rename all class's private vars --- source/Disk.cpp | 396 ++++++++++++++++++++++++------------------------ source/Disk.h | 32 ++-- 2 files changed, 214 insertions(+), 214 deletions(-) diff --git a/source/Disk.cpp b/source/Disk.cpp index 8af828dc..83abf6b7 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -47,66 +47,66 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA DiskIIInterfaceCard::DiskIIInterfaceCard(void) { - currdrive = 0; - floppylatch = 0; - floppymotoron = 0; - floppyloadmode = 0; - floppywritemode = 0; - phases = 0; - g_bSaveDiskImage = true; // Save the DiskImage name to Registry - g_uSlot = 0; - g_uDiskLastCycle = 0; - g_uDiskLastReadLatchCycle = 0; - enhancedisk = true; + m_currDrive = 0; + m_floppyLatch = 0; + m_floppyMotorOn = 0; + m_floppyLoadMode = 0; + m_floppyWriteMode = 0; + m_phases = 0; + m_saveDiskImage = true; // Save the DiskImage name to Registry + m_slot = 0; + m_diskLastCycle = 0; + m_diskLastReadLatchCycle = 0; + m_enhanceDisk = true; // Debug: #if LOG_DISK_NIBBLES_USE_RUNTIME_VAR - g_bLogDisk_NibblesRW = false; + m_bLogDisk_NibblesRW = false; #endif #if LOG_DISK_NIBBLES_WRITE - g_uWriteLastCycle = 0; - g_uSyncFFCount = 0; + m_uWriteLastCycle = 0; + m_uSyncFFCount = 0; #endif } -bool DiskIIInterfaceCard::Disk_GetEnhanceDisk(void) { return enhancedisk; } -void DiskIIInterfaceCard::Disk_SetEnhanceDisk(bool bEnhanceDisk) { enhancedisk = bEnhanceDisk; } +bool DiskIIInterfaceCard::Disk_GetEnhanceDisk(void) { return m_enhanceDisk; } +void DiskIIInterfaceCard::Disk_SetEnhanceDisk(bool bEnhanceDisk) { m_enhanceDisk = bEnhanceDisk; } -int DiskIIInterfaceCard::DiskGetCurrentDrive(void) { return currdrive; } -int DiskIIInterfaceCard::DiskGetCurrentTrack(void) { return g_aFloppyDrive[currdrive].track; } -int DiskIIInterfaceCard::DiskGetCurrentPhase(void) { return g_aFloppyDrive[currdrive].phase; } -int DiskIIInterfaceCard::DiskGetCurrentOffset(void) { return g_aFloppyDrive[currdrive].disk.byte; } -int DiskIIInterfaceCard::DiskGetTrack( int drive ) { return g_aFloppyDrive[ drive ].track; } +int DiskIIInterfaceCard::DiskGetCurrentDrive(void) { return m_currDrive; } +int DiskIIInterfaceCard::DiskGetCurrentTrack(void) { return m_floppyDrive[m_currDrive].track; } +int DiskIIInterfaceCard::DiskGetCurrentPhase(void) { return m_floppyDrive[m_currDrive].phase; } +int DiskIIInterfaceCard::DiskGetCurrentOffset(void) { return m_floppyDrive[m_currDrive].disk.byte; } +int DiskIIInterfaceCard::DiskGetTrack( int drive ) { return m_floppyDrive[ drive ].track; } const char* DiskIIInterfaceCard::DiskGetDiskPathFilename(const int iDrive) { - return g_aFloppyDrive[iDrive].disk.fullname; + return m_floppyDrive[iDrive].disk.fullname; } const char* DiskIIInterfaceCard::DiskGetCurrentState(void) { - if (g_aFloppyDrive[currdrive].disk.imagehandle == NULL) + if (m_floppyDrive[m_currDrive].disk.imagehandle == NULL) return "Empty"; - if (!floppymotoron) + if (!m_floppyMotorOn) { - if (g_aFloppyDrive[currdrive].spinning > 0) + if (m_floppyDrive[m_currDrive].spinning > 0) return "Off (spinning)"; else return "Off"; } - else if (floppywritemode) + else if (m_floppyWriteMode) { - if (g_aFloppyDrive[currdrive].disk.bWriteProtected) + if (m_floppyDrive[m_currDrive].disk.bWriteProtected) return "Writing (write protected)"; else return "Writing"; } else { - /*if (floppyloadmode) + /*if (m_floppyLoadMode) { - if (g_aFloppyDrive[currdrive].disk.bWriteProtected) + if (m_floppyDrive[m_currDrive].disk.bWriteProtected) return "Reading write protect state (write protected)"; else return "Reading write protect state (not write protected)"; @@ -133,10 +133,10 @@ void DiskIIInterfaceCard::Disk_LoadLastDiskImage(const int iDrive) { sFilePath[ MAX_PATH ] = 0; - g_bSaveDiskImage = false; + m_saveDiskImage = false; // Pass in ptr to local copy of filepath, since RemoveDisk() sets DiskPathFilename = "" DiskInsert(iDrive, sFilePath, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); - g_bSaveDiskImage = true; + m_saveDiskImage = true; } } @@ -146,10 +146,10 @@ void DiskIIInterfaceCard::Disk_SaveLastDiskImage(const int iDrive) { _ASSERT(iDrive == DRIVE_1 || iDrive == DRIVE_2); - if (!g_bSaveDiskImage) + if (!m_saveDiskImage) return; - const char *pFileName = g_aFloppyDrive[iDrive].disk.fullname; + const char *pFileName = m_floppyDrive[iDrive].disk.fullname; if (iDrive == DRIVE_1) RegSaveString(TEXT(REG_PREFS), REGVALUE_PREF_LAST_DISK_1, TRUE, pFileName); @@ -173,19 +173,19 @@ void DiskIIInterfaceCard::Disk_SaveLastDiskImage(const int iDrive) // Called by DiskControlMotor() & DiskEnable() void DiskIIInterfaceCard::CheckSpinning(const ULONG nExecutedCycles) { - DWORD modechange = (floppymotoron && !g_aFloppyDrive[currdrive].spinning); + DWORD modechange = (m_floppyMotorOn && !m_floppyDrive[m_currDrive].spinning); - if (floppymotoron) - g_aFloppyDrive[currdrive].spinning = SPINNING_CYCLES; + if (m_floppyMotorOn) + m_floppyDrive[m_currDrive].spinning = SPINNING_CYCLES; if (modechange) FrameDrawDiskLEDS( (HDC)0 ); if (modechange) { - // Set g_uDiskLastCycle when motor changes: not spinning (ie. off for 1 sec) -> on + // Set m_diskLastCycle when motor changes: not spinning (ie. off for 1 sec) -> on CpuCalcCycles(nExecutedCycles); - g_uDiskLastCycle = g_nCumulativeCycles; + m_diskLastCycle = g_nCumulativeCycles; } } @@ -195,7 +195,7 @@ Disk_Status_e DiskIIInterfaceCard::GetDriveLightStatus(const int iDrive) { if (IsDriveValid( iDrive )) { - Drive_t* pDrive = &g_aFloppyDrive[ iDrive ]; + Drive_t* pDrive = &m_floppyDrive[ iDrive ]; if (pDrive->spinning) { @@ -227,7 +227,7 @@ bool DiskIIInterfaceCard::IsDriveValid(const int iDrive) void DiskIIInterfaceCard::AllocTrack(const int iDrive) { - Disk_t* pFloppy = &g_aFloppyDrive[iDrive].disk; + Disk_t* pFloppy = &m_floppyDrive[iDrive].disk; pFloppy->trackimage = (LPBYTE)VirtualAlloc(NULL, NIBBLES_PER_TRACK, MEM_COMMIT, PAGE_READWRITE); } @@ -238,7 +238,7 @@ void DiskIIInterfaceCard::ReadTrack(const int iDrive) if (! IsDriveValid( iDrive )) return; - Drive_t* pDrive = &g_aFloppyDrive[ iDrive ]; + Drive_t* pDrive = &m_floppyDrive[ iDrive ]; Disk_t* pFloppy = &pDrive->disk; if (pDrive->track >= ImageGetNumTracks(pFloppy->imagehandle)) @@ -261,7 +261,7 @@ void DiskIIInterfaceCard::ReadTrack(const int iDrive) pDrive->phase, pFloppy->trackimage, &pFloppy->nibbles, - enhancedisk); + m_enhanceDisk); pFloppy->byte = 0; pFloppy->trackimagedata = (pFloppy->nibbles != 0); @@ -272,7 +272,7 @@ void DiskIIInterfaceCard::ReadTrack(const int iDrive) void DiskIIInterfaceCard::RemoveDisk(const int iDrive) { - Disk_t* pFloppy = &g_aFloppyDrive[iDrive].disk; + Disk_t* pFloppy = &m_floppyDrive[iDrive].disk; if (pFloppy->imagehandle) { @@ -301,7 +301,7 @@ void DiskIIInterfaceCard::RemoveDisk(const int iDrive) void DiskIIInterfaceCard::WriteTrack(const int iDrive) { - Drive_t* pDrive = &g_aFloppyDrive[ iDrive ]; + Drive_t* pDrive = &m_floppyDrive[ iDrive ]; Disk_t* pFloppy = &pDrive->disk; if (pDrive->track >= ImageGetNumTracks(pFloppy->imagehandle)) @@ -328,7 +328,7 @@ void DiskIIInterfaceCard::WriteTrack(const int iDrive) void DiskIIInterfaceCard::DiskFlushCurrentTrack(const int iDrive) { - Disk_t* pFloppy = &g_aFloppyDrive[iDrive].disk; + Disk_t* pFloppy = &m_floppyDrive[iDrive].disk; if (pFloppy->trackimage && pFloppy->trackimagedirty) WriteTrack(iDrive); @@ -340,8 +340,8 @@ void DiskIIInterfaceCard::DiskBoot(void) { // THIS FUNCTION RELOADS A PROGRAM IMAGE IF ONE IS LOADED IN DRIVE ONE. // IF A DISK IMAGE OR NO IMAGE IS LOADED IN DRIVE ONE, IT DOES NOTHING. - if (g_aFloppyDrive[0].disk.imagehandle && ImageBoot(g_aFloppyDrive[0].disk.imagehandle)) - floppymotoron = 0; + if (m_floppyDrive[0].disk.imagehandle && ImageBoot(m_floppyDrive[0].disk.imagehandle)) + m_floppyMotorOn = 0; } //=========================================================================== @@ -350,14 +350,14 @@ void __stdcall DiskIIInterfaceCard::DiskControlMotor(WORD, WORD address, BYTE, B { BOOL newState = address & 1; - if (newState != floppymotoron) // motor changed state - g_formatTrack.DriveNotWritingTrack(); + if (newState != m_floppyMotorOn) // motor changed state + m_formatTrack.DriveNotWritingTrack(); - floppymotoron = newState; + m_floppyMotorOn = newState; // NB. Motor off doesn't reset the Command Decoder like reset. (UTAIIe figures 9.7 & 9.8 chip C2) - // - so it doesn't reset this state: floppyloadmode, floppywritemode, phases + // - so it doesn't reset this state: m_floppyLoadMode, m_floppyWriteMode, m_phases #if LOG_DISK_MOTOR - LOG_DISK("motor %s\r\n", (floppymotoron) ? "on" : "off"); + LOG_DISK("motor %s\r\n", (m_floppyMotorOn) ? "on" : "off"); #endif CheckSpinning(uExecutedCycles); } @@ -366,10 +366,10 @@ void __stdcall DiskIIInterfaceCard::DiskControlMotor(WORD, WORD address, BYTE, B void __stdcall DiskIIInterfaceCard::DiskControlStepper(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles) { - Drive_t* pDrive = &g_aFloppyDrive[currdrive]; + Drive_t* pDrive = &m_floppyDrive[m_currDrive]; Disk_t* pFloppy = &pDrive->disk; - if (!floppymotoron) // GH#525 + if (!m_floppyMotorOn) // GH#525 { if (!pDrive->spinning) { @@ -392,12 +392,12 @@ void __stdcall DiskIIInterfaceCard::DiskControlStepper(WORD, WORD address, BYTE, if (address & 1) { // phase on - phases |= phase_bit; + m_phases |= phase_bit; } else { // phase off - phases &= ~phase_bit; + m_phases &= ~phase_bit; } // check for any stepping effect from a magnet @@ -406,9 +406,9 @@ void __stdcall DiskIIInterfaceCard::DiskControlStepper(WORD, WORD address, BYTE, // - do not move if both adjacent magnets are on // momentum and timing are not accounted for ... maybe one day! int direction = 0; - if (phases & (1 << ((pDrive->phase + 1) & 3))) + if (m_phases & (1 << ((pDrive->phase + 1) & 3))) direction += 1; - if (phases & (1 << ((pDrive->phase + 3) & 3))) + if (m_phases & (1 << ((pDrive->phase + 3) & 3))) direction -= 1; // apply magnet step, if any @@ -420,11 +420,11 @@ void __stdcall DiskIIInterfaceCard::DiskControlStepper(WORD, WORD address, BYTE, : MIN(nNumTracksInImage-1, pDrive->phase >> 1); // (round half tracks down) if (newtrack != pDrive->track) { - DiskFlushCurrentTrack(currdrive); + DiskFlushCurrentTrack(m_currDrive); pDrive->track = newtrack; pFloppy->trackimagedata = false; - g_formatTrack.DriveNotWritingTrack(); + m_formatTrack.DriveNotWritingTrack(); } // Feature Request #201 Show track status @@ -439,10 +439,10 @@ void __stdcall DiskIIInterfaceCard::DiskControlStepper(WORD, WORD address, BYTE, LOG_DISK("track $%02X%s phases %d%d%d%d phase %d %s address $%4X\r\n", pDrive->phase >> 1, (pDrive->phase & 1) ? ".5" : " ", - (phases >> 3) & 1, - (phases >> 2) & 1, - (phases >> 1) & 1, - (phases >> 0) & 1, + (m_phases >> 3) & 1, + (m_phases >> 2) & 1, + (m_phases >> 1) & 1, + (m_phases >> 0) & 1, phase, (address & 1) ? "on " : "off", address); @@ -453,25 +453,25 @@ void __stdcall DiskIIInterfaceCard::DiskControlStepper(WORD, WORD address, BYTE, void DiskIIInterfaceCard::DiskDestroy(void) { - g_bSaveDiskImage = false; + m_saveDiskImage = false; RemoveDisk(DRIVE_1); - g_bSaveDiskImage = false; + m_saveDiskImage = false; RemoveDisk(DRIVE_2); - g_bSaveDiskImage = true; + m_saveDiskImage = true; } //=========================================================================== void __stdcall DiskIIInterfaceCard::DiskEnable(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles) { - currdrive = address & 1; + m_currDrive = address & 1; #if LOG_DISK_ENABLE_DRIVE - LOG_DISK("enable drive: %d\r\n", currdrive); + LOG_DISK("enable drive: %d\r\n", m_currDrive); #endif - g_aFloppyDrive[!currdrive].spinning = 0; - g_aFloppyDrive[!currdrive].writelight = 0; + m_floppyDrive[!m_currDrive].spinning = 0; + m_floppyDrive[!m_currDrive].writelight = 0; CheckSpinning(uExecutedCycles); } @@ -491,29 +491,29 @@ void DiskIIInterfaceCard::DiskEject(const int iDrive) // . Used by Property Sheet Page (Disk) LPCTSTR DiskIIInterfaceCard::DiskGetFullName(const int iDrive) { - return g_aFloppyDrive[iDrive].disk.fullname; + return m_floppyDrive[iDrive].disk.fullname; } // Return the filename // . Used by Drive Buttons' tooltips LPCTSTR DiskIIInterfaceCard::DiskGetFullDiskFilename(const int iDrive) { - if (!g_aFloppyDrive[iDrive].disk.strFilenameInZip.empty()) - return g_aFloppyDrive[iDrive].disk.strFilenameInZip.c_str(); + if (!m_floppyDrive[iDrive].disk.strFilenameInZip.empty()) + return m_floppyDrive[iDrive].disk.strFilenameInZip.c_str(); return DiskGetFullName(iDrive); } LPCTSTR DiskIIInterfaceCard::DiskGetFullPathName(const int iDrive) { - return ImageGetPathname(g_aFloppyDrive[iDrive].disk.imagehandle); + return ImageGetPathname(m_floppyDrive[iDrive].disk.imagehandle); } // Return the imagename // . Used by Drive Button's icons & Property Sheet Page (Save snapshot) LPCTSTR DiskIIInterfaceCard::DiskGetBaseName(const int iDrive) { - return g_aFloppyDrive[iDrive].disk.imagename; + return m_floppyDrive[iDrive].disk.imagename; } //=========================================================================== @@ -532,14 +532,14 @@ void DiskIIInterfaceCard::DiskInitialize(void) { int loop = NUM_DRIVES; while (loop--) - g_aFloppyDrive[loop].clear(); + m_floppyDrive[loop].clear(); } //=========================================================================== ImageError_e DiskIIInterfaceCard::DiskInsert(const int iDrive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary) { - Drive_t* pDrive = &g_aFloppyDrive[iDrive]; + Drive_t* pDrive = &m_floppyDrive[iDrive]; Disk_t* pFloppy = &pDrive->disk; if (pFloppy->imagehandle) @@ -615,12 +615,12 @@ ImageError_e DiskIIInterfaceCard::DiskInsert(const int iDrive, LPCTSTR pszImageF bool DiskIIInterfaceCard::Disk_IsConditionForFullSpeed(void) { - return floppymotoron && enhancedisk; + return m_floppyMotorOn && m_enhanceDisk; } BOOL DiskIIInterfaceCard::DiskIsSpinning(void) { - return floppymotoron; + return m_floppyMotorOn; } //=========================================================================== @@ -687,7 +687,7 @@ void DiskIIInterfaceCard::DiskNotifyInvalidImage(const int iDrive, LPCTSTR pszIm TEXT("first file (%s) in this multi-zip archive is not recognized.\n") TEXT("Try unzipping and using the disk images directly.\n"), pszImageFilename, - g_aFloppyDrive[iDrive].disk.strFilenameInZip.c_str()); + m_floppyDrive[iDrive].disk.strFilenameInZip.c_str()); break; case eIMAGE_ERROR_GZ: @@ -742,7 +742,7 @@ bool DiskIIInterfaceCard::DiskGetProtect(const int iDrive) { if (IsDriveValid(iDrive)) { - if (g_aFloppyDrive[iDrive].disk.bWriteProtected) + if (m_floppyDrive[iDrive].disk.bWriteProtected) return true; } @@ -755,7 +755,7 @@ void DiskIIInterfaceCard::DiskSetProtect(const int iDrive, const bool bWriteProt { if (IsDriveValid( iDrive )) { - g_aFloppyDrive[iDrive].disk.bWriteProtected = bWriteProtect; + m_floppyDrive[iDrive].disk.bWriteProtected = bWriteProtect; } } @@ -766,7 +766,7 @@ bool DiskIIInterfaceCard::Disk_ImageIsWriteProtected(const int iDrive) if (!IsDriveValid(iDrive)) return true; - return ImageIsWriteProtected(g_aFloppyDrive[iDrive].disk.imagehandle); + return ImageIsWriteProtected(m_floppyDrive[iDrive].disk.imagehandle); } //=========================================================================== @@ -776,7 +776,7 @@ bool DiskIIInterfaceCard::Disk_IsDriveEmpty(const int iDrive) if (!IsDriveValid(iDrive)) return true; - return g_aFloppyDrive[iDrive].disk.imagehandle == NULL; + return m_floppyDrive[iDrive].disk.imagehandle == NULL; } //=========================================================================== @@ -786,26 +786,26 @@ bool DiskIIInterfaceCard::LogWriteCheckSyncFF(ULONG& uCycleDelta) { bool bIsSyncFF = false; - if (g_uWriteLastCycle == 0) // Reset to 0 when write mode is enabled + if (m_uWriteLastCycle == 0) // Reset to 0 when write mode is enabled { uCycleDelta = 0; - if (floppylatch == 0xFF) + if (m_floppyLatch == 0xFF) { - g_uSyncFFCount = 0; + m_uSyncFFCount = 0; bIsSyncFF = true; } } else { - uCycleDelta = (ULONG) (g_nCumulativeCycles - g_uWriteLastCycle); - if (floppylatch == 0xFF && uCycleDelta > 32) + uCycleDelta = (ULONG) (g_nCumulativeCycles - m_uWriteLastCycle); + if (m_floppyLatch == 0xFF && uCycleDelta > 32) { - g_uSyncFFCount++; + m_uSyncFFCount++; bIsSyncFF = true; } } - g_uWriteLastCycle = g_nCumulativeCycles; + m_uWriteLastCycle = g_nCumulativeCycles; return bIsSyncFF; } #endif @@ -814,16 +814,16 @@ bool DiskIIInterfaceCard::LogWriteCheckSyncFF(ULONG& uCycleDelta) void __stdcall DiskIIInterfaceCard::DiskReadWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles) { - /* floppyloadmode = 0; */ - Drive_t* pDrive = &g_aFloppyDrive[currdrive]; + /* m_floppyLoadMode = 0; */ + Drive_t* pDrive = &m_floppyDrive[m_currDrive]; Disk_t* pFloppy = &pDrive->disk; if (!pFloppy->trackimagedata && pFloppy->imagehandle) - ReadTrack(currdrive); + ReadTrack(m_currDrive); if (!pFloppy->trackimagedata) { - floppylatch = 0xFF; + m_floppyLatch = 0xFF; return; } @@ -831,10 +831,10 @@ void __stdcall DiskIIInterfaceCard::DiskReadWrite(WORD pc, WORD addr, BYTE bWrit UINT uSpinNibbleCount = 0; CpuCalcCycles(nExecutedCycles); // g_nCumulativeCycles required for uSpinNibbleCount & LogWriteCheckSyncFF() - if (!enhancedisk && pDrive->spinning) + if (!m_enhanceDisk && pDrive->spinning) { - const ULONG nCycleDiff = (ULONG) (g_nCumulativeCycles - g_uDiskLastCycle); - g_uDiskLastCycle = g_nCumulativeCycles; + const ULONG nCycleDiff = (ULONG) (g_nCumulativeCycles - m_diskLastCycle); + m_diskLastCycle = g_nCumulativeCycles; if (nCycleDiff > 40) { @@ -853,7 +853,7 @@ void __stdcall DiskIIInterfaceCard::DiskReadWrite(WORD pc, WORD addr, BYTE bWrit } } - if (!floppywritemode) + if (!m_floppyWriteMode) { // Don't change latch if drive off after 1 second drive-off delay (UTAIIe page 9-13) // "DRIVES OFF forces the data register to hold its present state." (UTAIIe page 9-12) @@ -861,38 +861,38 @@ void __stdcall DiskIIInterfaceCard::DiskReadWrite(WORD pc, WORD addr, BYTE bWrit if (!pDrive->spinning) // GH#599 return; - const ULONG nReadCycleDiff = (ULONG) (g_nCumulativeCycles - g_uDiskLastReadLatchCycle); + const ULONG nReadCycleDiff = (ULONG) (g_nCumulativeCycles - m_diskLastReadLatchCycle); // Support partial nibble read if disk reads are very close: (GH#582) // . 6 cycles (1st->2nd read) for DOS 3.3 / $BD34: "read with delays to see if disk is spinning." (Beneath Apple DOS) // . 6 cycles (1st->2nd read) for Curse of the Azure Bonds (loop to see if disk is spinning) // . 31 cycles is the max for a partial 8-bit nibble - const ULONG kReadAccessThreshold = enhancedisk ? 6 : 31; + const ULONG kReadAccessThreshold = m_enhanceDisk ? 6 : 31; if (nReadCycleDiff <= kReadAccessThreshold) { UINT invalidBits = 8 - (nReadCycleDiff / 4); // 4 cycles per bit-cell - floppylatch = *(pFloppy->trackimage + pFloppy->byte) >> invalidBits; - return; // Early return so don't update: g_uDiskLastReadLatchCycle & pFloppy->byte + m_floppyLatch = *(pFloppy->trackimage + pFloppy->byte) >> invalidBits; + return; // Early return so don't update: m_diskLastReadLatchCycle & pFloppy->byte } - floppylatch = *(pFloppy->trackimage + pFloppy->byte); - g_uDiskLastReadLatchCycle = g_nCumulativeCycles; + m_floppyLatch = *(pFloppy->trackimage + pFloppy->byte); + m_diskLastReadLatchCycle = g_nCumulativeCycles; #if LOG_DISK_NIBBLES_READ #if LOG_DISK_NIBBLES_USE_RUNTIME_VAR - if (g_bLogDisk_NibblesRW) + if (m_bLogDisk_NibblesRW) #endif { - LOG_DISK("read %04X = %02X\r\n", pFloppy->byte, floppylatch); + LOG_DISK("read %04X = %02X\r\n", pFloppy->byte, m_floppyLatch); } - g_formatTrack.DecodeLatchNibbleRead(floppylatch); + m_formatTrack.DecodeLatchNibbleRead(m_floppyLatch); #endif } - else if (!pFloppy->bWriteProtected) // && floppywritemode + else if (!pFloppy->bWriteProtected) // && m_floppyWriteMode { - *(pFloppy->trackimage + pFloppy->byte) = floppylatch; + *(pFloppy->trackimage + pFloppy->byte) = m_floppyLatch; pFloppy->trackimagedirty = true; bool bIsSyncFF = false; @@ -901,17 +901,17 @@ void __stdcall DiskIIInterfaceCard::DiskReadWrite(WORD pc, WORD addr, BYTE bWrit bIsSyncFF = LogWriteCheckSyncFF(uCycleDelta); #endif - g_formatTrack.DecodeLatchNibbleWrite(floppylatch, uSpinNibbleCount, pFloppy, bIsSyncFF); // GH#125 + m_formatTrack.DecodeLatchNibbleWrite(m_floppyLatch, uSpinNibbleCount, pFloppy, bIsSyncFF); // GH#125 #if LOG_DISK_NIBBLES_WRITE #if LOG_DISK_NIBBLES_USE_RUNTIME_VAR - if (g_bLogDisk_NibblesRW) + if (m_bLogDisk_NibblesRW) #endif { if (!bIsSyncFF) - LOG_DISK("write %04X = %02X (cy=+%d)\r\n", pFloppy->byte, floppylatch, uCycleDelta); + LOG_DISK("write %04X = %02X (cy=+%d)\r\n", pFloppy->byte, m_floppyLatch, uCycleDelta); else - LOG_DISK("write %04X = %02X (cy=+%d) sync #%d\r\n", pFloppy->byte, floppylatch, uCycleDelta, g_uSyncFFCount); + LOG_DISK("write %04X = %02X (cy=+%d) sync #%d\r\n", pFloppy->byte, m_floppyLatch, uCycleDelta, m_uSyncFFCount); } #endif } @@ -929,13 +929,13 @@ void __stdcall DiskIIInterfaceCard::DiskReadWrite(WORD pc, WORD addr, BYTE bWrit void DiskIIInterfaceCard::DiskReset(const bool bIsPowerCycle/*=false*/) { // RESET forces all switches off (UTAIIe Table 9.1) - currdrive = 0; - floppymotoron = 0; - floppyloadmode = 0; - floppywritemode = 0; - phases = 0; + m_currDrive = 0; + m_floppyMotorOn = 0; + m_floppyLoadMode = 0; + m_floppyWriteMode = 0; + m_phases = 0; - g_formatTrack.Reset(); + m_formatTrack.Reset(); if (bIsPowerCycle) // GH#460 { @@ -943,10 +943,10 @@ void DiskIIInterfaceCard::DiskReset(const bool bIsPowerCycle/*=false*/) // . The initial machine start-up state is track=0, but after a power-cycle the track could be any value. // . (For DiskII firmware, this results in a subtle extra latch read in this latter case, for the track!=0 case) - g_aFloppyDrive[DRIVE_1].spinning = 0; - g_aFloppyDrive[DRIVE_1].writelight = 0; - g_aFloppyDrive[DRIVE_2].spinning = 0; - g_aFloppyDrive[DRIVE_2].writelight = 0; + m_floppyDrive[DRIVE_1].spinning = 0; + m_floppyDrive[DRIVE_1].writelight = 0; + m_floppyDrive[DRIVE_2].spinning = 0; + m_floppyDrive[DRIVE_2].writelight = 0; FrameRefreshStatus(DRAW_LEDS, false); } @@ -1014,12 +1014,12 @@ bool DiskIIInterfaceCard::DiskSelect(const int iDrive) void __stdcall DiskIIInterfaceCard::DiskLoadWriteProtect(WORD, WORD, BYTE write, BYTE value, ULONG) { - /* floppyloadmode = 1; */ + /* m_floppyLoadMode = 1; */ // Don't change latch if drive off after 1 second drive-off delay (UTAIIe page 9-13) // "DRIVES OFF forces the data register to hold its present state." (UTAIIe page 9-12) // Note: Gemstone Warrior sets load mode with the drive off. - if (!g_aFloppyDrive[currdrive].spinning) // GH#599 + if (!m_floppyDrive[m_currDrive].spinning) // GH#599 return; if (!write) @@ -1029,10 +1029,10 @@ void __stdcall DiskIIInterfaceCard::DiskLoadWriteProtect(WORD, WORD, BYTE write, // . write mode doesn't prevent reading write protect (GH#537): // "If for some reason the above write protect check were entered with the READ/WRITE switch in WRITE, // the write protect switch would still be read correctly" (UTAIIe page 9-21) - if (g_aFloppyDrive[currdrive].disk.bWriteProtected) - floppylatch |= 0x80; + if (m_floppyDrive[m_currDrive].disk.bWriteProtected) + m_floppyLatch |= 0x80; else - floppylatch &= 0x7F; + m_floppyLatch &= 0x7F; } } @@ -1040,9 +1040,9 @@ void __stdcall DiskIIInterfaceCard::DiskLoadWriteProtect(WORD, WORD, BYTE write, void __stdcall DiskIIInterfaceCard::DiskSetReadMode(WORD, WORD, BYTE, BYTE, ULONG) { - floppywritemode = 0; + m_floppyWriteMode = 0; - g_formatTrack.DriveSwitchedToReadMode(&g_aFloppyDrive[currdrive].disk); + m_formatTrack.DriveSwitchedToReadMode(&m_floppyDrive[m_currDrive].disk); #if LOG_DISK_RW_MODE LOG_DISK("rw mode: read\r\n"); @@ -1053,19 +1053,19 @@ void __stdcall DiskIIInterfaceCard::DiskSetReadMode(WORD, WORD, BYTE, BYTE, ULON void __stdcall DiskIIInterfaceCard::DiskSetWriteMode(WORD, WORD, BYTE, BYTE, ULONG uExecutedCycles) { - floppywritemode = 1; + m_floppyWriteMode = 1; - g_formatTrack.DriveSwitchedToWriteMode(g_aFloppyDrive[currdrive].disk.byte); + m_formatTrack.DriveSwitchedToWriteMode(m_floppyDrive[m_currDrive].disk.byte); - BOOL modechange = !g_aFloppyDrive[currdrive].writelight; + BOOL modechange = !m_floppyDrive[m_currDrive].writelight; #if LOG_DISK_RW_MODE LOG_DISK("rw mode: write (mode changed=%d)\r\n", modechange ? 1 : 0); #endif #if LOG_DISK_NIBBLES_WRITE - g_uWriteLastCycle = 0; + m_uWriteLastCycle = 0; #endif - g_aFloppyDrive[currdrive].writelight = WRITELIGHT_CYCLES; + m_floppyDrive[m_currDrive].writelight = WRITELIGHT_CYCLES; if (modechange) FrameDrawDiskLEDS( (HDC)0 ); @@ -1078,9 +1078,9 @@ void DiskIIInterfaceCard::DiskUpdateDriveState(DWORD cycles) int loop = NUM_DRIVES; while (loop--) { - Drive_t* pDrive = &g_aFloppyDrive[loop]; + Drive_t* pDrive = &m_floppyDrive[loop]; - if (pDrive->spinning && !floppymotoron) + if (pDrive->spinning && !m_floppyMotorOn) { if (!(pDrive->spinning -= MIN(pDrive->spinning, cycles))) { @@ -1089,7 +1089,7 @@ void DiskIIInterfaceCard::DiskUpdateDriveState(DWORD cycles) } } - if (floppywritemode && (currdrive == loop) && pDrive->spinning) + if (m_floppyWriteMode && (m_currDrive == loop) && pDrive->spinning) { pDrive->writelight = WRITELIGHT_CYCLES; } @@ -1110,7 +1110,7 @@ bool DiskIIInterfaceCard::DiskDriveSwap(void) { // Refuse to swap if either Disk][ is active // TODO: if Shift-Click then FORCE drive swap to bypass message - if (g_aFloppyDrive[DRIVE_1].spinning || g_aFloppyDrive[DRIVE_2].spinning) + if (m_floppyDrive[DRIVE_1].spinning || m_floppyDrive[DRIVE_2].spinning) { // 1.26.2.4 Prompt when trying to swap disks while drive is on instead of silently failing int status = MessageBox( @@ -1145,11 +1145,11 @@ bool DiskIIInterfaceCard::DiskDriveSwap(void) // Swap disks between drives // . NB. We swap trackimage ptrs (so don't need to swap the buffers' data) - std::swap(g_aFloppyDrive[DRIVE_1].disk, g_aFloppyDrive[DRIVE_2].disk); + std::swap(m_floppyDrive[DRIVE_1].disk, m_floppyDrive[DRIVE_2].disk); // Invalidate the trackimage so that a read latch will re-read the track for the new floppy (GH#543) - g_aFloppyDrive[DRIVE_1].disk.trackimagedata = false; - g_aFloppyDrive[DRIVE_2].disk.trackimagedata = false; + m_floppyDrive[DRIVE_1].disk.trackimagedata = false; + m_floppyDrive[DRIVE_2].disk.trackimagedata = false; Disk_SaveLastDiskImage(DRIVE_1); Disk_SaveLastDiskImage(DRIVE_2); @@ -1193,7 +1193,7 @@ void DiskIIInterfaceCard::Initialize(LPBYTE pCxRomPeripheral, UINT uSlot) RegisterIoHandler(uSlot, &DiskIIInterfaceCard::Disk_IORead, &DiskIIInterfaceCard::Disk_IOWrite, NULL, NULL, this, NULL); - g_uSlot = uSlot; + m_slot = uSlot; } //=========================================================================== @@ -1225,7 +1225,7 @@ BYTE __stdcall DiskIIInterfaceCard::Disk_IORead(WORD pc, WORD addr, BYTE bWrite, // only even addresses return the latch (UTAIIe Table 9.1) if (!(addr & 1)) - return pCard->floppylatch; + return pCard->m_floppyLatch; else return MemReadFloatingBus(nExecutedCycles); } @@ -1256,9 +1256,9 @@ BYTE __stdcall DiskIIInterfaceCard::Disk_IOWrite(WORD pc, WORD addr, BYTE bWrite } // any address writes the latch via sequencer LD command (74LS323 datasheet) - if (pCard->floppywritemode /* && floppyloadmode */) + if (pCard->m_floppyWriteMode /* && m_floppyLoadMode */) { - pCard->floppylatch = d; + pCard->m_floppyLatch = d; } return 0; } @@ -1304,39 +1304,39 @@ std::string DiskIIInterfaceCard::DiskGetSnapshotCardName(void) void DiskIIInterfaceCard::DiskSaveSnapshotDisk2Unit(YamlSaveHelper& yamlSaveHelper, UINT unit) { YamlSaveHelper::Label label(yamlSaveHelper, "%s%d:\n", SS_YAML_KEY_DISK2UNIT, unit); - yamlSaveHelper.SaveString(SS_YAML_KEY_FILENAME, g_aFloppyDrive[unit].disk.fullname); - yamlSaveHelper.SaveUint(SS_YAML_KEY_TRACK, g_aFloppyDrive[unit].track); - yamlSaveHelper.SaveUint(SS_YAML_KEY_PHASE, g_aFloppyDrive[unit].phase); - yamlSaveHelper.SaveHexUint16(SS_YAML_KEY_BYTE, g_aFloppyDrive[unit].disk.byte); - yamlSaveHelper.SaveBool(SS_YAML_KEY_WRITE_PROTECTED, g_aFloppyDrive[unit].disk.bWriteProtected); - yamlSaveHelper.SaveUint(SS_YAML_KEY_SPINNING, g_aFloppyDrive[unit].spinning); - yamlSaveHelper.SaveUint(SS_YAML_KEY_WRITE_LIGHT, g_aFloppyDrive[unit].writelight); - yamlSaveHelper.SaveHexUint16(SS_YAML_KEY_NIBBLES, g_aFloppyDrive[unit].disk.nibbles); - yamlSaveHelper.SaveUint(SS_YAML_KEY_TRACK_IMAGE_DATA, g_aFloppyDrive[unit].disk.trackimagedata); - yamlSaveHelper.SaveUint(SS_YAML_KEY_TRACK_IMAGE_DIRTY, g_aFloppyDrive[unit].disk.trackimagedirty); + yamlSaveHelper.SaveString(SS_YAML_KEY_FILENAME, m_floppyDrive[unit].disk.fullname); + yamlSaveHelper.SaveUint(SS_YAML_KEY_TRACK, m_floppyDrive[unit].track); + yamlSaveHelper.SaveUint(SS_YAML_KEY_PHASE, m_floppyDrive[unit].phase); + yamlSaveHelper.SaveHexUint16(SS_YAML_KEY_BYTE, m_floppyDrive[unit].disk.byte); + yamlSaveHelper.SaveBool(SS_YAML_KEY_WRITE_PROTECTED, m_floppyDrive[unit].disk.bWriteProtected); + yamlSaveHelper.SaveUint(SS_YAML_KEY_SPINNING, m_floppyDrive[unit].spinning); + yamlSaveHelper.SaveUint(SS_YAML_KEY_WRITE_LIGHT, m_floppyDrive[unit].writelight); + yamlSaveHelper.SaveHexUint16(SS_YAML_KEY_NIBBLES, m_floppyDrive[unit].disk.nibbles); + yamlSaveHelper.SaveUint(SS_YAML_KEY_TRACK_IMAGE_DATA, m_floppyDrive[unit].disk.trackimagedata); + yamlSaveHelper.SaveUint(SS_YAML_KEY_TRACK_IMAGE_DIRTY, m_floppyDrive[unit].disk.trackimagedirty); - if (g_aFloppyDrive[unit].disk.trackimage) + if (m_floppyDrive[unit].disk.trackimage) { YamlSaveHelper::Label image(yamlSaveHelper, "%s:\n", SS_YAML_KEY_TRACK_IMAGE); - yamlSaveHelper.SaveMemory(g_aFloppyDrive[unit].disk.trackimage, NIBBLES_PER_TRACK); + yamlSaveHelper.SaveMemory(m_floppyDrive[unit].disk.trackimage, NIBBLES_PER_TRACK); } } void DiskIIInterfaceCard::DiskSaveSnapshot(class YamlSaveHelper& yamlSaveHelper) { - YamlSaveHelper::Slot slot(yamlSaveHelper, DiskGetSnapshotCardName(), g_uSlot, kUNIT_VERSION); + YamlSaveHelper::Slot slot(yamlSaveHelper, DiskGetSnapshotCardName(), m_slot, kUNIT_VERSION); YamlSaveHelper::Label state(yamlSaveHelper, "%s:\n", SS_YAML_KEY_STATE); - yamlSaveHelper.SaveHexUint4(SS_YAML_KEY_PHASES, phases); - yamlSaveHelper.SaveUint(SS_YAML_KEY_CURRENT_DRIVE, currdrive); + yamlSaveHelper.SaveHexUint4(SS_YAML_KEY_PHASES, m_phases); + yamlSaveHelper.SaveUint(SS_YAML_KEY_CURRENT_DRIVE, m_currDrive); yamlSaveHelper.SaveBool(SS_YAML_KEY_DISK_ACCESSED, false); // deprecated - 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); - yamlSaveHelper.SaveHexUint64(SS_YAML_KEY_LAST_CYCLE, g_uDiskLastCycle); // v2 - yamlSaveHelper.SaveHexUint64(SS_YAML_KEY_LAST_READ_LATCH_CYCLE, g_uDiskLastReadLatchCycle); // v3 - g_formatTrack.SaveSnapshot(yamlSaveHelper); // v2 + yamlSaveHelper.SaveBool(SS_YAML_KEY_ENHANCE_DISK, m_enhanceDisk); + yamlSaveHelper.SaveHexUint8(SS_YAML_KEY_FLOPPY_LATCH, m_floppyLatch); + yamlSaveHelper.SaveBool(SS_YAML_KEY_FLOPPY_MOTOR_ON, m_floppyMotorOn == TRUE); + yamlSaveHelper.SaveBool(SS_YAML_KEY_FLOPPY_WRITE_MODE, m_floppyWriteMode == TRUE); + yamlSaveHelper.SaveHexUint64(SS_YAML_KEY_LAST_CYCLE, m_diskLastCycle); // v2 + yamlSaveHelper.SaveHexUint64(SS_YAML_KEY_LAST_READ_LATCH_CYCLE, m_diskLastReadLatchCycle); // v3 + m_formatTrack.SaveSnapshot(yamlSaveHelper); // v2 DiskSaveSnapshotDisk2Unit(yamlSaveHelper, DRIVE_1); DiskSaveSnapshotDisk2Unit(yamlSaveHelper, DRIVE_2); @@ -1350,9 +1350,9 @@ void DiskIIInterfaceCard::DiskLoadSnapshotDriveUnit(YamlLoadHelper& yamlLoadHelp bool bImageError = false; - g_aFloppyDrive[unit].disk.fullname[0] = 0; - g_aFloppyDrive[unit].disk.imagename[0] = 0; - g_aFloppyDrive[unit].disk.bWriteProtected = false; // Default to false (until image is successfully loaded below) + m_floppyDrive[unit].disk.fullname[0] = 0; + m_floppyDrive[unit].disk.imagename[0] = 0; + m_floppyDrive[unit].disk.bWriteProtected = false; // Default to false (until image is successfully loaded below) std::string filename = yamlLoadHelper.LoadString(SS_YAML_KEY_FILENAME); if (!filename.empty()) @@ -1372,22 +1372,22 @@ void DiskIIInterfaceCard::DiskLoadSnapshotDriveUnit(YamlLoadHelper& yamlLoadHelp if(DiskInsert(unit, filename.c_str(), dwAttributes & FILE_ATTRIBUTE_READONLY, IMAGE_DONT_CREATE) != eIMAGE_ERROR_NONE) bImageError = true; - // DiskInsert() zeros g_aFloppyDrive[unit], then sets up: + // DiskInsert() zeros m_floppyDrive[unit], then sets up: // . imagename // . fullname // . writeprotected } } - g_aFloppyDrive[unit].track = yamlLoadHelper.LoadUint(SS_YAML_KEY_TRACK); - g_aFloppyDrive[unit].phase = yamlLoadHelper.LoadUint(SS_YAML_KEY_PHASE); - g_aFloppyDrive[unit].disk.byte = yamlLoadHelper.LoadUint(SS_YAML_KEY_BYTE); + m_floppyDrive[unit].track = yamlLoadHelper.LoadUint(SS_YAML_KEY_TRACK); + m_floppyDrive[unit].phase = yamlLoadHelper.LoadUint(SS_YAML_KEY_PHASE); + m_floppyDrive[unit].disk.byte = yamlLoadHelper.LoadUint(SS_YAML_KEY_BYTE); yamlLoadHelper.LoadBool(SS_YAML_KEY_WRITE_PROTECTED); // Consume - g_aFloppyDrive[unit].spinning = yamlLoadHelper.LoadUint(SS_YAML_KEY_SPINNING); - g_aFloppyDrive[unit].writelight = yamlLoadHelper.LoadUint(SS_YAML_KEY_WRITE_LIGHT); - g_aFloppyDrive[unit].disk.nibbles = yamlLoadHelper.LoadUint(SS_YAML_KEY_NIBBLES); - g_aFloppyDrive[unit].disk.trackimagedata = yamlLoadHelper.LoadUint(SS_YAML_KEY_TRACK_IMAGE_DATA) ? true : false; - g_aFloppyDrive[unit].disk.trackimagedirty = yamlLoadHelper.LoadUint(SS_YAML_KEY_TRACK_IMAGE_DIRTY) ? true : false; + m_floppyDrive[unit].spinning = yamlLoadHelper.LoadUint(SS_YAML_KEY_SPINNING); + m_floppyDrive[unit].writelight = yamlLoadHelper.LoadUint(SS_YAML_KEY_WRITE_LIGHT); + m_floppyDrive[unit].disk.nibbles = yamlLoadHelper.LoadUint(SS_YAML_KEY_NIBBLES); + m_floppyDrive[unit].disk.trackimagedata = yamlLoadHelper.LoadUint(SS_YAML_KEY_TRACK_IMAGE_DATA) ? true : false; + m_floppyDrive[unit].disk.trackimagedirty = yamlLoadHelper.LoadUint(SS_YAML_KEY_TRACK_IMAGE_DIRTY) ? true : false; std::vector track(NIBBLES_PER_TRACK); if (yamlLoadHelper.GetSubMap(SS_YAML_KEY_TRACK_IMAGE)) @@ -1402,20 +1402,20 @@ void DiskIIInterfaceCard::DiskLoadSnapshotDriveUnit(YamlLoadHelper& yamlLoadHelp if (!filename.empty() && !bImageError) { - if ((g_aFloppyDrive[unit].disk.trackimage == NULL) && g_aFloppyDrive[unit].disk.nibbles) + if ((m_floppyDrive[unit].disk.trackimage == NULL) && m_floppyDrive[unit].disk.nibbles) AllocTrack(unit); - if (g_aFloppyDrive[unit].disk.trackimage == NULL) + if (m_floppyDrive[unit].disk.trackimage == NULL) bImageError = true; else - memcpy(g_aFloppyDrive[unit].disk.trackimage, &track[0], NIBBLES_PER_TRACK); + memcpy(m_floppyDrive[unit].disk.trackimage, &track[0], NIBBLES_PER_TRACK); } if (bImageError) { - g_aFloppyDrive[unit].disk.trackimagedata = false; - g_aFloppyDrive[unit].disk.trackimagedirty = false; - g_aFloppyDrive[unit].disk.nibbles = 0; + m_floppyDrive[unit].disk.trackimagedata = false; + m_floppyDrive[unit].disk.trackimagedirty = false; + m_floppyDrive[unit].disk.nibbles = 0; } } @@ -1427,30 +1427,30 @@ bool DiskIIInterfaceCard::DiskLoadSnapshot(class YamlLoadHelper& yamlLoadHelper, if (version < 1 || version > kUNIT_VERSION) throw std::string("Card: wrong version"); - phases = yamlLoadHelper.LoadUint(SS_YAML_KEY_PHASES); - currdrive = yamlLoadHelper.LoadUint(SS_YAML_KEY_CURRENT_DRIVE); + m_phases = yamlLoadHelper.LoadUint(SS_YAML_KEY_PHASES); + m_currDrive = yamlLoadHelper.LoadUint(SS_YAML_KEY_CURRENT_DRIVE); (void) yamlLoadHelper.LoadBool(SS_YAML_KEY_DISK_ACCESSED); // deprecated - but retrieve the value to avoid the "State: Unknown key (Disk Accessed)" warning - enhancedisk = yamlLoadHelper.LoadBool(SS_YAML_KEY_ENHANCE_DISK); - floppylatch = yamlLoadHelper.LoadUint(SS_YAML_KEY_FLOPPY_LATCH); - floppymotoron = yamlLoadHelper.LoadBool(SS_YAML_KEY_FLOPPY_MOTOR_ON); - floppywritemode = yamlLoadHelper.LoadBool(SS_YAML_KEY_FLOPPY_WRITE_MODE); + m_enhanceDisk = yamlLoadHelper.LoadBool(SS_YAML_KEY_ENHANCE_DISK); + m_floppyLatch = yamlLoadHelper.LoadUint(SS_YAML_KEY_FLOPPY_LATCH); + m_floppyMotorOn = yamlLoadHelper.LoadBool(SS_YAML_KEY_FLOPPY_MOTOR_ON); + m_floppyWriteMode = yamlLoadHelper.LoadBool(SS_YAML_KEY_FLOPPY_WRITE_MODE); if (version >= 2) { - g_uDiskLastCycle = yamlLoadHelper.LoadUint64(SS_YAML_KEY_LAST_CYCLE); - g_formatTrack.LoadSnapshot(yamlLoadHelper); + m_diskLastCycle = yamlLoadHelper.LoadUint64(SS_YAML_KEY_LAST_CYCLE); + m_formatTrack.LoadSnapshot(yamlLoadHelper); } if (version >= 3) { - g_uDiskLastReadLatchCycle = yamlLoadHelper.LoadUint64(SS_YAML_KEY_LAST_READ_LATCH_CYCLE); + m_diskLastReadLatchCycle = yamlLoadHelper.LoadUint64(SS_YAML_KEY_LAST_READ_LATCH_CYCLE); } // Eject all disks first in case Drive-2 contains disk to be inserted into Drive-1 for(UINT i=0; i Date: Mon, 8 Apr 2019 10:41:47 +0100 Subject: [PATCH 4/7] Remove the 'Disk' prefix from method names --- source/Applewin.cpp | 16 +- source/Configuration/PageDisk.cpp | 22 +- source/Configuration/PropertySheetHelper.cpp | 2 +- source/Debugger/Debug.cpp | 18 +- source/Disk.cpp | 217 +++++++++---------- source/Disk.h | 114 +++++----- source/Frame.cpp | 52 ++--- source/SaveState.cpp | 8 +- source/Video.cpp | 2 +- 9 files changed, 221 insertions(+), 230 deletions(-) diff --git a/source/Applewin.cpp b/source/Applewin.cpp index 402b44de..d8b042c6 100644 --- a/source/Applewin.cpp +++ b/source/Applewin.cpp @@ -270,7 +270,7 @@ static void ContinueExecution(void) const bool bWasFullSpeed = g_bFullSpeed; g_bFullSpeed = (g_dwSpeed == SPEED_MAX) || bScrollLock_FullSpeed || - (sg_DiskIICard.Disk_IsConditionForFullSpeed() && !Spkr_IsActive() && !MB_IsActive()) || + (sg_DiskIICard.IsConditionForFullSpeed() && !Spkr_IsActive() && !MB_IsActive()) || IsDebugSteppingAtFullSpeed(); if (g_bFullSpeed) @@ -317,7 +317,7 @@ static void ContinueExecution(void) const DWORD uActualCyclesExecuted = CpuExecute(uCyclesToExecute, bVideoUpdate); g_dwCyclesThisFrame += uActualCyclesExecuted; - sg_DiskIICard.DiskUpdateDriveState(uActualCyclesExecuted); + sg_DiskIICard.UpdateDriveState(uActualCyclesExecuted); JoyUpdateButtonLatch(nExecutionPeriodUsec); // Button latch time is independent of CPU clock frequency PrintUpdate(uActualCyclesExecuted); @@ -625,7 +625,7 @@ void LoadConfiguration(void) DWORD dwEnhanceDisk; REGLOAD(TEXT(REGVALUE_ENHANCE_DISK_SPEED), &dwEnhanceDisk); - sg_DiskIICard.Disk_SetEnhanceDisk(dwEnhanceDisk ? true : false); + sg_DiskIICard.SetEnhanceDisk(dwEnhanceDisk ? true : false); Config_Load_Video(); @@ -714,8 +714,8 @@ void LoadConfiguration(void) GetCurrentDirectory(sizeof(szFilename), szFilename); SetCurrentImageDir(szFilename); - sg_DiskIICard.Disk_LoadLastDiskImage(DRIVE_1); - sg_DiskIICard.Disk_LoadLastDiskImage(DRIVE_2); + sg_DiskIICard.LoadLastDiskImage(DRIVE_1); + sg_DiskIICard.LoadLastDiskImage(DRIVE_2); // @@ -1062,7 +1062,7 @@ static bool DoDiskInsert(const int nDrive, LPCSTR szFileName) std::string strPathName = GetFullPath(szFileName); if (strPathName.empty()) return false; - ImageError_e Error = sg_DiskIICard.DiskInsert(nDrive, strPathName.c_str(), IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); + ImageError_e Error = sg_DiskIICard.InsertDisk(nDrive, strPathName.c_str(), IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); return Error == eIMAGE_ERROR_NONE; } @@ -1522,7 +1522,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) ImageInitialize(); LogFileOutput("Init: ImageInitialize()\n"); - sg_DiskIICard.DiskInitialize(); + sg_DiskIICard.Initialize(); LogFileOutput("Init: DiskInitialize()\n"); // @@ -1616,7 +1616,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) } // Need to test if it's safe to call ResetMachineState(). In the meantime, just call DiskReset(): - sg_DiskIICard.DiskReset(); // Switch from a booting A][+ to a non-autostart A][, so need to turn off floppy motor + sg_DiskIICard.Reset(); // 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/Configuration/PageDisk.cpp b/source/Configuration/PageDisk.cpp index f871ade5..8803fba2 100644 --- a/source/Configuration/PageDisk.cpp +++ b/source/Configuration/PageDisk.cpp @@ -130,19 +130,19 @@ BOOL CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM l case WM_INITDIALOG: { - m_PropertySheetHelper.FillComboBox(hWnd, IDC_DISKTYPE, m_discchoices, sg_DiskIICard.Disk_GetEnhanceDisk() ? 1 : 0); + m_PropertySheetHelper.FillComboBox(hWnd, IDC_DISKTYPE, m_discchoices, sg_DiskIICard.GetEnhanceDisk() ? 1 : 0); m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK1, m_defaultDiskOptions, -1); m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK2, m_defaultDiskOptions, -1); - if (strlen(sg_DiskIICard.DiskGetFullName(DRIVE_1)) > 0) + if (strlen(sg_DiskIICard.GetFullName(DRIVE_1)) > 0) { - SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_INSERTSTRING, 0, (LPARAM)sg_DiskIICard.DiskGetFullName(DRIVE_1)); + SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_INSERTSTRING, 0, (LPARAM)sg_DiskIICard.GetFullName(DRIVE_1)); SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_SETCURSEL, 0, 0); } - if (strlen(sg_DiskIICard.DiskGetFullName(DRIVE_2)) > 0) + if (strlen(sg_DiskIICard.GetFullName(DRIVE_2)) > 0) { - SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_INSERTSTRING, 0, (LPARAM)sg_DiskIICard.DiskGetFullName(DRIVE_2)); + SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_INSERTSTRING, 0, (LPARAM)sg_DiskIICard.GetFullName(DRIVE_2)); SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_SETCURSEL, 0, 0); } @@ -187,9 +187,9 @@ void CPageDisk::InitComboHDD(HWND hWnd) void CPageDisk::DlgOK(HWND hWnd) { const bool bNewEnhanceDisk = SendDlgItemMessage(hWnd, IDC_DISKTYPE,CB_GETCURSEL, 0, 0) ? true : false; - if (bNewEnhanceDisk != sg_DiskIICard.Disk_GetEnhanceDisk()) + if (bNewEnhanceDisk != sg_DiskIICard.GetEnhanceDisk()) { - sg_DiskIICard.Disk_SetEnhanceDisk(bNewEnhanceDisk); + sg_DiskIICard.SetEnhanceDisk(bNewEnhanceDisk); REGSAVE(TEXT(REGVALUE_ENHANCE_DISK_SPEED), (DWORD)bNewEnhanceDisk); } @@ -299,7 +299,7 @@ void CPageDisk::HandleDiskCombo(HWND hWnd, UINT driveSelected, UINT comboSelecte if (dwComboSelection == dwOpenDialogIndex) { EnableDisk(hWnd, FALSE); // Prevent multiple Selection dialogs to be triggered - bool bRes = sg_DiskIICard.DiskSelect(driveSelected); + bool bRes = sg_DiskIICard.UserSelectNewDiskImage(driveSelected); EnableDisk(hWnd, TRUE); if (!bRes) @@ -316,13 +316,13 @@ void CPageDisk::HandleDiskCombo(HWND hWnd, UINT driveSelected, UINT comboSelecte SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0); } - SendDlgItemMessage(hWnd, comboSelected, CB_INSERTSTRING, 0, (LPARAM)sg_DiskIICard.DiskGetFullName(driveSelected)); + SendDlgItemMessage(hWnd, comboSelected, CB_INSERTSTRING, 0, (LPARAM)sg_DiskIICard.GetFullName(driveSelected)); SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, 0, 0); // If the FD was in the other combo, remove now DWORD comboOther = (comboSelected == IDC_COMBO_DISK1) ? IDC_COMBO_DISK2 : IDC_COMBO_DISK1; - DWORD duplicated = (DWORD)SendDlgItemMessage(hWnd, comboOther, CB_FINDSTRINGEXACT, -1, (LPARAM)sg_DiskIICard.DiskGetFullName(driveSelected)); + DWORD duplicated = (DWORD)SendDlgItemMessage(hWnd, comboOther, CB_FINDSTRINGEXACT, -1, (LPARAM)sg_DiskIICard.GetFullName(driveSelected)); if (duplicated != CB_ERR) { SendDlgItemMessage(hWnd, comboOther, CB_DELETESTRING, duplicated, 0); @@ -337,7 +337,7 @@ void CPageDisk::HandleDiskCombo(HWND hWnd, UINT driveSelected, UINT comboSelecte if (RemovalConfirmation(uCommand)) { // Eject selected disk - sg_DiskIICard.DiskEject(driveSelected); + sg_DiskIICard.EjectDisk(driveSelected); // Remove drive from list SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0); } diff --git a/source/Configuration/PropertySheetHelper.cpp b/source/Configuration/PropertySheetHelper.cpp index 5f26e5d6..b414fc7d 100644 --- a/source/Configuration/PropertySheetHelper.cpp +++ b/source/Configuration/PropertySheetHelper.cpp @@ -198,7 +198,7 @@ void CPropertySheetHelper::SaveStateUpdate() void CPropertySheetHelper::GetDiskBaseNameWithAWS(TCHAR* pszFilename) { - LPCTSTR pDiskName = sg_DiskIICard.DiskGetBaseName(DRIVE_1); + LPCTSTR pDiskName = sg_DiskIICard.GetBaseName(DRIVE_1); if (pDiskName && pDiskName[0]) { strcpy(pszFilename, pDiskName); diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index cb37c579..b0d94117 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -3727,15 +3727,15 @@ Update_t CmdDisk ( int nArgs) if (nArgs > 2) goto _Help; - int drive = sg_DiskIICard.DiskGetCurrentDrive() + 1; + int drive = sg_DiskIICard.GetCurrentDrive() + 1; char buffer[200] = ""; ConsoleBufferPushFormat(buffer, "D%d at T$%X (%d), phase $%X, offset $%X, %s", drive, - sg_DiskIICard.DiskGetCurrentTrack(), - sg_DiskIICard.DiskGetCurrentTrack(), - sg_DiskIICard.DiskGetCurrentPhase(), - sg_DiskIICard.DiskGetCurrentOffset(), - sg_DiskIICard.DiskGetCurrentState()); + sg_DiskIICard.GetCurrentTrack(), + sg_DiskIICard.GetCurrentTrack(), + sg_DiskIICard.GetCurrentPhase(), + sg_DiskIICard.GetCurrentOffset(), + sg_DiskIICard.GetCurrentState()); return ConsoleUpdate(); } @@ -3762,7 +3762,7 @@ Update_t CmdDisk ( int nArgs) if (nArgs > 2) goto _Help; - sg_DiskIICard.DiskEject( iDrive ); + sg_DiskIICard.EjectDisk( iDrive ); FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); } else @@ -3776,7 +3776,7 @@ Update_t CmdDisk ( int nArgs) if (nArgs == 3) bProtect = g_aArgs[ 3 ].nValue ? true : false; - sg_DiskIICard.DiskSetProtect( iDrive, bProtect ); + sg_DiskIICard.SetProtect( iDrive, bProtect ); FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); } else @@ -3787,7 +3787,7 @@ Update_t CmdDisk ( int nArgs) LPCTSTR pDiskName = g_aArgs[ 3 ].sArg; // DISK # "Diskname" - sg_DiskIICard.DiskInsert( iDrive, pDiskName, IMAGE_FORCE_WRITE_PROTECTED, IMAGE_DONT_CREATE ); + sg_DiskIICard.InsertDisk( iDrive, pDiskName, IMAGE_FORCE_WRITE_PROTECTED, IMAGE_DONT_CREATE ); FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); } diff --git a/source/Disk.cpp b/source/Disk.cpp index 83abf6b7..b8613a89 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -69,21 +69,21 @@ DiskIIInterfaceCard::DiskIIInterfaceCard(void) #endif } -bool DiskIIInterfaceCard::Disk_GetEnhanceDisk(void) { return m_enhanceDisk; } -void DiskIIInterfaceCard::Disk_SetEnhanceDisk(bool bEnhanceDisk) { m_enhanceDisk = bEnhanceDisk; } +bool DiskIIInterfaceCard::GetEnhanceDisk(void) { return m_enhanceDisk; } +void DiskIIInterfaceCard::SetEnhanceDisk(bool bEnhanceDisk) { m_enhanceDisk = bEnhanceDisk; } -int DiskIIInterfaceCard::DiskGetCurrentDrive(void) { return m_currDrive; } -int DiskIIInterfaceCard::DiskGetCurrentTrack(void) { return m_floppyDrive[m_currDrive].track; } -int DiskIIInterfaceCard::DiskGetCurrentPhase(void) { return m_floppyDrive[m_currDrive].phase; } -int DiskIIInterfaceCard::DiskGetCurrentOffset(void) { return m_floppyDrive[m_currDrive].disk.byte; } -int DiskIIInterfaceCard::DiskGetTrack( int drive ) { return m_floppyDrive[ drive ].track; } +int DiskIIInterfaceCard::GetCurrentDrive(void) { return m_currDrive; } +int DiskIIInterfaceCard::GetCurrentTrack(void) { return m_floppyDrive[m_currDrive].track; } +int DiskIIInterfaceCard::GetCurrentPhase(void) { return m_floppyDrive[m_currDrive].phase; } +int DiskIIInterfaceCard::GetCurrentOffset(void) { return m_floppyDrive[m_currDrive].disk.byte; } +int DiskIIInterfaceCard::GetTrack(const int drive) { return m_floppyDrive[drive].track; } -const char* DiskIIInterfaceCard::DiskGetDiskPathFilename(const int iDrive) +LPCTSTR DiskIIInterfaceCard::GetDiskPathFilename(const int iDrive) { return m_floppyDrive[iDrive].disk.fullname; } -const char* DiskIIInterfaceCard::DiskGetCurrentState(void) +LPCTSTR DiskIIInterfaceCard::GetCurrentState(void) { if (m_floppyDrive[m_currDrive].disk.imagehandle == NULL) return "Empty"; @@ -118,7 +118,7 @@ const char* DiskIIInterfaceCard::DiskGetCurrentState(void) //=========================================================================== -void DiskIIInterfaceCard::Disk_LoadLastDiskImage(const int iDrive) +void DiskIIInterfaceCard::LoadLastDiskImage(const int iDrive) { _ASSERT(iDrive == DRIVE_1 || iDrive == DRIVE_2); @@ -135,14 +135,14 @@ void DiskIIInterfaceCard::Disk_LoadLastDiskImage(const int iDrive) m_saveDiskImage = false; // Pass in ptr to local copy of filepath, since RemoveDisk() sets DiskPathFilename = "" - DiskInsert(iDrive, sFilePath, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); + InsertDisk(iDrive, sFilePath, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); m_saveDiskImage = true; } } //=========================================================================== -void DiskIIInterfaceCard::Disk_SaveLastDiskImage(const int iDrive) +void DiskIIInterfaceCard::SaveLastDiskImage(const int iDrive) { _ASSERT(iDrive == DRIVE_1 || iDrive == DRIVE_2); @@ -276,7 +276,7 @@ void DiskIIInterfaceCard::RemoveDisk(const int iDrive) if (pFloppy->imagehandle) { - DiskFlushCurrentTrack(iDrive); + FlushCurrentTrack(iDrive); ImageClose(pFloppy->imagehandle); pFloppy->imagehandle = NULL; @@ -293,7 +293,7 @@ void DiskIIInterfaceCard::RemoveDisk(const int iDrive) memset( pFloppy->fullname , 0, MAX_DISK_FULL_NAME +1 ); pFloppy->strFilenameInZip = ""; - Disk_SaveLastDiskImage( iDrive ); + SaveLastDiskImage( iDrive ); Video_ResetScreenshotCounter( NULL ); } @@ -326,7 +326,7 @@ void DiskIIInterfaceCard::WriteTrack(const int iDrive) pFloppy->trackimagedirty = false; } -void DiskIIInterfaceCard::DiskFlushCurrentTrack(const int iDrive) +void DiskIIInterfaceCard::FlushCurrentTrack(const int iDrive) { Disk_t* pFloppy = &m_floppyDrive[iDrive].disk; @@ -336,7 +336,7 @@ void DiskIIInterfaceCard::DiskFlushCurrentTrack(const int iDrive) //=========================================================================== -void DiskIIInterfaceCard::DiskBoot(void) +void DiskIIInterfaceCard::Boot(void) { // THIS FUNCTION RELOADS A PROGRAM IMAGE IF ONE IS LOADED IN DRIVE ONE. // IF A DISK IMAGE OR NO IMAGE IS LOADED IN DRIVE ONE, IT DOES NOTHING. @@ -346,7 +346,7 @@ void DiskIIInterfaceCard::DiskBoot(void) //=========================================================================== -void __stdcall DiskIIInterfaceCard::DiskControlMotor(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles) +void __stdcall DiskIIInterfaceCard::ControlMotor(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles) { BOOL newState = address & 1; @@ -364,7 +364,7 @@ void __stdcall DiskIIInterfaceCard::DiskControlMotor(WORD, WORD address, BYTE, B //=========================================================================== -void __stdcall DiskIIInterfaceCard::DiskControlStepper(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles) +void __stdcall DiskIIInterfaceCard::ControlStepper(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles) { Drive_t* pDrive = &m_floppyDrive[m_currDrive]; Disk_t* pFloppy = &pDrive->disk; @@ -420,7 +420,7 @@ void __stdcall DiskIIInterfaceCard::DiskControlStepper(WORD, WORD address, BYTE, : MIN(nNumTracksInImage-1, pDrive->phase >> 1); // (round half tracks down) if (newtrack != pDrive->track) { - DiskFlushCurrentTrack(m_currDrive); + FlushCurrentTrack(m_currDrive); pDrive->track = newtrack; pFloppy->trackimagedata = false; @@ -451,7 +451,7 @@ void __stdcall DiskIIInterfaceCard::DiskControlStepper(WORD, WORD address, BYTE, //=========================================================================== -void DiskIIInterfaceCard::DiskDestroy(void) +void DiskIIInterfaceCard::Destroy(void) { m_saveDiskImage = false; RemoveDisk(DRIVE_1); @@ -464,7 +464,7 @@ void DiskIIInterfaceCard::DiskDestroy(void) //=========================================================================== -void __stdcall DiskIIInterfaceCard::DiskEnable(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles) +void __stdcall DiskIIInterfaceCard::Enable(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles) { m_currDrive = address & 1; #if LOG_DISK_ENABLE_DRIVE @@ -477,7 +477,7 @@ void __stdcall DiskIIInterfaceCard::DiskEnable(WORD, WORD address, BYTE, BYTE, U //=========================================================================== -void DiskIIInterfaceCard::DiskEject(const int iDrive) +void DiskIIInterfaceCard::EjectDisk(const int iDrive) { if (IsDriveValid(iDrive)) { @@ -489,19 +489,19 @@ void DiskIIInterfaceCard::DiskEject(const int iDrive) // Return the file or zip name // . Used by Property Sheet Page (Disk) -LPCTSTR DiskIIInterfaceCard::DiskGetFullName(const int iDrive) +LPCTSTR DiskIIInterfaceCard::GetFullName(const int iDrive) { return m_floppyDrive[iDrive].disk.fullname; } // Return the filename // . Used by Drive Buttons' tooltips -LPCTSTR DiskIIInterfaceCard::DiskGetFullDiskFilename(const int iDrive) +LPCTSTR DiskIIInterfaceCard::GetFullDiskFilename(const int iDrive) { if (!m_floppyDrive[iDrive].disk.strFilenameInZip.empty()) return m_floppyDrive[iDrive].disk.strFilenameInZip.c_str(); - return DiskGetFullName(iDrive); + return GetFullName(iDrive); } LPCTSTR DiskIIInterfaceCard::DiskGetFullPathName(const int iDrive) @@ -511,13 +511,13 @@ LPCTSTR DiskIIInterfaceCard::DiskGetFullPathName(const int iDrive) // Return the imagename // . Used by Drive Button's icons & Property Sheet Page (Save snapshot) -LPCTSTR DiskIIInterfaceCard::DiskGetBaseName(const int iDrive) +LPCTSTR DiskIIInterfaceCard::GetBaseName(const int iDrive) { return m_floppyDrive[iDrive].disk.imagename; } //=========================================================================== -void DiskIIInterfaceCard::DiskGetLightStatus(Disk_Status_e *pDisk1Status, Disk_Status_e *pDisk2Status) +void DiskIIInterfaceCard::GetLightStatus(Disk_Status_e *pDisk1Status, Disk_Status_e *pDisk2Status) { if (pDisk1Status) *pDisk1Status = GetDriveLightStatus(DRIVE_1); @@ -528,7 +528,7 @@ void DiskIIInterfaceCard::DiskGetLightStatus(Disk_Status_e *pDisk1Status, Disk_S //=========================================================================== -void DiskIIInterfaceCard::DiskInitialize(void) +void DiskIIInterfaceCard::Initialize(void) { int loop = NUM_DRIVES; while (loop--) @@ -537,7 +537,7 @@ void DiskIIInterfaceCard::DiskInitialize(void) //=========================================================================== -ImageError_e DiskIIInterfaceCard::DiskInsert(const int iDrive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary) +ImageError_e DiskIIInterfaceCard::InsertDisk(const int iDrive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary) { Drive_t* pDrive = &m_floppyDrive[iDrive]; Disk_t* pFloppy = &pDrive->disk; @@ -572,7 +572,7 @@ ImageError_e DiskIIInterfaceCard::DiskInsert(const int iDrive, LPCTSTR pszImageF if (!strcmp(pszOtherPathname, szCurrentPathname)) { - DiskEject(!iDrive); + EjectDisk(!iDrive); FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); } } @@ -606,26 +606,26 @@ ImageError_e DiskIIInterfaceCard::DiskInsert(const int iDrive, LPCTSTR pszImageF Video_ResetScreenshotCounter(NULL); } - Disk_SaveLastDiskImage(iDrive); + SaveLastDiskImage(iDrive); return Error; } //=========================================================================== -bool DiskIIInterfaceCard::Disk_IsConditionForFullSpeed(void) +bool DiskIIInterfaceCard::IsConditionForFullSpeed(void) { return m_floppyMotorOn && m_enhanceDisk; } -BOOL DiskIIInterfaceCard::DiskIsSpinning(void) +BOOL DiskIIInterfaceCard::IsSpinning(void) { return m_floppyMotorOn; } //=========================================================================== -void DiskIIInterfaceCard::DiskNotifyInvalidImage(const int iDrive, LPCTSTR pszImageFilename, const ImageError_e Error) +void DiskIIInterfaceCard::NotifyInvalidImage(const int iDrive, LPCTSTR pszImageFilename, const ImageError_e Error) { TCHAR szBuffer[MAX_PATH+128]; szBuffer[sizeof(szBuffer)-1] = 0; @@ -738,7 +738,7 @@ void DiskIIInterfaceCard::DiskNotifyInvalidImage(const int iDrive, LPCTSTR pszIm //=========================================================================== -bool DiskIIInterfaceCard::DiskGetProtect(const int iDrive) +bool DiskIIInterfaceCard::GetProtect(const int iDrive) { if (IsDriveValid(iDrive)) { @@ -751,7 +751,7 @@ bool DiskIIInterfaceCard::DiskGetProtect(const int iDrive) //=========================================================================== -void DiskIIInterfaceCard::DiskSetProtect(const int iDrive, const bool bWriteProtect) +void DiskIIInterfaceCard::SetProtect(const int iDrive, const bool bWriteProtect) { if (IsDriveValid( iDrive )) { @@ -761,7 +761,7 @@ void DiskIIInterfaceCard::DiskSetProtect(const int iDrive, const bool bWriteProt //=========================================================================== -bool DiskIIInterfaceCard::Disk_ImageIsWriteProtected(const int iDrive) +bool DiskIIInterfaceCard::IsDiskImageWriteProtected(const int iDrive) { if (!IsDriveValid(iDrive)) return true; @@ -771,7 +771,7 @@ bool DiskIIInterfaceCard::Disk_ImageIsWriteProtected(const int iDrive) //=========================================================================== -bool DiskIIInterfaceCard::Disk_IsDriveEmpty(const int iDrive) +bool DiskIIInterfaceCard::IsDriveEmpty(const int iDrive) { if (!IsDriveValid(iDrive)) return true; @@ -812,7 +812,7 @@ bool DiskIIInterfaceCard::LogWriteCheckSyncFF(ULONG& uCycleDelta) //=========================================================================== -void __stdcall DiskIIInterfaceCard::DiskReadWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles) +void __stdcall DiskIIInterfaceCard::ReadWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles) { /* m_floppyLoadMode = 0; */ Drive_t* pDrive = &m_floppyDrive[m_currDrive]; @@ -926,7 +926,7 @@ void __stdcall DiskIIInterfaceCard::DiskReadWrite(WORD pc, WORD addr, BYTE bWrit //=========================================================================== -void DiskIIInterfaceCard::DiskReset(const bool bIsPowerCycle/*=false*/) +void DiskIIInterfaceCard::Reset(const bool bIsPowerCycle/*=false*/) { // RESET forces all switches off (UTAIIe Table 9.1) m_currDrive = 0; @@ -954,7 +954,7 @@ void DiskIIInterfaceCard::DiskReset(const bool bIsPowerCycle/*=false*/) //=========================================================================== -bool DiskIIInterfaceCard::DiskSelectImage(const int iDrive, LPCSTR pszFilename) +bool DiskIIInterfaceCard::UserSelectNewDiskImage(const int iDrive, LPCSTR pszFilename/*=""*/) { TCHAR directory[MAX_PATH] = TEXT(""); TCHAR filename[MAX_PATH] = TEXT(""); @@ -989,14 +989,14 @@ bool DiskIIInterfaceCard::DiskSelectImage(const int iDrive, LPCSTR pszFilename) if ((!ofn.nFileExtension) || !filename[ofn.nFileExtension]) _tcscat(filename,TEXT(".dsk")); - ImageError_e Error = DiskInsert(iDrive, filename, ofn.Flags & OFN_READONLY, IMAGE_CREATE); + ImageError_e Error = InsertDisk(iDrive, filename, ofn.Flags & OFN_READONLY, IMAGE_CREATE); if (Error == eIMAGE_ERROR_NONE) { bRes = true; } else { - DiskNotifyInvalidImage(iDrive, filename, Error); + NotifyInvalidImage(iDrive, filename, Error); } } @@ -1005,14 +1005,7 @@ bool DiskIIInterfaceCard::DiskSelectImage(const int iDrive, LPCSTR pszFilename) //=========================================================================== -bool DiskIIInterfaceCard::DiskSelect(const int iDrive) -{ - return DiskSelectImage(iDrive, TEXT("")); -} - -//=========================================================================== - -void __stdcall DiskIIInterfaceCard::DiskLoadWriteProtect(WORD, WORD, BYTE write, BYTE value, ULONG) +void __stdcall DiskIIInterfaceCard::LoadWriteProtect(WORD, WORD, BYTE write, BYTE value, ULONG) { /* m_floppyLoadMode = 1; */ @@ -1038,7 +1031,7 @@ void __stdcall DiskIIInterfaceCard::DiskLoadWriteProtect(WORD, WORD, BYTE write, //=========================================================================== -void __stdcall DiskIIInterfaceCard::DiskSetReadMode(WORD, WORD, BYTE, BYTE, ULONG) +void __stdcall DiskIIInterfaceCard::SetReadMode(WORD, WORD, BYTE, BYTE, ULONG) { m_floppyWriteMode = 0; @@ -1051,7 +1044,7 @@ void __stdcall DiskIIInterfaceCard::DiskSetReadMode(WORD, WORD, BYTE, BYTE, ULON //=========================================================================== -void __stdcall DiskIIInterfaceCard::DiskSetWriteMode(WORD, WORD, BYTE, BYTE, ULONG uExecutedCycles) +void __stdcall DiskIIInterfaceCard::SetWriteMode(WORD, WORD, BYTE, BYTE, ULONG uExecutedCycles) { m_floppyWriteMode = 1; @@ -1073,7 +1066,7 @@ void __stdcall DiskIIInterfaceCard::DiskSetWriteMode(WORD, WORD, BYTE, BYTE, ULO //=========================================================================== -void DiskIIInterfaceCard::DiskUpdateDriveState(DWORD cycles) +void DiskIIInterfaceCard::UpdateDriveState(DWORD cycles) { int loop = NUM_DRIVES; while (loop--) @@ -1106,7 +1099,7 @@ void DiskIIInterfaceCard::DiskUpdateDriveState(DWORD cycles) //=========================================================================== -bool DiskIIInterfaceCard::DiskDriveSwap(void) +bool DiskIIInterfaceCard::DriveSwap(void) { // Refuse to swap if either Disk][ is active // TODO: if Shift-Click then FORCE drive swap to bypass message @@ -1140,8 +1133,8 @@ bool DiskIIInterfaceCard::DiskDriveSwap(void) } } - DiskFlushCurrentTrack(DRIVE_1); - DiskFlushCurrentTrack(DRIVE_2); + FlushCurrentTrack(DRIVE_1); + FlushCurrentTrack(DRIVE_2); // Swap disks between drives // . NB. We swap trackimage ptrs (so don't need to swap the buffers' data) @@ -1151,8 +1144,8 @@ bool DiskIIInterfaceCard::DiskDriveSwap(void) m_floppyDrive[DRIVE_1].disk.trackimagedata = false; m_floppyDrive[DRIVE_2].disk.trackimagedata = false; - Disk_SaveLastDiskImage(DRIVE_1); - Disk_SaveLastDiskImage(DRIVE_2); + SaveLastDiskImage(DRIVE_1); + SaveLastDiskImage(DRIVE_2); FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES, false); @@ -1191,36 +1184,36 @@ void DiskIIInterfaceCard::Initialize(LPBYTE pCxRomPeripheral, UINT uSlot) // . Patching the firmware breaks the ADC checksum used by "The CIA Files" (Tricky Dick) // . In this case we can patch to compensate for an ADC or EOR checksum but not both (nickw) - RegisterIoHandler(uSlot, &DiskIIInterfaceCard::Disk_IORead, &DiskIIInterfaceCard::Disk_IOWrite, NULL, NULL, this, NULL); + RegisterIoHandler(uSlot, &DiskIIInterfaceCard::IORead, &DiskIIInterfaceCard::IOWrite, NULL, NULL, this, NULL); m_slot = uSlot; } //=========================================================================== -BYTE __stdcall DiskIIInterfaceCard::Disk_IORead(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles) +BYTE __stdcall DiskIIInterfaceCard::IORead(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles) { UINT uSlot = ((addr & 0xff) >> 4) - 8; DiskIIInterfaceCard* pCard = (DiskIIInterfaceCard*) MemGetSlotParameters(uSlot); switch (addr & 0xF) { - case 0x0: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x1: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x2: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x3: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x4: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x5: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x6: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x7: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x8: pCard->DiskControlMotor(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x9: pCard->DiskControlMotor(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xA: pCard->DiskEnable(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xB: pCard->DiskEnable(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xC: pCard->DiskReadWrite(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xD: pCard->DiskLoadWriteProtect(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xE: pCard->DiskSetReadMode(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xF: pCard->DiskSetWriteMode(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x0: pCard->ControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x1: pCard->ControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x2: pCard->ControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x3: pCard->ControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x4: pCard->ControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x5: pCard->ControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x6: pCard->ControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x7: pCard->ControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x8: pCard->ControlMotor(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x9: pCard->ControlMotor(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xA: pCard->Enable(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xB: pCard->Enable(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xC: pCard->ReadWrite(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xD: pCard->LoadWriteProtect(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xE: pCard->SetReadMode(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xF: pCard->SetWriteMode(pc, addr, bWrite, d, nExecutedCycles); break; } // only even addresses return the latch (UTAIIe Table 9.1) @@ -1230,29 +1223,29 @@ BYTE __stdcall DiskIIInterfaceCard::Disk_IORead(WORD pc, WORD addr, BYTE bWrite, return MemReadFloatingBus(nExecutedCycles); } -BYTE __stdcall DiskIIInterfaceCard::Disk_IOWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles) +BYTE __stdcall DiskIIInterfaceCard::IOWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles) { UINT uSlot = ((addr & 0xff) >> 4) - 8; DiskIIInterfaceCard* pCard = (DiskIIInterfaceCard*) MemGetSlotParameters(uSlot); switch (addr & 0xF) { - case 0x0: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x1: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x2: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x3: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x4: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x5: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x6: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x7: pCard->DiskControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x8: pCard->DiskControlMotor(pc, addr, bWrite, d, nExecutedCycles); break; - case 0x9: pCard->DiskControlMotor(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xA: pCard->DiskEnable(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xB: pCard->DiskEnable(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xC: pCard->DiskReadWrite(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xD: pCard->DiskLoadWriteProtect(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xE: pCard->DiskSetReadMode(pc, addr, bWrite, d, nExecutedCycles); break; - case 0xF: pCard->DiskSetWriteMode(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x0: pCard->ControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x1: pCard->ControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x2: pCard->ControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x3: pCard->ControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x4: pCard->ControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x5: pCard->ControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x6: pCard->ControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x7: pCard->ControlStepper(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x8: pCard->ControlMotor(pc, addr, bWrite, d, nExecutedCycles); break; + case 0x9: pCard->ControlMotor(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xA: pCard->Enable(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xB: pCard->Enable(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xC: pCard->ReadWrite(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xD: pCard->LoadWriteProtect(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xE: pCard->SetReadMode(pc, addr, bWrite, d, nExecutedCycles); break; + case 0xF: pCard->SetWriteMode(pc, addr, bWrite, d, nExecutedCycles); break; } // any address writes the latch via sequencer LD command (74LS323 datasheet) @@ -1295,13 +1288,13 @@ static const UINT kUNIT_VERSION = 3; #define SS_YAML_KEY_TRACK_IMAGE_DIRTY "Track Image Dirty" #define SS_YAML_KEY_TRACK_IMAGE "Track Image" -std::string DiskIIInterfaceCard::DiskGetSnapshotCardName(void) +std::string DiskIIInterfaceCard::GetSnapshotCardName(void) { static const std::string name(SS_YAML_VALUE_CARD_DISK2); return name; } -void DiskIIInterfaceCard::DiskSaveSnapshotDisk2Unit(YamlSaveHelper& yamlSaveHelper, UINT unit) +void DiskIIInterfaceCard::SaveSnapshotDisk2Unit(YamlSaveHelper& yamlSaveHelper, UINT unit) { YamlSaveHelper::Label label(yamlSaveHelper, "%s%d:\n", SS_YAML_KEY_DISK2UNIT, unit); yamlSaveHelper.SaveString(SS_YAML_KEY_FILENAME, m_floppyDrive[unit].disk.fullname); @@ -1322,9 +1315,9 @@ void DiskIIInterfaceCard::DiskSaveSnapshotDisk2Unit(YamlSaveHelper& yamlSaveHelp } } -void DiskIIInterfaceCard::DiskSaveSnapshot(class YamlSaveHelper& yamlSaveHelper) +void DiskIIInterfaceCard::SaveSnapshot(class YamlSaveHelper& yamlSaveHelper) { - YamlSaveHelper::Slot slot(yamlSaveHelper, DiskGetSnapshotCardName(), m_slot, kUNIT_VERSION); + YamlSaveHelper::Slot slot(yamlSaveHelper, GetSnapshotCardName(), m_slot, kUNIT_VERSION); YamlSaveHelper::Label state(yamlSaveHelper, "%s:\n", SS_YAML_KEY_STATE); yamlSaveHelper.SaveHexUint4(SS_YAML_KEY_PHASES, m_phases); @@ -1338,11 +1331,11 @@ void DiskIIInterfaceCard::DiskSaveSnapshot(class YamlSaveHelper& yamlSaveHelper) yamlSaveHelper.SaveHexUint64(SS_YAML_KEY_LAST_READ_LATCH_CYCLE, m_diskLastReadLatchCycle); // v3 m_formatTrack.SaveSnapshot(yamlSaveHelper); // v2 - DiskSaveSnapshotDisk2Unit(yamlSaveHelper, DRIVE_1); - DiskSaveSnapshotDisk2Unit(yamlSaveHelper, DRIVE_2); + SaveSnapshotDisk2Unit(yamlSaveHelper, DRIVE_1); + SaveSnapshotDisk2Unit(yamlSaveHelper, DRIVE_2); } -void DiskIIInterfaceCard::DiskLoadSnapshotDriveUnit(YamlLoadHelper& yamlLoadHelper, UINT unit) +void DiskIIInterfaceCard::LoadSnapshotDriveUnit(YamlLoadHelper& yamlLoadHelper, UINT unit) { std::string disk2UnitName = std::string(SS_YAML_KEY_DISK2UNIT) + (unit == DRIVE_1 ? std::string("0") : std::string("1")); if (!yamlLoadHelper.GetSubMap(disk2UnitName)) @@ -1361,7 +1354,7 @@ void DiskIIInterfaceCard::DiskLoadSnapshotDriveUnit(YamlLoadHelper& yamlLoadHelp if(dwAttributes == INVALID_FILE_ATTRIBUTES) { // Get user to browse for file - DiskSelectImage(unit, filename.c_str()); + UserSelectNewDiskImage(unit, filename.c_str()); dwAttributes = GetFileAttributes(filename.c_str()); } @@ -1369,7 +1362,7 @@ void DiskIIInterfaceCard::DiskLoadSnapshotDriveUnit(YamlLoadHelper& yamlLoadHelp bImageError = (dwAttributes == INVALID_FILE_ATTRIBUTES); if (!bImageError) { - if(DiskInsert(unit, filename.c_str(), dwAttributes & FILE_ATTRIBUTE_READONLY, IMAGE_DONT_CREATE) != eIMAGE_ERROR_NONE) + if(InsertDisk(unit, filename.c_str(), dwAttributes & FILE_ATTRIBUTE_READONLY, IMAGE_DONT_CREATE) != eIMAGE_ERROR_NONE) bImageError = true; // DiskInsert() zeros m_floppyDrive[unit], then sets up: @@ -1419,7 +1412,7 @@ void DiskIIInterfaceCard::DiskLoadSnapshotDriveUnit(YamlLoadHelper& yamlLoadHelp } } -bool DiskIIInterfaceCard::DiskLoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version) +bool DiskIIInterfaceCard::LoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version) { if (slot != 6) // fixme throw std::string("Card: wrong slot"); @@ -1427,12 +1420,12 @@ bool DiskIIInterfaceCard::DiskLoadSnapshot(class YamlLoadHelper& yamlLoadHelper, if (version < 1 || version > kUNIT_VERSION) throw std::string("Card: wrong version"); - m_phases = yamlLoadHelper.LoadUint(SS_YAML_KEY_PHASES); - m_currDrive = yamlLoadHelper.LoadUint(SS_YAML_KEY_CURRENT_DRIVE); - (void) yamlLoadHelper.LoadBool(SS_YAML_KEY_DISK_ACCESSED); // deprecated - but retrieve the value to avoid the "State: Unknown key (Disk Accessed)" warning + m_phases = yamlLoadHelper.LoadUint(SS_YAML_KEY_PHASES); + m_currDrive = yamlLoadHelper.LoadUint(SS_YAML_KEY_CURRENT_DRIVE); + (void) yamlLoadHelper.LoadBool(SS_YAML_KEY_DISK_ACCESSED); // deprecated - but retrieve the value to avoid the "State: Unknown key (Disk Accessed)" warning m_enhanceDisk = yamlLoadHelper.LoadBool(SS_YAML_KEY_ENHANCE_DISK); m_floppyLatch = yamlLoadHelper.LoadUint(SS_YAML_KEY_FLOPPY_LATCH); - m_floppyMotorOn = yamlLoadHelper.LoadBool(SS_YAML_KEY_FLOPPY_MOTOR_ON); + m_floppyMotorOn = yamlLoadHelper.LoadBool(SS_YAML_KEY_FLOPPY_MOTOR_ON); m_floppyWriteMode = yamlLoadHelper.LoadBool(SS_YAML_KEY_FLOPPY_WRITE_MODE); if (version >= 2) @@ -1447,14 +1440,14 @@ bool DiskIIInterfaceCard::DiskLoadSnapshot(class YamlLoadHelper& yamlLoadHelper, } // Eject all disks first in case Drive-2 contains disk to be inserted into Drive-1 - for(UINT i=0; ihdr.hwndFrom == tooltipwindow && ((LPNMTTDISPINFO)lparam)->hdr.code == TTN_GETDISPINFO) ((LPNMTTDISPINFO)lparam)->lpszText = - (LPTSTR)sg_DiskIICard.DiskGetFullDiskFilename(((LPNMTTDISPINFO)lparam)->hdr.idFrom); + (LPTSTR)sg_DiskIICard.GetFullDiskFilename(((LPNMTTDISPINFO)lparam)->hdr.idFrom); break; case WM_PAINT: @@ -1967,7 +1967,7 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) if (g_nAppMode == MODE_LOGO) { - sg_DiskIICard.DiskBoot(); + sg_DiskIICard.Boot(); LogFileTimeUntilFirstKeyReadReset(); g_nAppMode = MODE_RUNNING; } @@ -1990,13 +1990,13 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) case BTN_DRIVE1: case BTN_DRIVE2: - sg_DiskIICard.DiskSelect(button-BTN_DRIVE1); + sg_DiskIICard.UserSelectNewDiskImage(button-BTN_DRIVE1); if (!g_bIsFullScreen) DrawButton((HDC)0,button); break; case BTN_DRIVESWAP: - sg_DiskIICard.DiskDriveSwap(); + sg_DiskIICard.DriveSwap(); break; case BTN_FULLSCR: @@ -2057,7 +2057,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) //TODO: A directory is open if an empty path to CiderPress is set. This has to be fixed. std::string filename1= "\""; - filename1.append( sg_DiskIICard.DiskGetDiskPathFilename(iDrive) ); + filename1.append( sg_DiskIICard.GetDiskPathFilename(iDrive) ); filename1.append("\""); std::string sFileNameEmpty = "\""; sFileNameEmpty.append("\""); @@ -2079,16 +2079,16 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) // Check menu depending on current floppy protection { int iMenuItem = ID_DISKMENU_WRITEPROTECTION_OFF; - if (sg_DiskIICard.DiskGetProtect( iDrive )) + if (sg_DiskIICard.GetProtect( iDrive )) iMenuItem = ID_DISKMENU_WRITEPROTECTION_ON; CheckMenuItem(hmenu, iMenuItem, MF_CHECKED); } - if (sg_DiskIICard.Disk_IsDriveEmpty(iDrive)) + if (sg_DiskIICard.IsDriveEmpty(iDrive)) EnableMenuItem(hmenu, ID_DISKMENU_EJECT, MF_GRAYED); - if (sg_DiskIICard.Disk_ImageIsWriteProtected(iDrive)) + if (sg_DiskIICard.IsDiskImageWriteProtected(iDrive)) { // If image-file is read-only (or a gzip) then disable these menu items EnableMenuItem(hmenu, ID_DISKMENU_WRITEPROTECTION_ON, MF_GRAYED); @@ -2104,13 +2104,13 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) , hwnd, NULL ); if (iCommand == ID_DISKMENU_EJECT) - sg_DiskIICard.DiskEject( iDrive ); + sg_DiskIICard.EjectDisk( iDrive ); else if (iCommand == ID_DISKMENU_WRITEPROTECTION_ON) - sg_DiskIICard.DiskSetProtect( iDrive, true ); + sg_DiskIICard.SetProtect( iDrive, true ); else if (iCommand == ID_DISKMENU_WRITEPROTECTION_OFF) - sg_DiskIICard.DiskSetProtect( iDrive, false ); + sg_DiskIICard.SetProtect( iDrive, false ); else if (iCommand == ID_DISKMENU_SENDTO_CIDERPRESS) { @@ -2119,7 +2119,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) "Please install CiderPress.\n" "Otherwise set the path to CiderPress from Configuration->Disk."; - sg_DiskIICard.DiskFlushCurrentTrack(iDrive); + sg_DiskIICard.FlushCurrentTrack(iDrive); //if(!filename1.compare("\"\"") == false) //Do not use this, for some reason it does not work!!! if(!filename1.compare(sFileNameEmpty) ) @@ -2181,13 +2181,13 @@ void RelayEvent (UINT message, WPARAM wparam, LPARAM lparam) { // todo: consolidate CtrlReset() and ResetMachineState() void ResetMachineState () { - sg_DiskIICard.DiskReset(true); + sg_DiskIICard.Reset(true); HD_Reset(); g_bFullSpeed = 0; // Might've hit reset in middle of InternalCpuExecute() - so beep may get (partially) muted MemReset(); // calls CpuInitialize() PravetsReset(); - sg_DiskIICard.DiskBoot(); + sg_DiskIICard.Boot(); VideoResetState(); sg_SSC.CommReset(); PrintReset(); @@ -2225,7 +2225,7 @@ void CtrlReset() } PravetsReset(); - sg_DiskIICard.DiskReset(); + sg_DiskIICard.Reset(); HD_Reset(); KeybReset(); sg_SSC.CommReset(); diff --git a/source/SaveState.cpp b/source/SaveState.cpp index 447423f8..19d5b27e 100644 --- a/source/SaveState.cpp +++ b/source/SaveState.cpp @@ -286,9 +286,9 @@ static void ParseSlots(YamlLoadHelper& yamlLoadHelper, UINT unitVersion) bRes = Phasor_LoadSnapshot(yamlLoadHelper, slot, cardVersion); type = CT_Phasor; } - else if (card == sg_DiskIICard.DiskGetSnapshotCardName()) + else if (card == sg_DiskIICard.GetSnapshotCardName()) { - bRes = sg_DiskIICard.DiskLoadSnapshot(yamlLoadHelper, slot, cardVersion); + bRes = sg_DiskIICard.LoadSnapshot(yamlLoadHelper, slot, cardVersion); type = CT_Disk2; } else if (card == HD_GetSnapshotCardName()) @@ -391,7 +391,7 @@ static void Snapshot_LoadState_v2(void) MemReset(); PravetsReset(); - sg_DiskIICard.DiskReset(); + sg_DiskIICard.Reset(); HD_Reset(); KeybReset(); VideoResetState(); @@ -519,7 +519,7 @@ void Snapshot_SaveState(void) if (g_Slot4 == CT_Phasor) Phasor_SaveSnapshot(yamlSaveHelper, 4); - sg_DiskIICard.DiskSaveSnapshot(yamlSaveHelper); + sg_DiskIICard.SaveSnapshot(yamlSaveHelper); HD_SaveSnapshot(yamlSaveHelper); } diff --git a/source/Video.cpp b/source/Video.cpp index 147ce350..ed6d986b 100644 --- a/source/Video.cpp +++ b/source/Video.cpp @@ -304,7 +304,7 @@ void VideoBenchmark () { while (cycles > 0) { DWORD executedcycles = CpuExecute(103, true); cycles -= executedcycles; - sg_DiskIICard.DiskUpdateDriveState(executedcycles); + sg_DiskIICard.UpdateDriveState(executedcycles); JoyUpdateButtonLatch(executedcycles); } } From 7c04c2c51efbe041ba8961980991587660a78418 Mon Sep 17 00:00:00 2001 From: tomcw Date: Mon, 8 Apr 2019 16:54:11 +0100 Subject: [PATCH 5/7] Rename var: iDrive to drive --- source/Disk.cpp | 138 ++++++++++++++++++++++++------------------------ source/Disk.h | 44 +++++++-------- 2 files changed, 91 insertions(+), 91 deletions(-) diff --git a/source/Disk.cpp b/source/Disk.cpp index b8613a89..d2ed3527 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -78,9 +78,9 @@ int DiskIIInterfaceCard::GetCurrentPhase(void) { return m_floppyDrive[m_currDri int DiskIIInterfaceCard::GetCurrentOffset(void) { return m_floppyDrive[m_currDrive].disk.byte; } int DiskIIInterfaceCard::GetTrack(const int drive) { return m_floppyDrive[drive].track; } -LPCTSTR DiskIIInterfaceCard::GetDiskPathFilename(const int iDrive) +LPCTSTR DiskIIInterfaceCard::GetDiskPathFilename(const int drive) { - return m_floppyDrive[iDrive].disk.fullname; + return m_floppyDrive[drive].disk.fullname; } LPCTSTR DiskIIInterfaceCard::GetCurrentState(void) @@ -118,14 +118,14 @@ LPCTSTR DiskIIInterfaceCard::GetCurrentState(void) //=========================================================================== -void DiskIIInterfaceCard::LoadLastDiskImage(const int iDrive) +void DiskIIInterfaceCard::LoadLastDiskImage(const int drive) { - _ASSERT(iDrive == DRIVE_1 || iDrive == DRIVE_2); + _ASSERT(drive == DRIVE_1 || drive == DRIVE_2); char sFilePath[ MAX_PATH + 1]; sFilePath[0] = 0; - const char *pRegKey = (iDrive == DRIVE_1) + const char *pRegKey = (drive == DRIVE_1) ? REGVALUE_PREF_LAST_DISK_1 : REGVALUE_PREF_LAST_DISK_2; @@ -135,23 +135,23 @@ void DiskIIInterfaceCard::LoadLastDiskImage(const int iDrive) m_saveDiskImage = false; // Pass in ptr to local copy of filepath, since RemoveDisk() sets DiskPathFilename = "" - InsertDisk(iDrive, sFilePath, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); + InsertDisk(drive, sFilePath, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); m_saveDiskImage = true; } } //=========================================================================== -void DiskIIInterfaceCard::SaveLastDiskImage(const int iDrive) +void DiskIIInterfaceCard::SaveLastDiskImage(const int drive) { - _ASSERT(iDrive == DRIVE_1 || iDrive == DRIVE_2); + _ASSERT(drive == DRIVE_1 || drive == DRIVE_2); if (!m_saveDiskImage) return; - const char *pFileName = m_floppyDrive[iDrive].disk.fullname; + const char *pFileName = m_floppyDrive[drive].disk.fullname; - if (iDrive == DRIVE_1) + if (drive == DRIVE_1) RegSaveString(TEXT(REG_PREFS), REGVALUE_PREF_LAST_DISK_1, TRUE, pFileName); else RegSaveString(TEXT(REG_PREFS), REGVALUE_PREF_LAST_DISK_2, TRUE, pFileName); @@ -159,7 +159,7 @@ void DiskIIInterfaceCard::SaveLastDiskImage(const int iDrive) // char szPathName[MAX_PATH]; - strcpy(szPathName, DiskGetFullPathName(iDrive)); + strcpy(szPathName, DiskGetFullPathName(drive)); if (_tcsrchr(szPathName, TEXT('\\'))) { char* pPathEnd = _tcsrchr(szPathName, TEXT('\\'))+1; @@ -191,11 +191,11 @@ void DiskIIInterfaceCard::CheckSpinning(const ULONG nExecutedCycles) //=========================================================================== -Disk_Status_e DiskIIInterfaceCard::GetDriveLightStatus(const int iDrive) +Disk_Status_e DiskIIInterfaceCard::GetDriveLightStatus(const int drive) { - if (IsDriveValid( iDrive )) + if (IsDriveValid( drive )) { - Drive_t* pDrive = &m_floppyDrive[ iDrive ]; + Drive_t* pDrive = &m_floppyDrive[ drive ]; if (pDrive->spinning) { @@ -218,27 +218,27 @@ Disk_Status_e DiskIIInterfaceCard::GetDriveLightStatus(const int iDrive) //=========================================================================== -bool DiskIIInterfaceCard::IsDriveValid(const int iDrive) +bool DiskIIInterfaceCard::IsDriveValid(const int drive) { - return (iDrive >= 0 && iDrive < NUM_DRIVES); + return (drive >= 0 && drive < NUM_DRIVES); } //=========================================================================== -void DiskIIInterfaceCard::AllocTrack(const int iDrive) +void DiskIIInterfaceCard::AllocTrack(const int drive) { - Disk_t* pFloppy = &m_floppyDrive[iDrive].disk; + Disk_t* pFloppy = &m_floppyDrive[drive].disk; pFloppy->trackimage = (LPBYTE)VirtualAlloc(NULL, NIBBLES_PER_TRACK, MEM_COMMIT, PAGE_READWRITE); } //=========================================================================== -void DiskIIInterfaceCard::ReadTrack(const int iDrive) +void DiskIIInterfaceCard::ReadTrack(const int drive) { - if (! IsDriveValid( iDrive )) + if (! IsDriveValid( drive )) return; - Drive_t* pDrive = &m_floppyDrive[ iDrive ]; + Drive_t* pDrive = &m_floppyDrive[ drive ]; Disk_t* pFloppy = &pDrive->disk; if (pDrive->track >= ImageGetNumTracks(pFloppy->imagehandle)) @@ -248,7 +248,7 @@ void DiskIIInterfaceCard::ReadTrack(const int iDrive) } if (!pFloppy->trackimage) - AllocTrack( iDrive ); + AllocTrack( drive ); if (pFloppy->trackimage && pFloppy->imagehandle) { @@ -270,13 +270,13 @@ void DiskIIInterfaceCard::ReadTrack(const int iDrive) //=========================================================================== -void DiskIIInterfaceCard::RemoveDisk(const int iDrive) +void DiskIIInterfaceCard::RemoveDisk(const int drive) { - Disk_t* pFloppy = &m_floppyDrive[iDrive].disk; + Disk_t* pFloppy = &m_floppyDrive[drive].disk; if (pFloppy->imagehandle) { - FlushCurrentTrack(iDrive); + FlushCurrentTrack(drive); ImageClose(pFloppy->imagehandle); pFloppy->imagehandle = NULL; @@ -293,15 +293,15 @@ void DiskIIInterfaceCard::RemoveDisk(const int iDrive) memset( pFloppy->fullname , 0, MAX_DISK_FULL_NAME +1 ); pFloppy->strFilenameInZip = ""; - SaveLastDiskImage( iDrive ); + SaveLastDiskImage( drive ); Video_ResetScreenshotCounter( NULL ); } //=========================================================================== -void DiskIIInterfaceCard::WriteTrack(const int iDrive) +void DiskIIInterfaceCard::WriteTrack(const int drive) { - Drive_t* pDrive = &m_floppyDrive[ iDrive ]; + Drive_t* pDrive = &m_floppyDrive[ drive ]; Disk_t* pFloppy = &pDrive->disk; if (pDrive->track >= ImageGetNumTracks(pFloppy->imagehandle)) @@ -326,12 +326,12 @@ void DiskIIInterfaceCard::WriteTrack(const int iDrive) pFloppy->trackimagedirty = false; } -void DiskIIInterfaceCard::FlushCurrentTrack(const int iDrive) +void DiskIIInterfaceCard::FlushCurrentTrack(const int drive) { - Disk_t* pFloppy = &m_floppyDrive[iDrive].disk; + Disk_t* pFloppy = &m_floppyDrive[drive].disk; if (pFloppy->trackimage && pFloppy->trackimagedirty) - WriteTrack(iDrive); + WriteTrack(drive); } //=========================================================================== @@ -477,11 +477,11 @@ void __stdcall DiskIIInterfaceCard::Enable(WORD, WORD address, BYTE, BYTE, ULONG //=========================================================================== -void DiskIIInterfaceCard::EjectDisk(const int iDrive) +void DiskIIInterfaceCard::EjectDisk(const int drive) { - if (IsDriveValid(iDrive)) + if (IsDriveValid(drive)) { - RemoveDisk(iDrive); + RemoveDisk(drive); } } @@ -489,31 +489,31 @@ void DiskIIInterfaceCard::EjectDisk(const int iDrive) // Return the file or zip name // . Used by Property Sheet Page (Disk) -LPCTSTR DiskIIInterfaceCard::GetFullName(const int iDrive) +LPCTSTR DiskIIInterfaceCard::GetFullName(const int drive) { - return m_floppyDrive[iDrive].disk.fullname; + return m_floppyDrive[drive].disk.fullname; } // Return the filename // . Used by Drive Buttons' tooltips -LPCTSTR DiskIIInterfaceCard::GetFullDiskFilename(const int iDrive) +LPCTSTR DiskIIInterfaceCard::GetFullDiskFilename(const int drive) { - if (!m_floppyDrive[iDrive].disk.strFilenameInZip.empty()) - return m_floppyDrive[iDrive].disk.strFilenameInZip.c_str(); + if (!m_floppyDrive[drive].disk.strFilenameInZip.empty()) + return m_floppyDrive[drive].disk.strFilenameInZip.c_str(); - return GetFullName(iDrive); + return GetFullName(drive); } -LPCTSTR DiskIIInterfaceCard::DiskGetFullPathName(const int iDrive) +LPCTSTR DiskIIInterfaceCard::DiskGetFullPathName(const int drive) { - return ImageGetPathname(m_floppyDrive[iDrive].disk.imagehandle); + return ImageGetPathname(m_floppyDrive[drive].disk.imagehandle); } // Return the imagename // . Used by Drive Button's icons & Property Sheet Page (Save snapshot) -LPCTSTR DiskIIInterfaceCard::GetBaseName(const int iDrive) +LPCTSTR DiskIIInterfaceCard::GetBaseName(const int drive) { - return m_floppyDrive[iDrive].disk.imagename; + return m_floppyDrive[drive].disk.imagename; } //=========================================================================== @@ -537,13 +537,13 @@ void DiskIIInterfaceCard::Initialize(void) //=========================================================================== -ImageError_e DiskIIInterfaceCard::InsertDisk(const int iDrive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary) +ImageError_e DiskIIInterfaceCard::InsertDisk(const int drive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary) { - Drive_t* pDrive = &m_floppyDrive[iDrive]; + Drive_t* pDrive = &m_floppyDrive[drive]; Disk_t* pFloppy = &pDrive->disk; if (pFloppy->imagehandle) - RemoveDisk(iDrive); + RemoveDisk(drive); // Reset the drive's struct, but preserve the physical attributes (bug#18242: Platoon) // . Changing the disk (in the drive) doesn't affect the drive's head etc. @@ -563,7 +563,7 @@ ImageError_e DiskIIInterfaceCard::InsertDisk(const int iDrive, LPCTSTR pszImageF // Check if image is being used by the other drive, and if so remove it in order so it can be swapped { - const char* pszOtherPathname = DiskGetFullPathName(!iDrive); + const char* pszOtherPathname = DiskGetFullPathName(!drive); char szCurrentPathname[MAX_PATH]; DWORD uNameLen = GetFullPathName(pszImageFilename, MAX_PATH, szCurrentPathname, NULL); @@ -572,7 +572,7 @@ ImageError_e DiskIIInterfaceCard::InsertDisk(const int iDrive, LPCTSTR pszImageF if (!strcmp(pszOtherPathname, szCurrentPathname)) { - EjectDisk(!iDrive); + EjectDisk(!drive); FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); } } @@ -591,7 +591,7 @@ ImageError_e DiskIIInterfaceCard::InsertDisk(const int iDrive, LPCTSTR pszImageF int nRes = MessageBox(g_hFrameWindow, szText, TEXT("Multi-Zip Warning"), MB_ICONWARNING | MB_YESNO | MB_SETFOREGROUND); if (nRes == IDNO) { - RemoveDisk(iDrive); + RemoveDisk(drive); Error = eIMAGE_ERROR_REJECTED_MULTI_ZIP; } } @@ -606,7 +606,7 @@ ImageError_e DiskIIInterfaceCard::InsertDisk(const int iDrive, LPCTSTR pszImageF Video_ResetScreenshotCounter(NULL); } - SaveLastDiskImage(iDrive); + SaveLastDiskImage(drive); return Error; } @@ -625,7 +625,7 @@ BOOL DiskIIInterfaceCard::IsSpinning(void) //=========================================================================== -void DiskIIInterfaceCard::NotifyInvalidImage(const int iDrive, LPCTSTR pszImageFilename, const ImageError_e Error) +void DiskIIInterfaceCard::NotifyInvalidImage(const int drive, LPCTSTR pszImageFilename, const ImageError_e Error) { TCHAR szBuffer[MAX_PATH+128]; szBuffer[sizeof(szBuffer)-1] = 0; @@ -687,7 +687,7 @@ void DiskIIInterfaceCard::NotifyInvalidImage(const int iDrive, LPCTSTR pszImageF TEXT("first file (%s) in this multi-zip archive is not recognized.\n") TEXT("Try unzipping and using the disk images directly.\n"), pszImageFilename, - m_floppyDrive[iDrive].disk.strFilenameInZip.c_str()); + m_floppyDrive[drive].disk.strFilenameInZip.c_str()); break; case eIMAGE_ERROR_GZ: @@ -738,11 +738,11 @@ void DiskIIInterfaceCard::NotifyInvalidImage(const int iDrive, LPCTSTR pszImageF //=========================================================================== -bool DiskIIInterfaceCard::GetProtect(const int iDrive) +bool DiskIIInterfaceCard::GetProtect(const int drive) { - if (IsDriveValid(iDrive)) + if (IsDriveValid(drive)) { - if (m_floppyDrive[iDrive].disk.bWriteProtected) + if (m_floppyDrive[drive].disk.bWriteProtected) return true; } @@ -751,32 +751,32 @@ bool DiskIIInterfaceCard::GetProtect(const int iDrive) //=========================================================================== -void DiskIIInterfaceCard::SetProtect(const int iDrive, const bool bWriteProtect) +void DiskIIInterfaceCard::SetProtect(const int drive, const bool bWriteProtect) { - if (IsDriveValid( iDrive )) + if (IsDriveValid( drive )) { - m_floppyDrive[iDrive].disk.bWriteProtected = bWriteProtect; + m_floppyDrive[drive].disk.bWriteProtected = bWriteProtect; } } //=========================================================================== -bool DiskIIInterfaceCard::IsDiskImageWriteProtected(const int iDrive) +bool DiskIIInterfaceCard::IsDiskImageWriteProtected(const int drive) { - if (!IsDriveValid(iDrive)) + if (!IsDriveValid(drive)) return true; - return ImageIsWriteProtected(m_floppyDrive[iDrive].disk.imagehandle); + return ImageIsWriteProtected(m_floppyDrive[drive].disk.imagehandle); } //=========================================================================== -bool DiskIIInterfaceCard::IsDriveEmpty(const int iDrive) +bool DiskIIInterfaceCard::IsDriveEmpty(const int drive) { - if (!IsDriveValid(iDrive)) + if (!IsDriveValid(drive)) return true; - return m_floppyDrive[iDrive].disk.imagehandle == NULL; + return m_floppyDrive[drive].disk.imagehandle == NULL; } //=========================================================================== @@ -954,7 +954,7 @@ void DiskIIInterfaceCard::Reset(const bool bIsPowerCycle/*=false*/) //=========================================================================== -bool DiskIIInterfaceCard::UserSelectNewDiskImage(const int iDrive, LPCSTR pszFilename/*=""*/) +bool DiskIIInterfaceCard::UserSelectNewDiskImage(const int drive, LPCSTR pszFilename/*=""*/) { TCHAR directory[MAX_PATH] = TEXT(""); TCHAR filename[MAX_PATH] = TEXT(""); @@ -964,7 +964,7 @@ bool DiskIIInterfaceCard::UserSelectNewDiskImage(const int iDrive, LPCSTR pszFil RegLoadString(TEXT(REG_PREFS), REGVALUE_PREF_START_DIR, 1, directory, MAX_PATH); _tcscpy(title, TEXT("Select Disk Image For Drive ")); - _tcscat(title, iDrive ? TEXT("2") : TEXT("1")); + _tcscat(title, drive ? TEXT("2") : TEXT("1")); _ASSERT(sizeof(OPENFILENAME) == sizeof(OPENFILENAME_NT4)); // Required for Win98/ME support (selected by _WIN32_WINNT=0x0400 in stdafx.h) @@ -989,14 +989,14 @@ bool DiskIIInterfaceCard::UserSelectNewDiskImage(const int iDrive, LPCSTR pszFil if ((!ofn.nFileExtension) || !filename[ofn.nFileExtension]) _tcscat(filename,TEXT(".dsk")); - ImageError_e Error = InsertDisk(iDrive, filename, ofn.Flags & OFN_READONLY, IMAGE_CREATE); + ImageError_e Error = InsertDisk(drive, filename, ofn.Flags & OFN_READONLY, IMAGE_CREATE); if (Error == eIMAGE_ERROR_NONE) { bRes = true; } else { - NotifyInvalidImage(iDrive, filename, Error); + NotifyInvalidImage(drive, filename, Error); } } diff --git a/source/Disk.h b/source/Disk.h index 36e1e1bd..9add6853 100644 --- a/source/Disk.h +++ b/source/Disk.h @@ -112,30 +112,30 @@ public: void Destroy(void); // no, doesn't "destroy" the disk image. DiskIIManagerShutdown() void Boot(void); - void FlushCurrentTrack(const int iDrive); + void FlushCurrentTrack(const int drive); - LPCTSTR GetDiskPathFilename(const int iDrive); - LPCTSTR GetFullDiskFilename(const int iDrive); - LPCTSTR GetFullName(const int iDrive); - LPCTSTR GetBaseName(const int iDrive); + LPCTSTR GetDiskPathFilename(const int drive); + LPCTSTR GetFullDiskFilename(const int drive); + LPCTSTR GetFullName(const int drive); + LPCTSTR GetBaseName(const int drive); void GetLightStatus (Disk_Status_e* pDisk1Status, Disk_Status_e* pDisk2Status); - ImageError_e InsertDisk(const int iDrive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary); - void EjectDisk(const int iDrive); + ImageError_e InsertDisk(const int drive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary); + void EjectDisk(const int drive); bool IsConditionForFullSpeed(void); BOOL IsSpinning(void); - void NotifyInvalidImage(const int iDrive, LPCTSTR pszImageFilename, const ImageError_e Error); + void NotifyInvalidImage(const int drive, LPCTSTR pszImageFilename, const ImageError_e Error); void Reset(const bool bIsPowerCycle=false); - bool GetProtect(const int iDrive); - void SetProtect(const int iDrive, const bool bWriteProtect); + bool GetProtect(const int drive); + void SetProtect(const int drive, const bool bWriteProtect); int GetCurrentDrive(void); int GetCurrentTrack(); int GetTrack(const int drive); int GetCurrentPhase(void); int GetCurrentOffset(void); LPCTSTR GetCurrentState(void); - bool UserSelectNewDiskImage(const int iDrive, LPCSTR pszFilename=""); + bool UserSelectNewDiskImage(const int drive, LPCSTR pszFilename=""); void UpdateDriveState(DWORD); bool DriveSwap(void); @@ -143,11 +143,11 @@ public: void SaveSnapshot(class YamlSaveHelper& yamlSaveHelper); bool LoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version); - void LoadLastDiskImage(const int iDrive); - void SaveLastDiskImage(const int iDrive); + void LoadLastDiskImage(const int drive); + void SaveLastDiskImage(const int drive); - bool IsDiskImageWriteProtected(const int iDrive); - bool IsDriveEmpty(const int iDrive); + bool IsDiskImageWriteProtected(const int drive); + bool IsDriveEmpty(const int drive); bool GetEnhanceDisk(void); void SetEnhanceDisk(bool bEnhanceDisk); @@ -157,13 +157,13 @@ public: private: void CheckSpinning(const ULONG nExecutedCycles); - Disk_Status_e GetDriveLightStatus(const int iDrive); - bool IsDriveValid(const int iDrive); - void AllocTrack(const int iDrive); - void ReadTrack(const int iDrive); - void RemoveDisk(const int iDrive); - void WriteTrack(const int iDrive); - LPCTSTR DiskGetFullPathName(const int iDrive); + Disk_Status_e GetDriveLightStatus(const int drive); + bool IsDriveValid(const int drive); + void AllocTrack(const int drive); + void ReadTrack(const int drive); + void RemoveDisk(const int drive); + void WriteTrack(const int drive); + LPCTSTR DiskGetFullPathName(const int drive); void SaveSnapshotDisk2Unit(YamlSaveHelper& yamlSaveHelper, UINT unit); void LoadSnapshotDriveUnit(YamlLoadHelper& yamlLoadHelper, UINT unit); From aa1e4cab09b4e9d8685e1e733a41d274a7e0554f Mon Sep 17 00:00:00 2001 From: tomcw Date: Tue, 9 Apr 2019 18:13:05 +0100 Subject: [PATCH 6/7] Remove redundant Initialize() --- source/Applewin.cpp | 3 --- source/Disk.cpp | 9 --------- source/Disk.h | 3 +-- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/source/Applewin.cpp b/source/Applewin.cpp index d8b042c6..aefa30a7 100644 --- a/source/Applewin.cpp +++ b/source/Applewin.cpp @@ -1522,9 +1522,6 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) ImageInitialize(); LogFileOutput("Init: ImageInitialize()\n"); - sg_DiskIICard.Initialize(); - LogFileOutput("Init: DiskInitialize()\n"); - // do diff --git a/source/Disk.cpp b/source/Disk.cpp index d2ed3527..611af8b7 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -528,15 +528,6 @@ void DiskIIInterfaceCard::GetLightStatus(Disk_Status_e *pDisk1Status, Disk_Statu //=========================================================================== -void DiskIIInterfaceCard::Initialize(void) -{ - int loop = NUM_DRIVES; - while (loop--) - m_floppyDrive[loop].clear(); -} - -//=========================================================================== - ImageError_e DiskIIInterfaceCard::InsertDisk(const int drive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary) { Drive_t* pDrive = &m_floppyDrive[drive]; diff --git a/source/Disk.h b/source/Disk.h index 9add6853..54579dd8 100644 --- a/source/Disk.h +++ b/source/Disk.h @@ -107,7 +107,6 @@ public: DiskIIInterfaceCard(void); virtual ~DiskIIInterfaceCard(void){}; - void Initialize(void); // 2x Initialize() funcs! void Initialize(LPBYTE pCxRomPeripheral, UINT uSlot); void Destroy(void); // no, doesn't "destroy" the disk image. DiskIIManagerShutdown() @@ -136,7 +135,7 @@ public: int GetCurrentOffset(void); LPCTSTR GetCurrentState(void); bool UserSelectNewDiskImage(const int drive, LPCSTR pszFilename=""); - void UpdateDriveState(DWORD); + void UpdateDriveState(DWORD cycles); bool DriveSwap(void); std::string GetSnapshotCardName(void); From 249b15b02d2744a61d36a1a630fe80015f87bfec Mon Sep 17 00:00:00 2001 From: tomcw Date: Tue, 9 Apr 2019 19:29:58 +0100 Subject: [PATCH 7/7] Get rid of duplicate func --- source/Disk.cpp | 24 ++++++++++-------------- source/Disk.h | 1 - source/Frame.cpp | 2 +- source/Memory.cpp | 9 +++++++++ 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/source/Disk.cpp b/source/Disk.cpp index 611af8b7..87d43948 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -78,11 +78,6 @@ int DiskIIInterfaceCard::GetCurrentPhase(void) { return m_floppyDrive[m_currDri int DiskIIInterfaceCard::GetCurrentOffset(void) { return m_floppyDrive[m_currDrive].disk.byte; } int DiskIIInterfaceCard::GetTrack(const int drive) { return m_floppyDrive[drive].track; } -LPCTSTR DiskIIInterfaceCard::GetDiskPathFilename(const int drive) -{ - return m_floppyDrive[drive].disk.fullname; -} - LPCTSTR DiskIIInterfaceCard::GetCurrentState(void) { if (m_floppyDrive[m_currDrive].disk.imagehandle == NULL) @@ -487,13 +482,6 @@ void DiskIIInterfaceCard::EjectDisk(const int drive) //=========================================================================== -// Return the file or zip name -// . Used by Property Sheet Page (Disk) -LPCTSTR DiskIIInterfaceCard::GetFullName(const int drive) -{ - return m_floppyDrive[drive].disk.fullname; -} - // Return the filename // . Used by Drive Buttons' tooltips LPCTSTR DiskIIInterfaceCard::GetFullDiskFilename(const int drive) @@ -504,9 +492,11 @@ LPCTSTR DiskIIInterfaceCard::GetFullDiskFilename(const int drive) return GetFullName(drive); } -LPCTSTR DiskIIInterfaceCard::DiskGetFullPathName(const int drive) +// Return the file or zip name +// . Used by Property Sheet Page (Disk) +LPCTSTR DiskIIInterfaceCard::GetFullName(const int drive) { - return ImageGetPathname(m_floppyDrive[drive].disk.imagehandle); + return m_floppyDrive[drive].disk.fullname; } // Return the imagename @@ -515,6 +505,12 @@ LPCTSTR DiskIIInterfaceCard::GetBaseName(const int drive) { return m_floppyDrive[drive].disk.imagename; } + +LPCTSTR DiskIIInterfaceCard::DiskGetFullPathName(const int drive) +{ + return ImageGetPathname(m_floppyDrive[drive].disk.imagehandle); +} + //=========================================================================== void DiskIIInterfaceCard::GetLightStatus(Disk_Status_e *pDisk1Status, Disk_Status_e *pDisk2Status) diff --git a/source/Disk.h b/source/Disk.h index 54579dd8..c9e01536 100644 --- a/source/Disk.h +++ b/source/Disk.h @@ -113,7 +113,6 @@ public: void Boot(void); void FlushCurrentTrack(const int drive); - LPCTSTR GetDiskPathFilename(const int drive); LPCTSTR GetFullDiskFilename(const int drive); LPCTSTR GetFullName(const int drive); LPCTSTR GetBaseName(const int drive); diff --git a/source/Frame.cpp b/source/Frame.cpp index 86f5d030..5a0c1808 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -2057,7 +2057,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) //TODO: A directory is open if an empty path to CiderPress is set. This has to be fixed. std::string filename1= "\""; - filename1.append( sg_DiskIICard.GetDiskPathFilename(iDrive) ); + filename1.append( sg_DiskIICard.GetFullName(iDrive) ); filename1.append("\""); std::string sFileNameEmpty = "\""; sFileNameEmpty.append("\""); diff --git a/source/Memory.cpp b/source/Memory.cpp index 406fadfd..fcd946cf 100644 --- a/source/Memory.cpp +++ b/source/Memory.cpp @@ -1692,6 +1692,15 @@ void MemInitializeIO(void) ConfigureSAM(pCxRomPeripheral, 5); // $C500 : Z80 card } +#if 0 // debug test + if (g_Slot5 == CT_EMPTY) + { + DiskIIInterfaceCard* pDiskIISlot5 = new DiskIIInterfaceCard; + pDiskIISlot5->Initialize(pCxRomPeripheral, 5); + pDiskIISlot5->InsertDisk(0, "C:\\Work\\Personal\\Images\\lady tut PRODOS (san inc pack).dsk", false, false); + } +#endif + sg_DiskIICard.Initialize(pCxRomPeripheral, 6); // $C600 : Disk][ card HD_Load_Rom(pCxRomPeripheral, 7); // $C700 : HDD f/w