Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.91 KB | None | 0 0
  1. // Include the most common headers from the C standard library
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5.  
  6. // Include the main libnx system header, for Switch development
  7. #include <switch.h>
  8.  
  9. // Sysmodules should not use applet*.
  10. u32 __nx_applet_type = AppletType_None;
  11.  
  12. // Adjust size as needed.
  13. #define INNER_HEAP_SIZE 0x80000
  14. size_t nx_inner_heap_size = INNER_HEAP_SIZE;
  15. char   nx_inner_heap[INNER_HEAP_SIZE];
  16.  
  17. void __libnx_initheap(void) {
  18.     void*  addr = nx_inner_heap;
  19.     size_t size = nx_inner_heap_size;
  20.  
  21.     // Newlib
  22.     extern char* fake_heap_start;
  23.     extern char* fake_heap_end;
  24.  
  25.     fake_heap_start = (char*)addr;
  26.     fake_heap_end   = (char*)addr + size;
  27. }
  28.  
  29. // Init/exit services, update as needed.
  30. void __attribute__((weak)) __appInit(void) {
  31.     Result rc;
  32.  
  33.     // Initialize default services.
  34.     rc = smInitialize();
  35.     if (R_FAILED(rc))
  36.         fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_SM));
  37.  
  38.     //Enable this if you want to use time.
  39.     /*rc = timeInitialize();
  40.     if (R_FAILED(rc))
  41.         fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_Time));
  42.  
  43.     __libnx_init_time();*/
  44.  
  45.     rc = fsInitialize();
  46.     if (R_FAILED(rc))
  47.         fatalSimple(MAKERESULT(Module_Libnx, LibnxError_InitFail_FS));
  48.  
  49.     fsdevMountSdmc();
  50. }
  51.  
  52. void __attribute__((weak)) userAppExit(void);
  53.  
  54. void __attribute__((weak)) __appExit(void) {
  55.     // Cleanup default services.
  56.     fsdevUnmountAll();
  57.     fsExit();
  58.     //timeExit();//Enable this if you want to use time.
  59.     smExit();
  60. }
  61.  
  62. // Main program entrypoint
  63. int main(int argc, char* argv[]) {
  64.     setInitialize();
  65.  
  66.     while(appletMainLoop()) {
  67.         bool wlan;
  68.  
  69.         setsysGetFlag(73, &wlan);
  70.         if(wlan) {
  71.             setsysSetFlag(73, true);
  72.         }
  73.         svcSleepThread(1000000000L);
  74.     }
  75.  
  76.     // Deinitialization and resources clean up code can go here.
  77.     setExit();
  78.  
  79.     return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement