Load the required modules for Memory Card I/O

This commit is contained in:
Fierelier 2024-09-25 23:08:49 +02:00
parent 17461c73fc
commit 9b4e2d665e

View File

@ -1,9 +1,21 @@
#include <kernel.h> #include <kernel.h>
#include <sifrpc.h>
#include <loadfile.h>
#include <sys/stat.h>
#include "SDL2/SDL.h" #include "SDL2/SDL.h"
int printf(const char *format, ...); int printf(const char *format, ...);
char * ps2elf_storage; 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) int main(int argc, char **argv)
{ {
// Just some debugging // Just some debugging
@ -19,11 +31,25 @@ int main(int argc, char **argv)
printf("ERROR: Could not find storage device of elf!\n"); printf("ERROR: Could not find storage device of elf!\n");
return 1; return 1;
} else { } else {
SifInitRpc(0);
size_t size = sep - argv[0]; size_t size = sep - argv[0];
ps2elf_storage = malloc(size + 1); ps2elf_storage = malloc(size + 1);
memcpy(ps2elf_storage,argv[0],size); memcpy(ps2elf_storage,argv[0],size);
ps2elf_storage[size] = 0; ps2elf_storage[size] = 0;
printf("* Detected storage device: '%s'\n",ps2elf_storage); 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 // Initializing SDL2