summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkipcode66 <kipcode66@gmail.com>2022-07-17 17:54:58 -0400
committerkipcode66 <kipcode66@gmail.com>2022-07-17 17:54:58 -0400
commitcb105e61b5835bfb48d611edc37f644afc99e546 (patch)
treeb1c10dbedff60ae10700fd01222c5fa04ef18c57
parentaa595cb276d87a4801ce930c755adeb918370254 (diff)
fix: frame advance holdfix_hold
-rw-r--r--include/controller.h1
-rw-r--r--src/controller.cpp8
-rw-r--r--src/gz_flags.cpp20
3 files changed, 8 insertions, 21 deletions
diff --git a/include/controller.h b/include/controller.h
index 0f2a68f..1af24cb 100644
--- a/include/controller.h
+++ b/include/controller.h
@@ -40,6 +40,7 @@ enum GZPad {
#endif
bool GZ_getButtonRepeat(int idx);
+bool GZ_getButtonRepeat(int idx, uint16_t repeat_time, uint16_t repeat_delay);
bool GZ_getButtonRepeat(int idx, uint16_t repeat_time);
bool GZ_getButtonPressed(int idx);
bool GZ_getButtonHold(int idx, int phase = 0);
diff --git a/src/controller.cpp b/src/controller.cpp
index 2d52e83..5577809 100644
--- a/src/controller.cpp
+++ b/src/controller.cpp
@@ -122,15 +122,19 @@ bool GZ_getButtonPressed(int idx) {
return buttonStates[idx].is_down;
}
-bool GZ_getButtonRepeat(int idx, uint16_t repeat_time) {
+bool GZ_getButtonRepeat(int idx, uint16_t repeat_time, uint16_t repeat_delay) {
auto delta = cCt_getFrameCount() - buttonStates[idx].pressed_frame;
auto just_clicked = delta == 0;
- auto held_down_long_enough = delta > REPEAT_DELAY;
+ auto held_down_long_enough = delta > repeat_delay;
auto is_repeat_frame = held_down_long_enough && delta % repeat_time == 0;
auto down = GZ_getButtonPressed(idx);
return down && (just_clicked || is_repeat_frame);
}
+bool GZ_getButtonRepeat(int idx, uint16_t repeat_time) {
+ return GZ_getButtonRepeat(idx, repeat_time, REPEAT_DELAY);
+}
+
bool GZ_getButtonRepeat(int idx) {
return GZ_getButtonRepeat(idx, REPEAT_TIME);
}
diff --git a/src/gz_flags.cpp b/src/gz_flags.cpp
index 79266bb..88c208e 100644
--- a/src/gz_flags.cpp
+++ b/src/gz_flags.cpp
@@ -40,40 +40,22 @@ GZFlag g_gzFlags[MAX_GZ_FLAGS] = {
};
void GZ_frameAdvance() {
- static int holdCounter = 0;
sPauseTimer = 1;
#ifdef GCN_PLATFORM
tp_cPadInfo[0].mPressedButtonFlags = tp_cPadInfo[0].mButtonFlags;
-
- if (tp_cPadInfo[0].mButtonFlags & CButton::R) {
- holdCounter++;
- } else {
- holdCounter = 0;
- }
#endif
#ifdef WII_PLATFORM
tp_mPad.mHoldButton &= ~FRAME_ADVANCE_PAD;
tp_mPad.mTrigButton = tp_mPad.mHoldButton;
-
- if (tp_mPad.mHoldButton & CButton::TWO) {
- holdCounter++;
- } else {
- holdCounter = 0;
- }
#endif
- if (GZ_getButtonTrig(FRAME_ADVANCE_BTN)) {
+ if (GZ_getButtonRepeat(FRAME_ADVANCE_BTN, 1, 30)) {
// this sets pause timer to 0 for 1 frame,
// which lets 1 frame pass before pausing again
sPauseTimer = 0;
}
-
- // frames start passing at normal speed after holding for 30 frames
- if (holdCounter >= 30) {
- sPauseTimer = 0;
- }
}
void GZ_drawFrameTex(Texture* pauseTex, Texture* playTex) {