diff --git a/Config/FFBPlugin.ini b/Config/FFBPlugin.ini
index 92bbeb5..5be5027 100644
--- a/Config/FFBPlugin.ini
+++ b/Config/FFBPlugin.ini
@@ -203,6 +203,11 @@ GameId=6
FeedbackLength=500
DefaultCentering=15
+[Sega Rally 3 Other]
+GameId=47
+FeedbackLength=500
+DefaultCentering=15
+
[KODrive]
GameId=39
PowerMode=0
diff --git a/Dinput8Wrapper.vcxproj b/Dinput8Wrapper.vcxproj
index a4da824..2c4fe01 100644
--- a/Dinput8Wrapper.vcxproj
+++ b/Dinput8Wrapper.vcxproj
@@ -87,6 +87,7 @@
+
@@ -121,6 +122,7 @@
+
diff --git a/Dinput8Wrapper.vcxproj.filters b/Dinput8Wrapper.vcxproj.filters
index e46c7f1..d0f1a80 100644
--- a/Dinput8Wrapper.vcxproj.filters
+++ b/Dinput8Wrapper.vcxproj.filters
@@ -124,6 +124,7 @@
+
@@ -274,6 +275,9 @@
Common Header Files
+
+ Common Header Files
+
diff --git a/DllMain.cpp b/DllMain.cpp
index 92c4778..1c9761a 100644
--- a/DllMain.cpp
+++ b/DllMain.cpp
@@ -51,6 +51,7 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include "Game Files/OutRun2Real.h"
#include "Game Files/SegaRacingClassic.h"
#include "Game Files/SegaRally3.h"
+#include "Game Files/SegaRally3Other.h"
#include "Game Files/SnoCross.h"
#include "Game Files/WackyRaces.h"
#include "Game Files/WMMT5.h"
@@ -832,6 +833,14 @@ LPCDIDATAFORMAT WINAPI DirectInputGetdfDIJoystick()
return originalGetdfDIJoystick();
}
+void MEMwrite(void* adr, void* ptr, int size)
+{
+ DWORD OldProtection;
+ VirtualProtect(adr, size, PAGE_EXECUTE_READWRITE, &OldProtection);
+ memcpy(adr, ptr, size);
+ VirtualProtect(adr, size, OldProtection, &OldProtection);
+}
+
// global variables
SDL_Haptic* haptic;
SDL_Haptic* haptic2 = NULL;
@@ -961,6 +970,7 @@ const int H2_Overdrive = 43;
const int Sno_Cross = 44;
const int Bat_man = 45;
const int R_Tuned = 46;
+const int SEGA_RALLY_3_Other = 47;
HINSTANCE Get_hInstance()
{
@@ -2019,6 +2029,9 @@ DWORD WINAPI FFBLoop(LPVOID lpParam)
case SEGA_RALLY_3:
game = new SegaRally3;
break;
+ case SEGA_RALLY_3_Other:
+ game = new SegaRally3Other;
+ break;
case WACKY_RACES:
game = new WackyRaces;
break;
@@ -2210,6 +2223,10 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ulReasonForCall, LPVOID lpReserved)
}
hlp.log(buffer);
gl_hOriginalDll = LoadLibraryA(buffer);
+ if (configGameId == 47)
+ {
+ MEMwrite((void*)(0x57B2F0), (void*)"\x33\xC0\x40\xC3", 4);
+ }
if (configGameId == 29)
{
gl_hjgtDll = LoadLibraryA("jgt.dll");
diff --git a/Game Files/FordRacingOther.cpp b/Game Files/FordRacingOther.cpp
index 69bd229..0181cae 100644
--- a/Game Files/FordRacingOther.cpp
+++ b/Game Files/FordRacingOther.cpp
@@ -65,22 +65,23 @@ static bool Hook(void * toHook, void * ourFunct, int len) {
static DWORD jmpBackAddy;
void FordRacingOther::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
- HMODULE hMod = GetModuleHandleA("inpout32.dll");
- if (hMod)
+ if (!init)
{
- if (!init)
+ HMODULE hMod = GetModuleHandleA("inpout32.dll");
+ if (hMod)
{
+
int hookLength = 6;
DWORD hookAddress = (DWORD)GetProcAddress(GetModuleHandle(L"inpout32.dll"), "Out32");
if (hookAddress)
- {
+ {
jmpBackAddy = hookAddress + hookLength;
Hook((void*)hookAddress, Out32, hookLength);
init = true;
}
-
}
}
+
myTriggers = triggers;
myConstants = constants;
myHelpers = helpers;
diff --git a/Game Files/SegaRally3Other.cpp b/Game Files/SegaRally3Other.cpp
new file mode 100644
index 0000000..a5a84b8
--- /dev/null
+++ b/Game Files/SegaRally3Other.cpp
@@ -0,0 +1,72 @@
+#include
+#include "SegaRally3Other.h"
+static EffectTriggers* myTriggers;
+static EffectConstants* myConstants;
+static Helpers* myHelpers;
+
+static bool init = false;
+
+static int __stdcall Out32(DWORD device, DWORD data)
+{
+ if (data > 15)
+ {
+ double percentForce = (31 - data) / 15.0;
+ double percentLength = 100;
+ myTriggers->LeftRight(percentForce, 0, percentLength);
+ myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce);
+ }
+ else if (data > 0)
+ {
+ double percentForce = (16 - data) / 15.0;
+ double percentLength = 100;
+ myTriggers->LeftRight(0, percentForce, percentLength);
+ myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce);
+ }
+ return 0;
+}
+
+static bool Hook(void* toHook, void* ourFunct, int len) {
+ if (len < 5) {
+ return false;
+ }
+
+ DWORD curProtection;
+ VirtualProtect(toHook, len, PAGE_EXECUTE_READWRITE, &curProtection);
+
+ memset(toHook, 0x90, len);
+
+ DWORD relativeAddress = ((DWORD)ourFunct - (DWORD)toHook) - 5;
+
+ *(BYTE*)toHook = 0xE9;
+ *(DWORD*)((DWORD)toHook + 1) = relativeAddress;
+
+ DWORD temp;
+ VirtualProtect(toHook, len, curProtection, &temp);
+
+ return true;
+}
+
+static DWORD jmpBackAddy;
+
+void SegaRally3Other::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) {
+ if (!init)
+ {
+ HMODULE hMod = GetModuleHandleA("inpout32.dll");
+ if (hMod)
+ {
+
+ int hookLength = 6;
+ DWORD hookAddress = (DWORD)GetProcAddress(GetModuleHandle(L"inpout32.dll"), "Out32");
+ if (hookAddress)
+ {
+ jmpBackAddy = hookAddress + hookLength;
+ Hook((void*)hookAddress, Out32, hookLength);
+ init = true;
+ }
+ }
+ }
+
+ myTriggers = triggers;
+ myConstants = constants;
+ myHelpers = helpers;
+}
\ No newline at end of file
diff --git a/Game Files/SegaRally3Other.h b/Game Files/SegaRally3Other.h
new file mode 100644
index 0000000..2cf3fd8
--- /dev/null
+++ b/Game Files/SegaRally3Other.h
@@ -0,0 +1,20 @@
+/*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/Game.h"
+class SegaRally3Other : public Game {
+
+public:
+ void FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers);
+};
\ No newline at end of file