diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index f0727fcca..791daf007 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -46,6 +46,7 @@ #include "M6532.hxx" #include "MouseControl.hxx" #include "PNGLibrary.hxx" +#include "TIASurface.hxx" #include "EventHandler.hxx" @@ -386,7 +387,8 @@ void EventHandler::handleEvent(Event::Type event, Int32 state) return; case Event::TakeSnapshot: - if(state) myOSystem.png().takeSnapshot(); + //if(state) myOSystem.png().takeSnapshot(); + if(state) myOSystem.frameBuffer().tiaSurface().saveSnapShot(); return; case Event::LauncherMode: diff --git a/src/emucore/TIASurface.cxx b/src/emucore/TIASurface.cxx index 83dd48485..a1eb1c14e 100644 --- a/src/emucore/TIASurface.cxx +++ b/src/emucore/TIASurface.cxx @@ -23,6 +23,7 @@ #include "OSystem.hxx" #include "Console.hxx" #include "TIA.hxx" + #include "PNGLibrary.hxx" #include "TIASurface.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -34,7 +35,8 @@ TIASurface::TIASurface(OSystem& system) myUsePhosphor(false), myPhosphorPercent(0.60f), myScanlinesEnabled(false), - myPalette(nullptr) + myPalette(nullptr), + saveFlag(false) { // Load NTSC filter settings myNTSCFilter.loadConfig(myOSystem.settings()); @@ -389,6 +391,12 @@ void TIASurface::render() // Draw overlaying scanlines if(myScanlinesEnabled) mySLineSurface->render(); + + if(saveFlag) + { + saveFlag = false; + myOSystem.png().takeSnapshot(); + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/TIASurface.hxx b/src/emucore/TIASurface.hxx index 4ec22a49b..58949544b 100644 --- a/src/emucore/TIASurface.hxx +++ b/src/emucore/TIASurface.hxx @@ -155,6 +155,11 @@ class TIASurface */ void reRender(); + /** + Save a snapshot after rendering. + */ + void saveSnapShot() { saveFlag = true; } + private: OSystem& myOSystem; FrameBuffer& myFB; @@ -202,6 +207,9 @@ class TIASurface // Palette for normal TIA rendering mode const uInt32* myPalette; + // Flag for saving a snapshot + bool saveFlag; + private: // Following constructors and assignment operators not supported TIASurface() = delete;