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

View File

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

View File

@ -178,7 +178,7 @@ void TIA::reset()
if (myFrameManager) if (myFrameManager)
{ {
myFrameManager->reset(); myFrameManager->reset();
enableColorLoss(mySettings.getBool(mySettings.getBool("dev.settings") ? "dev.colorloss" : "plr.colorloss")); frameReset(); // Recalculate the size of the display
} }
myFrontBufferScanlines = myFrameBufferScanlines = 0; myFrontBufferScanlines = myFrameBufferScanlines = 0;
@ -189,16 +189,20 @@ void TIA::reset()
enableFixedColors(mySettings.getBool(mySettings.getBool("dev.settings") ? "dev.debugcolors" : "plr.debugcolors")); enableFixedColors(mySettings.getBool(mySettings.getBool("dev.settings") ? "dev.debugcolors" : "plr.debugcolors"));
setFixedColorPalette(mySettings.getString("tia.dbgcolors")); 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 #ifdef DEBUGGER_SUPPORT
createAccessBase(); createAccessBase();
#endif // DEBUGGER_SUPPORT #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) void TIA::install(System& system)
{ {

View File

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

View File

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