From eb7f5a9dd9055fc5ea07b24276c719b19f83b606 Mon Sep 17 00:00:00 2001 From: nastys <@> Date: Wed, 1 Sep 2021 02:35:30 +0200 Subject: [PATCH] Gamma control --- .../source/PD-Loader/Patches/PatchApplier710.h | 11 ++++++++++- .../source/PD-Loader/Patches/patches-framework.h | 1 + source-code/source/PD-Loader/templates.h | 6 ++++++ source-code/source/plugins/Launcher/Resources.restext | 2 ++ source-code/source/plugins/Launcher/framework.h | 1 + 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/source-code/source/PD-Loader/Patches/PatchApplier710.h b/source-code/source/PD-Loader/Patches/PatchApplier710.h index f018694..feab975 100644 --- a/source-code/source/PD-Loader/Patches/PatchApplier710.h +++ b/source-code/source/PD-Loader/Patches/PatchApplier710.h @@ -686,7 +686,7 @@ class PatchApplier710 : public PatchApplier { { InjectCode((void*)(0x14011e44e), { 0xf3, 0x0f, 0x10, 0x05, 0x8a, 0xcf, 0x9c, 0x00 }); // hijack xmm0 InjectCode((void*)(0x14011e46b), { 0xf3, 0x0f, 0x11, 0x44, 0x24, 0x20 }); // get value from xmm0 instead of xmm1 - float startPos = (float)nLagCompensation / 1000.0; + float startPos = (float)nLagCompensation / 1000.0f; InjectCode((void*)(0x140aeB3e0), { *((uint8_t*)(&startPos)), *((uint8_t*)(&startPos)+1), *((uint8_t*)(&startPos) + 2), *((uint8_t*)(&startPos) + 3) }); printf("[Patches] Lag Compensation: %f\n", startPos); @@ -765,6 +765,15 @@ class PatchApplier710 : public PatchApplier { InjectCode((void*)(0x140300a88), { 0x90, 0x90, 0x90 }); // NOPs } + // gamma + if (nGamma != 100) + { + float gamma_float = (float)nGamma / 100.0f; + InjectCode((void*)(0x1404a863b), { *((uint8_t*)(&gamma_float)), *((uint8_t*)(&gamma_float) + 1), *((uint8_t*)(&gamma_float) + 2), *((uint8_t*)(&gamma_float) + 3) }); + + printf("[Patches] Gamma: %f\n", gamma_float); + } + // modpack redirection /*{ wchar_t* mpstr = NULL; diff --git a/source-code/source/PD-Loader/Patches/patches-framework.h b/source-code/source/PD-Loader/Patches/patches-framework.h index caa1a72..99fc12d 100644 --- a/source-code/source/PD-Loader/Patches/patches-framework.h +++ b/source-code/source/PD-Loader/Patches/patches-framework.h @@ -107,6 +107,7 @@ auto nForceExpressions = GetPrivateProfileIntW(L"patches", L"force_expressions", auto nForceLook = GetPrivateProfileIntW(L"patches", L"force_look", 0, CONFIG_FILE); auto nNpr1 = GetPrivateProfileIntW(L"graphics", L"npr1", 0, CONFIG_FILE); auto nReflections = GetPrivateProfileIntW(L"graphics", L"reflections", TRUE, CONFIG_FILE); +auto nGamma = GetPrivateProfileIntW(L"graphics", L"gamma", 100, CONFIG_FILE); auto nShadows = GetPrivateProfileIntW(L"graphics", L"shadows", TRUE, CONFIG_FILE); auto nPunchthrough = GetPrivateProfileIntW(L"graphics", L"punchthrough", TRUE, CONFIG_FILE); auto nGlare = GetPrivateProfileIntW(L"graphics", L"glare", TRUE, CONFIG_FILE); diff --git a/source-code/source/PD-Loader/templates.h b/source-code/source/PD-Loader/templates.h index 2ee991b..844e803 100644 --- a/source-code/source/PD-Loader/templates.h +++ b/source-code/source/PD-Loader/templates.h @@ -122,6 +122,12 @@ char config_template[] = "DOF=1\n" "# Reflections\n" "Reflections=1\n" +"Reflect_Res_Width = 512\n" +"Reflect_Res_Height = 256\n" +"Refract_Res_Width = 512\n" +"Refract_Res_Height = 256\n" +"# Gamma -- 100=default, 125=console-like\n" +"Gamma = 100\n" "# Shadows\n" "Shadows=1\n" "# Transparent Meshes\n" diff --git a/source-code/source/plugins/Launcher/Resources.restext b/source-code/source/plugins/Launcher/Resources.restext index b5328d0..bd0f883 100644 --- a/source-code/source/plugins/Launcher/Resources.restext +++ b/source-code/source/plugins/Launcher/Resources.restext @@ -32,6 +32,8 @@ REFLECT_RES_WIDTH_NAME=Reflection Res: REFLECT_RES_WIDTH_HINT=Sets the reflection buffer resolution (instead of 512x256). REFRACT_RES_WIDTH_NAME=Refraction Res: REFRACT_RES_WIDTH_HINT=Sets the refraction buffer resolution (instead of 512x256). +GAMMA_NAME=Gamma: +GAMMA_HINT=Increase to darken shadows.\nSet to 125 for a console-like experience.\n\nDefault: 100 SHADOWS_NAME=Shadows SHADOWS_HINT=Enable or disable shadows. PUNCHTHROUGH_NAME=Transparent Meshes diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index dc0f7bf..52d1a0f 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -189,6 +189,7 @@ ConfigOptionBase* graphicsArray[] = { new BooleanOption(L"reflections", GRAPHICS_SECTION, CONFIG_FILE, L"REFLECTIONS_NAME", L"REFLECTIONS_HINT", true, false), new ResolutionOption(L"reflect_res_width", L"reflect_res_height", GRAPHICS_SECTION, CONFIG_FILE, L"REFLECT_RES_WIDTH_NAME", L"REFLECT_RES_WIDTH_HINT", resolution(512, 256), std::vector({resolution(256,256), resolution(512,256), resolution(512,512), resolution(1024,1024), resolution(2048,2048), resolution(4096,4096)}), true, (ResolutionOptionOpts)0), new ResolutionOption(L"refract_res_width", L"refract_res_height", GRAPHICS_SECTION, CONFIG_FILE, L"REFRACT_RES_WIDTH_NAME", L"REFRACT_RES_WIDTH_HINT", resolution(512, 256), std::vector({resolution(256,256), resolution(512,256), resolution(512,512), resolution(1024,1024), resolution(2048,2048), resolution(4096,4096)}), true, (ResolutionOptionOpts)0), + new NumericOption(L"gamma", GRAPHICS_SECTION, CONFIG_FILE, L"GAMMA_NAME", L"GAMMA_HINT", 100, 0, 200), new BooleanOption(L"shadows", GRAPHICS_SECTION, CONFIG_FILE, L"SHADOWS_NAME", L"SHADOWS_HINT", true, false), new BooleanOption(L"punchthrough", GRAPHICS_SECTION, CONFIG_FILE, L"PUNCHTHROUGH_NAME", L"PUNCHTHROUGH_HINT", true, false), new BooleanOption(L"glare", GRAPHICS_SECTION, CONFIG_FILE, L"GLARE_NAME", L"GLARE_HINT", true, false),