Fixes, properly handle TV format any ystart changes from GUI.

This commit is contained in:
Christian Speckner 2018-09-09 23:30:20 +02:00
parent ab0e4d6bba
commit e129391dbd
9 changed files with 46 additions and 17 deletions

View File

@ -216,7 +216,7 @@ Console::~Console()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::autodetectFrameLayout()
void Console::autodetectFrameLayout(bool reset)
{
// Run the TIA, looking for PAL scanline patterns
// We turn off the SuperCharger progress bars, otherwise the SC BIOS
@ -227,7 +227,8 @@ void Console::autodetectFrameLayout()
FrameLayoutDetector frameLayoutDetector;
myTIA->setFrameManager(&frameLayoutDetector);
mySystem->reset(true);
if (reset) mySystem->reset(true);
for(int i = 0; i < 60; ++i) myTIA->update();
@ -247,7 +248,7 @@ void Console::redetectFrameLayout()
myOSystem.sound().close();
save(s);
autodetectFrameLayout();
autodetectFrameLayout(false);
if (myYStartAutodetected) autodetectYStart();
load(s);
@ -255,7 +256,7 @@ void Console::redetectFrameLayout()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::autodetectYStart()
void Console::autodetectYStart(bool reset)
{
// We turn off the SuperCharger progress bars, otherwise the SC BIOS
// will take over 250 frames!
@ -266,7 +267,8 @@ void Console::autodetectYStart()
YStartDetector ystartDetector;
ystartDetector.setLayout(myDisplayFormat == "PAL" ? FrameLayout::pal : FrameLayout::ntsc);
myTIA->setFrameManager(&ystartDetector);
mySystem->reset(true);
if (reset) mySystem->reset(true);
for (int i = 0; i < 80; i++) myTIA->update();
@ -288,7 +290,7 @@ void Console::redetectYStart()
myOSystem.sound().close();
save(s);
autodetectYStart();
autodetectYStart(false);
load(s);
initializeAudio();
@ -718,6 +720,20 @@ void Console::changeYStart(int direction)
myTIA->frameReset();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::updateYStart(uInt32 ystart)
{
if (ystart == TIAConstants::minYStart-1 && !myYStartAutodetected) {
redetectYStart();
ystart = myAutodetectedYstart;
} else if (ystart <= TIAConstants::maxYStart) myYStartAutodetected = false;
if (ystart <= TIAConstants::maxYStart) {
myTIA->setYStart(ystart);
myTIA->frameReset();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::changeHeight(int direction)
{

View File

@ -304,16 +304,21 @@ class Console : public Serializable
*/
void toggleJitter() const;
/**
* Update yatart and run autodetection if necessary.
*/
void updateYStart(uInt32 ystart);
private:
/**
* Dry-run the emulation and detect the frame layout (PAL / NTSC).
*/
void autodetectFrameLayout();
void autodetectFrameLayout(bool reset = true);
/**
* Dryrun the emulation and detect ystart (the first visible scanline).
*/
void autodetectYStart();
void autodetectYStart(bool reset = true);
/**
* Rerun frame layout autodetection

View File

@ -24,7 +24,6 @@ AbstractFrameManager::AbstractFrameManager() :
myOnFrameComplete(nullptr)
{
layout(FrameLayout::ntsc);
reset();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -42,6 +42,12 @@ FrameLayout FrameLayoutDetector::detectedLayout() const{
return myPalFrames > myNtscFrames ? FrameLayout::pal : FrameLayout::ntsc;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FrameLayoutDetector::FrameLayoutDetector()
{
reset();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameLayoutDetector::onReset()
{

View File

@ -28,7 +28,7 @@
class FrameLayoutDetector: public AbstractFrameManager {
public:
FrameLayoutDetector() = default;
FrameLayoutDetector();
public:

View File

@ -49,6 +49,7 @@ FrameManager::FrameManager()
myYStart(0),
myJitterEnabled(false)
{
reset();
onLayoutChange();
}

View File

@ -46,6 +46,12 @@ enum Metrics: uInt32 {
initialGarbageFrames = TIAConstants::initialGarbageFrames
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
YStartDetector::YStartDetector()
{
reset();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 YStartDetector::detectedYStart() const
{

View File

@ -28,7 +28,7 @@ class YStartDetector: public AbstractFrameManager {
public:
YStartDetector() = default;
YStartDetector();
public:

View File

@ -560,12 +560,8 @@ void GameInfoDialog::saveConfig()
// update 'Display' tab settings immediately
bool reset = false;
instance().console().setFormat(myFormat->getSelected());
if(uInt32(myYStart->getValue()) != TIAConstants::minYStart - 1 &&
uInt32(myYStart->getValue()) != instance().console().tia().ystart())
{
instance().console().tia().setYStart(myYStart->getValue());
reset = true;
}
instance().console().updateYStart(myYStart->getValue());
if(uInt32(myHeight->getValue()) != TIAConstants::minViewableHeight - 1 &&
uInt32(myHeight->getValue()) != instance().console().tia().height())
{