diff --git a/src/common/VideoModeHandler.cxx b/src/common/VideoModeHandler.cxx index 6651bba63..e26ac4760 100644 --- a/src/common/VideoModeHandler.cxx +++ b/src/common/VideoModeHandler.cxx @@ -33,7 +33,7 @@ void VideoModeHandler::setDisplaySize(const Common::Size& display, Int32 fsIndex // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const VideoModeHandler::Mode& - VideoModeHandler::buildMode(const Settings& settings, bool inTIAMode, Mode::BezelInfo bezelInfo) + VideoModeHandler::buildMode(const Settings& settings, bool inTIAMode, bool showBezel) { const bool windowedRequested = myFSIndex == -1; @@ -49,7 +49,7 @@ const VideoModeHandler::Mode& // Image and screen (aka window) dimensions are the same // Overscan is not applicable in this mode myMode = Mode(myImage.w * zoom, myImage.h * zoom, Mode::Stretch::Fill, - myFSIndex, desc.str(), zoom, bezelInfo); + myFSIndex, desc.str(), zoom, showBezel); } else { @@ -57,7 +57,7 @@ const VideoModeHandler::Mode& // First calculate maximum zoom that keeps aspect ratio // Note: We are assuming a 16:9 bezel image here - const float bezelScaleW = bezelInfo.enabled ? bezelInfo.scaleW() : 1; + const float bezelScaleW = showBezel ? (16.F / 9.F) / (4.F / 3.F) : 1; const float scaleX = myImage.w / (myDisplay.w / bezelScaleW), scaleY = static_cast(myImage.h) / myDisplay.h; float zoom = 1.F / std::max(scaleX, scaleY); @@ -73,7 +73,8 @@ const VideoModeHandler::Mode& myDisplay.w, myDisplay.h, Mode::Stretch::Preserve, myFSIndex, "Fullscreen: Preserve aspect, no stretch", - zoom, overscan, bezelInfo); + zoom, overscan, + showBezel, showBezel ? settings.getInt("bezel.border") : 0); } else // ignore aspect, use all space { @@ -81,7 +82,7 @@ const VideoModeHandler::Mode& myDisplay.w, myDisplay.h, Mode::Stretch::Fill, myFSIndex, "Fullscreen: Ignore aspect, full stretch", - zoom, overscan, bezelInfo); + zoom, overscan, showBezel); } } } @@ -100,15 +101,17 @@ const VideoModeHandler::Mode& // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - VideoModeHandler::Mode::Mode(uInt32 iw, uInt32 ih, Stretch smode, Int32 fsindex, string_view desc, - float zoomLevel, BezelInfo bezelInfo) - : Mode(iw, ih, iw, ih, smode, fsindex, desc, zoomLevel, 1.F, bezelInfo) + float zoomLevel, + bool showBezel, Int32 bezelBorder) + : Mode(iw, ih, iw, ih, smode, fsindex, desc, zoomLevel, 1.F, showBezel, bezelBorder) { } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - VideoModeHandler::Mode::Mode(uInt32 iw, uInt32 ih, uInt32 sw, uInt32 sh, Stretch smode, Int32 fsindex, string_view desc, - float zoomLevel, float overscan, BezelInfo bezelInfo) + float zoomLevel, float overscan, + bool showBezel, Int32 bezelBorder) : screenS{sw, sh}, stretch{smode}, description{desc}, @@ -116,15 +119,15 @@ VideoModeHandler::Mode::Mode(uInt32 iw, uInt32 ih, uInt32 sw, uInt32 sh, fsIndex{fsindex} { // Note: We are assuming a 16:9 bezel image here - const float bezelScaleW = bezelInfo.enabled ? bezelInfo.scaleW() : 1; + const float bezelScaleW = showBezel ? (16.F / 9.F) / (4.F / 3.F) : 1; // Now resize based on windowed/fullscreen mode and stretch factor if(fsIndex != -1) // fullscreen mode { switch(stretch) { case Stretch::Preserve: - iw = (iw - bezelInfo.hBorder() * zoomLevel) * overscan; - ih = (ih - bezelInfo.vBorder() * zoomLevel) * overscan; + iw = (iw - bezelBorder * 4.F / 3.F * zoomLevel) * overscan; + ih = (ih - bezelBorder * zoomLevel) * overscan; //iw *= overscan; //ih *= overscan; break; diff --git a/src/common/VideoModeHandler.hxx b/src/common/VideoModeHandler.hxx index 380ce17ba..a13b159f0 100644 --- a/src/common/VideoModeHandler.hxx +++ b/src/common/VideoModeHandler.hxx @@ -49,11 +49,6 @@ class VideoModeHandler BezelInfo(bool _enabled, bool _windowedMode, uInt32 _topBorder, uInt32 _bottomBorder) : enabled{_enabled}, windowedMode{_windowedMode}, topBorder{_topBorder}, bottomBorder(_bottomBorder) { } - - uInt32 vBorder() { return topBorder + bottomBorder; } - uInt32 hBorder() { return (topBorder + bottomBorder) * 4.F / 3.F; } - // Scale width from 4:3 into 16:9 - float scaleW(float width = 1.F) { return width * (16.F / 9.F) / (4.F / 3.F); } }; Common::Rect imageR; @@ -68,12 +63,10 @@ class VideoModeHandler Mode(uInt32 iw, uInt32 ih, uInt32 sw, uInt32 sh, Stretch smode, Int32 fsindex = -1, string_view desc = "", float zoomLevel = 1.F, float overscan = 1.F, - BezelInfo bezelInfo = BezelInfo()); - //bool showBezel = false, Int32 bezelBorder = 0); + bool showBezel = false, Int32 bezelBorder = 0); Mode(uInt32 iw, uInt32 ih, Stretch smode, Int32 fsindex = -1, string_view desc = "", float zoomLevel = 1.F, - BezelInfo bezelInfo = BezelInfo()); - //bool showBezel = false, Int32 bezelBorder = 0); + bool showBezel = false, Int32 bezelBorder = 0); friend ostream& operator<<(ostream& os, const Mode& vm) { @@ -115,8 +108,8 @@ class VideoModeHandler @return A video mode based on the given criteria */ - const VideoModeHandler::Mode& buildMode(const Settings& settings, bool inTIAMode, - Mode::BezelInfo bezelInfo = Mode::BezelInfo()); + const VideoModeHandler::Mode& buildMode(const Settings& settings, + bool inTIAMode, bool showBezel); private: Common::Size myImage, myDisplay; diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index a83ceebe4..ac2818af8 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -1279,13 +1279,9 @@ FBInitStatus FrameBuffer::applyVideoMode() #else const bool showBezel = false; #endif - VideoModeHandler::Mode::BezelInfo bezelInfo(showBezel, - myOSystem.settings().getBool("bezel.windowed"), - myOSystem.settings().getInt("bezel.topborder"), - myOSystem.settings().getInt("bezel.bottomborder")); // Build the new mode based on current settings - const VideoModeHandler::Mode& mode = myVidModeHandler.buildMode(s, inTIAMode, bezelInfo); + const VideoModeHandler::Mode& mode = myVidModeHandler.buildMode(s, inTIAMode, showBezel); if(mode.imageR.size() > mode.screenS) return FBInitStatus::FailTooLarge; @@ -1310,9 +1306,14 @@ FBInitStatus FrameBuffer::applyVideoMode() if(inTIAMode) { #ifdef IMAGE_SUPPORT - loadBezel(bezelInfo); + if(myBezelSurface) + deallocateSurface(myBezelSurface); + myBezelSurface = nullptr; + if(showBezel) + loadBezel(); #endif - myTIASurface->initialize(myOSystem.console(), myActiveVidMode); + + myTIASurface->initialize(myOSystem.console(), myActiveVidMode); if(fullScreen()) myOSystem.settings().setValue("tia.fs_stretch", myActiveVidMode.stretch == VideoModeHandler::Mode::Stretch::Fill); @@ -1384,87 +1385,79 @@ bool FrameBuffer::checkBezel() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool FrameBuffer::loadBezel(VideoModeHandler::Mode::BezelInfo& info) +bool FrameBuffer::loadBezel() { bool isValid = false; + double aspectRatio = 1; - if(myBezelSurface) - deallocateSurface(myBezelSurface); - myBezelSurface = nullptr; - - if(info.enabled) + myBezelSurface = allocateSurface(myActiveVidMode.screenS.w, myActiveVidMode.screenS.h); + try { - double aspectRatio = 1; + const string& path = myOSystem.bezelDir().getPath(); + string imageName; + VariantList metaData; + int index = 0; - myBezelSurface = allocateSurface(myActiveVidMode.screenS.w, myActiveVidMode.screenS.h); - try + do { - const string& path = myOSystem.bezelDir().getPath(); - string imageName; - VariantList metaData; - int index = 0; - - do + const string& name = getBezelName(index); + if(name != EmptyString) { - const string& name = getBezelName(index); - if(name != EmptyString) + imageName = path + name + ".png"; + FSNode node(imageName); + if(node.exists()) { - imageName = path + name + ".png"; - FSNode node(imageName); - if(node.exists()) - { - isValid = true; - break; - } + isValid = true; + break; } - } while(index != -1); - if(isValid) - myOSystem.png().loadImage(imageName, *myBezelSurface, &aspectRatio, metaData); - } - catch(const runtime_error&) - { - isValid = false; - } - + } + } while (index != -1); if(isValid) + myOSystem.png().loadImage(imageName, *myBezelSurface, &aspectRatio, metaData); + } + catch(const runtime_error&) + { + isValid = false; + } + + if(isValid) + { + const float overscan = 1 - myOSystem.settings().getInt("tia.fs_overscan") / 100.0; + bool fs = fullScreen(); + + uInt32 imageW, imageH; + if(fullScreen()) { - const float overscan = 1 - myOSystem.settings().getInt("tia.fs_overscan") / 100.0; + const float bezelBorder = myOSystem.settings().getInt("bezel.border") * overscan * myActiveVidMode.zoom; + imageW = (myActiveVidMode.imageR.w() + static_cast(bezelBorder * 4.F / 3.F)) * (16.F / 9.F) / (4.F / 3.F); + imageH = myActiveVidMode.imageR.h() + static_cast(bezelBorder); + } + else + { + imageW = static_cast(myActiveVidMode.imageR.w() * (16.F / 9.F) / (4.F / 3.F)); + imageH = myActiveVidMode.imageR.h(); + } - uInt32 imageW, imageH; - if(fullScreen()) - { - const float hBorder = info.hBorder() * overscan * myActiveVidMode.zoom; - const float vBorder = info.vBorder() * overscan * myActiveVidMode.zoom; - imageW = info.scaleW(myActiveVidMode.imageR.w() + hBorder); - imageH = myActiveVidMode.imageR.h() + vBorder; - } - else - { - imageW = info.scaleW(myActiveVidMode.imageR.w()); - imageH = myActiveVidMode.imageR.h(); - } - - // Scale bezel to fullscreen (preserve or stretch) or window size - const uInt32 bezelW = std::min( - myActiveVidMode.screenS.w, imageW); + // Scale bezel to fullscreen (preserve or stretch) or window size + const uInt32 bezelW = std::min( + myActiveVidMode.screenS.w, imageW); //static_cast(myActiveVidMode.imageR.w() * (16.F / 9.F) / (4.F / 3.F)) + static_cast(40 * myActiveVidMode.zoom)); - const uInt32 bezelH = std::min( - myActiveVidMode.screenS.h, imageH); + const uInt32 bezelH = std::min( + myActiveVidMode.screenS.h, imageH); //myActiveVidMode.imageR.h() + static_cast(30 * myActiveVidMode.zoom)); //cerr << bezelW << " x " << bezelH << endl; - myBezelSurface->setDstSize(bezelW, bezelH); - myBezelSurface->setDstPos((myActiveVidMode.screenS.w - bezelW) / 2, - (myActiveVidMode.screenS.h - bezelH) / 2); // center - myBezelSurface->setScalingInterpolation(ScalingInterpolation::sharp); + myBezelSurface->setDstSize(bezelW, bezelH); + myBezelSurface->setDstPos((myActiveVidMode.screenS.w - bezelW) / 2, + (myActiveVidMode.screenS.h - bezelH) / 2); // center + myBezelSurface->setScalingInterpolation(ScalingInterpolation::sharp); - // Enable blending to allow overlaying the bezel over the TIA output - myBezelSurface->attributes().blending = true; - myBezelSurface->attributes().blendalpha = 100; - myBezelSurface->applyAttributes(); - } - if(myBezelSurface) - myBezelSurface->setVisible(isValid); + // Enable blending to allow overlaying the bezel over the TIA output + myBezelSurface->attributes().blending = true; + myBezelSurface->attributes().blendalpha = 100; + myBezelSurface->applyAttributes(); } + if(myBezelSurface) + myBezelSurface->setVisible(isValid); return isValid; } #endif diff --git a/src/emucore/FrameBuffer.hxx b/src/emucore/FrameBuffer.hxx index 67bf0fe1c..abdeaa57b 100644 --- a/src/emucore/FrameBuffer.hxx +++ b/src/emucore/FrameBuffer.hxx @@ -485,7 +485,7 @@ class FrameBuffer @return Whether the bezel was loaded or not */ - bool loadBezel(VideoModeHandler::Mode::BezelInfo& info); + bool loadBezel(); #endif /** diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index 4b518b51b..9382f8ba6 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -64,8 +64,7 @@ Settings::Settings() setPermanent("pausedim", "true"); setPermanent("bezel.show", "true"); setPermanent("bezel.windowed", "false"); - setPermanent("bezel.topborder", "0"); - setPermanent("bezel.bottomborder", "0"); + setPermanent("bezel.border", "30"); // TIA specific options setPermanent("tia.inter", "false"); setPermanent("tia.zoom", "3");