Unified ps2 build

This commit is contained in:
Carlos Sanchez 2024-09-12 02:58:48 -04:00
parent dfa6176182
commit 1d17372d8e
5 changed files with 84 additions and 10 deletions

44
Makefile_PS2 Normal file
View File

@ -0,0 +1,44 @@
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright 2001-2022, ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
EE_BIN = $(PROGRAM).elf
# KERNEL_NOPATCH = 1
# NEWLIB_NANO = 1
EE_OBJS = $(PROGRAM).o
EE_CFLAGS += -fdata-sections -DPS2 -ffunction-sections -I$(PS2SDK)/ports/include -Wformat=0
EE_LDFLAGS += -L$(PS2SDK)/ports/lib -L$(GSKIT)/lib -lSDL2 -lgskit -ldmakit -lps2_drivers -lm -Wl,--gc-sections
ifeq ($(DUMMY_TIMEZONE), 1)
EE_CFLAGS += -DDUMMY_TIMEZONE
endif
ifeq ($(DUMMY_LIBC_INIT), 1)
EE_CFLAGS += -DDUMMY_LIBC_INIT
endif
ifeq ($(KERNEL_NOPATCH), 1)
EE_CFLAGS += -DKERNEL_NOPATCH
endif
ifeq ($(DEBUG), 1)
EE_CFLAGS += -DDEBUG -O0 -g
else
EE_CFLAGS += -Os
EE_LDFLAGS += -s
endif
all: $(EE_BIN)
clean:
rm -rf $(EE_OBJS) $(EE_BIN)
# Include makefiles
include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal

9
make_ps2.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
if [ "$#" -ne "1" ]; then
echo "ERROR: You must pass the program name! For instance, to build maze.elf,"
echo "pass in just 'maze'"
exit 1
fi
make -f Makefile_PS2 PROGRAM="$1"

41
maze.c
View File

@ -1,12 +1,24 @@
#ifdef PS2
#define DIRECTBUILD
#endif
#ifdef DIRECTBUILD
#include "haloo3d/haloo3d.c"
#include "haloo3d/haloo3dex_console.c"
#include "haloo3d/haloo3dex_easy.c"
#include "haloo3d/haloo3dex_gen.c"
#include "haloo3d/haloo3dex_obj.c"
#include "haloo3d/haloo3dex_print.c"
#include "unigi.platform.sdl2/main.c"
#else
#include "haloo3d/haloo3d.h"
#include "haloo3d/haloo3dex_console.h"
#include "haloo3d/haloo3dex_easy.h"
#include "haloo3d/haloo3dex_gen.h"
// #include "haloo3d/haloo3dex_img.h"
#include "haloo3d/haloo3dex_obj.h"
#include "haloo3d/haloo3dex_print.h"
#include "unigi/main.h"
#endif
#include "ecs2.h"
#include "keys.h"
@ -22,25 +34,36 @@
#include <stdlib.h>
// INteresting flags for debugging
#define FASTFILL
#define NUMMICE 1
#define MOUSELOGGING
// #define NOWALLS
#ifdef PS2
#define WIDTH 160
#define HEIGHT 120
#define SCREENSCALE 4
#define DITHERSTART 2.5
#define DITHEREND 3.5
int fps = 24;
uint16_t sky = 0xF644;
#else
#define WIDTH 480
#define HEIGHT 300
#define ASPECT ((float)WIDTH / HEIGHT)
#define SCREENSCALE 2
#define MOUSELOGGING
#define DITHERSTART 10000
#define DITHEREND 10000
int fps = 30;
uint16_t sky = 0xF000;
#endif
#define ASPECT ((float)WIDTH / HEIGHT)
#define SWIDTH (WIDTH * SCREENSCALE)
#define SHEIGHT (HEIGHT * SCREENSCALE)
#define NEARCLIP 0.01
#define FARCLIP 100.0
#define LIGHTANG -MPI / 4.0
#define AVGWEIGHT 0.85
// Try 0.5 and 3.5 or something
#define DITHERSTART 10000
#define DITHEREND 10000
// Game options
#define MAZESIZE 15
@ -96,8 +119,6 @@ const char POLYNAMES[NUMPOLYS][20] = {"tetrahedron"};
float fov = 90.0;
float minlight = 0.15;
float speed = 1.0;
int fps = 30;
uint16_t sky = 0xF000;
struct vec2i dirtovec(uint8_t dir) {
struct vec2i result;