diff options
| author | 3gg <3gg@shellblade.net> | 2025-12-27 12:03:39 -0800 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2025-12-27 12:03:39 -0800 |
| commit | 5a079a2d114f96d4847d1ee305d5b7c16eeec50e (patch) | |
| tree | 8926ab44f168acf787d8e19608857b3af0f82758 /contrib/SDL-3.2.8/src/main/psp | |
Initial commit
Diffstat (limited to 'contrib/SDL-3.2.8/src/main/psp')
| -rw-r--r-- | contrib/SDL-3.2.8/src/main/psp/SDL_sysmain_runapp.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/src/main/psp/SDL_sysmain_runapp.c b/contrib/SDL-3.2.8/src/main/psp/SDL_sysmain_runapp.c new file mode 100644 index 0000000..e89f5ff --- /dev/null +++ b/contrib/SDL-3.2.8/src/main/psp/SDL_sysmain_runapp.c | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | /* | ||
| 2 | Simple DirectMedia Layer | ||
| 3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> | ||
| 4 | |||
| 5 | This software is provided 'as-is', without any express or implied | ||
| 6 | warranty. In no event will the authors be held liable for any damages | ||
| 7 | arising from the use of this software. | ||
| 8 | |||
| 9 | Permission is granted to anyone to use this software for any purpose, | ||
| 10 | including commercial applications, and to alter it and redistribute it | ||
| 11 | freely, subject to the following restrictions: | ||
| 12 | |||
| 13 | 1. The origin of this software must not be misrepresented; you must not | ||
| 14 | claim that you wrote the original software. If you use this software | ||
| 15 | in a product, an acknowledgment in the product documentation would be | ||
| 16 | appreciated but is not required. | ||
| 17 | 2. Altered source versions must be plainly marked as such, and must not be | ||
| 18 | misrepresented as being the original software. | ||
| 19 | 3. This notice may not be removed or altered from any source distribution. | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "SDL_internal.h" | ||
| 23 | |||
| 24 | #ifdef SDL_PLATFORM_PSP | ||
| 25 | |||
| 26 | // SDL_RunApp() for PSP based on SDL_psp_main.c, placed in the public domain by Sam Lantinga 3/13/14 | ||
| 27 | |||
| 28 | #include <pspkernel.h> | ||
| 29 | #include <pspthreadman.h> | ||
| 30 | #include "../../events/SDL_events_c.h" | ||
| 31 | |||
| 32 | /* If application's main() is redefined as SDL_main, and libSDL_main is | ||
| 33 | linked, then this file will create the standard exit callback, | ||
| 34 | define the PSP_MODULE_INFO macro, and exit back to the browser when | ||
| 35 | the program is finished. | ||
| 36 | |||
| 37 | You can still override other parameters in your own code if you | ||
| 38 | desire, such as PSP_HEAP_SIZE_KB, PSP_MAIN_THREAD_ATTR, | ||
| 39 | PSP_MAIN_THREAD_STACK_SIZE, etc. | ||
| 40 | */ | ||
| 41 | |||
| 42 | PSP_MODULE_INFO("SDL App", 0, 1, 0); | ||
| 43 | PSP_MAIN_THREAD_ATTR(THREAD_ATTR_VFPU | THREAD_ATTR_USER); | ||
| 44 | |||
| 45 | int sdl_psp_exit_callback(int arg1, int arg2, void *common) | ||
| 46 | { | ||
| 47 | SDL_SendQuit(); | ||
| 48 | return 0; | ||
| 49 | } | ||
| 50 | |||
| 51 | int sdl_psp_callback_thread(SceSize args, void *argp) | ||
| 52 | { | ||
| 53 | int cbid; | ||
| 54 | cbid = sceKernelCreateCallback("Exit Callback", | ||
| 55 | sdl_psp_exit_callback, NULL); | ||
| 56 | sceKernelRegisterExitCallback(cbid); | ||
| 57 | sceKernelSleepThreadCB(); | ||
| 58 | return 0; | ||
| 59 | } | ||
| 60 | |||
| 61 | int sdl_psp_setup_callbacks(void) | ||
| 62 | { | ||
| 63 | int thid; | ||
| 64 | thid = sceKernelCreateThread("update_thread", | ||
| 65 | sdl_psp_callback_thread, 0x11, 0xFA0, 0, 0); | ||
| 66 | if (thid >= 0) { | ||
| 67 | sceKernelStartThread(thid, 0, 0); | ||
| 68 | } | ||
| 69 | return thid; | ||
| 70 | } | ||
| 71 | |||
| 72 | int SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserved) | ||
| 73 | { | ||
| 74 | (void)reserved; | ||
| 75 | sdl_psp_setup_callbacks(); | ||
| 76 | |||
| 77 | SDL_SetMainReady(); | ||
| 78 | |||
| 79 | return mainFunction(argc, argv); | ||
| 80 | } | ||
| 81 | |||
| 82 | #endif // SDL_PLATFORM_PSP | ||
