summaryrefslogtreecommitdiff
path: root/arm9/src/play_timer.c
blob: 9675e179246dd8add0252af9aa96c4aeb5b85bd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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;
        }
    }
}