]> Chaos Git - corbenik/ctrulib.git/commitdiff
Added comments to the app_launch example for better understanding for beginners
authorprofi200 <fd3194@gmx.de>
Thu, 20 Nov 2014 13:58:24 +0000 (14:58 +0100)
committerprofi200 <fd3194@gmx.de>
Thu, 20 Nov 2014 13:58:24 +0000 (14:58 +0100)
examples/app_launch/source/main.c

index 0077c6cc6328b79dc89d95ab35d53e8634c2432c..807cb39b598a29e39b2337bc349e050c7853f7c2 100644 (file)
@@ -6,37 +6,47 @@
 
 int main()
 {
-       srvInit();      
-       aptInit();
-       gfxInit();
-       hidInit(NULL);
+       srvInit(); // Needed
+       aptInit(); // Needed
+       gfxInit(); // Init graphic stuff
+       hidInit(NULL); // For input (buttons, touchscreen...)
 
 
+       // We need these 2 buffers for APT_DoAppJump() later. They can be smaller too
        u8 buf0[0x300];
        u8 buf1[0x20];
 
 
+       // Loop as long as the status is not exit
        while(aptMainLoop())
        {
+               // Scan hid shared memory for input events
                hidScanInput();
 
-               if(hidKeysDown() & KEY_A)
+               if(hidKeysDown() & KEY_A) // If the A button got pressed, start the app launch
                {
+                       // Clear both buffers
                        memset(buf0, 0, 0x300);
                        memset(buf1, 0, 0x20);
 
+                       // Open an APT session so we can talk to the APT service
                        aptOpenSession();
-                       APT_PrepareToDoAppJump(NULL, 0, 0x0004001000022400LL, 0); // *EUR* camera app
-                       APT_DoAppJump(NULL, 0x300, 0x20, buf0, buf1);
+                       // Prepare for the app launch
+                       APT_PrepareToDoAppJump(NULL, 0, 0x0004001000022400LL, 0); // *EUR* camera app title ID
+                       // Tell APT to trigger the app launch and set the status of this app to exit
+                       APT_DoAppJump(NULL, 0x300 /* size of buf0 */, 0x20 /* size of buf1 */, buf0, buf1);
+                       // Close the APT session because we don't need APT anymore
                        aptCloseSession();
                }
 
+               // Flush + swap framebuffers and wait for VBlank. Not really needed in this example
                gfxFlushBuffers();
                gfxSwapBuffers();
                gspWaitForVBlank();
        }
 
 
+       // Deinit everything before the app process get's terminated
        hidExit();
        gfxExit();
        aptExit();