HostInterface: Add proper turbo speed setting

This commit is contained in:
Connor McLaughlin
2020-11-03 21:21:11 +10:00
parent d5a5969bd4
commit 2b66492ed8
20 changed files with 201 additions and 98 deletions

View File

@ -414,7 +414,7 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si)
si.SetStringValue("Console", "Region", Settings::GetConsoleRegionName(Settings::DEFAULT_CONSOLE_REGION));
si.SetFloatValue("Main", "EmulationSpeed", 1.0f);
si.SetBoolValue("Main", "SpeedLimiterEnabled", true);
si.SetFloatValue("Main", "FastForwardSpeed", 0.0f);
si.SetBoolValue("Main", "IncreaseTimerResolution", true);
si.SetBoolValue("Main", "StartPaused", false);
si.SetBoolValue("Main", "SaveStateOnExit", true);

View File

@ -110,7 +110,7 @@ void Settings::Load(SettingsInterface& si)
ParseConsoleRegionName(si.GetStringValue("Console", "Region", "NTSC-U").c_str()).value_or(DEFAULT_CONSOLE_REGION);
emulation_speed = si.GetFloatValue("Main", "EmulationSpeed", 1.0f);
speed_limiter_enabled = si.GetBoolValue("Main", "SpeedLimiterEnabled", true);
fast_forward_speed = si.GetFloatValue("Main", "FastForwardSpeed", 0.0f);
increase_timer_resolution = si.GetBoolValue("Main", "IncreaseTimerResolution", true);
start_paused = si.GetBoolValue("Main", "StartPaused", false);
start_fullscreen = si.GetBoolValue("Main", "StartFullscreen", false);
@ -249,7 +249,7 @@ void Settings::Save(SettingsInterface& si) const
si.SetStringValue("Console", "Region", GetConsoleRegionName(region));
si.SetFloatValue("Main", "EmulationSpeed", emulation_speed);
si.SetBoolValue("Main", "SpeedLimiterEnabled", speed_limiter_enabled);
si.SetFloatValue("Main", "FastForwardSpeed", fast_forward_speed);
si.SetBoolValue("Main", "IncreaseTimerResolution", increase_timer_resolution);
si.SetBoolValue("Main", "StartPaused", start_paused);
si.SetBoolValue("Main", "StartFullscreen", start_fullscreen);

View File

@ -79,7 +79,7 @@ struct Settings
bool cpu_fastmem = true;
float emulation_speed = 1.0f;
bool speed_limiter_enabled = true;
float fast_forward_speed = 0.0f;
bool increase_timer_resolution = true;
bool start_paused = false;
bool start_fullscreen = false;

View File

@ -78,6 +78,7 @@ static std::string s_running_game_code;
static std::string s_running_game_title;
static float s_throttle_frequency = 60.0f;
static float s_target_speed = 1.0f;
static s32 s_throttle_period = 0;
static u64 s_last_throttle_time = 0;
static Common::Timer s_throttle_timer;
@ -1170,6 +1171,12 @@ void RunFrame()
g_gpu->ResetGraphicsAPIState();
}
void SetTargetSpeed(float speed)
{
s_target_speed = speed;
UpdateThrottlePeriod();
}
void SetThrottleFrequency(float frequency)
{
s_throttle_frequency = frequency;
@ -1178,8 +1185,8 @@ void SetThrottleFrequency(float frequency)
void UpdateThrottlePeriod()
{
s_throttle_period = static_cast<s32>(1000000000.0 / static_cast<double>(s_throttle_frequency) /
static_cast<double>(g_settings.emulation_speed));
s_throttle_period =
static_cast<s32>(1000000000.0 / static_cast<double>(s_throttle_frequency) / static_cast<double>(s_target_speed));
}
void Throttle()

View File

@ -146,6 +146,9 @@ bool RecreateGPU(GPURenderer renderer);
void RunFrame();
/// Sets target emulation speed.
void SetTargetSpeed(float speed);
/// Adjusts the throttle frequency, i.e. how many times we should sleep per second.
void SetThrottleFrequency(float frequency);