From bece055dca6722d8f5473157250a2b33a3f8a586 Mon Sep 17 00:00:00 2001 From: ThirteenAG Date: Thu, 9 Nov 2023 12:58:20 +0800 Subject: [PATCH] re0/re1 disable fog test --- .../scripts/ResidentEvil.FusionFix.ini | 3 +- .../scripts/ResidentEvil0.FusionFix.ini | 3 +- source/ResidentEvil.FusionFix/dllmain.cpp | 38 ++++++++++++++++++- source/ResidentEvil0.FusionFix/dllmain.cpp | 38 ++++++++++++++++++- 4 files changed, 78 insertions(+), 4 deletions(-) diff --git a/data/ResidentEvil.FusionFix/scripts/ResidentEvil.FusionFix.ini b/data/ResidentEvil.FusionFix/scripts/ResidentEvil.FusionFix.ini index cb76948b4..1e7f8acd6 100644 --- a/data/ResidentEvil.FusionFix/scripts/ResidentEvil.FusionFix.ini +++ b/data/ResidentEvil.FusionFix/scripts/ResidentEvil.FusionFix.ini @@ -5,4 +5,5 @@ DoorSkip = 1 BorderlessWindowed = 1 LightSyncRGB = 1 // Only Logitech hardware is supported, requires Logitech G HUB app DisableNoise = 0 -DisableColorCorrection = 0 \ No newline at end of file +DisableColorCorrection = 0 +DisableFog = 0 diff --git a/data/ResidentEvil0.FusionFix/scripts/ResidentEvil0.FusionFix.ini b/data/ResidentEvil0.FusionFix/scripts/ResidentEvil0.FusionFix.ini index 164f5c761..1cfbe565f 100644 --- a/data/ResidentEvil0.FusionFix/scripts/ResidentEvil0.FusionFix.ini +++ b/data/ResidentEvil0.FusionFix/scripts/ResidentEvil0.FusionFix.ini @@ -4,4 +4,5 @@ DoorSkip = 1 BorderlessWindowed = 1 LightSyncRGB = 1 // Only Logitech hardware is supported, requires Logitech G HUB app DisableNoise = 0 -DisableColorCorrection = 0 \ No newline at end of file +DisableColorCorrection = 0 +DisableFog = 0 diff --git a/source/ResidentEvil.FusionFix/dllmain.cpp b/source/ResidentEvil.FusionFix/dllmain.cpp index cbdb1c37d..6884a4464 100644 --- a/source/ResidentEvil.FusionFix/dllmain.cpp +++ b/source/ResidentEvil.FusionFix/dllmain.cpp @@ -140,6 +140,7 @@ int __fastcall sub_663820(uint32_t* _this, void* edx) bool bDisableNoise = false; bool bDisableColorCorrection = false; +bool bDisableFog = false; uintptr_t pD3D9DeviceAddr; IDirect3DPixelShader9* __stdcall CreatePixelShaderHook(const DWORD** a1) { @@ -292,6 +293,40 @@ IDirect3DPixelShader9* __stdcall CreatePixelShaderHook(const DWORD** a1) } } } + else if (crc == 0xE8C35AD8 && bDisableFog) + { + const char* shader_text = + "ps_3_0\n" + "def c0, 0.00392156886, 0, 0, 0\n" + "def c2, 1, 255, 65025, 0\n" + "dcl_texcoord v0.zw\n" + "dcl_2d s0\n" + "mov r0, c0.w\n" + "mul r0.yzw, r0.x, c2.xxyz\n" + "mov oDepth, r0.x\n" + "frc r0.xyz, r0.yzww\n" + "mad oC0.xyz, r0.yzzw, -c0.xxyw, r0\n" + "mov oC0.w, c1.y\n"; + + LPD3DXBUFFER pCode; + LPD3DXBUFFER pErrorMsgs; + LPDWORD shader_data; + auto result = D3DXAssembleShader(shader_text, strlen(shader_text), NULL, NULL, 0, &pCode, &pErrorMsgs); + if (SUCCEEDED(result)) + { + shader_data = (DWORD*)pCode->GetBufferPointer(); + IDirect3DPixelShader9* shader = nullptr; + result = pDevice->CreatePixelShader(shader_data, &shader); + if (FAILED(result)) { + return pShader; + } + else + { + pShader->Release(); + return shader; + } + } + } } return pShader; @@ -307,6 +342,7 @@ void Init() auto bLightSyncRGB = iniReader.ReadInteger("MAIN", "LightSyncRGB", 1) != 0; bDisableNoise = iniReader.ReadInteger("MAIN", "DisableNoise", 0) != 0; bDisableColorCorrection = iniReader.ReadInteger("MAIN", "DisableColorCorrection", 0) != 0; + bDisableFog = iniReader.ReadInteger("MAIN", "DisableFog", 0) != 0; if (bUnlockAllResolutions) { @@ -465,7 +501,7 @@ void Init() ); } - if (bDisableNoise || bDisableColorCorrection) + if (bDisableNoise || bDisableColorCorrection || bDisableFog) { pD3D9DeviceAddr = (uintptr_t)*hook::get_pattern("A1 ? ? ? ? 56 66 0F 6E 80", 1); injector::MakeCALL(hook::get_pattern("E8 ? ? ? ? 89 47 08 66 8B 4C 24 ? 0F B7 C1 43 83 C5 0C 3B D8 72 C7 33 C0"), CreatePixelShaderHook, true); diff --git a/source/ResidentEvil0.FusionFix/dllmain.cpp b/source/ResidentEvil0.FusionFix/dllmain.cpp index 4ed117792..7a82bcdfb 100644 --- a/source/ResidentEvil0.FusionFix/dllmain.cpp +++ b/source/ResidentEvil0.FusionFix/dllmain.cpp @@ -21,6 +21,7 @@ void __fastcall sub_529250(uint32_t* _this, void* edx, int32_t a2) bool bDisableNoise = false; bool bDisableColorCorrection = false; +bool bDisableFog = false; uintptr_t pD3D9DeviceAddr; IDirect3DPixelShader9* __stdcall CreatePixelShaderHook(const DWORD** a1) { @@ -173,6 +174,40 @@ IDirect3DPixelShader9* __stdcall CreatePixelShaderHook(const DWORD** a1) } } } + else if (crc == 0xE8C35AD8 && bDisableFog) + { + const char* shader_text = + "ps_3_0\n" + "def c0, 0.00392156886, 0, 0, 0\n" + "def c2, 1, 255, 65025, 0\n" + "dcl_texcoord v0.zw\n" + "dcl_2d s0\n" + "mov r0, c0.w\n" + "mul r0.yzw, r0.x, c2.xxyz\n" + "mov oDepth, r0.x\n" + "frc r0.xyz, r0.yzww\n" + "mad oC0.xyz, r0.yzzw, -c0.xxyw, r0\n" + "mov oC0.w, c1.y\n"; + + LPD3DXBUFFER pCode; + LPD3DXBUFFER pErrorMsgs; + LPDWORD shader_data; + auto result = D3DXAssembleShader(shader_text, strlen(shader_text), NULL, NULL, 0, &pCode, &pErrorMsgs); + if (SUCCEEDED(result)) + { + shader_data = (DWORD*)pCode->GetBufferPointer(); + IDirect3DPixelShader9* shader = nullptr; + result = pDevice->CreatePixelShader(shader_data, &shader); + if (FAILED(result)) { + return pShader; + } + else + { + pShader->Release(); + return shader; + } + } + } } return pShader; @@ -201,6 +236,7 @@ void Init() auto bLightSyncRGB = iniReader.ReadInteger("MAIN", "LightSyncRGB", 1) != 0; bDisableNoise = iniReader.ReadInteger("MAIN", "DisableNoise", 0) != 0; bDisableColorCorrection = iniReader.ReadInteger("MAIN", "DisableColorCorrection", 0) != 0; + bDisableFog = iniReader.ReadInteger("MAIN", "DisableFog", 0) != 0; if (nHideMouseCursorAfterMs) { @@ -292,7 +328,7 @@ void Init() ); } - if (bDisableNoise || bDisableColorCorrection) + if (bDisableNoise || bDisableColorCorrection || bDisableFog) { pD3D9DeviceAddr = (uintptr_t)*hook::get_pattern("8B 0D ? ? ? ? E8 ? ? ? ? 0F B6 C0 F7 D8", 2); injector::MakeCALL(hook::get_pattern("E8 ? ? ? ? 89 46 08 66 8B 4C 24 ? 0F B7 C1 43 83 C5 0C 3B D8 72 C7 33 C0"), CreatePixelShaderHook, true);