refactor v-size

This commit is contained in:
thrust26 2020-01-13 21:13:55 +01:00
parent 6c691c91b8
commit fbfccfbec6
12 changed files with 126 additions and 82 deletions

View File

@ -1525,13 +1525,13 @@
</tr>
<tr>
<td>Move display <i>up</i> (uses "Display.YStart")</td>
<td>Move display <i>up</i> (uses "Display.VCenter")</td>
<td>Alt + PageUp</td>
<td>Cmd + PageUp</td>
</tr>
<tr>
<td>Move display <i>down</i> (uses "Display.YStart")</td>
<td>Move display <i>down</i> (uses "Display.VCenter")</td>
<td>Alt + PageDown</td>
<td>Cmd + PageDown</td>
</tr>
@ -2004,18 +2004,15 @@
</tr>
<tr>
<td><pre>-tia.inter &lt;1|0&gt;</pre></td>
<td>Use interpolation for the TIA image (results in blending/smoothing
of the image).</td>
<td><pre>-tia.vsizeadjust &lt;-5 - 5&gt;</pre></td>
<td>Adjust the display height of the TIA image
</td>
</tr>
<tr>
<td><pre>-tia.aspectn &lt;number&gt;<br>-tia.aspectp &lt;number&gt;</pre></td>
<td>Specify the amount (as a percentage) to scale the
TIA image width in NTSC and PAL mode. Since many video modes do not
use square pixels, you can reduce width until the pixels appear square.
Allowable values are 80 - 120; I find 85 - 90 gives the most authentic
look for NTSC, and 105 - 110 for PAL.</td>
<td><pre>-tia.inter &lt;1|0&gt;</pre></td>
<td>Use interpolation for the TIA image (results in blending/smoothing
of the image).</td>
</tr>
<tr>
@ -2572,8 +2569,8 @@
</tr>
<tr>
<td><pre>-ystart &lt;number&gt;</pre></td>
<td>Set "Display.YStart" property (0 - 64).</td>
<td><pre>-vcenter &lt;number&gt;</pre></td>
<td>Set "Display.VCenter" property (-5..5).</td>
</tr>
<tr>
@ -2717,15 +2714,14 @@
<tr><td>Renderer</td><td>Use specified rendering mode</td><td>-video</td></tr>
<tr><td>TIA palette</td><td>Palette for emulation mode</td><td>-palette</td></tr>
<tr><td>TIA interpolation</td><td>Interpolation for TIA image</td><td>-tia.inter</td></tr>
<tr><td>TIA zoom</td><td>Zoom level for emulation mode </td><td>-tia.zoom</td></tr>
<tr><td>NTSC aspect</td><td>Width of TIA image in NTSC mode</td><td>-tia.aspectn</td></tr>
<tr><td>PAL aspect</td><td>Width of TIA image in PAL mode</td><td>-tia.aspectp</td></tr>
<tr><td>TIA zoom</td><td>Zoom level for emulation mode </td><td>-tia.zoom</td></tr>
<tr><td>V-Size adjust</td><td>Adjust height of TIA image</td><td>-tia.vsizeadjust</td></tr>
<tr><td>Emul. speed</td><td>Emulation speed</td><td>-speed</td></tr>
<tr><td>VSync</td><td>Enable vertical synced updates</td><td>-vsync</td></tr>
<tr><td>VSync</td><td>Enable vertical synced updates</td><td>-vsync</td></tr>
<tr><td>Fullscreen</td><td>Self-explanatory - Note that colors may slightly change.
This depends on the OS and renderer used.</td><td>-fullscreen</td></tr>
<tr><td>Stretch</td><td>In fullscreen mode, completely fill screen with TIA image</td><td>-tia.fs_stretch</td></tr>
<tr><td>Overscan</td><td>In fullscreen mode, add overscan to the TIA image</td><td>-tia.fs_overscan</td></tr>
<tr><td>Overscan</td><td>In fullscreen mode, add overscan to the TIA image</td><td>-tia.fs_overscan</td></tr>
<tr><td>Fast SuperCharger load</td><td>Skip progress loading bars for SuperCharger ROMs</td><td>-fastscbios</td></tr>
<tr><td>Show UI messages</td><td>Overlay UI messages onscreen</td><td>-uimessages</td></tr>
<tr><td>Center window</td><td>Attempt to center application windows, else position at last position</td><td>-center</td></tr>
@ -3749,9 +3745,9 @@ Ms Pac-Man (Stella extended codes):
</tr>
<tr>
<td VALIGN="TOP"><i>Display.YStart:</i></td>
<td>Indicates the scan-line to start displaying at.
The value must be <i>n</i> such that 0 &lt;= <i>n</i> &lt;= 64.
<td VALIGN="TOP"><i>Display.VCenter:</i></td>
<td>Indicates the offset for the vertical center of the display.
The value must be <i>n</i> such that -5 &lt;= <i>n</i> &lt;= 5.
</td>
</tr>

