summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYamaArashi <shadow962@live.com>2016-01-31 15:48:09 -0800
committerYamaArashi <shadow962@live.com>2016-01-31 15:48:09 -0800
commitb274bdf7d39a95fb9eca8dc67fc8bba0cb36b554 (patch)
treebb29cef1a63b02fefeacb34597b43b63aa740021 /src
parentb78957167b742f6947ee4379ee60864e7cdc0d36 (diff)
play_time.c
Diffstat (limited to 'src')
-rw-r--r--src/play_time.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/play_time.c b/src/play_time.c
new file mode 100644
index 000000000..f11973d56
--- /dev/null
+++ b/src/play_time.c
@@ -0,0 +1,73 @@
+#include "global.h"
+
+enum
+{
+ STOPPED,
+ RUNNING,
+ MAXED_OUT
+};
+
+extern u8 gPlayTimeCounterState;
+
+void PlayTimeCounter_SetToMax();
+
+void PlayTimeCounter_Reset()
+{
+ gPlayTimeCounterState = STOPPED;
+
+ gSaveBlock2.playTimeHours = 0;
+ gSaveBlock2.playTimeMinutes = 0;
+ gSaveBlock2.playTimeSeconds = 0;
+ gSaveBlock2.playTimeVBlanks = 0;
+}
+
+void PlayTimeCounter_Start()
+{
+ gPlayTimeCounterState = RUNNING;
+
+ if (gSaveBlock2.playTimeHours > 999)
+ PlayTimeCounter_SetToMax();
+}
+
+void PlayTimeCounter_Stop()
+{
+ gPlayTimeCounterState = STOPPED;
+}
+
+void PlayTimeCounter_Update()
+{
+ if (gPlayTimeCounterState == 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()
+{
+ gPlayTimeCounterState = MAXED_OUT;
+ gSaveBlock2.playTimeHours = 999;
+ gSaveBlock2.playTimeMinutes = 59;
+ gSaveBlock2.playTimeSeconds = 59;
+ gSaveBlock2.playTimeVBlanks = 59;
+}