2022-03-21 21:51:23 -04:00
|
|
|
#include "global.h"
|
|
|
|
|
|
|
|
void FrameAdvance_Init(FrameAdvanceContext* frameAdvCtx) {
|
|
|
|
frameAdvCtx->timer = 0;
|
|
|
|
frameAdvCtx->enabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Frame advance allows you to advance through the game one frame at a time on command.
|
|
|
|
* To enable, hold R and press Dpad Down on the specified controller.
|
|
|
|
* To advance a frame, hold Z and press R.
|
|
|
|
* Holding Z and R will advance a frame every half second.
|
|
|
|
*
|
|
|
|
* This function returns true when frame advance is not active (game will run normally)
|
|
|
|
*/
|
|
|
|
s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, Input* input) {
|
|
|
|
if (CHECK_BTN_ALL(input->cur.button, BTN_R) && CHECK_BTN_ALL(input->press.button, BTN_DDOWN)) {
|
|
|
|
frameAdvCtx->enabled = !frameAdvCtx->enabled;
|
|
|
|
}
|
|
|
|
|
2023-12-26 19:08:37 -05:00
|
|
|
if (!frameAdvCtx->enabled || CVarGetInteger("gFrameAdvance", 0) || (CHECK_BTN_ALL(input->cur.button, BTN_Z) &&
|
2022-03-21 21:51:23 -04:00
|
|
|
(CHECK_BTN_ALL(input->press.button, BTN_R) ||
|
|
|
|
(CHECK_BTN_ALL(input->cur.button, BTN_R) && (++frameAdvCtx->timer >= 9))))) {
|
2023-12-26 19:08:37 -05:00
|
|
|
CVarClear("gFrameAdvance");
|
2022-03-21 21:51:23 -04:00
|
|
|
frameAdvCtx->timer = 0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|