From 59772cda6bf78a0ea4495076410e0dd97f38512d Mon Sep 17 00:00:00 2001 From: Andrea Odetti Date: Sun, 29 Nov 2020 19:26:47 +0000 Subject: [PATCH 1/2] Move CtrlReset() and ResetMachineState() to Utilities.cpp. --- source/Interface.h | 1 + source/Utilities.cpp | 91 +++++++++++++++++++++++++++++++++++ source/Utilities.h | 3 ++ source/Windows/WinFrame.cpp | 95 ------------------------------------- 4 files changed, 95 insertions(+), 95 deletions(-) diff --git a/source/Interface.h b/source/Interface.h index 81bd52e8..fdaa5094 100644 --- a/source/Interface.h +++ b/source/Interface.h @@ -4,6 +4,7 @@ extern HINSTANCE g_hInstance; extern HWND g_hFrameWindow; extern BOOL g_bConfirmReboot; // saved PageConfig REGSAVE extern BOOL g_bMultiMon; +extern bool g_bFreshReset; void FrameDrawDiskLEDS(HDC hdc); void FrameDrawDiskStatus(HDC hdc); diff --git a/source/Utilities.cpp b/source/Utilities.cpp index 1e08af28..6ba4f4c5 100644 --- a/source/Utilities.cpp +++ b/source/Utilities.cpp @@ -42,12 +42,20 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "SaveState.h" #include "SerialComms.h" #include "Speaker.h" +#include "Memory.h" +#include "Pravets.h" +#include "Keyboard.h" #include "Mockingboard.h" #include "Interface.h" +#include "SoundCore.h" #include "Configuration/IPropertySheet.h" #include "Tfe/Tfe.h" +#ifdef USE_SPEECH_API +#include "Speech.h" +#endif + // Backwards compatibility with AppleWin <1.24.0 static void LoadConfigOldJoystick_v1(const UINT uJoyNum) { @@ -499,3 +507,86 @@ void GetAppleWindowTitle() case MODE_STEPPING: g_pAppTitle += std::string(TEXT(" [")) + TITLE_STEPPING + TEXT("]"); break; } } + +//=========================================================================== + +// CtrlReset() vs ResetMachineState(): +// . CPU: +// 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 + +// todo: consolidate CtrlReset() and ResetMachineState() +void ResetMachineState() +{ + GetCardMgr().GetDisk2CardMgr().Reset(true); + HD_Reset(); + g_bFullSpeed = 0; // Might've hit reset in middle of InternalCpuExecute() - so beep may get (partially) muted + + MemReset(); // calls CpuInitialize(), CNoSlotClock.Reset() + PravetsReset(); + if (GetCardMgr().QuerySlot(SLOT6) == CT_Disk2) + dynamic_cast(GetCardMgr().GetRef(SLOT6)).Boot(); + VideoResetState(); + KeybReset(); + if (GetCardMgr().IsSSCInstalled()) + GetCardMgr().GetSSC()->CommReset(); + PrintReset(); + JoyReset(); + MB_Reset(); + SpkrReset(); + if (GetCardMgr().IsMouseCardInstalled()) + GetCardMgr().GetMouseCard()->Reset(); + SetActiveCpu(GetMainCpu()); +#ifdef USE_SPEECH_API + g_Speech.Reset(); +#endif + + SoundCore_SetFade(FADE_NONE); + LogFileTimeUntilFirstKeyReadReset(); +} + + +//=========================================================================== + +/* + * In comments, UTAII is an abbreviation for a reference to "Understanding the Apple II" by James Sather + */ + + // todo: consolidate CtrlReset() and ResetMachineState() +void CtrlReset() +{ + if (!IS_APPLE2) + { + // For A][ & A][+, reset doesn't reset the LC switches (UTAII:5-29) + MemResetPaging(); + + // For A][ & A][+, reset doesn't reset the video mode (UTAII:4-4) + VideoResetState(); // Switch Alternate char set off + } + + if (IsAppleIIeOrAbove(GetApple2Type()) || IsCopamBase64A(GetApple2Type())) + { + // For A][ & A][+, reset doesn't reset the annunciators (UTAIIe:I-5) + // Base 64A: on RESET does reset to ROM page 0 (GH#807) + MemAnnunciatorReset(); + } + + PravetsReset(); + GetCardMgr().GetDisk2CardMgr().Reset(); + HD_Reset(); + KeybReset(); + if (GetCardMgr().IsSSCInstalled()) + GetCardMgr().GetSSC()->CommReset(); + MB_Reset(); + if (GetCardMgr().IsMouseCardInstalled()) + GetCardMgr().GetMouseCard()->Reset(); // Deassert any pending IRQs - GH#514 +#ifdef USE_SPEECH_API + g_Speech.Reset(); +#endif + + CpuReset(); + g_bFreshReset = true; +} diff --git a/source/Utilities.h b/source/Utilities.h index ba617c44..61eb7d4b 100644 --- a/source/Utilities.h +++ b/source/Utilities.h @@ -11,3 +11,6 @@ void InsertFloppyDisks(const UINT slot, LPSTR szImageName_drive[NUM_DRIVES], boo void InsertHardDisks(LPSTR szImageName_harddisk[NUM_HARDDISKS], bool& bBoot); void UnplugHardDiskControllerCard(void); void GetAppleWindowTitle(); + +void CtrlReset(); +void ResetMachineState(); diff --git a/source/Windows/WinFrame.cpp b/source/Windows/WinFrame.cpp index 126ee3ac..13a368b0 100644 --- a/source/Windows/WinFrame.cpp +++ b/source/Windows/WinFrame.cpp @@ -30,11 +30,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "Windows/WinFrame.h" #include "Windows/AppleWin.h" -#include "CardManager.h" -#include "CPU.h" -#include "Disk.h" -#include "DiskImage.h" -#include "Harddisk.h" #include "Keyboard.h" #include "Log.h" #include "Memory.h" @@ -43,7 +38,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "Windows/DirectInput.h" #include "NTSC.h" #include "ParallelPrinter.h" -#include "Pravets.h" #include "Registry.h" #include "SaveState.h" #include "SerialComms.h" @@ -51,11 +45,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "Speaker.h" #include "Frame.h" #include "Utilities.h" -#ifdef USE_SPEECH_API -#include "Speech.h" -#endif #include "Windows/WinVideo.h" - #include "../resource/resource.h" #include "Configuration/PropertySheet.h" #include "Debugger/Debug.h" @@ -150,7 +140,6 @@ void DrawStatusArea (HDC passdc, BOOL drawflags); static void ProcessButtonClick (int button, bool bFromButtonUI=false); void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive); void RelayEvent (UINT message, WPARAM wparam, LPARAM lparam); -void ResetMachineState (); void SetFullScreenMode (); void SetNormalMode (); static void SetUsingCursor(BOOL); @@ -2231,90 +2220,6 @@ void RelayEvent (UINT message, WPARAM wparam, LPARAM lparam) { SendMessage(tooltipwindow,TTM_RELAYEVENT,0,(LPARAM)&msg); } -//=========================================================================== - -// CtrlReset() vs ResetMachineState(): -// . CPU: -// 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 - -// todo: consolidate CtrlReset() and ResetMachineState() -void ResetMachineState () -{ - GetCardMgr().GetDisk2CardMgr().Reset(true); - HD_Reset(); - g_bFullSpeed = 0; // Might've hit reset in middle of InternalCpuExecute() - so beep may get (partially) muted - - MemReset(); // calls CpuInitialize(), CNoSlotClock.Reset() - PravetsReset(); - if (GetCardMgr().QuerySlot(SLOT6) == CT_Disk2) - dynamic_cast(GetCardMgr().GetRef(SLOT6)).Boot(); - VideoResetState(); - KeybReset(); - if (GetCardMgr().IsSSCInstalled()) - GetCardMgr().GetSSC()->CommReset(); - PrintReset(); - JoyReset(); - MB_Reset(); - SpkrReset(); - if (GetCardMgr().IsMouseCardInstalled()) - GetCardMgr().GetMouseCard()->Reset(); - SetActiveCpu( GetMainCpu() ); -#ifdef USE_SPEECH_API - g_Speech.Reset(); -#endif - - SoundCore_SetFade(FADE_NONE); - LogFileTimeUntilFirstKeyReadReset(); -} - - -//=========================================================================== - -/* - * In comments, UTAII is an abbreviation for a reference to "Understanding the Apple II" by James Sather - */ - -// todo: consolidate CtrlReset() and ResetMachineState() -// Ctrl+Reset - TODO: This is a terrible place for this code! Should be in AppleWin.cpp -void CtrlReset() -{ - if (!IS_APPLE2) - { - // For A][ & A][+, reset doesn't reset the LC switches (UTAII:5-29) - MemResetPaging(); - - // For A][ & A][+, reset doesn't reset the video mode (UTAII:4-4) - VideoResetState(); // Switch Alternate char set off - } - - if (IsAppleIIeOrAbove(GetApple2Type()) || IsCopamBase64A(GetApple2Type())) - { - // For A][ & A][+, reset doesn't reset the annunciators (UTAIIe:I-5) - // Base 64A: on RESET does reset to ROM page 0 (GH#807) - MemAnnunciatorReset(); - } - - PravetsReset(); - GetCardMgr().GetDisk2CardMgr().Reset(); - HD_Reset(); - KeybReset(); - if (GetCardMgr().IsSSCInstalled()) - GetCardMgr().GetSSC()->CommReset(); - MB_Reset(); - if (GetCardMgr().IsMouseCardInstalled()) - GetCardMgr().GetMouseCard()->Reset(); // Deassert any pending IRQs - GH#514 -#ifdef USE_SPEECH_API - g_Speech.Reset(); -#endif - - CpuReset(); - g_bFreshReset = true; -} - //=========================================================================== From f919a3ba6f2a0994f118fb4096579a743c90d6fb Mon Sep 17 00:00:00 2001 From: Andrea Odetti Date: Sun, 29 Nov 2020 19:27:11 +0000 Subject: [PATCH 2/2] Fix arguments of fwd declared function. --- source/Windows/WinFrame.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Windows/WinFrame.cpp b/source/Windows/WinFrame.cpp index 13a368b0..5922d61a 100644 --- a/source/Windows/WinFrame.cpp +++ b/source/Windows/WinFrame.cpp @@ -136,7 +136,7 @@ static UINT g_uCount100msec = 0; static bool g_bShowingCursor = true; static bool g_bLastCursorInAppleViewport = false; -void DrawStatusArea (HDC passdc, BOOL drawflags); +static void DrawStatusArea (HDC passdc, int drawflags); static void ProcessButtonClick (int button, bool bFromButtonUI=false); void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive); void RelayEvent (UINT message, WPARAM wparam, LPARAM lparam);