diff --git a/MarathonRecomp/api/Marathon.h b/MarathonRecomp/api/Marathon.h index 0e87f796..15bb9c87 100644 --- a/MarathonRecomp/api/Marathon.h +++ b/MarathonRecomp/api/Marathon.h @@ -49,6 +49,7 @@ #include "Sonicteam/HUDMainMenu.h" #include "Sonicteam/HUDMessageWindow.h" #include "Sonicteam/HUDOption.h" +#include "Sonicteam/HUDPause.h" #include "Sonicteam/HUDPopupScreen.h" #include "Sonicteam/HUDRaderMap.h" #include "Sonicteam/HUDStageTitle.h" diff --git a/MarathonRecomp/api/Sonicteam/HUDPause.h b/MarathonRecomp/api/Sonicteam/HUDPause.h new file mode 100644 index 00000000..2a0c6710 --- /dev/null +++ b/MarathonRecomp/api/Sonicteam/HUDPause.h @@ -0,0 +1,18 @@ +#pragma once + +#include +#include + +namespace Sonicteam +{ + class HUDPause : public SoX::RefCountObject, public SoX::Engine::Task + { + public: + xpointer m_pCsdObject; + MARATHON_INSERT_PADDING(0xA0); + be m_TextPriority; + MARATHON_INSERT_PADDING(0x40); + xpointer m_pHudTextRoot; + bool m_ShowMissionWindow; + }; +} diff --git a/MarathonRecomp/api/Sonicteam/PauseTask.h b/MarathonRecomp/api/Sonicteam/PauseTask.h index 31ead449..fc700d89 100644 --- a/MarathonRecomp/api/Sonicteam/PauseTask.h +++ b/MarathonRecomp/api/Sonicteam/PauseTask.h @@ -25,7 +25,12 @@ namespace Sonicteam be m_SelectedIndex; MARATHON_INSERT_PADDING(0x28); be m_Buttons; - MARATHON_INSERT_PADDING(0x1E0); + MARATHON_INSERT_PADDING(0x1D8); + xpointer m_pMissionText; + MARATHON_INSERT_PADDING(0x4); be m_ItemCount; }; + + MARATHON_ASSERT_OFFSETOF(PauseTask, m_pMissionText, 0x27C); + MARATHON_ASSERT_OFFSETOF(PauseTask, m_ItemCount, 0x284); } diff --git a/MarathonRecomp/patches/aspect_ratio_patches.cpp b/MarathonRecomp/patches/aspect_ratio_patches.cpp index 3f97b9eb..cba407b4 100644 --- a/MarathonRecomp/patches/aspect_ratio_patches.cpp +++ b/MarathonRecomp/patches/aspect_ratio_patches.cpp @@ -1,5 +1,4 @@ #include "aspect_ratio_patches.h" -#include #include #include #include @@ -10,7 +9,6 @@ #include #include #include -#include // #define CORNER_DEBUG @@ -1613,19 +1611,6 @@ PPC_FUNC(sub_8262D868) ReplaceTextVariables(pTextEntity); } -void SetTextEntityModifier(Sonicteam::TextEntity* pTextEntity, uint64_t flags) -{ - if (!pTextEntity) - return; - - auto pTextModifier = (uint64_t*)(reinterpret_cast(pTextEntity) + sizeof(Sonicteam::TextEntity)); - - *pTextModifier = flags; - - pTextEntity->m_FieldDD = true; - pTextEntity->Update(); -} - // Sonicteam::HUDMainMenu::Destroy PPC_FUNC_IMPL(__imp__sub_824E2978); PPC_FUNC(sub_824E2978) @@ -1986,7 +1971,7 @@ const xxHashMap g_csdModifiers = // pausemenu { HashStr("sprite/pausemenu/pausemenu/pause_menu"), { CSD_SCALE } }, { HashStr("sprite/pausemenu/pausemenu/pause_menu_cursor"), { CSD_SCALE } }, - { HashStr("sprite/pausemenu/pausemenu/mission"), { CSD_SCALE } }, + { HashStr("sprite/pausemenu/pausemenu/mission"), { CSD_ALIGN_BOTTOM | CSD_SCALE } }, // radarmap_cover { HashStr("sprite/radarmap_cover/radarmap_cover/Scene_0000"), { CSD_RADARMAP | CSD_ALIGN_TOP_RIGHT | CSD_SCALE } }, diff --git a/MarathonRecomp/patches/aspect_ratio_patches.h b/MarathonRecomp/patches/aspect_ratio_patches.h index b6069180..297fe8ec 100644 --- a/MarathonRecomp/patches/aspect_ratio_patches.h +++ b/MarathonRecomp/patches/aspect_ratio_patches.h @@ -1,6 +1,7 @@ #pragma once #include +#include #define MAKE_BITFLAG32(bit) 1U << bit #define MAKE_BITFLAG64(bit) 1ULL << bit @@ -157,8 +158,21 @@ struct MovieModifier }; extern const xxHashMap g_movieModifiers; - MovieModifier FindMovieModifier(XXH64_hash_t nameHash); +static void SetTextEntityModifier(Sonicteam::TextEntity* pTextEntity, uint64_t flags) +{ + if (!pTextEntity) + return; + + const auto pTextModifier = reinterpret_cast( + reinterpret_cast(pTextEntity) + sizeof(Sonicteam::TextEntity)); + + *pTextModifier = flags; + + pTextEntity->m_FieldDD = true; + pTextEntity->Update(); +} + #undef MAKE_BITFLAG64 #undef MAKE_BITFLAG32 diff --git a/MarathonRecomp/patches/misc_patches.cpp b/MarathonRecomp/patches/misc_patches.cpp index a8a8e320..f2c87189 100644 --- a/MarathonRecomp/patches/misc_patches.cpp +++ b/MarathonRecomp/patches/misc_patches.cpp @@ -233,4 +233,22 @@ PPC_FUNC(sub_82188460) ctx.r3.u64 = Config::Subtitles; } +// Sonicteam::HUDPause::ProcessMessage +PPC_FUNC_IMPL(__imp__sub_824EF788); +PPC_FUNC(sub_824EF788) +{ + if (Config::RestorePauseMissionText) + reinterpret_cast(base + ctx.r3.u32)->m_ShowMissionWindow = true; + + __imp__sub_824EF788(ctx, base); +} + +// The mission text is drawn at a lower priority +// than the mission box by default. 1001.0f is the +// priority value used by the rest of the pause menu. +void PauseTask_SetMissionTextPriority(PPCRegister& priority) +{ + priority.f64 = 1001.0f; +} + void NOP() {} diff --git a/MarathonRecomp/patches/pause_patches.cpp b/MarathonRecomp/patches/pause_patches.cpp index d1a10509..90e9e79a 100644 --- a/MarathonRecomp/patches/pause_patches.cpp +++ b/MarathonRecomp/patches/pause_patches.cpp @@ -2,6 +2,8 @@ #include #include +#include "aspect_ratio_patches.h" + void AddPauseMenuItem ( Sonicteam::TextBook* in_pTextBook, @@ -107,5 +109,7 @@ PPC_FUNC(sub_82509870) } } + SetTextEntityModifier(pPauseTask->m_pMissionText.get(), CSD_ALIGN_BOTTOM | CSD_SCALE); + __imp__sub_82509870(ctx, base); } diff --git a/MarathonRecomp/user/config_def.h b/MarathonRecomp/user/config_def.h index 2b2412c0..c7eb9652 100644 --- a/MarathonRecomp/user/config_def.h +++ b/MarathonRecomp/user/config_def.h @@ -95,6 +95,7 @@ CONFIG_DEFINE_HIDDEN("Codes", bool, RestoreChaosBoostJump, false, false); CONFIG_DEFINE_HIDDEN("Codes", bool, RestoreChaosSpearFlips, false, false); CONFIG_DEFINE_HIDDEN("Codes", bool, RestoreContextualHUDColours, false, false); CONFIG_DEFINE_HIDDEN("Codes", bool, RestoreDemoCameraMode, false, false); +CONFIG_DEFINE_HIDDEN("Codes", bool, RestorePauseMissionText, false, false); CONFIG_DEFINE_HIDDEN("Codes", bool, RestoreSonicActionGauge, false, false); CONFIG_DEFINE_HIDDEN("Codes", bool, SkipIntroLogos, false, false); CONFIG_DEFINE_HIDDEN("Codes", bool, TailsGauge, false, false); diff --git a/MarathonRecompLib/config/Marathon.toml b/MarathonRecompLib/config/Marathon.toml index fb3a8321..2bbf6c11 100644 --- a/MarathonRecompLib/config/Marathon.toml +++ b/MarathonRecompLib/config/Marathon.toml @@ -556,6 +556,11 @@ name = "SonicGauge_FixFlags" address = 0x822196EC registers = ["r3", "r31"] +[[midasm_hook]] +name = "PauseTask_SetMissionTextPriority" +address = 0x82509AEC +registers = ["f1"] + [[midasm_hook]] name = "SonicGauge_FixGemSprite" address = 0x82185768