From 56ad019fe1470c08022a31fac586c84333c563e1 Mon Sep 17 00:00:00 2001 From: Sergey P Date: Sun, 30 Jul 2023 00:42:01 +0800 Subject: [PATCH] fps related fix - fixes #107 --- .../TBoGT/common/data/frontend_menus.xml | 5 +-- .../TLAD/common/data/frontend_menus.xml | 5 +-- data/update/common/data/frontend_menus.xml | 5 +-- premake5.lua | 2 +- shaders/GTAIV.ShaderFixesCollection | 2 +- source/dllmain.cpp | 31 ++++++++++++++++--- 6 files changed, 37 insertions(+), 13 deletions(-) diff --git a/data/update/TBoGT/common/data/frontend_menus.xml b/data/update/TBoGT/common/data/frontend_menus.xml index 7f191b03..23334226 100644 --- a/data/update/TBoGT/common/data/frontend_menus.xml +++ b/data/update/TBoGT/common/data/frontend_menus.xml @@ -382,6 +382,7 @@ + @@ -550,7 +551,7 @@ - + - + + @@ -581,7 +582,7 @@ - + @@ -1199,7 +1200,7 @@ - + diff --git a/data/update/common/data/frontend_menus.xml b/data/update/common/data/frontend_menus.xml index a16e6200..8577605e 100644 --- a/data/update/common/data/frontend_menus.xml +++ b/data/update/common/data/frontend_menus.xml @@ -311,6 +311,7 @@ + @@ -451,7 +452,7 @@ - + @@ -802,7 +803,7 @@ - + diff --git a/premake5.lua b/premake5.lua index 5569fe37..5b7019cb 100644 --- a/premake5.lua +++ b/premake5.lua @@ -2,7 +2,7 @@ workspace "GTAIV.EFLC.FusionFix" configurations { "Release", "Debug" } architecture "x86" location "build" - buildoptions {"-std:c++latest"} + cppdialect "C++latest" kind "SharedLib" language "C++" targetdir "bin/%{cfg.buildcfg}" diff --git a/shaders/GTAIV.ShaderFixesCollection b/shaders/GTAIV.ShaderFixesCollection index 9146927b..0ebbdd94 160000 --- a/shaders/GTAIV.ShaderFixesCollection +++ b/shaders/GTAIV.ShaderFixesCollection @@ -1 +1 @@ -Subproject commit 9146927b76f6741643c8a868f448f3988e2a417f +Subproject commit 0ebbdd9449c5b0e1a1d050b6be3626bf3c8fdabc diff --git a/source/dllmain.cpp b/source/dllmain.cpp index 000466cd..1fce5573 100644 --- a/source/dllmain.cpp +++ b/source/dllmain.cpp @@ -190,7 +190,7 @@ float fFpsLimit; float fCutsceneFpsLimit; float fScriptCutsceneFpsLimit; float fScriptCutsceneFovLimit; -std::vector fpsCaps = { 0, 1, 2, 30, 40, 50, 60, 75, 100, 120, 144, 165, 240 }; +std::vector fpsCaps = { 0, 1, 2, 30, 40, 50, 60, 75, 100, 120, 144, 165, 240, 360 }; class FrameLimiter { @@ -202,9 +202,11 @@ class FrameLimiter double TIME_Ticks = 0.0; double TIME_Frametime = 0.0; float fFPSLimit = 0.0f; + bool bFpsLimitWasUpdated = false; public: void Init(FPSLimitMode mode, float fps_limit) { + bFpsLimitWasUpdated = true; mFPSLimitMode = mode; fFPSLimit = fps_limit; @@ -225,6 +227,12 @@ class FrameLimiter } DWORD Sync_RT() { + if (bFpsLimitWasUpdated) + { + bFpsLimitWasUpdated = false; + return 1; + } + DWORD lastTicks, currentTicks; LARGE_INTEGER counter; @@ -237,6 +245,12 @@ class FrameLimiter } DWORD Sync_SLP() { + if (bFpsLimitWasUpdated) + { + bFpsLimitWasUpdated = false; + return 1; + } + LARGE_INTEGER counter; QueryPerformanceCounter(&counter); double millis_current = (double)counter.QuadPart / TIME_Frequency; @@ -274,13 +288,17 @@ FrameLimiter CutsceneFpsLimiter; FrameLimiter ScriptCutsceneFpsLimiter; bool(*CCutscenes__hasCutsceneFinished)(); bool(*CCamera__isWidescreenBordersActive)(); +uint8_t* bLoadscreenShown = nullptr; void __cdecl sub_855640() { static auto preset = FusionFixSettings.GetRef("PREF_FPS_LIMIT_PRESET"); - if (preset && *preset >= 2) { - if (fFpsLimit > 0.0f || (*preset > 2 && *preset < fpsCaps.size())) - FpsLimiter.Sync(); + if (bLoadscreenShown && !*bLoadscreenShown) + { + if (preset && *preset >= 2) { + if (fFpsLimit > 0.0f || (*preset > 2 && *preset < fpsCaps.size())) + FpsLimiter.Sync(); + } } if (CCamera__isWidescreenBordersActive()) @@ -909,6 +927,9 @@ void Init() else FpsLimiter.Init(mode, fFpsLimit); }); + + pattern = hook::pattern("80 3D ? ? ? ? ? 53 56 8A FA"); + bLoadscreenShown = *pattern.get_first(2); } if (fScriptCutsceneFovLimit) @@ -1071,7 +1092,7 @@ void Init() auto id = regs.edx; auto value = regs.ebx; if (FusionFixSettings.isSame(id, "PREF_FPS_LIMIT_PRESET")) { - if (regs.ebx == 1) { + if (value == 1) { auto old = FusionFixSettings(id); if (old >= 2) value = 0;