From 5505ff696fb0aefbe9e4cac6849900355ef8a5b2 Mon Sep 17 00:00:00 2001 From: tomcw Date: Sun, 3 Dec 2017 21:05:05 +0000 Subject: [PATCH] HDD error wasn't cleared on a reset or power-cycle - fixes #515 --- source/Applewin.cpp | 4 +++- source/Disk.cpp | 3 --- source/Frame.cpp | 7 +++++-- source/Harddisk.cpp | 9 +++++++++ source/Harddisk.h | 1 + source/SaveState.cpp | 2 ++ 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/source/Applewin.cpp b/source/Applewin.cpp index 36e2c8d1..1668b8fd 100644 --- a/source/Applewin.cpp +++ b/source/Applewin.cpp @@ -1270,6 +1270,8 @@ 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 LogFileOutput("Main: DiskReset()\n"); + HD_Reset(); // GH#515 + LogFileOutput("Main: HDDReset()\n"); if (!bSysClkOK) { @@ -1365,7 +1367,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) LogFileOutput("Main: MB_Reset()\n"); sg_Mouse.Uninitialize(); // Maybe restarting due to switching slot-4 card from MouseCard to Mockingboard - sg_Mouse.Reset(); + sg_Mouse.Reset(); // Deassert any pending IRQs - GH#514 LogFileOutput("Main: sg_Mouse.Uninitialize()\n"); DSUninit(); diff --git a/source/Disk.cpp b/source/Disk.cpp index c3751a65..c286bfe3 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -558,9 +558,6 @@ void DiskInitialize(void) int loop = NUM_DRIVES; while (loop--) ZeroMemory(&g_aFloppyDisk[loop], sizeof(Disk_t)); - - TCHAR imagefilename[MAX_PATH]; - _tcscpy(imagefilename,g_sProgramDir); } //=========================================================================== diff --git a/source/Frame.cpp b/source/Frame.cpp index 062c7ab7..6618a91f 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -2139,8 +2139,8 @@ void RelayEvent (UINT message, WPARAM wparam, LPARAM lparam) { // CtrlReset() vs ResetMachineState(): // . CPU: -// Ctrl+Reset : sp=-3 / CpuReset() -// Power cycle: sp=0x1ff / CpuInitialize() +// Ctrl+Reset : 6502.sp=-3 / CpuReset() +// Power cycle: 6502.sp=0x1ff / CpuInitialize() // . Disk][: // Ctrl+Reset : if motor-on, then motor-off but continue to spin for 1s // Power cycle: motor-off & immediately stop spinning @@ -2149,6 +2149,7 @@ void RelayEvent (UINT message, WPARAM wparam, LPARAM lparam) { void ResetMachineState () { DiskReset(true); + HD_Reset(); g_bFullSpeed = 0; // Might've hit reset in middle of InternalCpuExecute() - so beep may get (partially) muted MemReset(); // calls CpuInitialize() @@ -2182,11 +2183,13 @@ void CtrlReset() PravetsReset(); DiskReset(); + HD_Reset(); KeybReset(); if (!IS_APPLE2) // TODO: Why not for A][ & A][+ too? VideoResetState(); // Switch Alternate char set off sg_SSC.CommReset(); MB_Reset(); + sg_Mouse.Reset(); // Deassert any pending IRQs - GH#514 #ifdef USE_SPEECH_API g_Speech.Reset(); #endif diff --git a/source/Harddisk.cpp b/source/Harddisk.cpp index f17af3cd..7132dfe4 100644 --- a/source/Harddisk.cpp +++ b/source/Harddisk.cpp @@ -289,6 +289,15 @@ static LPCTSTR HD_DiskGetBaseName(const int iDrive) // Not used return g_HardDisk[iDrive].imagename; } + +//------------------------------------- + +void HD_Reset(void) +{ + g_HardDisk[HARDDISK_1].hd_error = 0; + g_HardDisk[HARDDISK_2].hd_error = 0; +} + //------------------------------------- void HD_Load_Rom(const LPBYTE pCxRomPeripheral, const UINT uSlot) diff --git a/source/Harddisk.h b/source/Harddisk.h index ca575e84..82a70ad7 100644 --- a/source/Harddisk.h +++ b/source/Harddisk.h @@ -35,6 +35,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA void HD_SetEnabled(const bool bEnabled); LPCTSTR HD_GetFullName(const int iDrive); LPCTSTR HD_GetFullPathName(const int iDrive); + void HD_Reset(void); void HD_Load_Rom(const LPBYTE pCxRomPeripheral, const UINT uSlot); bool HD_Select(const int iDrive); void HD_Unplug(const int iDrive); diff --git a/source/SaveState.cpp b/source/SaveState.cpp index 8fc17c0a..aa64fad9 100644 --- a/source/SaveState.cpp +++ b/source/SaveState.cpp @@ -171,6 +171,7 @@ static void Snapshot_LoadState_v1() // .aws v1.0.0.1, up to (and including) Appl // Reset all sub-systems MemReset(); DiskReset(); + HD_Reset(); KeybReset(); VideoResetState(); MB_Reset(); @@ -492,6 +493,7 @@ static void Snapshot_LoadState_v2(void) MemReset(); PravetsReset(); DiskReset(); + HD_Reset(); KeybReset(); VideoResetState(); MB_Reset();