cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

SDL_psp_main.c (1542B)


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