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