View File

@ -399,6 +399,7 @@ PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultCommo
{Event::ConsoleReset, KBDK_F2},
{Event::ConsoleColor, KBDK_F3},
{Event::ConsoleBlackWhite, KBDK_F4},
{Event::Console7800Pause, KBDK_F3, MOD3},
{Event::ConsoleLeftDiffA, KBDK_F5},
{Event::ConsoleLeftDiffB, KBDK_F6},
{Event::ConsoleRightDiffA, KBDK_F7},

View File

@ -668,7 +668,11 @@ void Console::changeVerticalCenter(int direction)
if (vcenter != myTIA->vcenter()) myTIA->setVcenter(vcenter);
ss.str("");
ss << "V-Center " << (vcenter > 0 ? "+" : "") << vcenter;
ss << "V-Center ";
if (!vcenter)
ss << "default";
else
ss << (vcenter > 0 ? "+" : "") << vcenter << "px";
myOSystem.frameBuffer().showMessage(ss.str());
}
@ -685,24 +689,44 @@ void Console::updateVcenter(Int32 vcenter)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::changeScanlineAdjust(int direction)
{
float newVsizeAdjust = myTIA->vsizeAdjust();
Int32 newAdjustVSize = myTIA->adjustVSize();;
if (direction != -1 && direction != +1) return;
if(direction == +1) // increase scanline adjustment
{
newVsizeAdjust = std::min(myTIA->vsizeAdjust() + 0.5f, 5.f);
if (newAdjustVSize >= 5)
{
myOSystem.frameBuffer().showMessage("V-Size at maximum");
return;
}
newAdjustVSize++;
}
else if(direction == -1) // decrease scanline adjustment
{
newVsizeAdjust = std::max(myTIA->vsizeAdjust() - 0.5f, -5.f);
if (newAdjustVSize <= -5)
{
myOSystem.frameBuffer().showMessage("V-Size at minimum");
return;
}
newAdjustVSize--;
}
if (newVsizeAdjust != myTIA->vsizeAdjust()) {
myTIA->setVsizeAdjust(newVsizeAdjust);
myOSystem.settings().setValue("tia.vsizeadjust", newVsizeAdjust);
if (newAdjustVSize != myTIA->adjustVSize()) {
myTIA->setAdjustVSize(newAdjustVSize);
myOSystem.settings().setValue("tia.vsizeadjust", newAdjustVSize);
initializeVideo();
}
ostringstream ss;
ss << "V-Size ";
if (!newAdjustVSize)
ss << "default";
else
ss << (newAdjustVSize > 0 ? "+" : "") << newAdjustVSize << "%";
myOSystem.frameBuffer().showMessage(ss.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -724,7 +748,7 @@ void Console::setTIAProperties()
myTIA->setLayout(FrameLayout::pal);
}
myTIA->setVsizeAdjust(myOSystem.settings().getFloat("tia.vsizeadjust"));
myTIA->setAdjustVSize(myOSystem.settings().getInt("tia.vsizeadjust"));
myTIA->setVcenter(vcenter);
myEmulationTiming.updateFrameLayout(myTIA->frameLayout());

View File

@ -119,6 +119,8 @@ class Event
ToggleFrameStats, ToggleSAPortOrder,
// add new events from here to avoid that user remapped events get overwritten
LastType
};
@ -131,7 +133,7 @@ class Event
LastGroup
};
// Event list version, update if the id of existing event types changed
// Event list version, update only if the id of existing(!) event types changed
static constexpr Int32 VERSION = 2;
using EventSet = std::set<Event::Type>;

View File

