1
0
mirror of synced 2025-02-23 05:29:15 +01:00

Tidy up TTX2 Page & Move BG4/SkyStage Inputs to own cpp

This commit is contained in:
Aaron M 2021-05-09 11:30:01 +12:00
parent 83b797c5e9
commit baa9bfbad2
3 changed files with 690 additions and 683 deletions

View File

@ -0,0 +1,506 @@
#include <StdInc.h>
#include "Utility/GameDetect.h"
#include "Utility/InitFunction.h"
#include "Functions/Global.h"
#include "Utility/Helper.h"
static bool CoinPressed = false;
static bool TestPressed = false;
static bool ServicePressed = false;
static bool TimeStartPressed = false;
static bool StartPressed = false;
static bool ViewPressed = false;
static bool HazardPressed = false;
static bool OverTakePressed = false;
static bool ShiftLeftPressed = false;
static bool ShiftRightPressed = false;
static bool SideBrakePressed = false;
static bool SeatSwitch1Pressed = false;
static bool SeatSwitch2Pressed = false;
static bool Gear1Pressed = false;
static bool Gear2Pressed = false;
static bool Gear3Pressed = false;
static bool Gear4Pressed = false;
static bool Gear5Pressed = false;
static bool Gear6Pressed = false;
static bool KeyPressed = false;
static bool init = false;
static bool MenuHack = false;
static bool MenuHackDelay = false;
static bool TestMode = false;
extern int* wheelSection;
extern int* ffbOffset;
extern int* ffbOffset3;
extern int* ffbOffset4;
extern int* ffbOffset5;
static Helpers* myHelpers;
static DWORD WINAPI ChangeValues(LPVOID lpParam)
{
Sleep(10000);
DWORD imageBase = (DWORD)GetModuleHandleA(0);
myHelpers->WriteByte(0x42E296, 0x01, true);
myHelpers->WriteByte(0x42E295, 0x80, true);
injector::MakeNOP(imageBase + 0x27400, 6);
return 0;
}
void BG4ManualHack(Helpers* helpers)
{
//Hack to allow us to select Manual
INT_PTR MenuTimerBase = helpers->ReadIntPtr(0x4C2924, true);
INT_PTR MenuTimerBaseA = helpers->ReadIntPtr(MenuTimerBase + 0x08, false);
INT_PTR MenuTime = helpers->ReadIntPtr(MenuTimerBaseA + 0x45C, false);
if (MenuTime == 0x1194)
{
if (!MenuHack)
{
MenuHack = true;
}
}
if (MenuTime == 0x00)
{
if (MenuHack)
{
MenuHack = false;
MenuHackDelay = false;
}
}
if (MenuHack)
{
if (!MenuHackDelay)
{
MenuHackDelay = true;
Sleep(2500);
}
helpers->WriteByte(MenuTimerBaseA + 0x454, 0x03, false);
}
}
void BG4ProInputs(Helpers* helpers)
{
if (!init)
{
init = true;
myHelpers = helpers;
CreateThread(NULL, 0, ChangeValues, NULL, 0, NULL);
}
//Hack to allow us to select Manual and Manual with Clutch
INT_PTR MenuTimerBase = helpers->ReadIntPtr(0x4C2924, true);
INT_PTR MenuTimerBaseA = helpers->ReadIntPtr(MenuTimerBase + 0x08, false);
INT_PTR MenuTime = helpers->ReadIntPtr(MenuTimerBaseA + 0x45C, false);
if (MenuTime == 0x1194)
{
if (!MenuHack)
{
MenuHack = true;
}
}
if (MenuTime == 0x00)
{
if (MenuHack)
{
MenuHack = false;
MenuHackDelay = false;
}
}
if (MenuHack)
{
if (!MenuHackDelay)
{
MenuHackDelay = true;
Sleep(2500);
}
helpers->WriteByte(MenuTimerBaseA + 0x454, 0x04, false);
BYTE This = helpers->ReadByte(MenuTimerBaseA + 0x44C, false);
if (This == 0x02)
{
helpers->WriteByte(0x42E341, 0xD0, true); //Set Shift SEN 2 to ON or error
}
else if (This == 0x03)
{
helpers->WriteByte(0x42E341, 0xE0, true); //Set Shift SEN 1 to ON or error
}
}
DWORD imageBase = (DWORD)GetModuleHandleA(0);
UINT8 KeyInput = helpers->ReadByte(imageBase + 0x42E296, false);
if (*ffbOffset & 0x01) //Test
{
if (!TestPressed)
{
TestPressed = true;
TestMode = true;
*(BYTE*)(imageBase + 0x42E297) += 0x80;
}
}
else
{
if (TestPressed)
{
TestPressed = false;
*(BYTE*)(imageBase + 0x42E297) -= 0x80;
}
}
if (*ffbOffset & 0x02) //Service
{
if (!ServicePressed)
{
ServicePressed = true;
*(BYTE*)(imageBase + 0x42E296) += 0x40;
}
}
else
{
if (ServicePressed)
{
ServicePressed = false;
*(BYTE*)(imageBase + 0x42E296) -= 0x40;
}
}
if (*ffbOffset & 0x04) //Coin Chute 1
{
if (!CoinPressed)
{
CoinPressed = true;
*(BYTE*)(imageBase + 0x42E294) += 0x40;
if (!TestMode) //Let's get that sweet sweet sexy coin sound
{
*(BYTE*)(imageBase + 0x42E296) += 0x40;
}
}
}
else
{
if (CoinPressed)
{
CoinPressed = false;
*(BYTE*)(imageBase + 0x42E294) -= 0x40;
if (!TestMode)
{
*(BYTE*)(imageBase + 0x42E296) -= 0x40;
}
}
}
if (*ffbOffset & 0x08) //Start
{
if (!StartPressed)
{
StartPressed = true;
*(BYTE*)(imageBase + 0x42E296) += 0x80;
}
}
else
{
if (StartPressed)
{
StartPressed = false;
*(BYTE*)(imageBase + 0x42E296) -= 0x80;
}
}
if (*ffbOffset & 0x10) //Key
{
if (!KeyPressed)
{
KeyPressed = true;
if (!(KeyInput & 0x04))
{
*(BYTE*)(imageBase + 0x42E296) += 0x04;
}
else
{
*(BYTE*)(imageBase + 0x42E296) -= 0x04;
}
}
}
else
{
if (KeyPressed)
{
KeyPressed = false;
}
}
if (*ffbOffset & 0x20) //View
{
if (!ViewPressed)
{
ViewPressed = true;
*(BYTE*)(imageBase + 0x42E296) += 0x20;
}
}
else
{
if (ViewPressed)
{
ViewPressed = false;
*(BYTE*)(imageBase + 0x42E296) -= 0x20;
}
}
if (*ffbOffset & 0x40) //Hazard
{
if (!HazardPressed)
{
HazardPressed = true;
*(BYTE*)(imageBase + 0x42E296) += 0x10;
}
}
else
{
if (HazardPressed)
{
HazardPressed = false;
*(BYTE*)(imageBase + 0x42E296) -= 0x10;
}
}
if (*ffbOffset & 0x80) //Overtake
{
if (!OverTakePressed)
{
OverTakePressed = true;
*(BYTE*)(imageBase + 0x42E296) += 0x08;
}
}
else
{
if (OverTakePressed)
{
OverTakePressed = false;
*(BYTE*)(imageBase + 0x42E296) -= 0x08;
}
}
if (*ffbOffset & 0x100) //SideBrake
{
if (!SideBrakePressed)
{
SideBrakePressed = true;
*(BYTE*)(imageBase + 0x42E296) += 0x02;
}
}
else
{
if (SideBrakePressed)
{
SideBrakePressed = false;
*(BYTE*)(imageBase + 0x42E296) -= 0x02;
}
}
if (*ffbOffset & 0x200) //Shift Right
{
if (!ShiftRightPressed)
{
ShiftRightPressed = true;
*(BYTE*)(imageBase + 0x42E341) -= 0x40;
}
}
else
{
if (ShiftRightPressed)
{
ShiftRightPressed = false;
*(BYTE*)(imageBase + 0x42E341) += 0x40;
}
}
if (*ffbOffset & 0x400) //Shift Left
{
if (!ShiftLeftPressed)
{
ShiftLeftPressed = true;
*(BYTE*)(imageBase + 0x42E341) -= 0x80;
}
}
else
{
if (ShiftLeftPressed)
{
ShiftLeftPressed = false;
*(BYTE*)(imageBase + 0x42E341) += 0x80;
}
}
if (*ffbOffset & 0x800) //Timer Start
{
if (!TimeStartPressed)
{
TimeStartPressed = true;
*(BYTE*)(imageBase + 0x42E295) += 0x01;
}
}
else
{
if (TimeStartPressed)
{
TimeStartPressed = false;
*(BYTE*)(imageBase + 0x42E295) -= 0x01;
}
}
if (*ffbOffset & 0x1000) //Seat Switch 1
{
if (!SeatSwitch1Pressed)
{
SeatSwitch1Pressed = true;
*(BYTE*)(imageBase + 0x42E295) += 0x04;
}
}
else
{
if (SeatSwitch1Pressed)
{
SeatSwitch1Pressed = false;
*(BYTE*)(imageBase + 0x42E295) -= 0x04;
}
}
if (*ffbOffset & 0x2000) //Seat Switch 2
{
if (!SeatSwitch2Pressed)
{
SeatSwitch2Pressed = true;
*(BYTE*)(imageBase + 0x42E295) += 0x02;
}
}
else
{
if (SeatSwitch2Pressed)
{
SeatSwitch2Pressed = false;
*(BYTE*)(imageBase + 0x42E295) -= 0x02;
}
}
if (*ffbOffset & 0x4000) //Gear 1
{
if ((!Gear1Pressed) && (!Gear2Pressed) && (!Gear3Pressed) && (!Gear4Pressed) && (!Gear5Pressed) && (!Gear6Pressed))
{
Gear1Pressed = true;
*(BYTE*)(imageBase + 0x42E295) -= 0x80;
*(BYTE*)(imageBase + 0x42E341) -= 0x80;
}
}
else
{
if (Gear1Pressed)
{
Gear1Pressed = false;
*(BYTE*)(imageBase + 0x42E295) += 0x80;
*(BYTE*)(imageBase + 0x42E341) += 0x80;
}
}
if (*ffbOffset & 0x8000) //Gear 2
{
if ((!Gear2Pressed) && (!Gear1Pressed) && (!Gear3Pressed) && (!Gear4Pressed) && (!Gear5Pressed) && (!Gear6Pressed))
{
Gear2Pressed = true;
*(BYTE*)(imageBase + 0x42E296) -= 0x01;
*(BYTE*)(imageBase + 0x42E341) -= 0x80;
}
}
else
{
if (Gear2Pressed)
{
Gear2Pressed = false;
*(BYTE*)(imageBase + 0x42E296) += 0x01;
*(BYTE*)(imageBase + 0x42E341) += 0x80;
}
}
if (*ffbOffset & 0x10000) //Gear 3 / Shift Up
{
if ((!Gear3Pressed) && (!Gear2Pressed) && (!Gear1Pressed) && (!Gear4Pressed) && (!Gear5Pressed) && (!Gear6Pressed))
{
Gear3Pressed = true;
*(BYTE*)(imageBase + 0x42E296) -= 0x01;
}
}
else
{
if (Gear3Pressed)
{
Gear3Pressed = false;
*(BYTE*)(imageBase + 0x42E296) += 0x01;
}
}
if (*ffbOffset & 0x20000) //Gear 4 / Shift Down
{
if ((!Gear4Pressed) && (!Gear2Pressed) && (!Gear3Pressed) && (!Gear1Pressed) && (!Gear5Pressed) && (!Gear6Pressed))
{
Gear4Pressed = true;
*(BYTE*)(imageBase + 0x42E295) -= 0x80;
}
}
else
{
if (Gear4Pressed)
{
Gear4Pressed = false;
*(BYTE*)(imageBase + 0x42E295) += 0x80;
}
}
if (*ffbOffset & 0x40000) //Gear 5
{
if ((!Gear5Pressed) && (!Gear2Pressed) && (!Gear3Pressed) && (!Gear4Pressed) && (!Gear1Pressed) && (!Gear6Pressed))
{
Gear5Pressed = true;
*(BYTE*)(imageBase + 0x42E295) -= 0x80;
*(BYTE*)(imageBase + 0x42E341) -= 0x40;
}
}
else
{
if (Gear5Pressed)
{
Gear5Pressed = false;
*(BYTE*)(imageBase + 0x42E295) += 0x80;
*(BYTE*)(imageBase + 0x42E341) += 0x40;
}
}
if (*ffbOffset & 0x80000) //Gear 6/Reverse
{
if ((!Gear6Pressed) && (!Gear2Pressed) && (!Gear3Pressed) && (!Gear4Pressed) && (!Gear5Pressed) && (!Gear1Pressed))
{
Gear6Pressed = true;
*(BYTE*)(imageBase + 0x42E296) -= 0x01;
*(BYTE*)(imageBase + 0x42E341) -= 0x40;
}
}
else
{
if (Gear6Pressed)
{
Gear6Pressed = false;
*(BYTE*)(imageBase + 0x42E296) += 0x01;
*(BYTE*)(imageBase + 0x42E341) += 0x40;
}
}
*(float*)(imageBase + 0x42D994) = (*wheelSection - 128) / 128.0; // Steering
*(float*)(imageBase + 0x42D998) = (*ffbOffset3) / 255.0; // Gas
*(float*)(imageBase + 0x42D99C) = (*ffbOffset4) / 255.0; // Brake
*(float*)(imageBase + 0x42D9A0) = (*ffbOffset5) / 255.0; // Clutch
}

