From 0b1e386e854dd078fa4b585e7a8b847d447c6ea9 Mon Sep 17 00:00:00 2001 From: emoose Date: Fri, 30 Aug 2024 13:38:58 +0100 Subject: [PATCH] DefaultManualTransmission: makes MT the default selection in C2C menus --- OutRun2006Tweaks.ini | 4 ++++ external/ModUtils | 2 +- external/spdlog | 2 +- external/xxHash | 2 +- src/dllmain.cpp | 3 ++- src/hooks_flac.cpp | 1 + src/hooks_misc.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ src/plugin.hpp | 1 + src/resource.h | 4 ++-- 9 files changed, 54 insertions(+), 6 deletions(-) diff --git a/OutRun2006Tweaks.ini b/OutRun2006Tweaks.ini index 22a707c..8f07c05 100644 --- a/OutRun2006Tweaks.ini +++ b/OutRun2006Tweaks.ini @@ -37,6 +37,10 @@ SteeringDeadZone = 0.2 # IF YOU HAVE ISSUES WITH GAME DETECTING CONTROLLER: try disabling this! ControllerHotPlug = true +# Makes Manual Transmission the default selection in C2C menus +# (the menu animation will briefly show as Automatic, but Manual will be selected - spamming through menus will select Manual by default) +DefaultManualTransmission = false + # Allows assigning a keyboard key to toggle the game HUD # Depends on your keyboard layout which keys can be assigned here, some might work as-is (eg. P to bind it to P, or HOME to bind to Home) # Binding to a function key such as F10 should work fine on all keyboard layouts diff --git a/external/ModUtils b/external/ModUtils index 3d5474e..58f3f47 160000 --- a/external/ModUtils +++ b/external/ModUtils @@ -1 +1 @@ -Subproject commit 3d5474e8d5f8732f2306409c58890e5578d1eed7 +Subproject commit 58f3f475e6e84dc97f5e2c171e21b928c2c366ab diff --git a/external/spdlog b/external/spdlog index c3aed4b..a3a0c9d 160000 --- a/external/spdlog +++ b/external/spdlog @@ -1 +1 @@ -Subproject commit c3aed4b68373955e1cc94307683d44dca1515d2b +Subproject commit a3a0c9d66386962fcaf0178fcae03ac77c1e0257 diff --git a/external/xxHash b/external/xxHash index 1b6ad7d..dbea33e 160000 --- a/external/xxHash +++ b/external/xxHash @@ -1 +1 @@ -Subproject commit 1b6ad7dd6fd5dac5302537412ddbeb0db21165b9 +Subproject commit dbea33e47e7c0fe0b7c8592cd931c7430c1f130d diff --git a/src/dllmain.cpp b/src/dllmain.cpp index 5a51121..9b0caed 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -104,6 +104,7 @@ namespace Settings spdlog::info(" - SteeringDeadZone: {}", SteeringDeadZone); spdlog::info(" - ControllerHotPlug: {}", ControllerHotPlug); + spdlog::info(" - DefaultManualTransmission: {}", DefaultManualTransmission); spdlog::info(" - VibrationMode: {}", VibrationMode); spdlog::info(" - VibrationStrength: {}", VibrationStrength); spdlog::info(" - VibrationControllerId: {}", VibrationControllerId); @@ -111,7 +112,6 @@ namespace Settings spdlog::info(" - ImpulseVibrationLeftMultiplier: {}", ImpulseVibrationLeftMultiplier); spdlog::info(" - ImpulseVibrationRightMultiplier: {}", ImpulseVibrationRightMultiplier); - spdlog::info(" - EnableHollyCourse2: {}", EnableHollyCourse2); spdlog::info(" - SkipIntroLogos: {}", SkipIntroLogos); spdlog::info(" - DisableCountdownTimer: {}", DisableCountdownTimer); @@ -216,6 +216,7 @@ namespace Settings SteeringDeadZone = ini.Get("Controls", "SteeringDeadZone", std::move(SteeringDeadZone)); SteeringDeadZone = std::clamp(SteeringDeadZone, 0.f, 1.f); ControllerHotPlug = ini.Get("Controls", "ControllerHotPlug", std::move(ControllerHotPlug)); + DefaultManualTransmission = ini.Get("Controls", "DefaultManualTransmission", std::move(DefaultManualTransmission)); HudToggleKey = ini.Get("Controls", "HudToggleKey", std::move(HudToggleKey)); VibrationMode = ini.Get("Controls", "VibrationMode", std::move(VibrationMode)); VibrationMode = std::clamp(VibrationMode, 0, 3); diff --git a/src/hooks_flac.cpp b/src/hooks_flac.cpp index 60bed9e..513f5ea 100644 --- a/src/hooks_flac.cpp +++ b/src/hooks_flac.cpp @@ -6,6 +6,7 @@ #include #include +// CWaveFile class used in C2C, seems based on DirectX DXUTsound.cpp code class CWaveFile { public: diff --git a/src/hooks_misc.cpp b/src/hooks_misc.cpp index a89e8d7..688fd4b 100644 --- a/src/hooks_misc.cpp +++ b/src/hooks_misc.cpp @@ -9,6 +9,47 @@ #include #include +class DefaultManualTransmission : public Hook +{ + inline static SafetyHookInline Sumo_TransmissionSelection_Init{}; + static char __fastcall destination2(uint8_t* thisptr) + { + char ret = Sumo_TransmissionSelection_Init.thiscall(thisptr); + + *(int*)(thisptr + 0xE4) = 0; // prev selection = auto + *(int*)(thisptr + 0xE8) = 1; // current selection = manual + + // This can force sprite to update to manual immediately, which should improve presentation + // but this causes it to draw transmision menu while the animation for opening it plays out + // (that anim also seems to show automatic selected despite this update, maybe the graphic for that animation has it selected...) + //fn_0args_class sub_51BE30 = (fn_0args_class)0x51BE30; + //sub_51BE30(thisptr + 0x34, 0); + + return ret; + } + +public: + std::string_view description() override + { + return "DefaultManualTransmission"; + } + + bool validate() override + { + return Settings::DefaultManualTransmission; + } + + bool apply() override + { + Sumo_TransmissionSelection_Init = safetyhook::create_inline(Module::exe_ptr(0xDD250), destination2); + + return !!Sumo_TransmissionSelection_Init; + } + + static DefaultManualTransmission instance; +}; +DefaultManualTransmission DefaultManualTransmission::instance; + class EnableHollyCourse2 : public Hook { // TODO: Percentage might not be affected by the holly 2 missions atm, letting it go above 100% might be neat diff --git a/src/plugin.hpp b/src/plugin.hpp index 1246157..db4841c 100644 --- a/src/plugin.hpp +++ b/src/plugin.hpp @@ -95,6 +95,7 @@ namespace Settings inline float SteeringDeadZone = 0.2f; inline bool ControllerHotPlug = true; + inline bool DefaultManualTransmission = false; inline std::string HudToggleKey = ""; inline int VibrationMode = 0; inline int VibrationStrength = 10; diff --git a/src/resource.h b/src/resource.h index 936ac36..c4d9e74 100644 --- a/src/resource.h +++ b/src/resource.h @@ -14,8 +14,8 @@ #endif #define MODULE_VERSION_MAJOR 0 -#define MODULE_VERSION_MINOR 5 -#define MODULE_VERSION_BUILD 1 +#define MODULE_VERSION_MINOR 6 +#define MODULE_VERSION_BUILD 0 #define MODULE_VERSION_REVISION 0 #define STR(value) #value