diff --git a/Config/FFBPlugin.ini b/Config/FFBPlugin.ini index c11f543..da07b49 100644 --- a/Config/FFBPlugin.ini +++ b/Config/FFBPlugin.ini @@ -339,6 +339,18 @@ EnableDamper=0 DamperStrength=100 EnableOutputs=0 +[Initial D Zero v230] +GameId=67 +FeedbackLength=80 +PowerMode=0 +IDZMode=0 +EnableForceSpringEffect=0 +ForceSpringStrength=70 +EscapeKeyExitViaPlugin=0 +EnableDamper=0 +DamperStrength=100 +EnableOutputs=0 + [Initial D 4] GameId=16 FeedbackLength=5000 diff --git a/Dinput8Wrapper.vcxproj b/Dinput8Wrapper.vcxproj index 4cd6d52..a0724dd 100644 --- a/Dinput8Wrapper.vcxproj +++ b/Dinput8Wrapper.vcxproj @@ -39,6 +39,7 @@ + @@ -97,6 +98,7 @@ + diff --git a/Dinput8Wrapper.vcxproj.filters b/Dinput8Wrapper.vcxproj.filters index de4b6cb..d173a35 100644 --- a/Dinput8Wrapper.vcxproj.filters +++ b/Dinput8Wrapper.vcxproj.filters @@ -152,6 +152,7 @@ + @@ -368,6 +369,9 @@ Common Header Files + + Common Header Files + diff --git a/DllMain.cpp b/DllMain.cpp index 76103ec..2e2b925 100644 --- a/DllMain.cpp +++ b/DllMain.cpp @@ -50,6 +50,7 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. #include "Game Files/GoldenGun.h" #include "Game Files/InitialD0v131.h" #include "Game Files/InitialD0v211.h" +#include "Game Files/InitialD0v230.h" #include "Game Files/InitialD4.h" #include "Game Files/InitialD4Japan.h" #include "Game Files/InitialD5.h" @@ -1040,6 +1041,7 @@ const int DEAD_HEAT_RIDERS = 63; const int GAELCO_TUNING_RACE = 64; const int TOKYO_COP = 65; const int RING_RIDERS = 66; +const int INITIAL_D_0_230 = 67; HINSTANCE Get_hInstance() { @@ -2369,6 +2371,9 @@ DWORD WINAPI FFBLoop(LPVOID lpParam) case INITIAL_D_0_211: game = new InitialD0v211; break; + case INITIAL_D_0_230: + game = new InitialD0v230; + break; case INITIAL_D_4: game = new InitialD4; break; diff --git a/Game Files/Flycast.cpp b/Game Files/Flycast.cpp index deecbd5..62946ef 100644 --- a/Game Files/Flycast.cpp +++ b/Game Files/Flycast.cpp @@ -53,10 +53,14 @@ void Flycast::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTrigge if (!FFBGameInit) { HWND hwnd = FindWindowA(0, "Flycast"); + HWND hwnddojo = FindWindowA(0, "Flycast Dojo"); - if (pOrigProc == NULL) + if (pOrigProc == NULL && hwnd) pOrigProc = (WNDPROC)::SetWindowLongPtr((HWND)hwnd, GWLP_WNDPROC, (LONG_PTR)HookWndProc); + if (pOrigProc == NULL && hwnddojo) + pOrigProc = (WNDPROC)::SetWindowLongPtr((HWND)hwnddojo, GWLP_WNDPROC, (LONG_PTR)HookWndProc); + if (LetsStartFFB) { Sleep(15000); diff --git a/Game Files/InitialD0v230.cpp b/Game Files/InitialD0v230.cpp new file mode 100644 index 0000000..b022051 --- /dev/null +++ b/Game Files/InitialD0v230.cpp @@ -0,0 +1,172 @@ +/*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 "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 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); + +void InitialD0v230::FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers) { + + if (!outputinit) + { + if (EnableOutputs == 1) + { + outputinit = true; + LoadLibraryA("OutputBlaster.dll"); + } + } + + if (GetAsyncKeyState((VK_ESCAPE)) && (EscapeKeyExitViaPlugin == 1)) + { + ExitProcess(0); + } + + if (EnableDamper == 1) + { + triggers->Damper(DamperStrength / 100.0); + } + + if (IDZMode == 0) + { + ff = helpers->ReadByte(0x18A720F, true); + oldff = 0; + newff = ff; + + helpers->log("got value: "); + std::string ffs = std::to_string(ff); + helpers->log((char*)ffs.c_str()); + + if (EnableForceSpringEffect == 1) + { + triggers->Springi(ForceSpringStrength / 100.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; + } + 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) + { + helpers->log("Spring"); + triggers->Spring(1.0); + } + else if (ff1 == 0x85) + { + 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); + } + } + } + } +} \ No newline at end of file diff --git a/Game Files/InitialD0v230.h b/Game Files/InitialD0v230.h new file mode 100644 index 0000000..440f58c --- /dev/null +++ b/Game Files/InitialD0v230.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 InitialD0v230 : public Game { +public: + void FFBLoop(EffectConstants* constants, Helpers* helpers, EffectTriggers* triggers); +}; \ No newline at end of file