diff --git a/sdl/src/Makefile b/sdl/src/Makefile index ad1dbd28..ff55eb73 100755 --- a/sdl/src/Makefile +++ b/sdl/src/Makefile @@ -18,11 +18,24 @@ USE_FREESD=1 # Enable FREESIO2 instead of XSIO2MAN USE_FREESIO2=1 +# surrender all IOP handling to the program using this library. granting full control of the IOP, and not forcing usage of specific modules +# Very useful for special cases, like Supporting arcade PS2s, or... just trying to do things right +NO_IOP_HANDLING=0 + EE_CFLAGS = -DNO_SIGNAL_H -DDEBUG_ERROR -DUSE_MATH_H EE_CFLAGS += -DENABLE_PS2SDK -ifeq ($(ENABLE_MTAP), 1) -EE_CFLAGS += -DPS2SDL_ENABLE_MTAP +# surrender all IOP handling to the program using this library. granting full control of the IOP, and not forcing usage of specific modules +# Very useful for special cases, like Supporting arcade PS2s, or... just trying to do things right +ifeq ($(NO_IOP_HANDLING), 1) + EE_CFLAGS += -DNO_IOP_HANDLING + ifeq ($(ENABLE_MTAP), 1) + EE_CFLAGS += -DPS2SDL_ENABLE_MTAP + endif + + ifeq ($(USE_FREESIO2), 1) + EE_CFLAGS += -DUSE_FREESIO2 + endif endif ifeq ($(HAVE_INPUT_DEVICES), 1) @@ -33,10 +46,6 @@ ifeq ($(USE_FREESD), 1) EE_CFLAGS += -DUSE_FREESD endif -ifeq ($(USE_FREESIO2), 1) -EE_CFLAGS += -DUSE_FREESIO2 -endif - ifeq ($(ENABLE_VSYNC_CB), 1) EE_CFLAGS += -DENABLE_VSYNC_CB endif @@ -150,25 +159,30 @@ video/ps2sdk/ps2usbd_irx.c: $(PS2SDK)/iop/irx/usbd.irx $(PS2SDK)/bin/bin2c $< $@ ps2usbd_irx -ifeq ($(ENABLE_MTAP), 1) -EMBEDDED = \ - $(PS2SDK)/ee/lib/libpadx.a \ - $(PS2SDK)/ee/lib/libmtap.a -else -EMBEDDED = \ - $(PS2SDK)/ee/lib/libpad.a +ifeq ($(NO_IOP_HANDLING), 1) + ifeq ($(ENABLE_MTAP), 1) + EMBEDDED = \ + $(PS2SDK)/ee/lib/libpadx.a \ + $(PS2SDK)/ee/lib/libmtap.a + else + EMBEDDED = \ + $(PS2SDK)/ee/lib/libpad.a + endif endif EMBEDDED += \ $(PS2SDK)/ee/lib/libcdvd.a \ - $(PS2SDK)/ee/lib/libpatches.a \ - $(PS2SDK)/ee/lib/libkbd.a \ - $(PS2SDK)/ee/lib/libmouse.a \ - $(PS2SDK)/ee/lib/libaudsrv.a \ - $(PS2SDK)/ports/lib/libjpeg.a \ - $(GSKIT)/lib/libdmakit.a \ + $(PS2SDK)/ee/lib/libpatches.a \ + $(PS2SDK)/ee/lib/libaudsrv.a \ + $(PS2SDK)/ports/lib/libjpeg.a \ + $(GSKIT)/lib/libdmakit.a \ $(GSKIT)/lib/libgskit.a +ifeq ($(HAVE_INPUT_DEVICES), 1) + EMBEDDED += $(PS2SDK)/ee/lib/libkbd.a \ + $(PS2SDK)/ee/lib/libmouse.a +endif + $(LIB_SDL): $(SDL_OBJS) # packing with all embedded libraries rm -rf tmp diff --git a/sdl/src/audio/ps2sdk/SDL_ps2audio.c b/sdl/src/audio/ps2sdk/SDL_ps2audio.c index 5a342504..48dee11e 100755 --- a/sdl/src/audio/ps2sdk/SDL_ps2audio.c +++ b/sdl/src/audio/ps2sdk/SDL_ps2audio.c @@ -52,32 +52,32 @@ extern unsigned char audsrv_irx; static int spu2_init() { - int error; + int id, ret; SifInitRpc(0); - +#ifndef NO_IOP_HANDLING #ifdef USE_FREESD // load freesd (libsd replacement) - SifExecModuleBuffer(&freesd_irx, size_freesd_irx, 0, NULL, &error); - if (error < 0) - { + id = SifExecModuleBuffer(&freesd_irx, size_freesd_irx, 0, NULL, &ret); + if (id < 0 || ((ret & 3) != 0)) + { SDL_SetError("Failed to load FREESD module"); - } + } #else - error = SifLoadModule("rom0:LIBSD", 0, NULL); - if (error < 0) + id = SifLoadStartModule("rom0:LIBSD", 0, NULL, &ret); + if (id < 0 || ((ret & 3) != 0)) { SDL_SetError("Failed to open LIBSD module"); return -1; } #endif - SifExecModuleBuffer(&audsrv_irx, size_audsrv_irx, 0, NULL, &error); - if (error < 0) + id = SifExecModuleBuffer(&audsrv_irx, size_audsrv_irx, 0, NULL, &ret); + if (id < 0 || ((ret & 3) != 0)) { SDL_SetError("Failed to load audsrv module"); return -1; } - +#endif /* init audsrv */ audsrv_init(); diff --git a/sdl/src/joystick/ps2sdk/ps2joystick.c b/sdl/src/joystick/ps2sdk/ps2joystick.c index 8593b323..9e24c708 100755 --- a/sdl/src/joystick/ps2sdk/ps2joystick.c +++ b/sdl/src/joystick/ps2sdk/ps2joystick.c @@ -145,78 +145,79 @@ static int wait_pad(int port, int slot, int tries) */ int SDL_SYS_JoystickInit(void) { - int ret; + int ret, id; int mtap_enabled; int index; int numports, numdevs; int port, slot; printf("SDL_Joystick: JoystickInit begins\n"); - +#ifndef NO_IOP_HANDLING #ifdef PS2SDL_ENABLE_MTAP #ifdef USE_FREESIO2 - SifExecModuleBuffer(sio2man_irx, size_sio2man_irx, 0, NULL, &ret); - if (ret < 0) + id = SifExecModuleBuffer(sio2man_irx, size_sio2man_irx, 0, NULL, &ret); + if (id < 0 || ((ret & 3) != 0)) { SDL_SetError("Failed to load SIO2MAN"); return 0; } - SifExecModuleBuffer(padman_irx, size_padman_irx, 0, NULL, &ret); - if (ret < 0) + id = SifExecModuleBuffer(padman_irx, size_padman_irx, 0, NULL, &ret); + if (id < 0 || ((ret & 3) != 0)) { SDL_SetError("Failed to load PADMAN"); return 0; } - SifExecModuleBuffer(mtapman_irx, size_mtapman_irx, 0, NULL, &ret); - if (ret < 0) + id = SifExecModuleBuffer(mtapman_irx, size_mtapman_irx, 0, NULL, &ret); + if (id < 0 || ((ret & 3) != 0)) { SDL_SetError("Failed to load MTAPMAN"); return 0; } #else - ret = SifLoadModule("rom0:XSIO2MAN", 0, NULL); - if (ret < 0) + id = SifLoadStartModule("rom0:XSIO2MAN", 0, NULL, &ret); + if (id < 0 || ((ret & 3) != 0)) { SDL_SetError("Failed to load XSIO2MAN"); return 0; } - ret = SifLoadModule("rom0:XPADMAN", 0, NULL); - if (ret < 0) + id = SifLoadStartModule("rom0:XPADMAN", 0, NULL, &ret); + if (id < 0 || ((ret & 3) != 0)) { SDL_SetError("Failed to load XPADMAN"); return 0; } - ret = SifLoadModule("rom0:XMTAPMAN", 0, NULL); - if (ret < 0) + id = SifLoadStartModule("rom0:XMTAPMAN", 0, NULL, &ret); + if (id < 0 || ((ret & 3) != 0)) { SDL_SetError("Failed to load XMTAPMAN"); return 0; } #endif #else - ret = SifLoadModule("rom0:SIO2MAN", 0, NULL); - if (ret < 0) + ret = SifLoadStartModule("rom0:SIO2MAN", 0, NULL, &ret); + if (id < 0 || ((ret & 3) != 0)) { SDL_SetError("Failed to load SIO2MAN"); return 0; } - ret = SifLoadModule("rom0:PADMAN", 0, NULL); - if (ret < 0) + ret = SifLoadStartModule("rom0:PADMAN", 0, NULL, &ret); + if (id < 0 || ((ret & 3) != 0)) { SDL_SetError("Failed to load PADMAN"); return 0; } +#endif #endif ret = padInit(0); printf("SDL_Joystick: padInit: %d\n", ret); -#ifdef PS2SDL_ENABLE_MTAP +#if defined(PS2SDL_ENABLE_MTAP) && !defined(NO_IOP_HANDLING) ret = mtapInit(); printf("SDL_Joystick: mtapInit: %d\n", ret); #endif diff --git a/sdl/src/main/ps2sdk/sdl_main.c b/sdl/src/main/ps2sdk/sdl_main.c index 36702ba6..90a6b93d 100755 --- a/sdl/src/main/ps2sdk/sdl_main.c +++ b/sdl/src/main/ps2sdk/sdl_main.c @@ -18,7 +18,7 @@ int SDL_HasMMX() #undef main int main(int argc, char *argv[]) { -#ifdef PS2SDL_ENABLE_MTAP +#if defined(PS2SDL_ENABLE_MTAP) && !defined(NO_IOP_HANDLING) SifInitRpc(0); smod_mod_info_t info; diff --git a/sdl/src/video/ps2sdk/SDL_ps2USBevents.c b/sdl/src/video/ps2sdk/SDL_ps2USBevents.c index 7b3e0cfd..7d74c813 100755 --- a/sdl/src/video/ps2sdk/SDL_ps2USBevents.c +++ b/sdl/src/video/ps2sdk/SDL_ps2USBevents.c @@ -44,14 +44,14 @@ int PS2_InitUSB(_THIS) int ret; printf("[PS2] Init USB driver\n"); - - SifExecModuleBuffer(ps2usbd_irx, size_ps2usbd_irx, 0, NULL, &ret); - if (ret < 0) +#ifndef NO_IOP_HANDLING + id = SifExecModuleBuffer(ps2usbd_irx, size_ps2usbd_irx, 0, NULL, &ret); + if (id < 0 || ((ret & 3) != 0)) { SDL_SetError("[PS2] Failed to load module: usbd_irx\n"); return -1; } - +#endif usbState = USB_AVAILABLE; printf("[PS2] Init USB driver done\n"); diff --git a/sdl/src/video/ps2sdk/SDL_ps2kbdevents.c b/sdl/src/video/ps2sdk/SDL_ps2kbdevents.c index 21ec64ce..805a9e93 100755 --- a/sdl/src/video/ps2sdk/SDL_ps2kbdevents.c +++ b/sdl/src/video/ps2sdk/SDL_ps2kbdevents.c @@ -352,18 +352,19 @@ void PS2_InitOSKeymap(_THIS) */ int PS2_InitKeyboard(_THIS){ - int ret; + int ret, id; printf("[PS2] Init USB Keyboard\n"); - +#ifndef NO_IOP_HANDLING // the keyboard driver is embedded in the library.... - SifExecModuleBuffer(ps2kbd_irx, size_ps2kbd_irx, 0, NULL, &ret); - if (ret < 0) { + id = SifExecModuleBuffer(ps2kbd_irx, size_ps2kbd_irx, 0, NULL, &ret); + if (id < 0 || ((ret & 3) != 0)) SDL_SetError("[PS2] Failed to load module: ps2kbd_irx\n"); return -1; } - else { - + else +#endif + { if((PS2KbdInit()) == 0) { SDL_SetError("[PS2] PS2KbdInit failed\n"); kbdState = KBD_NOT_AVAILABLE; diff --git a/sdl/src/video/ps2sdk/SDL_ps2mouseevents.c b/sdl/src/video/ps2sdk/SDL_ps2mouseevents.c index 7bfbdb37..a3850948 100755 --- a/sdl/src/video/ps2sdk/SDL_ps2mouseevents.c +++ b/sdl/src/video/ps2sdk/SDL_ps2mouseevents.c @@ -88,10 +88,10 @@ int PS2_InitMouse(_THIS) int ret; printf("[PS2] Init USB Mouse\n"); - +#ifndef NO_IOP_HANDLING // the mouse driver is embedded in the library.... - SifExecModuleBuffer(ps2mouse_irx, size_ps2mouse_irx, 0, NULL, &ret); - if (ret < 0) + id = SifExecModuleBuffer(ps2mouse_irx, size_ps2mouse_irx, 0, NULL, &ret); + if (id < 0 || ((ret & 3) != 0)) { SDL_SetError("[PS2] Failed to load module: PS2MOUSE.IRX\n"); @@ -107,6 +107,7 @@ int PS2_InitMouse(_THIS) return -1; } else +#endif { // Initialize the mouse if(PS2MouseInit() < 0)