[Patches+TLAC] Force toon (NPR1; option in launcher + press F9 to toggle)

This commit is contained in:
nastys
2020-08-06 00:57:32 +02:00
parent abfb4f3324
commit ac20b9cb7f
9 changed files with 88 additions and 11 deletions
@@ -186,21 +186,21 @@ ConfigOptionBase* optionsArray[] = {
new BooleanOption(L"no_lyrics", PATCHES_SECTION, CONFIG_FILE, L"Disable Lyrics", L"Disable showing lyrics.", false, false),
new BooleanOption(L"no_error", PATCHES_SECTION, CONFIG_FILE, L"Disable Error Banner", L"Disable the error banner on the attract screen.", true, false),
new BooleanOption(L"hide_freeplay", PATCHES_SECTION, CONFIG_FILE, L"Hide \"FREE PLAY\"/\"CREDIT(S)\"", L"Hide the \"FREE PLAY\"/\"CREDIT(S)\" text.", false, false),
new BooleanOption(L"freeplay", PATCHES_SECTION, CONFIG_FILE, L"FREE PLAY", L"Show \"FREE PLAY\" instead of \"CREDIT(S)\".", true, false),
new BooleanOption(L"freeplay", PATCHES_SECTION, CONFIG_FILE, L"FREE PLAY", L"Show \"FREE PLAY\" instead of \"CREDIT(S)\" and don't require credits.", true, false),
new BooleanOption(L"pdloadertext", PATCHES_SECTION, CONFIG_FILE, L"PD Loader FREE PLAY", L"Show \"PD Loader\" instead of \"FREE PLAY\".", true, false),
new BooleanOption(L"no_timer", PATCHES_SECTION, CONFIG_FILE, L"Freeze Timer", L"Disable the timer.", true, false),
new BooleanOption(L"no_timer_sprite", PATCHES_SECTION, CONFIG_FILE, L"Disable Timer Sprite", L"Disable the timer sprite.", true, false),
new OptionMetaSpacer(8),
new BooleanOption(L"unlock_pseudo", PATCHES_SECTION, CONFIG_FILE, L"Unlock PSEUDO modules (incomplete)", L"Lets you play any PV with any performer.\n(incomplete, recommended modules will default to Miku)", false, false),
new BooleanOption(L"card", PATCHES_SECTION, CONFIG_FILE, L"Unlock card menu (incomplete)", L"Enables the card menu.\n(incomplete, it doesn't bypass the card prompt)", true, false),
new OptionMetaSpacer(8),
new BooleanOption(L"hardware_slider", PATCHES_SECTION, CONFIG_FILE, L"Use Hardware Slider", L"Enable this if using a real arcade slider.\n(set the slider to port COM11)", false, false),
new BooleanOption(L"card", PATCHES_SECTION, CONFIG_FILE, L"Unlock card menu (incomplete)", L"Enables the card menu.\n(incomplete, it doesn't bypass the card prompt)", false, false),
new OptionMetaSpacer(8),
new BooleanOption(L"TAA", GRAPHICS_SECTION, CONFIG_FILE, L"TAA", L"Temporal Anti-Aliasing", true, false),
new BooleanOption(L"MLAA", GRAPHICS_SECTION, CONFIG_FILE, L"MLAA", L"Morphological Anti-Aliasing", true, false),
new DropdownOption(L"NPR1", GRAPHICS_SECTION, CONFIG_FILE, L"Toon (F9):", L"NPR1 shader\n\nPress F9 to toggle.", 0, std::vector<LPCWSTR>({ L"Default", L"Force on", L"Force off" })),
new OptionMetaSpacer(8),
new BooleanOption(L"FPS.Limit.LightMode", GRAPHICS_SECTION, CONFIG_FILE, L"Use Lightweight Limiter", L"Makes the FPS limiter use less CPU.\nMay have less consistent performance.", true, false),
new NumericOption(L"FPS.Limit", GRAPHICS_SECTION, CONFIG_FILE, L"FPS Limit:", L"Allows you to set a frame rate cap. Set to -1 to unlock the frame rate.", 60, -1, INT_MAX),
new NumericOption(L"frm.motion.rate", GRAPHICS_SECTION, CONFIG_FILE, L"FRM Motion Rate:", L"Sets the motion rate (fps) for the Frame Rate Manager component.\nLarger values should be smoother, but more CPU intensive and possibly buggier.", 300, 1, INT_MAX),
@@ -212,7 +212,10 @@ ConfigOptionBase* optionsArray[] = {
new BooleanOption(L"rumble", KEYCONFIG_SECTION, KEYCONFIG_FILE, L"XInput Rumble", L"Enables rumble during chainslides.", true, true),
new NumericOption(L"xinput_preferred", KEYCONFIG_SECTION, KEYCONFIG_FILE, L"XInput Controller Num:", L"Sets the preferred XInput controller.\nIf unavailable, the next connected controller is used.", 0, 0, 3),
new OptionMetaSpacer(8),
new BooleanOption(L"hardware_slider", PATCHES_SECTION, CONFIG_FILE, L"Use Hardware Slider", L"Enable this if using a real arcade slider.\n(set the slider to port COM11)", false, false),
new OptionMetaSpacer(8),
new BooleanOption(L"opengl_patch_a", LAUNCHER_SECTION, CONFIG_FILE, L"OpenGL Patch A", L"Ignores some OpenGL-related errors. Don't use both patches at the same time unless you're know what you're doing.", L"", false),
new BooleanOption(L"opengl_patch_b", LAUNCHER_SECTION, CONFIG_FILE, L"OpenGL Patch B", L"Ignores some OpenGL-related errors. Don't use both patches at the same time unless you're know what you're doing.", L"", false),
new OptionMetaSpacer(8),
+19 -2
View File
@@ -230,6 +230,7 @@ void ApplyPatches() {
auto nForceMouth = GetPrivateProfileIntW(L"patches", L"force_mouth", 0, CONFIG_FILE);
auto nForceExpressions = GetPrivateProfileIntW(L"patches", L"force_expressions", 0, CONFIG_FILE);
auto nForceLook = GetPrivateProfileIntW(L"patches", L"force_look", 0, CONFIG_FILE);
auto nNpr1 = GetPrivateProfileIntW(L"graphics", L"npr1", 0, CONFIG_FILE);
std::string version_string = std::to_string(game_version);
version_string.insert(version_string.begin()+1, '.');
@@ -291,7 +292,7 @@ void ApplyPatches() {
*((byte*)0x000000014049258A + 2) = 0x90;
VirtualProtect((BYTE*)0x000000014049258A, 3, oldProtect, &bck); }
printf("[TLAC] MLAA disabled\n");
printf("[Patches] MLAA disabled\n");
}
// Replace the hardcoded videos with MP4s, if they exist
@@ -560,7 +561,7 @@ void ApplyPatches() {
*((byte*)0x00000001404AB11A + 2) = 0x90;
VirtualProtect((BYTE*)0x00000001404AB11A, 3, oldProtect, &bck); }
printf("[TLAC] MLAA disabled\n");
printf("[Patches] MLAA disabled\n");
}
// Replace the hardcoded videos with MP4s, if they exist
@@ -889,7 +890,23 @@ void ApplyPatches() {
printf("[Patches] FT look forced\n");
}
}
// NPR1
{
if (nNpr1 == 1) // force on
{
InjectCode((void*)0x0000000140502FC0, { 0xC7, 0x05, 0x6E });
InjectCode((void*)0x0000000140502FC6, { 0x01, 0x00, 0x00, 0x00, 0xC3 });
printf("[Patches] NPR1 forced\n");
}
if (nNpr1 == 2) // force off
{
InjectCode((void*)0x0000000140502FC0, { 0xC7, 0x05, 0x6E });
InjectCode((void*)0x0000000140502FC6, { 0x00, 0x00, 0x00, 0x00, 0xC3 });
printf("[Patches] NPR1 disabled\n");
}
}
}
@@ -14,6 +14,7 @@
#include "../../FileSystem/ConfigFile.h"
#include "../GameState.h"
#include "../Pause.h"
#include "../../Utils.h"
const std::string KEY_CONFIG_FILE_NAME = "keyconfig.ini";
@@ -344,6 +345,9 @@ namespace TLAC::Components
if (keyboard->IsIntervalTapped(VK_SPACE))
inputKey = 0x20;
if (keyboard->IsIntervalTapped(VK_F9))
toggleNpr1();
if (keyboard->IsDoubleTapped(VK_ESCAPE))
*(bool*)SHOULD_EXIT_BOOL_ADDRESS = true;
@@ -435,4 +439,30 @@ namespace TLAC::Components
if ((*(unsigned char*)0x14CD93A98) == 0) (*(unsigned char*)0x14CD93A98)++;
}
}
void InputEmulator::toggleNpr1()
{
switch(*(byte*)0x0000000140502FC6)
{
case 0xC3: // default -> force on
InjectCode((void*)0x0000000140502FC0, { 0xC7, 0x05, 0x6E });
InjectCode((void*)0x0000000140502FC6, { 0x01, 0x00, 0x00, 0x00, 0xC3 });
*(byte*)0x00000001411AD638 = 1;
printf("[TLAC] NPR1 forced\n");
break;
case 0x01: // default -> force off
InjectCode((void*)0x0000000140502FC0, { 0xC7, 0x05, 0x6E });
InjectCode((void*)0x0000000140502FC6, { 0x00, 0x00, 0x00, 0x00, 0xC3 });
*(byte*)0x00000001411AD638 = 0;
printf("[TLAC] NPR1 disabled\n");
break;
default: // force off -> default
InjectCode((void*)0x0000000140502FC0, { 0x89, 0x0D, 0x72 });
InjectCode((void*)0x0000000140502FC6, { 0xC3, 0xCC, 0xCC, 0xCC, 0xCC });
printf("[TLAC] NPR1 restored\n");
}
}
}
@@ -110,5 +110,6 @@ namespace TLAC::Components
void SetMetaButtons();
void addCoin();
void toggleNpr1();
};
}
@@ -173,6 +173,7 @@
<ClInclude Include="Utilities\Stopwatch.h" />
<ClInclude Include="Utilities\Vec2.h" />
<ClInclude Include="Utilities\Vec3.h" />
<ClInclude Include="Utils.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Components\CameraController.cpp" />
@@ -224,6 +225,7 @@
<ClCompile Include="Utilities\Stopwatch.cpp" />
<ClCompile Include="Utilities\Vec2.cpp" />
<ClCompile Include="Utilities\Vec3.cpp" />
<ClCompile Include="Utils.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
@@ -213,6 +213,9 @@
<ClInclude Include="Input\Bindings\GuBinding.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Utils.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
@@ -362,5 +365,8 @@
<ClCompile Include="Input\Bindings\GuBinding.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
+12
View File
@@ -0,0 +1,12 @@
#include "Utils.h"
#include <Windows.h>
void InjectCode(void* address, const std::vector<uint8_t> data)
{
const size_t byteCount = data.size() * sizeof(uint8_t);
DWORD oldProtect;
VirtualProtect(address, byteCount, PAGE_EXECUTE_READWRITE, &oldProtect);
memcpy(address, data.data(), byteCount);
VirtualProtect(address, byteCount, oldProtect, nullptr);
}
+4
View File
@@ -0,0 +1,4 @@
#pragma once
#include <vector>
void InjectCode(void* address, const std::vector<uint8_t> data);