From 8fce7a8753865e27f7068023218b402e42bb84d8 Mon Sep 17 00:00:00 2001 From: tomcw Date: Fri, 11 Aug 2017 21:45:07 +0100 Subject: [PATCH] Debugger: F2 or Ctrl+F2 whilst debugger will immediately stop the drive spinning (allowing disk swap) (fixed #460) --- source/Disk.cpp | 14 ++++++++++++-- source/Disk.h | 2 +- source/Frame.cpp | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/source/Disk.cpp b/source/Disk.cpp index 4a5f2983..c2f0cb23 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -811,12 +811,12 @@ static void __stdcall DiskReadWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULO // https://github.com/AppleWin/AppleWin/issues/201 // NB. Prevent flooding of forcing UI to redraw!!! if( ((fptr->byte) & 0xFF) == 0 ) - FrameDrawDiskStatus( (HDC)0 ); + FrameDrawDiskStatus( (HDC)0 ); } //=========================================================================== -void DiskReset(void) +void DiskReset(const bool bIsPowerCycle/*=false*/) { // RESET forces all switches off (UTAIIe Table 9.1) currdrive = 0; @@ -824,6 +824,16 @@ void DiskReset(void) floppyloadmode = 0; floppywritemode = 0; phases = 0; + + if (bIsPowerCycle) // GH#460 - Ctrl+Reset whilst debugging acts like a power-cycle + { + g_aFloppyDisk[DRIVE_1].spinning = 0; + g_aFloppyDisk[DRIVE_1].writelight = 0; + g_aFloppyDisk[DRIVE_2].spinning = 0; + g_aFloppyDisk[DRIVE_2].writelight = 0; + + FrameRefreshStatus(DRAW_LEDS,false); + } } //=========================================================================== diff --git a/source/Disk.h b/source/Disk.h index 2e0d2a3a..95d8f7e2 100644 --- a/source/Disk.h +++ b/source/Disk.h @@ -57,7 +57,7 @@ void DiskGetLightStatus (Disk_Status_e *pDisk1Status_, Disk_Status_e *pDisk2S ImageError_e DiskInsert(const int iDrive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary); BOOL DiskIsSpinning(void); void DiskNotifyInvalidImage(const int iDrive, LPCTSTR pszImageFilename, const ImageError_e Error); -void DiskReset(void); +void DiskReset(const bool bIsPowerCycle=false); bool DiskGetProtect(const int iDrive); void DiskSetProtect(const int iDrive, const bool bWriteProtect); int DiskGetCurrentDrive(); diff --git a/source/Frame.cpp b/source/Frame.cpp index 694accf3..807bbc54 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -2036,7 +2036,7 @@ void RelayEvent (UINT message, WPARAM wparam, LPARAM lparam) { // todo: consolidate CtrlReset() and ResetMachineState() void ResetMachineState () { - DiskReset(); // Set floppymotoron=0 + DiskReset(true); // Set floppymotoron=0 g_bFullSpeed = 0; // Might've hit reset in middle of InternalCpuExecute() - so beep may get (partially) muted MemReset(); @@ -2069,7 +2069,7 @@ void CtrlReset() MemResetPaging(); PravetsReset(); - DiskReset(); + DiskReset(g_nAppMode == MODE_DEBUG); // For MODE_DEBUG act like a power-cycle (GH#460) KeybReset(); if (!IS_APPLE2) // TODO: Why not for A][ & A][+ too? VideoResetState(); // Switch Alternate char set off