forked from AnalogMan151/sumoCheatMenu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
time_modifiers.c
77 lines (60 loc) · 1.87 KB
/
time_modifiers.c
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Filename: time_modifiers.c
#include "cheats.h"
#include "hid.h"
/********************************
* *
* Time Modifiers *
* *
********************************/
char currentTime[40] = "Undefined";
// Time menu entry
void timeMenu(void) {
updateTime();
new_spoiler("Time");
new_unselectable_entry(currentTime);
new_separator();
new_entry_managed("Increase Hour +1", increaseTime, INCREASETIME, AUTO_DISABLE);
new_entry_managed("Decrease Hour -1", decreaseTime, DECREASETIME, AUTO_DISABLE);
new_line();
exit_spoiler();
}
// Reads current time offset and prints it to the menu
void updateTime(void) {
u32 timeOffset = READU32(0x330D9238);
char timeType[4] = "NULL";
int timeHours = 0;
timeOffset = timeOffset / 3600;
if (timeOffset == 24) {
xsprintf(timeType, "Sun");
timeHours = 0;
} else if (timeOffset < 12) {
xsprintf(timeType, "Sun");
timeHours = timeOffset;
} else if (timeOffset >= 12) {
xsprintf(timeType, "Moon");
timeHours = timeOffset - 12;
}
xsprintf(currentTime, "Current: %4s Time +%-2d hours", timeType, timeHours);
}
// Increases time offset by one hour and rolls over if at max
void increaseTime(void) {
u32 timeOffset = READU32(0x330D9238);
timeOffset = timeOffset / 3600;
if (timeOffset == 24)
timeOffset = 1;
else
timeOffset += 1;
WRITEU32(0x330D9238, timeOffset * 3600);
updateTime();
}
// Decreases time offset by one hour and rolls over if at min
void decreaseTime(void) {
u32 timeOffset = READU32(0x330D9238);
timeOffset = timeOffset / 3600;
if (timeOffset == 1)
timeOffset = 24;
else
timeOffset -= 1;
WRITEU32(0x330D9238, timeOffset * 3600);
updateTime();
}