Skip to content

Commit

Permalink
re0/re1 disable fog test
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirteenAG committed Nov 9, 2023
1 parent 7b45fe3 commit bece055
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ DoorSkip = 1
BorderlessWindowed = 1
LightSyncRGB = 1 // Only Logitech hardware is supported, requires Logitech G HUB app
DisableNoise = 0
DisableColorCorrection = 0
DisableColorCorrection = 0
DisableFog = 0
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ DoorSkip = 1
BorderlessWindowed = 1
LightSyncRGB = 1 // Only Logitech hardware is supported, requires Logitech G HUB app
DisableNoise = 0
DisableColorCorrection = 0
DisableColorCorrection = 0
DisableFog = 0
38 changes: 37 additions & 1 deletion source/ResidentEvil.FusionFix/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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)
{
Expand Down Expand Up @@ -465,7 +501,7 @@ void Init()
);
}

if (bDisableNoise || bDisableColorCorrection)
if (bDisableNoise || bDisableColorCorrection || bDisableFog)
{
pD3D9DeviceAddr = (uintptr_t)*hook::get_pattern<uint32_t>("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);
Expand Down
38 changes: 37 additions & 1 deletion source/ResidentEvil0.FusionFix/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -292,7 +328,7 @@ void Init()
);
}

if (bDisableNoise || bDisableColorCorrection)
if (bDisableNoise || bDisableColorCorrection || bDisableFog)
{
pD3D9DeviceAddr = (uintptr_t)*hook::get_pattern<uint32_t>("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);
Expand Down

0 comments on commit bece055

Please sign in to comment.