Advertisement
PauSix

PSP Debug Example main.c

Feb 15th, 2017
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.37 KB | None | 0 0
  1. // include psp stuff
  2. #include <pspkernel.h>
  3. #include <pspdebug.h>
  4. #include <pspdisplay.h>
  5. #include <pspctrl.h>
  6.  
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include <string.h>
  10.  
  11. // include commons stuff
  12. #include "../common/callback.h"
  13.  
  14.  
  15. // configure PSP stuff
  16. #define VERS    1
  17. #define REVS    0
  18.  
  19. PSP_MODULE_INFO("DebugExample", PSP_MODULE_USER, VERS, REVS);
  20. PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
  21.  
  22. // make printing easier on us
  23. #define printf pspDebugScreenPrintf
  24.  
  25.  
  26.  
  27. void crash(int error, const char* crasher, const char* message) {
  28.     sceDisplayWaitVblankStart();
  29.     printf("Error (%d) : %s\n", error, crasher);
  30.     printf("%s\n", message);
  31.     sceKernelSleepThread();
  32. }
  33.  
  34. void test_crash() {
  35.     sceDisplayWaitVblankStart();
  36.     printf("No crash occured.");
  37.     sceKernelSleepThread();
  38. }
  39.  
  40.  
  41.  
  42. int main(int argc, char** argv)
  43. {
  44.     // basic init
  45.     setupExitCallback();
  46.     pspDebugScreenInit();
  47.    
  48.     // path to non-existent file
  49.     const char* path = "umd0:/this/path_doesnt/exist.txt";
  50.    
  51.     // attempt to open the non-existent file, uid being a handle pointer
  52.     int uid = sceIoOpen(path, PSP_O_RDONLY, 0777);
  53.     if(uid != 0)
  54.         crash(uid, "File Open", "Failed to open file. File not found!");
  55.    
  56.     // if for some reason the file was found
  57.     printf("I see you built the path to test if sceIoOpen worked to open files.");
  58.     sceKernelSleepThread();
  59.    
  60.     sceKernelExitGame();
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement