diff options
author | camthesaxman <cameronghall@cox.net> | 2017-10-01 00:21:17 -0500 |
---|---|---|
committer | camthesaxman <cameronghall@cox.net> | 2017-10-01 00:21:17 -0500 |
commit | 1a8b3fa9af2c248bd40e72ae467b45ba888e31bf (patch) | |
tree | 66dec9ad8b1eac336690eda0c0438779012d28e2 /src/engine/play_time.c | |
parent | 30bc88f6572c435ff49b62f16c3734c12f75f7f0 (diff) | |
parent | 83efcc9c3d1e81b78c2cd9ceab3ac6420a5f4070 (diff) |
move sound_check_menu.c to debug
Diffstat (limited to 'src/engine/play_time.c')
-rw-r--r-- | src/engine/play_time.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/engine/play_time.c b/src/engine/play_time.c new file mode 100644 index 000000000..9882c9c4b --- /dev/null +++ b/src/engine/play_time.c @@ -0,0 +1,73 @@ +#include "global.h" +#include "play_time.h" + +enum +{ + STOPPED, + RUNNING, + MAXED_OUT +}; + +static u8 sPlayTimeCounterState; + +void PlayTimeCounter_Reset() +{ + sPlayTimeCounterState = STOPPED; + + gSaveBlock2.playTimeHours = 0; + gSaveBlock2.playTimeMinutes = 0; + gSaveBlock2.playTimeSeconds = 0; + gSaveBlock2.playTimeVBlanks = 0; +} + +void PlayTimeCounter_Start() +{ + sPlayTimeCounterState = RUNNING; + + if (gSaveBlock2.playTimeHours > 999) + PlayTimeCounter_SetToMax(); +} + +void PlayTimeCounter_Stop() +{ + sPlayTimeCounterState = STOPPED; +} + +void PlayTimeCounter_Update() +{ + if (sPlayTimeCounterState == RUNNING) + { + gSaveBlock2.playTimeVBlanks++; + + if (gSaveBlock2.playTimeVBlanks > 59) + { + gSaveBlock2.playTimeVBlanks = 0; + gSaveBlock2.playTimeSeconds++; + + if (gSaveBlock2.playTimeSeconds > 59) + { + gSaveBlock2.playTimeSeconds = 0; + gSaveBlock2.playTimeMinutes++; + + if (gSaveBlock2.playTimeMinutes > 59) + { + gSaveBlock2.playTimeMinutes = 0; + gSaveBlock2.playTimeHours++; + + if (gSaveBlock2.playTimeHours > 999) + PlayTimeCounter_SetToMax(); + } + } + } + } +} + +void PlayTimeCounter_SetToMax() +{ + sPlayTimeCounterState = MAXED_OUT; + + gSaveBlock2.playTimeHours = 999; + gSaveBlock2.playTimeMinutes = 59; + gSaveBlock2.playTimeSeconds = 59; + gSaveBlock2.playTimeVBlanks = 59; +} |