Add Sega Rally 3 Other
This commit is contained in:
parent
5735539ae9
commit
2bdf262b61
@ -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
|
||||
|
@ -87,6 +87,7 @@
|
||||
<ClCompile Include="Game Files\SegaRacingClassic.cpp" />
|
||||
<ClCompile Include="Game Files\FordRacing.cpp" />
|
||||
<ClCompile Include="Game Files\MarioKartGPDX.cpp" />
|
||||
<ClCompile Include="Game Files\SegaRally3Other.cpp" />
|
||||
<ClCompile Include="Game Files\SnoCross.cpp" />
|
||||
<ClCompile Include="Game Files\SonicSegaAllStarsRacing.cpp" />
|
||||
<ClCompile Include="Game Files\TestGame.cpp" />
|
||||
@ -121,6 +122,7 @@
|
||||
<ClInclude Include="Game Files\SegaRacingClassic.h" />
|
||||
<ClInclude Include="Game Files\FordRacing.h" />
|
||||
<ClInclude Include="Game Files\MarioKartGPDX.h" />
|
||||
<ClInclude Include="Game Files\SegaRally3Other.h" />
|
||||
<ClInclude Include="Game Files\SnoCross.h" />
|
||||
<ClInclude Include="Game Files\SonicSegaAllStarsRacing.h" />
|
||||
<ClInclude Include="Game Files\TestGame.h" />
|
||||
|
@ -124,6 +124,7 @@
|
||||
<ClCompile Include="Game Files\Batman.cpp" />
|
||||
<ClCompile Include="Game Files\R-Tuned.cpp" />
|
||||
<ClCompile Include="Game Files\MAMESupermodel.cpp" />
|
||||
<ClCompile Include="Game Files\SegaRally3Other.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Game Files\Daytona3.h">
|
||||
@ -274,6 +275,9 @@
|
||||
<ClInclude Include="Game Files\MAMESupermodel.h">
|
||||
<Filter>Common Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Game Files\SegaRally3Other.h">
|
||||
<Filter>Common Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<MASM Include="DLLWrapper.asm" />
|
||||
|
17
DllMain.cpp
17
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");
|
||||
|
@ -65,11 +65,12 @@ static bool Hook(void * toHook, void * ourFunct, int len) {
|
||||
static DWORD jmpBackAddy;
|
||||
|
||||
void FordRacingOther::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) {
|
||||
if (!init)
|
||||
{
|
||||
HMODULE hMod = GetModuleHandleA("inpout32.dll");
|
||||
if (hMod)
|
||||
{
|
||||
if (!init)
|
||||
{
|
||||
|
||||
int hookLength = 6;
|
||||
DWORD hookAddress = (DWORD)GetProcAddress(GetModuleHandle(L"inpout32.dll"), "Out32");
|
||||
if (hookAddress)
|
||||
@ -78,9 +79,9 @@ void FordRacingOther::FFBLoop(EffectConstants *constants, Helpers *helpers, Effe
|
||||
Hook((void*)hookAddress, Out32, hookLength);
|
||||
init = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
myTriggers = triggers;
|
||||
myConstants = constants;
|
||||
myHelpers = helpers;
|
||||
|
72
Game Files/SegaRally3Other.cpp
Normal file
72
Game Files/SegaRally3Other.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
#include <string>
|
||||
#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;
|
||||
}
|
20
Game Files/SegaRally3Other.h
Normal file
20
Game Files/SegaRally3Other.h
Normal file
@ -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);
|
||||
};
|
Loading…
Reference in New Issue
Block a user