diff --git a/arch/ps2/CONFIG.PS2 b/arch/ps2/CONFIG.PS2 new file mode 100644 index 000000000..ec8f215ee --- /dev/null +++ b/arch/ps2/CONFIG.PS2 @@ -0,0 +1,8 @@ +#!/bin/sh + +[[ -z $PS2DEV ]] && { echo "\$PS2DEV is unset. Aborting"; exit 1; } + +./config.sh --platform ps2 --prefix "$PS2DEV/ps2sdk/ee" --optimize-size \ + --disable-editor --disable-helpsys --disable-utils \ + --enable-release --enable-meter --enable-extram \ + --enable-stdio-redirect "$@" diff --git a/arch/ps2/Makefile.in b/arch/ps2/Makefile.in new file mode 100644 index 000000000..7b0df2ca8 --- /dev/null +++ b/arch/ps2/Makefile.in @@ -0,0 +1,32 @@ +ifeq ($(strip $(PS2DEV)),) +$(error "PS2DEV must be set in your environment.") +endif + +CROSS_COMPILE = mips64r5900el-ps2-elf- +BINEXT := .elf + +# Disable rules that require target code to run natively. +SUPPRESS_HOST_TARGETS ?= 1 + +PS2_CFLAGS = -D_EE -D__PS2__ +PS2_INCLUDES = -isystem $(PS2DEV)/ps2sdk/common/include -isystem $(PS2DEV)/ps2sdk/ports/include +PS2_LDFLAGS = -T$(PS2DEV)/ps2sdk/ee/startup/linkfile -L$(PS2DEV)/ps2sdk/ports/lib \ + -L$(PS2DEV)/gsKit/lib -Wl,-zmax-page-size=128 -G0 -gdwarf-2 -gz + +SDL_CFLAGS = -isystem $(PS2DEV)/ps2sdk/ports/include/SDL2 +SDL_LDFLAGS = -lSDL2main -lSDL2 -lpatches -lgskit -ldmakit -lps2_drivers + +LIBPNG_CFLAGS = +LIBPNG_LDFLAGS = -lpng16 + +MIKMOD_CFLAGS = +MIKMOD_LDFLAGS = -lmikmod + +ARCH_CFLAGS += ${PS2_CFLAGS} ${PS2_INCLUDES} +ARCH_CXXFLAGS += ${PS2_CFLAGS} ${PS2_INCLUDES} +ARCH_LDFLAGS += ${PS2_LDFLAGS} + +build: ${build} + ${CP} arch/ps2/pad.config ${build} + +include arch/zip.inc diff --git a/arch/ps2/README.md b/arch/ps2/README.md new file mode 100644 index 000000000..5138bc74d --- /dev/null +++ b/arch/ps2/README.md @@ -0,0 +1,14 @@ +# Building MegaZeux for PS2 + +NOTE: Only tested on Linux and WSL2. + +## Preparation + +You need to build or install the [ps2dev](https://github.com/ps2dev/ps2dev) toolchain. + +The toolchain comes with all MegaZeux dependencies pre-installed. + +## Configuration + +See CONFIG.PS2 for an optimal `config.sh' configure line. You need +to ensure PS2DEV is defined and valid. diff --git a/arch/ps2/pad.config b/arch/ps2/pad.config new file mode 100644 index 000000000..ebb5682ca --- /dev/null +++ b/arch/ps2/pad.config @@ -0,0 +1,21 @@ +# 1 Select +# 2 L3 +# 3 R3 +# 4 Start +# 5 Up +# 6 Right +# 7 Down +# 8 Left +# 9 L2 +# 10 R2 +# 11 L1 +# 12 R1 +# 13 Triangle +# 14 Circle +# 15 Cross +# 16 Square + +#gamepad.a = act_b +#gamepad.b = act_a +#gamepad.x = act_y +#gamepad.y = act_x diff --git a/config.sh b/config.sh index c092c956c..ca924e0c0 100755 --- a/config.sh +++ b/config.sh @@ -32,6 +32,7 @@ usage() { echo " darwin Mac OS X Unix-like install" echo " darwin-devel Mac OS X running from current dir" echo " darwin-dist Mac OS X multiarchitecture .app (see arch/darwin/README.md)" + echo " ps2 Experimental PS2 port" echo " psp Experimental PSP port" echo " gp2x Experimental GP2X port" echo " nds Experimental NDS port" @@ -1073,6 +1074,27 @@ case "$PLATFORM" in POLL="false" IPV6="false" ;; + +"ps2") + echo "Enabling PS2-specific hacks." + echo "#define CONFIG_PS2" >> src/config.h + echo "BUILD_PS2=1" >> platform.inc + + echo "Force-disabling modular build on PS2." + MODULAR="false" + + echo "Force-disabling OpenGL and overlay renderers on PS2." + GL="false" + OVERLAY="false" + + echo "Force-disabling stack protector on PS2." + STACK_PROTECTOR="false" + + echo "Force-disabling getaddrinfo, poll, and IPv6 on PS2." + GETADDRINFO="false" + POLL="false" + IPV6="false" + ;; "psvita") echo "Enabling PS Vita-specific hacks." diff --git a/docs/platform_matrix.html b/docs/platform_matrix.html index 832851ef4..b1c406703 100644 --- a/docs/platform_matrix.html +++ b/docs/platform_matrix.html @@ -472,6 +472,32 @@ loadsave_meter: yes, }, + ps2: + { + platform: "ps2", + description: "PlayStation 2", + architecture: "MIPS (ELF)", + endian: "Little", + toolchain: "gcc 15.2
binutils 2.44.0", + packaged: ZIP, + stack_protector: _FAULTY(), + layer_rendering: yes, + module_engine: xmp, + adlib_engine: rad, + ogg_vorbis: libvorbis, + optimization: size, + sdl: sdl2, + editor: no_low_memory, + helpsys: no_low_memory, + audio: yes, + software: yes, + network: _FAULTY(), + updater: no_updater, + png: yes, + hashtables: yes, + loadsave_meter: yes, + }, + psvita: { platform: "psvita", diff --git a/src/configure.c b/src/configure.c index d5db4af43..cb5864854 100644 --- a/src/configure.c +++ b/src/configure.c @@ -94,6 +94,14 @@ #define SAVE_SLOTS_DEFAULT true #endif +#ifdef CONFIG_PS2 +#define VIDEO_OUTPUT_DEFAULT "softscale" +#define FULLSCREEN_WIDTH_DEFAULT 640 +#define FULLSCREEN_HEIGHT_DEFAULT 448 +#define FULLSCREEN_DEFAULT 1 +#define SAVE_SLOTS_DEFAULT true +#endif + #ifdef CONFIG_PSVITA #define VIDEO_OUTPUT_DEFAULT "softscale" #define FULLSCREEN_WIDTH_DEFAULT 960 diff --git a/src/event/sdl/event_sdl.c b/src/event/sdl/event_sdl.c index 526f007f9..6561748e1 100644 --- a/src/event/sdl/event_sdl.c +++ b/src/event/sdl/event_sdl.c @@ -46,7 +46,6 @@ */ #if !SDL_VERSION_ATLEAST(2,0,0) || \ (!SDL_VERSION_ATLEAST(3,0,0) && defined(CONFIG_3DS)) || \ - (!SDL_VERSION_ATLEAST(3,0,0) && defined(CONFIG_PS2)) || \ (!SDL_VERSION_ATLEAST(2,32,0) && defined(CONFIG_PSP)) || \ (!SDL_VERSION_ATLEAST(2,0,22) && defined(CONFIG_PSVITA)) || \ defined(CONFIG_SWITCH) @@ -1527,6 +1526,7 @@ static boolean process_event(SDL_Event *event) break; } + case SDL_EVENT_GAMEPAD_ADDED: case SDL_EVENT_JOYSTICK_ADDED: { // Add a new joystick. @@ -1541,6 +1541,7 @@ static boolean process_event(SDL_Event *event) break; } + case SDL_EVENT_GAMEPAD_REMOVED: case SDL_EVENT_JOYSTICK_REMOVED: { // Close a disconnected joystick. diff --git a/src/io/zip.c b/src/io/zip.c index 5c2765124..730dd9bfe 100644 --- a/src/io/zip.c +++ b/src/io/zip.c @@ -52,7 +52,7 @@ // DJGPP may be running on exceptionally slow hardware. #if defined(CONFIG_NDS) || defined(CONFIG_3DS) || defined(CONFIG_SWITCH) || \ - defined(CONFIG_PSVITA) || defined(CONFIG_DJGPP) + defined(CONFIG_PSVITA) || defined(CONFIG_DJGPP) || defined(PS2) #define ZIP_WRITE_DATA_DESCRIPTOR #endif diff --git a/src/platform/sdl/SDLmzx.h b/src/platform/sdl/SDLmzx.h index 0399cc994..39f401ac8 100644 --- a/src/platform/sdl/SDLmzx.h +++ b/src/platform/sdl/SDLmzx.h @@ -191,6 +191,8 @@ static inline void *SDL_GetWindowProperty_HWND(SDL_Window *window) #define SDL_EVENT_FINGER_MOTION SDL_FINGERMOTION #define SDL_EVENT_FINGER_UP SDL_FINGERUP #define SDL_EVENT_GAMEPAD_AXIS_MOTION SDL_CONTROLLERAXISMOTION +#define SDL_EVENT_GAMEPAD_ADDED SDL_CONTROLLERDEVICEADDED +#define SDL_EVENT_GAMEPAD_REMOVED SDL_CONTROLLERDEVICEREMOVED #define SDL_EVENT_JOYSTICK_ADDED SDL_JOYDEVICEADDED #define SDL_EVENT_JOYSTICK_REMOVED SDL_JOYDEVICEREMOVED #define SDL_EVENT_JOYSTICK_AXIS_MOTION SDL_JOYAXISMOTION