diff --git a/source/frontends/ncurses/main.cpp b/source/frontends/ncurses/main.cpp index 3c6c64a0..6cd9a37f 100644 --- a/source/frontends/ncurses/main.cpp +++ b/source/frontends/ncurses/main.cpp @@ -144,7 +144,7 @@ namespace const DWORD uActualCyclesExecuted = CpuExecute(uCyclesToExecute, bVideoUpdate); g_dwCyclesThisFrame += uActualCyclesExecuted; - DiskUpdateDriveState(uActualCyclesExecuted); + sg_Disk2Card.UpdateDriveState(uActualCyclesExecuted); const int key = ProcessKeyboard(); @@ -180,7 +180,7 @@ namespace g_relativeSpeed = g_relativeSpeed * coeff + double(us) / double(nExecutionPeriodUsec) * (1.0 - coeff); - if (!DiskIsSpinning()) + if (!sg_Disk2Card.IsConditionForFullSpeed()) { if (us < nExecutionPeriodUsec) { @@ -224,7 +224,7 @@ namespace strPathName.append(fileName); } - ImageError_e Error = DiskInsert(nDrive, strPathName.c_str(), IMAGE_USE_FILES_WRITE_PROTECT_STATUS, createMissingDisk); + ImageError_e Error = sg_Disk2Card.InsertDisk(nDrive, strPathName.c_str(), IMAGE_USE_FILES_WRITE_PROTECT_STATUS, createMissingDisk); return Error == eIMAGE_ERROR_NONE; } @@ -247,7 +247,6 @@ namespace LogFileOutput("Initialisation\n"); ImageInitialize(); - DiskInitialize(); bool disksOk = true; if (!options.disk1.empty()) @@ -277,7 +276,7 @@ namespace MemInitialize(); VideoInitialize(); - DiskReset(); + sg_Disk2Card.Reset(); HD_Reset(); if (!options.snapshot.empty()) @@ -312,7 +311,7 @@ namespace PrintDestroy(); CpuDestroy(); - DiskDestroy(); + sg_Disk2Card.Destroy(); ImageDestroy(); fclose(g_fh); diff --git a/source/frontends/ncurses/world.cpp b/source/frontends/ncurses/world.cpp index 2f89baa0..cb9b288f 100644 --- a/source/frontends/ncurses/world.cpp +++ b/source/frontends/ncurses/world.cpp @@ -275,7 +275,7 @@ void FrameRefresh() void FrameDrawDiskLEDS(HDC x) { - DiskGetLightStatus(&g_eStatusDrive1, &g_eStatusDrive2); + sg_Disk2Card.GetLightStatus(&g_eStatusDrive1, &g_eStatusDrive2); FrameRefresh(); } @@ -290,10 +290,10 @@ void FrameDrawDiskStatus(HDC x) // Track $B7EC LC1 $D356 // Sector $B7ED LC1 $D357 // RWTS LC1 $D300 - int nActiveFloppy = DiskGetCurrentDrive(); + int nActiveFloppy = sg_Disk2Card.GetCurrentDrive(); - int nDisk1Track = DiskGetTrack(0); - int nDisk2Track = DiskGetTrack(1); + int nDisk1Track = sg_Disk2Card.GetTrack(0); + int nDisk2Track = sg_Disk2Card.GetTrack(1); // Probe known OS's for Track/Sector int isProDOS = mem[ 0xBF00 ] == 0x4C; diff --git a/source/frontends/qapple/configuration.cpp b/source/frontends/qapple/configuration.cpp index f6ed3430..5914a821 100644 --- a/source/frontends/qapple/configuration.cpp +++ b/source/frontends/qapple/configuration.cpp @@ -25,12 +25,12 @@ namespace { if (filename.isEmpty()) { - DiskEject(disk); + sg_Disk2Card.EjectDisk(disk); } else { const bool createMissingDisk = true; - const ImageError_e result = DiskInsert(disk, filename.toStdString().c_str(), IMAGE_USE_FILES_WRITE_PROTECT_STATUS, createMissingDisk); + const ImageError_e result = sg_Disk2Card.InsertDisk(disk, filename.toStdString().c_str(), IMAGE_USE_FILES_WRITE_PROTECT_STATUS, createMissingDisk); if (result != eIMAGE_ERROR_NONE) { const QString message = QString("Error [%1] inserting '%2'").arg(QString::number(result), filename); @@ -111,7 +111,7 @@ Preferences::Data getCurrentOptions(const std::shared_ptr & gamepad) currentOptions.disks.resize(diskIDs.size()); for (size_t i = 0; i < diskIDs.size(); ++i) { - const char * diskName = DiskGetFullName(diskIDs[i]); + const char * diskName = sg_Disk2Card.GetFullName(diskIDs[i]); if (diskName) { currentOptions.disks[i] = diskName; @@ -128,6 +128,7 @@ Preferences::Data getCurrentOptions(const std::shared_ptr & gamepad) } } + currentOptions.enhancedSpeed = sg_Disk2Card.GetEnhanceDisk(); currentOptions.languageCardInSlot0 = g_Slot0 == CT_LanguageCard; currentOptions.mouseInSlot4 = g_Slot4 == CT_MouseInterface; currentOptions.cpmInSlot5 = g_Slot5 == CT_Z80; @@ -202,6 +203,12 @@ void setNewOptions(const Preferences::Data & currentOptions, const Preferences:: } } + if (currentOptions.enhancedSpeed != newOptions.enhancedSpeed) + { + REGSAVE(TEXT(REGVALUE_ENHANCE_DISK_SPEED), newOptions.enhancedSpeed ? 1 : 0); + sg_Disk2Card.SetEnhanceDisk(newOptions.enhancedSpeed); + } + for (size_t i = 0; i < diskIDs.size(); ++i) { if (currentOptions.disks[i] != newOptions.disks[i]) diff --git a/source/frontends/qapple/preferences.cpp b/source/frontends/qapple/preferences.cpp index 90c2ea53..847d358f 100644 --- a/source/frontends/qapple/preferences.cpp +++ b/source/frontends/qapple/preferences.cpp @@ -168,6 +168,7 @@ void Preferences::setData(const Data & data) initialiseDisks(myDisks, data.disks); initialiseDisks(myHDs, data.hds); + enhanced_speed->setChecked(data.enhancedSpeed); apple2Type->setCurrentIndex(data.apple2Type); lc_0->setChecked(data.languageCardInSlot0); mouse_4->setChecked(data.mouseInSlot4); @@ -190,6 +191,7 @@ Preferences::Data Preferences::getData() const fillData(myDisks, data.disks); fillData(myHDs, data.hds); + data.enhancedSpeed = enhanced_speed->isChecked(); data.apple2Type = apple2Type->currentIndex(); data.languageCardInSlot0 = lc_0->isChecked(); data.mouseInSlot4 = mouse_4->isChecked(); diff --git a/source/frontends/qapple/preferences.h b/source/frontends/qapple/preferences.h index 1b5195ac..c3ebeefd 100644 --- a/source/frontends/qapple/preferences.h +++ b/source/frontends/qapple/preferences.h @@ -23,6 +23,8 @@ public: QString joystick; int joystickId; // only putput + bool enhancedSpeed; + std::vector disks; std::vector hds; diff --git a/source/frontends/qapple/preferences.ui b/source/frontends/qapple/preferences.ui index 04b8d744..284354f3 100644 --- a/source/frontends/qapple/preferences.ui +++ b/source/frontends/qapple/preferences.ui @@ -179,7 +179,7 @@ Disks - + @@ -189,21 +189,21 @@ - + HD 1 - + Disk 1 - + @@ -221,14 +221,14 @@ - + Disk 2 - + @@ -238,7 +238,7 @@ - + @@ -253,41 +253,48 @@ - + HD 2 - + Browse... - + Browse... - + Browse... - + Browse... + + + + Enhanced Speed + + + diff --git a/source/frontends/qapple/qapple.cpp b/source/frontends/qapple/qapple.cpp index 4abe5ac1..5de778b3 100644 --- a/source/frontends/qapple/qapple.cpp +++ b/source/frontends/qapple/qapple.cpp @@ -37,7 +37,6 @@ namespace LogFileOutput("Initialisation\n"); ImageInitialize(); - DiskInitialize(); } /* In AppleWin there are 3 ways to reset the emulator @@ -67,7 +66,7 @@ namespace } MemInitialize(); VideoInitialize(); - DiskReset(); + sg_Disk2Card.Reset(); HD_Reset(); } @@ -84,7 +83,7 @@ namespace PrintDestroy(); CpuDestroy(); - DiskDestroy(); + sg_Disk2Card.Destroy(); ImageDestroy(); fclose(g_fh); g_fh = NULL; @@ -229,6 +228,7 @@ void QApple::on_timer() { const DWORD uActualCyclesExecuted = CpuExecute(uCyclesToExecute, bVideoUpdate); g_dwCyclesThisFrame += uActualCyclesExecuted; + sg_Disk2Card.UpdateDriveState(uActualCyclesExecuted); if (g_dwCyclesThisFrame >= dwClksPerFrame) { g_dwCyclesThisFrame -= dwClksPerFrame; @@ -236,7 +236,7 @@ void QApple::on_timer() } ++count; } - while (DiskIsSpinning() && (myElapsedTimer.elapsed() < target + full_speed_ms)); + while (sg_Disk2Card.IsConditionForFullSpeed() && (myElapsedTimer.elapsed() < target + full_speed_ms)); if (count > 0) { @@ -414,5 +414,5 @@ void QApple::on_actionSwap_disks_triggered() PauseEmulator pause(this); // this might open a file dialog - DiskDriveSwap(); + sg_Disk2Card.DriveSwap(); } diff --git a/source/linux/benchmark.cpp b/source/linux/benchmark.cpp index 57cb7293..bf61e48c 100644 --- a/source/linux/benchmark.cpp +++ b/source/linux/benchmark.cpp @@ -152,7 +152,7 @@ void VideoBenchmark(std::function VideoRedrawScreen) while (cycles > 0) { DWORD executedcycles = CpuExecute(103, true); cycles -= executedcycles; - DiskUpdateDriveState(executedcycles); + sg_Disk2Card.UpdateDriveState(executedcycles); #if 0 JoyUpdateButtonLatch(executedcycles); #endif diff --git a/source/linux/data.cpp b/source/linux/data.cpp index eee6c9e4..34b1eeb4 100644 --- a/source/linux/data.cpp +++ b/source/linux/data.cpp @@ -38,6 +38,7 @@ const TCHAR *g_pAppTitle = TITLE_APPLE_2E_ENHANCED; bool g_bRestart = false; CSuperSerialCard sg_SSC; CMouseInterface sg_Mouse; +Disk2InterfaceCard sg_Disk2Card; const short SPKR_DATA_INIT = (short)0x8000; short g_nSpeakerData = SPKR_DATA_INIT; @@ -202,7 +203,7 @@ void LoadConfiguration(void) DWORD dwEnhanceDisk; REGLOAD(TEXT(REGVALUE_ENHANCE_DISK_SPEED), &dwEnhanceDisk); - Disk_SetEnhanceDisk(dwEnhanceDisk ? true : false); + sg_Disk2Card.SetEnhanceDisk(dwEnhanceDisk ? true : false); #if 0 Config_Load_Video(); @@ -293,8 +294,8 @@ void LoadConfiguration(void) GetCurrentDirectory(sizeof(szFilename), szFilename); SetCurrentImageDir(szFilename); - Disk_LoadLastDiskImage(DRIVE_1); - Disk_LoadLastDiskImage(DRIVE_2); + sg_Disk2Card.LoadLastDiskImage(DRIVE_1); + sg_Disk2Card.LoadLastDiskImage(DRIVE_2); //