diff --git a/src/common/PaletteHandler.cxx b/src/common/PaletteHandler.cxx index b0e4eea2d..f040fe8e5 100644 --- a/src/common/PaletteHandler.cxx +++ b/src/common/PaletteHandler.cxx @@ -91,6 +91,31 @@ void PaletteHandler::cyclePalette(bool next) setPalette(palette); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void PaletteHandler::showAdjustableMessage() +{ + const bool isPhaseShift = myAdjustables[myCurrentAdjustable].value == nullptr; + ostringstream msg, buf; + + msg << "Palette " << myAdjustables[myCurrentAdjustable].name; + if(isPhaseShift) + { + const ConsoleTiming timing = myOSystem.console().timing(); + const bool isNTSC = timing == ConsoleTiming::ntsc; + const float value = myOSystem.console().timing() == ConsoleTiming::pal ? myPhasePAL : myPhaseNTSC; + buf << std::fixed << std::setprecision(1) << value << DEGREE; + myOSystem.frameBuffer().showMessage("Palette phase shift", buf.str(), value, + (isNTSC ? DEF_NTSC_SHIFT : DEF_PAL_SHIFT) - MAX_SHIFT, + (isNTSC ? DEF_NTSC_SHIFT : DEF_PAL_SHIFT) + MAX_SHIFT); + } + else + { + const int value = scaleTo100(*myAdjustables[myCurrentAdjustable].value); + buf << value << "%"; + myOSystem.frameBuffer().showMessage(msg.str(), buf.str(), value); + } +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PaletteHandler::cycleAdjustable(bool next) { @@ -115,16 +140,7 @@ void PaletteHandler::cycleAdjustable(bool next) // skip phase shift when 'Custom' palette is not selected } while(isPhaseShift && !isCustomPalette); - ostringstream buf; - buf << "Palette adjustable '" << myAdjustables[myCurrentAdjustable].name - << "' selected ("; - if(isPhaseShift) - buf << (myOSystem.console().timing() == ConsoleTiming::pal ? myPhasePAL : myPhaseNTSC) - << DEGREE << ")"; - else - buf << scaleTo100(*myAdjustables[myCurrentAdjustable].value) << "%)"; - - myOSystem.frameBuffer().showMessage(buf.str()); + showAdjustableMessage(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -144,10 +160,7 @@ void PaletteHandler::changeAdjustable(bool increase) *myAdjustables[myCurrentAdjustable].value = scaleFrom100(newVal); - ostringstream msg, val; - msg << "Palette " << myAdjustables[myCurrentAdjustable].name; - val << newVal << "%"; - myOSystem.frameBuffer().showMessage(msg.str(), val.str(), newVal); + showAdjustableMessage(); setPalette(); } } @@ -178,11 +191,7 @@ void PaletteHandler::changeColorPhaseShift(bool increase) generateCustomPalette(timing); setPalette(SETTING_CUSTOM); - ostringstream val; - val << std::fixed << std::setprecision(1) << newPhase << DEGREE; - myOSystem.frameBuffer().showMessage("Palette phase shift", val.str(), newPhase, - (isNTSC ? DEF_NTSC_SHIFT : DEF_PAL_SHIFT) - MAX_SHIFT, - (isNTSC ? DEF_NTSC_SHIFT : DEF_PAL_SHIFT) + MAX_SHIFT); + showAdjustableMessage(); } } diff --git a/src/common/PaletteHandler.hxx b/src/common/PaletteHandler.hxx index 3a8c5c9e3..e8e083a8a 100644 --- a/src/common/PaletteHandler.hxx +++ b/src/common/PaletteHandler.hxx @@ -128,6 +128,11 @@ class PaletteHandler */ string toPaletteName(PaletteType type) const; + /** + Display current adjustable with bar gauge message + */ + void showAdjustableMessage(); + /** Change the "phase shift" variable. Note that there are two of these (NTSC and PAL). The currently diff --git a/src/common/tv_filters/NTSCFilter.cxx b/src/common/tv_filters/NTSCFilter.cxx index d742cc674..2d0ffaa6e 100644 --- a/src/common/tv_filters/NTSCFilter.cxx +++ b/src/common/tv_filters/NTSCFilter.cxx @@ -72,61 +72,53 @@ string NTSCFilter::getPreset() const } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string NTSCFilter::setNextAdjustable() +void NTSCFilter::selectAdjustable(bool next, string& text, string& valueText, Int32& value) { - //if(myPreset != Preset::CUSTOM) - // return "'Custom' TV mode not selected"; + if(next) + { + #ifdef BLARGG_PALETTE + myCurrentAdjustable = (myCurrentAdjustable + 1) % 10; + #else + myCurrentAdjustable = (myCurrentAdjustable + 1) % 5; + #endif + } + else + { + #ifdef BLARGG_PALETTE + if(myCurrentAdjustable == 0) myCurrentAdjustable = 9; + #else + if(myCurrentAdjustable == 0) myCurrentAdjustable = 4; + #endif + else --myCurrentAdjustable; + } -#ifdef BLARGG_PALETTE - myCurrentAdjustable = (myCurrentAdjustable + 1) % 10; -#else - myCurrentAdjustable = (myCurrentAdjustable + 1) % 5; -#endif - - ostringstream buf; - buf << "Custom adjustable '" << ourCustomAdjustables[myCurrentAdjustable].type - << "' selected (" - << scaleTo100(*ourCustomAdjustables[myCurrentAdjustable].value) << "%)"; - - return buf.str(); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string NTSCFilter::setPreviousAdjustable() -{ - //if(myPreset != Preset::CUSTOM) - // return "'Custom' TV mode not selected"; - -#ifdef BLARGG_PALETTE - if(myCurrentAdjustable == 0) myCurrentAdjustable = 9; -#else - if(myCurrentAdjustable == 0) myCurrentAdjustable = 4; -#endif - else --myCurrentAdjustable; - ostringstream buf; - buf << "Custom adjustable '" << ourCustomAdjustables[myCurrentAdjustable].type - << "' selected (" - << scaleTo100(*ourCustomAdjustables[myCurrentAdjustable].value) << "%)"; - - return buf.str(); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void NTSCFilter::changeAdjustable(bool increase, string& text, string& valueText, Int32& value) -{ - //if(myPreset != Preset::CUSTOM) - // return "'Custom' TV mode not selected"; + ostringstream msg, val; value = scaleTo100(*ourCustomAdjustables[myCurrentAdjustable].value); - value = BSPF::clamp(value + (increase ? 2 : -2), 0, 100); + msg << "Custom " << ourCustomAdjustables[myCurrentAdjustable].type; + val << value << "%"; - *ourCustomAdjustables[myCurrentAdjustable].value = scaleFrom100(value); + text = msg.str(); + valueText = val.str(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void NTSCFilter::changeAdjustable(bool increase, string& text, string& valueText, Int32& newValue) +{ + //if(myPreset != Preset::CUSTOM) + // return "'Custom' TV mode not selected"; + + newValue = scaleTo100(*ourCustomAdjustables[myCurrentAdjustable].value); + newValue = BSPF::clamp(newValue + (increase ? 2 : -2), 0, 100); + + *ourCustomAdjustables[myCurrentAdjustable].value = scaleFrom100(newValue); setPreset(myPreset); ostringstream msg, val; + msg << "Custom " << ourCustomAdjustables[myCurrentAdjustable].type; - val << value << "%"; + val << newValue << "%"; text = msg.str(); valueText = val.str(); diff --git a/src/common/tv_filters/NTSCFilter.hxx b/src/common/tv_filters/NTSCFilter.hxx index c4fe30f15..6ccdcd155 100644 --- a/src/common/tv_filters/NTSCFilter.hxx +++ b/src/common/tv_filters/NTSCFilter.hxx @@ -90,9 +90,8 @@ class NTSCFilter // Changes are made this way since otherwise 20 key-combinations // would be needed to dynamically change each setting, and now // only 4 combinations are necessary - string setNextAdjustable(); - string setPreviousAdjustable(); - void changeAdjustable(bool increase, string& text, string& valueText, Int32& value); + void selectAdjustable(bool next, string& text, string& valueText, Int32& value); + void changeAdjustable(bool increase, string& text, string& valueText, Int32& newValue); // Load and save NTSC-related settings void loadConfig(const Settings& settings); diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 82fd4280c..d83a44aa0 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -496,6 +496,22 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) if (pressed && !repeated) myOSystem.frameBuffer().tiaSurface().setNTSC(NTSCFilter::Preset::CUSTOM); return; + case Event::PreviousAttribute: + if (pressed) myOSystem.frameBuffer().tiaSurface().setNTSCAdjustable(false); + return; + + case Event::NextAttribute: + if (pressed) myOSystem.frameBuffer().tiaSurface().setNTSCAdjustable(true); + return; + + case Event::DecreaseAttribute: + if(pressed) myOSystem.frameBuffer().tiaSurface().changeNTSCAdjustable(false); + return; + + case Event::IncreaseAttribute: + if(pressed) myOSystem.frameBuffer().tiaSurface().changeNTSCAdjustable(true); + return; + case Event::ScanlinesDecrease: if (pressed) myOSystem.frameBuffer().tiaSurface().setScanlineIntensity(-2); return; @@ -504,48 +520,6 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) if (pressed) myOSystem.frameBuffer().tiaSurface().setScanlineIntensity(+2); return; - case Event::PreviousAttribute: - if (pressed) - { - myOSystem.frameBuffer().tiaSurface().setNTSC(NTSCFilter::Preset::CUSTOM); - myOSystem.frameBuffer().showMessage( - myOSystem.frameBuffer().tiaSurface().ntsc().setPreviousAdjustable()); - } - return; - - case Event::NextAttribute: - if (pressed) - { - myOSystem.frameBuffer().tiaSurface().setNTSC(NTSCFilter::Preset::CUSTOM); - myOSystem.frameBuffer().showMessage( - myOSystem.frameBuffer().tiaSurface().ntsc().setNextAdjustable()); - } - return; - - case Event::DecreaseAttribute: - if (pressed) - { - string text, valueText; - Int32 newVal; - - myOSystem.frameBuffer().tiaSurface().setNTSC(NTSCFilter::Preset::CUSTOM); - myOSystem.frameBuffer().tiaSurface().ntsc().changeAdjustable(false, text, valueText, newVal); - myOSystem.frameBuffer().showMessage(text, valueText, newVal); - } - return; - - case Event::IncreaseAttribute: - if (pressed) - { - string text, valueText; - Int32 newVal; - - myOSystem.frameBuffer().tiaSurface().setNTSC(NTSCFilter::Preset::CUSTOM); - myOSystem.frameBuffer().tiaSurface().ntsc().changeAdjustable(true, text, valueText, newVal); - myOSystem.frameBuffer().showMessage(text, valueText, newVal); - } - return; - case Event::PhosphorDecrease: if (pressed) myOSystem.console().changePhosphor(false); return; diff --git a/src/emucore/TIASurface.cxx b/src/emucore/TIASurface.cxx index 53060a97e..307863e8e 100644 --- a/src/emucore/TIASurface.cxx +++ b/src/emucore/TIASurface.cxx @@ -225,6 +225,29 @@ void TIASurface::changeNTSC(bool next, bool show) setNTSC(PRESETS[preset], show); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void TIASurface::setNTSCAdjustable(bool next) +{ + string text, valueText; + Int32 value; + + setNTSC(NTSCFilter::Preset::CUSTOM); + ntsc().selectAdjustable(next, text, valueText, value); + myOSystem.frameBuffer().showMessage(text, valueText, value); + +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void TIASurface::changeNTSCAdjustable(bool increase) +{ + string text, valueText; + Int32 newValue; + + setNTSC(NTSCFilter::Preset::CUSTOM); + ntsc().changeAdjustable(increase, text, valueText, newValue); + myOSystem.frameBuffer().showMessage(text, valueText, newValue); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TIASurface::setScanlineIntensity(int amount) { diff --git a/src/emucore/TIASurface.hxx b/src/emucore/TIASurface.hxx index b2c00f912..90aeacb14 100644 --- a/src/emucore/TIASurface.hxx +++ b/src/emucore/TIASurface.hxx @@ -94,6 +94,16 @@ class TIASurface */ void changeNTSC(bool next, bool show = true); + /** + Switch to next/previous NTSC filtering adjustable. + */ + void setNTSCAdjustable(bool next = true); + + /** + Increase/decrease current NTSC filtering adjustable. + */ + void changeNTSCAdjustable(bool increase = true); + /** Retrieve palette handler. */