From 2f9fc4f525340a4aecc9b1d58582223342ef290e Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Thu, 13 Sep 2018 23:23:21 +0200 Subject: [PATCH] Bug fixing, harcode min ystart to 0. --- .vscode/settings.json | 5 ++++- src/emucore/Console.cxx | 32 ++++++++++++++++++++------------ src/emucore/tia/TIAConstants.hxx | 2 +- src/gui/GameInfoDialog.cxx | 13 ++++++++----- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index ee4e3bcc3..c00ccb459 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -64,6 +64,9 @@ "__hash_table": "cpp", "array": "cpp", "queue": "cpp", - "unordered_map": "cpp" + "unordered_map": "cpp", + "istream": "cpp", + "thread": "cpp", + "utility": "cpp" } } diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index c79f76780..c937d3e93 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -680,10 +680,9 @@ void Console::changeYStart(int direction) } else if(direction == -1) // decrease YStart { - if(ystart == TIAConstants::minYStart-1 && myAutodetectedYstart > 0) + if(ystart == 0) { - myOSystem.frameBuffer().showMessage("YStart at minimum"); - return; + throw runtime_error("cannot happen"); } --ystart; @@ -694,7 +693,7 @@ void Console::changeYStart(int direction) ostringstream val; val << ystart; - if(ystart == TIAConstants::minYStart-1) { + if(ystart == 0) { redetectYStart(); ystart = myAutodetectedYstart; @@ -707,12 +706,12 @@ void Console::changeYStart(int direction) // We've reached the auto-detect value, so reset myOSystem.frameBuffer().showMessage("YStart " + val.str() + " (Auto)"); val.str(""); - val << TIAConstants::minYStart-1; + val << static_cast(0); } else myOSystem.frameBuffer().showMessage("YStart " + val.str()); - myAutodetectedYstart = false; + myYStartAutodetected = false; } myProperties.set(Display_YStart, val.str()); @@ -723,14 +722,23 @@ void Console::changeYStart(int direction) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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) return; - if (ystart <= TIAConstants::maxYStart) { + ostringstream ss; + ss << ystart; + + if (ss.str() == myProperties.get(Display_YStart)) return; + + myProperties.set(Display_YStart, ss.str()); + + if (ystart == 0) { + redetectYStart(); + myTIA->setYStart(myAutodetectedYstart); + myTIA->frameReset(); + } else { myTIA->setYStart(ystart); myTIA->frameReset(); + myYStartAutodetected = false; } } @@ -772,7 +780,7 @@ void Console::setTIAProperties() { uInt32 ystart = atoi(myProperties.get(Display_YStart).c_str()); if(ystart != 0) - ystart = BSPF::clamp(ystart, TIAConstants::minYStart, TIAConstants::maxYStart); + ystart = BSPF::clamp(ystart, 0u, TIAConstants::maxYStart); uInt32 height = atoi(myProperties.get(Display_Height).c_str()); if(height != 0) height = BSPF::clamp(height, TIAConstants::minViewableHeight, TIAConstants::maxViewableHeight); diff --git a/src/emucore/tia/TIAConstants.hxx b/src/emucore/tia/TIAConstants.hxx index fa98c6b54..8f7d60cf8 100644 --- a/src/emucore/tia/TIAConstants.hxx +++ b/src/emucore/tia/TIAConstants.hxx @@ -23,7 +23,7 @@ namespace TIAConstants { constexpr uInt32 frameBufferHeight = 320; - constexpr uInt32 minYStart = 1, maxYStart = 64; + constexpr uInt32 maxYStart = 64; constexpr uInt32 minViewableHeight = 210, maxViewableHeight = 256; constexpr uInt32 initialGarbageFrames = 10; } diff --git a/src/gui/GameInfoDialog.cxx b/src/gui/GameInfoDialog.cxx index 798ffa941..4aeaf2047 100644 --- a/src/gui/GameInfoDialog.cxx +++ b/src/gui/GameInfoDialog.cxx @@ -307,10 +307,10 @@ GameInfoDialog::GameInfoDialog( t = new StaticTextWidget(myTab, font, HBORDER, ypos+2, "Y-start "); myYStart = new SliderWidget(myTab, font, t->getRight(), ypos, swidth, lineHeight, " ", 0, kYStartChanged, 5 * fontWidth, "px"); - myYStart->setMinValue(TIAConstants::minYStart-1); + myYStart->setMinValue(0); myYStart->setMaxValue(TIAConstants::maxYStart); // one tickmark every ~10 pixel - myYStart->setTickmarkInterval((TIAConstants::maxYStart - (TIAConstants::minYStart-1) + 5) / 10); + myYStart->setTickmarkInterval((TIAConstants::maxYStart + 5) / 10); wid.push_back(myYStart); int iWidth = ifont.getCharWidth('2'); @@ -532,8 +532,6 @@ void GameInfoDialog::saveConfig() // Display properties 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"); @@ -571,6 +569,11 @@ void GameInfoDialog::saveConfig() instance().frameBuffer().tiaSurface().enablePhosphor(myPhosphor->getState(), myPPBlend->getValue()); if (reset) instance().console().tia().frameReset(); + } else { + myGameProperties.set( + Display_YStart, + myYStart->getValueLabel() == "Auto" ? "0" : myYStart->getValueLabel() + ); } } @@ -703,7 +706,7 @@ void GameInfoDialog::handleCommand(CommandSender* sender, int cmd, } case kYStartChanged: - if(myYStart->getValue() == TIAConstants::minYStart-1) + if(myYStart->getValue() == 0) { myYStart->setValueLabel("Auto"); myYStart->setValueUnit("");