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.
This commit is contained in:
tomcw 2022-06-06 19:40:10 +01:00
parent cd0fdf15ff
commit 1b80c7bf16
2 changed files with 23 additions and 4 deletions

View File

@ -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);

View File

@ -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");