Skip to content

Commit

Permalink
cutscene dof fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirteenAG committed Sep 15, 2024
1 parent e293747 commit 8d4d5aa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
12 changes: 12 additions & 0 deletions source/comvars.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,13 @@ export namespace CMenuManager
export namespace CCutscenes
{
uint32_t* m_dwCutsceneState;

bool(*hasCutsceneFinished)();
}

export namespace CCamera
{
bool(*isWidescreenBordersActive)();
}

export namespace CTimer
Expand Down Expand Up @@ -1227,5 +1234,10 @@ public:

pattern = find_pattern("A1 ? ? ? ? 83 F8 08 74 17", "A1 ? ? ? ? 83 F8 08 74 0C");
pMenuTab = *pattern.get_first<int32_t*>(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;
13 changes: 3 additions & 10 deletions source/framelimit.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -145,9 +143,9 @@ void __cdecl sub_855640()
}
}

if (CCamera__isWidescreenBordersActive())
if (CCamera::isWidescreenBordersActive())
{
if (CCutscenes__hasCutsceneFinished())
if (CCutscenes::hasCutsceneFinished())
{
if (fCutsceneFpsLimit)
CutsceneFpsLimiter.Sync();
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion source/postfx.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8d4d5aa

Please sign in to comment.