It runs on the ps2, barely (broken)

This commit is contained in:
Carlos Sanchez 2024-09-12 04:46:47 -04:00
parent 93d9113451
commit 1de3a60aef
3 changed files with 23 additions and 12 deletions

View File

@ -6,14 +6,14 @@
# Licenced under Academic Free License version 2.0 # Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details. # Review ps2sdk README & LICENSE files for further details.
EE_BIN = $(PROGRAM).elf EE_BIN = $(PROGRAM_PS2).elf
# KERNEL_NOPATCH = 1 # KERNEL_NOPATCH = 1
# NEWLIB_NANO = 1 # NEWLIB_NANO = 1
EE_OBJS = $(PROGRAM).o EE_OBJS = $(PROGRAM_PS2).o
EE_CFLAGS += -fdata-sections -DPS2 -ffunction-sections -I$(PS2SDK)/ports/include -Wformat=0 EE_CFLAGS += -DPS2 -fdata-sections -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 EE_LDFLAGS += -L$(PS2SDK)/ports/lib -L$(GSKIT)/lib -lSDL2 -lSDL2main -lkernel -lpatches -lgskit -ldmakit -lps2_drivers -lm -Wl,--gc-sections
ifeq ($(DUMMY_TIMEZONE), 1) ifeq ($(DUMMY_TIMEZONE), 1)
EE_CFLAGS += -DDUMMY_TIMEZONE EE_CFLAGS += -DDUMMY_TIMEZONE

View File

@ -1,9 +1,15 @@
#!/bin/bash #!/bin/bash
if [ "$#" -ne "1" ]; then if [ "$#" -lt "1" ]; then
echo "ERROR: You must pass the program name! For instance, to build maze.elf," echo "ERROR: You must pass the program name! For instance, to build maze.elf,"
echo "pass in just 'maze'" echo "pass in just 'maze'"
exit 1 exit 1
fi fi
make -f Makefile_PS2 PROGRAM="$1" make -f Makefile_PS2 PROGRAM_PS2="$1"
if [ "$#" -gt "1" ]; then
echo "Running on $2"
ps2client -h "$2" reset
ps2client -h "$2" execee host:$1.elf
fi

17
maze.c
View File

@ -4,18 +4,20 @@
#endif #endif
#ifdef DIRECTBUILD #ifdef DIRECTBUILD
// clang-format off
#define MATHC_USE_UNIONS #define MATHC_USE_UNIONS
#define MATHC_NO_STRUCT_FUNCTIONS #define MATHC_NO_STRUCT_FUNCTIONS
#include "haloo3d/lib/mathc.c" #include "haloo3d/lib/mathc.c"
#define FNL_IMPL #define FNL_IMPL
#include "haloo3d/lib/FastNoiseLite.h"
#include "haloo3d/haloo3d.c" #include "haloo3d/haloo3d.c"
#include "haloo3d/haloo3dex_console.c" // #include "haloo3d/haloo3dex_console.c"
#include "haloo3d/haloo3dex_easy.c" #include "haloo3d/haloo3dex_easy.c"
#include "haloo3d/haloo3dex_gen.c" #include "haloo3d/haloo3dex_gen.c"
#include "haloo3d/haloo3dex_obj.c" #include "haloo3d/haloo3dex_obj.c"
#include "haloo3d/haloo3dex_print.c" #include "haloo3d/haloo3dex_print.c"
#include "haloo3d/lib/FastNoiseLite.h"
#include "unigi.platform.sdl2/main.c" #include "unigi.platform.sdl2/main.c"
// clang-format on
#else #else
#include "haloo3d/haloo3d.h" #include "haloo3d/haloo3d.h"
#include "haloo3d/haloo3dex_console.h" #include "haloo3d/haloo3dex_console.h"
@ -995,11 +997,10 @@ void create_paintingobj(haloo3d_obj *obj) {
} }
} }
#ifdef PS2
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
#else
int main() { // int argc, char **argv) { // We HAVE to use argc and argv
#endif eprintf("Argc: %d, prog: %s\n", argc, argv[0]);
srand(clock()); srand(clock());
@ -1120,6 +1121,7 @@ int main() { // int argc, char **argv) {
// render.camera.pitch = MPI - 0.1; // 2.2; // render.camera.pitch = MPI - 0.1; // 2.2;
// ceili->pos.y = -10; // ceili->pos.y = -10;
#ifndef PS2
haloo3d_debugconsole dc; haloo3d_debugconsole dc;
haloo3d_debugconsole_init(&dc); haloo3d_debugconsole_init(&dc);
@ -1134,6 +1136,7 @@ int main() { // int argc, char **argv) {
haloo3d_debugconsole_set(&dc, "camera/pos_y.f", &render.camera.pos.y); haloo3d_debugconsole_set(&dc, "camera/pos_y.f", &render.camera.pos.y);
haloo3d_debugconsole_set(&dc, "camera/pitch.f", &render.camera.pitch); haloo3d_debugconsole_set(&dc, "camera/pitch.f", &render.camera.pitch);
haloo3d_debugconsole_set(&dc, "obj/ceil/pos_y.f", &ceili->pos.y); haloo3d_debugconsole_set(&dc, "obj/ceil/pos_y.f", &ceili->pos.y);
#endif
// Set up ECS entities. For this game, we mostly have global entities. // Set up ECS entities. For this game, we mostly have global entities.
mecs ecs; mecs ecs;
@ -1238,9 +1241,11 @@ int main() { // int argc, char **argv) {
case unigi_enum_event_input_keyboard: case unigi_enum_event_input_keyboard:
if (event.data.input_keyboard.down) { if (event.data.input_keyboard.down) {
switch (event.data.input_keyboard.button) { switch (event.data.input_keyboard.button) {
#ifndef PS2
case KEY_SPACE: case KEY_SPACE:
haloo3d_debugconsole_beginprompt(&dc); haloo3d_debugconsole_beginprompt(&dc);
break; break;
#endif
default: default:
exit(0); exit(0);
} }