@ -50,7 +50,7 @@ Settings::Settings()
// TIA specific options
setPermanent("tia.zoom", "3");
setPermanent("tia.inter", "false");
setPermanent("tia.vsizeadjust", 0.f);
setPermanent("tia.vsizeadjust", 0);
setPermanent("fullscreen", "false");
setPermanent("tia.fs_stretch", "false");
setPermanent("tia.fs_overscan", "0");
@ -254,8 +254,8 @@ void Settings::validate()
f = getFloat("speed");
if (f <= 0) setValue("speed", "1.0");
i = getFloat("tia.vsizeadjust");
if(i < -5. || i > 5.) setValue("tia.vsizeadjust", 0.f);
i = getInt("tia.vsizeadjust");
if(i < -5 || i > 5) setValue("tia.vsizeadjust", 0);
s = getString("tia.dbgcolors");
sort(s.begin(), s.end());
@ -403,14 +403,14 @@ void Settings::usage() const
<< " -audio.stereo <1|0> Enable stereo mode for all ROMs\n"
<< endl
#endif
<< " -tia.zoom <zoom> Use the specified zoom level (windowed mode)\n"
<< " -tia.zoom <zoom> Use the specified zoom level (windowed mode)\n"
<< " for TIA image\n"
<< " -tia.inter <1|0> Enable interpolated (smooth) scaling for TIA\n"
<< " -tia.vsizeadjust <-5..5> Adjust the vertical display size [percent]\n"
<< " -tia.inter <1|0> Enable interpolated (smooth) scaling for TIA\n"
<< " image\n"
<< " -tia.vsizeadjust <float> Adjust the vertical range of the image [percent]\n"
<< " -tia.fs_stretch <1|0> Stretch TIA image to fill fullscreen mode\n"
<< " -tia.fs_stretch <1|0> Stretch TIA image to fill fullscreen mode\n"
<< " -tia.fs_overscan <0-10> Add overscan to TIA image in fill fullscreen mode\n"
<< " -tia.dbgcolors <string> Debug colors to use for each object (see manual\n"
<< " -tia.dbgcolors <string> Debug colors to use for each object (see manual\n"
<< " for description)\n"
<< endl
<< " -tv.filter <0-5> Set TV effects off (0) or to specified mode\n"

View File

