From 8d4d5aa256d613c2675a68016839a39b93e519ae Mon Sep 17 00:00:00 2001 From: ThirteenAG Date: Sun, 15 Sep 2024 19:04:55 +0800 Subject: [PATCH] cutscene dof fix --- source/comvars.ixx | 12 ++++++++++++ source/framelimit.ixx | 13 +++---------- source/postfx.ixx | 2 +- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/source/comvars.ixx b/source/comvars.ixx index 4fbdb1e0..099aa505 100644 --- a/source/comvars.ixx +++ b/source/comvars.ixx @@ -914,6 +914,13 @@ export namespace CMenuManager export namespace CCutscenes { uint32_t* m_dwCutsceneState; + + bool(*hasCutsceneFinished)(); +} + +export namespace CCamera +{ + bool(*isWidescreenBordersActive)(); } export namespace CTimer @@ -1227,5 +1234,10 @@ public: pattern = find_pattern("A1 ? ? ? ? 83 F8 08 74 17", "A1 ? ? ? ? 83 F8 08 74 0C"); pMenuTab = *pattern.get_first(1); + + pattern = find_pattern("E8 ? ? ? ? 84 C0 75 89", "E8 ? ? ? ? 84 C0 75 15 38 05"); + CCutscenes::hasCutsceneFinished = (bool(*)())injector::GetBranchDestination(pattern.get_first(0)).get(); + pattern = find_pattern("E8 ? ? ? ? 84 C0 75 44 38 05 ? ? ? ? 74 26", "E8 ? ? ? ? 84 C0 75 42 38 05"); + CCamera::isWidescreenBordersActive = (bool(*)())injector::GetBranchDestination(pattern.get_first(0)).get(); } } Common; \ No newline at end of file diff --git a/source/framelimit.ixx b/source/framelimit.ixx index d59ae7b2..fc97493f 100644 --- a/source/framelimit.ixx +++ b/source/framelimit.ixx @@ -130,8 +130,6 @@ FrameLimiter CutsceneFpsLimiter; FrameLimiter ScriptCutsceneFpsLimiter; FrameLimiter LoadingFpsLimiter; FrameLimiter LoadingFpsLimiter2; -bool(*CCutscenes__hasCutsceneFinished)(); -bool(*CCamera__isWidescreenBordersActive)(); bool bUnlockFramerateDuringLoadscreens = true; void __cdecl sub_855640() { @@ -145,9 +143,9 @@ void __cdecl sub_855640() } } - if (CCamera__isWidescreenBordersActive()) + if (CCamera::isWidescreenBordersActive()) { - if (CCutscenes__hasCutsceneFinished()) + if (CCutscenes::hasCutsceneFinished()) { if (fCutsceneFpsLimit) CutsceneFpsLimiter.Sync(); @@ -205,12 +203,7 @@ public: LoadingFpsLimiter.Init(mode, std::clamp(fLoadingFpsLimit, 30.0f, FLT_MAX)); LoadingFpsLimiter2.Init(mode, 240.0f); - auto pattern = find_pattern("E8 ? ? ? ? 84 C0 75 89", "E8 ? ? ? ? 84 C0 75 15 38 05"); - CCutscenes__hasCutsceneFinished = (bool(*)()) injector::GetBranchDestination(pattern.get_first(0)).get(); - pattern = find_pattern("E8 ? ? ? ? 84 C0 75 44 38 05 ? ? ? ? 74 26", "E8 ? ? ? ? 84 C0 75 42 38 05"); - CCamera__isWidescreenBordersActive = (bool(*)()) injector::GetBranchDestination(pattern.get_first(0)).get(); - - pattern = find_pattern("8B 35 ? ? ? ? 8B 0D ? ? ? ? 8B 15 ? ? ? ? A1", "A1 ? ? ? ? 83 F8 01 8B 0D"); + auto pattern = find_pattern("8B 35 ? ? ? ? 8B 0D ? ? ? ? 8B 15 ? ? ? ? A1", "A1 ? ? ? ? 83 F8 01 8B 0D"); injector::WriteMemory(pattern.get_first(0), 0x901CC483, true); //nop + add esp,1C injector::MakeJMP(pattern.get_first(4), sub_855640, true); // + jmp diff --git a/source/postfx.ixx b/source/postfx.ixx index 20487241..780b3ac9 100644 --- a/source/postfx.ixx +++ b/source/postfx.ixx @@ -804,7 +804,7 @@ private: } static auto dof = FusionFixSettings.GetRef("PREF_TCYC_DOF"); - if(dof->get() > FusionFixSettings.DofText.eCutscenesOnly || (dof->get() == FusionFixSettings.DofText.eCutscenesOnly && Natives::HasCutsceneFinished())) { + if(dof->get() > FusionFixSettings.DofText.eCutscenesOnly || (dof->get() == FusionFixSettings.DofText.eCutscenesOnly && CCutscenes::hasCutsceneFinished())) { if(PostFxResources.useDepthOfField > 0 && PostFxResources.dof_blur_ps && PostFxResources.dof_coc_ps) { if(PostFxResources.ppZStencilSurface && PostFxResources.halfZStencilSurface && PostFxResources.FullScreenDownsampleSurf && PostFxResources.FullScreenDownsampleSurf2) { pDevice->SetSamplerState(8, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);