From cf49325555e8224f7924d8110c1baeed8cbfff9c Mon Sep 17 00:00:00 2001 From: BearOso Date: Sat, 2 Sep 2023 16:07:16 -0500 Subject: [PATCH] Qt: More overclock options. --- qt/src/EmuConfig.cpp | 4 +-- qt/src/EmuConfig.hpp | 9 +++++- qt/src/EmulationPanel.cpp | 4 +-- qt/src/EmulationPanel.ui | 60 ++++++++++++++++++++++++++++++------- qt/src/Snes9xController.cpp | 16 +++------- 5 files changed, 65 insertions(+), 28 deletions(-) diff --git a/qt/src/EmuConfig.cpp b/qt/src/EmuConfig.cpp index 36c04212..c2436ea4 100644 --- a/qt/src/EmuConfig.cpp +++ b/qt/src/EmuConfig.cpp @@ -278,7 +278,7 @@ bool EmuConfig::setDefaults(int section) allow_invalid_vram_access = false; allow_opposing_dpad_directions = false; - overclock = false; + overclock = eNoOverclock; remove_sprite_limit = false; enable_shadow_buffer = false; superfx_clock_multiplier = 100; @@ -489,7 +489,7 @@ void EmuConfig::config(std::string filename, bool write) Int("RewindFrameInterval", rewind_frame_interval); Bool("AllowInvalidVRAMAccess", allow_invalid_vram_access); Bool("AllowOpposingDpadDirections", allow_opposing_dpad_directions); - Bool("Overclock", overclock); + Int("Overclock", overclock); Bool("RemoveSpriteLimit", remove_sprite_limit); Bool("EnableShadowBuffer", enable_shadow_buffer); Int("SuperFXClockMultiplier", superfx_clock_multiplier); diff --git a/qt/src/EmuConfig.hpp b/qt/src/EmuConfig.hpp index 7a05f58d..9fed4592 100644 --- a/qt/src/EmuConfig.hpp +++ b/qt/src/EmuConfig.hpp @@ -116,7 +116,14 @@ struct EmuConfig bool allow_invalid_vram_access; bool allow_opposing_dpad_directions; - bool overclock; + enum Overclock + { + eNoOverclock = 0, + eAutoFastROM = 1, + eLow = 2, + eHigh = 3 + }; + int overclock; bool remove_sprite_limit; bool enable_shadow_buffer; int superfx_clock_multiplier; diff --git a/qt/src/EmulationPanel.cpp b/qt/src/EmulationPanel.cpp index 91363bb3..464ea9ba 100644 --- a/qt/src/EmulationPanel.cpp +++ b/qt/src/EmulationPanel.cpp @@ -36,7 +36,7 @@ EmulationPanel::EmulationPanel(EmuApplication *app_) connect_checkbox(checkBox_allow_invalid_vram_access, &app->config->allow_invalid_vram_access); connect_checkbox(checkBox_allow_opposing_dpad_directions, &app->config->allow_opposing_dpad_directions); - connect_checkbox(checkBox_overclock, &app->config->overclock); + connect_combo(comboBox_overclock, &app->config->overclock); connect_checkbox(checkBox_remove_sprite_limit, &app->config->remove_sprite_limit); connect_checkbox(checkBox_use_shadow_echo_buffer, &app->config->enable_shadow_buffer); connect_spin(spinBox_superfx_clock_speed, &app->config->superfx_clock_multiplier); @@ -59,7 +59,7 @@ void EmulationPanel::showEvent(QShowEvent *event) checkBox_allow_invalid_vram_access->setChecked(config->allow_invalid_vram_access); checkBox_allow_opposing_dpad_directions->setChecked(config->allow_opposing_dpad_directions); - checkBox_overclock->setChecked(config->overclock); + comboBox_overclock->setCurrentIndex(config->overclock); checkBox_remove_sprite_limit->setChecked(config->remove_sprite_limit); checkBox_use_shadow_echo_buffer->setChecked(config->enable_shadow_buffer); spinBox_superfx_clock_speed->setValue(config->superfx_clock_multiplier); diff --git a/qt/src/EmulationPanel.ui b/qt/src/EmulationPanel.ui index d7be21ab..a9029096 100644 --- a/qt/src/EmulationPanel.ui +++ b/qt/src/EmulationPanel.ui @@ -248,16 +248,6 @@ - - - - <html><head/><body><p>Decrease the time it takes for the CPU to perform operations, making it faster. This can remove slowdown, but can also cause glitches in many games.</p></body></html> - - - Overclock the CPU - - - @@ -278,7 +268,7 @@ - + <html><head/><body><p>Allows more sprites to be displayed on the screen in an attempt to remove flickering.</p><p>Some games take advantage of this limit and use it to hide glitches, and removing the limit will make those visible.</p></body></html> @@ -392,6 +382,54 @@ + + + + + + Overclock: + + + + + + + + None + + + + + Auto-FastROM + + + + + Low + + + + + High + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + diff --git a/qt/src/Snes9xController.cpp b/qt/src/Snes9xController.cpp index 3a92ca79..15eb4c43 100644 --- a/qt/src/Snes9xController.cpp +++ b/qt/src/Snes9xController.cpp @@ -174,18 +174,10 @@ void Snes9xController::updateSettings(const EmuConfig * const config) else Settings.MaxSpriteTilesPerLine = 34; - if (!config->overclock) - { - Settings.OneClockCycle = 6; - Settings.OneSlowClockCycle = 8; - Settings.TwoClockCycles = 12; - } - else - { - Settings.OneClockCycle = 2; - Settings.OneSlowClockCycle = 3; - Settings.TwoClockCycles = 4; - } + const int overclock_cycles[4][2] = { { 6, 8 }, { 6, 6 }, { 3, 4 }, { 1, 1 } }; + Settings.OneClockCycle = overclock_cycles[config->overclock][0]; + Settings.OneSlowClockCycle = overclock_cycles[config->overclock][1]; + Settings.TwoClockCycles = overclock_cycles[config->overclock][0] * 2; Settings.ShowOverscan = config->show_overscan;