From 0e23f0ee7bee9da847c4b32a38124b1a7df790e9 Mon Sep 17 00:00:00 2001 From: rebtd7 <59185507+rebtd7@users.noreply.github.com> Date: Sun, 3 May 2020 19:00:06 -0300 Subject: [PATCH] Fix menus for anamorphic resolutions --- d3d9ex/AutoFix.cpp | 28 ++++++++++++++++++++++------ d3d9ex/Context.h | 5 ++++- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/d3d9ex/AutoFix.cpp b/d3d9ex/AutoFix.cpp index 6edd0fe..2de07a7 100644 --- a/d3d9ex/AutoFix.cpp +++ b/d3d9ex/AutoFix.cpp @@ -76,10 +76,10 @@ bool MainContext::ApplyBehaviorFlagsFix(DWORD* flags) } void MainContext::ScaleScissorRect(RECT * rect) { - rect->left = (LONG) (rect->left * scissor_scaling_factor); - rect->top = (LONG) (rect->top * scissor_scaling_factor); - rect->right = (LONG)(rect->right * scissor_scaling_factor); - rect->bottom = (LONG) (rect-> bottom * scissor_scaling_factor); + rect->left = (LONG) (rect->left * scissor_scaling_factor_w); + rect->top = (LONG) (rect->top * scissor_scaling_factor_h); + rect->right = (LONG)(rect->right * scissor_scaling_factor_w); + rect->bottom = (LONG) (rect-> bottom * scissor_scaling_factor_h); } HRESULT APIENTRY MainContext::ApplyVertexBufferFix(IDirect3DDevice9* pIDirect3DDevice9, UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) @@ -132,6 +132,8 @@ void MainContext::FF13_InitializeGameAddresses() ff13_internal_res_h = ff13_internal_res_w + 1; ff13_loading_screen_scissor_scaling_factor_1 = baseAddr + 0x616596; ff13_loading_screen_scissor_scaling_factor_2 = baseAddr + 0x6165BB; + ff13_loading_screen_scissor_scaling_factor_3 = baseAddr + 0x61654C; + ff13_loading_screen_scissor_scaling_factor_4 = baseAddr + 0x616571; ff13_settings_screen_scissor_scaling_factor = baseAddr + 0x572B26; ff13_party_screen_scissor_scaling_factor_1 = baseAddr + 0x668DE9; ff13_party_screen_scissor_scaling_factor_2 = baseAddr + 0x668E1E; @@ -210,9 +212,13 @@ void MainContext::FF13_RemoveContinuousControllerScan() { void MainContext::FF13_FixScissorRect() { PrintLog("Fixing ScissorRect..."); + const float originalWidth = 1280.0F; + const float resolutionFactorW = (float)*ff13_internal_res_w / originalWidth; + scissor_scaling_factor_w = resolutionFactorW; + const float originalHeight = 720.0F; const float resolutionFactorH = (float)*ff13_internal_res_h / originalHeight; - scissor_scaling_factor = resolutionFactorH; + scissor_scaling_factor_h = resolutionFactorH; // The game scales some scissor rects, but not all of them. // It seems easier to neuter its internal scaling process and scale everything on our own... @@ -227,6 +233,16 @@ void MainContext::FF13_FixScissorRect() { *(ff13_loading_screen_scissor_scaling_factor_2 + 1) = 0x90; // NOP *(ff13_loading_screen_scissor_scaling_factor_2 + 2) = 0x90; // NOP + context.ChangeMemoryProtectionToReadWriteExecute(ff13_loading_screen_scissor_scaling_factor_3, 3); + *(ff13_loading_screen_scissor_scaling_factor_3 + 0) = 0x90; // NOP + *(ff13_loading_screen_scissor_scaling_factor_3 + 1) = 0x90; // NOP + *(ff13_loading_screen_scissor_scaling_factor_3 + 2) = 0x90; // NOP + + context.ChangeMemoryProtectionToReadWriteExecute(ff13_loading_screen_scissor_scaling_factor_4, 3); + *(ff13_loading_screen_scissor_scaling_factor_4 + 0) = 0x90; // NOP + *(ff13_loading_screen_scissor_scaling_factor_4 + 1) = 0x90; // NOP + *(ff13_loading_screen_scissor_scaling_factor_4 + 2) = 0x90; // NOP + context.ChangeMemoryProtectionToReadWriteExecute(ff13_settings_screen_scissor_scaling_factor, 5); *(ff13_settings_screen_scissor_scaling_factor) = 0x90; // NOP *(ff13_settings_screen_scissor_scaling_factor + 1) = 0x90; // NOP @@ -475,7 +491,7 @@ void MainContext::ChangeMemoryProtectionToReadWriteExecute(void* address, const } void MainContext::PrintVersionInfo() { - PrintLog("FF13Fix 1.4.5 https://github.com/rebtd7/FF13Fix"); + PrintLog("FF13Fix 1.4.6 https://github.com/rebtd7/FF13Fix"); } bool MainContext::AreAlmostTheSame(float a, float b) { diff --git a/d3d9ex/Context.h b/d3d9ex/Context.h index 022b0ee..bf8dff8 100644 --- a/d3d9ex/Context.h +++ b/d3d9ex/Context.h @@ -87,6 +87,8 @@ private: uint8_t* ff13_vibration_low_set_zero_address = NULL; uint8_t* ff13_loading_screen_scissor_scaling_factor_1 = NULL; uint8_t* ff13_loading_screen_scissor_scaling_factor_2 = NULL; + uint8_t* ff13_loading_screen_scissor_scaling_factor_3 = NULL; + uint8_t* ff13_loading_screen_scissor_scaling_factor_4 = NULL; uint8_t* ff13_settings_screen_scissor_scaling_factor = NULL; uint8_t* ff13_party_screen_scissor_scaling_factor_1 = NULL; uint8_t* ff13_party_screen_scissor_scaling_factor_2 = NULL; @@ -109,7 +111,8 @@ private: const float FF13_2_30_FPS = 30.0F; const float FF13_2_MAX_FRAME_CAP = 1000.0F; - float scissor_scaling_factor = 1.0f; + float scissor_scaling_factor_w = 1.0f; + float scissor_scaling_factor_h = 1.0f; XInputManager* xinputManager; std::thread * patchingThread = NULL;