2015-02-25 16:28:30 +01:00
|
|
|
#include <string.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <3ds.h>
|
|
|
|
|
2015-11-21 18:55:51 +01:00
|
|
|
Thread threadHandle;
|
|
|
|
Handle threadRequest;
|
2015-02-25 16:28:30 +01:00
|
|
|
|
|
|
|
#define STACKSIZE (4 * 1024)
|
|
|
|
|
2015-11-21 18:55:51 +01:00
|
|
|
volatile bool runThread = true;
|
2015-02-25 16:28:30 +01:00
|
|
|
|
|
|
|
volatile int threadcount=0;
|
|
|
|
|
|
|
|
void threadMain(void *arg) {
|
|
|
|
|
2015-11-21 18:55:51 +01:00
|
|
|
while(runThread) {
|
2015-02-25 16:28:30 +01:00
|
|
|
svcWaitSynchronization(threadRequest, U64_MAX);
|
2015-11-21 18:55:51 +01:00
|
|
|
svcClearEvent(threadRequest);
|
2015-02-25 16:28:30 +01:00
|
|
|
|
|
|
|
threadcount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-21 18:55:51 +01:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2015-02-25 16:28:30 +01:00
|
|
|
gfxInitDefault();
|
|
|
|
consoleInit(GFX_TOP, NULL);
|
|
|
|
|
|
|
|
svcCreateEvent(&threadRequest,0);
|
2015-11-21 18:55:51 +01:00
|
|
|
threadHandle = threadCreate(threadMain, 0, STACKSIZE, 0x3f, -2, true);
|
2015-02-25 16:28:30 +01:00
|
|
|
|
2015-11-21 18:55:51 +01:00
|
|
|
printf("thread handle: %p\n", threadHandle);
|
2015-02-25 16:28:30 +01:00
|
|
|
|
|
|
|
// Main loop
|
|
|
|
while (aptMainLoop())
|
|
|
|
{
|
|
|
|
gspWaitForVBlank();
|
|
|
|
hidScanInput();
|
|
|
|
|
|
|
|
printf("\x1b[5;0H");
|
|
|
|
printf("thread counter = %d\n",threadcount);
|
|
|
|
|
|
|
|
u32 kDown = hidKeysDown();
|
|
|
|
if (kDown & KEY_START)
|
|
|
|
break; // break in order to return to hbmenu
|
|
|
|
|
2015-02-26 09:37:23 +01:00
|
|
|
if (kDown & KEY_A)
|
2015-02-25 16:28:30 +01:00
|
|
|
svcSignalEvent(threadRequest);
|
|
|
|
|
|
|
|
// Flush and swap framebuffers
|
|
|
|
gfxFlushBuffers();
|
|
|
|
gfxSwapBuffers();
|
|
|
|
}
|
|
|
|
|
|
|
|
// tell thread to exit
|
2015-11-21 18:55:51 +01:00
|
|
|
runThread = false;
|
2015-02-25 16:28:30 +01:00
|
|
|
|
2015-11-21 18:55:51 +01:00
|
|
|
// signal the thread and wait for it to exit
|
2015-02-25 16:28:30 +01:00
|
|
|
svcSignalEvent(threadRequest);
|
2015-11-21 18:55:51 +01:00
|
|
|
threadJoin(threadHandle, U64_MAX);
|
2015-02-25 16:28:30 +01:00
|
|
|
|
2015-11-21 18:55:51 +01:00
|
|
|
// close event handle
|
2015-02-25 16:28:30 +01:00
|
|
|
svcCloseHandle(threadRequest);
|
|
|
|
|
|
|
|
gfxExit();
|
|
|
|
return 0;
|
|
|
|
}
|