From 98ba231fb016a7158cc14af52c96ab408644d317 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 19 Dec 2021 11:54:52 -0800 Subject: pause (Frame Advance) OK (#455) * Matched * Rename and format * typo * Missed renames * Revert "Missed renames" This reverts commit 64d9f7046407eac71b849420457968e3b38fc4d8. * Revert "typo" This reverts commit 81696364d3db71b6085fda1aa99855def390628e. * Revert "Rename and format" This reverts commit aec7d245e896777d70eb7024c336f76ed2a32c7f. * Rename functions * Add header explaining frame advance * Header * Format --- src/code/z_pause.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'src/code') diff --git a/src/code/z_pause.c b/src/code/z_pause.c index 44be6238a..bb5b33cf2 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; +} -- cgit v1.2.3