From 9b4e2d665ef45e2aae25aceb00424793ad9be278 Mon Sep 17 00:00:00 2001 From: Fierelier Date: Wed, 25 Sep 2024 23:08:49 +0200 Subject: [PATCH] Load the required modules for Memory Card I/O --- sdl2/main.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/sdl2/main.c b/sdl2/main.c index 0a6e3e3..075e3b7 100755 --- a/sdl2/main.c +++ b/sdl2/main.c @@ -1,9 +1,21 @@ #include +#include +#include +#include #include "SDL2/SDL.h" int printf(const char *format, ...); char * ps2elf_storage; +int loadModule(char * module) { + printf("Loading module '%s' ...\n",module); + int rtn = SifLoadModule(module,0,NULL); + if (rtn < 0) { + printf("Could not load module '%s': %d\n",module,rtn); + } + return rtn; +} + int main(int argc, char **argv) { // Just some debugging @@ -19,11 +31,25 @@ int main(int argc, char **argv) printf("ERROR: Could not find storage device of elf!\n"); return 1; } else { + SifInitRpc(0); size_t size = sep - argv[0]; ps2elf_storage = malloc(size + 1); memcpy(ps2elf_storage,argv[0],size); ps2elf_storage[size] = 0; printf("* Detected storage device: '%s'\n",ps2elf_storage); + + int rtn; + if (strcmp(ps2elf_storage,"mc0") || strcmp(ps2elf_storage,"mc1")) { + char module[] = "rom0:MCMAN"; + + rtn = SifLoadModule(module,0,NULL); + if ( + (loadModule("rom:SIO2MAN") < 0) || + (loadModule("rom:MCMAN") < 0) + ) { + return 1; + } + } } // Initializing SDL2