From 329b3333d2fd4f5fdebd4b5d49eaeb3879dae79e Mon Sep 17 00:00:00 2001 From: Boomslangnz Date: Sat, 11 Mar 2023 20:12:38 +1300 Subject: [PATCH] Sonic All Stars Changes --- Config/FFBPlugin.ini | 4 +- Game Files/SegaRally3.cpp | 4 +- Game Files/SonicSegaAllStarsRacing.cpp | 54 +++++++++++++++++--------- 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/Config/FFBPlugin.ini b/Config/FFBPlugin.ini index 5b11032..e2e0c4e 100644 --- a/Config/FFBPlugin.ini +++ b/Config/FFBPlugin.ini @@ -817,8 +817,10 @@ DamperStrength=100 [Sonic & Sega All Stars Racing] GameId=21 FeedbackLength=80 -EnableDamper=1 +EnableDamper=0 DamperStrength=100 +SpringEnable=1 +SpringStrength=100 [GTI Club Supermini Festa] GameId=27 diff --git a/Game Files/SegaRally3.cpp b/Game Files/SegaRally3.cpp index 3b79af9..f7938c9 100644 --- a/Game Files/SegaRally3.cpp +++ b/Game Files/SegaRally3.cpp @@ -23,10 +23,8 @@ void SegaRally3::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTri std::string ffs = std::to_string(ff); helpers->log((char*)ffs.c_str()); - if (EnableDamper == 1) - { + if (EnableDamper) triggers->Damper(DamperStrength / 100.0); - } if (ff > 15) { diff --git a/Game Files/SonicSegaAllStarsRacing.cpp b/Game Files/SonicSegaAllStarsRacing.cpp index fa36eb4..a839a4a 100644 --- a/Game Files/SonicSegaAllStarsRacing.cpp +++ b/Game Files/SonicSegaAllStarsRacing.cpp @@ -16,32 +16,48 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. extern int EnableDamper; extern int DamperStrength; +static UINT8 OLDFFB; + +static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini"); +static int SpringEnable = GetPrivateProfileInt(TEXT("Settings"), TEXT("SpringEnable"), 0, settingsFilename); +static int SpringStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("SpringStrength"), 0, settingsFilename); + void SonicSegaAllStarsRacing::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) { - INT_PTR FFBEnable = helpers->ReadByte(0x5CD858, true); - INT_PTR FFB = helpers->ReadByte(0x5CD864, true); + UINT8 FFB = helpers->ReadByte(0x5CD864, true); helpers->WriteByte(0x5CD858, 0x03, true); - if (EnableDamper == 1) - { + if (EnableDamper) triggers->Damper(DamperStrength / 100.0); - } - if ((FFB > 0) && (FFB < 19)) + if (SpringEnable) + triggers->Springi(SpringStrength / 100.0); + + if (OLDFFB != FFB) { - helpers->log("moving wheel left"); - double percentForce = FFB / 18.0; - double percentLength = 100; - triggers->Rumble(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((FFB > 237) && (FFB < 256)) - { - helpers->log("moving wheel right"); - double percentForce = (256 - FFB) / 18.0; - double percentLength = 100; - triggers->Rumble(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + if (FFB > 0 && FFB < 19) + { + helpers->log("moving wheel left"); + double percentForce = FFB / 18.0; + double percentLength = 100; + triggers->Rumble(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + } + else if (FFB > 237 && FFB < 256) + { + helpers->log("moving wheel right"); + double percentForce = (256 - FFB) / 18.0; + double percentLength = 100; + triggers->Rumble(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + } + else + { + triggers->Rumble(0, 0, 80); + triggers->Constant(constants->DIRECTION_FROM_LEFT, 0); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, 0); + } } + OLDFFB = FFB; }