diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 85926ef24..365d6a186 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -75,8 +75,8 @@ bool FrameBuffer::initialize() query_h = s.h; } // Various parts of the codebase assume a minimum screen size - myDesktopSize.w = std::max(query_w, uInt32(kFBMinW)); - myDesktopSize.h = std::max(query_h, uInt32(kFBMinH)); + myDesktopSize.w = std::max(query_w, FBMinimum::Width); + myDesktopSize.h = std::max(query_h, FBMinimum::Height); //////////////////////////////////////////////////////////////////// // Create fonts to draw text @@ -88,7 +88,8 @@ bool FrameBuffer::initialize() // We can probably add ifdefs to take care of corner cases, // but that means we've failed to abstract it enough ... //////////////////////////////////////////////////////////////////// - bool smallScreen = myDesktopSize.w < kFBMinW || myDesktopSize.h < kFBMinH; + bool smallScreen = myDesktopSize.w < FBMinimum::Width || + myDesktopSize.h < FBMinimum::Height; // This font is used in a variety of situations when a really small // font is needed; we let the specific widget/dialog decide when to @@ -120,8 +121,9 @@ bool FrameBuffer::initialize() myLauncherFont = make_unique(GUI::stellaDesc); // Determine possible TIA windowed zoom levels - uInt32 maxZoom = maxWindowSizeForScreen(uInt32(kTIAMinW), uInt32(kTIAMinH), - myDesktopSize.w, myDesktopSize.h); + uInt32 maxZoom = maxWindowSizeForScreen( + TIAConstants::viewableWidth, TIAConstants::viewableHeight, + myDesktopSize.w, myDesktopSize.h); // Figure our the smallest zoom level we can use uInt32 firstZoom = smallScreen ? 1 : 2; @@ -186,7 +188,7 @@ FBInitStatus FrameBuffer::createDisplay(const string& title, // we're running on a 'large' system, and the window size requirements // can be relaxed // Otherwise, we treat the system as if WINDOWED_SUPPORT is not defined - if(myDesktopSize.w < kFBMinW && myDesktopSize.h < kFBMinH && + if(myDesktopSize.w < FBMinimum::Width && myDesktopSize.h < FBMinimum::Height && (myDesktopSize.w < width || myDesktopSize.h < height)) return FBInitStatus::FailTooLarge; @@ -254,7 +256,7 @@ FBInitStatus FrameBuffer::createDisplay(const string& title, } if(!myMsg.surface) - myMsg.surface = allocateSurface(kFBMinW, font().getFontHeight()+10); + myMsg.surface = allocateSurface(FBMinimum::Width, font().getFontHeight()+10); // Print initial usage message, but only print it later if the status has changed if(myInitializedCount == 1) @@ -837,7 +839,7 @@ void FrameBuffer::setAvailableVidModes(uInt32 baseWidth, uInt32 baseHeight) // Figure our the smallest zoom level we can use uInt32 firstZoom = 2; - if(myDesktopSize.w < kFBMinW || myDesktopSize.h < kFBMinH) + if(myDesktopSize.w < FBMinimum::Width || myDesktopSize.h < FBMinimum::Height) firstZoom = 1; for(uInt32 zoom = firstZoom; zoom <= maxZoom; ++zoom) { @@ -924,8 +926,8 @@ VideoMode::VideoMode(uInt32 iw, uInt32 ih, uInt32 sw, uInt32 sh, zoom(z), description(desc) { - sw = std::max(sw, uInt32(FrameBuffer::kTIAMinW)); - sh = std::max(sh, uInt32(FrameBuffer::kTIAMinH)); + sw = std::max(sw, TIAConstants::viewableWidth); + sh = std::max(sh, TIAConstants::viewableHeight); iw = std::min(iw, sw); ih = std::min(ih, sh); int ix = (sw - iw) >> 1; diff --git a/src/emucore/FrameBuffer.hxx b/src/emucore/FrameBuffer.hxx index b5083b052..0458a4dc5 100644 --- a/src/emucore/FrameBuffer.hxx +++ b/src/emucore/FrameBuffer.hxx @@ -83,11 +83,6 @@ class VideoMode class FrameBuffer { public: - enum { - kTIAMinW = 320u, kTIAMinH = TIAConstants::viewableHeight, - kFBMinW = 640u, kFBMinH = 480u - }; - /** Creates a new Frame Buffer */ diff --git a/src/emucore/FrameBufferConstants.hxx b/src/emucore/FrameBufferConstants.hxx index 2d36868c3..22e5e5d84 100644 --- a/src/emucore/FrameBufferConstants.hxx +++ b/src/emucore/FrameBufferConstants.hxx @@ -18,8 +18,15 @@ #ifndef FRAMEBUFFER_CONSTANTS_HXX #define FRAMEBUFFER_CONSTANTS_HXX +#include "TIAConstants.hxx" #include "bspf.hxx" +// Minimum size for a framebuffer window +namespace FBMinimum { + static constexpr uInt32 Width = TIAConstants::viewableWidth * 2; + static constexpr uInt32 Height = TIAConstants::viewableHeight * 2; +} + // Return values for initialization of framebuffer window enum class FBInitStatus { Success, diff --git a/src/emucore/TIASurface.cxx b/src/emucore/TIASurface.cxx index 4052319e1..49b98b95f 100644 --- a/src/emucore/TIASurface.cxx +++ b/src/emucore/TIASurface.cxx @@ -23,7 +23,7 @@ #include "OSystem.hxx" #include "Console.hxx" #include "TIA.hxx" - #include "PNGLibrary.hxx" +#include "PNGLibrary.hxx" #include "TIASurface.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -42,19 +42,22 @@ TIASurface::TIASurface(OSystem& system) myNTSCFilter.loadConfig(myOSystem.settings()); // Create a surface for the TIA image and scanlines; we'll need them eventually - myTiaSurface = myFB.allocateSurface(AtariNTSC::outWidth(kTIAW), kTIAH); + myTiaSurface = myFB.allocateSurface(AtariNTSC::outWidth(TIAConstants::frameBufferWidth), + TIAConstants::frameBufferHeight); // Generate scanline data, and a pre-defined scanline surface - uInt32 scanData[kScanH]; - for(int i = 0; i < kScanH; i+=2) + constexpr uInt32 scanHeight = TIAConstants::frameBufferHeight * 2; + uInt32 scanData[scanHeight]; + for(uInt32 i = 0; i < scanHeight; i += 2) { scanData[i] = 0x00000000; scanData[i+1] = 0xff000000; } - mySLineSurface = myFB.allocateSurface(1, kScanH, scanData); + mySLineSurface = myFB.allocateSurface(1, scanHeight, scanData); // Base TIA surface for use in taking snapshots in 1x mode - myBaseTiaSurface = myFB.allocateSurface(kTIAW*2, kTIAH); + myBaseTiaSurface = myFB.allocateSurface(TIAConstants::frameBufferWidth*2, + TIAConstants::frameBufferHeight); memset(myRGBFramebuffer, 0, sizeof(myRGBFramebuffer)); @@ -278,8 +281,8 @@ void TIASurface::enableNTSC(bool enable) myFilter = Filter(enable ? uInt8(myFilter) | 0x10 : uInt8(myFilter) & 0x01); // Normal vs NTSC mode uses different source widths - myTiaSurface->setSrcSize(enable ? - AtariNTSC::outWidth(kTIAW) : uInt32(kTIAW), myTIA->height()); + myTiaSurface->setSrcSize(enable ? AtariNTSC::outWidth(TIAConstants::frameBufferWidth) + : TIAConstants::frameBufferWidth, myTIA->height()); FBSurface::Attributes& tia_attr = myTiaSurface->attributes(); tia_attr.smoothing = myOSystem.settings().getBool("tia.inter"); diff --git a/src/emucore/TIASurface.hxx b/src/emucore/TIASurface.hxx index 63c9ec5c8..fc3dd37cf 100644 --- a/src/emucore/TIASurface.hxx +++ b/src/emucore/TIASurface.hxx @@ -185,20 +185,16 @@ class TIASurface }; Filter myFilter; - enum { - kTIAW = 160, - kTIAH = TIAConstants::frameBufferHeight, - kScanH = kTIAH*2 - }; - // NTSC object to use in TIA rendering mode NTSCFilter myNTSCFilter; ///////////////////////////////////////////////////////////// // Phosphor mode items (aka reduced flicker on 30Hz screens) // RGB frame buffer - uInt32 myRGBFramebuffer[AtariNTSC::outWidth(kTIAW) * kTIAH]; - uInt32 myPrevRGBFramebuffer[AtariNTSC::outWidth(kTIAW) * kTIAH]; + uInt32 myRGBFramebuffer[AtariNTSC::outWidth(TIAConstants::frameBufferWidth) * + TIAConstants::frameBufferHeight]; + uInt32 myPrevRGBFramebuffer[AtariNTSC::outWidth(TIAConstants::frameBufferWidth) * + TIAConstants::frameBufferHeight]; // Use phosphor effect bool myUsePhosphor; diff --git a/src/emucore/tia/TIAConstants.hxx b/src/emucore/tia/TIAConstants.hxx index f64ab12d2..1c134f4ed 100644 --- a/src/emucore/tia/TIAConstants.hxx +++ b/src/emucore/tia/TIAConstants.hxx @@ -22,10 +22,12 @@ namespace TIAConstants { - constexpr uInt32 frameBufferHeight = 320; - constexpr uInt32 maxYStart = 64; - constexpr uInt32 viewableHeight = 240; - constexpr uInt32 initialGarbageFrames = 10; + static constexpr uInt32 frameBufferWidth = 160; + static constexpr uInt32 frameBufferHeight = 320; + static constexpr uInt32 maxYStart = 64; // TODO - this may be removed + static constexpr uInt32 viewableWidth = 320; + static constexpr uInt32 viewableHeight = 240; + static constexpr uInt32 initialGarbageFrames = 10; static constexpr uInt16 H_PIXEL = 160, H_CYCLES = 76, CYCLE_CLOCKS = 3, diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 053b54711..d402bd9e3 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -814,7 +814,7 @@ bool Dialog::getDynamicBounds(uInt32& w, uInt32& h) const { const GUI::Rect& r = instance().frameBuffer().imageRect(); - if(r.width() <= FrameBuffer::kFBMinW || r.height() <= FrameBuffer::kFBMinH) + if(r.width() <= FBMinimum::Width || r.height() <= FBMinimum::Height) { w = r.width(); h = r.height(); diff --git a/src/gui/Launcher.cxx b/src/gui/Launcher.cxx index 348e89fbf..f3d7bfcb1 100644 --- a/src/gui/Launcher.cxx +++ b/src/gui/Launcher.cxx @@ -35,13 +35,12 @@ Launcher::Launcher(OSystem& osystem) // The launcher dialog is resizable, within certain bounds // We check those bounds now - myWidth = std::max(myWidth, uInt32(FrameBuffer::kFBMinW)); - myHeight = std::max(myHeight, uInt32(FrameBuffer::kFBMinH)); + myWidth = std::max(myWidth, FBMinimum::Width); + myHeight = std::max(myHeight, FBMinimum::Height); myWidth = std::min(myWidth, uInt32(d.w)); myHeight = std::min(myHeight, uInt32(d.h)); - myOSystem.settings().setValue("launcherres", - GUI::Size(myWidth, myHeight)); + myOSystem.settings().setValue("launcherres", GUI::Size(myWidth, myHeight)); myBaseDialog = new LauncherDialog(myOSystem, *this, 0, 0, myWidth, myHeight); } diff --git a/src/gui/Menu.cxx b/src/gui/Menu.cxx index cf57c0df7..a970b9a7d 100644 --- a/src/gui/Menu.cxx +++ b/src/gui/Menu.cxx @@ -16,7 +16,7 @@ //============================================================================ #include "Dialog.hxx" -#include "FrameBuffer.hxx" +#include "FrameBufferConstants.hxx" #include "OptionsDialog.hxx" #include "bspf.hxx" #include "Menu.hxx" @@ -26,5 +26,5 @@ Menu::Menu(OSystem& osystem) : DialogContainer(osystem) { myBaseDialog = new OptionsDialog(myOSystem, *this, nullptr, - FrameBuffer::kFBMinW, FrameBuffer::kFBMinH, OptionsDialog::emulator); + FBMinimum::Width, FBMinimum::Height, OptionsDialog::emulator); } diff --git a/src/gui/RomInfoWidget.cxx b/src/gui/RomInfoWidget.cxx index a959a1d30..9d8a68170 100644 --- a/src/gui/RomInfoWidget.cxx +++ b/src/gui/RomInfoWidget.cxx @@ -35,8 +35,9 @@ RomInfoWidget::RomInfoWidget(GuiObject* boss, const GUI::Font& font, : Widget(boss, font, x, y, w, h), mySurfaceIsValid(false), myHaveProperties(false), - myAvail(w > 400 ? GUI::Size(640, TIAConstants::viewableHeight*2) : - GUI::Size(320, TIAConstants::viewableHeight)) + myAvail(w > 400 ? + GUI::Size(TIAConstants::viewableWidth*2, TIAConstants::viewableHeight*2) : + GUI::Size(TIAConstants::viewableWidth, TIAConstants::viewableHeight)) { _flags = WIDGET_ENABLED; _bgcolor = kDlgColor; @@ -84,7 +85,8 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node) // only draw certain parts of it if(mySurface == nullptr) { - mySurface = instance().frameBuffer().allocateSurface(320*2, TIAConstants::viewableHeight*2); + mySurface = instance().frameBuffer().allocateSurface( + TIAConstants::viewableWidth*2, TIAConstants::viewableHeight*2); mySurface->attributes().smoothing = true; mySurface->applyAttributes(); diff --git a/src/gui/TimeMachine.cxx b/src/gui/TimeMachine.cxx index 5cdf3e6a7..0abe5d62c 100644 --- a/src/gui/TimeMachine.cxx +++ b/src/gui/TimeMachine.cxx @@ -16,14 +16,14 @@ //============================================================================ #include "Dialog.hxx" -#include "FrameBuffer.hxx" +#include "FrameBufferConstants.hxx" #include "TimeMachineDialog.hxx" #include "TimeMachine.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TimeMachine::TimeMachine(OSystem& osystem) : DialogContainer(osystem), - myWidth(FrameBuffer::kFBMinW) + myWidth(FBMinimum::Width) { myBaseDialog = new TimeMachineDialog(myOSystem, *this, myWidth); } diff --git a/src/gui/UIDialog.cxx b/src/gui/UIDialog.cxx index e59db4fb0..7fca1d21e 100644 --- a/src/gui/UIDialog.cxx +++ b/src/gui/UIDialog.cxx @@ -133,21 +133,21 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent, // Launcher width and height myLauncherWidthSlider = new SliderWidget(myTab, font, xpos, ypos, "Launcher width ", lwidth, kLauncherSize, 6 * fontWidth, "px"); - myLauncherWidthSlider->setMinValue(FrameBuffer::kFBMinW); + myLauncherWidthSlider->setMinValue(FBMinimum::Width); myLauncherWidthSlider->setMaxValue(ds.w); myLauncherWidthSlider->setStepValue(10); // one tickmark every ~100 pixel - myLauncherWidthSlider->setTickmarkInterval((ds.w - FrameBuffer::kFBMinW + 50) / 100); + myLauncherWidthSlider->setTickmarkInterval((ds.w - FBMinimum::Width + 50) / 100); wid.push_back(myLauncherWidthSlider); ypos += lineHeight + V_GAP; myLauncherHeightSlider = new SliderWidget(myTab, font, xpos, ypos, "Launcher height ", lwidth, kLauncherSize, 6 * fontWidth, "px"); - myLauncherHeightSlider->setMinValue(FrameBuffer::kFBMinH); + myLauncherHeightSlider->setMinValue(FBMinimum::Height); myLauncherHeightSlider->setMaxValue(ds.h); myLauncherHeightSlider->setStepValue(10); // one tickmark every ~100 pixel - myLauncherHeightSlider->setTickmarkInterval((ds.h - FrameBuffer::kFBMinH + 50) / 100); + myLauncherHeightSlider->setTickmarkInterval((ds.h - FBMinimum::Height + 50) / 100); wid.push_back(myLauncherHeightSlider); ypos += lineHeight + V_GAP; @@ -237,8 +237,8 @@ void UIDialog::loadConfig() const GUI::Size& ls = settings.getSize("launcherres"); uInt32 w = ls.w, h = ls.h; - w = std::max(w, uInt32(FrameBuffer::kFBMinW)); - h = std::max(h, uInt32(FrameBuffer::kFBMinH)); + w = std::max(w, FBMinimum::Width); + h = std::max(h, FBMinimum::Height); w = std::min(w, instance().frameBuffer().desktopSize().w); h = std::min(h, instance().frameBuffer().desktopSize().h);