From eab4dfb94c62efe0f80b094e9a0dd55da40993fb Mon Sep 17 00:00:00 2001 From: imaandrew <14946103+imaandrew@users.noreply.github.com> Date: Mon, 5 Aug 2024 21:52:09 -0400 Subject: [PATCH] Save timer mode in settings --- src/fp.c | 2 +- src/fp/practice/timer.c | 19 +++++++++---------- src/sys/settings.c | 1 + src/sys/settings.h | 2 ++ 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/fp.c b/src/fp.c index 9f456d33..2c706584 100644 --- a/src/fp.c +++ b/src/fp.c @@ -289,7 +289,7 @@ void fpDrawTimer(struct GfxFont *font, s32 cellWidth, s32 cellHeight, u8 menuAlp } gfxPrintf(font, x, y + cellHeight, "%d", timerLagFrames); - if (timerMode != TIMER_MANUAL) { + if (settings->timerMode != TIMER_MANUAL) { gfxPrintf(font, x, y + cellHeight * 2, "%d/%d", timerCutsceneCount, timerCutsceneTarget); } } diff --git a/src/fp/practice/timer.c b/src/fp/practice/timer.c index 155eea1c..aeec199e 100644 --- a/src/fp/practice/timer.c +++ b/src/fp/practice/timer.c @@ -5,7 +5,6 @@ #include "sys/gfx.h" #include "sys/settings.h" -enum TimerMode timerMode = 0; enum TimerState timerState = 0; s64 timerCount = 0; s32 timerLagFrames = 0; @@ -60,7 +59,7 @@ static s32 timerDrawProc(struct MenuItem *item, struct MenuDrawParams *drawParam gfxPrintf(font, x, y, "timer %d.%02d", seconds, hundredths); } gfxPrintf(font, x, y + chHeight, "lag %d", timerLagFrames >= 0 ? timerLagFrames : 0); - if (timerMode != TIMER_MANUAL) { + if (settings->timerMode != TIMER_MANUAL) { gfxPrintf(font, x, y + chHeight * 2, "cs/lz %d/%d", timerCutsceneCount, timerCutsceneTarget); } return 1; @@ -96,15 +95,15 @@ void timerUpdate(void) { switch (timerState) { case TIMER_WAITING: - if (timerMode == TIMER_LOADING_ZONE) { + if (settings->timerMode == TIMER_LOADING_ZONE) { if (newMap) { newMapWaiting = TRUE; } } else { newMapWaiting = FALSE; } - if (timerMode == TIMER_MANUAL || (prevCutsceneState && !inCutscene)) { - if (timerMode == TIMER_LOADING_ZONE && !newMapWaiting) { + if (settings->timerMode == TIMER_MANUAL || (prevCutsceneState && !inCutscene)) { + if (settings->timerMode == TIMER_LOADING_ZONE && !newMapWaiting) { break; } timerState = TIMER_RUNNING; @@ -118,12 +117,12 @@ void timerUpdate(void) { } break; case TIMER_RUNNING: - if (timerMode == TIMER_CUTSCENE && !prevCutsceneState && inCutscene) { + if (settings->timerMode == TIMER_CUTSCENE && !prevCutsceneState && inCutscene) { timerCutsceneCount++; if (settings->timerLogging && timerCutsceneCount != timerCutsceneTarget) { fpLog("cutscene started"); } - } else if (timerMode == TIMER_LOADING_ZONE && newMap) { + } else if (settings->timerMode == TIMER_LOADING_ZONE && newMap) { timerCutsceneCount++; if (settings->timerLogging && timerCutsceneCount != timerCutsceneTarget) { fpLog("loading zone"); @@ -154,7 +153,7 @@ void timerUpdate(void) { void timerStartStop(void) { if (timerState == TIMER_INACTIVE) { timerState = TIMER_WAITING; - if (timerMode != TIMER_MANUAL) { + if (settings->timerMode != TIMER_MANUAL) { fpLog("timer set to start"); } } else if (timerState == TIMER_RUNNING) { @@ -162,7 +161,7 @@ void timerStartStop(void) { } else if (timerState == TIMER_STOPPED) { timerState = TIMER_WAITING; timerCutsceneCount = 0; - if (timerMode != TIMER_MANUAL) { + if (settings->timerMode != TIMER_MANUAL) { fpLog("timer set to start"); } } @@ -196,7 +195,7 @@ void createTimerMenu(struct Menu *menu) { "cutscene\0" "loading zone\0" "manual\0", - menuWordOptionmodProc, &timerMode); + menuWordOptionmodProc, &settings->timerMode); menuAddStatic(menu, 0, y, "cs/lz count", 0xC0C0C0); menuAddIntinput(menu, menuX, y++, 10, 2, menuByteModProc, &timerCutsceneTarget); menuAddStatic(menu, 0, y, "show timer", 0xC0C0C0); diff --git a/src/sys/settings.c b/src/sys/settings.c index 02fdce0c..ef13c587 100644 --- a/src/sys/settings.c +++ b/src/sys/settings.c @@ -32,6 +32,7 @@ void settingsLoadDefault(void) { struct SettingsData *d = &settingsStore.data; d->cheats = 0; + d->timerMode = 0; d->menuFontResource = RES_FONT_PRESSSTART2P; d->menuDropShadow = 1; d->menuBackground = 1; diff --git a/src/sys/settings.h b/src/sys/settings.h index 95104293..6b53d85b 100644 --- a/src/sys/settings.h +++ b/src/sys/settings.h @@ -2,6 +2,7 @@ #define SETTINGS_H #include "commands.h" #include "common.h" +#include "fp/practice/timer.h" #define SETTINGS_SAVE_FILE_SIZE 0x1380 #define SETTINGS_PROFILE_MAX 4 @@ -39,6 +40,7 @@ struct SettingsData { /* order elements by size for space-efficient packing */ u32 watchAddress[SETTINGS_WATCHES_MAX]; u32 cheats; + enum TimerMode timerMode; s16 menuX; s16 menuY; s16 inputDisplayX;