mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-10-30 07:11:05 +00:00
Implemented score hooks
This commit is contained in:
parent
ce95692d8a
commit
ceee6948a8
6 changed files with 70 additions and 4 deletions
|
|
@ -5,8 +5,9 @@ namespace SWA
|
||||||
class CApplicationDocument // : public Hedgehog::Base::CSynchronizedObject
|
class CApplicationDocument // : public Hedgehog::Base::CSynchronizedObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
// TODO: use g_memory.Translate?
|
||||||
// TODO: Hedgehog::Base::TSynchronizedPtr<CApplicationDocument>*
|
// TODO: Hedgehog::Base::TSynchronizedPtr<CApplicationDocument>*
|
||||||
inline static xpointer<CApplicationDocument>* ms_pInstance = (xpointer<CApplicationDocument>*)g_memory.Translate(0x833678A0);
|
inline static xpointer<CApplicationDocument>* ms_pInstance = (xpointer<CApplicationDocument>*)0x1833678A0;
|
||||||
|
|
||||||
// TODO: Hedgehog::Base::TSynchronizedPtr<CApplicationDocument>
|
// TODO: Hedgehog::Base::TSynchronizedPtr<CApplicationDocument>
|
||||||
static CApplicationDocument* GetInstance();
|
static CApplicationDocument* GetInstance();
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,9 @@ namespace SWA
|
||||||
be<uint32_t> m_Score;
|
be<uint32_t> m_Score;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: use g_memory.Translate?
|
||||||
// TODO: Hedgehog::Base::TSynchronizedPtr<CGameDocument>*
|
// TODO: Hedgehog::Base::TSynchronizedPtr<CGameDocument>*
|
||||||
inline static xpointer<CGameDocument>* ms_pInstance = (xpointer<CGameDocument>*)g_memory.Translate(0x83367900);
|
inline static xpointer<CGameDocument>* ms_pInstance = (xpointer<CGameDocument>*)0x183367900;
|
||||||
|
|
||||||
// TODO: Hedgehog::Base::TSynchronizedPtr<CGameDocument>
|
// TODO: Hedgehog::Base::TSynchronizedPtr<CGameDocument>
|
||||||
static CGameDocument* GetInstance();
|
static CGameDocument* GetInstance();
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,9 @@ namespace SWA
|
||||||
class CInputState // : public Hedgehog::Base::CSynchronizedObject
|
class CInputState // : public Hedgehog::Base::CSynchronizedObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
// TODO: use g_memory.Translate?
|
||||||
// TODO: Hedgehog::Base::TSynchronizedPtr<CInputState>*
|
// TODO: Hedgehog::Base::TSynchronizedPtr<CInputState>*
|
||||||
inline static xpointer<CInputState>* ms_pInstance = (xpointer<CInputState>*)g_memory.Translate(0x833671EC);
|
inline static xpointer<CInputState>* ms_pInstance = (xpointer<CInputState>*)0x1833671EC;
|
||||||
|
|
||||||
// TODO: Hedgehog::Base::TSynchronizedPtr<CInputState>
|
// TODO: Hedgehog::Base::TSynchronizedPtr<CInputState>
|
||||||
static CInputState* GetInstance();
|
static CInputState* GetInstance();
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
constexpr float m_baseAspectRatio = 16.0f / 9.0f;
|
constexpr float m_baseAspectRatio = 16.0f / 9.0f;
|
||||||
|
|
||||||
|
uint32_t m_lastCheckpointScore = 0;
|
||||||
|
|
||||||
void Game::Exit()
|
void Game::Exit()
|
||||||
{
|
{
|
||||||
s_isSignalExit = true;
|
s_isSignalExit = true;
|
||||||
|
|
@ -16,6 +18,8 @@ bool GracefulLoopExitMidAsmHook()
|
||||||
return Game::s_isSignalExit;
|
return Game::s_isSignalExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma region Aspect Ratio Hooks
|
||||||
|
|
||||||
bool CameraAspectRatioMidAsmHook(PPCRegister& r31)
|
bool CameraAspectRatioMidAsmHook(PPCRegister& r31)
|
||||||
{
|
{
|
||||||
auto pCamera = (SWA::CCamera*)g_memory.Translate(r31.u32);
|
auto pCamera = (SWA::CCamera*)g_memory.Translate(r31.u32);
|
||||||
|
|
@ -72,6 +76,57 @@ void CSDOffsetMidAsmHook(PPCRegister& f1, PPCRegister& f2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Score Hooks
|
||||||
|
|
||||||
|
/* Hook function for when checkpoints are activated
|
||||||
|
to preserve the current checkpoint score. */
|
||||||
|
PPC_FUNC_IMPL(__imp__sub_82624308);
|
||||||
|
PPC_FUNC(sub_82624308)
|
||||||
|
{
|
||||||
|
__imp__sub_82624308(ctx, base);
|
||||||
|
|
||||||
|
if (Config::ScoreBehaviour != EScoreBehaviour_CheckpointRetain)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto pGameDocument = SWA::CGameDocument::GetInstance();
|
||||||
|
|
||||||
|
if (!pGameDocument)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_lastCheckpointScore = pGameDocument->m_pMember->m_Score;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hook function that resets the score
|
||||||
|
and restore the last checkpoint score. */
|
||||||
|
PPC_FUNC_IMPL(__imp__sub_8245F048);
|
||||||
|
PPC_FUNC(sub_8245F048)
|
||||||
|
{
|
||||||
|
__imp__sub_8245F048(ctx, base);
|
||||||
|
|
||||||
|
if (Config::ScoreBehaviour != EScoreBehaviour_CheckpointRetain)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto pGameDocument = SWA::CGameDocument::GetInstance();
|
||||||
|
|
||||||
|
if (!pGameDocument)
|
||||||
|
return;
|
||||||
|
|
||||||
|
printf("Resetting score to %d\n", m_lastCheckpointScore);
|
||||||
|
|
||||||
|
pGameDocument->m_pMember->m_Score = m_lastCheckpointScore;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResetScoreOnRestartMidAsmHook()
|
||||||
|
{
|
||||||
|
m_lastCheckpointScore = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Miscellaneous Hooks
|
||||||
|
|
||||||
bool DisableHintsMidAsmHook()
|
bool DisableHintsMidAsmHook()
|
||||||
{
|
{
|
||||||
return !Config::Hints;
|
return !Config::Hints;
|
||||||
|
|
@ -91,3 +146,5 @@ PPC_FUNC(sub_825197C0)
|
||||||
|
|
||||||
__imp__sub_825197C0(ctx, base);
|
__imp__sub_825197C0(ctx, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,8 @@ int Window_OnSDLEvent(void*, SDL_Event* event)
|
||||||
|
|
||||||
void Window::Init()
|
void Window::Init()
|
||||||
{
|
{
|
||||||
|
/* TODO: move this since it'll have to change
|
||||||
|
on soft reboot from the options menu. */
|
||||||
auto title = Config::Language == ELanguage_Japanese
|
auto title = Config::Language == ELanguage_Japanese
|
||||||
? "Sonic World Adventure"
|
? "Sonic World Adventure"
|
||||||
: "SONIC UNLEASHED";
|
: "SONIC UNLEASHED";
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ savevmx_64_address = 0x831B34E4
|
||||||
longjmp_address = 0x831B6790
|
longjmp_address = 0x831B6790
|
||||||
setjmp_address = 0x831B6AB0
|
setjmp_address = 0x831B6AB0
|
||||||
|
|
||||||
# These functions do not exist in .pdata and
|
# These functions do not exist in .pdata and do
|
||||||
# not analyze properly due to having jump tables
|
# not analyze properly due to having jump tables
|
||||||
functions = [
|
functions = [
|
||||||
{ address = 0x824E7EF0, size = 0x98 },
|
{ address = 0x824E7EF0, size = 0x98 },
|
||||||
|
|
@ -132,6 +132,10 @@ address = 0x830C0A78
|
||||||
registers = ["f1", "f2"]
|
registers = ["f1", "f2"]
|
||||||
return = true
|
return = true
|
||||||
|
|
||||||
|
[[midasm_hook]]
|
||||||
|
name = "ResetScoreOnRestartMidAsmHook"
|
||||||
|
address = 0x82304374
|
||||||
|
|
||||||
# Disable hint volumes
|
# Disable hint volumes
|
||||||
[[midasm_hook]]
|
[[midasm_hook]]
|
||||||
name = "DisableHintsMidAsmHook"
|
name = "DisableHintsMidAsmHook"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue