From 98ed61b776dc106bb08c704518d8381173322844 Mon Sep 17 00:00:00 2001 From: rebtd7 <59185507+rebtd7@users.noreply.github.com> Date: Fri, 24 Jan 2020 23:08:40 -0300 Subject: [PATCH] Fix enemy scan text on aspect ratios different then 16:9 --- d3d9ex/AutoFix.cpp | 14 ++++++++------ d3d9ex/Context.cpp | 1 - d3d9ex/Context.h | 4 ++-- d3d9ex/XInputManager.cpp | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/d3d9ex/AutoFix.cpp b/d3d9ex/AutoFix.cpp index 3c303a2..ac6df7c 100644 --- a/d3d9ex/AutoFix.cpp +++ b/d3d9ex/AutoFix.cpp @@ -116,6 +116,8 @@ void MainContext::FF13_InitializeGameAddresses() ff13_base_controller_input_address_ptr = (byte**)(baseAddr + 0x02411220); ff13_vibration_low_set_zero_address = baseAddr + 0x4210DF; ff13_vibration_high_set_zero_address = baseAddr + 0x4210F3; + ff13_internal_res_w = (uint32_t*)(baseAddr + 0x22E5168); + ff13_internal_res_h = ff13_internal_res_w + 1; } void MainContext::FF13_OneTimeFixes() { @@ -167,12 +169,12 @@ void MainContext::FF13_FixMissingEnemyScan() { // The game incorrectly uses the same values here regardless of the resolution. PrintLog("Patching libra info box instructions to take in account the game resolution..."); + const float originalHeight = 720.0F; + const float resolutionFactorH = (float)*ff13_internal_res_h / originalHeight; - const float resolutionFactor = (float)context.backbufferWidth / 1280.0F; - - const uint32_t rectHeight = (uint32_t)ceil(130.0F * resolutionFactor); - const uint32_t rectWidth = context.backbufferWidth; - const uint32_t rectPosY = (uint32_t)(496.0F * resolutionFactor); + const uint32_t rectHeight = (uint32_t)ceil(130.0F * resolutionFactorH); + const uint32_t rectWidth = *ff13_internal_res_w; + const uint32_t rectPosY = (uint32_t)(496.0F * resolutionFactorH); context.ChangeMemoryProtectionToReadWriteExecute(ff13_enemy_scan_box_code_address, 18); @@ -375,7 +377,7 @@ void MainContext::ChangeMemoryProtectionToReadWriteExecute(void* address, const } void MainContext::PrintVersionInfo() { - PrintLog("FF13Fix 1.4.0 https://github.com/rebtd7/FF13Fix"); + PrintLog("FF13Fix 1.4.1 https://github.com/rebtd7/FF13Fix"); } bool MainContext::AreAlmostTheSame(float a, float b) { diff --git a/d3d9ex/Context.cpp b/d3d9ex/Context.cpp index 27ce3c5..576a8e6 100644 --- a/d3d9ex/Context.cpp +++ b/d3d9ex/Context.cpp @@ -113,7 +113,6 @@ bool MainContext::ApplyPresentationParameters(D3DPRESENT_PARAMETERS* pPresentati { if (pPresentationParameters) { - context.backbufferWidth = pPresentationParameters->BackBufferWidth; if (config.GetTripleBuffering()) { pPresentationParameters->BackBufferCount = 3; diff --git a/d3d9ex/Context.h b/d3d9ex/Context.h index f728eae..535af79 100644 --- a/d3d9ex/Context.h +++ b/d3d9ex/Context.h @@ -85,6 +85,8 @@ private: byte** ff13_base_controller_input_address_ptr = NULL; byte* ff13_vibration_high_set_zero_address = NULL; byte* ff13_vibration_low_set_zero_address = NULL; + uint32_t* ff13_internal_res_w; + uint32_t* ff13_internal_res_h; byte* FF13_2_SET_FRAME_RATE_INJECTED_CODE = NULL; byte* ff13_2_continuous_scan_instruction_address; @@ -99,8 +101,6 @@ private: const float FF13_2_MAX_FRAME_CAP = 1000.0F; XInputManager* xinputManager; - UINT backbufferWidth = 0; - void FixBehaviorFlagConflict(const DWORD flags_in, DWORD* flags_out); static const std::map behaviorflags_fixes; diff --git a/d3d9ex/XInputManager.cpp b/d3d9ex/XInputManager.cpp index dd6357a..e27d281 100644 --- a/d3d9ex/XInputManager.cpp +++ b/d3d9ex/XInputManager.cpp @@ -48,7 +48,7 @@ void XInputManager::VibrationLoop() const float vibrationStrengthLowFrequency = *vibration_address_low_frequency; const float vibrationStrengthHighFrequency = *vibration_address_high_frequency; if (vibrationStrengthLowFrequency || vibrationStrengthHighFrequency) { - SetControllerVibration(vibrationStrengthLowFrequency * maxVibrationStrength, vibrationStrengthHighFrequency * maxVibrationStrength); + SetControllerVibration((WORD)(vibrationStrengthLowFrequency * maxVibrationStrength), (WORD)(vibrationStrengthHighFrequency * maxVibrationStrength)); wasVibrating = true; } else if(wasVibrating) {