diff --git a/.github/platform-builds.json b/.github/platform-builds.json index e4276dc7..ee76369e 100644 --- a/.github/platform-builds.json +++ b/.github/platform-builds.json @@ -67,12 +67,15 @@ "port_dir": "ps2", "backend": "SDL2", "build_system": "Makefile", - "ci": false, + "runs_on": "ubuntu-22.04", + "build_command": "sh ./ps2/ci-docker-run.sh sh -c \"sh ./ps2/ci-prepare.sh && sh ./ps2/ci-build.sh\"", + "artifact_name": "ps2-build", + "artifact_path": "ps2/OpenSupaplex-ps2.zip", "release": false }, { "id": "ps3", - "name": "PS3", + "name": "PlayStation 3", "port_dir": "ps3", "backend": "SDL2", "build_system": "Makefile", diff --git a/.gitignore b/.gitignore index d5dc4da8..14599aca 100644 --- a/.gitignore +++ b/.gitignore @@ -64,6 +64,9 @@ ps3/*.elf ps3/*.pkg ps3/*.map +# PS2 stuff +ps2/*.elf + # WASM stuff wasm/opensupaplex.data wasm/opensupaplex.html @@ -77,3 +80,5 @@ riscos/\!OSupaplex/*,ff8 riscos/\!OSupaplex/audio riscos/\!OSupaplex/data +/ps2/OpenSupaplex +ps2/OpenSupaplex-ps2.zip diff --git a/PLATFORM_SUPPORT.md b/PLATFORM_SUPPORT.md index 9361f81b..a4535c1f 100644 --- a/PLATFORM_SUPPORT.md +++ b/PLATFORM_SUPPORT.md @@ -11,8 +11,8 @@ This document is generated from `.github/platform-builds.json`. | Linux | SDL2 | Makefile | `linux` | Yes | Yes | | PS Vita | SDL2 | CMake | `vita` | Yes | Yes | | PSP | SDL1 | Makefile | `psp` | Yes | Yes | -| PlayStation 2 | SDL2 | Makefile | `ps2` | No | No | -| PS3 | SDL2 | Makefile | `ps3` | Yes | Yes | +| PlayStation 2 | SDL2 | Makefile | `ps2` | Yes | No | +| PlayStation 3 | SDL2 | Makefile | `ps3` | Yes | Yes | | Nintendo DS | SDL1 | Makefile | `nds` | Yes | Yes | | Nintendo 3DS | SDL1 | Makefile | `3ds` | Yes | Yes | | Wii | SDL1 | Makefile | `wii` | Yes | Yes | diff --git a/ci/Dockerfile-ps2 b/ci/Dockerfile-ps2 new file mode 100644 index 00000000..7db79525 --- /dev/null +++ b/ci/Dockerfile-ps2 @@ -0,0 +1,8 @@ +FROM ps2dev/ps2dev:latest + +MAINTAINER Sergio Padrino (@sergiou87) + +RUN apk add --no-cache make zip gmp mpfr4 mpc1 + +WORKDIR /src +CMD ["/bin/sh"] \ No newline at end of file diff --git a/ps2/Makefile b/ps2/Makefile index 703f209d..8e2daa0c 100644 --- a/ps2/Makefile +++ b/ps2/Makefile @@ -1,24 +1,27 @@ DEBUG = 0 -TARGET = OpenSupaplex-debug.elf +TARGET = OpenSupaplex.elf +TARGET_DEBUG = OpenSupaplex-debug.elf TARGET_RELEASE = OpenSupaplex.elf ifeq ($(DEBUG), 1) + TARGET := $(TARGET_DEBUG) OPTIMIZE_LV := -O0 -g RARCH_DEFINES += -DDEBUG else + TARGET := $(TARGET_RELEASE) OPTIMIZE_LV := -O3 LDFLAGS := -s endif -INCDIR = -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ports/include +INCDIR = -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ports/include -I$(PS2SDK)/ports/include/SDL2 CFLAGS = $(OPTIMIZE_LV) -ffast-math -fsingle-precision-constant ASFLAGS = $(CFLAGS) CFLAGS += -D__PS2__ -Dmain=SDL_main -DHAVE_SDL2 LDFLAGS += -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ports/lib -L. -LIBS += -lSDL2main -lSDL2 -lSDL2_mixer -lpatches -lgskit -ldmakit -lps2_drivers -lxmp -lmodplug +LIBS += -lSDL2main -lSDL2 -lSDL2_mixer -lpatches -lmodplug -lxmp -lgskit -ldmakit -lps2_drivers -lstdc++ -lm -lc SRC = $(wildcard ../src/*.c) $(wildcard ../src/sdl_common/*.c) $(wildcard ../src/sdl2/*.c) ../src/null/virtualKeyboard.c ../src/lib/ini/ini.c EXCLUDE = ../src/sdl1/video.c @@ -38,11 +41,13 @@ EE_GPVAL = $(GPVAL) all: $(EE_BIN) clean: - rm -f $(EE_BIN) $(EE_OBJS) + rm -f $(TARGET_DEBUG) $(TARGET_RELEASE) $(TARGET_RELEASE).packed $(EE_OBJS) release: all - ps2-packer $(EE_BIN) $(TARGET_RELEASE) + rm -f $(TARGET_RELEASE).packed + ps2-packer $(EE_BIN) $(TARGET_RELEASE).packed + mv $(TARGET_RELEASE).packed $(TARGET_RELEASE) #Include preferences include $(PS2SDK)/samples/Makefile.pref -include $(PS2SDK)/samples/Makefile.eeglobal_cpp \ No newline at end of file +include $(PS2SDK)/samples/Makefile.eeglobal \ No newline at end of file diff --git a/ps2/ci-build.sh b/ps2/ci-build.sh index f7a5cdbc..bb261224 100644 --- a/ps2/ci-build.sh +++ b/ps2/ci-build.sh @@ -1,7 +1,17 @@ -#!/bin/bash +#!/bin/sh -set -euo pipefail +set -eu cd "$(dirname "$0")" + +bundle_dir=OpenSupaplex + make clean -make -j8 release \ No newline at end of file +make -j8 + +rm -rf "$bundle_dir" OpenSupaplex-ps2.zip +mkdir "$bundle_dir" +cp OpenSupaplex.elf "$bundle_dir"/ +cp -R ../resources/* "$bundle_dir"/ + +zip -r OpenSupaplex-ps2.zip "$bundle_dir" \ No newline at end of file diff --git a/ps2/ci-docker-run.sh b/ps2/ci-docker-run.sh new file mode 100644 index 00000000..d5035eab --- /dev/null +++ b/ps2/ci-docker-run.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +repo_root=$(cd "$(dirname "$0")/.." && pwd) +image_name=sergiou87/ps2dev-docker-open-supaplex:7.2 + +if ! docker pull "$image_name"; then + docker build -f "$repo_root/ci/Dockerfile-ps2" -t "$image_name" "$repo_root/ci" +fi + +docker run --rm -v "$repo_root":/src -w /src "$image_name" "$@" \ No newline at end of file diff --git a/ps2/ci-prepare.sh b/ps2/ci-prepare.sh index 5b76b110..a8f2bab0 100644 --- a/ps2/ci-prepare.sh +++ b/ps2/ci-prepare.sh @@ -1,15 +1,10 @@ -#!/bin/bash +#!/bin/sh -set -euo pipefail +set -eu : "${PS2DEV:?PS2DEV must be set}" : "${PS2SDK:?PS2SDK must be set}" -if ! command -v ps2-packer >/dev/null 2>&1; then - echo "ps2-packer not found in PATH" >&2 - exit 1 -fi - test -d "$PS2DEV/gsKit/include" test -d "$PS2DEV/gsKit/lib" test -d "$PS2SDK/ports/include" diff --git a/src/sdl2/video.c b/src/sdl2/video.c index 4fd4228e..db83053d 100644 --- a/src/sdl2/video.c +++ b/src/sdl2/video.c @@ -85,6 +85,9 @@ void initializeVideo(uint8_t fastMode) // Disable vsync in fast mode to prevent limiting FPS rate if (fastMode == 0) { +#ifdef __PS2__ + SDL_SetHint(SDL_HINT_PS2_DYNAMIC_VSYNC, "1"); +#endif rendererFlags |= SDL_RENDERER_PRESENTVSYNC; } @@ -105,6 +108,9 @@ void initializeVideo(uint8_t fastMode) #ifdef __PSP__ format = SDL_PIXELFORMAT_ABGR32; #endif +#ifdef __PS2__ + format = SDL_PIXELFORMAT_ABGR1555; +#endif gTexture = SDL_CreateTexture(gRenderer, format, @@ -118,7 +124,11 @@ void initializeVideo(uint8_t fastMode) exit(1); } +#ifdef __PS2__ + gTextureSurface = SDL_CreateRGBSurfaceWithFormat(0, kScreenWidth, kScreenHeight, 8, SDL_PIXELFORMAT_ABGR1555); +#else gTextureSurface = SDL_CreateRGBSurfaceWithFormat(0, kScreenWidth, kScreenHeight, 8, SDL_PIXELFORMAT_RGB24); +#endif if (gTextureSurface == NULL) { diff --git a/src/supaplex.c b/src/supaplex.c index 2a70e2c0..1ee14976 100644 --- a/src/supaplex.c +++ b/src/supaplex.c @@ -1941,7 +1941,11 @@ void readConfig() // proc near ; CODE XREF: start:loc_46F0Fp FILE *file = openWritableFile("SUPAPLEX.CFG", "rb"); if (file == NULL) { +#ifdef __PS2__ // PS2 for now is not returning errno code properly + if (1) // ax == 2? ax has error code, 2 is file not found (http://stanislavs.org/helppc/dos_error_codes.html) +#else if (errno == ENOENT || errno == ENOSYS || errno == EIO) // ax == 2? ax has error code, 2 is file not found (http://stanislavs.org/helppc/dos_error_codes.html) +#endif { // loc_47551: //; CODE XREF: readConfig+Fj // ; readConfig+17j