From 2651bfa5a1cda673a7d640108a98d6756c21418b Mon Sep 17 00:00:00 2001 From: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Sat, 7 Dec 2024 14:25:10 +0300 Subject: [PATCH] Add controller buttons as config option & handle loading screen. --- UnleashedRecomp/gpu/video.cpp | 2 +- UnleashedRecomp/locale/config_locale.h | 16 ++++++++++++++++ UnleashedRecomp/patches/resident_patches.cpp | 17 +++++++++++++++++ UnleashedRecomp/ui/options_menu.cpp | 1 + UnleashedRecomp/user/config.h | 1 + UnleashedRecomp/user/config_detail.h | 12 ++++++++++++ UnleashedRecompLib/config/SWA.toml | 6 +++++- UnleashedRecompResources | 2 +- 8 files changed, 54 insertions(+), 3 deletions(-) diff --git a/UnleashedRecomp/gpu/video.cpp b/UnleashedRecomp/gpu/video.cpp index c74a67b3..7da98cf1 100644 --- a/UnleashedRecomp/gpu/video.cpp +++ b/UnleashedRecomp/gpu/video.cpp @@ -2614,7 +2614,7 @@ static void ProcSetViewport(const RenderCommand& cmd) static void SetTexture(GuestDevice* device, uint32_t index, GuestTexture* texture) { - if (texture != nullptr && texture->patchedTexture != nullptr) + if (Config::ControllerButtons == EControllerButtons::PlayStation && texture != nullptr && texture->patchedTexture != nullptr) texture = texture->patchedTexture.get(); RenderCommand cmd; diff --git a/UnleashedRecomp/locale/config_locale.h b/UnleashedRecomp/locale/config_locale.h index 5ac29f11..28c72d75 100644 --- a/UnleashedRecomp/locale/config_locale.h +++ b/UnleashedRecomp/locale/config_locale.h @@ -131,6 +131,22 @@ CONFIG_DEFINE_ENUM_LOCALE(ETimeOfDayTransition) } }; +CONFIG_DEFINE_LOCALE(ControllerButtons) +{ + { ELanguage::English, { "Controller Buttons", "[PLACEHOLDER]" } } +}; + +CONFIG_DEFINE_ENUM_LOCALE(EControllerButtons) +{ + { + ELanguage::English, + { + { EControllerButtons::Xbox, { "XBOX", "[PLACEHOLDER]" } }, + { EControllerButtons::PlayStation, { "PLAYSTATION", "[PLACEHOLDER]" } } + } + } +}; + CONFIG_DEFINE_LOCALE(SkipIntroLogos) { { ELanguage::English, { "Skip Intro Logos", "Skip the logos during the game's boot sequence.\n\n[TO BE REMOVED]" } } diff --git a/UnleashedRecomp/patches/resident_patches.cpp b/UnleashedRecomp/patches/resident_patches.cpp index 94efda94..ea82a391 100644 --- a/UnleashedRecomp/patches/resident_patches.cpp +++ b/UnleashedRecomp/patches/resident_patches.cpp @@ -101,3 +101,20 @@ PPC_FUNC(sub_82BD06C8) { ctx.r3.u64 = 0; } + +void LoadingScreenControllerMidAsmHook() +{ + static constexpr size_t STR_ADDRESSES[] = + { + 0x820301AC, // 360_sonic1 + 0x820301B8, // 360_sonic2 + 0x820301C4, // 360_sonic3 + 0x820301D0, // 360_evil + 0x820301DC, // 360_robo + 0x820301E8, // 360_super + }; + + const char* prefix = Config::ControllerButtons == EControllerButtons::PlayStation ? "ps3" : "360"; + for (auto address : STR_ADDRESSES) + memcpy(g_memory.Translate(address), prefix, 3); +} diff --git a/UnleashedRecomp/ui/options_menu.cpp b/UnleashedRecomp/ui/options_menu.cpp index 198805b8..fc96f9c1 100644 --- a/UnleashedRecomp/ui/options_menu.cpp +++ b/UnleashedRecomp/ui/options_menu.cpp @@ -790,6 +790,7 @@ static void DrawConfigOptions() DrawConfigOption(rowCount++, yOffset, &Config::InvertCameraX, true); DrawConfigOption(rowCount++, yOffset, &Config::InvertCameraY, true); DrawConfigOption(rowCount++, yOffset, &Config::AllowBackgroundInput, true); + DrawConfigOption(rowCount++, yOffset, &Config::ControllerButtons, true); break; case 2: // AUDIO DrawConfigOption(rowCount++, yOffset, &Config::MusicVolume, true); diff --git a/UnleashedRecomp/user/config.h b/UnleashedRecomp/user/config.h index 5757da31..cd5ca442 100644 --- a/UnleashedRecomp/user/config.h +++ b/UnleashedRecomp/user/config.h @@ -24,6 +24,7 @@ public: CONFIG_DEFINE_LOCALISED("Input", bool, XButtonHoming, true); CONFIG_DEFINE_LOCALISED("Input", bool, AllowCancellingUnleash, false); CONFIG_DEFINE_LOCALISED("Input", bool, AllowBackgroundInput, false); + CONFIG_DEFINE_ENUM_LOCALISED("Input", EControllerButtons, ControllerButtons, EControllerButtons::Xbox); CONFIG_DEFINE_LOCALISED("Audio", float, MusicVolume, 1.0f); CONFIG_DEFINE_LOCALISED("Audio", float, EffectsVolume, 1.0f); diff --git a/UnleashedRecomp/user/config_detail.h b/UnleashedRecomp/user/config_detail.h index 9cff0987..b7eeefe1 100644 --- a/UnleashedRecomp/user/config_detail.h +++ b/UnleashedRecomp/user/config_detail.h @@ -67,6 +67,18 @@ CONFIG_DEFINE_ENUM_TEMPLATE(ETimeOfDayTransition) { "PlayStation", ETimeOfDayTransition::PlayStation } }; +enum class EControllerButtons : uint32_t +{ + Xbox, + PlayStation +}; + +CONFIG_DEFINE_ENUM_TEMPLATE(EControllerButtons) +{ + { "Xbox", EControllerButtons::Xbox }, + { "PlayStation", EControllerButtons::PlayStation } +}; + enum class EVoiceLanguage : uint32_t { English, diff --git a/UnleashedRecompLib/config/SWA.toml b/UnleashedRecompLib/config/SWA.toml index 74203c0f..99b60fc7 100644 --- a/UnleashedRecompLib/config/SWA.toml +++ b/UnleashedRecompLib/config/SWA.toml @@ -553,4 +553,8 @@ jump_address = 0x825854FC name = "TitleMenuAddInstallOptionMidAsmHook" address = 0x8258547C registers = ["r3"] -jump_address = 0x82585480 \ No newline at end of file +jump_address = 0x82585480 + +[[midasm_hook]] +name = "LoadingScreenControllerMidAsmHook" +address = 0x824DC9D4 diff --git a/UnleashedRecompResources b/UnleashedRecompResources index d45116bb..bcad34ee 160000 --- a/UnleashedRecompResources +++ b/UnleashedRecompResources @@ -1 +1 @@ -Subproject commit d45116bb0b5c5075da9b3c166fdf73af2415e880 +Subproject commit bcad34ee648f69c448b204cb38337e7ef2e0aa18