PauSix

PSP Debug Example main.c

Feb 15th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.29 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. typedef struct Example {
  43.     int a;
  44.     int b;
  45. } Example;
  46.  
  47. void free_reference(Example** ref) {
  48.     free(ref); // should be free(*ref);
  49.     *ref = 0;
  50. }
  51.  
  52.  
  53.  
  54. int main(int argc, char** argv)
  55. {
  56.     // basic init
  57.     setupExitCallback();
  58.     pspDebugScreenInit();
  59.    
  60.     Example* ptr = malloc(sizeof(Example));
  61.    
  62.     printf("ptr: %d\n", ptr->a);
  63.    
  64.     test_crash();
  65.     free_reference(&ptr);
  66.    
  67.     printf("ptr: %d\n", ptr->b);
  68.    
  69.     printf("No errors.");
  70.     sceKernelSleepThread();
  71.    
  72.     sceKernelExitGame();
  73.     return 0;
  74. }
Add Comment
Please, Sign In to add comment