Skip to content

Commit

Permalink
Add previous movie fix as alternate solution for those still getting …
Browse files Browse the repository at this point in the history
…stretched cutscenes. #82
  • Loading branch information
Lyall committed Oct 20, 2024
1 parent 358821e commit 66a6498
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 2 additions & 0 deletions FFXVIFix.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ HUDSize = 3
[Fix Movies]
; Fixes stretched movie sequences.
Enabled = true
; If movies are still stretched, set "Alternative" to true to attempt to fix movies using a different method.
Alternative = false

[Fix FOV]
; Fixes cropped FOV when using a narrower than 16:9 resolution. (4:3, 16:10 for example)
Expand Down
37 changes: 36 additions & 1 deletion src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ int iWindowedResY;
bool bFixHUD;
int iHUDSize;
bool bFixMovies;
bool bAltFixMovies;
bool bFixFOV;
float fGameplayCamFOV;
float fGameplayCamHorPos;
Expand Down Expand Up @@ -230,6 +231,7 @@ void Configuration()
inipp::get_value(ini.sections["Fix HUD"], "Enabled", bFixHUD);
inipp::get_value(ini.sections["Fix HUD"], "HUDSize", iHUDSize);
inipp::get_value(ini.sections["Fix Movies"], "Enabled", bFixMovies);
inipp::get_value(ini.sections["Fix Movies"], "Alternative", bAltFixMovies);
inipp::get_value(ini.sections["Fix FOV"], "Enabled", bFixFOV);
inipp::get_value(ini.sections["Gameplay Camera"], "AdditionalFOV", fGameplayCamFOV);
inipp::get_value(ini.sections["Gameplay Camera"], "HorizontalPos", fGameplayCamHorPos);
Expand Down Expand Up @@ -696,7 +698,7 @@ void HUD()
}
}

if (bFixMovies) {
if (bFixMovies && !bAltFixMovies) {
// Get movie status
uint8_t* MovieStatusScanResult = Memory::PatternScan(baseModule, "0F 84 ?? ?? ?? ?? C5 ?? ?? ?? ?? ?? ?? ?? C4 ?? ?? ?? ?? 48 8B ?? 80 ?? ?? ?? ?? ?? 02");
if (MovieStatusScanResult) {
Expand Down Expand Up @@ -788,6 +790,39 @@ void HUD()
spdlog::error("HUD: Movies: Offset: Pattern scan failed.");
}
}

if (bFixMovies && bAltFixMovies) {
// Alternative movie fix
uint8_t* AltMoviesScanResult = Memory::PatternScan(baseModule, "8B ?? ?? 48 8B ?? C5 ?? ?? ?? C4 ?? ?? ?? ?? C5 ?? ?? ?? ?? ?? C5 ?? ?? ?? ?? ??");
if (AltMoviesScanResult) {
spdlog::info("HUD: Movies (Alt): Address is {:s}+{:x}", sExeName.c_str(), (uintptr_t)AltMoviesScanResult - (uintptr_t)baseModule);
// Change xmm8 to xmm9
Memory::PatchBytes((uintptr_t)AltMoviesScanResult + 0x1E, "\x4C", 1);

static SafetyHookMid AltMoviesMidHook{};
AltMoviesMidHook = safetyhook::create_mid(AltMoviesScanResult + 0xF,
[](SafetyHookContext& ctx) {
float Width = ctx.xmm0.f32[0];
float Height = ctx.xmm1.f32[0];

if (fAspectRatio > fNativeAspect) {
float HUDWidth = Height * fNativeAspect;
float WidthOffset = (Width - HUDWidth) / 2.00f;
ctx.xmm0.f32[0] = HUDWidth + WidthOffset;
ctx.xmm9.f32[0] = WidthOffset;
}
else if (fAspectRatio < fNativeAspect) {
float HUDHeight = Width / fNativeAspect;
float HeightOffset = (Height - HUDHeight) / 2.00f;
ctx.xmm1.f32[0] = HUDHeight + HeightOffset;
ctx.xmm8.f32[0] = HeightOffset;
}
});
}
else if (!AltMoviesScanResult) {
spdlog::error("HUD: Movies (Alt): Pattern scan failed.");
}
}
}

void Camera()
Expand Down

0 comments on commit 66a6498

Please sign in to comment.