Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Rubberduckycooly
GitHub Repository: Rubberduckycooly/RSDKv5-Decompilation
Path: blob/master/RSDKv5/RSDK/User/NX/NXCore.cpp
1163 views
1
#if RETRO_REV02
2
3
// release switch has the stack and other stuff predefined for the loop thread to use
4
// issue is it MUST be page-aligned (& 0xFFF of location must be 0), which we don't know how to do
5
// so bc we're using libNX we can pass null for it to do it for us
6
// uint8 messageLoopThreadStack[16384];
7
8
// Thread messageLoopThread;
9
10
// normally this func looks a little different
11
// but libNX sucks and won't properly thread things for us
12
// 4 am note: this literally doesn't work anyway fuck libNX we do a hack at the bottom
13
void MessageLoopThreadCB(SKU::NXCore *core)
14
{
15
uint32 msg = 0;
16
uint32 unknown = 0;
17
18
while (R_SUCCEEDED(appletGetMessage(&msg))) {
19
appletProcessMessage(msg);
20
PrintLog(PRINT_NORMAL, "yo whatup %d", msg);
21
22
switch (msg) {
23
case AppletMessage_ExitRequest: unknown = 1; break;
24
25
case AppletMessage_FocusStateChanged:
26
core->focusState = appletGetFocusState();
27
if (engine.inFocus)
28
engine.inFocus = (core->focusState == AppletFocusState_InFocus) ? 1 : 2;
29
break;
30
31
case AppletMessage_Resume:
32
// sub_71002813BC();
33
break;
34
35
case AppletMessage_OperationModeChanged:
36
// if (appletGetOperationMode == AppletOperationMode_Console)
37
// sub_71002813BC();
38
break;
39
40
case AppletMessage_PerformanceModeChanged: break;
41
42
default: PrintLog(PRINT_NORMAL, "Unhandled message = 0x%08x\n", msg); break;
43
}
44
}
45
}
46
47
SKU::NXCore *InitNXCore()
48
{
49
// Initalize API subsystems
50
NXCore *core = new NXCore;
51
52
if (achievements)
53
delete achievements;
54
achievements = new NXAchievements;
55
56
if (leaderboards)
57
delete leaderboards;
58
leaderboards = new NXLeaderboards;
59
60
if (richPresence)
61
delete richPresence;
62
richPresence = new NXRichPresence;
63
64
if (stats)
65
delete stats;
66
stats = new NXStats;
67
68
if (userStorage)
69
delete userStorage;
70
userStorage = new NXUserStorage;
71
72
// Setup default values
73
74
memset(core->values, 0, sizeof(core->values));
75
core->values[0] = false;
76
core->valueCount = 1;
77
78
core->focusState = appletGetFocusState();
79
if (engine.inFocus)
80
engine.inFocus = (core->focusState == AppletFocusState_InFocus) ? 1 : 2;
81
appletSetFocusHandlingMode(AppletFocusHandlingMode_NoSuspend);
82
// nn::oe::SetResumeNotificationEnabled(true);
83
// nn::oe::SetOperationModeChangedNotificationEnabled(true);
84
85
// int32 rc = threadCreate(&messageLoopThread, MessageLoopThreadCB, userCore, NULL, 0x4000, 28, -2);
86
// PrintLog(PRINT_NORMAL, "%d %d", R_MODULE(rc), R_DESCRIPTION(rc));
87
88
// threadStart(&messageLoopThread);
89
90
return core;
91
}
92
93
void NXCore::FrameInit()
94
{
95
MessageLoopThreadCB(this);
96
97
// hack to ensure focus state
98
this->focusState = appletGetFocusState();
99
if (engine.inFocus)
100
engine.inFocus = (this->focusState == AppletFocusState_InFocus) ? 1 : 2;
101
102
UserCore::FrameInit();
103
}
104
#endif
105
106