2016-01-07 13:48:45 +01:00
|
|
|
#include <coreinit/core.h>
|
2016-01-06 00:24:54 +01:00
|
|
|
#include <coreinit/debug.h>
|
2016-01-07 13:48:45 +01:00
|
|
|
#include <coreinit/thread.h>
|
2016-07-27 09:42:14 +02:00
|
|
|
#include <coreinit/foreground.h>
|
|
|
|
#include <proc_ui/procui.h>
|
2016-07-28 02:49:43 +02:00
|
|
|
#include <sysapp/launch.h>
|
2016-07-27 09:42:14 +02:00
|
|
|
|
|
|
|
bool isAppRunning = true;
|
|
|
|
|
|
|
|
void
|
|
|
|
SaveCallback()
|
|
|
|
{
|
|
|
|
OSSavesDone_ReadyToRelease(); // Required
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
AppRunning()
|
|
|
|
{
|
|
|
|
if(!OSIsMainCore())
|
|
|
|
{
|
|
|
|
ProcUISubProcessMessages(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ProcUIStatus status = ProcUIProcessMessages(true);
|
|
|
|
|
|
|
|
if(status == PROCUI_STATUS_EXITING)
|
|
|
|
{
|
|
|
|
// Being closed, deinit, free, and prepare to exit
|
|
|
|
isAppRunning = false;
|
|
|
|
ProcUIShutdown();
|
|
|
|
}
|
|
|
|
else if(status == PROCUI_STATUS_RELEASE_FOREGROUND)
|
|
|
|
{
|
|
|
|
// Free up MEM1 to next foreground app, deinit screen, etc.
|
|
|
|
ProcUIDrawDoneRelease();
|
|
|
|
}
|
|
|
|
else if(status == PROCUI_STATUS_IN_FOREGROUND)
|
|
|
|
{
|
|
|
|
// Executed while app is in foreground
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return isAppRunning;
|
|
|
|
}
|
2015-12-27 03:22:53 +01:00
|
|
|
|
2016-01-07 13:48:45 +01:00
|
|
|
int
|
|
|
|
CoreEntryPoint(int argc, const char **argv)
|
2015-12-27 03:22:53 +01:00
|
|
|
{
|
2016-01-07 13:48:45 +01:00
|
|
|
OSReport("Hello world from %s", argv[0]);
|
|
|
|
return argc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
2016-07-27 09:42:14 +02:00
|
|
|
ProcUIInit(&SaveCallback);
|
2016-01-07 13:48:45 +01:00
|
|
|
OSReport("Main thread running on core %d", OSGetCoreId());
|
|
|
|
|
|
|
|
// Run thread on core 0
|
|
|
|
OSThread *threadCore0 = OSGetDefaultThread(0);
|
|
|
|
|
|
|
|
const char *core0Args[] = {
|
|
|
|
"Core 0"
|
|
|
|
};
|
|
|
|
|
|
|
|
OSRunThread(threadCore0, CoreEntryPoint, 0, core0Args);
|
|
|
|
|
|
|
|
// Run thread on core 2
|
|
|
|
OSThread *threadCore2 = OSGetDefaultThread(2);
|
|
|
|
|
|
|
|
const char *core2Args[] = {
|
|
|
|
"Core 2"
|
|
|
|
};
|
|
|
|
|
|
|
|
OSRunThread(threadCore2, CoreEntryPoint, 2, core2Args);
|
|
|
|
|
|
|
|
// Wait for threads to return
|
|
|
|
int resultCore0 = -1, resultCore2 = -1;
|
|
|
|
OSJoinThread(threadCore0, &resultCore0);
|
|
|
|
OSJoinThread(threadCore2, &resultCore2);
|
|
|
|
|
|
|
|
OSReport("Core 0 thread returned %d", resultCore0);
|
|
|
|
OSReport("Core 2 thread returned %d", resultCore2);
|
2016-07-27 09:42:14 +02:00
|
|
|
|
2016-07-28 02:49:43 +02:00
|
|
|
// Sends messages for ProcUI to release foreground, exit
|
|
|
|
// and launch into the system menu immediately.
|
|
|
|
SYSLaunchMenu();
|
|
|
|
|
2016-07-27 09:42:14 +02:00
|
|
|
while(AppRunning());
|
2016-01-07 13:48:45 +01:00
|
|
|
return 0;
|
2015-12-27 03:22:53 +01:00
|
|
|
}
|