View File

@ -0,0 +1,163 @@
#include <StdInc.h>
#include "Utility/GameDetect.h"
#include "Utility/InitFunction.h"
#include "Functions/Global.h"
#include "Utility/Helper.h"
void KOFSkyStageInputs(Helpers* helpers)
{
UINT8 JVSInput1 = helpers->ReadByte(0x2DF304, true);
UINT8 JVSInput1A = helpers->ReadByte(0x2DF305, true);
UINT8 Joystick1Up = helpers->ReadByte(0x37085A, true);
UINT8 Joystick1Down = helpers->ReadByte(0x370860, true);
UINT8 Joystick1Left = helpers->ReadByte(0x370866, true);
UINT8 Joystick1Right = helpers->ReadByte(0x37086C, true);
UINT8 Joystick1Start = helpers->ReadByte(0x37088A, true);
UINT8 Joystick1Button1 = helpers->ReadByte(0x370890, true);
UINT8 Joystick1Button2 = helpers->ReadByte(0x370896, true);
UINT8 Joystick1Button3 = helpers->ReadByte(0x37089C, true);
UINT8 JVSInput2 = helpers->ReadByte(0x2DF306, true);
UINT8 JVSInput2A = helpers->ReadByte(0x2DF307, true);
UINT8 Joystick2Up = helpers->ReadByte(0x370950, true);
UINT8 Joystick2Down = helpers->ReadByte(0x370956, true);
UINT8 Joystick2Left = helpers->ReadByte(0x37095C, true);
UINT8 Joystick2Right = helpers->ReadByte(0x370962, true);
UINT8 Joystick2Start = helpers->ReadByte(0x370980, true);
UINT8 Joystick2Button1 = helpers->ReadByte(0x370986, true);
UINT8 Joystick2Button2 = helpers->ReadByte(0x37098C, true);
UINT8 Joystick2Button3 = helpers->ReadByte(0x370992, true);
if (!(JVSInput1 & 0x20))
{
if (Joystick1Up == 0x01)
{
helpers->WriteByte(0x37085A, 0x00, true);
}
}
if (!(JVSInput1 & 0x10))
{
if (Joystick1Down == 0x01)
{
helpers->WriteByte(0x370860, 0x00, true);
}
}
if (!(JVSInput1 & 0x08))
{
if (Joystick1Left == 0x01)
{
helpers->WriteByte(0x370866, 0x00, true);
}
}
if (!(JVSInput1 & 0x04))
{
if (Joystick1Right == 0x01)
{
helpers->WriteByte(0x37086C, 0x00, true);
}
}
if (!(JVSInput1 & 0x80))
{
if (Joystick1Start == 0x01)
{
helpers->WriteByte(0x37088A, 0x00, true);
}
}
if (!(JVSInput1 & 0x02))
{
if (Joystick1Button1 == 0x01)
{
helpers->WriteByte(0x370890, 0x00, true);
helpers->WriteByte(0x370872, 0x00, true);
}
}
if (!(JVSInput1 & 0x01))
{
if (Joystick1Button2 == 0x01)
{
helpers->WriteByte(0x370896, 0x00, true);
helpers->WriteByte(0x370878, 0x00, true);
}
}
if (!(JVSInput1A & 0x80))
{
if (Joystick1Button3 == 0x01)
{
helpers->WriteByte(0x37089C, 0x00, true);
helpers->WriteByte(0x370884, 0x00, true);
}
}
if (!(JVSInput2 & 0x20))
{
if (Joystick2Up == 0x01)
{
helpers->WriteByte(0x370950, 0x00, true);
}
}
if (!(JVSInput2 & 0x10))
{
if (Joystick2Down == 0x01)
{
helpers->WriteByte(0x370956, 0x00, true);
}
}
if (!(JVSInput2 & 0x08))
{
if (Joystick2Left == 0x01)
{
helpers->WriteByte(0x37095C, 0x00, true);
}
}
if (!(JVSInput2 & 0x04))
{
if (Joystick2Right == 0x01)
{
helpers->WriteByte(0x370962, 0x00, true);
}
}
if (!(JVSInput2 & 0x80))
{
if (Joystick2Start == 0x01)
{
helpers->WriteByte(0x370980, 0x00, true);
}
}
if (!(JVSInput2 & 0x02))
{
if (Joystick2Button1 == 0x01)
{
helpers->WriteByte(0x370986, 0x00, true);
helpers->WriteByte(0x370968, 0x00, true);
}
}
if (!(JVSInput2 & 0x01))
{
if (Joystick2Button2 == 0x01)
{
helpers->WriteByte(0x37098C, 0x00, true);
helpers->WriteByte(0x37096E, 0x00, true);
}
}
if (!(JVSInput2A & 0x80))
{
if (Joystick2Button3 == 0x01)
{
helpers->WriteByte(0x370992, 0x00, true);
helpers->WriteByte(0x37097A, 0x00, true);
}
}
}

