diff --git a/.vscode/settings.json b/.vscode/settings.json index 66d6c8112..ee4e3bcc3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -60,6 +60,10 @@ "cstdint": "cpp", "ostream": "cpp", "__memory": "cpp", - "iosfwd": "cpp" + "iosfwd": "cpp", + "__hash_table": "cpp", + "array": "cpp", + "queue": "cpp", + "unordered_map": "cpp" } } diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index c7d132619..c3dd0082e 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -52,6 +52,7 @@ #include "Menu.hxx" #include "CommandMenu.hxx" #include "Serializable.hxx" +#include "Serializer.hxx" #include "Version.hxx" #include "TIAConstants.hxx" #include "FrameLayout.hxx" @@ -85,6 +86,7 @@ Console::Console(OSystem& osystem, unique_ptr& cart, myDisplayFormat(""), // Unknown TV format @ start myCurrentFormat(0), // Unknown format @ start, myAutodetectedYstart(0), + myYStartAutodetected(false), myUserPaletteDefined(false), myConsoleTiming(ConsoleTiming::ntsc), myAudioSettings(audioSettings) @@ -237,6 +239,21 @@ void Console::autodetectFrameLayout() myOSystem.settings().setValue("fastscbios", fastscbios); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Console::redetectFrameLayout() +{ + Serializer s; + + myOSystem.sound().close(); + save(s); + + autodetectFrameLayout(); + if (myYStartAutodetected) autodetectYStart(); + + load(s); + initializeAudio(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Console::autodetectYStart() { @@ -259,6 +276,22 @@ void Console::autodetectYStart() // Don't forget to reset the SC progress bars again myOSystem.settings().setValue("fastscbios", fastscbios); + + myYStartAutodetected = true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Console::redetectYStart() +{ + Serializer s; + + myOSystem.sound().close(); + save(s); + + autodetectYStart(); + + load(s); + initializeAudio(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -337,7 +370,7 @@ void Console::setFormat(uInt32 format) case 0: // auto-detect { string oldDisplayFormat = myDisplayFormat; - autodetectFrameLayout(); + redetectFrameLayout(); myTIA->update(); reset = oldDisplayFormat != myDisplayFormat; saveformat = "AUTO"; @@ -639,15 +672,12 @@ void Console::changeYStart(int direction) myOSystem.frameBuffer().showMessage("YStart at maximum"); return; } + ++ystart; + myYStartAutodetected = false; } else if(direction == -1) // decrease YStart { - if (ystart == TIAConstants::minYStart && myAutodetectedYstart == 0) { - myOSystem.frameBuffer().showMessage("Autodetected YStart not available"); - return; - } - if(ystart == TIAConstants::minYStart-1 && myAutodetectedYstart > 0) { myOSystem.frameBuffer().showMessage("YStart at minimum"); @@ -655,14 +685,19 @@ void Console::changeYStart(int direction) } --ystart; + myYStartAutodetected = false; } else return; ostringstream val; val << ystart; - if(ystart == TIAConstants::minYStart-1) + if(ystart == TIAConstants::minYStart-1) { + redetectYStart(); + ystart = myAutodetectedYstart; + myOSystem.frameBuffer().showMessage("YStart autodetected"); + } else { if(myAutodetectedYstart > 0 && myAutodetectedYstart == ystart) @@ -674,6 +709,8 @@ void Console::changeYStart(int direction) } else myOSystem.frameBuffer().showMessage("YStart " + val.str()); + + myAutodetectedYstart = false; } myProperties.set(Display_YStart, val.str()); @@ -739,7 +776,7 @@ void Console::setTIAProperties() myTIA->setLayout(FrameLayout::pal); } - myTIA->setYStart(ystart != 0 ? ystart : myAutodetectedYstart); + myTIA->setYStart(myAutodetectedYstart ? myAutodetectedYstart : ystart); myTIA->setHeight(height); myEmulationTiming.updateFrameLayout(myTIA->frameLayout()); diff --git a/src/emucore/Console.hxx b/src/emucore/Console.hxx index 5ab23fa84..11166b3ca 100644 --- a/src/emucore/Console.hxx +++ b/src/emucore/Console.hxx @@ -315,6 +315,16 @@ class Console : public Serializable */ void autodetectYStart(); + /** + * Rerun frame layout autodetection + */ + void redetectFrameLayout(); + + /** + * Rerun ystart autodetection. + */ + void redetectYStart(); + /** Sets various properties of the TIA (YStart, Height, etc) based on the current display format. @@ -409,6 +419,9 @@ class Console : public Serializable // Autodetected ystart. uInt32 myAutodetectedYstart; + // Is ystart currently autodetected? + bool myYStartAutodetected; + // Indicates whether an external palette was found and // successfully loaded bool myUserPaletteDefined;