SDL 2.0
SDL_psp_main.c
Go to the documentation of this file.
1/*
2 SDL_psp_main.c, placed in the public domain by Sam Lantinga 3/13/14
3*/
4#include "SDL_config.h"
5
6#ifdef __PSP__
7
8#include "SDL_main.h"
9#include <pspkernel.h>
10#include <pspdebug.h>
11#include <pspsdk.h>
12#include <pspthreadman.h>
13#include <stdlib.h>
14#include <stdio.h>
15
16/* If application's main() is redefined as SDL_main, and libSDLmain is
17 linked, then this file will create the standard exit callback,
18 define the PSP_MODULE_INFO macro, and exit back to the browser when
19 the program is finished.
20
21 You can still override other parameters in your own code if you
22 desire, such as PSP_HEAP_SIZE_KB, PSP_MAIN_THREAD_ATTR,
23 PSP_MAIN_THREAD_STACK_SIZE, etc.
24*/
25
26PSP_MODULE_INFO("SDL App", 0, 1, 1);
27
28int sdl_psp_exit_callback(int arg1, int arg2, void *common)
29{
30 exit(0);
31 return 0;
32}
33
34int sdl_psp_callback_thread(SceSize args, void *argp)
35{
36 int cbid;
37 cbid = sceKernelCreateCallback("Exit Callback",
38 sdl_psp_exit_callback, NULL);
39 sceKernelRegisterExitCallback(cbid);
40 sceKernelSleepThreadCB();
41 return 0;
42}
43
44int sdl_psp_setup_callbacks(void)
45{
46 int thid = 0;
47 thid = sceKernelCreateThread("update_thread",
48 sdl_psp_callback_thread, 0x11, 0xFA0, 0, 0);
49 if(thid >= 0)
50 sceKernelStartThread(thid, 0, 0);
51 return thid;
52}
53
54int main(int argc, char *argv[])
55{
56 pspDebugScreenInit();
57 sdl_psp_setup_callbacks();
58
59 /* Register sceKernelExitGame() to be called when we exit */
60 atexit(sceKernelExitGame);
61
63
64 (void)SDL_main(argc, argv);
65 return 0;
66}
67
68#endif /* __PSP__ */
69
70/* vi: set ts=4 sw=4 expandtab: */
#define SDL_SetMainReady
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[])
#define main
Definition: SDL_main.h:109
GLuint GLuint GLuint GLuint arg1
GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2
#define NULL
Definition: begin_code.h:167