From d29a7a6917d86e2af86571694c2ebdc7c7286ffa Mon Sep 17 00:00:00 2001 From: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Sun, 22 Dec 2024 19:05:18 +0300 Subject: [PATCH] Replace FPS literals with constants. --- UnleashedRecomp/app.cpp | 2 +- UnleashedRecomp/patches/fps_patches.cpp | 2 +- UnleashedRecomp/ui/options_menu.cpp | 2 +- UnleashedRecomp/user/config.h | 3 +++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/UnleashedRecomp/app.cpp b/UnleashedRecomp/app.cpp index d2cf3ac3..306b7f9d 100644 --- a/UnleashedRecomp/app.cpp +++ b/UnleashedRecomp/app.cpp @@ -39,7 +39,7 @@ PPC_FUNC_IMPL(__imp__sub_822C1130); PPC_FUNC(sub_822C1130) { // Correct small delta time errors. - if (Config::FPS >= 15 && Config::FPS < 240) + if (Config::FPS >= FPS_MIN && Config::FPS < FPS_MAX) { double targetDeltaTime = 1.0 / Config::FPS; if (abs(ctx.f1.f64 - targetDeltaTime) < 0.00001) diff --git a/UnleashedRecomp/patches/fps_patches.cpp b/UnleashedRecomp/patches/fps_patches.cpp index 8441fd95..1e466485 100644 --- a/UnleashedRecomp/patches/fps_patches.cpp +++ b/UnleashedRecomp/patches/fps_patches.cpp @@ -83,7 +83,7 @@ static std::chrono::steady_clock::time_point g_next; void ApplicationUpdateMidAsmHook() { - if (Config::FPS >= 15 && Config::FPS < 240) + if (Config::FPS >= FPS_MIN && Config::FPS < FPS_MAX) { auto now = std::chrono::steady_clock::now(); diff --git a/UnleashedRecomp/ui/options_menu.cpp b/UnleashedRecomp/ui/options_menu.cpp index 50e737c0..e37017a4 100644 --- a/UnleashedRecomp/ui/options_menu.cpp +++ b/UnleashedRecomp/ui/options_menu.cpp @@ -850,7 +850,7 @@ static void DrawConfigOptions() DrawConfigOption(rowCount++, yOffset, &Config::ResolutionScale, true, nullptr, 0.25f, 1.0f, 2.0f); DrawConfigOption(rowCount++, yOffset, &Config::Fullscreen, true); DrawConfigOption(rowCount++, yOffset, &Config::VSync, true); - DrawConfigOption(rowCount++, yOffset, &Config::FPS, true, nullptr, 15, 120, 240); + DrawConfigOption(rowCount++, yOffset, &Config::FPS, true, nullptr, FPS_MIN, 120, FPS_MAX); DrawConfigOption(rowCount++, yOffset, &Config::Brightness, true); DrawConfigOption(rowCount++, yOffset, &Config::AntiAliasing, true); DrawConfigOption(rowCount++, yOffset, &Config::TransparencyAntiAliasing, Config::AntiAliasing != EAntiAliasing::None, &Localise("Options_Desc_NotAvailableMSAA")); diff --git a/UnleashedRecomp/user/config.h b/UnleashedRecomp/user/config.h index 685c9e06..f2c173ef 100644 --- a/UnleashedRecomp/user/config.h +++ b/UnleashedRecomp/user/config.h @@ -169,6 +169,9 @@ CONFIG_DEFINE_ENUM_TEMPLATE(ETripleBuffering) { "Off", ETripleBuffering::Off } }; +static constexpr int32_t FPS_MIN = 15; +static constexpr int32_t FPS_MAX = 240; + enum class EAntiAliasing : uint32_t { None = 0,