Files
UnleashedRecomp-hedge-dev/UnleashedRecomp/patches/misc_patches.cpp
2025-01-17 20:44:56 +00:00

110 lines
2.2 KiB
C++

#include <api/SWA.h>
#include <ui/reddog/debug_draw.h>
#include <ui/game_window.h>
#include <user/achievement_data.h>
#include <user/config.h>
void AchievementManagerUnlockMidAsmHook(PPCRegister& id)
{
AchievementData::Unlock(id.u32);
}
bool DisableHintsMidAsmHook()
{
return !Config::Hints;
}
bool DisableControlTutorialMidAsmHook()
{
return !Config::ControlTutorial;
}
bool DisableEvilControlTutorialMidAsmHook(PPCRegister& r4, PPCRegister& r5)
{
if (Config::ControlTutorial)
return true;
// Only allow enemy QTE prompts to get through.
return r4.u32 == 1 && r5.u32 == 1;
}
bool DisableDLCIconMidAsmHook()
{
return Config::DisableDLCIcon;
}
void ToggleSubtitlesMidAsmHook(PPCRegister& r27)
{
auto pApplicationDocument = (SWA::CApplicationDocument*)g_memory.Translate(r27.u32);
pApplicationDocument->m_InspireSubtitles = Config::Subtitles;
}
void WerehogBattleMusicMidAsmHook(PPCRegister& r11)
{
if (Config::BattleTheme)
return;
// Swap CStateBattle for CStateNormal.
if (r11.u8 == 4)
r11.u8 = 3;
}
void StorageDevicePromptMidAsmHook() {}
/* Hook function that gets the game region
and force result to zero for Japanese
to display the correct logos. */
PPC_FUNC_IMPL(__imp__sub_825197C0);
PPC_FUNC(sub_825197C0)
{
if (Config::Language == ELanguage::Japanese)
{
ctx.r3.u64 = 0;
return;
}
__imp__sub_825197C0(ctx, base);
}
// Logo skip
PPC_FUNC_IMPL(__imp__sub_82547DF0);
PPC_FUNC(sub_82547DF0)
{
if (Config::SkipIntroLogos)
{
ctx.r4.u64 = 0;
ctx.r5.u64 = 0;
ctx.r6.u64 = 1;
ctx.r7.u64 = 0;
sub_825517C8(ctx, base);
}
else
{
__imp__sub_82547DF0(ctx, base);
}
}
/* Ignore xercesc::EmptyStackException to
allow DLC stages with invalid XML to load. */
PPC_FUNC_IMPL(__imp__sub_8305D5B8);
PPC_FUNC(sub_8305D5B8)
{
auto value = PPC_LOAD_U32(ctx.r3.u32 + 4);
if (!value)
return;
__imp__sub_8305D5B8(ctx, base);
}
// Disable auto save warning.
PPC_FUNC_IMPL(__imp__sub_82586698);
PPC_FUNC(sub_82586698)
{
if (Config::DisableAutoSaveWarning)
*(bool*)g_memory.Translate(0x83367BC2) = true;
__imp__sub_82586698(ctx, base);
}