mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-12-31 00:10:26 -06:00
SWA API: - Added CVector - Added CVector4 - Combined CVectorX into one header Reddog: - Added toggle for visualizing the loaded GI Atlas Mipmap level - Added toggles for rendering Havok collision - Added toggles for Light Field
129 lines
2.7 KiB
C++
129 lines
2.7 KiB
C++
#include <api/SWA.h>
|
|
#include <ui/game_window.h>
|
|
#include <user/achievement_data.h>
|
|
#include <user/config.h>
|
|
#include <ui/reddog/debug_draw.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);
|
|
}
|
|
|
|
PPC_FUNC_IMPL(__imp__sub_822C9398);
|
|
PPC_FUNC(sub_822C9398)
|
|
{
|
|
auto a2 = (Hedgehog::Math::CVector*)g_memory.Translate(ctx.r4.u32);
|
|
auto a3 = (Hedgehog::Math::CVector*)g_memory.Translate(ctx.r5.u32);
|
|
auto a4 = (be<unsigned int>*)g_memory.Translate(ctx.r6.u32);
|
|
|
|
Reddog::Vector3 start(a2->X, a2->Y, a2->Z);
|
|
Reddog::Vector3 end(a3->X, a3->Y, a3->Z);
|
|
|
|
const Reddog::SDrawLine line{
|
|
start, end, a4->value
|
|
};
|
|
|
|
Reddog::DebugDraw::DrawLine(line);
|
|
|
|
__imp__sub_822C9398(ctx, base);
|
|
}
|