From 124eca45462d9d3fbb365d319978e94c2f75d36f Mon Sep 17 00:00:00 2001 From: tomcw Date: Sat, 22 Apr 2017 20:42:42 +0100 Subject: [PATCH] Debugger: Allow MODE_DEBUG and MODE_STEPPING states to persist across an F2 ResetMachineState() call (#217) --- source/Applewin.cpp | 4 +++- source/Debugger/Debug.cpp | 16 +++++++++++----- source/Debugger/Debug.h | 2 +- source/Frame.cpp | 25 ++++++++++++------------- 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/source/Applewin.cpp b/source/Applewin.cpp index 6db6033b..72b7e0ab 100644 --- a/source/Applewin.cpp +++ b/source/Applewin.cpp @@ -432,7 +432,9 @@ void EnterMessageLoop(void) { if (g_nAppMode == MODE_DEBUG) DebuggerUpdate(); - else if ((g_nAppMode == MODE_LOGO) || (g_nAppMode == MODE_PAUSED)) + else if (g_nAppMode == MODE_PAUSED) + Sleep(1); // Stop process hogging CPU - 1ms, as need to fade-out speaker sound buffer + else if (g_nAppMode == MODE_LOGO) Sleep(100); // Stop process hogging CPU } } diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index a6ee7fd2..d52222d7 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -4845,7 +4845,7 @@ size_t Util_GetDebuggerText( char* &pText_ ) memset( pBeg, 0, sizeof( g_aTextScreen ) ); memset( g_aDebuggerVirtualTextScreen, 0, sizeof( g_aDebuggerVirtualTextScreen ) ); - DebugDisplay(1); + DebugDisplay(TRUE); for( int y = 0; y < DEBUG_VIRTUAL_TEXT_HEIGHT; y++ ) { @@ -8393,6 +8393,11 @@ bool ProfileSave() } +static void InitDisasm(void) +{ + g_nDisasmCurAddress = regs.pc; + DisasmCalcTopBotAddress(); +} // _____________________________________________________________________________________ // | | @@ -8423,11 +8428,9 @@ void DebugBegin () g_aOpmodes[ AM_3 ].m_nBytes = 3; } - g_nDisasmCurAddress = regs.pc; - DisasmCalcTopBotAddress(); + InitDisasm(); DebugVideoMode::Instance().Reset(); - UpdateDisplay( UPDATE_ALL ); #if DEBUG_APPLE_FONT @@ -9576,13 +9579,16 @@ void DebuggerProcessKey( int keycode ) } // Still called from external file -void DebugDisplay( BOOL bDrawBackground ) +void DebugDisplay( BOOL bDrawBackground, BOOL bInitDisasm/*=FALSE*/ ) { Update_t bUpdateFlags = UPDATE_ALL; // if (! bDrawBackground) // bUpdateFlags &= ~UPDATE_BACKGROUND; + if (bInitDisasm) + InitDisasm(); + UpdateDisplay( bUpdateFlags ); } diff --git a/source/Debugger/Debug.h b/source/Debugger/Debug.h index 05f011d5..0bffd132 100644 --- a/source/Debugger/Debug.h +++ b/source/Debugger/Debug.h @@ -168,7 +168,7 @@ void DebugContinueStepping (); void DebugStopStepping(void); void DebugDestroy (); - void DebugDisplay (BOOL); + void DebugDisplay (BOOL bDrawBackground, BOOL bInitDisasm = FALSE ); void DebugInitialize (); void DebuggerInputConsoleChar( TCHAR ch ); diff --git a/source/Frame.cpp b/source/Frame.cpp index 086ac05c..ebcae331 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -625,7 +625,7 @@ static void DrawFrameWindow () if (g_nAppMode == MODE_LOGO) VideoDisplayLogo(); else if (g_nAppMode == MODE_DEBUG) - DebugDisplay(1); + DebugDisplay(TRUE); else VideoRedrawScreen(); @@ -1841,6 +1841,8 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) if( g_bCtrlKey ) { CtrlReset(); + if (g_nAppMode == MODE_DEBUG) + DebugDisplay(TRUE, TRUE); return; } @@ -1850,22 +1852,19 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) LogFileTimeUntilFirstKeyReadReset(); g_nAppMode = MODE_RUNNING; } - else if (g_nAppMode == MODE_RUNNING) + else if ((g_nAppMode == MODE_RUNNING) || (g_nAppMode == MODE_DEBUG) || (g_nAppMode == MODE_STEPPING) || (g_nAppMode == MODE_PAUSED)) { if (ConfirmReboot(bFromButtonUI)) { ResetMachineState(); - g_nAppMode = MODE_RUNNING; - } - } - else if ((g_nAppMode == MODE_DEBUG) || (g_nAppMode == MODE_STEPPING)) // exit debugger - { - if (ConfirmReboot(bFromButtonUI)) - { - DebugExitDebugger(); - // Post: g_nAppMode = MODE_RUNNING or MODE_STEPPING + + // NB. Don't exit debugger or stepping + + if (g_nAppMode == MODE_DEBUG) + DebugDisplay(TRUE, TRUE); } } + DrawStatusArea((HDC)0,DRAW_TITLE); VideoRedrawScreen(); break; @@ -1902,9 +1901,9 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) } else if (g_nAppMode == MODE_DEBUG) { - ProcessButtonClick(BTN_RUN); // Exit debugger, switch to MODE_RUNNING or MODE_STEPPING + DebugExitDebugger(); // Exit debugger, switch to MODE_RUNNING or MODE_STEPPING } - else + else // MODE_RUNNING, MODE_LOGO, MODE_PAUSED { DebugBegin(); }