View File

@ -11,32 +11,11 @@ extern int* ffbOffset;
extern int* ffbOffset3;
extern int* ffbOffset4;
extern int* ffbOffset5;
static Helpers* myHelpers;
static bool CoinPressed = false;
static bool TestPressed = false;
static bool ServicePressed = false;
static bool TimeStartPressed = false;
static bool StartPressed = false;
static bool ViewPressed = false;
static bool HazardPressed = false;
static bool OverTakePressed = false;
static bool ShiftLeftPressed = false;
static bool ShiftRightPressed = false;
static bool SideBrakePressed = false;
static bool SeatSwitch1Pressed = false;
static bool SeatSwitch2Pressed = false;
static bool Gear1Pressed = false;
static bool Gear2Pressed = false;
static bool Gear3Pressed = false;
static bool Gear4Pressed = false;
static bool Gear5Pressed = false;
static bool Gear6Pressed = false;
static bool KeyPressed = false;
static bool init = false;
static bool MenuHack = false;
static bool MenuHackDelay = false;
static bool TestMode = false;
extern void BG4ManualHack(Helpers* helpers);
extern void BG4ProInputs(Helpers* helpers);
extern void KOFSkyStageInputs(Helpers* helpers);
static bool ProMode;
void AddCommOverride(HANDLE hFile);
@ -396,661 +375,22 @@ BOOL __stdcall WriteFileWrapTx2(HANDLE hFile,
return WriteFile(hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, lpOverlapped);
}
static DWORD WINAPI ChangeValues(LPVOID lpParam)
static DWORD WINAPI RunningLoop(LPVOID lpParam)
{
Sleep(10000);
DWORD imageBase = (DWORD)GetModuleHandleA(0);
myHelpers->WriteByte(0x42E296, 0x01, true);
myHelpers->WriteByte(0x42E295, 0x80, true);
injector::MakeNOP(imageBase + 0x27400, 6);
return 0;
}
static int BG4ThreadLoop(Helpers* helpers)
{
//Hack to allow us to select Manual
INT_PTR MenuTimerBase = helpers->ReadIntPtr(0x4C2924, true);
INT_PTR MenuTimerBaseA = helpers->ReadIntPtr(MenuTimerBase + 0x08, false);
INT_PTR MenuTime = helpers->ReadIntPtr(MenuTimerBaseA + 0x45C, false);
if (MenuTime == 0x1194)
while (true)
{
if (!MenuHack)
switch (GameDetect::currentGame)
{
MenuHack = true;
}
}
if (MenuTime == 0x00)
{
if (MenuHack)
{
MenuHack = false;
MenuHackDelay = false;
}
}
if (MenuHack)
{
if (!MenuHackDelay)
{
MenuHackDelay = true;
Sleep(2500);
}
helpers->WriteByte(MenuTimerBaseA + 0x454, 0x03, false);
}
return 0;
}
static int BG4ProThreadLoop(Helpers* helpers)
{
if (!init)
{
init = true;
myHelpers = helpers;
CreateThread(NULL, 0, ChangeValues, NULL, 0, NULL);
}
//Hack to allow us to select Manual and Manual with Clutch
INT_PTR MenuTimerBase = helpers->ReadIntPtr(0x4C2924, true);
INT_PTR MenuTimerBaseA = helpers->ReadIntPtr(MenuTimerBase + 0x08, false);
INT_PTR MenuTime = helpers->ReadIntPtr(MenuTimerBaseA + 0x45C, false);
if (MenuTime == 0x1194)
{
if (!MenuHack)
{
MenuHack = true;
}
}
if (MenuTime == 0x00)
{
if (MenuHack)
{
MenuHack = false;
MenuHackDelay = false;
}
}
if (MenuHack)
{
if (!MenuHackDelay)
{
MenuHackDelay = true;
Sleep(2500);
}
helpers->WriteByte(MenuTimerBaseA + 0x454, 0x04, false);
BYTE This = helpers->ReadByte(MenuTimerBaseA + 0x44C,false);
if (This == 0x02)
{
helpers->WriteByte(0x42E341, 0xD0, true); //Set Shift SEN 2 to ON or error
}
else if (This == 0x03)
{
helpers->WriteByte(0x42E341, 0xE0, true); //Set Shift SEN 1 to ON or error
}
}
DWORD imageBase = (DWORD)GetModuleHandleA(0);
UINT8 KeyInput = helpers->ReadByte(imageBase + 0x42E296, false);
if (*ffbOffset & 0x100) //Test
{
if (!TestPressed)
{
TestPressed = true;
TestMode = true;
*(BYTE*)(imageBase + 0x42E297) += 0x80;
}
}
else
{
if (TestPressed)
{
TestPressed = false;
*(BYTE*)(imageBase + 0x42E297) -= 0x80;
}
}
if (*ffbOffset & 0x200) //Service
{
if (!ServicePressed)
{
ServicePressed = true;
*(BYTE*)(imageBase + 0x42E296) += 0x40;
}
}
else
{
if (ServicePressed)
{
ServicePressed = false;
*(BYTE*)(imageBase + 0x42E296) -= 0x40;
}
}
if (*ffbOffset & 0x800) //Shift Left
{
if (!ShiftLeftPressed)
{
ShiftLeftPressed = true;
*(BYTE*)(imageBase + 0x42E341) -= 0x80;
}
}
else
{
if (ShiftLeftPressed)
{
ShiftLeftPressed = false;
*(BYTE*)(imageBase + 0x42E341) += 0x80;
}
}
if (*ffbOffset & 0x4000) //Shift Right
{
if (!ShiftRightPressed)
{
ShiftRightPressed = true;
*(BYTE*)(imageBase + 0x42E341) -= 0x40;
}
}
else
{
if (ShiftRightPressed)
{
ShiftRightPressed = false;
*(BYTE*)(imageBase + 0x42E341) += 0x40;
}
}
if (*ffbOffset & 0x40) //Start
{
if (!StartPressed)
{
StartPressed = true;
*(BYTE*)(imageBase + 0x42E296) += 0x80;
}
}
else
{
if (StartPressed)
{
StartPressed = false;
*(BYTE*)(imageBase + 0x42E296) -= 0x80;
}
}
if (*ffbOffset & 0x8000) //View
{
if (!ViewPressed)
{
ViewPressed = true;
*(BYTE*)(imageBase + 0x42E296) += 0x20;
}
}
else
{
if (ViewPressed)
{
ViewPressed = false;
*(BYTE*)(imageBase + 0x42E296) -= 0x20;
}
}
if (*ffbOffset & 0x01) //Hazard
{
if (!HazardPressed)
{
HazardPressed = true;
*(BYTE*)(imageBase + 0x42E296) += 0x10;
}
}
else
{
if (HazardPressed)
{
HazardPressed = false;
*(BYTE*)(imageBase + 0x42E296) -= 0x10;
}
}
if (*ffbOffset & 0x20) //Overtake
{
if (!OverTakePressed)
{
OverTakePressed = true;
*(BYTE*)(imageBase + 0x42E296) += 0x08;
}
}
else
{
if (OverTakePressed)
{
OverTakePressed = false;
*(BYTE*)(imageBase + 0x42E296) -= 0x08;
}
}
if (*ffbOffset & 0x02) //SideBrake
{
if (!SideBrakePressed)
{
SideBrakePressed = true;
*(BYTE*)(imageBase + 0x42E296) += 0x02;
}
}
else
{
if (SideBrakePressed)
{
SideBrakePressed = false;
*(BYTE*)(imageBase + 0x42E296) -= 0x02;
}
}
if (*ffbOffset & 0x10000) //Timer Start
{
if (!TimeStartPressed)
{
TimeStartPressed = true;
*(BYTE*)(imageBase + 0x42E295) += 0x01;
}
}
else
{
if (TimeStartPressed)
{
TimeStartPressed = false;
*(BYTE*)(imageBase + 0x42E295) -= 0x01;
}
}
if (*ffbOffset & 0x20000) //Seat Switch 1
{
if (!SeatSwitch1Pressed)
{
SeatSwitch1Pressed = true;
*(BYTE*)(imageBase + 0x42E295) += 0x04;
}
}
else
{
if (SeatSwitch1Pressed)
{
SeatSwitch1Pressed = false;
*(BYTE*)(imageBase + 0x42E295) -= 0x04;
}
}
if (*ffbOffset & 0x40000) //Seat Switch 2
{
if (!SeatSwitch2Pressed)
{
SeatSwitch2Pressed = true;
*(BYTE*)(imageBase + 0x42E295) += 0x02;
}
}
else
{
if (SeatSwitch2Pressed)
{
SeatSwitch2Pressed = false;
*(BYTE*)(imageBase + 0x42E295) -= 0x02;
}
}
if (*ffbOffset & 0x400) //Coin Chute 1
{
if (!CoinPressed)
{
CoinPressed = true;
*(BYTE*)(imageBase + 0x42E294) += 0x40;
if (!TestMode) //Let's get that sweet sweet sexy coin sound
{
*(BYTE*)(imageBase + 0x42E296) += 0x40;
}
}
}
else
{
if (CoinPressed)
{
CoinPressed = false;
*(BYTE*)(imageBase + 0x42E294) -= 0x40;
if (!TestMode)
{
*(BYTE*)(imageBase + 0x42E296) -= 0x40;
}
}
}
if (*ffbOffset & 0x2000) //Key
{
if (!KeyPressed)
{
KeyPressed = true;
if (!(KeyInput & 0x04))
{
*(BYTE*)(imageBase + 0x42E296) += 0x04;
}
case GameID::BG4:
if (ProMode)
BG4ProInputs(0);
else
{
*(BYTE*)(imageBase + 0x42E296) -= 0x04;
}
BG4ManualHack(0);
break;
case GameID::KOFSkyStage100J:
KOFSkyStageInputs(0);
break;
}
}
else
{
if (KeyPressed)
{
KeyPressed = false;
}
}
if (*ffbOffset & 0x100000) //Gear 1
{
if ((!Gear1Pressed) && (!Gear2Pressed) && (!Gear3Pressed) && (!Gear4Pressed) && (!Gear5Pressed) && (!Gear6Pressed))
{
Gear1Pressed = true;
*(BYTE*)(imageBase + 0x42E295) -= 0x80;
*(BYTE*)(imageBase + 0x42E341) -= 0x80;
}
}
else
{
if (Gear1Pressed)
{
Gear1Pressed = false;
*(BYTE*)(imageBase + 0x42E295) += 0x80;
*(BYTE*)(imageBase + 0x42E341) += 0x80;
}
}
if (*ffbOffset & 0x200000) //Gear 2
{
if ((!Gear2Pressed) && (!Gear1Pressed) && (!Gear3Pressed) && (!Gear4Pressed) && (!Gear5Pressed) && (!Gear6Pressed))
{
Gear2Pressed = true;
*(BYTE*)(imageBase + 0x42E296) -= 0x01;
*(BYTE*)(imageBase + 0x42E341) -= 0x80;
}
}
else
{
if (Gear2Pressed)
{
Gear2Pressed = false;
*(BYTE*)(imageBase + 0x42E296) += 0x01;
*(BYTE*)(imageBase + 0x42E341) += 0x80;
}
}
if (*ffbOffset & 0x08) //Gear 3 / Shift Up
{
if ((!Gear3Pressed) && (!Gear2Pressed) && (!Gear1Pressed) && (!Gear4Pressed) && (!Gear5Pressed) && (!Gear6Pressed))
{
Gear3Pressed = true;
*(BYTE*)(imageBase + 0x42E296) -= 0x01;
}
}
else
{
if (Gear3Pressed)
{
Gear3Pressed = false;
*(BYTE*)(imageBase + 0x42E296) += 0x01;
}
}
if (*ffbOffset & 0x04) //Gear 4 / Shift Down
{
if ((!Gear4Pressed) && (!Gear2Pressed) && (!Gear3Pressed) && (!Gear1Pressed) && (!Gear5Pressed) && (!Gear6Pressed))
{
Gear4Pressed = true;
*(BYTE*)(imageBase + 0x42E295) -= 0x80;
}
}
else
{
if (Gear4Pressed)
{
Gear4Pressed = false;
*(BYTE*)(imageBase + 0x42E295) += 0x80;
}
}
if (*ffbOffset & 0x1000000) //Gear 5
{
if ((!Gear5Pressed) && (!Gear2Pressed) && (!Gear3Pressed) && (!Gear4Pressed) && (!Gear1Pressed) && (!Gear6Pressed))
{
Gear5Pressed = true;
*(BYTE*)(imageBase + 0x42E295) -= 0x80;
*(BYTE*)(imageBase + 0x42E341) -= 0x40;
}
}
else
{
if (Gear5Pressed)
{
Gear5Pressed = false;
*(BYTE*)(imageBase + 0x42E295) += 0x80;
*(BYTE*)(imageBase + 0x42E341) += 0x40;
}
}
if (*ffbOffset & 0x2000000) //Gear 6/Reverse
{
if ((!Gear6Pressed) && (!Gear2Pressed) && (!Gear3Pressed) && (!Gear4Pressed) && (!Gear5Pressed) && (!Gear1Pressed))
{
Gear6Pressed = true;
*(BYTE*)(imageBase + 0x42E296) -= 0x01;
*(BYTE*)(imageBase + 0x42E341) -= 0x40;
}
}
else
{
if (Gear6Pressed)
{
Gear6Pressed = false;
*(BYTE*)(imageBase + 0x42E296) += 0x01;
*(BYTE*)(imageBase + 0x42E341) += 0x40;
}
}
*(float*)(imageBase + 0x42D994) = (*wheelSection - 128) / 128.0; // Steering
*(float*)(imageBase + 0x42D998) = (*ffbOffset3) / 255.0; // Gas
*(float*)(imageBase + 0x42D99C) = (*ffbOffset4) / 255.0; // Brake
*(float*)(imageBase + 0x42D9A0) = (*ffbOffset5) / 255.0; // Clutch
return 0;
}
static int KOFSkyStageThreadLoop(Helpers* helpers) // Temp Fix for turbo fire (Remove when proper fix sorted)
{
UINT8 JVSInput1 = helpers->ReadByte(0x2DF304, true);
UINT8 JVSInput1A = helpers->ReadByte(0x2DF305, true);
UINT8 Joystick1Up = helpers->ReadByte(0x37085A, true);
UINT8 Joystick1Down = helpers->ReadByte(0x370860, true);
UINT8 Joystick1Left = helpers->ReadByte(0x370866, true);
UINT8 Joystick1Right = helpers->ReadByte(0x37086C, true);
UINT8 Joystick1Start = helpers->ReadByte(0x37088A, true);
UINT8 Joystick1Button1 = helpers->ReadByte(0x370890, true);
UINT8 Joystick1Button2 = helpers->ReadByte(0x370896, true);
UINT8 Joystick1Button3 = helpers->ReadByte(0x37089C, true);
UINT8 JVSInput2 = helpers->ReadByte(0x2DF306, true);
UINT8 JVSInput2A = helpers->ReadByte(0x2DF307, true);
UINT8 Joystick2Up = helpers->ReadByte(0x370950, true);
UINT8 Joystick2Down = helpers->ReadByte(0x370956, true);
UINT8 Joystick2Left = helpers->ReadByte(0x37095C, true);
UINT8 Joystick2Right = helpers->ReadByte(0x370962, true);
UINT8 Joystick2Start = helpers->ReadByte(0x370980, true);
UINT8 Joystick2Button1 = helpers->ReadByte(0x370986, true);
UINT8 Joystick2Button2 = helpers->ReadByte(0x37098C, true);
UINT8 Joystick2Button3 = helpers->ReadByte(0x370992, true);
if (!(JVSInput1 & 0x20))
{
if (Joystick1Up == 0x01)
{
helpers->WriteByte(0x37085A, 0x00, true);
}
}
if (!(JVSInput1 & 0x10))
{
if (Joystick1Down == 0x01)
{
helpers->WriteByte(0x370860, 0x00, true);
}
}
if (!(JVSInput1 & 0x08))
{
if (Joystick1Left == 0x01)
{
helpers->WriteByte(0x370866, 0x00, true);
}
}
if (!(JVSInput1 & 0x04))
{
if (Joystick1Right == 0x01)
{
helpers->WriteByte(0x37086C, 0x00, true);
}
}
if (!(JVSInput1 & 0x80))
{
if (Joystick1Start == 0x01)
{
helpers->WriteByte(0x37088A, 0x00, true);
}
}
if (!(JVSInput1 & 0x02))
{
if (Joystick1Button1 == 0x01)
{
helpers->WriteByte(0x370890, 0x00, true);
helpers->WriteByte(0x370872, 0x00, true);
}
}
if (!(JVSInput1 & 0x01))
{
if (Joystick1Button2 == 0x01)
{
helpers->WriteByte(0x370896, 0x00, true);
helpers->WriteByte(0x370878, 0x00, true);
}
}
if (!(JVSInput1A & 0x80))
{
if (Joystick1Button3 == 0x01)
{
helpers->WriteByte(0x37089C, 0x00, true);
helpers->WriteByte(0x370884, 0x00, true);
}
}
if (!(JVSInput2 & 0x20))
{
if (Joystick2Up == 0x01)
{
helpers->WriteByte(0x370950, 0x00, true);
}
}
if (!(JVSInput2 & 0x10))
{
if (Joystick2Down == 0x01)
{
helpers->WriteByte(0x370956, 0x00, true);
}
}
if (!(JVSInput2 & 0x08))
{
if (Joystick2Left == 0x01)
{
helpers->WriteByte(0x37095C, 0x00, true);
}
}
if (!(JVSInput2 & 0x04))
{
if (Joystick2Right == 0x01)
{
helpers->WriteByte(0x370962, 0x00, true);
}
}
if (!(JVSInput2 & 0x80))
{
if (Joystick2Start == 0x01)
{
helpers->WriteByte(0x370980, 0x00, true);
}
}
if (!(JVSInput2 & 0x02))
{
if (Joystick2Button1 == 0x01)
{
helpers->WriteByte(0x370986, 0x00, true);
helpers->WriteByte(0x370968, 0x00, true);
}
}
if (!(JVSInput2 & 0x01))
{
if (Joystick2Button2 == 0x01)
{
helpers->WriteByte(0x37098C, 0x00, true);
helpers->WriteByte(0x37096E, 0x00, true);
}
}
if (!(JVSInput2A & 0x80))
{
if (Joystick2Button3 == 0x01)
{
helpers->WriteByte(0x370992, 0x00, true);
helpers->WriteByte(0x37097A, 0x00, true);
}
}
return 0;
}
static DWORD WINAPI BG4ProRunningLoop(LPVOID lpParam)
{
while (true)
{
BG4ProThreadLoop(0);
Sleep(16);
}
}
static DWORD WINAPI BG4RunningLoop(LPVOID lpParam)
{
while (true)
{
BG4ThreadLoop(0);
Sleep(16);
}
}
static DWORD WINAPI KOFSkyStageRunningLoop(LPVOID lpParam)
{
while (true)
{
KOFSkyStageThreadLoop(0);
Sleep(16);
}
}
@ -1184,7 +524,9 @@ static InitFunction initFunction([]()
injector::MakeRET(0x5F21B0, 4);
}
if (ToBool(config["General"]["Professional Edition Enable"]))
ProMode = (ToBool(config["General"]["Professional Edition Enable"]));
if (ProMode)
{
injector::MakeNOP(imageBase + 0x1E7AB, 6);
injector::MakeNOP(imageBase + 0x1E7DC, 6);
@ -1203,13 +545,9 @@ static InitFunction initFunction([]()
{
injector::MakeNOP(imageBase + 0x8ADFF, 10);
}
}
CreateThread(NULL, 0, BG4ProRunningLoop, NULL, 0, NULL);
}
else
{
CreateThread(NULL, 0, BG4RunningLoop, NULL, 0, NULL);
}
CreateThread(NULL, 0, RunningLoop, NULL, 0, NULL);
// IP stuff for working LAN
static const char* BroadcastAddress = config["Network"]["BroadcastAddress"].c_str();
@ -1505,7 +843,7 @@ static InitFunction initFunction([]()
//Temp Fix (Remove when properly sorted)
injector::MakeNOP(imageBase + 0xBD675, 3);
CreateThread(NULL, 0, KOFSkyStageRunningLoop, NULL, 0, NULL);
CreateThread(NULL, 0, RunningLoop, NULL, 0, NULL);
// don't hide windows and don't break desktop
injector::WriteMemory<BYTE>(imageBase + 0x12F6E2, 0xEB, true);