diff --git a/src/core/host_interface.cpp b/src/core/host_interface.cpp index 84d05c55c..0a412bb41 100644 --- a/src/core/host_interface.cpp +++ b/src/core/host_interface.cpp @@ -206,11 +206,11 @@ void HostInterface::UpdateSpeedLimiterState() { m_speed_limiter_enabled = m_settings.speed_limiter_enabled && !m_speed_limiter_temp_disabled; - const bool audio_sync_enabled = !m_system || m_paused || m_speed_limiter_enabled; - const bool vsync_enabled = !m_system || m_paused || (m_speed_limiter_enabled && m_settings.gpu_vsync); + const bool audio_sync_enabled = !m_system || m_paused || (m_speed_limiter_enabled && m_settings.audio_sync_enabled); + const bool video_sync_enabled = !m_system || m_paused || (m_speed_limiter_enabled && m_settings.video_sync_enabled); Log_InfoPrintf("Syncing to %s%s", audio_sync_enabled ? "audio" : "", - (m_speed_limiter_enabled && vsync_enabled) ? " and video" : ""); + (audio_sync_enabled && video_sync_enabled) ? " and video" : (video_sync_enabled ? "video" : "")); m_audio_stream->SetSync(audio_sync_enabled); - m_display->SetVSync(vsync_enabled); + m_display->SetVSync(video_sync_enabled); } diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 49c8791b1..ba6a60fc3 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -13,9 +13,15 @@ Settings::Settings() = default; void Settings::SetDefaults() { + region = ConsoleRegion::Auto; + + audio_sync_enabled = true; + video_sync_enabled = true; + speed_limiter_enabled = true; + start_paused = false; + gpu_renderer = GPURenderer::HardwareOpenGL; gpu_resolution_scale = 1; - gpu_vsync = true; gpu_true_color = true; display_linear_filtering = true; @@ -39,9 +45,13 @@ void Settings::Load(const char* filename) region = ParseConsoleRegionName(ini.GetValue("Console", "Region", "NTSC-U")).value_or(ConsoleRegion::NTSC_U); + audio_sync_enabled = ini.GetBoolValue("General", "SyncToAudio", true); + video_sync_enabled = ini.GetBoolValue("General", "SyncToVideo", true); + speed_limiter_enabled = ini.GetBoolValue("General", "SpeedLimiterEnabled", true); + start_paused = ini.GetBoolValue("General", "StartPaused", false); + gpu_renderer = ParseRendererName(ini.GetValue("GPU", "Renderer", "OpenGL")).value_or(GPURenderer::HardwareOpenGL); gpu_resolution_scale = static_cast(ini.GetLongValue("GPU", "ResolutionScale", 1)); - gpu_vsync = static_cast(ini.GetBoolValue("GPU", "VSync", true)); gpu_true_color = ini.GetBoolValue("GPU", "TrueColor", false); display_linear_filtering = ini.GetBoolValue("Display", "LinearFiltering", true); @@ -64,9 +74,14 @@ bool Settings::Save(const char* filename) const ini.SetValue("Console", "Region", GetConsoleRegionName(region)); + ini.SetBoolValue("General", "SyncToAudio", audio_sync_enabled); + ini.SetBoolValue("General", "SyncToVideo", video_sync_enabled); + ini.SetBoolValue("General", "SpeedLimiterEnabled", speed_limiter_enabled); + ini.SetBoolValue("General", "StartPaused", start_paused); + ini.SetValue("GPU", "Renderer", GetRendererName(gpu_renderer)); ini.SetLongValue("GPU", "ResolutionScale", static_cast(gpu_resolution_scale)); - ini.SetBoolValue("GPU", "VSync", gpu_vsync); + ini.SetBoolValue("GPU", "VSync", video_sync_enabled); ini.SetBoolValue("GPU", "TrueColor", gpu_true_color); ini.SetBoolValue("Display", "LinearFiltering", display_linear_filtering); diff --git a/src/core/settings.h b/src/core/settings.h index e08150b57..7a639d2b5 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -6,15 +6,16 @@ struct Settings { Settings(); - ConsoleRegion region = ConsoleRegion::NTSC_U; + ConsoleRegion region = ConsoleRegion::Auto; bool start_paused = false; bool speed_limiter_enabled = true; + bool audio_sync_enabled = true; + bool video_sync_enabled = true; GPURenderer gpu_renderer = GPURenderer::Software; u32 gpu_resolution_scale = 1; mutable u32 max_gpu_resolution_scale = 1; - bool gpu_vsync = true; bool gpu_true_color = false; bool display_linear_filtering = true; bool display_fullscreen = false; diff --git a/src/duckstation/sdl_host_interface.cpp b/src/duckstation/sdl_host_interface.cpp index 41e61bc68..876420b5c 100644 --- a/src/duckstation/sdl_host_interface.cpp +++ b/src/duckstation/sdl_host_interface.cpp @@ -743,9 +743,12 @@ void SDLHostInterface::DrawQuickSettingsMenu() } if (ImGui::MenuItem("Fullscreen", nullptr, &m_settings.display_fullscreen)) + { + settings_changed = true; UpdateFullscreen(); + } - if (ImGui::MenuItem("VSync", nullptr, &m_settings.gpu_vsync)) + if (ImGui::MenuItem("VSync", nullptr, &m_settings.video_sync_enabled)) { settings_changed = true; UpdateSpeedLimiterState(); @@ -914,13 +917,6 @@ void SDLHostInterface::DrawSettingsWindow() if (ImGui::BeginTabItem("General")) { - if (DrawSettingsSectionHeader("Behavior")) - { - settings_changed |= ImGui::Checkbox("Enable Speed Limiter", &m_settings.speed_limiter_enabled); - settings_changed |= ImGui::Checkbox("Pause On Start", &m_settings.start_paused); - } - - ImGui::NewLine(); if (DrawSettingsSectionHeader("Console")) { ImGui::Text("Region:"); @@ -940,6 +936,33 @@ void SDLHostInterface::DrawSettingsWindow() } } + ImGui::NewLine(); + if (DrawSettingsSectionHeader("Behavior")) + { + if (ImGui::Checkbox("Enable Speed Limiter", &m_settings.speed_limiter_enabled)) + { + settings_changed = true; + UpdateSpeedLimiterState(); + } + + settings_changed |= ImGui::Checkbox("Pause On Start", &m_settings.start_paused); + } + + ImGui::NewLine(); + if (DrawSettingsSectionHeader("Host Synchronization")) + { + if (ImGui::Checkbox("Sync To Audio", &m_settings.audio_sync_enabled)) + { + settings_changed = true; + UpdateSpeedLimiterState(); + } + if (ImGui::Checkbox("Sync To Video", &m_settings.video_sync_enabled)) + { + settings_changed = true; + UpdateSpeedLimiterState(); + } + } + ImGui::NewLine(); if (DrawSettingsSectionHeader("BIOS")) { @@ -1017,11 +1040,6 @@ void SDLHostInterface::DrawSettingsWindow() if (ImGui::Checkbox("Fullscreen", &m_settings.display_fullscreen)) UpdateFullscreen(); - if (ImGui::Checkbox("VSync", &m_settings.gpu_vsync)) - { - UpdateSpeedLimiterState(); - settings_changed = true; - } if (ImGui::Checkbox("Linear Filtering", &m_settings.display_linear_filtering)) { m_display->SetDisplayLinearFiltering(m_settings.display_linear_filtering);