From a1d6d6ea41593a9a9d2af7d8728061761cfa4755 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Thu, 18 Jun 2020 21:48:51 -0230 Subject: [PATCH] Fix TIA images saved in '1x' mode to not use TV effects (fixes #643). --- Changes.txt | 3 +++ src/debugger/gui/TiaOutputWidget.cxx | 2 +- src/emucore/TIASurface.cxx | 15 +-------------- src/emucore/TIASurface.hxx | 12 ++++++++---- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/Changes.txt b/Changes.txt index 490d98b82..2a5efe3b6 100644 --- a/Changes.txt +++ b/Changes.txt @@ -35,6 +35,9 @@ * Make NTSC custom phase shift not affect Yellow anymore. + * Fixed '1x' snapshot mode; TV effects are now disabled. This mode + now generates a clean, pixel-exact image. + * A ROM properties file may now be placed next to the ROM (with the same name as the ROM, except ending in .pro), and Stella will automatically apply the properties to the ROM. [NOTE: this was present in 6.2, but diff --git a/src/debugger/gui/TiaOutputWidget.cxx b/src/debugger/gui/TiaOutputWidget.cxx index 5277647dc..01d6d094b 100644 --- a/src/debugger/gui/TiaOutputWidget.cxx +++ b/src/debugger/gui/TiaOutputWidget.cxx @@ -179,7 +179,7 @@ void TiaOutputWidget::drawWidget(bool hilite) bool visible = instance().console().tia().electronBeamPos(scanx, scany); scanoffset = width * scany + scanx; uInt8* tiaOutputBuffer = instance().console().tia().outputBuffer(); - TIASurface& tiaSurface(instance().frameBuffer().tiaSurface()); + const TIASurface& tiaSurface = instance().frameBuffer().tiaSurface(); for(uInt32 y = 0, i = yStart * width; y < height; ++y) { diff --git a/src/emucore/TIASurface.cxx b/src/emucore/TIASurface.cxx index afaad7855..781ca203a 100644 --- a/src/emucore/TIASurface.cxx +++ b/src/emucore/TIASurface.cxx @@ -148,32 +148,19 @@ const FBSurface& TIASurface::baseSurface(Common::Rect& rect) const uInt32 tiaw = myTIA->width(), width = tiaw * 2, height = myTIA->height(); rect.setBounds(0, 0, width, height); - // Get Blargg buffer and width - uInt32 *blarggBuf, blarggPitch; - myTiaSurface->basePtr(blarggBuf, blarggPitch); - double blarggXFactor = double(blarggPitch) / width; - bool useBlargg = ntscEnabled(); - // Fill the surface with pixels from the TIA, scaled 2x horizontally uInt32 *buf_ptr, pitch; myBaseTiaSurface->basePtr(buf_ptr, pitch); for(uInt32 y = 0; y < height; ++y) - { for(uInt32 x = 0; x < width; ++x) - { - if (useBlargg) - *buf_ptr++ = blarggBuf[y * blarggPitch + uInt32(nearbyint(x * blarggXFactor))]; - else *buf_ptr++ = myPalette[*(myTIA->frameBuffer() + y * tiaw + x / 2)]; - } - } return *myBaseTiaSurface; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 TIASurface::mapIndexedPixel(uInt8 indexedColor, uInt8 shift) +uInt32 TIASurface::mapIndexedPixel(uInt8 indexedColor, uInt8 shift) const { return myPalette[indexedColor | shift]; } diff --git a/src/emucore/TIASurface.hxx b/src/emucore/TIASurface.hxx index 826ff75d9..2b6213785 100644 --- a/src/emucore/TIASurface.hxx +++ b/src/emucore/TIASurface.hxx @@ -70,14 +70,18 @@ class TIASurface void setPalette(const PaletteArray& tia_palette, const PaletteArray& rgb_palette); /** - Get the TIA base surface for use in saving to a PNG image. + Get a TIA surface that has no post-processing whatsoever. This is + currently used to save PNG image in the so-called '1x mode'. + + @param rect Specifies the area in which the surface data is valid */ const FBSurface& baseSurface(Common::Rect& rect) const; /** - Use the palette to map a single indexed pixel color. This is used by the TIA output widget. + Use the palette to map a single indexed pixel color. This is used by the + TIA output widget. */ - uInt32 mapIndexedPixel(uInt8 indexedColor, uInt8 shift = 0); + uInt32 mapIndexedPixel(uInt8 indexedColor, uInt8 shift = 0) const; /** Get the NTSCFilter object associated with the framebuffer @@ -220,7 +224,7 @@ class TIASurface bool mySaveSnapFlag{false}; // The palette handler - unique_ptrmyPaletteHandler; + unique_ptr myPaletteHandler; private: // Following constructors and assignment operators not supported