diff --git a/include/functions.h b/include/functions.h index c29dc246d7..364073459b 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2129,8 +2129,8 @@ void func_80121FC4(GlobalContext* globalCtx); Path* Path_GetByIndex(GlobalContext* globalCtx, s16 index, s16 max); f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw); void Path_CopyLastPoint(Path* path, Vec3f* dest); -// void func_80122660(void); -// UNK_TYPE4 func_80122670(s32* param_1, Input* input); +void FrameAdvance_Init(FrameAdvanceContext* frameAdvCtx); +s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, Input* input); // void func_801226E0(void); void func_80122744(GlobalContext* globalCtx, UNK_PTR arg1, u32 arg2, Vec3s* arg3); s32 func_80122760(GlobalContext* globalCtx, UNK_PTR arg1, f32 arg2); diff --git a/src/code/z_pause.c b/src/code/z_pause.c index 44be6238af..bb5b33cf2f 100644 --- a/src/code/z_pause.c +++ b/src/code/z_pause.c @@ -1,5 +1,39 @@ +/* + * File: z_pause.c + * Description: Frame Advance debug feature + * + * This allows you to advance through the game one frame at a time on command. + * To advance a frame, hold Z and press R on the specified controller (see z_play). + * Holding Z and R will advance a frame every half second. + * + * Note: While the system is fully hooked up, there is no way to enable it in game + * Instead one would have to add something like: + * + * if (CHECK_BTN_ALL(input->cur.button, BTN_R) && CHECK_BTN_ALL(input->press.button, BTN_DDOWN)) { + * frameAdvCtx->enabled = !frameAdvCtx->enabled; + * } + * + * to the start of FrameAdvance_Update, which would allow the system to be toggled on and off by holding R + * and pressing Dpad Down on the specified controller. + * + * Note2: Controllers 2-4's inputs are normally zeroed out, so this would also need to be fixed to use frame advance + */ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_pause/func_80122660.s") +void FrameAdvance_Init(FrameAdvanceContext* frameAdvCtx) { + frameAdvCtx->timer = 0; + frameAdvCtx->enabled = false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_pause/func_80122670.s") +/* + * Returns true when frame advance is not active (game will run normally) + */ +s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, Input* input) { + if (!frameAdvCtx->enabled || (CHECK_BTN_ALL(input->cur.button, BTN_Z) && + (CHECK_BTN_ALL(input->press.button, BTN_R) || + (CHECK_BTN_ALL(input->cur.button, BTN_R) && (++frameAdvCtx->timer >= 9))))) { + frameAdvCtx->timer = 0; + return true; + } + return false; +} diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 79a254d428..642970ff4e 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2170,8 +2170,8 @@ 0x801224E0:("Path_GetByIndex",), 0x80122524:("Path_OrientAndGetDistSq",), 0x801225CC:("Path_CopyLastPoint",), - 0x80122660:("func_80122660",), - 0x80122670:("func_80122670",), + 0x80122660:("FrameAdvance_Init",), + 0x80122670:("FrameAdvance_Update",), 0x801226E0:("func_801226E0",), 0x80122744:("func_80122744",), 0x80122760:("func_80122760",),