underclock/overclock SH4 option

Increase/reduce the dynarec cycle count for each block.
Issue #210
This commit is contained in:
Flyinghead 2023-03-30 17:22:24 +02:00
parent 08ac485eac
commit 48acb03b81
7 changed files with 45 additions and 2 deletions

View File

@ -25,6 +25,7 @@ namespace config {
// Dynarec
Option<bool> DynarecEnabled("Dynarec.Enabled", true);
Option<int> Sh4Clock("Sh4Clock", 200);
// General

View File

@ -356,6 +356,9 @@ using OptionString = Option<std::string>;
// Dynarec
extern Option<bool> DynarecEnabled;
#ifndef LIBRETRO
extern Option<int> Sh4Clock;
#endif
// General

View File

@ -1057,8 +1057,8 @@ _end:
verify(blk->oplist.size() <= BLOCK_MAX_SH_OPS_HARD);
//make sure we don't use wayy-too-many cycles
blk->guest_cycles = std::min(blk->guest_cycles, max_cycles);
blk->guest_cycles = std::round(blk->guest_cycles * 200.f / std::max(1.f, (float)config::Sh4Clock));
//make sure we don't use wayy-too-few cycles
blk->guest_cycles = std::max(1U, blk->guest_cycles);
blk = nullptr;

View File

@ -2172,6 +2172,10 @@ static void gui_display_settings()
OptionRadioButton("Interpreter", config::DynarecEnabled, false,
"Use the interpreter. Very slow but may help in case of a dynarec problem");
ImGui::Columns(1, NULL, false);
OptionSlider("SH4 Clock", config::Sh4Clock, 100, 300,
"Over/Underclock the main SH4 CPU. Default is 200 MHz. Other values may crash, freeze or trigger unexpected nuclear reactions.",
"%d MHz");
}
ImGui::Spacing();
header("Network");

View File

@ -689,6 +689,39 @@ struct retro_core_option_v2_definition option_defs_us[] = {
"disabled",
#endif
},
{
CORE_OPTION_NAME "_sh4clock",
"SH4 CPU under/overclock",
NULL,
"Change the SH4 main CPU clock from the default 200 MHz. Underclocking may help slow platforms. Overclocking may increase the frame rate for some games. Use with caution.",
NULL,
"hacks",
{
{ "100", "100 MHz" },
{ "110", "110 MHz" },
{ "120", "120 MHz" },
{ "130", "130 MHz" },
{ "140", "140 MHz" },
{ "150", "150 MHz" },
{ "160", "160 MHz" },
{ "170", "170 MHz" },
{ "180", "180 MHz" },
{ "190", "190 MHz" },
{ "200", "200 MHz" },
{ "210", "210 MHz" },
{ "220", "220 MHz" },
{ "230", "230 MHz" },
{ "240", "240 MHz" },
{ "250", "250 MHz" },
{ "260", "260 MHz" },
{ "270", "270 MHz" },
{ "280", "280 MHz" },
{ "290", "290 MHz" },
{ "300", "300 MHz" },
{ NULL, NULL },
},
"200",
},
{
CORE_OPTION_NAME "_custom_textures",
"Load Custom Textures",

View File

@ -24,6 +24,7 @@ namespace config {
// Dynarec
Option<bool> DynarecEnabled("", true);
IntOption Sh4Clock(CORE_OPTION_NAME "_sh4clock", 200);
// General

View File

@ -202,3 +202,4 @@ extern Option<bool> PowerVR2Filter;
extern IntOption TextureUpscale;
extern IntOption MaxFilteredTextureSize;
extern IntOption PerPixelLayers;
extern IntOption Sh4Clock;