From a1e7323abb2c52ce689241545130bf59e30a81b7 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sat, 17 May 2025 23:29:40 +0200 Subject: [PATCH] fixed timer saving (fixes #1077) --- src/debugger/DebuggerParser.cxx | 44 +++++++++++++++++++++++++++++++++ src/debugger/DebuggerParser.hxx | 1 + 2 files changed, 45 insertions(+) diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index fe89a6419..8af2a295c 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -653,6 +653,48 @@ void DebuggerParser::printTimer(uInt32 idx, bool showHeader) } } +string DebuggerParser::getTimerCmds() +{ + ostringstream out; + + for(uInt32 idx = 0; idx < debugger.m6502().numTimers(); ++idx) + { + const TimerMap::Timer& timer = debugger.m6502().getTimer(idx); + const bool banked = debugger.cartDebug().romBankCount() > 1; + ostringstream fromBuf; + + if(!debugger.cartDebug().getLabel(fromBuf, timer.from.addr, true)) + fromBuf << Base::HEX4 << timer.from.addr; + fromBuf << (timer.mirrors ? "+" : ""); + + out << "timer " << fromBuf.str(); + + if(banked) { + if(timer.anyBank) + fromBuf << "*"; + else + fromBuf << dec << static_cast(timer.from.bank); + } + if(!timer.isPartial) { + ostringstream toBuf; + + if(!debugger.cartDebug().getLabel(toBuf, timer.to.addr, true)) + toBuf << Base::HEX4 << timer.to.addr; + toBuf << (timer.mirrors ? "+" : ""); + + if(banked) { + if(timer.anyBank) + toBuf << "*"; + else + toBuf << dec << static_cast(timer.to.bank); + } + out << " " << toBuf.str(); + } + out << "\n"; + } // for + return out.str(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DebuggerParser::listTimers() { @@ -768,6 +810,8 @@ string DebuggerParser::saveScriptFile(string file) out << '\n'; } + out << getTimerCmds(); + // Append 'script' extension when necessary if(file.find_last_of('.') == string::npos) file += ".script"; diff --git a/src/debugger/DebuggerParser.hxx b/src/debugger/DebuggerParser.hxx index 53fa47e13..1e9062290 100644 --- a/src/debugger/DebuggerParser.hxx +++ b/src/debugger/DebuggerParser.hxx @@ -146,6 +146,7 @@ class DebuggerParser void printTimer(uInt32 idx,bool showHeader = true); void listTimers(); + string getTimerCmds(); // output the error with the example provided for the command void outputCommandError(string_view errorMsg, int command);