Bug fixing, harcode min ystart to 0.

This commit is contained in:
Christian Speckner 2018-09-13 23:23:21 +02:00
parent 5bc84bca52
commit 2f9fc4f525
4 changed files with 33 additions and 19 deletions

View File

@ -64,6 +64,9 @@
"__hash_table": "cpp", "__hash_table": "cpp",
"array": "cpp", "array": "cpp",
"queue": "cpp", "queue": "cpp",
"unordered_map": "cpp" "unordered_map": "cpp",
"istream": "cpp",
"thread": "cpp",
"utility": "cpp"
} }
} }

View File

@ -680,10 +680,9 @@ void Console::changeYStart(int direction)
} }
else if(direction == -1) // decrease YStart else if(direction == -1) // decrease YStart
{ {
if(ystart == TIAConstants::minYStart-1 && myAutodetectedYstart > 0) if(ystart == 0)
{ {
myOSystem.frameBuffer().showMessage("YStart at minimum"); throw runtime_error("cannot happen");
return;
} }
--ystart; --ystart;
@ -694,7 +693,7 @@ void Console::changeYStart(int direction)
ostringstream val; ostringstream val;
val << ystart; val << ystart;
if(ystart == TIAConstants::minYStart-1) { if(ystart == 0) {
redetectYStart(); redetectYStart();
ystart = myAutodetectedYstart; ystart = myAutodetectedYstart;
@ -707,12 +706,12 @@ void Console::changeYStart(int direction)
// We've reached the auto-detect value, so reset // We've reached the auto-detect value, so reset
myOSystem.frameBuffer().showMessage("YStart " + val.str() + " (Auto)"); myOSystem.frameBuffer().showMessage("YStart " + val.str() + " (Auto)");
val.str(""); val.str("");
val << TIAConstants::minYStart-1; val << static_cast<int>(0);
} }
else else
myOSystem.frameBuffer().showMessage("YStart " + val.str()); myOSystem.frameBuffer().showMessage("YStart " + val.str());
myAutodetectedYstart = false; myYStartAutodetected = false;
} }
myProperties.set(Display_YStart, val.str()); myProperties.set(Display_YStart, val.str());
@ -723,14 +722,23 @@ void Console::changeYStart(int direction)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::updateYStart(uInt32 ystart) void Console::updateYStart(uInt32 ystart)
{ {
if (ystart == TIAConstants::minYStart-1 && !myYStartAutodetected) { if (ystart > TIAConstants::maxYStart) return;
redetectYStart();
ystart = myAutodetectedYstart;
} else if (ystart <= TIAConstants::maxYStart) myYStartAutodetected = false;
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->setYStart(ystart);
myTIA->frameReset(); myTIA->frameReset();
myYStartAutodetected = false;
} }
} }
@ -772,7 +780,7 @@ 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, TIAConstants::minYStart, TIAConstants::maxYStart); ystart = BSPF::clamp(ystart, 0u, TIAConstants::maxYStart);
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);

View File

@ -23,7 +23,7 @@
namespace TIAConstants { namespace TIAConstants {
constexpr uInt32 frameBufferHeight = 320; constexpr uInt32 frameBufferHeight = 320;
constexpr uInt32 minYStart = 1, maxYStart = 64; constexpr uInt32 maxYStart = 64;
constexpr uInt32 minViewableHeight = 210, maxViewableHeight = 256; constexpr uInt32 minViewableHeight = 210, maxViewableHeight = 256;
constexpr uInt32 initialGarbageFrames = 10; constexpr uInt32 initialGarbageFrames = 10;
} }

View File

@ -307,10 +307,10 @@ GameInfoDialog::GameInfoDialog(
t = new StaticTextWidget(myTab, font, HBORDER, ypos+2, "Y-start "); t = new StaticTextWidget(myTab, font, HBORDER, ypos+2, "Y-start ");
myYStart = new SliderWidget(myTab, font, t->getRight(), ypos, swidth, lineHeight, myYStart = new SliderWidget(myTab, font, t->getRight(), ypos, swidth, lineHeight,
" ", 0, kYStartChanged, 5 * fontWidth, "px"); " ", 0, kYStartChanged, 5 * fontWidth, "px");
myYStart->setMinValue(TIAConstants::minYStart-1); myYStart->setMinValue(0);
myYStart->setMaxValue(TIAConstants::maxYStart); myYStart->setMaxValue(TIAConstants::maxYStart);
// one tickmark every ~10 pixel // one tickmark every ~10 pixel
myYStart->setTickmarkInterval((TIAConstants::maxYStart - (TIAConstants::minYStart-1) + 5) / 10); myYStart->setTickmarkInterval((TIAConstants::maxYStart + 5) / 10);
wid.push_back(myYStart); wid.push_back(myYStart);
int iWidth = ifont.getCharWidth('2'); int iWidth = ifont.getCharWidth('2');
@ -532,8 +532,6 @@ void GameInfoDialog::saveConfig()
// Display properties // Display properties
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");
@ -571,6 +569,11 @@ void GameInfoDialog::saveConfig()
instance().frameBuffer().tiaSurface().enablePhosphor(myPhosphor->getState(), myPPBlend->getValue()); instance().frameBuffer().tiaSurface().enablePhosphor(myPhosphor->getState(), myPPBlend->getValue());
if (reset) if (reset)
instance().console().tia().frameReset(); 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: case kYStartChanged:
if(myYStart->getValue() == TIAConstants::minYStart-1) if(myYStart->getValue() == 0)
{ {
myYStart->setValueLabel("Auto"); myYStart->setValueLabel("Auto");
myYStart->setValueUnit(""); myYStart->setValueUnit("");