]> Chaos Git - corbenik/ctrulib.git/commitdiff
Create APT event handler thread as soon as possible, and complete initialization...
authorStapleButter <thetotalworm@gmail.com>
Mon, 27 Oct 2014 14:37:30 +0000 (15:37 +0100)
committerStapleButter <thetotalworm@gmail.com>
Mon, 27 Oct 2014 14:37:30 +0000 (15:37 +0100)
Adapt examples to the changes (not tested).

examples/arm11u/source/main.c
examples/gpu/source/main.c
examples/mic/source/main.c
examples/sdmc/source/main.c
libctru/include/3ds/services/apt.h
libctru/source/services/apt.c

index 0c0f677d001688d94d907b96d1422749037f2ef8..8862f17efdd738e0abcd936ba4d8cdb5522dad5d 100644 (file)
@@ -121,8 +121,6 @@ int main()
 
        hidInit(NULL);
 
-       aptSetupEventHandler();
-
        APP_STATUS status;
        while((status=aptGetStatus())!=APP_EXITING)
        {
index 1bd9832a762132c00af3ac78efb86e63ed8502e8..1c06bd581ff0f0faa00ceaec31115823847a4eaf 100644 (file)
@@ -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();
        }
index 022902ad1d31932232719f9716549f88db01d295..90205b52b1fe159a87722715d2b3b1143e9ee92f 100644 (file)
@@ -16,7 +16,6 @@ int main()
        aptInit();
        gfxInit();
        hidInit(NULL);
-       aptSetupEventHandler();
        
        CSND_initialize(NULL);
 
index 68f9b5c7ea899ca2a816029fba0baabb1b2b162f..53d4404d55b4dfc558723c3c6b033670cb31fdc5 100644 (file)
@@ -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)
index b8c05d9d12837f353805d7578ce791274350e4e8..cf2fb3162cb8c34f8554c1befbc9ecf9dbad7191 100644 (file)
@@ -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.
index 3c8de84dcb0b6eb3b605956569fa8355a24a5d8a..4d4759ab1e0527c7fe324347ea5c88f332a2a236 100644 (file)
@@ -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);
        }
 }