From 06d837af24af1938c93bd250b6e56f0744b2b6bc Mon Sep 17 00:00:00 2001 From: Aaron M Date: Sat, 17 Apr 2021 10:31:12 +1200 Subject: [PATCH] Storm Racer G --- AutoSetup.cmd | 3 + Common Files/TeknoParrotGame.cpp | 53 ++++++++-- Common Files/TeknoParrotGame.h | 6 +- Config/FFBPlugin.ini | 24 +++++ Dinput8Wrapper.vcxproj | 2 + Dinput8Wrapper.vcxproj.filters | 4 + DllMain.cpp | 7 +- Game Files/StormRacerG.cpp | 161 +++++++++++++++++++++++++++++++ Game Files/StormRacerG.h | 21 ++++ Includes/FFBPluginReadme.txt | 6 +- 10 files changed, 275 insertions(+), 12 deletions(-) create mode 100644 Game Files/StormRacerG.cpp create mode 100644 Game Files/StormRacerG.h diff --git a/AutoSetup.cmd b/AutoSetup.cmd index 2bacd8d..ee58cbb 100644 --- a/AutoSetup.cmd +++ b/AutoSetup.cmd @@ -88,6 +88,9 @@ cd.. cd "Sonic & Sega All Stars Racing" rename dinput8.dll d3d9.dll cd.. +cd "Storm Racer G" +rename dinput8.dll xinput1_3.dll +cd.. cd Supermodel 32bit Outputs rename dinput8.dll opengl32.dll cd.. diff --git a/Common Files/TeknoParrotGame.cpp b/Common Files/TeknoParrotGame.cpp index 365ae09..4558055 100644 --- a/Common Files/TeknoParrotGame.cpp +++ b/Common Files/TeknoParrotGame.cpp @@ -4,23 +4,54 @@ static int configGameId = GetPrivateProfileInt(TEXT("Settings"), TEXT("GameId"), TeknoParrotGame::TeknoParrotGame() { + secData = 0; hSection = CreateFileMapping(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, 64, L"TeknoParrot_JvsState"); + if (hSection) secData = MapViewOfFile(hSection, FILE_MAP_ALL_ACCESS, 0, 0, 64); - if (configGameId == 19) + if (secData) { - ffbOffset = *((int*)secData + 6); - ffbOffset2 = *((int*)secData + 7); + if (*((int*)secData + 2) > 0) + { + *((int*)secData + 2) = 0; + } + + if (*((int*)secData + 6) > 0) + { + *((int*)secData + 6) = 0; + } + + if (*((int*)secData + 7) > 0) + { + *((int*)secData + 7) = 0; + } + + if (*((int*)secData + 8) > 0) + { + *((int*)secData + 8) = 0; + } + + if (configGameId == 54) + { + ffbOffset = *((int*)secData + 6); + ffbOffset2 = *((int*)secData + 7); + ffbOffset3 = *((int*)secData + 8); + } + else if (configGameId == 19) + { + ffbOffset = *((int*)secData + 6); + ffbOffset2 = *((int*)secData + 7); + } + else + { + ffbOffset = *((int*)secData + 2); + } } - else - { - ffbOffset = *((int*)secData + 2); - } } int TeknoParrotGame::GetTeknoParrotFFB() { - if (configGameId == 19) + if (configGameId == 19 || configGameId == 54) { ffbOffset = *((int*)secData + 6); } @@ -38,6 +69,12 @@ int TeknoParrotGame::GetTeknoParrotFFB2() return ffbOffset2; } +int TeknoParrotGame::GetTeknoParrotFFB3() +{ + ffbOffset3 = *((int*)secData + 8); + return ffbOffset3; +} + void TeknoParrotGame::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) { helpers->log("TeknoParrot game not implemented"); } \ No newline at end of file diff --git a/Common Files/TeknoParrotGame.h b/Common Files/TeknoParrotGame.h index d729f4e..3134662 100644 --- a/Common Files/TeknoParrotGame.h +++ b/Common Files/TeknoParrotGame.h @@ -6,12 +6,14 @@ class TeknoParrotGame : public Game { // TP-related HANDLE hSection; LPVOID secData; - int ffbOffset = 0; - int ffbOffset2 = 0; protected: + int ffbOffset = 0; + int ffbOffset2 = 0; + int ffbOffset3 = 0; int GetTeknoParrotFFB(); int GetTeknoParrotFFB2(); + int GetTeknoParrotFFB3(); TeknoParrotGame(); public: diff --git a/Config/FFBPlugin.ini b/Config/FFBPlugin.ini index bb5fea6..0fb697e 100644 --- a/Config/FFBPlugin.ini +++ b/Config/FFBPlugin.ini @@ -174,6 +174,30 @@ HowtoRumbleKnockEffect=0 HowtoRumbleMotorEffect=0 HowtoRumbleHealthEffect=0 +[Storm Racer G] +GameId=54 +FeedbackLength=500 +EnableDamper=0 +DamperStrength=100 +EnableShakeEffectsWhileRacing = 1; +EnableShakeEffectsinMenu = 1; +EnableGroundEffects = 1; +EnableForceSpringEffect = 0; +ForceSpringStrength = 100; +MinFFBConstantStrength=100 +FFBShakeSineStrength = 30 +FFBShakeSinePeriod = 75; +FFBShakeFadeSinePeriod = 0; +FFBGrassSineStrength=40 +FFBGrassSinePeriod = 40; +FFBGrassFadeSinePeriod = 0; +FFBRoughTerrainSineStrength=45 +FFBRoughTerrainSinePeriod = 120; +FFBRoughTerrainFadeSinePeriod = 0; +FFBRumbleStripSineStrength=55 +FFBRumbleStripSinePeriod = 30; +FFBRumbleStripFadeSinePeriod = 0; + [Dirty Drivin'] GameId=42 FeedbackLength=500 diff --git a/Dinput8Wrapper.vcxproj b/Dinput8Wrapper.vcxproj index 338655d..8f404b2 100644 --- a/Dinput8Wrapper.vcxproj +++ b/Dinput8Wrapper.vcxproj @@ -49,6 +49,7 @@ + @@ -106,6 +107,7 @@ + diff --git a/Dinput8Wrapper.vcxproj.filters b/Dinput8Wrapper.vcxproj.filters index 88424b2..a7b7ee1 100644 --- a/Dinput8Wrapper.vcxproj.filters +++ b/Dinput8Wrapper.vcxproj.filters @@ -136,6 +136,7 @@ + @@ -313,6 +314,9 @@ Common Header Files + + Common Header Files + diff --git a/DllMain.cpp b/DllMain.cpp index 1439c1d..cffe541 100644 --- a/DllMain.cpp +++ b/DllMain.cpp @@ -81,6 +81,7 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. #include "Game Files/SWDC2018.h" #include "Game Files/Transformers.h" #include "Game Files/H2Overdrive.h" +#include "Game Files/StormRacerG.h" // typedefs typedef unsigned char U8; @@ -1013,6 +1014,7 @@ const int SWDC_2018 = 50; const int MARIO_KART_GPDX_USA = 51; const int WMMT_6 = 52; const int WMMT_6_R = 53; +const int SRG = 54; HINSTANCE Get_hInstance() { @@ -2243,7 +2245,7 @@ DWORD WINAPI FFBLoop(LPVOID lpParam) { hlp.log("In FFBLoop"); - if ((configGameId != 22) && (configGameId != 29) && (configGameId != 34)) //For games which need code to run quicker etc. Some games will crash if no sleep added + if (configGameId != 22 && configGameId != 29 && configGameId != 34) //For games which need code to run quicker etc. Some games will crash if no sleep added { Sleep(2500); } @@ -2450,6 +2452,9 @@ DWORD WINAPI FFBLoop(LPVOID lpParam) case WMMT_6_R: game = new WMMT6R; break; + case SRG: + game = new StormRacerG; + break; case TEST_GAME_CONST: case TEST_GAME_FRICTION: case TEST_GAME_SINE: diff --git a/Game Files/StormRacerG.cpp b/Game Files/StormRacerG.cpp new file mode 100644 index 0000000..9aa37a9 --- /dev/null +++ b/Game Files/StormRacerG.cpp @@ -0,0 +1,161 @@ +/*This file is part of FFB Arcade Plugin. +FFB Arcade Plugin is free software : you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. +FFB Arcade Plugin is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the +GNU General Public License for more details. +You should have received a copy of the GNU General Public License +along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. +*/ + +#include +#include "StormRacerG.h" + +extern int EnableDamper; +extern int DamperStrength; + +static wchar_t* settingsFilename = TEXT(".\\FFBPlugin.ini"); +static int EnableShakeEffectsWhileRacing = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableShakeEffectsWhileRacing"), 0, settingsFilename); +static int EnableShakeEffectsinMenu = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableShakeEffectsinMenu"), 0, settingsFilename); +static int EnableGroundEffects = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableGroundEffects"), 0, settingsFilename); +static int EnableForceSpringEffect = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableForceSpringEffect"), 0, settingsFilename); +static int ForceSpringStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("ForceSpringStrength"), 0, settingsFilename); +static int MinFFBConstantStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("MinFFBConstantStrength"), 0, settingsFilename); +static int FFBShakeSineStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBShakeSineStrength"), 0, settingsFilename); +static int FFBShakeSinePeriod = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBShakeSinePeriod"), 0, settingsFilename); +static int FFBShakeFadeSinePeriod = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBShakeFadeSinePeriod"), 0, settingsFilename); +static int FFBGrassSinePeriod = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBGrassSinePeriod"), 0, settingsFilename); +static int FFBGrassSineStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBGrassSineStrength"), 0, settingsFilename); +static int FFBGrassFadeSinePeriod = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBGrassFadeSinePeriod"), 0, settingsFilename); +static int FFBRoughTerrainSineStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBRoughTerrainSineStrength"), 0, settingsFilename); +static int FFBRoughTerrainSinePeriod = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBRoughTerrainSinePeriod"), 0, settingsFilename); +static int FFBRoughTerrainFadeSinePeriod = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBRoughTerrainFadeSinePeriod"), 0, settingsFilename); +static int FFBRumbleStripSineStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBRumbleStripSineStrength"), 0, settingsFilename); +static int FFBRumbleStripSinePeriod = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBRumbleStripSinePeriod"), 0, settingsFilename); +static int FFBRumbleStripFadeSinePeriod = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBRumbleStripFadeSinePeriod"), 0, settingsFilename); + +void StormRacerG::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) +{ + float FFBConstant = GetTeknoParrotFFB() / 1000.0; + int Shake = GetTeknoParrotFFB2(); + float Ground = GetTeknoParrotFFB3(); + float Speedo = helpers->ReadFloat32(0x10BE22D8, true); + UINT8 Racing = helpers->ReadByte(0x10BD5B20, true); + + if (EnableDamper == 1) + { + triggers->Damper(DamperStrength / 100.0); + } + + if (EnableForceSpringEffect == 1) + { + triggers->Springi(ForceSpringStrength / 100.0); + } + else if (EnableForceSpringEffect == 2) + { + if (Racing == 0x00) + { + triggers->Spring(ForceSpringStrength / 100.0); + } + } + + if (FFBConstant > 0) + { + double percentForce = FFBConstant / (MinFFBConstantStrength / 2.173913043478261); + double percentLength = 100; + + if (percentForce > 1.0) + percentForce = 1.0; + + triggers->Rumble(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + } + else if (FFBConstant < 0) + { + double percentForce = -FFBConstant / (MinFFBConstantStrength / 2.173913043478261); + double percentLength = 100; + + if (percentForce > 1.0) + percentForce = 1.0; + + triggers->Rumble(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + } + + if (EnableShakeEffectsWhileRacing == 1) + { + if (Racing == 0x01) + { + if (Shake > 0) + { + double percentForce = ((Shake / 1500.0) * (FFBShakeSineStrength / 100.0)); + double percentLength = 100; + + if (percentForce > 1.0) + percentForce = 1.0; + + triggers->Rumble(percentForce, percentForce, percentLength); + triggers->Sine(FFBShakeSinePeriod, FFBShakeFadeSinePeriod, percentForce); + } + } + } + + if (EnableShakeEffectsinMenu == 1) + { + if (Racing == 0x00) + { + if (Shake > 0) + { + double percentForce = ((Shake / 1500.0) * (FFBShakeSineStrength / 100.0)); + double percentLength = 100; + + if (percentForce > 1.0) + percentForce = 1.0; + + triggers->Rumble(percentForce, percentForce, percentLength); + triggers->Sine(FFBShakeSinePeriod, FFBShakeFadeSinePeriod, percentForce); + } + } + } + + if (EnableGroundEffects == 1) + { + if (Speedo > 1.0) + { + if (Ground < 10000) // Driving on Road (Not implemented yet) + { + Ground = Ground / 1000.0; + } + else if (Ground < 300000) // Driving on Grass + { + Ground = ((Ground - 10000) / 1000.0); + + Ground = Ground * (FFBGrassSineStrength / 100.0); + + triggers->Rumble(Ground, Ground, 100); + triggers->Sine(FFBGrassSinePeriod, FFBGrassFadeSinePeriod, Ground); + } + else if (Ground < 700000) // Driving on Rough Ground + { + Ground = ((Ground - 300000) / 1000.0); + + Ground = Ground * (FFBRoughTerrainSineStrength / 100.0); + + triggers->Rumble(Ground, Ground, 100); + triggers->Sine(FFBRoughTerrainSinePeriod, FFBRoughTerrainFadeSinePeriod, Ground); + } + else + { + Ground = ((Ground - 700000) / 1000.0); // Driving on Rumble Strip + + Ground = Ground * (FFBRumbleStripSineStrength / 100.0); + + triggers->Rumble(Ground, Ground, 100); + triggers->Sine(FFBRumbleStripSinePeriod, FFBRumbleStripFadeSinePeriod, Ground); + } + } + } +} \ No newline at end of file diff --git a/Game Files/StormRacerG.h b/Game Files/StormRacerG.h new file mode 100644 index 0000000..1c2faf8 --- /dev/null +++ b/Game Files/StormRacerG.h @@ -0,0 +1,21 @@ +/*This file is part of FFB Arcade Plugin. +FFB Arcade Plugin is free software : you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. +FFB Arcade Plugin is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the +GNU General Public License for more details. +You should have received a copy of the GNU General Public License +along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. +*/ + +#pragma once +#include "../Common Files/TeknoParrotGame.h" + +class StormRacerG : public TeknoParrotGame { +public: + StormRacerG() : TeknoParrotGame() { } + void FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers); +}; \ No newline at end of file diff --git a/Includes/FFBPluginReadme.txt b/Includes/FFBPluginReadme.txt index a934095..c0e5398 100644 --- a/Includes/FFBPluginReadme.txt +++ b/Includes/FFBPluginReadme.txt @@ -166,11 +166,13 @@ extremely generous. -Sega Rally Championship (M2 Emulator & MAME) -Sega Rally 2 -Sega Rally 3 +-Sega World Drivers Championship 2018 -Super Chase - Criminal Termination -Super GT 24h (M2 Emulator & MAME) -Smashing Drive -SnoCross -Sonic & Sega All Stars Racing +-Storm Racer G -Space gun -Terminator 2 -Transformers: Human Alliance @@ -180,4 +182,6 @@ extremely generous. -Vapor TRX -Virtua Racing (CHANGE TO UPRIGHT CABINET) -Wacky Races --Wangan Midnight Maximum Tune 5 \ No newline at end of file +-Wangan Midnight Maximum Tune 5 +-Wangan Midnight Maximum Tune 6 +-Wangan Midnight Maximum Tune 6R \ No newline at end of file