Fix staffroll text getting cropped at narrow aspect ratios. (#1489)

This commit is contained in:
Skyth (Asilkan) 2025-03-30 18:42:37 +03:00 committed by GitHub
parent f5f92d0761
commit f7c823eeaf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 71 additions and 0 deletions

View file

@ -1650,3 +1650,39 @@ PPC_FUNC(sub_82E54950)
__imp__sub_82E54950(ctx, base);
}
}
// Credits while Sonic is running are offseted by 133 pixels at 16:9.
// We can make this dynamic by remembering the anchoring and shifting accordingly.
void EndingTextAllocMidAsmHook(PPCRegister& r3)
{
r3.u32 += sizeof(uint32_t);
}
static constexpr uint32_t ENDING_TEXT_SIZE = 0x164;
void EndingTextCtorRightMidAsmHook(PPCRegister& r3)
{
*reinterpret_cast<uint32_t*>(g_memory.base + r3.u32 + ENDING_TEXT_SIZE) = ALIGN_RIGHT;
}
void EndingTextCtorLeftMidAsmHook(PPCRegister& r3)
{
*reinterpret_cast<uint32_t*>(g_memory.base + r3.u32 + ENDING_TEXT_SIZE) = ALIGN_LEFT;
}
void EndingTextCtorCenterMidAsmHook(PPCRegister& r3)
{
*reinterpret_cast<uint32_t*>(g_memory.base + r3.u32 + ENDING_TEXT_SIZE) = ALIGN_CENTER;
}
void EndingTextPositionMidAsmHook(PPCRegister& r31, PPCRegister& f13)
{
uint32_t align = *reinterpret_cast<uint32_t*>(g_memory.base + r31.u32 + ENDING_TEXT_SIZE);
// Since widescreen is always forced, 133 offset will always be part of the position.
if (align == ALIGN_RIGHT)
f13.f64 += -133.0 * (1.0 - g_aspectRatioNarrowScale);
else if (align == ALIGN_LEFT)
f13.f64 += 133.0 * (1.0 - g_aspectRatioNarrowScale);
}

View file

@ -1106,3 +1106,38 @@ name = "UseAlternateTitleMidAsmHook"
address = 0x82580F44
jump_address_on_true = 0x82580F48
jump_address_on_false = 0x82580FA0
[[midasm_hook]]
name = "EndingTextAllocMidAsmHook"
address = 0x8257E284
registers = ["r3"]
[[midasm_hook]]
name = "EndingTextAllocMidAsmHook"
address = 0x8257E45C
registers = ["r3"]
[[midasm_hook]]
name = "EndingTextAllocMidAsmHook"
address = 0x8257EDD8
registers = ["r3"]
[[midasm_hook]]
name = "EndingTextCtorRightMidAsmHook"
address = 0x8257E304
registers = ["r3"]
[[midasm_hook]]
name = "EndingTextCtorLeftMidAsmHook"
address = 0x8257E4DC
registers = ["r3"]
[[midasm_hook]]
name = "EndingTextCtorCenterMidAsmHook"
address = 0x8257EE40
registers = ["r3"]
[[midasm_hook]]
name = "EndingTextPositionMidAsmHook"
address = 0x82580168
registers = ["r31", "f13"]