From ddece5ed43376494c8ca3d3e5d0ba150ff15dcca Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sun, 19 Apr 2020 23:08:25 +0200 Subject: [PATCH] added 'Turbo" mode --- Changes.txt | 2 ++ docs/index.html | 51 ++++++++++++++++++++------------- src/common/FrameBufferSDL2.cxx | 3 +- src/common/PKeyboardHandler.cxx | 1 + src/emucore/Console.cxx | 22 +++++++++++++- src/emucore/Console.hxx | 5 ++++ src/emucore/Event.hxx | 1 + src/emucore/EventHandler.cxx | 6 ++++ src/emucore/EventHandler.hxx | 2 +- src/emucore/FrameBuffer.cxx | 5 +++- src/emucore/Settings.cxx | 2 ++ 11 files changed, 76 insertions(+), 24 deletions(-) diff --git a/Changes.txt b/Changes.txt index e7faac008..61989ecd9 100644 --- a/Changes.txt +++ b/Changes.txt @@ -22,6 +22,8 @@ a game. This allows the user to save high scores for these games. For each game and variation, the top 10 scores can be saved. (TODO: Doc) + * Added 'Turbo' mode, runs the game as fast as the computer allows. + * Added option which lets default ROM path follow launcher navigation (TODO: Doc) * Added displaying last write address in the debugger. diff --git a/docs/index.html b/docs/index.html index 18aa916dc..c7185ebe1 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1626,6 +1626,12 @@ Control + i + + Toggle 'Turbo' mode + Control + t + Control + t + + Toggle sound on/off Control + ] @@ -2004,6 +2010,11 @@ Control the emulation speed (as a percentage, 10 - 1000). + +
-turbo <1|0>
+ Enable 'Turbo' mode for maximum emulation speed. + +
-uimessages <1|0>
Enable or disable display of message in the UI. Note that messages @@ -2063,29 +2074,29 @@ Set the pitch o f Pitfall II music. - -
-tia.zoom <zoom>
- Use the specified zoom level (integer) while in TIA/emulation mode. - - + +
-tia.zoom <zoom>
+ Use the specified zoom level (integer) while in TIA/emulation mode. + + - -
-tia.vsizeadjust <-5 - 5>
- Adjust the display height of the TIA image - - + +
-tia.vsizeadjust <-5 - 5>
+ Adjust the display height of the TIA image + + - -
-tia.inter <1|0>
- Use interpolation for the TIA image (results in blending/smoothing - of the image). - + +
-tia.inter <1|0>
+ Use interpolation for the TIA image (results in blending/smoothing + of the image). + - -
-tia.fs_stretch <1|0>
- Stretch TIA image completely while in fullscreen mode, vs. keeping the correct - aspect ratio. - + +
-tia.fs_stretch <1|0>
+ Stretch TIA image completely while in fullscreen mode, vs. keeping the correct + aspect ratio. +
-tia.fs_overscan <0 - 10>
diff --git a/src/common/FrameBufferSDL2.cxx b/src/common/FrameBufferSDL2.cxx index d7b9ecb17..bce5c2e7c 100644 --- a/src/common/FrameBufferSDL2.cxx +++ b/src/common/FrameBufferSDL2.cxx @@ -320,7 +320,8 @@ bool FrameBufferSDL2::setVideoMode(const string& title, const VideoMode& mode) } uInt32 renderFlags = SDL_RENDERER_ACCELERATED; - if(myOSystem.settings().getBool("vsync")) // V'synced blits option + if(myOSystem.settings().getBool("vsync") + && !myOSystem.settings().getBool("turbo")) // V'synced blits option renderFlags |= SDL_RENDERER_PRESENTVSYNC; const string& video = myOSystem.settings().getString("video"); // Render hint if(video != "") diff --git a/src/common/PKeyboardHandler.cxx b/src/common/PKeyboardHandler.cxx index 76d48dd1a..bc2c545ca 100644 --- a/src/common/PKeyboardHandler.cxx +++ b/src/common/PKeyboardHandler.cxx @@ -468,6 +468,7 @@ PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultCommo {Event::ToggleColorLoss, KBDK_L, KBDM_CTRL}, {Event::TogglePalette, KBDK_P, KBDM_CTRL}, {Event::ToggleInter, KBDK_I, KBDM_CTRL}, + {Event::ToggleTurbo, KBDK_T, KBDM_CTRL}, {Event::ToggleJitter, KBDK_J, MOD3}, {Event::ToggleFrameStats, KBDK_L, MOD3}, {Event::ToggleTimeMachine, KBDK_T, MOD3}, diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index 518030966..fc5c1e9be 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -563,6 +563,24 @@ void Console::toggleInter() myOSystem.frameBuffer().showMessage(ss.str()); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Console::toggleTurbo() +{ + bool enabled = myOSystem.settings().getBool("turbo"); + + myOSystem.settings().setValue("turbo", !enabled); + + // update speed + initializeAudio(); + + // update VSync + myOSystem.createFrameBuffer(); + + ostringstream ss; + ss << "Turbo mode " << (!enabled ? "enabled" : "disabled"); + myOSystem.frameBuffer().showMessage(ss.str()); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Console::togglePhosphor() { @@ -657,7 +675,9 @@ void Console::initializeAudio() .updatePlaybackPeriod(myAudioSettings.fragmentSize()) .updateAudioQueueExtraFragments(myAudioSettings.bufferSize()) .updateAudioQueueHeadroom(myAudioSettings.headroom()) - .updateSpeedFactor(myOSystem.settings().getFloat("speed")); + .updateSpeedFactor(myOSystem.settings().getBool("turbo") + ? 20.0F + : myOSystem.settings().getFloat("speed")); createAudioQueue(); myTIA->setAudioQueue(myAudioQueue); diff --git a/src/emucore/Console.hxx b/src/emucore/Console.hxx index eb85025a6..33c3b117c 100644 --- a/src/emucore/Console.hxx +++ b/src/emucore/Console.hxx @@ -221,6 +221,11 @@ class Console : public Serializable, public ConsoleIO */ void toggleInter(); + /** + Toggle turbo mode on/off + */ + void toggleTurbo(); + /** Toggles phosphor effect. diff --git a/src/emucore/Event.hxx b/src/emucore/Event.hxx index b82bb7f50..c45fc1e0a 100644 --- a/src/emucore/Event.hxx +++ b/src/emucore/Event.hxx @@ -120,6 +120,7 @@ class Event ToggleFrameStats, ToggleSAPortOrder, ExitGame, // add new events from here to avoid that user remapped events get overwritten + ToggleTurbo, LastType }; diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 4433ed244..1a11c604b 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -539,6 +539,10 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) if (pressed && !repeated) myOSystem.console().toggleInter(); return; + case Event::ToggleTurbo: + if (pressed && !repeated) myOSystem.console().toggleTurbo(); + return; + case Event::ToggleJitter: if (pressed && !repeated) myOSystem.console().toggleJitter(); return; @@ -1815,6 +1819,7 @@ EventHandler::EmulActionList EventHandler::ourEmulActionList = { { { Event::TogglePauseMode, "Toggle Pause mode", "" }, { Event::StartPauseMode, "Start Pause mode", "" }, { Event::Fry, "Fry cartridge", "" }, + { Event::ToggleTurbo, "Toggle Turbo mode", "" }, { Event::DebuggerMode, "Toggle Debugger mode", "" }, { Event::ConsoleSelect, "Select", "" }, @@ -2023,6 +2028,7 @@ EventHandler::MenuActionList EventHandler::ourMenuActionList = { { const Event::EventSet EventHandler::MiscEvents = { Event::Quit, Event::ReloadConsole, Event::Fry, Event::StartPauseMode, Event::TogglePauseMode, Event::OptionsMenuMode, Event::CmdMenuMode, Event::ExitMode, + Event::ToggleTurbo, Event::TakeSnapshot, Event::ToggleContSnapshots, Event::ToggleContSnapshotsFrame, // Event::MouseAxisXMove, Event::MouseAxisYMove, // Event::MouseButtonLeftValue, Event::MouseButtonRightValue, diff --git a/src/emucore/EventHandler.hxx b/src/emucore/EventHandler.hxx index 7fa56d17d..8148fa085 100644 --- a/src/emucore/EventHandler.hxx +++ b/src/emucore/EventHandler.hxx @@ -468,7 +468,7 @@ class EventHandler #else PNG_SIZE = 0, #endif - EMUL_ACTIONLIST_SIZE = 144 + PNG_SIZE + COMBO_SIZE, + EMUL_ACTIONLIST_SIZE = 145 + PNG_SIZE + COMBO_SIZE, MENU_ACTIONLIST_SIZE = 18 ; diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 68b6e8caa..3c64c5d8f 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -502,7 +502,10 @@ void FrameBuffer::drawFrameStats(float framesPerSecond) ss << std::fixed << std::setprecision(1) << framesPerSecond << "fps @ " - << std::fixed << std::setprecision(0) << 100 * myOSystem.settings().getFloat("speed") + << std::fixed << std::setprecision(0) << 100 * + (myOSystem.settings().getBool("turbo") + ? 20.0F + : myOSystem.settings().getFloat("speed")) << "% speed"; myStatsMsg.surface->drawString(f, ss.str(), xPos, yPos, diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index c3feece37..50e45cd06 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -157,6 +157,7 @@ Settings::Settings() setPermanent("threads", "false"); setTemporary("romloadcount", "0"); setTemporary("maxres", ""); + setTemporary("turbo", "0"); #ifdef DEBUGGER_SUPPORT // Debugger/disassembly options @@ -400,6 +401,7 @@ void Settings::usage() const << " z26|\n" << " user>\n" << " -speed Run emulation at the given speed\n" + << " -turbo <1|0> Enable 'Turbo' mode for maximum emulation speed\n" << " -uimessages <1|0> Show onscreen UI messages for different events\n" << endl #ifdef SOUND_SUPPORT