Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ namespace Sonicteam::Message::HUDPause
struct MsgChangeState : SoX::Message<0x1B04E>
{
be<uint32_t> State{};
MARATHON_INSERT_PADDING(0x04);
be<uint32_t> Field08{};

MsgChangeState(uint32_t in_state) : State(in_state) {}
MsgChangeState(const uint32_t in_state, const uint32_t in_field08)
: State(in_state), Field08(in_field08) {}
};

MARATHON_ASSERT_OFFSETOF(MsgChangeState, State, 0x04);
MARATHON_ASSERT_OFFSETOF(MsgChangeState, Field08, 0x08);
MARATHON_ASSERT_SIZEOF(MsgChangeState, 0x0C);
}
10 changes: 6 additions & 4 deletions MarathonRecomp/api/Sonicteam/PauseTask.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <Marathon.inl>
#include <boost/smart_ptr/shared_ptr.h>
#include <Sonicteam/HUDPause.h>
#include <Sonicteam/TextEntity.h>

Expand All @@ -25,11 +26,11 @@ namespace Sonicteam
be<PauseTaskState> m_State;
be<uint32_t> m_Flags;
be<uint32_t> m_SelectedIndex;
MARATHON_INSERT_PADDING(0x28);
be<uint32_t> m_Field78;
MARATHON_INSERT_PADDING(0x24);
be<uint32_t> m_Buttons;
MARATHON_INSERT_PADDING(0x1D8);
xpointer<TextEntity> m_pMissionText;
MARATHON_INSERT_PADDING(0x04);
boost::shared_ptr<TextEntity> m_spMissionText;
be<uint32_t> m_ItemCount;
MARATHON_INSERT_PADDING(0x12C);
};
Expand All @@ -38,8 +39,9 @@ namespace Sonicteam
MARATHON_ASSERT_OFFSETOF(PauseTask, m_State, 0x6C);
MARATHON_ASSERT_OFFSETOF(PauseTask, m_Flags, 0x70);
MARATHON_ASSERT_OFFSETOF(PauseTask, m_SelectedIndex, 0x74);
MARATHON_ASSERT_OFFSETOF(PauseTask, m_Field78, 0x78);
MARATHON_ASSERT_OFFSETOF(PauseTask, m_Buttons, 0xA0);
MARATHON_ASSERT_OFFSETOF(PauseTask, m_pMissionText, 0x27C);
MARATHON_ASSERT_OFFSETOF(PauseTask, m_spMissionText, 0x27C);
MARATHON_ASSERT_OFFSETOF(PauseTask, m_ItemCount, 0x284);
MARATHON_ASSERT_SIZEOF(PauseTask, 0x3B4);
}
36 changes: 28 additions & 8 deletions MarathonRecomp/patches/pause_patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ PPC_FUNC(sub_824F05D8)
const auto pHUDPause = static_cast<Sonicteam::HUDPause*>(reinterpret_cast<Sonicteam::SoX::MessageReceiver*>(base + ctx.r3.u32));
const auto pMessage = reinterpret_cast<Sonicteam::SoX::IMessage*>(base + ctx.r4.u32);

pHUDPause->m_ShowMissionWindow = true;

if (pMessage->ID == Sonicteam::Message::HUDPause::MsgChangeState::GetID())
{
const auto pMsgChangeState = static_cast<Sonicteam::Message::HUDPause::MsgChangeState*>(pMessage);
Expand Down Expand Up @@ -188,15 +186,37 @@ PPC_FUNC(sub_82509870)
});
}

SetTextEntityModifier(pPauseTask->m_pMissionText.get(), CSD_ALIGN_BOTTOM | CSD_SCALE);
SetTextEntityModifier(pPauseTask->m_spMissionText.get(), CSD_ALIGN_BOTTOM | CSD_SCALE);

__imp__sub_82509870(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)
// Skips the original code that sends this message, as it's sent *before* the
// text entity for the mission window is created, resulting in the message processor
// seeing nullptr. We'll send this message ourselves after the text entity is created.
bool PauseTask_SkipSendMsgChangeState()
{
return Config::RestorePauseMissionText;
}

void PauseTask_ConfigureMissionWindow(PPCRegister& r31)
{
priority.f64 = 1001.0f;
const auto pPauseTask = reinterpret_cast<Sonicteam::PauseTask*>(g_memory.Translate(r31.u32));

// The mission text is drawn at a lower priority than the mission window by default.
// 1001.0f is the priority value used by the rest of the pause menu.
if (pPauseTask->m_spMissionText)
GuestToHostFunction<int>(sub_8262AF00, pPauseTask->m_spMissionText.get(), 1001.0f);

if (!Config::RestorePauseMissionText)
return;

auto showMissionWindow = true;

if (!pPauseTask->m_spMissionText || pPauseTask->m_spMissionText->m_TextLength <= 0)
showMissionWindow = false;

auto msgChangeState = guest_stack_var<Sonicteam::Message::HUDPause::MsgChangeState>(0, pPauseTask->m_Field78.get());
pPauseTask->m_pHUDPause->m_ShowMissionWindow = showMissionWindow;
pPauseTask->m_pHUDPause->ProcessMessage(msgChangeState.get());
}
11 changes: 8 additions & 3 deletions MarathonRecompLib/config/Marathon.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,14 @@ address = 0x822196EC
registers = ["r3", "r31"]

[[midasm_hook]]
name = "PauseTask_SetMissionTextPriority"
address = 0x82509AEC
registers = ["f1"]
name = "PauseTask_SkipSendMsgChangeState"
address = 0x82509A30
jump_address_on_true = 0x82509A60

[[midasm_hook]]
name = "PauseTask_ConfigureMissionWindow"
address = 0x82509B04
registers = ["r31"]

[[midasm_hook]]
name = "SonicGauge_FixGemSprite"
Expand Down
Loading