Port PS2 SDL_main to header-only + SDL_RunApp()
This commit is contained in:
committed by
Sam Lantinga
parent
544f2c7982
commit
b1b3bd654d
@@ -1,91 +1,8 @@
|
||||
/*
|
||||
SDL_ps2_main.c, fjtrujy@gmail.com
|
||||
|
||||
empty, moved to SDL_RunApp() in src/core/ps2/SDL_ps2.c
|
||||
TODO: remove
|
||||
*/
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h> /* until this SDL_main impl is converted to header-only.. */
|
||||
|
||||
#ifdef __PS2__
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <kernel.h>
|
||||
#include <sifrpc.h>
|
||||
#include <iopcontrol.h>
|
||||
#include <sbv_patches.h>
|
||||
#include <ps2_fileXio_driver.h>
|
||||
#include <ps2_memcard_driver.h>
|
||||
#include <ps2_usb_driver.h>
|
||||
|
||||
#ifdef main
|
||||
#undef main
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) void reset_IOP()
|
||||
{
|
||||
SifInitRpc(0);
|
||||
while (!SifIopReset(NULL, 0)) {
|
||||
}
|
||||
while (!SifIopSync()) {
|
||||
}
|
||||
}
|
||||
|
||||
static void prepare_IOP()
|
||||
{
|
||||
reset_IOP();
|
||||
SifInitRpc(0);
|
||||
sbv_patch_enable_lmb();
|
||||
sbv_patch_disable_prefix_check();
|
||||
sbv_patch_fileio();
|
||||
}
|
||||
|
||||
static void init_drivers()
|
||||
{
|
||||
init_memcard_driver(true);
|
||||
init_usb_driver(true);
|
||||
}
|
||||
|
||||
static void deinit_drivers()
|
||||
{
|
||||
deinit_usb_driver(true);
|
||||
deinit_memcard_driver(true);
|
||||
}
|
||||
|
||||
static void waitUntilDeviceIsReady(char *path)
|
||||
{
|
||||
struct stat buffer;
|
||||
int ret = -1;
|
||||
int retries = 50;
|
||||
|
||||
while (ret != 0 && retries > 0) {
|
||||
ret = stat(path, &buffer);
|
||||
/* Wait until the device is ready */
|
||||
nopdelay();
|
||||
|
||||
retries--;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int res;
|
||||
char cwd[FILENAME_MAX];
|
||||
|
||||
prepare_IOP();
|
||||
init_drivers();
|
||||
|
||||
getcwd(cwd, sizeof(cwd));
|
||||
waitUntilDeviceIsReady(cwd);
|
||||
|
||||
res = SDL_main(argc, argv);
|
||||
|
||||
deinit_drivers();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif /* _PS2 */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
Reference in New Issue
Block a user