Create APT event handler thread as soon as possible, and complete initialization automatically when needed. No more 'call aptSetupEventHandler() as late as possible' shit.
Adapt examples to the changes (not tested).
This commit is contained in:
parent
cb6b23b884
commit
afd2140cb7
@ -121,8 +121,6 @@ int main()
|
||||
|
||||
hidInit(NULL);
|
||||
|
||||
aptSetupEventHandler();
|
||||
|
||||
APP_STATUS status;
|
||||
while((status=aptGetStatus())!=APP_EXITING)
|
||||
{
|
||||
|
@ -56,7 +56,7 @@ void doFrame1()
|
||||
|
||||
GPU_SetFaceCulling(GPU_CULL_BACK_CCW);
|
||||
GPU_SetStencilTest(false, GPU_ALWAYS, 0x00);
|
||||
GPU_SetDepthTest(true, GPU_GREATER, 0x1F);
|
||||
GPU_SetDepthTestAndWriteMask(true, GPU_GREATER, GPU_WRITE_ALL);
|
||||
|
||||
// ?
|
||||
GPUCMD_AddSingleParam(0x00010062, 0x00000000); //param always 0x0 according to code
|
||||
@ -122,9 +122,7 @@ void doFrame1()
|
||||
GPU_DrawArray(GPU_TRIANGLES, mdlFaces*3);
|
||||
|
||||
//finalize stuff ?
|
||||
GPUCMD_AddSingleParam(0x000F0111, 0x00000001);
|
||||
GPUCMD_AddSingleParam(0x000F0110, 0x00000001);
|
||||
GPUCMD_AddSingleParam(0x0008025E, 0x00000000);
|
||||
GPU_FinishDrawing();
|
||||
}
|
||||
|
||||
void demoControls(void)
|
||||
@ -156,7 +154,6 @@ int main()
|
||||
aptInit();
|
||||
gfxInit();
|
||||
hidInit(NULL);
|
||||
aptSetupEventHandler();
|
||||
|
||||
GPU_Init(NULL);
|
||||
|
||||
@ -177,6 +174,7 @@ int main()
|
||||
shader=SHDR_ParseSHBIN((u32*)test_vsh_shbin,test_vsh_shbin_size);
|
||||
|
||||
GX_SetMemoryFill(gxCmdBuf, (u32*)gpuOut, 0x404040FF, (u32*)&gpuOut[0x2EE00], 0x201, (u32*)gpuDOut, 0x00000000, (u32*)&gpuDOut[0x2EE00], 0x201);
|
||||
gspWaitForPSC0();
|
||||
gfxSwapBuffersGpu();
|
||||
|
||||
APP_STATUS status;
|
||||
@ -187,14 +185,17 @@ int main()
|
||||
demoControls();
|
||||
|
||||
GX_SetMemoryFill(gxCmdBuf, (u32*)gpuOut, 0x404040FF, (u32*)&gpuOut[0x2EE00], 0x201, (u32*)gpuDOut, 0x00000000, (u32*)&gpuDOut[0x2EE00], 0x201);
|
||||
gspWaitForPSC0();
|
||||
|
||||
GPUCMD_SetBuffer(gpuCmd, gpuCmdSize, 0);
|
||||
doFrame1();
|
||||
GPUCMD_Finalize();
|
||||
GPUCMD_Run(gxCmdBuf);
|
||||
gspWaitForP3D();
|
||||
|
||||
gfxSwapBuffersGpu();
|
||||
GX_SetDisplayTransfer(gxCmdBuf, (u32*)gpuOut, 0x019001E0, (u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), 0x019001E0, 0x01001000);
|
||||
gspWaitForPPF();
|
||||
}
|
||||
gspWaitForVBlank();
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ int main()
|
||||
aptInit();
|
||||
gfxInit();
|
||||
hidInit(NULL);
|
||||
aptSetupEventHandler();
|
||||
|
||||
CSND_initialize(NULL);
|
||||
|
||||
|
@ -131,8 +131,6 @@ int main()
|
||||
FSUSER_OpenFileDirectly(fsuHandle, &fileHandle, sdmcArchive, filePath, FS_OPEN_READ, FS_ATTRIBUTE_NONE);
|
||||
FSFILE_Read(fileHandle, &bytesRead, 0x0, (u32*)gspHeap, 0x46500);
|
||||
FSFILE_Close(fileHandle);
|
||||
|
||||
aptSetupEventHandler();
|
||||
|
||||
APP_STATUS status;
|
||||
while((status=aptGetStatus())!=APP_EXITING)
|
||||
|
@ -41,7 +41,6 @@ Result aptInit();
|
||||
void aptExit();
|
||||
void aptOpenSession();
|
||||
void aptCloseSession();
|
||||
void aptSetupEventHandler();
|
||||
void aptSetStatus(APP_STATUS status);
|
||||
APP_STATUS aptGetStatus();
|
||||
u32 aptGetStatusPower();//This can be used when the status is APP_SUSPEND* to check how the return-to-menu was triggered: 0 = home-button, 1 = power-button.
|
||||
|
@ -249,6 +249,7 @@ static bool __handle_incoming_parameter() {
|
||||
switch(type)
|
||||
{
|
||||
case 0x1: // Application just started.
|
||||
aptAppStarted();
|
||||
return true;
|
||||
|
||||
case 0xB: // Just returned from menu.
|
||||
@ -320,6 +321,10 @@ Result aptInit(void)
|
||||
aptOpenSession();
|
||||
if((ret=APT_NotifyToWait(NULL, currentAppId)))return ret;
|
||||
aptCloseSession();
|
||||
|
||||
// create APT event handler thread
|
||||
svcCreateThread(&aptEventHandlerThread, aptEventHandler, 0x0,
|
||||
(u32*)(&aptEventHandlerStack[APT_HANDLER_STACKSIZE/8]), 0x31, 0xfffffffe);
|
||||
}
|
||||
|
||||
svcCreateEvent(&aptStatusEvent, 0);
|
||||
@ -357,32 +362,10 @@ void aptExit()
|
||||
svcCloseHandle(aptStatusEvent);
|
||||
}
|
||||
|
||||
void aptSetupEventHandler()
|
||||
void aptAppStarted()
|
||||
{
|
||||
u8 buf1[4], buf2[4];
|
||||
|
||||
/*buf1[0]=0x02; buf1[1]=0x00; buf1[2]=0x00; buf1[3]=0x04;
|
||||
aptOpenSession();
|
||||
APT_AppletUtility(NULL, NULL, 0x7, 0x4, buf1, 0x1, buf2);
|
||||
aptCloseSession();
|
||||
|
||||
aptOpenSession();
|
||||
APT_AppletUtility(NULL, NULL, 0x4, 0x1, buf1, 0x1, buf2);
|
||||
aptCloseSession();
|
||||
|
||||
aptOpenSession();
|
||||
APT_AppletUtility(NULL, NULL, 0x4, 0x1, buf1, 0x1, buf2);
|
||||
aptCloseSession();
|
||||
|
||||
buf1[0]=0x13; buf1[1]=0x00; buf1[2]=0x10; buf1[3]=0x00;
|
||||
aptOpenSession();
|
||||
APT_AppletUtility(NULL, NULL, 0x7, 0x4, buf1, 0x1, buf2);
|
||||
aptCloseSession();
|
||||
|
||||
aptOpenSession();
|
||||
APT_AppletUtility(NULL, NULL, 0x4, 0x1, buf1, 0x1, buf2);
|
||||
aptCloseSession();*/
|
||||
|
||||
svcCreateMutex(&aptStatusMutex, true);
|
||||
aptStatus=0;
|
||||
svcReleaseMutex(aptStatusMutex);
|
||||
@ -406,10 +389,6 @@ void aptSetupEventHandler()
|
||||
aptOpenSession();
|
||||
APT_AppletUtility(NULL, NULL, 0x4, 0x1, buf1, 0x1, buf2);
|
||||
aptCloseSession();
|
||||
|
||||
// Create thread for stuff handling APT events.
|
||||
svcCreateThread(&aptEventHandlerThread, aptEventHandler, 0x0,
|
||||
(u32*)(&aptEventHandlerStack[APT_HANDLER_STACKSIZE/8]), 0x31, 0xfffffffe);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user