diff --git a/Config/FFBPlugin.ini b/Config/FFBPlugin.ini index 12249ea..fe39446 100644 --- a/Config/FFBPlugin.ini +++ b/Config/FFBPlugin.ini @@ -510,6 +510,30 @@ AlternativeMinForceLeftMaximumSpeed=0 AlternativeMaxForceLeftMaximumSpeed=-100 AlternativeMinForceRightMaximumSpeed=0 AlternativeMaxForceRightMaximumSpeed=100 +EnableDamperClubKart=0 +DamperStrengthClubKart=100 +FeedbackLengthClubKart=500 +PowerModeClubKart=0 +EnableForceSpringEffectClubKart=0 +ForceSpringStrengthClubKart=80 +MinForceClubKart=0 +MaxForceClubKart=100 +AlternativeMinForceLeftClubKart=0 +AlternativeMaxForceLeftClubKart=-100 +AlternativeMinForceRightClubKart=0 +AlternativeMaxForceRightClubKart=100 +EnableDamperKingOfRoute66=0 +DamperStrengthKingOfRoute66=100 +FeedbackLengthKingOfRoute66=500 +PowerModeKingOfRoute66=0 +EnableForceSpringEffectKingOfRoute66=0 +ForceSpringStrengthKingOfRoute66=80 +MinForceKingOfRoute66=0 +MaxForceKingOfRoute66=100 +AlternativeMinForceLeftKingOfRoute66=0 +AlternativeMaxForceLeftKingOfRoute66=-100 +AlternativeMinForceRightKingOfRoute66=0 +AlternativeMaxForceRightKingOfRoute66=100 [Crazy Taxi Steam] GameId=58 diff --git a/Game Files/Demul.cpp b/Game Files/Demul.cpp index 4a09756..efc63be 100644 --- a/Game Files/Demul.cpp +++ b/Game Files/Demul.cpp @@ -94,6 +94,9 @@ extern int AutoCloseWindowError; extern int EnableDamper; extern int DamperStrength; +static bool IncreaseSine; + + static int InputDeviceWheelEnable = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceWheelEnable"), 0, settingsFilename); static int configMinForceInitialDDemul = GetPrivateProfileInt(TEXT("Settings"), TEXT("MinForceInitialDDemul"), 0, settingsFilename); @@ -108,6 +111,7 @@ static int EnableForceSpringEffectInitialDDemul = GetPrivateProfileInt(TEXT("Set static int ForceSpringStrengthInitialDDemul = GetPrivateProfileInt(TEXT("Settings"), TEXT("ForceSpringStrengthInitialDDemul"), 0, settingsFilename); static int EnableDamperInitialDDemul = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableDamperInitialDDemul"), 0, settingsFilename); static int DamperStrengthInitialDDemul = GetPrivateProfileInt(TEXT("Settings"), TEXT("DamperStrengthInitialDDemul"), 100, settingsFilename); +static int IncreaseSineInitialDDemul = GetPrivateProfileInt(TEXT("Settings"), TEXT("IncreaseSineInitialDDemul"), 0, settingsFilename); static int configMinForceNascarRacing = GetPrivateProfileInt(TEXT("Settings"), TEXT("MinForceNascarRacing"), 0, settingsFilename); static int configMaxForceNascarRacing = GetPrivateProfileInt(TEXT("Settings"), TEXT("MaxForceNascarRacing"), 100, settingsFilename); @@ -317,45 +321,58 @@ int fasterspeed(int ffspeed) { static int InitialDFFBLoop() { - UINT8 ff1 = myHelpers->ReadByte(FFBAddress, false); - UINT8 ff2 = myHelpers->ReadByte(FFBAddress + 0x01, false); - UINT8 ff3 = myHelpers->ReadByte(FFBAddress + 0x02, false); + DWORD FFB = myHelpers->ReadInt32(FFBAddress, false); + + BYTE* ffb = reinterpret_cast(&FFB); if (KickStartWait) { - if ((ff1 == 0x80) && (ff3 == 0x01)) + if (ffb[0] == 0x80 && ffb[2] == 0x01) { myTriggers->Spring(1.0); } - if ((ff1 == 0x85) && (ff2 == 0x3F) && (ff3 > 0x00) && (ff3 < 0x30)) + if (ffb[0] == 0x85 && ffb[1] > 0x00 && ffb[2] > 0x00) { - double percentForce = ff3 / 47.0; + double percentForce = ffb[2] / 127.0; + + if (IncreaseSine) + { + percentForce = percentForce * 2.0; + + if (percentForce > 1.0) + percentForce = 1.0; + } + + double Period = ffb[1] / 127.0 * 120.0; double percentLength = 100; myTriggers->Rumble(percentForce, percentForce, percentLength); - myTriggers->Sine(40, 0, percentForce); + myTriggers->Sine(static_cast(Period), 0, percentForce); } - if ((ff1 == 0x86) && (ff2 == 0x02) && (ff3 > 0x09) && (ff3 < 0x3C)) + if (ffb[0] == 0x86 && ffb[2] > 0x00) { - double percentForce = (60 - ff3) / 43.0; + double percentForce = ffb[2] / 127.0; double percentLength = 100; myTriggers->Spring(percentForce); } - if ((ff1 == 0x84) && (ff2 == 0x00) && (ff3 > 0x37) && (ff3 < 0x80)) + if (ffb[0] == 0x84 && ffb[2] > 0x00) { - double percentForce = (128 - ff3) / 72.0; - double percentLength = 100; - myTriggers->Rumble(percentForce, 0, percentLength); - myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((ff1 == 0x84) && (ff2 == 0x01) && (ff3 > 0x00) && (ff3 < 0x49)) - { - double percentForce = (ff3 / 72.0); - double percentLength = 100; - myTriggers->Rumble(0, percentForce, percentLength); - myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce); + if (ffb[1] == 0x00) + { + double percentForce = (128 - ffb[0]) / 127.0; + double percentLength = 100; + myTriggers->Rumble(percentForce, 0, percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce); + } + else + { + double percentForce = (ffb[0] / 127.0); + double percentLength = 100; + myTriggers->Rumble(0, percentForce, percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce); + } } } return 0; diff --git a/Game Files/GTIClub3.cpp b/Game Files/GTIClub3.cpp index fe6bea1..05ae80f 100644 --- a/Game Files/GTIClub3.cpp +++ b/Game Files/GTIClub3.cpp @@ -32,27 +32,29 @@ void GTIClub3::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTrigg triggers->Damper(DamperStrength / 100.0); } - if ((ff1 > 0x00)& (ff1 < 0x40)& (menu == 0)) + if (!menu) { - double percentForce = (ff1) / 63.0; - double percentLength = 100; - triggers->Rumble(percentForce, percentForce, percentLength); - triggers->Sine(120, 120, percentForce); - } - if ((ff > 0x80)& (ff < 0x101)& (menu == 0)) - { - helpers->log("moving wheel right"); - double percentForce = (257 - ff) / 128.0; - double percentLength = 100; - triggers->Rumble(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((ff > 0x00)& (ff < 0x80)& (menu == 0)) - { - helpers->log("moving wheel left"); - double percentForce = (ff) / 127.0; - double percentLength = 100; - triggers->Rumble(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + if (ff1 > 0x00 && ff1 < 0x40) + { + double percentForce = ff1 / 63.0; + double percentLength = 100; + triggers->Rumble(percentForce, percentForce, percentLength); + triggers->Sine(120, 0, percentForce); + } + + if (ff > 0x80 && ff < 0x101) + { + double percentForce = (257 - ff) / 128.0; + double percentLength = 100; + triggers->Rumble(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + } + else if (ff > 0x00 && ff < 0x80) + { + double percentForce = (ff) / 127.0; + double percentLength = 100; + triggers->Rumble(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + } } } \ No newline at end of file diff --git a/Game Files/InitialD0v131.cpp b/Game Files/InitialD0v131.cpp index 5be1996..2b6a822 100644 --- a/Game Files/InitialD0v131.cpp +++ b/Game Files/InitialD0v131.cpp @@ -18,27 +18,20 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. extern int EnableDamper; extern int DamperStrength; -static bool outputinit = false; - -static UINT8 ff; -static UINT8 oldff; -static UINT8 newff; -static UINT8 ff1; -static UINT8 ff2; -static UINT8 ff3; +static bool outputinit; static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini"); static int EnableForceSpringEffect = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableForceSpringEffect"), 0, settingsFilename); static int ForceSpringStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("ForceSpringStrength"), 0, settingsFilename); static int EscapeKeyExitViaPlugin = GetPrivateProfileInt(TEXT("Settings"), TEXT("EscapeKeyExitViaPlugin"), 0, settingsFilename); -static int IDZMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("IDZMode"), 0, settingsFilename); static int EnableOutputs = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableOutputs"), 0, settingsFilename); +static int IncreaseSine = GetPrivateProfileInt(TEXT("Settings"), TEXT("IncreaseSine"), 0, settingsFilename); void InitialD0::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { if (!outputinit) { - if (EnableOutputs == 1) + if (EnableOutputs) { outputinit = true; LoadLibraryA("OutputBlaster.dll"); @@ -46,127 +39,60 @@ void InitialD0::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTrig } if (GetAsyncKeyState((VK_ESCAPE)) && (EscapeKeyExitViaPlugin == 1)) - { ExitProcess(0); - } - if (EnableDamper == 1) - { + if (EnableDamper) triggers->Damper(DamperStrength / 100.0); + + DWORD FFB = helpers->ReadInt32(0x168317C, true); + + BYTE* ffb = reinterpret_cast(&FFB); + + if (ffb[0] == 0x80 && ffb[2] == 0x01) + { + triggers->Spring(1.0); } - if (IDZMode == 0) + if (ffb[0] == 0x85 && ffb[1] > 0x00 && ffb[2] > 0x00) { - ff = helpers->ReadByte(0x168317F, true); - oldff = 0; - newff = ff; + double percentForce = ffb[2] / 127.0; - helpers->log("got value: "); - std::string ffs = std::to_string(ff); - helpers->log((char*)ffs.c_str()); - - if (EnableForceSpringEffect == 1) + if (IncreaseSine) { - triggers->Springi(ForceSpringStrength / 100.0); + percentForce = percentForce * 2.0; + + if (percentForce > 1.0) + percentForce = 1.0; } - if (oldff != newff) - { - if ((ff > 0x37) && (ff < 0x80)) - { - helpers->log("moving wheel right"); - double percentForce = (128 - ff) / 72.0; - double percentLength = 100; - triggers->Rumble(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((ff > 0x00) && (ff < 0x49)) - { - helpers->log("moving wheel left"); - double percentForce = (ff) / 72.0; - double percentLength = 100; - triggers->Rumble(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - } - oldff = newff; + double Period = ffb[1] / 127.0 * 120.0; + double percentLength = 100; + triggers->Rumble(percentForce, percentForce, percentLength); + triggers->Sine(static_cast(Period), 0, percentForce); } - else - { - ff1 = helpers->ReadByte(0x168317C, true); - ff2 = helpers->ReadByte(0x168317D, true); - if (IDZMode == 1) - { - ff3 = helpers->ReadByte(0x168317E, true); - } - else if (IDZMode == 2) - { - ff3 = helpers->ReadByte(0x168317F, true); - } - if (ff1 == 80) + if (ffb[0] == 0x86 && ffb[2] > 0x00) + { + double percentForce = ffb[2] / 127.0; + double percentLength = 100; + triggers->Spring(percentForce); + } + + if (ffb[0] == 0x84 && ffb[2] > 0x00) + { + if (ffb[1] == 0x00) { - helpers->log("Spring"); - triggers->Spring(1.0); + double percentForce = (128 - ffb[0]) / 127.0; + double percentLength = 100; + triggers->Rumble(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } - else if (ff1 == 0x85) + else { - if ((ff2 > 0x00) && (ff2 < 0x30)) - { - helpers->log("Sine"); - double percentForce = ff2 / 47.0; - double percentLength = 100; - triggers->Rumble(percentForce, percentForce, percentLength); - triggers->Sine(40, 0, percentForce); - } - } - else if (ff1 == 0x86) - { - if ((ff3 > 0x00) && (ff3 < 0x4E)) - { - helpers->log("Spring"); - double percentForce = ff3 / 77.0; - double percentLength = 100; - triggers->Spring(percentForce); - } - } - else if (ff1 == 0x84) - { - if ((ff2 == 0x00) && (ff3 > 0x37) && (ff3 < 0x80)) - { - helpers->log("moving wheel right"); - double percentForce = (128 - ff3) / 72.0; - double percentLength = 100; - triggers->Rumble(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((ff2 == 0x01) && (ff3 > 0x00) && (ff3 < 0x49)) - { - helpers->log("moving wheel left"); - double percentForce = (ff3 / 72.0); - double percentLength = 100; - triggers->Rumble(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else - { - if ((ff2 == 0x00) && (ff3 > 0x00) && (ff3 < 0x38)) - { - helpers->log("moving wheel right"); - double percentForce = 1.0; - double percentLength = 100; - triggers->Rumble(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((ff2 == 0x01) && (ff3 > 0x48)) - { - helpers->log("moving wheel left"); - double percentForce = 1.0; - double percentLength = 100; - triggers->Rumble(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - } + double percentForce = (ffb[0] / 127.0); + double percentLength = 100; + triggers->Rumble(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); } } } \ No newline at end of file diff --git a/Game Files/InitialD0v211.cpp b/Game Files/InitialD0v211.cpp index e684cab..3b5c907 100644 --- a/Game Files/InitialD0v211.cpp +++ b/Game Files/InitialD0v211.cpp @@ -15,24 +15,17 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. #include "InitialD0v211.h" #include "math.h" -static UINT8 ff; -static UINT8 oldff; -static UINT8 newff; -static UINT8 ff1; -static UINT8 ff2; -static UINT8 ff3; - extern int EnableDamper; extern int DamperStrength; -static bool outputinit = false; +static bool outputinit; static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini"); static int EnableForceSpringEffect = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableForceSpringEffect"), 0, settingsFilename); static int ForceSpringStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("ForceSpringStrength"), 0, settingsFilename); static int EscapeKeyExitViaPlugin = GetPrivateProfileInt(TEXT("Settings"), TEXT("EscapeKeyExitViaPlugin"), 0, settingsFilename); -static int IDZMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("IDZMode"), 0, settingsFilename); static int EnableOutputs = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableOutputs"), 0, settingsFilename); +static int IncreaseSine = GetPrivateProfileInt(TEXT("Settings"), TEXT("IncreaseSine"), 0, settingsFilename); void InitialD0v211::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { @@ -46,127 +39,60 @@ void InitialD0v211::FFBLoop(EffectConstants* constants, Helpers* helpers, Effect } if (GetAsyncKeyState((VK_ESCAPE)) && (EscapeKeyExitViaPlugin == 1)) - { ExitProcess(0); - } - if (EnableDamper == 1) - { + if (EnableDamper) triggers->Damper(DamperStrength / 100.0); + + DWORD FFB = helpers->ReadInt32(0x18A720C, true); + + BYTE* ffb = reinterpret_cast(&FFB); + + if (ffb[0] == 0x80 && ffb[2] == 0x01) + { + triggers->Spring(1.0); } - if (IDZMode == 0) + if (ffb[0] == 0x85 && ffb[1] > 0x00 && ffb[2] > 0x00) { - ff = helpers->ReadByte(0x18A720F, true); - oldff = 0; - newff = ff; + double percentForce = ffb[2] / 127.0; - helpers->log("got value: "); - std::string ffs = std::to_string(ff); - helpers->log((char*)ffs.c_str()); - - if (EnableForceSpringEffect == 1) + if (IncreaseSine) { - triggers->Springi(ForceSpringStrength / 100.0); + percentForce = percentForce * 2.0; + + if (percentForce > 1.0) + percentForce = 1.0; } - if (oldff != newff) - { - if ((ff > 0x37) && (ff < 0x80)) - { - helpers->log("moving wheel right"); - double percentForce = (128 - ff) / 72.0; - double percentLength = 100; - triggers->Rumble(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((ff > 0x00) && (ff < 0x49)) - { - helpers->log("moving wheel left"); - double percentForce = (ff) / 72.0; - double percentLength = 100; - triggers->Rumble(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - } - oldff = newff; + double Period = ffb[1] / 127.0 * 120.0; + double percentLength = 100; + triggers->Rumble(percentForce, percentForce, percentLength); + triggers->Sine(static_cast(Period), 0, percentForce); } - else - { - ff1 = helpers->ReadByte(0x18A720C, true); - ff2 = helpers->ReadByte(0x18A720D, true); - if (IDZMode == 1) - { - ff3 = helpers->ReadByte(0x18A720E, true); - } - else if (IDZMode == 2) - { - ff3 = helpers->ReadByte(0x18A720F, true); - } - if (ff1 == 80) + if (ffb[0] == 0x86 && ffb[2] > 0x00) + { + double percentForce = ffb[2] / 127.0; + double percentLength = 100; + triggers->Spring(percentForce); + } + + if (ffb[0] == 0x84 && ffb[2] > 0x00) + { + if (ffb[1] == 0x00) { - helpers->log("Spring"); - triggers->Spring(1.0); + double percentForce = (128 - ffb[0]) / 127.0; + double percentLength = 100; + triggers->Rumble(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } - else if (ff1 == 0x85) + else { - if ((ff2 > 0x00) && (ff2 < 0x30)) - { - helpers->log("Sine"); - double percentForce = ff2 / 47.0; - double percentLength = 100; - triggers->Rumble(percentForce, percentForce, percentLength); - triggers->Sine(40, 0, percentForce); - } - } - else if (ff1 == 0x86) - { - if ((ff3 > 0x00) && (ff3 < 0x4E)) - { - helpers->log("Spring"); - double percentForce = ff3 / 77.0; - double percentLength = 100; - triggers->Spring(percentForce); - } - } - else if (ff1 == 0x84) - { - if ((ff2 == 0x00) && (ff3 > 0x37) && (ff3 < 0x80)) - { - helpers->log("moving wheel right"); - double percentForce = (128 - ff3) / 72.0; - double percentLength = 100; - triggers->Rumble(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((ff2 == 0x01) && (ff3 > 0x00) && (ff3 < 0x49)) - { - helpers->log("moving wheel left"); - double percentForce = (ff3 / 72.0); - double percentLength = 100; - triggers->Rumble(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else - { - if ((ff2 == 0x00) && (ff3 > 0x00) && (ff3 < 0x38)) - { - helpers->log("moving wheel right"); - double percentForce = 1.0; - double percentLength = 100; - triggers->Rumble(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((ff2 == 0x01) && (ff3 > 0x48)) - { - helpers->log("moving wheel left"); - double percentForce = 1.0; - double percentLength = 100; - triggers->Rumble(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - } + double percentForce = (ffb[0] / 127.0); + double percentLength = 100; + triggers->Rumble(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); } } } \ No newline at end of file diff --git a/Game Files/InitialD0v230.cpp b/Game Files/InitialD0v230.cpp index 3f0a699..9d5a40c 100644 --- a/Game Files/InitialD0v230.cpp +++ b/Game Files/InitialD0v230.cpp @@ -15,30 +15,23 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. #include "InitialD0v230.h" #include "math.h" -static UINT8 ff; -static UINT8 oldff; -static UINT8 newff; -static UINT8 ff1; -static UINT8 ff2; -static UINT8 ff3; - extern int EnableDamper; extern int DamperStrength; -static bool outputinit = false; +static bool outputinit; static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini"); static int EnableForceSpringEffect = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableForceSpringEffect"), 0, settingsFilename); static int ForceSpringStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("ForceSpringStrength"), 0, settingsFilename); static int EscapeKeyExitViaPlugin = GetPrivateProfileInt(TEXT("Settings"), TEXT("EscapeKeyExitViaPlugin"), 0, settingsFilename); -static int IDZMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("IDZMode"), 0, settingsFilename); static int EnableOutputs = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableOutputs"), 0, settingsFilename); +static int IncreaseSine = GetPrivateProfileInt(TEXT("Settings"), TEXT("IncreaseSine"), 0, settingsFilename); void InitialD0v230::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { if (!outputinit) { - if (EnableOutputs == 1) + if (EnableOutputs) { outputinit = true; LoadLibraryA("OutputBlaster.dll"); @@ -46,127 +39,60 @@ void InitialD0v230::FFBLoop(EffectConstants* constants, Helpers* helpers, Effect } if (GetAsyncKeyState((VK_ESCAPE)) && (EscapeKeyExitViaPlugin == 1)) - { ExitProcess(0); - } - if (EnableDamper == 1) - { + if (EnableDamper) triggers->Damper(DamperStrength / 100.0); + + DWORD FFB = helpers->ReadInt32(0x18B54DC, true); + + BYTE* ffb = reinterpret_cast(&FFB); + + if (ffb[0] == 0x80 && ffb[2] == 0x01) + { + triggers->Spring(1.0); } - if (IDZMode == 0) + if (ffb[0] == 0x85 && ffb[1] > 0x00 && ffb[2] > 0x00) { - ff = helpers->ReadByte(0x18B54DF, true); - oldff = 0; - newff = ff; + double percentForce = ffb[2] / 127.0; - helpers->log("got value: "); - std::string ffs = std::to_string(ff); - helpers->log((char*)ffs.c_str()); - - if (EnableForceSpringEffect == 1) + if (IncreaseSine) { - triggers->Springi(ForceSpringStrength / 100.0); + percentForce = percentForce * 2.0; + + if (percentForce > 1.0) + percentForce = 1.0; } - if (oldff != newff) - { - if ((ff > 0x37) && (ff < 0x80)) - { - helpers->log("moving wheel right"); - double percentForce = (128 - ff) / 72.0; - double percentLength = 100; - triggers->Rumble(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((ff > 0x00) && (ff < 0x49)) - { - helpers->log("moving wheel left"); - double percentForce = (ff) / 72.0; - double percentLength = 100; - triggers->Rumble(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - } - oldff = newff; + double Period = ffb[1] / 127.0 * 120.0; + double percentLength = 100; + triggers->Rumble(percentForce, percentForce, percentLength); + triggers->Sine(static_cast(Period), 0, percentForce); } - else - { - ff1 = helpers->ReadByte(0x18B54DC, true); - ff2 = helpers->ReadByte(0x18B54DD, true); - if (IDZMode == 1) - { - ff3 = helpers->ReadByte(0x18B54DE, true); - } - else if (IDZMode == 2) - { - ff3 = helpers->ReadByte(0x18B54DF, true); - } - if (ff1 == 80) + if (ffb[0] == 0x86 && ffb[2] > 0x00) + { + double percentForce = ffb[2] / 127.0; + double percentLength = 100; + triggers->Spring(percentForce); + } + + if (ffb[0] == 0x84 && ffb[2] > 0x00) + { + if (ffb[1] == 0x00) { - helpers->log("Spring"); - triggers->Spring(1.0); + double percentForce = (128 - ffb[0]) / 127.0; + double percentLength = 100; + triggers->Rumble(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } - else if (ff1 == 0x85) + else { - if ((ff2 > 0x00) && (ff2 < 0x30)) - { - helpers->log("Sine"); - double percentForce = ff2 / 47.0; - double percentLength = 100; - triggers->Rumble(percentForce, percentForce, percentLength); - triggers->Sine(40, 0, percentForce); - } - } - else if (ff1 == 0x86) - { - if ((ff3 > 0x00) && (ff3 < 0x4E)) - { - helpers->log("Spring"); - double percentForce = ff3 / 77.0; - double percentLength = 100; - triggers->Spring(percentForce); - } - } - else if (ff1 == 0x84) - { - if ((ff2 == 0x00) && (ff3 > 0x37) && (ff3 < 0x80)) - { - helpers->log("moving wheel right"); - double percentForce = (128 - ff3) / 72.0; - double percentLength = 100; - triggers->Rumble(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((ff2 == 0x01) && (ff3 > 0x00) && (ff3 < 0x49)) - { - helpers->log("moving wheel left"); - double percentForce = (ff3 / 72.0); - double percentLength = 100; - triggers->Rumble(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else - { - if ((ff2 == 0x00) && (ff3 > 0x00) && (ff3 < 0x38)) - { - helpers->log("moving wheel right"); - double percentForce = 1.0; - double percentLength = 100; - triggers->Rumble(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((ff2 == 0x01) && (ff3 > 0x48)) - { - helpers->log("moving wheel left"); - double percentForce = 1.0; - double percentLength = 100; - triggers->Rumble(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - } + double percentForce = (ffb[0] / 127.0); + double percentLength = 100; + triggers->Rumble(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); } } } \ No newline at end of file diff --git a/Game Files/InitialD4.cpp b/Game Files/InitialD4.cpp index 598d3eb..8854fcf 100644 --- a/Game Files/InitialD4.cpp +++ b/Game Files/InitialD4.cpp @@ -18,51 +18,59 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. extern int EnableDamper; extern int DamperStrength; +static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini"); +static int IncreaseSine = GetPrivateProfileInt(TEXT("Settings"), TEXT("IncreaseSine"), 0, settingsFilename); + void InitialD4::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { + DWORD FFB = helpers->ReadInt32(0x089AE898, true); - UINT8 ff = helpers->ReadByte(0x089AE89A, /* isRelativeOffset */ false); - UINT8 ff1 = helpers->ReadByte(0x089AE899, /* isRelativeOffset */ false); - UINT8 ff2 = helpers->ReadByte(0x089AE898, /* isRelativeOffset */ false); - helpers->log("got value: "); - std::string ffs = std::to_string(ff); - helpers->log((char*)ffs.c_str()); + BYTE* ffb = reinterpret_cast(&FFB); - if (EnableDamper == 1) + if (ffb[0] == 0x80 && ffb[2] == 0x01) { - triggers->Damper(DamperStrength / 100.0); + triggers->Spring(1.0); } - if (ff2 == 0x86) + if (ffb[0] == 0x85 && ffb[1] > 0x00 && ffb[2] > 0x00) { - triggers->Spring(0.8); - } - if (ff2 == 0x85) //cars colliding or rubbing against wall etc - { - if (ff1 > 0) + double percentForce = ffb[2] / 127.0; + + if (IncreaseSine) { - double percentLength = 200; - double percentForce = (0.6); - triggers->Friction(percentForce); - triggers->Rumble(percentForce, percentForce, percentLength); + percentForce = percentForce * 2.0; + + if (percentForce > 1.0) + percentForce = 1.0; } + + double Period = ffb[1] / 127.0 * 120.0; + double percentLength = 100; + triggers->Rumble(percentForce, percentForce, percentLength); + triggers->Sine(static_cast(Period), 0, percentForce); } - if (ff2 == 0x84) + + if (ffb[0] == 0x86 && ffb[2] > 0x00) { - if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0)) + double percentForce = ffb[2] / 127.0; + double percentLength = 100; + triggers->Spring(percentForce); + } + + if (ffb[0] == 0x84 && ffb[2] > 0x00) + { + if (ffb[1] == 0x00) { - helpers->log("moving wheel right"); - double percentForce = (128 - ff) / 72.0; + double percentForce = (128 - ffb[0]) / 127.0; double percentLength = 100; triggers->Rumble(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } - else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1)) + else { - helpers->log("moving wheel left"); - double percentForce = (ff) / 72.0; + double percentForce = (ffb[0] / 127.0); double percentLength = 100; triggers->Rumble(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); } } -} \ No newline at end of file +} \ No newline at end of file diff --git a/Game Files/InitialD4Japan.cpp b/Game Files/InitialD4Japan.cpp index d9525ca..0036a22 100644 --- a/Game Files/InitialD4Japan.cpp +++ b/Game Files/InitialD4Japan.cpp @@ -18,48 +18,60 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. extern int EnableDamper; extern int DamperStrength; +static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini"); +static int IncreaseSine = GetPrivateProfileInt(TEXT("Settings"), TEXT("IncreaseSine"), 0, settingsFilename); + void InitialD4Japan::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { - UINT8 ff = helpers->ReadByte(0x0898985A, /* isRelativeOffset */ false); - UINT8 ff1 = helpers->ReadByte(0x08989859, /* isRelativeOffset */ false); - UINT8 ff2 = helpers->ReadByte(0x08989858, /* isRelativeOffset */ false); - helpers->log("got value: "); - std::string ffs = std::to_string(ff); - helpers->log((char*)ffs.c_str()); - - if (EnableDamper == 1) - { + if (EnableDamper) triggers->Damper(DamperStrength / 100.0); + + DWORD FFB = helpers->ReadInt32(0x08989858, true); + + BYTE* ffb = reinterpret_cast(&FFB); + + if (ffb[0] == 0x80 && ffb[2] == 0x01) + { + triggers->Spring(1.0); } - if (ff2 == 0x86) + if (ffb[0] == 0x85 && ffb[1] > 0x00 && ffb[2] > 0x00) { - triggers->Spring(0.8); - } - if (ff2 == 0x85) //cars colliding or rubbing against wall etc - { - if (ff1 > 0) + double percentForce = ffb[2] / 127.0; + + if (IncreaseSine) { - double percentLength = 200; - double percentForce = (0.6); - triggers->Friction(percentForce); - triggers->Rumble(percentForce, percentForce, percentLength); + percentForce = percentForce * 2.0; + + if (percentForce > 1.0) + percentForce = 1.0; } + + double Period = ffb[1] / 127.0 * 120.0; + double percentLength = 100; + triggers->Rumble(percentForce, percentForce, percentLength); + triggers->Sine(static_cast(Period), 0, percentForce); } - if (ff2 == 0x84) + + if (ffb[0] == 0x86 && ffb[2] > 0x00) { - if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0)) + double percentForce = ffb[2] / 127.0; + double percentLength = 100; + triggers->Spring(percentForce); + } + + if (ffb[0] == 0x84 && ffb[2] > 0x00) + { + if (ffb[1] == 0x00) { - helpers->log("moving wheel right"); - double percentForce = (128 - ff) / 72.0; + double percentForce = (128 - ffb[0]) / 127.0; double percentLength = 100; triggers->Rumble(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } - else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1)) + else { - helpers->log("moving wheel left"); - double percentForce = (ff) / 72.0; + double percentForce = (ffb[0] / 127.0); double percentLength = 100; triggers->Rumble(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); diff --git a/Game Files/InitialD5.cpp b/Game Files/InitialD5.cpp index 93ff911..12244a0 100644 --- a/Game Files/InitialD5.cpp +++ b/Game Files/InitialD5.cpp @@ -18,51 +18,63 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. extern int EnableDamper; extern int DamperStrength; +static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini"); +static int IncreaseSine = GetPrivateProfileInt(TEXT("Settings"), TEXT("IncreaseSine"), 0, settingsFilename); + void InitialD5::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { - UINT8 ff = helpers->ReadByte(0x08CB6122, /* isRelativeOffset */ false); - UINT8 ff1 = helpers->ReadByte(0x08CB6121, /* isRelativeOffset */ false); - UINT8 ff2 = helpers->ReadByte(0x08CB6120, /* isRelativeOffset */ false); - helpers->log("got value: "); - std::string ffs = std::to_string(ff); - helpers->log((char*)ffs.c_str()); - - if (EnableDamper == 1) - { + if (EnableDamper) triggers->Damper(DamperStrength / 100.0); + + DWORD FFB = helpers->ReadInt32(0x8CB6120, true); + + BYTE* ffb = reinterpret_cast(&FFB); + + if (ffb[0] == 0x80 && ffb[2] == 0x01) + { + triggers->Spring(1.0); } - if (ff2 == 0x86) + if (ffb[0] == 0x85 && ffb[1] > 0x00 && ffb[2] > 0x00) { - triggers->Spring(0.8); - } - if (ff2 == 0x85) //cars colliding or rubbing against wall etc - { - if (ff1 > 0) + double percentForce = ffb[2] / 127.0; + + if (IncreaseSine) { - double percentLength = 200; - double percentForce = (0.6); - triggers->Friction(percentForce); - triggers->Rumble(percentForce, percentForce, percentLength); + percentForce = percentForce * 2.0; + + if (percentForce > 1.0) + percentForce = 1.0; } + + double Period = ffb[1] / 127.0 * 120.0; + double percentLength = 100; + triggers->Rumble(percentForce, percentForce, percentLength); + triggers->Sine(static_cast(Period), 0, percentForce); } - if (ff2 == 0x84) + + if (ffb[0] == 0x86 && ffb[2] > 0x00) { - if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0)) + double percentForce = ffb[2] / 127.0; + double percentLength = 100; + triggers->Spring(percentForce); + } + + if (ffb[0] == 0x84 && ffb[2] > 0x00) + { + if (ffb[1] == 0x00) { - helpers->log("moving wheel right"); - double percentForce = (128 - ff) / 72.0; + double percentForce = (128 - ffb[0]) / 127.0; double percentLength = 100; triggers->Rumble(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } - else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1)) + else { - helpers->log("moving wheel left"); - double percentForce = (ff) / 72.0; + double percentForce = (ffb[0] / 127.0); double percentLength = 100; triggers->Rumble(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); } } -} \ No newline at end of file +} \ No newline at end of file diff --git a/Game Files/InitialD6.cpp b/Game Files/InitialD6.cpp index 2f439d6..37c2f72 100644 --- a/Game Files/InitialD6.cpp +++ b/Game Files/InitialD6.cpp @@ -17,6 +17,9 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. extern int EnableDamper; extern int DamperStrength; +static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini"); +static int IncreaseSine = GetPrivateProfileInt(TEXT("Settings"), TEXT("IncreaseSine"), 0, settingsFilename); + static int carscollide(int ffcollide) { switch (ffcollide) { case 0x50F05: @@ -127,52 +130,58 @@ static int rubbingwalls(int ffwalls) { void InitialD6::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { - int ffrubbingwalls = 0; - int ffcarcollision = 0; + DWORD FFB = GetTeknoParrotFFB(); + + BYTE* ffb = reinterpret_cast(&FFB); + + if (EnableDamper) + triggers->Damper(DamperStrength / 100.0); + + if (ffb[2] == 0x00 && ffb[0] == 0x01) { - helpers->log("in ID6 Ffbloop"); - const int ff = GetTeknoParrotFFB(); - std::string ffs = std::to_string(ff); - helpers->log((char*)ffs.c_str()); - ffcarcollision = carscollide(ff); - ffrubbingwalls = rubbingwalls(ff); + triggers->Spring(1.0); + } - if (EnableDamper == 1) + if (ffb[2] == 0x05 && ffb[1] > 0x00 && ffb[0] > 0x00) + { + double percentForce = ffb[0] / 127.0; + + if (IncreaseSine) { - triggers->Damper(DamperStrength / 100.0); + percentForce = percentForce * 2.0; + + if (percentForce > 1.0) + percentForce = 1.0; } - if (ff == 0x60000) + double Period = ffb[1] / 127.0 * 120.0; + double percentLength = 100; + triggers->Rumble(percentForce, percentForce, percentLength); + triggers->Sine(static_cast(Period), 0, percentForce); + } + + if (ffb[2] == 0x06 && ffb[0] > 0x00 && ffb[0] < 0x80) + { + double percentForce = ffb[0] / 127.0; + double percentLength = 100; + triggers->Spring(percentForce); + } + + if (ffb[2] == 0x04 && ffb[0] > 0x00 && ffb[0] < 0x80) + { + if (ffb[1] == 0x00) { - triggers->Spring(0.8); - } - if (ffrubbingwalls > 0) // car rubbing against wall - { - double percentLength = 200; - double percentForce = (ffrubbingwalls / 31.0); - triggers->Friction(percentForce); - triggers->Rumble(percentForce, percentForce, percentLength); - } - if (ffcarcollision > 0) //cars colliding or rubbing with each other - { - double percentLength = 200; - double percentForce = (ffcarcollision / 16.0); - triggers->Friction(percentForce); - triggers->Rumble(percentForce, percentForce, percentLength); - } - if ((ff > 0x40037) && (ff < 0x40080)) - { - double percentForce = (262272 - ff) / 72.0; + double percentForce = (128 - ffb[0]) / 127.0; double percentLength = 100; triggers->Rumble(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } - else if ((ff > 0x40100) && (ff < 0x40149)) + else { - double percentForce = (ff - 262400) / 72.0; + double percentForce = (ffb[0] / 127.0); double percentLength = 100; triggers->Rumble(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); } } -} \ No newline at end of file +} \ No newline at end of file diff --git a/Game Files/InitialD7.cpp b/Game Files/InitialD7.cpp index cbb5793..a45d324 100644 --- a/Game Files/InitialD7.cpp +++ b/Game Files/InitialD7.cpp @@ -17,159 +17,60 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. extern int EnableDamper; extern int DamperStrength; -static int carscollide(int ffcollide) { - switch (ffcollide) { - case 0x50F05: - return 16; - case 0x50E05: - return 15; - case 0x50D05: - return 14; - case 0x50C05: - return 13; - case 0x50B05: - return 12; - case 0x50A05: - return 11; - case 0x50905: - return 10; - case 0x50805: - return 9; - case 0x50705: - return 8; - case 0x50605: - return 7; - case 0x050505: - return 6; - case 0x050405: - return 5; - case 0x050305: - return 4; - case 0x50205: - return 3; - case 0x50105: - return 2; - case 0x50005: - return 1; - default: - return 0; - } -} - -static int rubbingwalls(int ffwalls) { - switch (ffwalls) { - case 0x51F08: - return 31; - case 0x51E08: - return 30; - case 0x51D08: - return 29; - case 0x51C08: - return 28; - case 0x51B08: - return 27; - case 0x51A08: - return 26; - case 0x51908: - return 25; - case 0x51808: - return 24; - case 0x51708: - return 23; - case 0x51608: - return 22; - case 0x51508: - return 21; - case 0x51408: - return 20; - case 0x51308: - return 19; - case 0x51208: - return 18; - case 0x51108: - return 17; - case 0x50F08: - return 16; - case 0x50E08: - return 15; - case 0x50D08: - return 14; - case 0x50C08: - return 13; - case 0x50B08: - return 12; - case 0x50A08: - return 11; - case 0x50908: - return 10; - case 0x50808: - return 9; - case 0x50708: - return 8; - case 0x50608: - return 7; - case 0x50508: - return 6; - case 0x50408: - return 5; - case 0x50308: - return 4; - case 0x50208: - return 3; - case 0x50108: - return 2; - case 0x50008: - return 1; - default: - return 0; - } -} +static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini"); +static int IncreaseSine = GetPrivateProfileInt(TEXT("Settings"), TEXT("IncreaseSine"), 0, settingsFilename); void InitialD7::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { - int ffrubbingwalls = 0; - int ffcarcollision = 0; + DWORD FFB = GetTeknoParrotFFB(); + + BYTE* ffb = reinterpret_cast(&FFB); + + if (EnableDamper) + triggers->Damper(DamperStrength / 100.0); + + if (ffb[2] == 0x00 && ffb[0] == 0x01) { - helpers->log("in ID7 Ffbloop"); - const int ff = GetTeknoParrotFFB(); - std::string ffs = std::to_string(ff); - helpers->log((char*)ffs.c_str()); - ffcarcollision = carscollide(ff); - ffrubbingwalls = rubbingwalls(ff); + triggers->Spring(1.0); + } - if (EnableDamper == 1) + if (ffb[2] == 0x05 && ffb[1] > 0x00 && ffb[0] > 0x00) + { + double percentForce = ffb[0] / 127.0; + + if (IncreaseSine) { - triggers->Damper(DamperStrength / 100.0); + percentForce = percentForce * 2.0; + + if (percentForce > 1.0) + percentForce = 1.0; } - if (ff == 0x60000) + double Period = ffb[1] / 127.0 * 120.0; + double percentLength = 100; + triggers->Rumble(percentForce, percentForce, percentLength); + triggers->Sine(static_cast(Period), 0, percentForce); + } + + if (ffb[2] == 0x06 && ffb[0] > 0x00 && ffb[0] < 0x80) + { + double percentForce = ffb[0] / 127.0; + double percentLength = 100; + triggers->Spring(percentForce); + } + + if (ffb[2] == 0x04 && ffb[0] > 0x00 && ffb[0] < 0x80) + { + if (ffb[1] == 0x00) { - triggers->Spring(0.8); - } - if (ffrubbingwalls > 0) // car rubbing against wall - { - double percentLength = 200; - double percentForce = (ffrubbingwalls / 31.0); - triggers->Friction(percentForce); - triggers->Rumble(percentForce, percentForce, percentLength); - } - if (ffcarcollision > 0) //cars colliding or rubbing with each other - { - double percentLength = 200; - double percentForce = (ffcarcollision / 16.0); - triggers->Friction(percentForce); - triggers->Rumble(percentForce, percentForce, percentLength); - } - if ((ff > 0x40037) && (ff < 0x40080)) - { - double percentForce = (262272 - ff) / 72.0; + double percentForce = (128 - ffb[0]) / 127.0; double percentLength = 100; triggers->Rumble(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } - else if ((ff > 0x40100) && (ff < 0x40149)) + else { - double percentForce = (ff - 262400) / 72.0; + double percentForce = (ffb[0] / 127.0); double percentLength = 100; triggers->Rumble(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); diff --git a/Game Files/InitialD8.cpp b/Game Files/InitialD8.cpp index 34ff814..39d51d3 100644 --- a/Game Files/InitialD8.cpp +++ b/Game Files/InitialD8.cpp @@ -17,159 +17,60 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. extern int EnableDamper; extern int DamperStrength; -static int carscollide(int ffcollide) { - switch (ffcollide) { - case 0x50F05: - return 16; - case 0x50E05: - return 15; - case 0x50D05: - return 14; - case 0x50C05: - return 13; - case 0x50B05: - return 12; - case 0x50A05: - return 11; - case 0x50905: - return 10; - case 0x50805: - return 9; - case 0x50705: - return 8; - case 0x50605: - return 7; - case 0x050505: - return 6; - case 0x050405: - return 5; - case 0x050305: - return 4; - case 0x50205: - return 3; - case 0x50105: - return 2; - case 0x50005: - return 1; - default: - return 0; - } -} - -static int rubbingwalls(int ffwalls) { - switch (ffwalls) { - case 0x51F08: - return 31; - case 0x51E08: - return 30; - case 0x51D08: - return 29; - case 0x51C08: - return 28; - case 0x51B08: - return 27; - case 0x51A08: - return 26; - case 0x51908: - return 25; - case 0x51808: - return 24; - case 0x51708: - return 23; - case 0x51608: - return 22; - case 0x51508: - return 21; - case 0x51408: - return 20; - case 0x51308: - return 19; - case 0x51208: - return 18; - case 0x51108: - return 17; - case 0x50F08: - return 16; - case 0x50E08: - return 15; - case 0x50D08: - return 14; - case 0x50C08: - return 13; - case 0x50B08: - return 12; - case 0x50A08: - return 11; - case 0x50908: - return 10; - case 0x50808: - return 9; - case 0x50708: - return 8; - case 0x50608: - return 7; - case 0x50508: - return 6; - case 0x50408: - return 5; - case 0x50308: - return 4; - case 0x50208: - return 3; - case 0x50108: - return 2; - case 0x50008: - return 1; - default: - return 0; - } -} +static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini"); +static int IncreaseSine = GetPrivateProfileInt(TEXT("Settings"), TEXT("IncreaseSine"), 0, settingsFilename); void InitialD8::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { - int ffrubbingwalls = 0; - int ffcarcollision = 0; + DWORD FFB = GetTeknoParrotFFB(); + + BYTE* ffb = reinterpret_cast(&FFB); + + if (EnableDamper) + triggers->Damper(DamperStrength / 100.0); + + if (ffb[2] == 0x00 && ffb[0] == 0x01) { - helpers->log("in ID8 Ffbloop"); - const int ff = GetTeknoParrotFFB(); - std::string ffs = std::to_string(ff); - helpers->log((char*)ffs.c_str()); - ffcarcollision = carscollide(ff); - ffrubbingwalls = rubbingwalls(ff); + triggers->Spring(1.0); + } - if (EnableDamper == 1) + if (ffb[2] == 0x05 && ffb[1] > 0x00 && ffb[0] > 0x00) + { + double percentForce = ffb[0] / 127.0; + + if (IncreaseSine) { - triggers->Damper(DamperStrength / 100.0); + percentForce = percentForce * 2.0; + + if (percentForce > 1.0) + percentForce = 1.0; } - if (ff == 0x60000) + double Period = ffb[1] / 127.0 * 120.0; + double percentLength = 100; + triggers->Rumble(percentForce, percentForce, percentLength); + triggers->Sine(static_cast(Period), 0, percentForce); + } + + if (ffb[2] == 0x06 && ffb[0] > 0x00 && ffb[0] < 0x80) + { + double percentForce = ffb[0] / 127.0; + double percentLength = 100; + triggers->Spring(percentForce); + } + + if (ffb[2] == 0x04 && ffb[0] > 0x00 && ffb[0] < 0x80) + { + if (ffb[1] == 0x00) { - triggers->Spring(0.8); - } - if (ffrubbingwalls > 0) // car rubbing against wall - { - double percentLength = 200; - double percentForce = (ffrubbingwalls / 31.0); - triggers->Friction(percentForce); - triggers->Rumble(percentForce, percentForce, percentLength); - } - if (ffcarcollision > 0) //cars colliding or rubbing with each other - { - double percentLength = 200; - double percentForce = (ffcarcollision / 16.0); - triggers->Friction(percentForce); - triggers->Rumble(percentForce, percentForce, percentLength); - } - if ((ff > 0x40037) && (ff < 0x40080)) - { - double percentForce = (262272 - ff) / 72.0; + double percentForce = (128 - ffb[0]) / 127.0; double percentLength = 100; triggers->Rumble(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } - else if ((ff > 0x40100) && (ff < 0x40149)) + else { - double percentForce = (ff - 262400) / 72.0; + double percentForce = (ffb[0] / 127.0); double percentLength = 100; triggers->Rumble(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); diff --git a/Game Files/KODrive.cpp b/Game Files/KODrive.cpp index 9d9c753..ece916f 100644 --- a/Game Files/KODrive.cpp +++ b/Game Files/KODrive.cpp @@ -17,41 +17,63 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. extern int EnableDamper; extern int DamperStrength; +static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini"); +static int IncreaseSine = GetPrivateProfileInt(TEXT("Settings"), TEXT("IncreaseSine"), 0, settingsFilename); + void KODrive::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { - UINT8 ff = helpers->ReadByte(0x00B261F6, /* isRelativeOffset */ false); - UINT8 ff1 = helpers->ReadByte(0x00B261F5, /* isRelativeOffset */ false); - helpers->log("got value: "); - std::string ffs = std::to_string(ff); - helpers->log((char*)ffs.c_str()); - if (EnableDamper == 1) - { + if (EnableDamper) triggers->Damper(DamperStrength / 100.0); + + DWORD FFB = helpers->ReadInt32(0x7261F4, true); + + BYTE* ffb = reinterpret_cast(&FFB); + + if (ffb[0] == 0x80 && ffb[2] == 0x01) + { + triggers->Spring(1.0); } - if ((ff == 10) & (ff1 == 30)) + if (ffb[0] == 0x85 && ffb[1] > 0x00 && ffb[2] > 0x00) { - double percentForce = 0.4; - double percentForce1 = 2.7; + double percentForce = ffb[2] / 24.0; + + if (IncreaseSine) + { + percentForce = percentForce * 2.0; + + if (percentForce > 1.0) + percentForce = 1.0; + } + + double Period = ffb[1] / 128.0 * 120.0; double percentLength = 100; - triggers->Rumble(percentForce1, percentForce1, percentLength); - triggers->Sine(80, 80, percentForce); + triggers->Rumble(percentForce, percentForce, percentLength); + triggers->Sine(static_cast(Period), 0, percentForce); } - if ((ff > 0x66)& (ff < 0x80)& (ff1 == 0)) + if (ffb[0] == 0x86 && ffb[2] > 0x00) { - helpers->log("moving wheel right"); - double percentForce = (128 - ff) / 24.0; + double percentForce = ffb[2] / 24.0; double percentLength = 100; - triggers->Rumble(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + triggers->Spring(percentForce); } - else if ((ff > 0x00)& (ff < 0x19)& (ff1 == 1)) + + if (ffb[0] == 0x84 && ffb[2] > 0x00) { - helpers->log("moving wheel left"); - double percentForce = (ff) / 24.0; - double percentLength = 100; - triggers->Rumble(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + if (ffb[1] == 0x00) + { + double percentForce = (128 - ffb[2]) / 24.0; + double percentLength = 100; + triggers->Rumble(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + } + else + { + double percentForce = (ffb[2] / 24.0); + double percentLength = 100; + triggers->Rumble(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + } } } \ No newline at end of file diff --git a/Game Files/M2Emulator.cpp b/Game Files/M2Emulator.cpp index 6c9f4a5..3d50ea8 100644 --- a/Game Files/M2Emulator.cpp +++ b/Game Files/M2Emulator.cpp @@ -627,7 +627,7 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x6384, 0x06, /* isRelativeOffset*/ false); helpers->WriteByte(Rambase1 + 0x6684, 0x07, /* isRelativeOffset*/ false); } - if ((gamestate == 0x16) & (countdown == 0x00) & (track == 0x00)) + if ((gamestate == 0x16) && (countdown == 0x00) && (track == 0x00)) { Sleep(150); helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 @@ -637,7 +637,7 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x40000, 0x01, /* isRelativeOffset*/ false); // change back to 1 helpers->WriteByte(Rambase1 + 0x1850, 0x01, /* isRelativeOffset*/ false); } - else if ((gamestate == 0x14) & (trackselect == 0x00) & (track == 0x02 || track == 0x01)) + else if ((gamestate == 0x14) && (trackselect == 0x00) && (track == 0x02 || track == 0x01)) { helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 Sleep(50); @@ -649,19 +649,19 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT } else if (linkID == 0x01) { - if ((gamestate == 0x1A) & (gamestatetimer < 100)) + if ((gamestate == 0x1A) && (gamestatetimer < 100)) { helpers->WriteByte(0xC2130, 0x88, /* isRelativeOffset*/ true); helpers->WriteByte(0xC2131, 0x14, /* isRelativeOffset*/ true); helpers->WriteByte(0xC2132, 0x01, /* isRelativeOffset*/ true); } - else if ((gamestate == 0x1A) & (gamestatetimer > 100)) + else if ((gamestate == 0x1A) && (gamestatetimer > 100)) { Sleep(100); helpers->WriteNop(0xC2130, 3, true); } - if ((gamestate > 0x1A)& (gamestate < 0x1A)) + if ((gamestate > 0x1A) && (gamestate < 0x1A)) { helpers->WriteByte(0xC2130, 0x88, /* isRelativeOffset*/ true); helpers->WriteByte(0xC2131, 0x14, /* isRelativeOffset*/ true); @@ -681,11 +681,11 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x6384, 0x06, /* isRelativeOffset*/ false); helpers->WriteByte(Rambase1 + 0x6684, 0x07, /* isRelativeOffset*/ false); } - if ((gamestatetimer > 4294964133)& (gamestate == 0x12)) + if ((gamestatetimer > 4294964133) && (gamestate == 0x12)) { helpers->WriteIntPtr(Rambase1 + 0x10A8, 0x3B6, /* isRelativeOffset*/ false); } - if ((gamestate == 0x16) & (countdown == 0x00) & (track == 0x00)) + if ((gamestate == 0x16) && (countdown == 0x00) && (track == 0x00)) { helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 Sleep(50); @@ -694,7 +694,7 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x40000, 0x01, /* isRelativeOffset*/ false); // change back to 1 helpers->WriteByte(Rambase1 + 0x1850, 0x01, /* isRelativeOffset*/ false); } - else if ((gamestate == 0x14) & (trackselect == 0x00) & (track == 0x02 || track == 0x01)) + else if ((gamestate == 0x14) && (trackselect == 0x00) && (track == 0x02 || track == 0x01)) { helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 Sleep(50); @@ -724,7 +724,7 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x6384, 0x06, /* isRelativeOffset*/ false); helpers->WriteByte(Rambase1 + 0x6684, 0x07, /* isRelativeOffset*/ false); } - if ((gamestate == 0x16) & (countdown == 0x00) & (track == 0x00)) + if ((gamestate == 0x16) && (countdown == 0x00) && (track == 0x00)) { Sleep(250); helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 @@ -734,7 +734,7 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x40000, 0x01, /* isRelativeOffset*/ false); // change back to 1 helpers->WriteByte(Rambase1 + 0x1850, 0x01, /* isRelativeOffset*/ false); } - else if ((gamestate == 0x14) & (trackselect == 0x00) & (track == 0x02 || track == 0x01)) + else if ((gamestate == 0x14) && (trackselect == 0x00) && (track == 0x02 || track == 0x01)) { helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 Sleep(50); @@ -744,26 +744,26 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x1468, 0x01, /* isRelativeOffset*/ false); helpers->WriteFloat32(Rambase1 + 0x519C, 450.0, /* isRelativeOffset */ false); } - if ((gamestatetimer > 4294964133)& (gamestate == 0x12)) + if ((gamestatetimer > 4294964133) && (gamestate == 0x12)) { helpers->WriteIntPtr(Rambase1 + 0x10A8, 0x3B6, /* isRelativeOffset*/ false); } } else if (linkID == 0x02) { - if ((gamestate == 0x1A) & (gamestatetimer < 100)) + if ((gamestate == 0x1A) && (gamestatetimer < 100)) { helpers->WriteByte(0xC2130, 0x88, /* isRelativeOffset*/ true); helpers->WriteByte(0xC2131, 0x14, /* isRelativeOffset*/ true); helpers->WriteByte(0xC2132, 0x01, /* isRelativeOffset*/ true); } - else if ((gamestate == 0x1A) & (gamestatetimer > 100)) + else if ((gamestate == 0x1A) && (gamestatetimer > 100)) { Sleep(100); helpers->WriteNop(0xC2130, 3, true); } - if ((gamestate > 0x1A)& (gamestate < 0x1A)) + if ((gamestate > 0x1A) && (gamestate < 0x1A)) { helpers->WriteByte(0xC2130, 0x88, /* isRelativeOffset*/ true); helpers->WriteByte(0xC2131, 0x14, /* isRelativeOffset*/ true); @@ -782,7 +782,7 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x6384, 0x06, /* isRelativeOffset*/ false); helpers->WriteByte(Rambase1 + 0x6684, 0x07, /* isRelativeOffset*/ false); } - if ((gamestate == 0x16) & (countdown == 0x00) & (track == 0x00)) + if ((gamestate == 0x16) && (countdown == 0x00) && (track == 0x00)) { Sleep(150); helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 @@ -792,7 +792,7 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x40000, 0x01, /* isRelativeOffset*/ false); // change back to 1 helpers->WriteByte(Rambase1 + 0x1850, 0x01, /* isRelativeOffset*/ false); } - else if ((gamestate == 0x14) & (trackselect == 0x00) & (track == 0x02 || track == 0x01)) + else if ((gamestate == 0x14) && (trackselect == 0x00) && (track == 0x02 || track == 0x01)) { helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 Sleep(50); @@ -801,26 +801,26 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x40000, 0x01, /* isRelativeOffset*/ false); // change back to 1 helpers->WriteByte(Rambase1 + 0x1468, 0x01, /* isRelativeOffset*/ false); } - if ((gamestatetimer > 4294964133)& (gamestate == 0x12)) + if ((gamestatetimer > 4294964133) && (gamestate == 0x12)) { helpers->WriteIntPtr(Rambase1 + 0x10A8, 0x3B6, /* isRelativeOffset*/ false); } } else if (linkID == 0x01) { - if ((gamestate == 0x1A) & (gamestatetimer < 100)) + if ((gamestate == 0x1A) && (gamestatetimer < 100)) { helpers->WriteByte(0xC2130, 0x88, /* isRelativeOffset*/ true); helpers->WriteByte(0xC2131, 0x14, /* isRelativeOffset*/ true); helpers->WriteByte(0xC2132, 0x01, /* isRelativeOffset*/ true); } - else if ((gamestate == 0x1A) & (gamestatetimer > 100)) + else if ((gamestate == 0x1A) && (gamestatetimer > 100)) { Sleep(100); helpers->WriteNop(0xC2130, 3, true); } - if ((gamestate > 0x1A)& (gamestate < 0x1A)) + if ((gamestate > 0x1A) && (gamestate < 0x1A)) { helpers->WriteByte(0xC2130, 0x88, /* isRelativeOffset*/ true); helpers->WriteByte(0xC2131, 0x14, /* isRelativeOffset*/ true); @@ -840,11 +840,11 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x6384, 0x06, /* isRelativeOffset*/ false); helpers->WriteByte(Rambase1 + 0x6684, 0x07, /* isRelativeOffset*/ false); } - if ((gamestatetimer > 4294964133)& (gamestate == 0x12)) + if ((gamestatetimer > 4294964133) && (gamestate == 0x12)) { helpers->WriteIntPtr(Rambase1 + 0x10A8, 0x3B6, /* isRelativeOffset*/ false); } - if ((gamestate == 0x16) & (countdown == 0x00) & (track == 0x00)) + if ((gamestate == 0x16) && (countdown == 0x00) && (track == 0x00)) { helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 Sleep(50); @@ -853,7 +853,7 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x40000, 0x01, /* isRelativeOffset*/ false); // change back to 1 helpers->WriteByte(Rambase1 + 0x1850, 0x01, /* isRelativeOffset*/ false); } - else if ((gamestate == 0x14) & (trackselect == 0x00) & (track == 0x01)) + else if ((gamestate == 0x14) && (trackselect == 0x00) && (track == 0x01)) { helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 Sleep(50); @@ -864,7 +864,7 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteIntPtr(Rambase1 + 0x51A4, 0xC2F195E8, /* isRelativeOffset */ false); helpers->WriteByte(Rambase1 + 0x1468, 0x01, /* isRelativeOffset*/ false); } - else if ((gamestate == 0x14) & (trackselect == 0x00) & (track == 0x02)) + else if ((gamestate == 0x14) && (trackselect == 0x00) && (track == 0x02)) { helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 Sleep(50); @@ -894,7 +894,7 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x6384, 0x06, /* isRelativeOffset*/ false); helpers->WriteByte(Rambase1 + 0x6684, 0x07, /* isRelativeOffset*/ false); } - if ((gamestate == 0x16) & (countdown == 0x00) & (track == 0x00)) + if ((gamestate == 0x16) && (countdown == 0x00) && (track == 0x00)) { Sleep(250); helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 @@ -904,7 +904,7 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x40000, 0x01, /* isRelativeOffset*/ false); // change back to 1 helpers->WriteByte(Rambase1 + 0x1850, 0x01, /* isRelativeOffset*/ false); } - else if ((gamestate == 0x14) & (trackselect == 0x00) & (track == 0x01)) + else if ((gamestate == 0x14) && (trackselect == 0x00) && (track == 0x01)) { helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 Sleep(50); @@ -915,7 +915,7 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteIntPtr(Rambase1 + 0x51A4, 0xC302CAF4, /* isRelativeOffset */ false); helpers->WriteByte(Rambase1 + 0x1468, 0x01, /* isRelativeOffset*/ false); } - else if ((gamestate == 0x14) & (trackselect == 0x00) & (track == 0x02)) + else if ((gamestate == 0x14) && (trackselect == 0x00) && (track == 0x02)) { helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 Sleep(50); @@ -927,26 +927,26 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteIntPtr(Rambase1 + 0x51A4, 0xC37C0001, /* isRelativeOffset */ false); helpers->WriteByte(Rambase1 + 0x1468, 0x01, /* isRelativeOffset*/ false); } - if ((gamestatetimer > 4294964133)& (gamestate == 0x12)) + if ((gamestatetimer > 4294964133) && (gamestate == 0x12)) { helpers->WriteIntPtr(Rambase1 + 0x10A8, 0x3B6, /* isRelativeOffset*/ false); } } if (linkID == 0x03) { - if ((gamestate == 0x1A) & (gamestatetimer < 100)) + if ((gamestate == 0x1A) && (gamestatetimer < 100)) { helpers->WriteByte(0xC2130, 0x88, /* isRelativeOffset*/ true); helpers->WriteByte(0xC2131, 0x14, /* isRelativeOffset*/ true); helpers->WriteByte(0xC2132, 0x01, /* isRelativeOffset*/ true); } - else if ((gamestate == 0x1A) & (gamestatetimer > 100)) + else if ((gamestate == 0x1A) && (gamestatetimer > 100)) { Sleep(100); helpers->WriteNop(0xC2130, 3, true); } - if ((gamestate > 0x1A)& (gamestate < 0x1A)) + if ((gamestate > 0x1A) && (gamestate < 0x1A)) { helpers->WriteByte(0xC2130, 0x88, /* isRelativeOffset*/ true); helpers->WriteByte(0xC2131, 0x14, /* isRelativeOffset*/ true); @@ -966,7 +966,7 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x6384, 0x06, /* isRelativeOffset*/ false); helpers->WriteByte(Rambase1 + 0x6684, 0x07, /* isRelativeOffset*/ false); } - if ((gamestate == 0x16) & (countdown == 0x00) & (track == 0x00)) + if ((gamestate == 0x16) && (countdown == 0x00) && (track == 0x00)) { Sleep(350); helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 @@ -976,7 +976,7 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x40000, 0x01, /* isRelativeOffset*/ false); // change back to 1 helpers->WriteByte(Rambase1 + 0x1850, 0x01, /* isRelativeOffset*/ false); } - else if ((gamestate == 0x14) & (trackselect == 0x00) & (track == 0x02)) + else if ((gamestate == 0x14) && (trackselect == 0x00) && (track == 0x02)) { helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 Sleep(50); @@ -988,7 +988,7 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT Sleep(50); helpers->WriteIntPtr(Rambase1 + 0x51A4, 0xC37CF3D0, /* isRelativeOffset */ false); } - else if ((gamestate == 0x14) & (trackselect == 0x00) & (track == 0x01)) + else if ((gamestate == 0x14) && (trackselect == 0x00) && (track == 0x01)) { helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 Sleep(50); @@ -998,26 +998,26 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x1468, 0x01, /* isRelativeOffset*/ false); helpers->WriteFloat32(Rambase1 + 0x519C, 450.0, /* isRelativeOffset */ false); } - if ((gamestatetimer > 4294964133)& (gamestate == 0x12)) + if ((gamestatetimer > 4294964133) && (gamestate == 0x12)) { helpers->WriteIntPtr(Rambase1 + 0x10A8, 0x3B6, /* isRelativeOffset*/ false); } } else if (linkID == 0x02) { - if ((gamestate == 0x1A) & (gamestatetimer < 100)) + if ((gamestate == 0x1A) && (gamestatetimer < 100)) { helpers->WriteByte(0xC2130, 0x88, /* isRelativeOffset*/ true); helpers->WriteByte(0xC2131, 0x14, /* isRelativeOffset*/ true); helpers->WriteByte(0xC2132, 0x01, /* isRelativeOffset*/ true); } - else if ((gamestate == 0x1A) & (gamestatetimer > 100)) + else if ((gamestate == 0x1A) && (gamestatetimer > 100)) { Sleep(100); helpers->WriteNop(0xC2130, 3, true); } - if ((gamestate > 0x1A)& (gamestate < 0x1A)) + if ((gamestate > 0x1A) && (gamestate < 0x1A)) { helpers->WriteByte(0xC2130, 0x88, /* isRelativeOffset*/ true); helpers->WriteByte(0xC2131, 0x14, /* isRelativeOffset*/ true); @@ -1036,7 +1036,7 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x6384, 0x06, /* isRelativeOffset*/ false); helpers->WriteByte(Rambase1 + 0x6684, 0x07, /* isRelativeOffset*/ false); } - if ((gamestate == 0x16) & (countdown == 0x00) & (track == 0x00)) + if ((gamestate == 0x16) && (countdown == 0x00) && (track == 0x00)) { Sleep(150); helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 @@ -1046,7 +1046,7 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x40000, 0x01, /* isRelativeOffset*/ false); // change back to 1 helpers->WriteByte(Rambase1 + 0x1850, 0x01, /* isRelativeOffset*/ false); } - else if ((gamestate == 0x14) & (trackselect == 0x00) & (track == 0x02 || track == 0x01)) + else if ((gamestate == 0x14) && (trackselect == 0x00) && (track == 0x02 || track == 0x01)) { helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 Sleep(50); @@ -1055,26 +1055,26 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x40000, 0x01, /* isRelativeOffset*/ false); // change back to 1 helpers->WriteByte(Rambase1 + 0x1468, 0x01, /* isRelativeOffset*/ false); } - if ((gamestatetimer > 4294964133)& (gamestate == 0x12)) + if ((gamestatetimer > 4294964133) && (gamestate == 0x12)) { helpers->WriteIntPtr(Rambase1 + 0x10A8, 0x3B6, /* isRelativeOffset*/ false); } } else if (linkID == 0x01) { - if ((gamestate == 0x1A) & (gamestatetimer < 100)) + if ((gamestate == 0x1A) && (gamestatetimer < 100)) { helpers->WriteByte(0xC2130, 0x88, /* isRelativeOffset*/ true); helpers->WriteByte(0xC2131, 0x14, /* isRelativeOffset*/ true); helpers->WriteByte(0xC2132, 0x01, /* isRelativeOffset*/ true); } - else if ((gamestate == 0x1A) & (gamestatetimer > 100)) + else if ((gamestate == 0x1A) && (gamestatetimer > 100)) { Sleep(100); helpers->WriteNop(0xC2130, 3, true); } - if ((gamestate > 0x1A)& (gamestate < 0x1A)) + if ((gamestate > 0x1A) && (gamestate < 0x1A)) { helpers->WriteByte(0xC2130, 0x88, /* isRelativeOffset*/ true); helpers->WriteByte(0xC2131, 0x14, /* isRelativeOffset*/ true); @@ -1094,11 +1094,11 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x6384, 0x06, /* isRelativeOffset*/ false); helpers->WriteByte(Rambase1 + 0x6684, 0x07, /* isRelativeOffset*/ false); } - if ((gamestatetimer > 4294964133)& (gamestate == 0x12)) + if ((gamestatetimer > 4294964133) && (gamestate == 0x12)) { helpers->WriteIntPtr(Rambase1 + 0x10A8, 0x3B6, /* isRelativeOffset*/ false); } - if ((gamestate == 0x16) & (countdown == 0x00) & (track == 0x00)) + if ((gamestate == 0x16) && (countdown == 0x00) && (track == 0x00)) { helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 Sleep(50); @@ -1107,7 +1107,7 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteByte(Rambase1 + 0x40000, 0x01, /* isRelativeOffset*/ false); // change back to 1 helpers->WriteByte(Rambase1 + 0x1850, 0x01, /* isRelativeOffset*/ false); } - else if ((gamestate == 0x14) & (trackselect == 0x00) & (track == 0x01)) + else if ((gamestate == 0x14) && (trackselect == 0x00) && (track == 0x01)) { helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 Sleep(50); @@ -1118,7 +1118,7 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->WriteIntPtr(Rambase1 + 0x51A4, 0xC2F195E8, /* isRelativeOffset */ false); helpers->WriteByte(Rambase1 + 0x1468, 0x01, /* isRelativeOffset*/ false); } - else if ((gamestate == 0x14) & (trackselect == 0x00) & (track == 0x02)) + else if ((gamestate == 0x14) && (trackselect == 0x00) && (track == 0x02)) { helpers->WriteByte(Rambase1 + 0x40000, 0x99, /* isRelativeOffset*/ false); // change to 99 Sleep(50); diff --git a/Game Files/M2EmulatorDaytonaInputs.cpp b/Game Files/M2EmulatorDaytonaInputs.cpp index eaff21b..ab8352a 100644 --- a/Game Files/M2EmulatorDaytonaInputs.cpp +++ b/Game Files/M2EmulatorDaytonaInputs.cpp @@ -258,7 +258,7 @@ void M2EmulatorDaytonaUSAInputsEnabled(Helpers* helpers) INT_PTR Rambase1 = helpers->ReadIntPtr(Rambase + 0x100, false); GearValue = helpers->ReadByte(Rambase1 + 0x52CC, false); - if ((e.type == SDL_JOYAXISMOTION) & (ShowAxisForSetup == 0)) + if ((e.type == SDL_JOYAXISMOTION) && (ShowAxisForSetup == 0)) { if (e.jaxis.which == joystick_index1) { @@ -348,7 +348,7 @@ void M2EmulatorDaytonaUSAInputsEnabled(Helpers* helpers) e.jaxis.value = e.jaxis.value + ACCL_DEAD_ZONE; BrakeValue = (-e.jaxis.value + ACCL_DEAD_ZONE) / 128; } - else if ((e.jaxis.value < ACCL_DEAD_ZONE) & (e.jaxis.value > -ACCL_DEAD_ZONE)) + else if ((e.jaxis.value < ACCL_DEAD_ZONE) && (e.jaxis.value > -ACCL_DEAD_ZONE)) { AcclValue = 0xFF; BrakeValue = 0xFF; @@ -477,7 +477,7 @@ void M2EmulatorDaytonaUSAInputsEnabled(Helpers* helpers) e.jaxis.value = e.jaxis.value + ACCL_DEAD_ZONE; BrakeValue = (-e.jaxis.value + ACCL_DEAD_ZONE) / 128; } - else if ((e.jaxis.value < ACCL_DEAD_ZONE) & (e.jaxis.value > -ACCL_DEAD_ZONE)) + else if ((e.jaxis.value < ACCL_DEAD_ZONE) && (e.jaxis.value > -ACCL_DEAD_ZONE)) { AcclValue = 0xFF; BrakeValue = 0xFF; diff --git a/Game Files/M2EmulatorIndy500Inputs.cpp b/Game Files/M2EmulatorIndy500Inputs.cpp index 6fcdfae..70ede4b 100644 --- a/Game Files/M2EmulatorIndy500Inputs.cpp +++ b/Game Files/M2EmulatorIndy500Inputs.cpp @@ -221,7 +221,7 @@ void M2EmulatorIndy500InputsEnabled(Helpers* helpers) UINT8 button1read = helpers->ReadByte(Button1Address, false); UINT8 button2read = helpers->ReadByte(Button2Address, false); - if ((e.type == SDL_JOYAXISMOTION) & (ShowAxisForSetup == 0)) + if ((e.type == SDL_JOYAXISMOTION) && (ShowAxisForSetup == 0)) { if (e.jaxis.which == joystick_index1) { @@ -311,7 +311,7 @@ void M2EmulatorIndy500InputsEnabled(Helpers* helpers) e.jaxis.value = e.jaxis.value + ACCL_DEAD_ZONE; BrakeValue = (-e.jaxis.value + ACCL_DEAD_ZONE) / 128; } - else if ((e.jaxis.value < ACCL_DEAD_ZONE) & (e.jaxis.value > -ACCL_DEAD_ZONE)) + else if ((e.jaxis.value < ACCL_DEAD_ZONE) && (e.jaxis.value > -ACCL_DEAD_ZONE)) { AcclValue = 0xFF; BrakeValue = 0xFF; @@ -440,7 +440,7 @@ void M2EmulatorIndy500InputsEnabled(Helpers* helpers) e.jaxis.value = e.jaxis.value + ACCL_DEAD_ZONE; BrakeValue = (-e.jaxis.value + ACCL_DEAD_ZONE) / 128; } - else if ((e.jaxis.value < ACCL_DEAD_ZONE) & (e.jaxis.value > -ACCL_DEAD_ZONE)) + else if ((e.jaxis.value < ACCL_DEAD_ZONE) && (e.jaxis.value > -ACCL_DEAD_ZONE)) { AcclValue = 0xFF; BrakeValue = 0xFF; diff --git a/Game Files/M2EmulatorSegaRallyInputs.cpp b/Game Files/M2EmulatorSegaRallyInputs.cpp index f240547..c459fdb 100644 --- a/Game Files/M2EmulatorSegaRallyInputs.cpp +++ b/Game Files/M2EmulatorSegaRallyInputs.cpp @@ -239,7 +239,7 @@ void M2EmulatorSegaRallyInputsEnabled(Helpers* helpers) UINT8 button1read = helpers->ReadByte(Button1Address, false); UINT8 button2read = helpers->ReadByte(Button2Address, false); - if ((e.type == SDL_JOYAXISMOTION) & (ShowAxisForSetup == 0)) + if ((e.type == SDL_JOYAXISMOTION) && (ShowAxisForSetup == 0)) { if (e.jaxis.which == joystick_index1) { @@ -329,7 +329,7 @@ void M2EmulatorSegaRallyInputsEnabled(Helpers* helpers) e.jaxis.value = e.jaxis.value + ACCL_DEAD_ZONE; BrakeValue = (-e.jaxis.value + ACCL_DEAD_ZONE) / 128; } - else if ((e.jaxis.value < ACCL_DEAD_ZONE) & (e.jaxis.value > -ACCL_DEAD_ZONE)) + else if ((e.jaxis.value < ACCL_DEAD_ZONE) && (e.jaxis.value > -ACCL_DEAD_ZONE)) { AcclValue = 0xFF; BrakeValue = 0xFF; @@ -459,7 +459,7 @@ void M2EmulatorSegaRallyInputsEnabled(Helpers* helpers) e.jaxis.value = e.jaxis.value + ACCL_DEAD_ZONE; BrakeValue = (-e.jaxis.value + ACCL_DEAD_ZONE) / 128; } - else if ((e.jaxis.value < ACCL_DEAD_ZONE) & (e.jaxis.value > -ACCL_DEAD_ZONE)) + else if ((e.jaxis.value < ACCL_DEAD_ZONE) && (e.jaxis.value > -ACCL_DEAD_ZONE)) { AcclValue = 0xFF; BrakeValue = 0xFF; diff --git a/Game Files/MAMESupermodel.cpp b/Game Files/MAMESupermodel.cpp index 98b6057..136637e 100644 --- a/Game Files/MAMESupermodel.cpp +++ b/Game Files/MAMESupermodel.cpp @@ -221,11 +221,15 @@ std::string victlap("victlap"); std::string dblaxle("dblaxle"); std::string dblaxleu("dblaxleu"); //Flycast Below -std::string INITIAL("INITIAL"); -std::string EIGHTEENWHEELER("18WHEELER\n"); -std::string MAXIMUM("MAXIMUM"); -std::string FASTER("FASTER"); -std::string F355("F355"); +std::string InitialDVer1("INITIAL D\n"); +std::string InitialDVer2("INITIAL D Ver.2\n"); +std::string InitialDVer3("INITIAL D Ver.3\n"); +std::string EighteenWheeler("18WHEELER\n"); +std::string MaximumSPEED("MAXIMUM SPEED\n"); +std::string FasterThanSPEED("FASTER THAN SPEED\n"); +std::string F355ChallengeJapan("F355 CHALLENGE JAPAN\n"); +std::string ClubKartInJapan("CLUB KART IN JAPAN\n"); +std::string TheKingOfRoute66("THE KING OF ROUTE66\n"); //Our string to load game from std::string M2Active("M2Active"); @@ -341,6 +345,8 @@ extern int ForceSpringStrength; extern int EnableDamper; extern int DamperStrength; +static bool IncreaseSine; + static int configMinForceDaytona2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("MinForceDaytona2"), 0, settingsFilename); static int configMaxForceDaytona2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("MaxForceDaytona2"), 100, settingsFilename); static int configAlternativeMinForceLeftDaytona2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("AlternativeMinForceLeftDaytona2"), 0, settingsFilename); @@ -960,6 +966,7 @@ static int EnableForceSpringEffectInitialD = GetPrivateProfileInt(TEXT("Settings static int ForceSpringStrengthInitialD = GetPrivateProfileInt(TEXT("Settings"), TEXT("ForceSpringStrengthInitialD"), 0, settingsFilename); static int EnableDamperInitialD = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableDamperInitialD"), 0, settingsFilename); static int DamperStrengthInitialD = GetPrivateProfileInt(TEXT("Settings"), TEXT("DamperStrengthInitialD"), 100, settingsFilename); +static int IncreaseSineInitialD = GetPrivateProfileInt(TEXT("Settings"), TEXT("IncreaseSineInitialD"), 0, settingsFilename); static int configMinForceF355 = GetPrivateProfileInt(TEXT("Settings"), TEXT("MinForceF355"), 0, settingsFilename); static int configMaxForceF355 = GetPrivateProfileInt(TEXT("Settings"), TEXT("MaxForceF355"), 100, settingsFilename); @@ -1013,6 +1020,34 @@ static int ForceSpringStrengthMaximumSpeed = GetPrivateProfileInt(TEXT("Settings static int EnableDamperMaximumSpeed = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableDamperMaximumSpeed"), 0, settingsFilename); static int DamperStrengthMaximumSpeed = GetPrivateProfileInt(TEXT("Settings"), TEXT("DamperStrengthMaximumSpeed"), 100, settingsFilename); +static int configMinForceClubKart = GetPrivateProfileInt(TEXT("Settings"), TEXT("MinForceClubKart"), 0, settingsFilename); +static int configMaxForceClubKart = GetPrivateProfileInt(TEXT("Settings"), TEXT("MaxForceClubKart"), 100, settingsFilename); +static int configAlternativeMinForceLeftClubKart = GetPrivateProfileInt(TEXT("Settings"), TEXT("AlternativeMinForceLeftClubKart"), 0, settingsFilename); +static int configAlternativeMaxForceLeftClubKart = GetPrivateProfileInt(TEXT("Settings"), TEXT("AlternativeMaxForceLeftClubKart"), 100, settingsFilename); +static int configAlternativeMinForceRightClubKart = GetPrivateProfileInt(TEXT("Settings"), TEXT("AlternativeMinForceRightClubKart"), 0, settingsFilename); +static int configAlternativeMaxForceRightClubKart = GetPrivateProfileInt(TEXT("Settings"), TEXT("AlternativeMaxForceRightClubKart"), 100, settingsFilename); +static int configFeedbackLengthClubKart = GetPrivateProfileInt(TEXT("Settings"), TEXT("FeedbackLengthClubKart"), 120, settingsFilename); +static int PowerModeClubKart = GetPrivateProfileInt(TEXT("Settings"), TEXT("PowerModeClubKart"), 0, settingsFilename); +static int EnableForceSpringEffectClubKart = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableForceSpringEffectClubKart"), 0, settingsFilename); +static int ForceSpringStrengthClubKart = GetPrivateProfileInt(TEXT("Settings"), TEXT("ForceSpringStrengthClubKart"), 0, settingsFilename); +static int EnableDamperClubKart = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableDamperClubKart"), 0, settingsFilename); +static int DamperStrengthClubKart = GetPrivateProfileInt(TEXT("Settings"), TEXT("DamperStrengthClubKart"), 100, settingsFilename); +static int IncreaseSineClubKart = GetPrivateProfileInt(TEXT("Settings"), TEXT("IncreaseSineClubKart"), 0, settingsFilename); + +static int configMinForceKingOfRoute66 = GetPrivateProfileInt(TEXT("Settings"), TEXT("MinForceKingOfRoute66"), 0, settingsFilename); +static int configMaxForceKingOfRoute66 = GetPrivateProfileInt(TEXT("Settings"), TEXT("MaxForceKingOfRoute66"), 100, settingsFilename); +static int configAlternativeMinForceLeftKingOfRoute66 = GetPrivateProfileInt(TEXT("Settings"), TEXT("AlternativeMinForceLeftKingOfRoute66"), 0, settingsFilename); +static int configAlternativeMaxForceLeftKingOfRoute66 = GetPrivateProfileInt(TEXT("Settings"), TEXT("AlternativeMaxForceLeftKingOfRoute66"), 100, settingsFilename); +static int configAlternativeMinForceRightKingOfRoute66 = GetPrivateProfileInt(TEXT("Settings"), TEXT("AlternativeMinForceRightKingOfRoute66"), 0, settingsFilename); +static int configAlternativeMaxForceRightKingOfRoute66 = GetPrivateProfileInt(TEXT("Settings"), TEXT("AlternativeMaxForceRightKingOfRoute66"), 100, settingsFilename); +static int configFeedbackLengthKingOfRoute66 = GetPrivateProfileInt(TEXT("Settings"), TEXT("FeedbackLengthKingOfRoute66"), 120, settingsFilename); +static int PowerModeKingOfRoute66 = GetPrivateProfileInt(TEXT("Settings"), TEXT("PowerModeKingOfRoute66"), 0, settingsFilename); +static int EnableForceSpringEffectKingOfRoute66 = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableForceSpringEffectKingOfRoute66"), 0, settingsFilename); +static int ForceSpringStrengthKingOfRoute66 = GetPrivateProfileInt(TEXT("Settings"), TEXT("ForceSpringStrengthKingOfRoute66"), 0, settingsFilename); +static int EnableDamperKingOfRoute66 = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableDamperKingOfRoute66"), 0, settingsFilename); +static int DamperStrengthKingOfRoute66 = GetPrivateProfileInt(TEXT("Settings"), TEXT("DamperStrengthKingOfRoute66"), 100, settingsFilename); +static int IncreaseSineKingOfRoute66 = GetPrivateProfileInt(TEXT("Settings"), TEXT("IncreaseSineKingOfRoute66"), 0, settingsFilename); + static bool init = false; static bool initSpring = false; static bool EmuName = false; @@ -1273,6 +1308,47 @@ int __stdcall mame_stop(void) return 1; } +static void removeWord(char* str, char* toRemove) +{ + int i, j, stringLen, toRemoveLen; + int found; + + stringLen = strlen(str); + toRemoveLen = strlen(toRemove); + + + for (i = 0; i <= stringLen - toRemoveLen; i++) + { + found = 1; + for (j = 0; j < toRemoveLen; j++) + { + if (str[i + j] != toRemove[j]) + { + found = 0; + break; + } + } + + if (str[i + j] != ' ' && str[i + j] != '\t' && str[i + j] != '\n' && str[i + j] != '\0') + { + found = 0; + } + + + if (found == 1) + { + for (j = i; j <= stringLen - toRemoveLen; j++) + { + str[j] = str[j + toRemoveLen]; + } + + stringLen = stringLen - toRemoveLen; + + i--; + } + } +} + static void CurrentGameName(Helpers* helpers) { helpers->info("Game = %s", GameName); @@ -1286,8 +1362,30 @@ int __stdcall mame_copydata(int id, const char* name) if (id == 0) { - //romFFB = name; - sprintf(GameName, "%s", name); + char RomName[256]; + sprintf(RomName, "%s", name); + + removeWord(RomName, "game ="); + + int whitespace = 0; + + for (int i = 0; i < strlen(RomName); i++) + { + if (RomName[i] == ' ' || RomName[i] == '\t') + whitespace++; + else + break; + } + + for (int i = 0; i < strlen(RomName); i++) + { + if (i + whitespace < strlen(RomName)) + RomName[i] = RomName[i + whitespace]; + else + RomName[i] = 0; + } + + sprintf(GameName, "%s", RomName); CurrentGameName(0); } @@ -2727,7 +2825,7 @@ void MAMESupermodel::FFBLoop(EffectConstants* constants, Helpers* helpers, Effec RunningFFB = "NamcoFFBActive"; } - if (romname == INITIAL) + if (romname == InitialDVer1 || romname == InitialDVer2 || romname == InitialDVer3) { configMinForce = configMinForceInitialD; configMaxForce = configMaxForceInitialD; @@ -2741,11 +2839,50 @@ void MAMESupermodel::FFBLoop(EffectConstants* constants, Helpers* helpers, Effec DamperStrength = DamperStrengthInitialD; EnableForceSpringEffect = EnableForceSpringEffectInitialD; ForceSpringStrength = ForceSpringStrengthInitialD; + IncreaseSine = IncreaseSineInitialD; RunningFFB = "InitialDActive"; } - if (romname == MAXIMUM) + if (romname == TheKingOfRoute66) + { + configMinForce = configMinForceKingOfRoute66; + configMaxForce = configMaxForceKingOfRoute66; + configAlternativeMinForceLeft = configAlternativeMinForceLeftKingOfRoute66; + configAlternativeMaxForceLeft = configAlternativeMaxForceLeftKingOfRoute66; + configAlternativeMinForceRight = configAlternativeMinForceRightKingOfRoute66; + configAlternativeMaxForceRight = configAlternativeMaxForceRightKingOfRoute66; + configFeedbackLength = configFeedbackLengthKingOfRoute66; + PowerMode = PowerModeKingOfRoute66; + EnableDamper = EnableDamperKingOfRoute66; + DamperStrength = DamperStrengthKingOfRoute66; + EnableForceSpringEffect = EnableForceSpringEffectKingOfRoute66; + ForceSpringStrength = ForceSpringStrengthKingOfRoute66; + IncreaseSine = IncreaseSineKingOfRoute66; + + RunningFFB = "InitialDActive"; + } + + if (romname == ClubKartInJapan) + { + configMinForce = configMinForceClubKart; + configMaxForce = configMaxForceClubKart; + configAlternativeMinForceLeft = configAlternativeMinForceLeftClubKart; + configAlternativeMaxForceLeft = configAlternativeMaxForceLeftClubKart; + configAlternativeMinForceRight = configAlternativeMinForceRightClubKart; + configAlternativeMaxForceRight = configAlternativeMaxForceRightClubKart; + configFeedbackLength = configFeedbackLengthClubKart; + PowerMode = PowerModeClubKart; + EnableDamper = EnableDamperClubKart; + DamperStrength = DamperStrengthClubKart; + EnableForceSpringEffect = EnableForceSpringEffectClubKart; + ForceSpringStrength = ForceSpringStrengthClubKart; + IncreaseSine = IncreaseSineClubKart; + + RunningFFB = "InitialDActive"; + } + + if (romname == MaximumSPEED) { configMinForce = configMinForceMaximumSpeed; configMaxForce = configMaxForceMaximumSpeed; @@ -2763,7 +2900,7 @@ void MAMESupermodel::FFBLoop(EffectConstants* constants, Helpers* helpers, Effec RunningFFB = "MaximumSpeedActive"; } - if (romname == FASTER) + if (romname == FasterThanSPEED) { configMinForce = configMinForceFasterThanSpeed; configMaxForce = configMaxForceFasterThanSpeed; @@ -2781,7 +2918,7 @@ void MAMESupermodel::FFBLoop(EffectConstants* constants, Helpers* helpers, Effec RunningFFB = "MaximumSpeedActive"; } - if (romname == F355) + if (romname == F355ChallengeJapan) { configMinForce = configMinForceF355; configMaxForce = configMaxForceF355; @@ -2800,7 +2937,7 @@ void MAMESupermodel::FFBLoop(EffectConstants* constants, Helpers* helpers, Effec NaomiFFBGo = true; } - if (romname == EIGHTEENWHEELER) + if (romname == EighteenWheeler) { configMinForce = configMinForce18Wheeler; configMaxForce = configMaxForce18Wheeler; @@ -3816,39 +3953,52 @@ void MAMESupermodel::FFBLoop(EffectConstants* constants, Helpers* helpers, Effec BYTE* ffb = reinterpret_cast(&stateFFB); - if ((ffb[2] == 0x80) && (ffb[0] == 0x01)) + if (ffb[2] == 0x80 && ffb[0] == 0x01) { triggers->Spring(1.0); } - if ((ffb[2] == 0x85) && (ffb[1] == 0x3F) && (ffb[0] > 0x00) && (ffb[0] < 0x30)) + if (ffb[2] == 0x85 && ffb[1] > 0x00 && ffb[0] > 0x00) { - double percentForce = ffb[0] / 47.0; + double percentForce = ffb[0] / 127.0; + + if (IncreaseSine) + { + percentForce = percentForce * 2.0; + + if (percentForce > 1.0) + percentForce = 1.0; + } + + double Period = ffb[1] / 127.0 * 120.0; double percentLength = 100; triggers->Rumble(percentForce, percentForce, percentLength); - triggers->Sine(40, 0, percentForce); - } + triggers->Sine(static_cast(Period), 0, percentForce); + } - if ((ffb[2] == 0x86) && (ffb[1] == 0x02) && (ffb[0] > 0x09) && (ffb[0] < 0x3C)) + if (ffb[2] == 0x86 && ffb[0] > 0x00 && ffb[0] < 0x80) { - double percentForce = (60 - ffb[0]) / 43.0; + double percentForce = ffb[0] / 127.0; double percentLength = 100; triggers->Spring(percentForce); } - if ((ffb[2] == 0x84) && (ffb[1] == 0x00) && (ffb[0] > 0x37) && (ffb[0] < 0x80)) + if (ffb[2] == 0x84 && ffb[0] > 0x00 && ffb[0] < 0x80) { - double percentForce = (128 - ffb[0]) / 72.0; - double percentLength = 100; - triggers->Rumble(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((ffb[2] == 0x84) && (ffb[1] == 0x01) && (ffb[0] > 0x00) && (ffb[0] < 0x49)) - { - double percentForce = (ffb[0] / 72.0); - double percentLength = 100; - triggers->Rumble(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + if (ffb[1] == 0x00) + { + double percentForce = (128 - ffb[0]) / 127.0; + double percentLength = 100; + triggers->Rumble(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + } + else + { + double percentForce = (ffb[0] / 127.0); + double percentLength = 100; + triggers->Rumble(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + } } } } diff --git a/Game Files/MarioKartGPDX.cpp b/Game Files/MarioKartGPDX.cpp index 4e27a11..e51e495 100644 --- a/Game Files/MarioKartGPDX.cpp +++ b/Game Files/MarioKartGPDX.cpp @@ -41,7 +41,7 @@ void MarioKartGPDX100::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff } // Large Shake when hitting walls, other karts or getting hit by items - if ((4194308 == ff1) & (ff10 == 1)) + if ((4194308 == ff1) && (ff10 == 1)) { double percentForce = 1.0; double percentForce1 = 3.5; @@ -51,7 +51,7 @@ void MarioKartGPDX100::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff } // small friction when driving on dirt while moving - if ((3 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216)) + if ((3 == ff3) && (ff10 == 1) && (ff5 == 1) && (ff11 == 1065353216)) { double percentForce = (0.3); double percentLength = (100); @@ -59,7 +59,7 @@ void MarioKartGPDX100::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Friction(percentForce); } // Small constant when hitting bumps - if ((10 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216)) + if ((10 == ff3) && (ff10 == 1) && (ff5 == 1) && (ff11 == 1065353216)) { double percentForce = (0.2); double percentLength = (50); @@ -68,7 +68,7 @@ void MarioKartGPDX100::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); } // Wheel rumbles while driving on grass - if ((4 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216)) + if ((4 == ff3) && (ff10 == 1) && (ff5 == 1) && (ff11 == 1065353216)) { double percentForce = 0.2; double percentLength = (50); @@ -76,13 +76,13 @@ void MarioKartGPDX100::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Sine(50, 50, percentForce); } //wheel hard to turn while driving through water - if ((7 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216)) + if ((7 == ff3) && (ff10 == 1) && (ff5 == 1) && (ff11 == 1065353216)) { double percentForce = (0.65); triggers->Friction(percentForce); } //Wheel rumbles lightly when driving over tiles - if ((12 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216)) + if ((12 == ff3) && (ff10 == 1) && (ff5 == 1) && (ff11 == 1065353216)) { double percentForce = 0.1; double percentForce1 = 0.2; @@ -91,7 +91,7 @@ void MarioKartGPDX100::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Sine(70, 70, percentForce); } //Wheel rumbles lightly when driving over sand - if ((14 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216)) + if ((14 == ff3) && (ff10 == 1) && (ff5 == 1) && (ff11 == 1065353216)) { double percentForce = 0.1; double percentForce1 = 0.2; @@ -100,7 +100,7 @@ void MarioKartGPDX100::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Sine(70, 70, percentForce); } //Wheel rumbles lightly when driving over rough part of track - if ((11 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216)) + if ((11 == ff3) && (ff10 == 1) && (ff5 == 1) && (ff11 == 1065353216)) { double percentForce = 0.1; double percentForce1 = 0.2; @@ -109,7 +109,7 @@ void MarioKartGPDX100::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Sine(40, 50, percentForce); } //Wheel rumbles moderately when driving over wooden bridges - if ((8 == ff3) & (ff10 == 1) & (ff5 == 1) & (ff11 == 1065353216)) + if ((8 == ff3) && (ff10 == 1) && (ff5 == 1) && (ff11 == 1065353216)) { double percentForce = 0.4; double percentLength = (100); diff --git a/Game Files/MarioKartGPDX1.10.cpp b/Game Files/MarioKartGPDX1.10.cpp index 60605c7..c7ee06e 100644 --- a/Game Files/MarioKartGPDX1.10.cpp +++ b/Game Files/MarioKartGPDX1.10.cpp @@ -89,14 +89,14 @@ void MarioKartGPDX110::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff if ((ConstantEffectForSteering == 1) && (ff11 == 1)) { - if ((Wheel >= 0) & (Wheel < 128)) + if ((Wheel >= 0) && (Wheel < 128)) { double percentForce = ((128 - Wheel) / (ConstantEffectForSteeringStrength / 1.0)); double percentLength = 100; triggers->Rumble(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } - else if ((Wheel > 127) & (Wheel < 256)) + else if ((Wheel > 127) && (Wheel < 256)) { double percentForce = ((Wheel - 127) / (ConstantEffectForSteeringStrength / 1.0)); double percentLength = 100; @@ -104,7 +104,7 @@ void MarioKartGPDX110::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); } } - if ((MainShakeRumble == 1) & (4194308 == ff1) & (ff11 == 1)) + if ((MainShakeRumble == 1) && (4194308 == ff1) && (ff11 == 1)) { // Large Shake when hitting walls, other karts or getting hit by items double percentForce = ((MainShakeRumbleStrength) / 100.0); @@ -113,7 +113,7 @@ void MarioKartGPDX110::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Sine(200, 200, percentForce); } - if ((BoostRumble == 1) & (ff18 == 1) & (ff11 == 1)) + if ((BoostRumble == 1) && (ff18 == 1) && (ff11 == 1)) { // Shake when Boost double percentForce = ((BoostRumbleStrength) / 100.0); @@ -122,7 +122,7 @@ void MarioKartGPDX110::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Sine(60, 60, percentForce); } - if ((DriftRumble == 1) & (ff17 == 1) & (Wheel >= 0) & (Wheel < 128) & (ff11 == 1)) + if ((DriftRumble == 1) && (ff17 == 1) && (Wheel >= 0) && (Wheel < 128) && (ff11 == 1)) { // Drift Effect including steering left double percentForce = (((128 - Wheel) / 128.0) * (DriftRumbleControllerStrengthMultiplier / 100.0)); @@ -131,7 +131,7 @@ void MarioKartGPDX110::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Friction(percentForce); } - if ((DriftRumble == 1) & (ff17 == 1) & (Wheel > 127) & (Wheel < 256) & (ff11 == 1)) + if ((DriftRumble == 1) && (ff17 == 1) && (Wheel > 127) && (Wheel < 256) && (ff11 == 1)) { // Drift Effect including steering right double percentForce = (((Wheel - 127) / 128.0) * (DriftRumbleControllerStrengthMultiplier / 100.0)); @@ -140,7 +140,7 @@ void MarioKartGPDX110::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Friction(percentForce); } - if ((HitGroundRumble == 1) & (oldhitground != newhitground) & (ff5 == 1) & (ff11 == 1)) + if ((HitGroundRumble == 1) && (oldhitground != newhitground) && (ff5 == 1) && (ff11 == 1)) { // Shake when hitting ground double percentForce = ((HitGroundRumbleStrength) / 100.0); @@ -151,7 +151,7 @@ void MarioKartGPDX110::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); } - if ((WeaponRumble == 1) & (oldweapon != newweapon) & (ff11 == 1)) + if ((WeaponRumble == 1) && (oldweapon != newweapon) && (ff11 == 1)) { // Shake when picking up new weapons or using them double percentForce = ((WeaponRumbleStrength) / 100.0); @@ -160,7 +160,7 @@ void MarioKartGPDX110::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Sine(80, 50, percentForce); } - if ((CoinRumble == 1) & (oldcoins != newcoins) & (ff11 == 1)) + if ((CoinRumble == 1) && (oldcoins != newcoins) && (ff11 == 1)) { // Shake when picking up coins double percentForce = ((CoinRumbleStrength) / 100.0); @@ -169,7 +169,7 @@ void MarioKartGPDX110::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Sine(50, 50, percentForce); } - if ((DirtRumble == 1) & (3 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1)) + if ((DirtRumble == 1) && (3 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1)) { // small friction when driving on dirt while moving double percentForce = ((DirtRumbleStrength) / 100.0); @@ -178,7 +178,7 @@ void MarioKartGPDX110::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Friction(percentForce); } - if ((SpeedBumpRumble == 1) & (10 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1)) + if ((SpeedBumpRumble == 1) && (10 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1)) { // Small constant when hitting bumps double percentForce = ((SpeedBumpRumbleStrength) / 100.0); @@ -188,7 +188,7 @@ void MarioKartGPDX110::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Constant(constants->DIRECTION_FROM_RIGHT, 0); } - if ((GrassRumble == 1) & (4 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1)) + if ((GrassRumble == 1) && (4 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1)) { // Wheel rumbles while driving on grass double percentForce = ((GrassRumbleStrength) / 100.0); @@ -197,7 +197,7 @@ void MarioKartGPDX110::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Sine(50, 50, percentForce); } - if ((CarpetRumble == 1) & (9 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1)) + if ((CarpetRumble == 1) && (9 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1)) { // Wheel rumbles while driving on carpet double percentForce = ((CarpetRumbleStrength) / 100.0); @@ -206,7 +206,7 @@ void MarioKartGPDX110::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Sine(50, 50, percentForce); } - if ((WaterRumble == 1) & (7 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1) & (Wheel >= 0) & (Wheel < 128)) + if ((WaterRumble == 1) && (7 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1) && (Wheel >= 0) && (Wheel < 128)) { //wheel hard to turn while driving through water double percentForce = ((WaterRumbleWheelStrength) / 100.0); @@ -216,7 +216,7 @@ void MarioKartGPDX110::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Friction(percentForce); } - if ((WaterRumble == 1) & (7 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1) & (Wheel > 127)) + if ((WaterRumble == 1) && (7 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1) && (Wheel > 127)) { double percentForce = ((WaterRumbleWheelStrength) / 100.0); double percentForce1 = ((Wheel - 127 / 128.0) * (WaterRumbleControllerStrengthMultiplier / 100.0)); @@ -225,7 +225,7 @@ void MarioKartGPDX110::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Friction(percentForce); } - if ((TileRumble == 1) & (12 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1)) + if ((TileRumble == 1) && (12 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1)) { //Wheel rumbles lightly when driving over tiles double percentForce = ((TileRumbleStrength) / 100.0); @@ -234,7 +234,7 @@ void MarioKartGPDX110::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Friction(percentForce); } - if ((SandRumble == 1) & (14 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1)) + if ((SandRumble == 1) && (14 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1)) { //Wheel rumbles lightly when driving over sand double percentForce = ((SandRumbleStrength) / 100.0); @@ -243,7 +243,7 @@ void MarioKartGPDX110::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Sine(70, 70, percentForce); } - if ((RoughTrackRumble == 1) & (11 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1)) + if ((RoughTrackRumble == 1) && (11 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1)) { //Wheel rumbles lightly when driving over rough part of track double percentForce = ((RoughTrackRumbleStrength) / 100.0); @@ -252,7 +252,7 @@ void MarioKartGPDX110::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Sine(40, 50, percentForce); } - if ((BridgeRumble == 1) & (8 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1)) + if ((BridgeRumble == 1) && (8 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1)) { //Wheel rumbles moderately when driving over wooden bridges double percentForce = ((BridgeRumbleStrength) / 100.0); diff --git a/Game Files/MarioKartGPDXUSA.cpp b/Game Files/MarioKartGPDXUSA.cpp index c8a18f3..c1c8688 100644 --- a/Game Files/MarioKartGPDXUSA.cpp +++ b/Game Files/MarioKartGPDXUSA.cpp @@ -87,14 +87,14 @@ void MarioKartGPDXUSA::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff if ((ConstantEffectForSteering == 1) && (ff11 == 1)) { - if ((Wheel >= 0) & (Wheel < 128)) + if ((Wheel >= 0) && (Wheel < 128)) { double percentForce = ((128 - Wheel) / (ConstantEffectForSteeringStrength / 1.0)); double percentLength = 100; triggers->LeftRight(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } - else if ((Wheel > 127) & (Wheel < 256)) + else if ((Wheel > 127) && (Wheel < 256)) { double percentForce = ((Wheel - 127) / (ConstantEffectForSteeringStrength / 1.0)); double percentLength = 100; @@ -102,7 +102,7 @@ void MarioKartGPDXUSA::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); } } - if ((MainShakeRumble == 1) & (4194308 == ff1) & (ff11 == 1)) + if ((MainShakeRumble == 1) && (4194308 == ff1) && (ff11 == 1)) { // Large Shake when hitting walls, other karts or getting hit by items double percentForce = ((MainShakeRumbleStrength) / 100.0); @@ -110,7 +110,7 @@ void MarioKartGPDXUSA::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->LeftRight(percentForce, percentForce, percentLength); triggers->Sine(200, 200, percentForce); } - else if ((BoostRumble == 1) & (ff18 == 1) & (ff11 == 1)) + else if ((BoostRumble == 1) && (ff18 == 1) && (ff11 == 1)) { // Shake when Boost double percentForce = ((BoostRumbleStrength) / 100.0); @@ -118,7 +118,7 @@ void MarioKartGPDXUSA::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->LeftRight(percentForce, percentForce, percentLength); triggers->Sine(60, 60, percentForce); } - else if ((DriftRumble == 1) & (ff17 == 1) & (Wheel >= 0) & (Wheel < 128) & (ff11 == 1)) + else if ((DriftRumble == 1) && (ff17 == 1) && (Wheel >= 0) && (Wheel < 128) && (ff11 == 1)) { // Drift Effect including steering left double percentForce = (((128 - Wheel) / 128.0) * (DriftRumbleControllerStrengthMultiplier / 100.0)); @@ -126,7 +126,7 @@ void MarioKartGPDXUSA::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->LeftRight(percentForce, 0, percentLength); triggers->Friction(percentForce); } - else if ((DriftRumble == 1) & (ff17 == 1) & (Wheel > 127) & (Wheel < 256) & (ff11 == 1)) + else if ((DriftRumble == 1) && (ff17 == 1) && (Wheel > 127) && (Wheel < 256) && (ff11 == 1)) { // Drift Effect including steering right double percentForce = (((Wheel - 127) / 128.0) * (DriftRumbleControllerStrengthMultiplier / 100.0)); @@ -134,7 +134,7 @@ void MarioKartGPDXUSA::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->LeftRight(0, percentForce, percentLength); triggers->Friction(percentForce); } - else if ((HitGroundRumble == 1) & (oldhitground != newhitground) & (ff5 == 1) & (ff11 == 1)) + else if ((HitGroundRumble == 1) && (oldhitground != newhitground) && (ff5 == 1) && (ff11 == 1)) { // Shake when hitting ground double percentForce = ((HitGroundRumbleStrength) / 100.0); @@ -144,7 +144,7 @@ void MarioKartGPDXUSA::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff Sleep(50); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); } - else if ((WeaponRumble == 1) & (oldweapon != newweapon) & (ff11 == 1)) + else if ((WeaponRumble == 1) && (oldweapon != newweapon) && (ff11 == 1)) { // Shake when picking up new weapons or using them double percentForce = ((WeaponRumbleStrength) / 100.0); @@ -152,7 +152,7 @@ void MarioKartGPDXUSA::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->LeftRight(percentForce, percentForce, percentLength); triggers->Sine(80, 50, percentForce); } - else if ((CoinRumble == 1) & (oldcoins != newcoins) & (ff11 == 1)) + else if ((CoinRumble == 1) && (oldcoins != newcoins) && (ff11 == 1)) { // Shake when picking up coins double percentForce = ((CoinRumbleStrength) / 100.0); @@ -160,7 +160,7 @@ void MarioKartGPDXUSA::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->LeftRight(percentForce, percentForce, percentLength); triggers->Sine(50, 50, percentForce); } - else if ((DirtRumble == 1) & (3 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1)) + else if ((DirtRumble == 1) && (3 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1)) { // small friction when driving on dirt while moving double percentForce = ((DirtRumbleStrength) / 100.0); @@ -168,7 +168,7 @@ void MarioKartGPDXUSA::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->LeftRight(percentForce, 0, percentLength); triggers->Friction(percentForce); } - else if ((SpeedBumpRumble == 1) & (10 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1)) + else if ((SpeedBumpRumble == 1) && (10 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1)) { // Small constant when hitting bumps double percentForce = ((SpeedBumpRumbleStrength) / 100.0); @@ -177,7 +177,7 @@ void MarioKartGPDXUSA::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); triggers->Constant(constants->DIRECTION_FROM_RIGHT, 0); } - else if ((GrassRumble == 1) & (4 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1)) + else if ((GrassRumble == 1) && (4 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1)) { // Wheel rumbles while driving on grass double percentForce = ((GrassRumbleStrength) / 100.0); @@ -185,7 +185,7 @@ void MarioKartGPDXUSA::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->LeftRight(0, percentForce, percentLength); triggers->Sine(50, 50, percentForce); } - else if ((CarpetRumble == 1) & (9 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1)) + else if ((CarpetRumble == 1) && (9 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1)) { // Wheel rumbles while driving on carpet double percentForce = ((CarpetRumbleStrength) / 100.0); @@ -193,7 +193,7 @@ void MarioKartGPDXUSA::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->LeftRight(0, percentForce, percentLength); triggers->Sine(50, 50, percentForce); } - else if ((WaterRumble == 1) & (7 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1) & (Wheel >= 0) & (Wheel < 128)) + else if ((WaterRumble == 1) && (7 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1) && (Wheel >= 0) && (Wheel < 128)) { //wheel hard to turn while driving through water double percentForce = ((WaterRumbleWheelStrength) / 100.0); @@ -202,7 +202,7 @@ void MarioKartGPDXUSA::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->LeftRight(percentForce1, 0, percentLength); triggers->Friction(percentForce); } - else if ((WaterRumble == 1) & (7 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1) & (Wheel > 127)) + else if ((WaterRumble == 1) && (7 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1) && (Wheel > 127)) { double percentForce = ((WaterRumbleWheelStrength) / 100.0); double percentForce1 = ((Wheel - 127 / 128.0) * (WaterRumbleControllerStrengthMultiplier / 100.0)); @@ -210,7 +210,7 @@ void MarioKartGPDXUSA::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->LeftRight(0, percentForce1, percentLength); triggers->Friction(percentForce); } - else if ((TileRumble == 1) & (12 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1)) + else if ((TileRumble == 1) && (12 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1)) { //Wheel rumbles lightly when driving over tiles double percentForce = ((TileRumbleStrength) / 100.0); @@ -218,7 +218,7 @@ void MarioKartGPDXUSA::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->LeftRight(0, percentForce, percentLength); triggers->Friction(percentForce); } - else if ((SandRumble == 1) & (14 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1)) + else if ((SandRumble == 1) && (14 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1)) { //Wheel rumbles lightly when driving over sand double percentForce = ((SandRumbleStrength) / 100.0); @@ -226,7 +226,7 @@ void MarioKartGPDXUSA::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->LeftRight(percentForce, 0, percentLength); triggers->Sine(70, 70, percentForce); } - else if ((RoughTrackRumble == 1) & (11 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1)) + else if ((RoughTrackRumble == 1) && (11 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1)) { //Wheel rumbles lightly when driving over rough part of track double percentForce = ((RoughTrackRumbleStrength) / 100.0); @@ -234,7 +234,7 @@ void MarioKartGPDXUSA::FFBLoop(EffectConstants *constants, Helpers *helpers, Eff triggers->LeftRight(0, percentForce, percentLength); triggers->Sine(40, 50, percentForce); } - else if ((BridgeRumble == 1) & (8 == ff3) & (ff11 == 1) & (ff5 == 1) & (Speed > 0.1)) + else if ((BridgeRumble == 1) && (8 == ff3) && (ff11 == 1) && (ff5 == 1) && (Speed > 0.1)) { //Wheel rumbles moderately when driving over wooden bridges double percentForce = ((BridgeRumbleStrength) / 100.0); diff --git a/Game Files/OutRun2Fake.cpp b/Game Files/OutRun2Fake.cpp index 209ae04..0eb002d 100644 --- a/Game Files/OutRun2Fake.cpp +++ b/Game Files/OutRun2Fake.cpp @@ -105,14 +105,14 @@ static int ThreadLoop() if (ff8 == 1) { - if ((ff6 >= 0x00) & (ff6 < 0x7F)) + if ((ff6 >= 0x00) && (ff6 < 0x7F)) { double percentForce = ((127 - ff6) / 127.0); double percentLength = 100; myTriggers->Rumble(percentForce, 0, percentLength); myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce); } - if ((ff6 > 0x7F)& (ff6 < 0x100)) + if ((ff6 > 0x7F) && (ff6 < 0x100)) { double percentForce = ((ff6 - 127) / 128.0); double percentLength = 100; @@ -122,14 +122,14 @@ static int ThreadLoop() } if (ff9 == 1) { - if ((ff6 >= 0x00) & (ff6 < 0x7F)) + if ((ff6 >= 0x00) && (ff6 < 0x7F)) { double percentForce = ((127 - ff6) / 127.0); double percentLength = 100; myTriggers->Rumble(percentForce, 0, percentLength); myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce); } - if ((ff6 > 0x7F)& (ff6 < 0x100)) + if ((ff6 > 0x7F) && (ff6 < 0x100)) { double percentForce = ((ff6 - 127) / 128.0); double percentLength = 100; diff --git a/Game Files/SWDC2018.cpp b/Game Files/SWDC2018.cpp index 5b042ba..d84104f 100644 --- a/Game Files/SWDC2018.cpp +++ b/Game Files/SWDC2018.cpp @@ -21,12 +21,11 @@ static bool VersionFound; static bool Version103; static bool Version230; +static DWORD FFB; + static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini"); static int EscapeKeyExitViaPlugin = GetPrivateProfileInt(TEXT("Settings"), TEXT("EscapeKeyExitViaPlugin"), 0, settingsFilename); - -static UINT8 ff1; -static UINT8 ff2; -static UINT8 ff3; +static int IncreaseSine = GetPrivateProfileInt(TEXT("Settings"), TEXT("IncreaseSine"), 0, settingsFilename); static const char* SDDS = "SDDS"; @@ -51,9 +50,7 @@ static void getSDDS230(char* Name) void SWDC::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { if (GetAsyncKeyState((VK_ESCAPE)) && (EscapeKeyExitViaPlugin == 1)) - { ExitProcess(0); - } if (!VersionFound) { @@ -74,80 +71,65 @@ void SWDC::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* else { if (Version103) - { - ff1 = helpers->ReadByte(0x8E5CCF4, true); - ff2 = helpers->ReadByte(0x8E5CCF5, true); - ff3 = helpers->ReadByte(0x8E5CCF6, true); - } - + FFB = helpers->ReadInt32(0x8E5CCF4, true); + if (Version230) - { - ff1 = helpers->ReadByte(0x9BC7B18, true); - ff2 = helpers->ReadByte(0x9BC7B19, true); - ff3 = helpers->ReadByte(0x9BC7B1A, true); - } + FFB = helpers->ReadInt32(0x9BC7B18, true); - if (EnableDamper == 1) - { + if (EnableDamper) triggers->Damper(DamperStrength / 100.0); - } - if (ff1 == 80) + BYTE* ffb = reinterpret_cast(&FFB); + + if (EnableDamper) + triggers->Damper(DamperStrength / 100.0); + + if (ffb[0] == 0x80 && ffb[2] == 0x01) { triggers->Spring(1.0); } - else if (ff1 == 0x85) + + if (ffb[0] == 0x85 && ffb[1] > 0x00 && ffb[2] > 0x00) { - if ((ff2 > 0x00) && (ff2 < 0x30)) + double percentForce = ffb[2] / 127.0; + + if (IncreaseSine) { - double percentForce = ff2 / 47.0; - double percentLength = 100; - triggers->Rumble(percentForce, percentForce, percentLength); - triggers->Sine(40, 0, percentForce); + percentForce = percentForce * 2.0; + + if (percentForce > 1.0) + percentForce = 1.0; } + + double Period = ffb[1] / 127.0 * 120.0; + double percentLength = 100; + triggers->Rumble(percentForce, percentForce, percentLength); + triggers->Sine(static_cast(Period), 0, percentForce); } - else if (ff1 == 0x86) + + if (ffb[0] == 0x86 && ffb[2] > 0x00) { - if ((ff3 > 0x00) && (ff3 < 0x4E)) - { - double percentForce = ff3 / 77.0; - double percentLength = 100; - triggers->Spring(percentForce); - } + double percentForce = ffb[2] / 127.0; + double percentLength = 100; + triggers->Spring(percentForce); } - else if (ff1 == 0x84) + + if (ffb[0] == 0x84 && ffb[2] > 0x00) { - if ((ff2 == 0x00) && (ff3 > 0x37) && (ff3 < 0x80)) + if (ffb[1] == 0x00) { - double percentForce = (128 - ff3) / 72.0; + double percentForce = (128 - ffb[0]) / 127.0; double percentLength = 100; triggers->Rumble(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } - else if ((ff2 == 0x01) && (ff3 > 0x00) && (ff3 < 0x49)) + else { - double percentForce = (ff3 / 72.0); + double percentForce = (ffb[0] / 127.0); double percentLength = 100; triggers->Rumble(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); } - else - { - if ((ff2 == 0x00) && (ff3 > 0x00) && (ff3 < 0x38)) - { - double percentForce = 1.0; - double percentLength = 100; - triggers->Rumble(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((ff2 == 0x01) && (ff3 > 0x48)) - { - double percentForce = 1.0; - double percentLength = 100; - triggers->Rumble(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - } } - } + } } \ No newline at end of file diff --git a/Game Files/SegaRacingClassic.cpp b/Game Files/SegaRacingClassic.cpp index 507ce02..f720fb9 100644 --- a/Game Files/SegaRacingClassic.cpp +++ b/Game Files/SegaRacingClassic.cpp @@ -35,6 +35,7 @@ void SegaRacingClassic::FFBLoop(EffectConstants* constants, Helpers* helpers, Ef double percentLength = 100; triggers->Friction(percentForce); } + if ((ff > 0xBF) && (ff < 0xC8)) { //Centering @@ -42,6 +43,7 @@ void SegaRacingClassic::FFBLoop(EffectConstants* constants, Helpers* helpers, Ef double percentLength = 100; triggers->Spring(pow(percentForce, 0.1)); } + if ((ff > 0xB7) && (ff < 0xC0)) { //Uncentering @@ -50,6 +52,7 @@ void SegaRacingClassic::FFBLoop(EffectConstants* constants, Helpers* helpers, Ef triggers->Rumble(percentForce, percentForce, percentLength); triggers->Sine(70, 80, percentForce); } + if ((ff > 0xA7) && (ff < 0xB0)) { //Roll Left @@ -58,6 +61,7 @@ void SegaRacingClassic::FFBLoop(EffectConstants* constants, Helpers* helpers, Ef triggers->Rumble(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); } + if ((ff > 0x97) && (ff < 0xA0)) { //Roll Right