From b276ca9625898218628fe3e335fc829db47b3cca Mon Sep 17 00:00:00 2001 From: Boomslangnz Date: Wed, 23 Mar 2022 17:01:01 +1300 Subject: [PATCH] SR1 and SR2 changes --- Common Files/Game.cpp | 15 +++++++++++++++ Common Files/Game.h | 1 + Game Files/M2Emulator.cpp | 36 +++++++++++++++++++++-------------- Game Files/MAMESupermodel.cpp | 8 ++++---- 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/Common Files/Game.cpp b/Common Files/Game.cpp index 2ef5457..8701f92 100644 --- a/Common Files/Game.cpp +++ b/Common Files/Game.cpp @@ -31,6 +31,21 @@ void Helpers::logInit(char *msg) { ofs.close(); } +void Helpers::info(const char* format, ...) +{ + va_list args; + char buffer[1024]; + + va_start(args, format); + int len = _vsnprintf(buffer, sizeof(buffer), format, args); + va_end(args); + + buffer[len] = '\n'; + buffer[len + 1] = '\0'; + + OutputDebugStringA(buffer); +} + // reading memory LPVOID Helpers::GetTranslatedOffset(INT_PTR offset) { diff --git a/Common Files/Game.h b/Common Files/Game.h index 4d5815b..62de194 100644 --- a/Common Files/Game.h +++ b/Common Files/Game.h @@ -99,6 +99,7 @@ public: void log(char *msg); void logInt(int value); void logInit(char *msg); + void info(const char* format, ...); // reading memory LPVOID GetTranslatedOffset(INT_PTR offset); int ReadInt32(INT_PTR offset, bool isRelativeOffset); diff --git a/Game Files/M2Emulator.cpp b/Game Files/M2Emulator.cpp index 686b3f9..6c9f4a5 100644 --- a/Game Files/M2Emulator.cpp +++ b/Game Files/M2Emulator.cpp @@ -65,6 +65,7 @@ extern int DamperStrength; static DWORD hookAddressM2A; static DWORD hookAddressM2B; static DWORD hookAddressM2C; +static UINT8 OldFFB; static int InputDeviceWheelEnable = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceWheelEnable"), 0, settingsFilename); static int DaytonaAIMultiplayerHack = GetPrivateProfileInt(TEXT("Settings"), TEXT("DaytonaAIMultiplayerHack"), 0, settingsFilename); @@ -523,22 +524,29 @@ void M2Emulator::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectT helpers->log((char*)ffs.c_str()); helpers->log("got value: "); - if ((ff1 > 0xBF) && (ff1 < 0xDF)) + if (OldFFB != ff1) { - helpers->log("moving wheel left"); - double percentForce = (ff1 - 191) / 31.0; - double percentLength = 100; - triggers->Rumble(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((ff1 > 0x7F) && (ff1 < 0x9F)) - { - helpers->log("moving wheel right"); - double percentForce = (ff1 - 127) / 31.0; - double percentLength = 100; - triggers->Rumble(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + if (ff1 >= 0xC0 && ff1 <= 0xDF) + { + helpers->log("moving wheel left"); + double percentForce = (ff1 - 191) / 32.0; + double percentLength = 100; + + triggers->Rumble(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + } + + if (ff1 >= 0x80 && ff1 <= 0x9F) + { + helpers->log("moving wheel right"); + double percentForce = (ff1 - 127) / 32.0; + double percentLength = 100; + + triggers->Rumble(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + } } + OldFFB = ff1; } if ((hWnd2 > NULL) || (hWnd7 > NULL) || (hWnd8 > NULL) || (hWnd9 > NULL) || (hWnd10 > NULL) || (hWnd11 > NULL) || (hWnd12 > NULL) || (hWnd13 > NULL)) diff --git a/Game Files/MAMESupermodel.cpp b/Game Files/MAMESupermodel.cpp index 8275156..71aa4a3 100644 --- a/Game Files/MAMESupermodel.cpp +++ b/Game Files/MAMESupermodel.cpp @@ -2808,16 +2808,16 @@ void MAMESupermodel::FFBLoop(EffectConstants* constants, Helpers* helpers, Effec stateFFB = newstateFFB; } - if ((stateFFB > 0x00) && (stateFFB < 0x30)) + if (stateFFB > 0x00 && stateFFB <= 0x3F) { - double percentForce = (stateFFB) / 41.0; + double percentForce = (stateFFB) / 64.0; double percentLength = 100; triggers->Rumble(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); } - else if ((stateFFB > 0x3F) && (stateFFB < 0x70)) + else if (stateFFB > 0x3F && stateFFB <= 0x7F) { - double percentForce = (stateFFB - 64) / 41.0; + double percentForce = (stateFFB - 64) / 64.0; double percentLength = 100; triggers->Rumble(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce);