diff options
| author | Nicholas Rodrigues Lordello <[email protected]> | 2026-10-29 19:24:31 +0100 |
|---|---|---|
| committer | Nicholas Rodrigues Lordello <[email protected]> | 2026-10-29 19:24:31 +0100 |
| commit | 4bfe4900b80c17702d9e2c02b1740c790537d5bd (patch) | |
| tree | 97c8acc9dd04fce8a8241c3488baff8a96fa88cf | |
| parent | 93a202d1fa6cd05b494bbf7175d79c6da075f333 (diff) | |
Add PS Vita Port
Compile PICO-w for the PS Vita :tada:.
Fixes some minor compiler warnings that only showed up because
of the different compilation target, and makes the Makefile port
system a little more opinionated.
| -rw-r--r-- | Makefile | 12 | ||||
| -rw-r--r-- | port/vita/container/Containerfile | 17 | ||||
| -rw-r--r-- | port/vita/rules.mk | 25 | ||||
| -rw-r--r-- | port/vita/src/vita.c | 4 | ||||
| -rw-r--r-- | src/fs.c | 2 | ||||
| -rw-r--r-- | src/input.c | 4 |
6 files changed, 57 insertions, 7 deletions
@@ -1,17 +1,17 @@ --include config.mk +-include port/$(PORT)/config.mk CC ?= cc -AR ?= ar HOSTCC ?= cc PICO8 ?= pico8 WASM2C ?= wasm2c TAR ?= tar ARCH ?= $(shell uname -m) +PKGCONFIG ?= pkg-config CFLAGS ?= -std=c99 -Wall -Wextra -O2 -MMD -Isrc -Ilib -I$(SYSTEM) \ - $(shell pkg-config sdl3 --cflags) + $(shell $(PKGCONFIG) sdl3 --cflags) HOSTCFLAGS ?= -std=c99 -Wall -Wextra -O2 -LDFLAGS ?= $(shell pkg-config sdl3 --libs) -lm +LDFLAGS ?= $(shell $(PKGCONFIG) sdl3 --libs) -lm W2CFLAGS ?= --disable-tail-call TARGET := build/$(ARCH) @@ -23,12 +23,14 @@ SRC := $(wildcard src/*.c) $(SYSTEM)/pico8.c $(SYSTEM)/sysroot.c OBJ := $(patsubst %.c,$(OUT)/%.o,$(SRC:build/%=%)) SYS := $(addprefix $(SYSTEM)/,pico8.c pico8.h sysroot.c sysroot.h wasm-rt.h) +-include port/$(PORT)/rules.mk + .PHONY: all all: $(TARGET)/picow ; $(TARGET)/picow: $(OBJ) @ echo "CC\t$@" - @ $(CC) $(OBJ) -o $@ $(LDFLAGS) + @ $(CC) $^ -o $@ $(LDFLAGS) $(OUT)/src/%.o: src/%.c $(SYSTEM)/pico8.h $(SYSTEM)/sysroot.h @ echo "CC\t$@" diff --git a/port/vita/container/Containerfile b/port/vita/container/Containerfile new file mode 100644 index 0000000..85b1f40 --- /dev/null +++ b/port/vita/container/Containerfile @@ -0,0 +1,17 @@ +ARG VITASDK_VERSION=2026.08-minimal-20260924.2 +FROM docker.io/vitasdk/vitasdk:${VITASDK_VERSION} + +ARG SDL3_VERSION=3.4.16 +WORKDIR /tmp +RUN curl -fsSL "https://github.com/libsdl-org/SDL/releases/download/release-$SDL3_VERSION/SDL3-$SDL3_VERSION.tar.gz" \ + | tar -xz && \ + cmake -S "SDL3-$SDL3_VERSION" \ + -B sdl3-build \ + -DCMAKE_TOOLCHAIN_FILE="$VITASDK/share/vita.toolchain.cmake" \ + -DCMAKE_BUILD_TYPE=Release && \ + cmake --build sdl3-build --parallel "$(nproc)" && \ + cmake --install sdl3-build && \ + rm -rf "SDL3-$SDL3_VERSION" sdl3-build + +WORKDIR /pw +CMD ["make", "PORT=vita"] diff --git a/port/vita/rules.mk b/port/vita/rules.mk new file mode 100644 index 0000000..6ac47c7 --- /dev/null +++ b/port/vita/rules.mk @@ -0,0 +1,25 @@ +TITLE := picow +TITLEID := PICO00008 + +port: $(TARGET)/picow.vpk + +$(TARGET)/picow.vpk: $(TARGET)/eboot.bin $(TARGET)/param.sfo + vita-pack-vpk -s $(TARGET)/param.sfo -b $(TARGET)/eboot.bin $@ + +$(TARGET)/eboot.bin: $(TARGET)/picow.velf + vita-make-fself -s $(TARGET)/picow.velf $@ + +$(TARGET)/param.sfo: + vita-mksfoex -s TITLE_ID=$(TITLEID) "PICO-w" $@ + +$(TARGET)/picow.velf: $(TARGET)/picow.elf + vita-elf-create $(TARGET)/picow.elf $@ + +$(TARGET)/picow.elf: $(OBJ) $(OUT)/port/vita/src/vita.o + @ echo "CC\t$@" + @ $(CC) $^ -o $@ $(LDFLAGS) + +$(OUT)/port/vita/src/vita.o: port/vita/src/vita.c + @ echo "CC\t$@" + @ mkdir -p $(dir $@) + @ $(CC) $(CFLAGS) -c $< -o $@ diff --git a/port/vita/src/vita.c b/port/vita/src/vita.c new file mode 100644 index 0000000..bc5ca60 --- /dev/null +++ b/port/vita/src/vita.c @@ -0,0 +1,4 @@ +// By default the VitaSDK only allocates a small stack for the main thread +// which is not enough for the PICO-8 engine. Specify a larter stack, 1 MiB +// should be more than enough, and we can grow it if needed. +unsigned int sceUserMainThreadStackSize = 1024 * 1024; @@ -660,10 +660,12 @@ bool pw_fs_seek(struct pw_fs *fs, pw_fd fd, int64_t offset, // This is a little weird - but the final position needs to fit in // a signed 64-bit value (even if we use unsigned `size_t` values // internally). In practice, this should not matter. +#if SIZE_MAX > INT64_MAX if (pos > INT64_MAX) { fs->err = PW_EOVERFLOW; return SDL_SetError("seek overflows PICO-8 maximum position"); } +#endif s->pos = pos; if (newpos) { diff --git a/src/input.c b/src/input.c index f85c63c..8eaf6d0 100644 --- a/src/input.c +++ b/src/input.c @@ -256,12 +256,12 @@ static int8_t scancode_to_p8scii(SDL_Scancode sc, SDL_Keymod mod) { #define PW_SCANCODE_MOD_SHIFT 9 static bool handle_key(struct pw_input *input, SDL_KeyboardEvent *event) { - if (event->scancode < 0 || event->scancode > PW_SCANCODE_MASK) { + uint32_t sc = (uint32_t)event->scancode; + if (sc > PW_SCANCODE_MASK) { // Ignore unsupported scancodes. return true; } - uint32_t sc = (uint32_t)event->scancode; if (event->down) { sc |= PW_SCANCODE_PRESSED; } |
