summaryrefslogtreecommitdiff
path: root/arm9/src/play_timer.c
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2021-11-11 14:51:54 -0500
committerPikalaxALT <pikalaxalt@gmail.com>2021-11-11 14:51:54 -0500
commit94edcc1b5496a41478e10bd6aa4ff84f5c2ee5aa (patch)
treeab56adaea3a1d2f67a78ecdc4af4805d6ad8d584 /arm9/src/play_timer.c
parent31601eb58e96adc717069135cecbe405dd25c2c1 (diff)
parent2e8f24c114893c871b6295f283d14b087e862b1a (diff)
Merge branch 'pikalax_work' of github.com:PikalaxALT/pokediamond into pikalax_work
Diffstat (limited to 'arm9/src/play_timer.c')
-rw-r--r--arm9/src/play_timer.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/arm9/src/play_timer.c b/arm9/src/play_timer.c
new file mode 100644
index 00000000..9675e179
--- /dev/null
+++ b/arm9/src/play_timer.c
@@ -0,0 +1,37 @@
+
+#include "play_timer.h"
+
+u64 sTimer3Start;
+u64 sUnused;
+u64 sDuration;
+struct IGT * sIGT_p;
+BOOL sTimerActive;
+
+THUMB_FUNC void PlayTimerInit()
+{
+ sTimerActive = FALSE;
+}
+
+THUMB_FUNC void PlayTimerStart(struct IGT *igt)
+{
+ sTimerActive = TRUE;
+ sUnused = 0;
+ sDuration = 0;
+ sIGT_p = igt;
+
+ sTimer3Start = GetTimer3Count();
+}
+
+THUMB_FUNC void PlayTimerUpdate(void)
+{
+ if (sTimerActive)
+ {
+ u64 res = Timer3CountToSeconds(GetTimer3Count() - sTimer3Start);
+
+ if (sDuration < res)
+ {
+ AddIGTSeconds(sIGT_p, (u32)(res - sDuration));
+ sDuration = res;
+ }
+ }
+}