@ -264,8 +264,8 @@ class TIA : public Device
void setLayout(FrameLayout layout) { myFrameManager->setLayout(layout); }
FrameLayout frameLayout() const { return myFrameManager->layout(); }
void setVsizeAdjust(float vsizeAdjust) { myFrameManager->setVsizeAdjust(vsizeAdjust); }
float vsizeAdjust() const { return myFrameManager->vsizeAdjust(); }
void setAdjustVSize(Int32 adjustVSize) { myFrameManager->setAdjustVSize(adjustVSize); }
Int32 adjustVSize() const { return myFrameManager->adjustVSize(); }
/**
Enables/disables color-loss for PAL modes only.

View File

@ -181,9 +181,9 @@ class AbstractFrameManager : public Serializable
virtual Int32 maxVcenter() const { return 0; }
virtual void setVsizeAdjust(float vsizeAdjust) {}
virtual void setAdjustVSize(Int32 adjustVSize) {}
virtual float vsizeAdjust() const { return 0; }
virtual Int32 adjustVSize() const { return 0; }
/**
* The corresponding start line.

View File

@ -121,9 +121,9 @@ void FrameManager::setVcenter(Int32 vcenter)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameManager::setVsizeAdjust(float vsizeAdjust)
void FrameManager::setAdjustVSize(Int32 adjustVSize)
{
myVsizeAdjust = vsizeAdjust;
myVSizeAdjust = adjustVSize;
recalculateMetrics();
}
@ -244,10 +244,12 @@ void FrameManager::recalculateMetrics() {
throw runtime_error("frame manager: invalid TV mode");
}
myHeight = BSPF::clamp<uInt32>(round(static_cast<float>(baseHeight) * (1.f + myVsizeAdjust / 100.f)), 0, myFrameLines);
myHeight = BSPF::clamp<uInt32>(round(static_cast<float>(baseHeight) * (1.f - myVSizeAdjust / 100.f)), 0, myFrameLines);
myYStart = BSPF::clamp<uInt32>(ystartBase + (baseHeight - static_cast<Int32>(myHeight)) / 2 - myVcenter, 0, myFrameLines);
// TODO: why "- 1" here: ???
myMaxVcenter = BSPF::clamp<Int32>(ystartBase + (baseHeight - static_cast<Int32>(myHeight)) / 2 - 1, 0, TIAConstants::maxVcenter);
//cout << "myVSizeAdjust " << myVSizeAdjust << " " << myHeight << endl << std::flush;
myJitterEmulation.setYStart(myYStart);
}

View File

@ -52,9 +52,9 @@ class FrameManager: public AbstractFrameManager {
Int32 maxVcenter() const override { return myMaxVcenter; }
void setVsizeAdjust(float vsizeAdjust) override;
void setAdjustVSize(Int32 adjustVSize) override;
float vsizeAdjust() const override { return myVsizeAdjust; }
Int32 adjustVSize() const override { return myVSizeAdjust; }
uInt32 startLine() const override { return myYStart; }
@ -102,7 +102,7 @@ class FrameManager: public AbstractFrameManager {
uInt32 myYStart{0};
Int32 myVcenter{0};
Int32 myMaxVcenter{0};
float myVsizeAdjust{0.f};
Int32 myVSizeAdjust{0};
bool myJitterEnabled{false};

View File

@ -86,7 +86,7 @@ VideoDialog::VideoDialog(OSystem& osystem, DialogContainer& parent,
fontWidth = font.getMaxCharWidth(),
buttonHeight = font.getLineHeight() + 4;
int xpos, ypos, tabID;
int lwidth = font.getStringWidth("NTSC scanlines adjust "),
int lwidth = font.getStringWidth("V-Size adjust "),
pwidth = font.getStringWidth("XXXXxXXXX"),
swidth = font.getMaxCharWidth() * 10 - 2;
@ -94,7 +94,7 @@ VideoDialog::VideoDialog(OSystem& osystem, DialogContainer& parent,
VariantList items;
// Set real dimensions
setSize(65 * fontWidth + HBORDER * 2, 14 * (lineHeight + VGAP) + 14 + _th, max_w, max_h);
setSize(60 * fontWidth + HBORDER * 2, 14 * (lineHeight + VGAP) + 14 + _th, max_w, max_h);
// The tab widget
xpos = 2; ypos = 4;
@ -136,12 +136,12 @@ VideoDialog::VideoDialog(OSystem& osystem, DialogContainer& parent,
ypos += lineHeight + VGAP;
// Aspect ratio (NTSC mode)
myVsizeAdjust =
myVSizeAdjust =
new SliderWidget(myTab, font, xpos, ypos-1, swidth, lineHeight,
"V-Size adjust ", lwidth, 0, fontWidth * 4, "", 0, true);
myVsizeAdjust->setMinValue(-50); myVsizeAdjust->setMaxValue(50);
myVsizeAdjust->setTickmarkIntervals(5);
wid.push_back(myVsizeAdjust);
"V-Size adjust", lwidth, kVSizeChanged, fontWidth * 7, "%", 0, true);
myVSizeAdjust->setMinValue(-5); myVSizeAdjust->setMaxValue(5);
myVSizeAdjust->setTickmarkIntervals(2);
wid.push_back(myVSizeAdjust);
ypos += lineHeight + VGAP;
// Speed
@ -159,7 +159,7 @@ VideoDialog::VideoDialog(OSystem& osystem, DialogContainer& parent,
wid.push_back(myUseVSync);
// Move over to the next column
xpos += mySpeed->getWidth() + 28;
xpos += mySpeed->getWidth() + 44;
ypos = VBORDER;
// Fullscreen
@ -342,9 +342,7 @@ void VideoDialog::loadConfig()
myTIAInterpolate->setState(instance().settings().getBool("tia.inter"));
// Aspect ratio setting (NTSC and PAL)
myVsizeAdjust->setValue(
round(instance().settings().getFloat("tia.vsizeadjust") * 10)
);
myVSizeAdjust->setValue(instance().settings().getInt("tia.vsizeadjust"));
// Emulation speed
int speed = mapSpeed(instance().settings().getFloat("speed"));
@ -403,22 +401,24 @@ void VideoDialog::saveConfig()
{
// Renderer setting
instance().settings().setValue("video",
myRenderer->getSelectedTag().toString());
myRenderer->getSelectedTag().toString());
// TIA zoom levels
instance().settings().setValue("tia.zoom", myTIAZoom->getValue() / 100.0);
// TIA Palette
instance().settings().setValue("palette",
myTIAPalette->getSelectedTag().toString());
myTIAPalette->getSelectedTag().toString());
// TIA interpolation
instance().settings().setValue("tia.inter", myTIAInterpolate->getState());
// Aspect ratio setting (NTSC and PAL)
instance().settings().setValue("tia.vsizeadjust",
static_cast<float>(myVsizeAdjust->getValue()) / 10.f
);
int oldAdjust = instance().settings().getInt("tia.vsizeadjust");
int newAdjust = myVSizeAdjust->getValue();
bool initializeVideo = oldAdjust != newAdjust;
instance().settings().setValue("tia.vsizeadjust", newAdjust);
// Speed
int speedup = mySpeed->getValue();
@ -427,8 +427,6 @@ void VideoDialog::saveConfig()
// Fullscreen
instance().settings().setValue("fullscreen", myFullscreen->getState());
/*instance().settings().setValue("fullscreenmode",
myFullScreenMode->getSelectedTag().toString());*/
// Fullscreen stretch setting
instance().settings().setValue("tia.fs_stretch", myUseStretch->getState());
// Fullscreen overscan
@ -448,25 +446,25 @@ void VideoDialog::saveConfig()
// Multi-threaded rendering
instance().settings().setValue("threads", myUseThreads->getState());
if(instance().hasConsole())
if (instance().hasConsole())
instance().frameBuffer().tiaSurface().ntsc().enableThreading(myUseThreads->getState());
// TV Mode
instance().settings().setValue("tv.filter",
myTVMode->getSelectedTag().toString());
myTVMode->getSelectedTag().toString());
// TV Custom adjustables
NTSCFilter::Adjustable adj;
adj.hue = myTVHue->getValue();
adj.saturation = myTVSatur->getValue();
adj.contrast = myTVContrast->getValue();
adj.brightness = myTVBright->getValue();
adj.sharpness = myTVSharp->getValue();
adj.gamma = myTVGamma->getValue();
adj.resolution = myTVRes->getValue();
adj.artifacts = myTVArtifacts->getValue();
adj.fringing = myTVFringe->getValue();
adj.bleed = myTVBleed->getValue();
adj.hue = myTVHue->getValue();
adj.saturation = myTVSatur->getValue();
adj.contrast = myTVContrast->getValue();
adj.brightness = myTVBright->getValue();
adj.sharpness = myTVSharp->getValue();
adj.gamma = myTVGamma->getValue();
adj.resolution = myTVRes->getValue();
adj.artifacts = myTVArtifacts->getValue();
adj.fringing = myTVFringe->getValue();
adj.bleed = myTVBleed->getValue();
instance().frameBuffer().tiaSurface().ntsc().setCustomAdjustables(adj);
// TV phosphor mode
@ -478,7 +476,13 @@ void VideoDialog::saveConfig()
// TV scanline intensity
instance().settings().setValue("tv.scanlines", myTVScanIntense->getValueLabel());
if (&instance().console()) instance().console().setTIAProperties();
if (instance().hasConsole())
{
instance().console().setTIAProperties();
// TODO: display the new screen (currently all blank)
if (initializeVideo)
instance().console().initializeVideo();
}
// Finally, issue a complete framebuffer re-initialization...
instance().createFrameBuffer();
@ -498,7 +502,7 @@ void VideoDialog::setDefaults()
myTIAZoom->setValue(300);
myTIAPalette->setSelected("standard", "");
myTIAInterpolate->setState(false);
myVsizeAdjust->setValue(0);
myVSizeAdjust->setValue(0);
mySpeed->setValue(0);
myFullscreen->setState(false);
@ -615,6 +619,20 @@ void VideoDialog::handleCommand(CommandSender* sender, int cmd,
setDefaults();
break;
case kVSizeChanged:
{
int adjust = myVSizeAdjust->getValue();
if (!adjust)
{
myVSizeAdjust->setValueLabel("Default");
myVSizeAdjust->setValueUnit("");
}
else
myVSizeAdjust->setValueUnit("%");
break;
}
case kSpeedupChanged:
mySpeed->setValueLabel(formatSpeed(mySpeed->getValue()));
break;

View File

@ -58,7 +58,7 @@ class VideoDialog : public Dialog
SliderWidget* myTIAZoom{nullptr};
PopUpWidget* myTIAPalette{nullptr};
CheckboxWidget* myTIAInterpolate{nullptr};
SliderWidget* myVsizeAdjust{nullptr};
SliderWidget* myVSizeAdjust{nullptr};
SliderWidget* mySpeed{nullptr};
CheckboxWidget* myFullscreen{nullptr};
@ -101,6 +101,7 @@ class VideoDialog : public Dialog
enum {
kSpeedupChanged = 'VDSp',
kVSizeChanged = 'VDVs',
kFullScreenChanged = 'VDFs',
kOverscanChanged = 'VDOv',

View File

@ -89,8 +89,8 @@ bool StellaLIBRETRO::create(bool logging)
settings.setValue("palette", video_palette);
settings.setValue("tia.zoom", 1);
settings.setValue("tia.vsizeadjust", 0);
settings.setValue("tia.inter", false);
settings.setValue("tia.vsizeadjust", 0.f);
//fastscbios
// Fast loading of Supercharger BIOS