From 1b80c7bf16ca4f450b9c16e358949e481d3c6d3c Mon Sep 17 00:00:00 2001 From: tomcw Date: Mon, 6 Jun 2022 19:40:10 +0100 Subject: [PATCH] Debugger: change search path for DebuggerAutoRun.txt . try CurrentDir first, only if this fails then try AppleWin's ProgramDir. Also: defer DebugInitialize() until later so it can take advantage of -current-dir command line switch. --- source/Debugger/Debug.cpp | 20 +++++++++++++++++++- source/Windows/AppleWin.cpp | 7 ++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index 36c0886c..ef3b43df 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -354,6 +354,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA static WORD g_LBR = 0x0000; // Last Branch Record + static bool g_bScriptReadOk = false; + // Private ________________________________________________________________________________________ @@ -6077,6 +6079,8 @@ _Help: //=========================================================================== Update_t CmdOutputRun (int nArgs) { + g_bScriptReadOk = false; + if (! nArgs) return Help_Arg_1( CMD_OUTPUT_RUN ); @@ -6114,6 +6118,8 @@ Update_t CmdOutputRun (int nArgs) if (script.Read( sFileName )) { + g_bScriptReadOk = true; + int nLine = script.GetNumLines(); Update_t bUpdateDisplay = UPDATE_NOTHING; @@ -8665,9 +8671,21 @@ void DebugInitialize () if (!doneAutoRun) // Don't re-run on a VM restart { doneAutoRun = true; - std::string pathname = g_sProgramDir + "DebuggerAutoRun.txt"; + + const std::string debuggerAutoRunName = "DebuggerAutoRun.txt"; + + // Look in g_sCurrentDir, otherwise try g_sProgramDir + + std::string pathname = g_sCurrentDir + debuggerAutoRunName; strncpy_s(g_aArgs[1].sArg, MAX_ARG_LEN, pathname.c_str(), _TRUNCATE); CmdOutputRun(1); + + if (!g_bScriptReadOk) + { + pathname = g_sProgramDir + debuggerAutoRunName; + strncpy_s(g_aArgs[1].sArg, MAX_ARG_LEN, pathname.c_str(), _TRUNCATE); + CmdOutputRun(1); + } } CmdMOTD(0); diff --git a/source/Windows/AppleWin.cpp b/source/Windows/AppleWin.cpp index ec19a418..2198f4b4 100644 --- a/source/Windows/AppleWin.cpp +++ b/source/Windows/AppleWin.cpp @@ -728,9 +728,6 @@ static void RepeatInitialization(void) // Reapply after a restart - TODO: grey-out the Config UI for "Swap 0/1" when this cmd line is passed in } - DebugInitialize(); - LogFileOutput("Main: DebugInitialize()\n"); - JoyInitialize(); LogFileOutput("Main: JoyInitialize()\n"); @@ -836,6 +833,10 @@ static void RepeatInitialization(void) if (g_cmdLine.bRemoveNoSlotClock) MemRemoveNoSlotClock(); + // Call DebugInitialize() after SetCurrentImageDir() + DebugInitialize(); + LogFileOutput("Main: DebugInitialize()\n"); + MemInitialize(); LogFileOutput("Main: MemInitialize()\n");