summaryrefslogtreecommitdiff
path: root/src/engine/play_time.c
diff options
context:
space:
mode:
authorcamthesaxman <cameronghall@cox.net>2017-11-08 17:25:26 -0600
committercamthesaxman <cameronghall@cox.net>2017-11-08 17:25:26 -0600
commitfc11078cef11edc9deedd08c6175fb5e6628504c (patch)
tree62823b5dc1335a4d8659104dc4156713674ce757 /src/engine/play_time.c
parentba06c424c974f18f9c4af85eb0ffe8adc6056941 (diff)
parent8832b766facd48c85c1b99ac6dad555f1e2aa1c7 (diff)
fix merge conflicts
Diffstat (limited to 'src/engine/play_time.c')
-rw-r--r--src/engine/play_time.c73
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;
+}