Implement samyuu's wireframe injection; Pro Lag Compensation

This commit is contained in:
nastys
2021-03-29 01:22:27 +02:00
parent fb3e735c1f
commit 5ab07cde0e
5 changed files with 213 additions and 62 deletions
@@ -47,6 +47,10 @@ namespace TLAC::Components
delete MenuLBinding;
delete MenuRBinding;
delete MenuCircleBinding;
delete CoinBinding;
delete WireframeBinding;
}
const char* InputEmulator::GetDisplayName()
@@ -83,6 +87,8 @@ namespace TLAC::Components
CoinBinding = new Binding();
WireframeBinding = new Binding();
FileSystem::ConfigFile configFile(framework::GetModuleDirectory(), KEY_CONFIG_FILE_NAME);
configFile.OpenRead();
@@ -101,6 +107,7 @@ namespace TLAC::Components
Config::BindConfigKeys(configFile.ConfigMap, "MENU_R", *MenuRBinding, { "Down", "Right" });
Config::BindConfigKeys(configFile.ConfigMap, "MENU_CIRCLE", *MenuCircleBinding, { "D", "L", "Spacebar" });
Config::BindConfigKeys(configFile.ConfigMap, "COIN", *CoinBinding, { "F10" });
Config::BindConfigKeys(configFile.ConfigMap, "WIREFRAME", *WireframeBinding, { "F12" });
mouseScrollPvSelection = configFile.GetBooleanValue("mouse_scroll_pv_selection");
}
@@ -302,6 +309,9 @@ namespace TLAC::Components
if (buttonTestFunc(CoinBinding))
addCoin();
if (buttonTestFunc(WireframeBinding))
toggleWireframe();
return buttons;
}
@@ -465,4 +475,28 @@ namespace TLAC::Components
printf("[TLAC] NPR1 restored\n");
}
}
void InputEmulator::toggleWireframe()
{
static bool wireframeEnabled = false;
if (!wireframeEnabled)
{
// inject samyuu's wireframe code
InjectCode((void*)0x00000000140500BE6, { 0xBA, 0x01, 0x1B, 0x00, 0x00, // mov edx,00001B01
0xB9, 0x08, 0x04, 0x00, 0x00, // mov ecx,00000408
0xE8, 0xE1, 0x5A, 0x3B, 0x00, // call 1408B66D6
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 });
wireframeEnabled = true;
printf("[TLAC] Wireframe enabled\n");
}
else
{
InjectCode((void*)0x00000000140500BE6, { 0xB9, 0x1C, 0x00, 0x00, 0x00, 0xE8, 0x30, 0x7C, 0xF3, 0xFF, 0xB9, 0x1B, 0x00, 0x00, 0x00, 0x8B, 0xD8, 0xE8, 0x24, 0x7C, 0xF3, 0xFF, 0xB9, 0x1A, 0x00, 0x00, 0x00 });
wireframeEnabled = false;
printf("[TLAC] Wireframe disabled\n");
}
}
}