diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 94ef3d9a4..6c73d713e 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -2063,7 +2063,7 @@ void DebuggerParser::executeSaveSes() // "saveSnap" void DebuggerParser::executeSaveSnap() { - debugger.tiaOutput().saveSnapshot(execDepth, execPrefix); + debugger.tiaOutput().saveSnapshot(execDepth, execPrefix, argCount == 0); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/TiaOutputWidget.cxx b/src/debugger/gui/TiaOutputWidget.cxx index 4c1144914..553041465 100644 --- a/src/debugger/gui/TiaOutputWidget.cxx +++ b/src/debugger/gui/TiaOutputWidget.cxx @@ -63,7 +63,8 @@ void TiaOutputWidget::loadConfig() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void TiaOutputWidget::saveSnapshot(int execDepth, const string& execPrefix) +void TiaOutputWidget::saveSnapshot(int execDepth, const string& execPrefix, + bool mark) { #ifdef IMAGE_SUPPORT if(execDepth > 0) @@ -72,12 +73,39 @@ void TiaOutputWidget::saveSnapshot(int execDepth, const string& execPrefix) ostringstream sspath; sspath << instance().snapshotSaveDir() << instance().console().properties().get(PropType::Cart_Name); - sspath << "_dbg_"; - if (execDepth > 0 && !execPrefix.empty()) { - sspath << execPrefix << "_"; + + if(mark) + { + sspath << "_dbg_"; + if(execDepth > 0 && !execPrefix.empty()) { + sspath << execPrefix << "_"; + } + sspath << std::hex << std::setw(8) << std::setfill('0') + << static_cast(TimerManager::getTicks() / 1000); } - sspath << std::hex << std::setw(8) << std::setfill('0') - << static_cast(TimerManager::getTicks()/1000) << ".png"; + else + { + // Determine if the file already exists, checking each successive filename + // until one doesn't exist + FSNode node(sspath.str() + ".png"); + if(node.exists()) + { + ostringstream suffix; + ostringstream buf; + for(uInt32 i = 1; ; ++i) + { + buf.str(""); + suffix.str(""); + suffix << "_" << i; + buf << sspath.str() << suffix.str() << ".png"; + FSNode next(buf.str()); + if(!next.exists()) + break; + } + sspath << suffix.str(); + } + } + sspath << ".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 1a7621c33..cd42d277b 100644 --- a/src/debugger/gui/TiaOutputWidget.hxx +++ b/src/debugger/gui/TiaOutputWidget.hxx @@ -36,7 +36,8 @@ class TiaOutputWidget : public Widget, public CommandSender void loadConfig() override; void setZoomWidget(TiaZoomWidget* w) { myZoom = w; } - void saveSnapshot(int execDepth = 0, const string& execPrefix = ""); + void saveSnapshot(int execDepth = 0, const string& execPrefix = EmptyString, + bool mark = true); // Eventually, these methods will enable access to the onscreen TIA image // For example, clicking an area may cause an action