-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathmain.cpp
73 lines (61 loc) · 2.21 KB
/
main.cpp
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
#include <3ds.h>
#include "menu.hpp"
#include "hint_list.hpp"
#include "item_list.hpp"
#include "item_location.hpp"
#include "location_access.hpp"
#include "music.hpp"
#define TICKS_PER_SEC 268123480.0
int main() {
gfxInitDefault();
HintTable_Init();
ItemTable_Init();
LocationTable_Init();
MenuInit();
u64 initialHoldTime = svcGetSystemTick();
u64 intervalTime = initialHoldTime;
while (aptMainLoop()) {
hidScanInput();
u32 kDown = hidKeysDown();
u32 kHeld = hidKeysHeld();
if (kDown & KEY_SELECT)
break; // stop the app
// Time calculations for menu scrolling
bool updatedByHeld = false;
if (kHeld & KEY_DOWN || kHeld & KEY_UP || kHeld & KEY_LEFT || kHeld & KEY_RIGHT) {
float totalHoldTime = (svcGetSystemTick() - initialHoldTime) / TICKS_PER_SEC;
float intervalElapsedTime = (svcGetSystemTick() - intervalTime) / TICKS_PER_SEC;
if (intervalElapsedTime > 0.09 && totalHoldTime > 0.4) {
kDown |= kHeld & (KEY_UP | KEY_DOWN | KEY_LEFT | KEY_RIGHT); // add input to kDown for simplicity
intervalTime = svcGetSystemTick();
updatedByHeld = true;
}
} else {
initialHoldTime = svcGetSystemTick();
}
// send inputs off to the menu
if (kDown)
MenuUpdate(kDown, updatedByHeld, kHeld);
// launch oot3d directly by holding L and R (cartridge only)
if (kHeld & KEY_L && kHeld & KEY_R) {
s64 playingOnCitra = 0;
// Type 0x20000 only exists on Citra, where parameter 0 returns 1
svcGetSystemInfo(&playingOnCitra, 0x20000, 0);
if (!playingOnCitra) {
if (Settings::Region == REGION_NA) {
aptSetChainloader(0x0004000000033500, 2);
} else if (Settings::Region == REGION_EUR) {
aptSetChainloader(0x0004000000033600, 2);
}
break;
}
}
// Flush and swap framebuffers
gfxFlushBuffers();
gfxSwapBuffers();
// Wait for VBlank
gspWaitForVBlank();
}
gfxExit();
return 0;
}