diff --git a/include/SDL_main.h b/include/SDL_main.h index ec78e4149..43aac974f 100644 --- a/include/SDL_main.h +++ b/include/SDL_main.h @@ -83,6 +83,15 @@ */ #define SDL_MAIN_NEEDED +#elif defined(__PSP__) +/* On PSP SDL provides a main function that sets the module info, + activates the GPU and starts the thread required to be able to exit + the software. + + If you provide this yourself, you may define SDL_MAIN_HANDLED + */ +#define SDL_MAIN_AVAILABLE + #endif #endif /* SDL_MAIN_HANDLED */ diff --git a/src/main/psp/SDL_psp_main.c b/src/main/psp/SDL_psp_main.c index 2ca8e446b..fb3dd4474 100644 --- a/src/main/psp/SDL_psp_main.c +++ b/src/main/psp/SDL_psp_main.c @@ -7,11 +7,12 @@ #include "SDL_main.h" #include -#include -#include #include #include -#include + +#ifdef main + #undef main +#endif /* If application's main() is redefined as SDL_main, and libSDLmain is linked, then this file will create the standard exit callback, @@ -23,11 +24,12 @@ PSP_MAIN_THREAD_STACK_SIZE, etc. */ -PSP_MODULE_INFO("SDL App", 0, 1, 1); +PSP_MODULE_INFO("SDL App", 0, 1, 0); +PSP_MAIN_THREAD_ATTR(THREAD_ATTR_VFPU | THREAD_ATTR_USER); int sdl_psp_exit_callback(int arg1, int arg2, void *common) { - exit(0); + sceKernelExitGame(); return 0; } @@ -53,12 +55,8 @@ int sdl_psp_setup_callbacks(void) int main(int argc, char *argv[]) { - pspDebugScreenInit(); sdl_psp_setup_callbacks(); - /* Register sceKernelExitGame() to be called when we exit */ - atexit(sceKernelExitGame); - SDL_SetMainReady(); (void)SDL_main(argc, argv);