main.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <pspkernel.h>
  4. #include <pspdebug.h>
  5. #include <pspsdk.h>
  6. #include <pspctrl.h>
  7. PSP_MODULE_INFO("Pthread Test", 0, 1, 1);
  8. extern void pte_test_main();
  9. #ifdef JNS
  10. #define printf pspDebugScreenPrintf
  11. #endif
  12. /* Exit callback */
  13. int exit_callback(int arg1, int arg2, void *common)
  14. {
  15. sceKernelExitGame();
  16. return 0;
  17. }
  18. /* Callback thread */
  19. int CallbackThread(SceSize args, void *argp)
  20. {
  21. int cbid;
  22. cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
  23. sceKernelRegisterExitCallback(cbid);
  24. sceKernelSleepThreadCB();
  25. return 0;
  26. }
  27. /* Sets up the callback thread and returns its thread id */
  28. int SetupCallbacks(void)
  29. {
  30. int thid = 0;
  31. thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
  32. if (thid >= 0)
  33. {
  34. sceKernelStartThread(thid, 0, 0);
  35. }
  36. return thid;
  37. }
  38. int main()
  39. {
  40. SceCtrlData pad;
  41. pspDebugScreenInit();
  42. SetupCallbacks();
  43. pte_test_main();
  44. while (1)
  45. {
  46. sceCtrlReadBufferPositive(&pad, 1);
  47. if (pad.Buttons & PSP_CTRL_UP)
  48. {
  49. printf("Exiting...\n");
  50. return 0;
  51. }
  52. }
  53. return 0;
  54. }