From 12e727ae4ec6fbd86295ca8b7e9284233c87d988 Mon Sep 17 00:00:00 2001 From: stephena Date: Fri, 20 Jun 2014 23:01:11 +0000 Subject: [PATCH] The 'savesnap' command in the debugger prompt now actually saves a snapshot of the TIA image, including partial rendering (if applicable) and scanline indicator. Previously it only saved the TIA image, which basically made it useless from the debugger POV. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2931 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/debugger/Debugger.hxx | 17 +++++++++-------- src/debugger/DebuggerParser.cxx | 8 ++------ src/debugger/gui/TiaOutputWidget.cxx | 21 +++++++++++++++++++++ 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/debugger/Debugger.hxx b/src/debugger/Debugger.hxx index 83b84f2c5..6eb8e72ac 100644 --- a/src/debugger/Debugger.hxx +++ b/src/debugger/Debugger.hxx @@ -156,14 +156,15 @@ class Debugger : public DialogContainer */ TIADebug& tiaDebug() const { return *myTiaDebug; } - const GUI::Font& lfont() const { return myDialog->lfont(); } - const GUI::Font& nlfont() const { return myDialog->nfont(); } - DebuggerParser& parser() const { return *myParser; } - PackedBitArray& breakpoints() const { return *myBreakPoints; } - PackedBitArray& readtraps() const { return *myReadTraps; } - PackedBitArray& writetraps() const { return *myWriteTraps; } - PromptWidget& prompt() const { return myDialog->prompt(); } - RomWidget& rom() const { return myDialog->rom(); } + const GUI::Font& lfont() const { return myDialog->lfont(); } + const GUI::Font& nlfont() const { return myDialog->nfont(); } + DebuggerParser& parser() const { return *myParser; } + PackedBitArray& breakpoints() const { return *myBreakPoints; } + PackedBitArray& readtraps() const { return *myReadTraps; } + PackedBitArray& writetraps() const { return *myWriteTraps; } + PromptWidget& prompt() const { return myDialog->prompt(); } + RomWidget& rom() const { return myDialog->rom(); } + TiaOutputWidget& tiaOutput() const { return myDialog->tiaOutput(); } /** Run the debugger command and return the result. diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index 031e73e49..347873afc 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -26,6 +26,7 @@ #include "CpuDebug.hxx" #include "RiotDebug.hxx" #include "TIADebug.hxx" +#include "TiaOutputWidget.hxx" #include "DebuggerParser.hxx" #include "YaccParser.hxx" #include "M6502.hxx" @@ -1432,12 +1433,7 @@ void DebuggerParser::executeSaveses() // "savesnap" void DebuggerParser::executeSavesnap() { - // FIXME - for now, temporarily enable 1x snapshot mode, and reset it - // afterwards; this will change once we move to FBSurfaces - bool ss1x = settings.getBool("ss1x"); - settings.setValue("ss1x", true); - debugger.myOSystem->eventHandler().takeSnapshot(); - settings.setValue("ss1x", ss1x); + debugger.tiaOutput().saveSnapshot(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/TiaOutputWidget.cxx b/src/debugger/gui/TiaOutputWidget.cxx index e5fd8db24..6a386599d 100644 --- a/src/debugger/gui/TiaOutputWidget.cxx +++ b/src/debugger/gui/TiaOutputWidget.cxx @@ -66,6 +66,27 @@ void TiaOutputWidget::loadConfig() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TiaOutputWidget::saveSnapshot() { + int number = instance().getTicks() / 1000; + ostringstream sspath; + sspath << instance().snapshotSaveDir() + << instance().console().properties().get(Cartridge_Name) + << "_dbg_" << hex << setw(8) << setfill('0') << number << ".png"; + + const uInt32 width = instance().console().tia().width(), + height = instance().console().tia().height(); + FBSurface& s = dialog().surface(); + + GUI::Rect rect(_x, _y, _x + width*2, _y + height); + string message = "Snapshot saved"; + try + { + instance().png().saveImage(sspath.str(), s, rect); + } + catch(const char* msg) + { + message = msg; + } + instance().frameBuffer().showMessage(message); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -