add non-integral TIA zoom steps (partially addresses #263)

This commit is contained in:
thrust26 2019-05-18 10:30:23 +02:00
parent 49585250fd
commit 95d8bb870d
4 changed files with 41 additions and 52 deletions

View File

@ -138,16 +138,9 @@ bool FrameBuffer::initialize()
#endif
// Determine possible TIA windowed zoom levels
uInt32 minZoom = 2 * hidpiScaleFactor();
uInt32 maxZoom = maxWindowSizeForScreen(
myTIAMaxZoom = maxZoomForScreen(
TIAConstants::viewableWidth, TIAConstants::viewableHeight,
myAbsDesktopSize.w, myAbsDesktopSize.h);
for(uInt32 zoom = minZoom; zoom <= maxZoom; ++zoom)
{
ostringstream desc;
desc << "Zoom " << zoom << "x";
VarList::push_back(myTIAZoomLevels, desc.str(), zoom);
}
setUIPalette();
@ -842,10 +835,10 @@ void FrameBuffer::toggleGrabMouse()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 FrameBuffer::maxWindowSizeForScreen(uInt32 baseWidth, uInt32 baseHeight,
double FrameBuffer::maxZoomForScreen(uInt32 baseWidth, uInt32 baseHeight,
uInt32 screenWidth, uInt32 screenHeight) const
{
uInt32 multiplier = 1;
double multiplier = 1;
for(;;)
{
// Figure out the zoomed size of the window
@ -855,9 +848,9 @@ uInt32 FrameBuffer::maxWindowSizeForScreen(uInt32 baseWidth, uInt32 baseHeight,
if((width > screenWidth) || (height > screenHeight))
break;
++multiplier;
multiplier += ZOOM_STEPS;
}
return multiplier > 1 ? multiplier - 1 : 1;
return multiplier > 1 ? multiplier - ZOOM_STEPS : 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -883,7 +876,7 @@ void FrameBuffer::setAvailableVidModes(uInt32 baseWidth, uInt32 baseHeight)
{
// TIA windowed modes
uInt32 minZoom = 2 * hidpiScaleFactor();
uInt32 maxZoom = maxWindowSizeForScreen(baseWidth, baseHeight,
myTIAMaxZoom = maxZoomForScreen(baseWidth, baseHeight,
myAbsDesktopSize.w, myAbsDesktopSize.h);
#if 0 // FIXME - does this apply any longer??
@ -894,7 +887,7 @@ void FrameBuffer::setAvailableVidModes(uInt32 baseWidth, uInt32 baseHeight)
#endif
// Determine all zoom levels
for(uInt32 zoom = minZoom; zoom <= maxZoom; ++zoom)
for(double zoom = minZoom; zoom <= myTIAMaxZoom; zoom += ZOOM_STEPS)
{
ostringstream desc;
desc << "Zoom " << zoom << "x";
@ -907,21 +900,21 @@ void FrameBuffer::setAvailableVidModes(uInt32 baseWidth, uInt32 baseHeight)
// TIA fullscreen mode
for(uInt32 i = 0; i < myFullscreenDisplays.size(); ++i)
{
maxZoom = maxWindowSizeForScreen(baseWidth, baseHeight,
myTIAMaxZoom = maxZoomForScreen(baseWidth, baseHeight,
myFullscreenDisplays[i].w * overscan, myFullscreenDisplays[i].h * overscan);
// Add both normal aspect and filled modes
// It's easier to define them both now, and simply switch between
// them when necessary
VideoMode mode1(baseWidth*maxZoom, baseHeight*maxZoom,
VideoMode mode1(baseWidth * myTIAMaxZoom, baseHeight * myTIAMaxZoom,
myFullscreenDisplays[i].w, myFullscreenDisplays[i].h,
VideoMode::Stretch::Preserve, overscan,
"Preserve aspect, no stretch", maxZoom, i);
"Preserve aspect, no stretch", myTIAMaxZoom, i);
myFullscreenModeLists[i].add(mode1);
VideoMode mode2(baseWidth*maxZoom, baseHeight*maxZoom,
VideoMode mode2(baseWidth * myTIAMaxZoom, baseHeight * myTIAMaxZoom,
myFullscreenDisplays[i].w, myFullscreenDisplays[i].h,
VideoMode::Stretch::Fill, overscan,
"Ignore aspect, full stretch", maxZoom, i);
"Ignore aspect, full stretch", myTIAMaxZoom, i);
myFullscreenModeLists[i].add(mode2);
}
}
@ -970,7 +963,7 @@ const FrameBuffer::VideoMode& FrameBuffer::getSavedVidMode(bool fullscreen)
myCurrentModeList->setByStretch(myOSystem.settings().getBool("tia.fs_stretch")
? VideoMode::Stretch::Fill : VideoMode::Stretch::Preserve);
else
myCurrentModeList->setByZoom(myOSystem.settings().getInt("tia.zoom"));
myCurrentModeList->setByZoom(myOSystem.settings().getFloat("tia.zoom"));
}
return myCurrentModeList->current();
@ -992,7 +985,7 @@ FrameBuffer::VideoMode::VideoMode()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FrameBuffer::VideoMode::VideoMode(uInt32 iw, uInt32 ih, uInt32 sw, uInt32 sh,
Stretch smode, double overscan, const string& desc,
uInt32 zoomLevel, Int32 fsindex)
double zoomLevel, Int32 fsindex)
: stretch(smode),
description(desc),
zoom(zoomLevel),
@ -1125,7 +1118,7 @@ void FrameBuffer::VideoModeList::next()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::VideoModeList::setByZoom(uInt32 zoom)
void FrameBuffer::VideoModeList::setByZoom(double zoom)
{
for(uInt32 i = 0; i < myModeList.size(); ++i)
{

View File

@ -63,12 +63,12 @@ class FrameBuffer
Common::Size screen;
Stretch stretch;
string description;
uInt32 zoom;
double zoom;
Int32 fsIndex;
VideoMode();
VideoMode(uInt32 iw, uInt32 ih, uInt32 sw, uInt32 sh, Stretch smode, double overscan = 1.0,
const string& desc = "", uInt32 zoomLevel = 1, Int32 fsindex = -1);
const string& desc = "", double zoomLevel = 1, Int32 fsindex = -1);
friend ostream& operator<<(ostream& os, const VideoMode& vm)
{
@ -80,6 +80,9 @@ class FrameBuffer
}
};
// Zoom level step interval
static constexpr double ZOOM_STEPS = 0.25;
public:
/**
Creates a new Frame Buffer
@ -195,9 +198,9 @@ class FrameBuffer
const VariantList& supportedRenderers() const { return myRenderers; }
/**
Get the supported TIA zoom levels (windowed mode) for the framebuffer.
Get the maximum supported TIA zoom level (windowed mode) for the framebuffer.
*/
const VariantList& supportedTIAZoomLevels() const { return myTIAZoomLevels; }
const double supportedTIAMaxZoom() const { return myTIAMaxZoom; }
/**
Get the TIA surface associated with the framebuffer.
@ -451,7 +454,7 @@ class FrameBuffer
Calculate the maximum level by which the base window can be zoomed and
still fit in the given screen dimensions.
*/
uInt32 maxWindowSizeForScreen(uInt32 baseWidth, uInt32 baseHeight,
double maxZoomForScreen(uInt32 baseWidth, uInt32 baseHeight,
uInt32 screenWidth, uInt32 screenHeight) const;
/**
@ -490,7 +493,7 @@ class FrameBuffer
const FrameBuffer::VideoMode& current() const;
void next();
void setByZoom(uInt32 zoom);
void setByZoom(double zoom);
void setByStretch(FrameBuffer::VideoMode::Stretch stretch);
friend ostream& operator<<(ostream& os, const VideoModeList& l)
@ -591,8 +594,8 @@ class FrameBuffer
VideoModeList myWindowedModeList;
vector<VideoModeList> myFullscreenModeLists;
// Names of the TIA zoom levels that can be used for this framebuffer
VariantList myTIAZoomLevels;
// Maximum TIA zoom level that can be used for this framebuffer
double myTIAMaxZoom;
// Holds a reference to all the surfaces that have been created
vector<shared_ptr<FBSurface>> mySurfaceList;

View File

@ -123,24 +123,18 @@ VideoDialog::VideoDialog(OSystem& osystem, DialogContainer& parent,
wid.push_back(myTIAPalette);
ypos += lineHeight + VGAP;
// TIA filters (will be dynamically filled later)
myTIAZoom = new PopUpWidget(myTab, font, xpos, ypos, pwidth,
lineHeight, items, "TIA zoom ", lwidth);
wid.push_back(myTIAZoom);
ypos += lineHeight + VGAP;
/*SliderWidget* s = new SliderWidget(myTab, font, xpos, ypos - 1, swidth, lineHeight,
"TIA zoom", lwidth, 0, fontWidth * 4, "%");
s->setMinValue(200); s->setMaxValue(500);
s->setTickmarkInterval(3); // just for testing now; TODO: remove or redefine
wid.push_back(s);
ypos += lineHeight + VGAP;*/
// TIA interpolation
myTIAInterpolate = new CheckboxWidget(myTab, font, xpos, ypos + 1, "TIA interpolation ");
wid.push_back(myTIAInterpolate);
ypos += lineHeight + VGAP;
// TIA zoom levels (will be dynamically filled later)
myTIAZoom = new SliderWidget(myTab, font, xpos, ypos - 1, swidth, lineHeight,
"TIA zoom", lwidth, 0, fontWidth * 4, "%");
myTIAZoom->setMinValue(200); myTIAZoom->setStepValue(FrameBuffer::ZOOM_STEPS * 100);
wid.push_back(myTIAZoom);
ypos += lineHeight + VGAP;
// Aspect ratio (NTSC mode)
myNAspectRatio =
new SliderWidget(myTab, font, xpos, ypos-1, swidth, lineHeight,
@ -340,12 +334,12 @@ void VideoDialog::loadConfig()
// Renderer settings
myRenderer->setSelected(instance().settings().getString("video"), "default");
// TIA Filter
// TIA zoom levels
// These are dynamically loaded, since they depend on the size of
// the desktop and which renderer we're using
const VariantList& items = instance().frameBuffer().supportedTIAZoomLevels();
myTIAZoom->addItems(items);
myTIAZoom->setSelected(instance().settings().getString("tia.zoom"), "3");
myTIAZoom->setMaxValue(instance().frameBuffer().supportedTIAMaxZoom() * 100);
myTIAZoom->setTickmarkIntervals((instance().frameBuffer().supportedTIAMaxZoom() - 2) * 2);
myTIAZoom->setValue(instance().settings().getFloat("tia.zoom") * 100);
// TIA Palette
myTIAPalette->setSelected(
@ -417,9 +411,8 @@ void VideoDialog::saveConfig()
instance().settings().setValue("video",
myRenderer->getSelectedTag().toString());
// TIA Filter
instance().settings().setValue("tia.zoom",
myTIAZoom->getSelectedTag().toString());
// TIA zoom levels
instance().settings().setValue("tia.zoom", myTIAZoom->getValue() / 100.0);
// TIA Palette
instance().settings().setValue("palette",
@ -502,7 +495,7 @@ void VideoDialog::setDefaults()
case 0: // General
{
myRenderer->setSelectedIndex(0);
myTIAZoom->setSelected("3", "");
myTIAZoom->setValue(300);
myTIAPalette->setSelected("standard", "");
myTIAInterpolate->setState(false);
myNAspectRatio->setValue(91);

View File

@ -55,7 +55,7 @@ class VideoDialog : public Dialog
// General options
PopUpWidget* myRenderer;
PopUpWidget* myTIAZoom; // TODO: SliderWidget
SliderWidget* myTIAZoom;
PopUpWidget* myTIAPalette;
CheckboxWidget* myTIAInterpolate;
SliderWidget* myNAspectRatio;