Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with pause buffer input window on save prompt close #4975

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions soh/soh/Enhancements/Restorations/PauseBufferInputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,22 @@ static u16 pauseInputs = 0;
#define PAUSE_STATE_OFF 0
#define PAUSE_STATE_OPENING_1 2
#define PAUSE_STATE_UNPAUSE_SETUP 18
#define PAUSE_STATE_SAVEPROMPT 7

void RegisterPauseBufferInputs() {
COND_VB_SHOULD(VB_KALEIDO_UNPAUSE_CLOSE, CVAR_BUFFER_VALUE || CVAR_INCLUDE_VALUE, {
Input* input = &gPlayState->state.input[0];

// Store all inputs that were pressed during the buffer window
pauseInputs |= input->press.button;

// If the user opts to include held inputs in the buffer window, store the held inputs, minus the held inputs when the pause menu was opened
// STEP #3: If the user opts to include held inputs in the buffer window, store the currnently held inputs, minus
// the held inputs when the pause menu was opened. This only applies to the first frame of the buffer window
if (CVAR_INCLUDE_VALUE && inputBufferTimer == 0) {
pauseInputs |= input->cur.button & ~prePauseInputs;
prePauseInputs = 0;
}

// STEP #4: Store all inputs that were pressed during the buffer window
pauseInputs |= input->press.button;

// Wait a specified number of frames before continuing the unpause
inputBufferTimer++;
if (inputBufferTimer < CVAR_BUFFER_VALUE) {
Expand All @@ -54,28 +56,32 @@ void RegisterPauseBufferInputs() {
Input* input = &gPlayState->state.input[0];
PauseContext* pauseCtx = &gPlayState->pauseCtx;

// if the input buffer timer is not 0 and the pause state is off, then the player just unpaused
if (inputBufferTimer != 0 && pauseCtx->state == PAUSE_STATE_OFF) {
// STEP #1: If the user opts to include held inputs in the buffer window, store the held inputs at the beginning
// of the pause process, minus the START input
if (pauseCtx->state == PAUSE_STATE_OPENING_1 && CVAR_INCLUDE_VALUE) {
prePauseInputs = input->cur.button & ~BTN_START;
}

// STEP #2: The unpause process has begun, so let's reset the input buffer timer
if (pauseCtx->state == PAUSE_STATE_UNPAUSE_SETUP || (
pauseCtx->state == PAUSE_STATE_SAVEPROMPT && (pauseCtx->unk_1EC == 2 || pauseCtx->unk_1EC == 5)
)) {
inputBufferTimer = 0;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be nice to have a little "where are steps 3 and 4????" comment in here

// STEP #5: If the input buffer timer is not 0 and the pause state is off, then the player just unpaused
if (inputBufferTimer != 0 && pauseCtx->state == PAUSE_STATE_OFF) {
// If the user opts into easy frame advance, remove START input
if (CVAR_FRAME_ADVANCE_VALUE) {
pauseInputs &= ~BTN_START;
}

// So we need to re-apply the inputs that were pressed during the buffer window
input->press.button |= pauseInputs;
}

// Reset the timer and stored inputs at the beginning of the unpause process
if (pauseCtx->state == PAUSE_STATE_UNPAUSE_SETUP && pauseCtx->unk_1F4 != 160.0f) {
inputBufferTimer = 0;
// Reset the used variables
pauseInputs = 0;
}

// If the user opts to include held inputs in the buffer window, store the held inputs at the beginning of the pause process, minus the START input
if (pauseCtx->state == PAUSE_STATE_OPENING_1 && CVAR_INCLUDE_VALUE) {
prePauseInputs = input->cur.button & ~BTN_START;
inputBufferTimer = 0;
}
});
}
Expand Down
Loading