Skip to content

Commit

Permalink
Add motion blur + framegen option.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyall committed Aug 29, 2024
1 parent a4ea093 commit 37f8df6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
4 changes: 4 additions & 0 deletions FFXVIFix.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Enabled = true
; Set to true to stop frame generation from being disabled during real-time cutscenes.
Enabled = true

[Motion Blur + Frame Generation]
; Set to true to unlock the ability to use motion blur while having frame generation enabled.
Enabled = true

[JPEG XL Tweaks]
; Set "NumThreads" to control the amount of worker threads used when taking JXL screenshots. (Game default = Max threads)
; This can reduce hitching when taking screenshots by setting the value to 4 on a modern CPU.
Expand Down
37 changes: 21 additions & 16 deletions src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ bool bFixFOV;
float fAdditionalFOV;
bool bUncapFPS;
bool bCutsceneFramegen;
bool bMotionBlurFramegen;
float fJXLQuality = 75.0f;
int iJXLThreads = 1;

Expand Down Expand Up @@ -148,6 +149,7 @@ void Configuration()
inipp::get_value(ini.sections["Gameplay FOV"], "AdditionalFOV", fAdditionalFOV);
inipp::get_value(ini.sections["Remove 30FPS Cap"], "Enabled", bUncapFPS);
inipp::get_value(ini.sections["Cutscene Frame Generation"], "Enabled", bCutsceneFramegen);
inipp::get_value(ini.sections["Motion Blur + Frame Generation"], "Enabled", bMotionBlurFramegen);
inipp::get_value(ini.sections["JPEG XL Tweaks"], "NumThreads", iJXLThreads);
inipp::get_value(ini.sections["JPEG XL Tweaks"], "Quality", fJXLQuality);

Expand All @@ -163,6 +165,7 @@ void Configuration()
spdlog::info("Config Parse: fAdditionalFOV: {}", fAdditionalFOV);
spdlog::info("Config Parse: bUncapFPS: {}", bUncapFPS);
spdlog::info("Config Parse: bCutsceneFramegen: {}", bCutsceneFramegen);
spdlog::info("Config Parse: bMotionBlurFramegen: {}", bMotionBlurFramegen);
if (iJXLThreads > (int)std::thread::hardware_concurrency() || iJXLThreads < 1 ) {
iJXLThreads = 1;
spdlog::warn("Config Parse: iJXLThreads value invalid, set to {}", iJXLThreads);
Expand Down Expand Up @@ -510,22 +513,24 @@ size_t JxlThreadParallelRunnerDefaultNumWorkerThreads_hk(void)

void Misc()
{
// Motion blur + frame generation
uint8_t* FrameGenMotionBlurLockoutScanResult = Memory::PatternScan(baseModule, "0F 85 ?? ?? ?? ?? 44 ?? ?? ?? ?? ?? ?? 44 88 ?? ?? ?? C6 ?? ?? ?? ?? 44 88 ?? ?? ?? E9 ?? ?? ?? ??");
uint8_t* FrameGenMotionBlurLogicScanResult = Memory::PatternScan(baseModule, "74 ?? C4 ?? ?? ?? ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? C4 ?? ?? ?? ?? ?? ?? ?? ?? EB ?? 41 ?? ?? ?? ?? ?? ?? 74 ??");
if (FrameGenMotionBlurLockoutScanResult && FrameGenMotionBlurLogicScanResult) {
spdlog::info("Frame Generation Motion Blur: Menu Lock: Address is {:s}+{:x}", sExeName.c_str(), (uintptr_t)FrameGenMotionBlurLockoutScanResult - (uintptr_t)baseModule);
spdlog::info("Frame Generation Motion Blur: Logic: Address is {:s}+{:x}", sExeName.c_str(), (uintptr_t)FrameGenMotionBlurLogicScanResult - (uintptr_t)baseModule);

// Stop the game menu from hiding motion blur option when frame generation is enabled.
Memory::PatchBytes((uintptr_t)FrameGenMotionBlurLockoutScanResult, "\x90\x90\x90\x90\x90\x90", 6);
// Stop the game from setting the motion blur float to 0 when frame generation is enabled.
Memory::PatchBytes((uintptr_t)FrameGenMotionBlurLogicScanResult, "\xEB", 1);

spdlog::info("Frame Generation Motion Blur: Patched instructions.");
}
else if (!FrameGenMotionBlurLockoutScanResult || !FrameGenMotionBlurLogicScanResult) {
spdlog::error("Frame Generation Motion Blur: Pattern scan failed.");
if (bMotionBlurFramegen) {
// Motion blur + frame generation
uint8_t* FrameGenMotionBlurLockoutScanResult = Memory::PatternScan(baseModule, "0F 85 ?? ?? ?? ?? 44 ?? ?? ?? ?? ?? ?? 44 88 ?? ?? ?? C6 ?? ?? ?? ?? 44 88 ?? ?? ?? E9 ?? ?? ?? ??");
uint8_t* FrameGenMotionBlurLogicScanResult = Memory::PatternScan(baseModule, "74 ?? C4 ?? ?? ?? ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? C4 ?? ?? ?? ?? ?? ?? ?? ?? EB ?? 41 ?? ?? ?? ?? ?? ?? 74 ??");
if (FrameGenMotionBlurLockoutScanResult && FrameGenMotionBlurLogicScanResult) {
spdlog::info("Frame Generation Motion Blur: Menu Lock: Address is {:s}+{:x}", sExeName.c_str(), (uintptr_t)FrameGenMotionBlurLockoutScanResult - (uintptr_t)baseModule);
spdlog::info("Frame Generation Motion Blur: Logic: Address is {:s}+{:x}", sExeName.c_str(), (uintptr_t)FrameGenMotionBlurLogicScanResult - (uintptr_t)baseModule);

// Stop the game menu from hiding motion blur option when frame generation is enabled.
Memory::PatchBytes((uintptr_t)FrameGenMotionBlurLockoutScanResult, "\x90\x90\x90\x90\x90\x90", 6);
// Stop the game from setting the motion blur float to 0 when frame generation is enabled.
Memory::PatchBytes((uintptr_t)FrameGenMotionBlurLogicScanResult, "\xEB", 1);

spdlog::info("Frame Generation Motion Blur: Patched instructions.");
}
else if (!FrameGenMotionBlurLockoutScanResult || !FrameGenMotionBlurLogicScanResult) {
spdlog::error("Frame Generation Motion Blur: Pattern scan failed.");
}
}
}

Expand Down

0 comments on commit 37f8df6

Please sign in to comment.