Skip to content

Commit

Permalink
Merge pull request #89 from imaandrew/timer
Browse files Browse the repository at this point in the history
Save timer mode in settings
  • Loading branch information
JCog authored Sep 24, 2024
2 parents 99082ea + eab4dfb commit 327706d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/fp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
19 changes: 9 additions & 10 deletions src/fp/practice/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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");
Expand Down Expand Up @@ -154,15 +153,15 @@ 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) {
timerCutsceneCount = timerCutsceneTarget;
} else if (timerState == TIMER_STOPPED) {
timerState = TIMER_WAITING;
timerCutsceneCount = 0;
if (timerMode != TIMER_MANUAL) {
if (settings->timerMode != TIMER_MANUAL) {
fpLog("timer set to start");
}
}
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/sys/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/sys/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 327706d

Please sign in to comment.