Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions arch/ps2/CONFIG.PS2
Original file line number Diff line number Diff line change
@@ -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 "$@"
32 changes: 32 additions & 0 deletions arch/ps2/Makefile.in
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions arch/ps2/README.md
Original file line number Diff line number Diff line change
@@ -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.
21 changes: 21 additions & 0 deletions arch/ps2/pad.config
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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."
Expand Down
26 changes: 26 additions & 0 deletions docs/platform_matrix.html
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,32 @@
loadsave_meter: yes,
},

ps2:
{
platform: "ps2",
description: "PlayStation 2",
architecture: "MIPS (ELF)",
endian: "Little",
toolchain: "gcc 15.2 <br> 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",
Expand Down
8 changes: 8 additions & 0 deletions src/configure.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/event/sdl/event_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/io/zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions src/platform/sdl/SDLmzx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down