diff --git a/d3d9ex/AutoFix.cpp b/d3d9ex/AutoFix.cpp index f0f00c7..8ba0bee 100644 --- a/d3d9ex/AutoFix.cpp +++ b/d3d9ex/AutoFix.cpp @@ -197,12 +197,21 @@ void MainContext::FF13_InitializeGameAddresses() ff13_party_screen_scissor_scaling_factor_2 = baseAddr + 0x668E1E; ff13_party_screen_scissor_scaling_factor_3 = baseAddr + 0x668E56; ff13_party_screen_scissor_scaling_factor_4 = baseAddr + 0x668E91; + ff13_message_box_call_address = baseAddr + 0xA8A98F; +} + +void MainContext::ForceWindowActivate(const HWND hWnd) { + PostMessage(hWnd, WM_ACTIVATE, WA_INACTIVE, NULL); + PostMessage(hWnd, WM_ACTIVATE, WA_CLICKACTIVE, NULL); } void MainContext::FF13_OneTimeFixes() { - if (IsDXVK()) - SetForegroundWindow(hWndFF13); + if (IsDXVK()) { + PatchMessageBox(ff13_message_box_call_address); + } + + ForceWindowActivate(hWndFF13); FF13_NOPIngameFrameRateLimitSetter(); FF13_RemoveContinuousControllerScan(); @@ -309,8 +318,10 @@ void MainContext::FF13_SetFrameRateVariables() void MainContext::FF13_2_OneTimeFixes() { - if (IsDXVK()) - SetForegroundWindow(hWndFF13); + ForceWindowActivate(hWndFF13); + if (IsDXVK()) { + PatchMessageBox(ff13_2_message_box_call_address); + } if (*ff13_2_frame_pacer_ptr_address) { **ff13_2_frame_pacer_ptr_address = MAX_FRAME_RATE_LIMIT; @@ -327,6 +338,22 @@ void MainContext::FF13_2_OneTimeFixes() } } +void MainContext::PatchMessageBox(uint8_t* callInstructionAddress) +{ + PrintLog("Removing 'Quit game' textbox"); + const int patchSize = 6; + uint8_t patch[patchSize]; + + // mov eax, IDYES + patch[0] = 0xB8; + *((uint32_t*)(patch + 1)) = IDYES; + + // nop + patch[5] = 0x90; + + MemPatch::Patch(callInstructionAddress, patch, patchSize); +} + void MainContext::FF13_2_EnableControllerVibration() { if (!config.GetFFXIIIEnableControllerVibration()) { @@ -366,6 +393,7 @@ void MainContext::FF13_2_InitializeGameAddresses() ff13_2_vibration_high_set_zero_address = baseAddr + 0x2A7226; ff13_2_internal_res_w = (uint32_t*)(baseAddr + 0x1FA864C); ff13_2_internal_res_h = ff13_2_internal_res_w + 1; + ff13_2_message_box_call_address = baseAddr + 0x8047C0; } void MainContext::FF13_2_RemoveContinuousControllerScan() diff --git a/d3d9ex/Context.cpp b/d3d9ex/Context.cpp index b538ed3..90d22f7 100644 --- a/d3d9ex/Context.cpp +++ b/d3d9ex/Context.cpp @@ -179,6 +179,7 @@ bool MainContext::ApplyPresentationParameters(D3DPRESENT_PARAMETERS* pPresentati pPresentationParameters->SwapEffect = pPresentationParameters->MultiSampleType == D3DMULTISAMPLE_NONE ? D3DSWAPEFFECT_DISCARD : D3DSWAPEFFECT_FLIP; pPresentationParameters->Windowed = TRUE; pPresentationParameters->FullScreen_RefreshRateInHz = 0; + PrintLog("ForceWindowedMode"); } } diff --git a/d3d9ex/Context.h b/d3d9ex/Context.h index 40978d5..484fd32 100644 --- a/d3d9ex/Context.h +++ b/d3d9ex/Context.h @@ -93,6 +93,7 @@ private: uint8_t* ff13_party_screen_scissor_scaling_factor_2 = NULL; uint8_t* ff13_party_screen_scissor_scaling_factor_3 = NULL; uint8_t* ff13_party_screen_scissor_scaling_factor_4 = NULL; + uint8_t* ff13_message_box_call_address = NULL; uint32_t* ff13_internal_res_w; uint32_t* ff13_internal_res_h; @@ -104,6 +105,7 @@ private: uint8_t** ff13_2_base_controller_input_address_ptr = NULL; uint8_t* ff13_2_vibration_high_set_zero_address = NULL; uint8_t* ff13_2_vibration_low_set_zero_address = NULL; + uint8_t* ff13_2_message_box_call_address = NULL; uint32_t* ff13_2_internal_res_w; uint32_t* ff13_2_internal_res_h; @@ -139,6 +141,7 @@ private: void PrintVersionInfo(); void FF13_InitializeGameAddresses(); + void FF13_OneTimeFixes(); void FF13_EnableControllerVibration(); void FF13_NOPIngameFrameRateLimitSetter(); @@ -154,8 +157,9 @@ private: void FF13_2_EnableControllerVibration(); void AdjustVertexData(const uint32_t width, const uint32_t height); - bool MatchesExpectedVertexStream(const float* pVertexStreamZeroData); + void ForceWindowActivate(const HWND hWnd); + void PatchMessageBox(uint8_t* callInstructionAddress); bool OneTimeFixInit(std::unique_ptr& className, HWND hWnd); std::atomic_bool otf_init = false;