From 0ecb4f5ae7d46fa2be2307018ecac0b8a453bd18 Mon Sep 17 00:00:00 2001 From: Markus Uhr Date: Tue, 14 Nov 2017 23:22:54 +0100 Subject: [PATCH] Add an 'exec'-prefix to snapshot name when saving from a script. Allow the user to specify an additional 'prefix' string in the exec command that will be prepended the ticks-part of the snapshot name when saving a snapshot from script. --- src/debugger/DebuggerParser.cxx | 19 ++++++++++++++----- src/debugger/DebuggerParser.hxx | 1 + src/debugger/gui/TiaOutputWidget.cxx | 10 +++++++--- src/debugger/gui/TiaOutputWidget.hxx | 4 ++-- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 61f08b884..1c68c4c38 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -59,7 +59,8 @@ DebuggerParser::DebuggerParser(Debugger& d, Settings& s) : debugger(d), settings(s), argCount(0), - execDepth(0) + execDepth(0), + execPrefix("") { } @@ -1063,11 +1064,19 @@ void DebuggerParser::executeExec() string file = argStrings[0]; if(file.find_last_of('.') == string::npos) file += ".script"; - FilesystemNode node(file); if (!node.exists()) { node = FilesystemNode(debugger.myOSystem.defaultSaveDir() + file); } + + if (argCount == 2) { + execPrefix = argStrings[1]; + } + else { + ostringstream prefix; + prefix << std::hex << std::setw(8) << std::setfill('0') << (debugger.myOSystem.getTicks()/1000 & 0xffffffff); + execPrefix = prefix.str(); + } execDepth++; commandResult << exec(node); execDepth--; @@ -1711,7 +1720,7 @@ void DebuggerParser::executeSaveses() // "savesnap" void DebuggerParser::executeSavesnap() { - debugger.tiaOutput().saveSnapshot(execDepth); + debugger.tiaOutput().saveSnapshot(execDepth, execPrefix); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2389,11 +2398,11 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = { { "exec", - "Execute script file ", + "Execute script file [prefix]", "Example: exec script.dat, exec auto.txt", true, true, - { kARG_FILE, kARG_END_ARGS }, + { kARG_FILE, kARG_LABEL, kARG_MULTI_BYTE }, std::mem_fn(&DebuggerParser::executeExec) }, diff --git a/src/debugger/DebuggerParser.hxx b/src/debugger/DebuggerParser.hxx index 6a1faf580..69926e544 100644 --- a/src/debugger/DebuggerParser.hxx +++ b/src/debugger/DebuggerParser.hxx @@ -124,6 +124,7 @@ class DebuggerParser uInt32 argCount; uInt32 execDepth; + string execPrefix; StringList myWatches; diff --git a/src/debugger/gui/TiaOutputWidget.cxx b/src/debugger/gui/TiaOutputWidget.cxx index 60fd21652..210988242 100644 --- a/src/debugger/gui/TiaOutputWidget.cxx +++ b/src/debugger/gui/TiaOutputWidget.cxx @@ -58,7 +58,7 @@ void TiaOutputWidget::loadConfig() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void TiaOutputWidget::saveSnapshot(int execDepth) +void TiaOutputWidget::saveSnapshot(int execDepth, const string& execPrefix) { if (execDepth > 0) { drawWidget(false); @@ -66,8 +66,12 @@ void TiaOutputWidget::saveSnapshot(int execDepth) int number = int(instance().getTicks() / 1000); ostringstream sspath; sspath << instance().snapshotSaveDir() - << instance().console().properties().get(Cartridge_Name) - << "_dbg_" << std::hex << std::setw(8) << std::setfill('0') << number << ".png"; + << instance().console().properties().get(Cartridge_Name); + sspath << "_dbg_"; + if (execDepth > 0 && !execPrefix.empty()) { + sspath << execPrefix << "_"; + } + sspath << std::hex << std::setw(8) << std::setfill('0') << (number/1000 & 0xffffffff) << ".png"; const uInt32 width = instance().console().tia().width(), height = instance().console().tia().height(); diff --git a/src/debugger/gui/TiaOutputWidget.hxx b/src/debugger/gui/TiaOutputWidget.hxx index 0b755c329..59a3c1843 100644 --- a/src/debugger/gui/TiaOutputWidget.hxx +++ b/src/debugger/gui/TiaOutputWidget.hxx @@ -36,8 +36,8 @@ class TiaOutputWidget : public Widget, public CommandSender void loadConfig() override; void setZoomWidget(TiaZoomWidget* w) { myZoom = w; } - void saveSnapshot() { saveSnapshot(0); }; - void saveSnapshot(int execDepth); + void saveSnapshot() { saveSnapshot(0, ""); }; + void saveSnapshot(int execDepth, const string& execPrefix); // Eventually, these methods will enable access to the onscreen TIA image // For example, clicking an area may cause an action