summaryrefslogtreecommitdiff
path: root/arm9/src/igt.c
blob: 843ef396b48f5d510e39666dc6d7d4949269d114 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "global.h"
#include "igt.h"

#pragma thumb on

void InitIGT(struct IGT * igt)
{
    igt->hours = 0;
    igt->minutes = 0;
    igt->seconds = 0;
}

void AddIGTSeconds(struct IGT * igt, u32 to_add)
{
    u32 hours, minutes, seconds;
    if (igt->hours == 999 && igt->minutes == 59 && igt->seconds == 59)
        return;
    seconds = (u32)(igt->seconds + to_add);
    minutes = (u32)igt->minutes;
    hours = (u32)igt->hours;
    if (seconds > 59)
    {
        minutes += seconds / 60;
        seconds %= 60;
        if (minutes > 59)
        {
            hours += minutes / 60;
            minutes %= 60;
            if (hours >= 999)
            {
                hours = 999;
                minutes = 59;
                seconds = 59;
            }
        }
    }
    igt->hours = (u16)hours;
    igt->minutes = (u8)minutes;
    igt->seconds = (u8)seconds;
}

u16 GetIGTHours(struct IGT * igt)
{
    return igt->hours;
}

u8 GetIGTMinutes(struct IGT * igt)
{
    return igt->minutes;
}