Another pass at resolving ystart issues. Reverts 02b0c13a and b9bbbe1 .

This commit is contained in:
Christian Speckner 2018-09-17 00:23:06 +02:00
parent 31f6dba87d
commit 888556b124
5 changed files with 66 additions and 72 deletions

View File

@ -87,6 +87,7 @@ Console::Console(OSystem& osystem, unique_ptr<Cartridge>& cart,
myCurrentFormat(0), // Unknown format @ start,
myAutodetectedYstart(0),
myYStartAutodetected(false),
myFormatAutodetected(false),
myUserPaletteDefined(false),
myConsoleTiming(ConsoleTiming::ntsc),
myAudioSettings(audioSettings)
@ -143,6 +144,7 @@ Console::Console(OSystem& osystem, unique_ptr<Cartridge>& cart,
{
autodetected = "*";
myCurrentFormat = 0;
myFormatAutodetected = true;
}
}
@ -284,8 +286,6 @@ void Console::autodetectYStart(bool reset)
// Don't forget to reset the SC progress bars again
myOSystem.settings().setValue("fastscbios", fastscbios);
myYStartAutodetected = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -370,17 +370,17 @@ void Console::setFormat(uInt32 format)
string saveformat, message;
string autodetected = "";
bool reset = true;
myCurrentFormat = format;
switch(myCurrentFormat)
{
case 0: // auto-detect
{
if (myFormatAutodetected) return;
string oldDisplayFormat = myDisplayFormat;
redetectFrameLayout();
myTIA->update();
reset = oldDisplayFormat != myDisplayFormat;
myFormatAutodetected = true;
saveformat = "AUTO";
autodetected = "*";
myConsoleTiming = myDisplayFormat == "PAL" ? ConsoleTiming::pal : ConsoleTiming::ntsc;
@ -391,45 +391,48 @@ void Console::setFormat(uInt32 format)
saveformat = myDisplayFormat = "NTSC";
myConsoleTiming = ConsoleTiming::ntsc;
message = "NTSC mode";
myFormatAutodetected = false;
break;
case 2:
saveformat = myDisplayFormat = "PAL";
myConsoleTiming = ConsoleTiming::pal;
message = "PAL mode";
myFormatAutodetected = false;
break;
case 3:
saveformat = myDisplayFormat = "SECAM";
myConsoleTiming = ConsoleTiming::secam;
message = "SECAM mode";
myFormatAutodetected = false;
break;
case 4:
saveformat = myDisplayFormat = "NTSC50";
myConsoleTiming = ConsoleTiming::ntsc;
message = "NTSC50 mode";
myFormatAutodetected = false;
break;
case 5:
saveformat = myDisplayFormat = "PAL60";
myConsoleTiming = ConsoleTiming::pal;
message = "PAL60 mode";
myFormatAutodetected = false;
break;
case 6:
saveformat = myDisplayFormat = "SECAM60";
myConsoleTiming = ConsoleTiming::secam;
message = "SECAM60 mode";
myFormatAutodetected = false;
break;
}
myProperties.set(Display_Format, saveformat);
myConsoleInfo.DisplayFormat = myDisplayFormat + autodetected;
if(reset)
{
setPalette(myOSystem.settings().getString("palette"));
setTIAProperties();
initializeVideo(); // takes care of refreshing the screen
initializeAudio(); // ensure that audio synthesis is set up to match emulation speed
myOSystem.resetFps(); // Reset FPS measurement
}
myOSystem.frameBuffer().showMessage(message);
@ -696,31 +699,28 @@ void Console::changeYStart(int direction)
else
return;
ostringstream val;
val << ystart;
if(ystart == 0) {
redetectYStart();
ystart = myAutodetectedYstart;
myYStartAutodetected = true;
myOSystem.frameBuffer().showMessage("YStart autodetected");
myProperties.set(Display_YStart, "0");
}
else
{
if(myAutodetectedYstart > 0 && myAutodetectedYstart == ystart)
{
// We've reached the auto-detect value, so reset
myOSystem.frameBuffer().showMessage("YStart " + val.str() + " (Auto)");
val.str("");
val << static_cast<int>(0);
}
else
myOSystem.frameBuffer().showMessage("YStart " + val.str());
else {
ostringstream ss;
ss << ystart;
myYStartAutodetected = false;
myProperties.set(Display_YStart, ss.str());
}
myProperties.set(Display_YStart, val.str());
myTIA->setYStart(ystart);
if (ystart != myTIA->ystart()) myTIA->setYStart(ystart);
ostringstream ss;
if(myAutodetectedYstart == ystart) ss << "YStart " << ystart << " (Auto)";
else ss << "YStart " << ystart;
myOSystem.frameBuffer().showMessage(ss.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -728,20 +728,15 @@ void Console::updateYStart(uInt32 ystart)
{
if (ystart > TIAConstants::maxYStart) return;
ostringstream ss;
ss << ystart;
if (ss.str() == myProperties.get(Display_YStart)) return;
myProperties.set(Display_YStart, ss.str());
if (ystart == 0) {
if (myYStartAutodetected) return;
redetectYStart();
myTIA->setYStart(myAutodetectedYstart);
} else {
myTIA->setYStart(ystart);
myYStartAutodetected = false;
myYStartAutodetected = true;
ystart = myAutodetectedYstart;
}
if (ystart != myTIA->ystart()) myTIA->setYStart(ystart);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -782,6 +777,11 @@ void Console::setTIAProperties()
uInt32 ystart = atoi(myProperties.get(Display_YStart).c_str());
if(ystart != 0)
ystart = BSPF::clamp(ystart, 0u, TIAConstants::maxYStart);
else {
ystart = myAutodetectedYstart;
myYStartAutodetected = true;
}
uInt32 height = atoi(myProperties.get(Display_Height).c_str());
if(height != 0)
height = BSPF::clamp(height, TIAConstants::minViewableHeight, TIAConstants::maxViewableHeight);
@ -801,7 +801,7 @@ void Console::setTIAProperties()
myTIA->setLayout(FrameLayout::pal);
}
myTIA->setYStart(myAutodetectedYstart ? myAutodetectedYstart : ystart);
myTIA->setYStart(ystart);
myTIA->setHeight(height);
myEmulationTiming.updateFrameLayout(myTIA->frameLayout());

View File

@ -420,6 +420,9 @@ class Console : public Serializable
// Is ystart currently autodetected?
bool myYStartAutodetected;
// Is the TV format autodetected?
bool myFormatAutodetected;
// Indicates whether an external palette was found and
// successfully loaded
bool myUserPaletteDefined;

View File

@ -178,7 +178,7 @@ void TIA::reset()
if (myFrameManager)
{
myFrameManager->reset();
enableColorLoss(mySettings.getBool(mySettings.getBool("dev.settings") ? "dev.colorloss" : "plr.colorloss"));
frameReset(); // Recalculate the size of the display
}
myFrontBufferScanlines = myFrameBufferScanlines = 0;
@ -189,16 +189,20 @@ void TIA::reset()
enableFixedColors(mySettings.getBool(mySettings.getBool("dev.settings") ? "dev.debugcolors" : "plr.debugcolors"));
setFixedColorPalette(mySettings.getString("tia.dbgcolors"));
// Blank the various framebuffers; they may contain graphical garbage
memset(myBackBuffer, 0, 160 * TIAConstants::frameBufferHeight);
memset(myFrontBuffer, 0, 160 * TIAConstants::frameBufferHeight);
memset(myFramebuffer, 0, 160 * TIAConstants::frameBufferHeight);
#ifdef DEBUGGER_SUPPORT
createAccessBase();
#endif // DEBUGGER_SUPPORT
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::frameReset()
{
memset(myBackBuffer, 0, 160 * TIAConstants::frameBufferHeight);
memset(myFrontBuffer, 0, 160 * TIAConstants::frameBufferHeight);
memset(myFramebuffer, 0, 160 * TIAConstants::frameBufferHeight);
enableColorLoss(mySettings.getBool(mySettings.getBool("dev.settings") ? "dev.colorloss" : "plr.colorloss"));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIA::install(System& system)
{

View File

@ -136,6 +136,11 @@ class TIA : public Device
*/
void reset() override;
/**
Reset frame to current YStart/Height properties.
*/
void frameReset();
/**
Install TIA in the specified system. Invoked by the system
when the TIA is attached to it.
@ -249,7 +254,7 @@ class TIA : public Device
/**
Changes the current Height/YStart properties.
Note that calls to these method(s) must be eventually followed by
::reset() for the changes to take effect.
::frameReset() for the changes to take effect.
*/
void setHeight(uInt32 height) { myFrameManager->setFixedHeight(height); }
void setYStart(uInt32 ystart) { myFrameManager->setYstart(ystart); }

View File

@ -531,22 +531,18 @@ void GameInfoDialog::saveConfig()
myGameProperties.set(Controller_MouseAxis, mcontrol);
// Display properties
const string& ystart = myGameProperties.get(Display_YStart);
uInt32 oldYStart = atoi(ystart.c_str());
const string& height = myGameProperties.get(Display_Height);
uInt32 oldHeight = atoi(height.c_str());
myGameProperties.set(Display_YStart, myYStart->getValue() == 0 ? "0" : myYStart->getValueLabel());
myGameProperties.set(Display_Format, myFormat->getSelectedTag().toString());
myGameProperties.set(Display_YStart, myYStart->getValueLabel() == "Auto" ? "0" :
myYStart->getValueLabel());
myGameProperties.set(Display_Height, myHeight->getValueLabel() == "Auto" ? "0" :
myHeight->getValueLabel());
myGameProperties.set(Display_Phosphor, myPhosphor->getState() ? "YES" : "NO");
myGameProperties.set(Display_PPBlend, myPPBlend->getValueLabel() == "Default" ? "0" :
myPPBlend->getValueLabel());
// Always insert; if the properties are already present, nothing will happen
instance().propSet().insert(myGameProperties);
instance().saveConfig();
// In any event, inform the Console
if(instance().hasConsole())
@ -563,28 +559,14 @@ void GameInfoDialog::saveConfig()
// update 'Display' tab settings immediately
instance().console().setFormat(myFormat->getSelected());
// only call tia().reset() when values have changed
bool reset = false;
if(uInt32((myYStart->getValue()) != 0 || oldYStart != 0) &&
uInt32(myYStart->getValue()) != instance().console().tia().ystart())
{
instance().console().updateYStart(myYStart->getValue());
reset = true;
}
if(uInt32((myHeight->getValue()) != TIAConstants::minViewableHeight - 1 || oldHeight != 0) &&
if(uInt32(myHeight->getValue()) != TIAConstants::minViewableHeight - 1 &&
uInt32(myHeight->getValue()) != instance().console().tia().height())
{
instance().console().tia().setHeight(myHeight->getValue());
reset = true;
}
instance().frameBuffer().tiaSurface().enablePhosphor(myPhosphor->getState(), myPPBlend->getValue());
if (reset)
instance().console().tia().reset();
// Certain calls above may blank the TIA image (notably, setFormat)
// So we make sure we have a valid image when the dialog exits
instance().console().tia().renderToFrameBuffer();
}
}