From e1847d5d67d2521a370ef84e60870668013dbfa5 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Wed, 11 Sep 2024 01:15:19 -0400 Subject: [PATCH 01/10] Setting up changes for new unigi --- .clangd | 2 ++ .gitmodules | 10 ++-------- Makefile | 15 ++++++++++++--- haloo3d | 2 +- maze.c | 3 +-- unigi | 1 + unigi.platform.sdl1 | 1 + unigi/pullall.sh | 10 ---------- unigi/unigi | 1 - unigi/unigi.ext | 1 - unigi/unigi.headers | 1 - unigi/unigi.platform.sdl1 | 1 - 12 files changed, 20 insertions(+), 28 deletions(-) create mode 100644 .clangd create mode 160000 unigi create mode 160000 unigi.platform.sdl1 delete mode 100644 unigi/pullall.sh delete mode 160000 unigi/unigi delete mode 160000 unigi/unigi.ext delete mode 160000 unigi/unigi.headers delete mode 160000 unigi/unigi.platform.sdl1 diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..12be32b --- /dev/null +++ b/.clangd @@ -0,0 +1,2 @@ +CompileFlags: # Tweak the parse settings + Add: [-Iunigi/] diff --git a/.gitmodules b/.gitmodules index b7d4373..354e146 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,14 +2,8 @@ path = haloo3d url = https://github.com/randomouscrap98/haloo3d.git [submodule "unigi/unigi"] - path = unigi/unigi + path = unigi url = https://git.lumen.sh/Fierelier/unigi.git -[submodule "unigi/unigi.headers"] - path = unigi/unigi.headers - url = https://git.lumen.sh/Fierelier/unigi.headers.git -[submodule "unigi/unigi.ext"] - path = unigi/unigi.ext - url = https://git.lumen.sh/Fierelier/unigi.ext [submodule "unigi/unigi.platform.sdl1"] - path = unigi/unigi.platform.sdl1 + path = unigi.platform.sdl1 url = https://git.lumen.sh/Fierelier/unigi.platform.sdl1.git diff --git a/Makefile b/Makefile index 819ca86..c2cb5be 100644 --- a/Makefile +++ b/Makefile @@ -21,24 +21,33 @@ else endif HALOOLIB = haloo3d/build/haloo3d_full.a +UNIGILIBDIR = unigi.platform.sdl1 +UNIGILIB = unigi.platform.sdl1.o .PHONY: clean .PHONY: full +.PHONY: unigi full: - echo "Please specify a sample to build (ends with .exe)" + @echo "Please specify a sample to build (ends with .exe)" $(HALOOLIB): cd haloo3d && $(MAKE) full +$(UNIGILIB): $(UNIGILIBDIR)/main.c + $(CC) $(CFLAGS) -c $< -o $@ + +unigi: $(UNIGILIB) + @echo "Built unigi!" + # Rule to build .o files in main folder $(BUILDD)/%.o: %.c %.h mkdir -p $(BUILDD) $(CC) $(CFLAGS) -c $< -o $@ # Rule to build any sample. We ALWAYS need math so... link it -%.exe: %.o $(HALOOLIB) - $(CC) $(CFLAGS) $< $(HALOOLIB) -o $@ -lm -lSDL +%.exe: %.o $(HALOOLIB) $(UNIGILIB) + $(CC) $(CFLAGS) $^ -o $@ -lm -lSDL # Rule to clean the build files clean: diff --git a/haloo3d b/haloo3d index 9fbc094..a07b4de 160000 --- a/haloo3d +++ b/haloo3d @@ -1 +1 @@ -Subproject commit 9fbc0948f182cd46c4aaff43b632f92f72fb4fb2 +Subproject commit a07b4de2e0753440f0fc664f717e9bc5f46193b9 diff --git a/maze.c b/maze.c index 410a081..9fb3102 100644 --- a/maze.c +++ b/maze.c @@ -6,8 +6,7 @@ #include "haloo3d/haloo3dex_obj.h" #include "haloo3d/haloo3dex_print.h" -#include "unigi/unigi.headers/src/main.h" -#include "unigi/unigi.platform.sdl1/src/main.c" +#include "unigi/main.h" #include "ecs2.h" #include "keys.h" diff --git a/unigi b/unigi new file mode 160000 index 0000000..b7bb4c4 --- /dev/null +++ b/unigi @@ -0,0 +1 @@ +Subproject commit b7bb4c428b1b5776b58b33be89057bf66082dfa2 diff --git a/unigi.platform.sdl1 b/unigi.platform.sdl1 new file mode 160000 index 0000000..e6443ef --- /dev/null +++ b/unigi.platform.sdl1 @@ -0,0 +1 @@ +Subproject commit e6443ef40a27de8e305eda755f43299eb1c6b651 diff --git a/unigi/pullall.sh b/unigi/pullall.sh deleted file mode 100644 index 2d29ebc..0000000 --- a/unigi/pullall.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -set -e -cd unigi -git pull -cd ../unigi.headers -git pull -cd ../unigi.ext -git pull -cd ../unigi.platform.sdl1 -git pull diff --git a/unigi/unigi b/unigi/unigi deleted file mode 160000 index 34aa7f0..0000000 --- a/unigi/unigi +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 34aa7f0a1cd24939c2de879b5dcce03daa0c7de2 diff --git a/unigi/unigi.ext b/unigi/unigi.ext deleted file mode 160000 index cf21dd8..0000000 --- a/unigi/unigi.ext +++ /dev/null @@ -1 +0,0 @@ -Subproject commit cf21dd85c6d49509c946ab9f462edc2e8a73327c diff --git a/unigi/unigi.headers b/unigi/unigi.headers deleted file mode 160000 index ab07d46..0000000 --- a/unigi/unigi.headers +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ab07d46aac8d7043399437b83f81ce8ce3bf1233 diff --git a/unigi/unigi.platform.sdl1 b/unigi/unigi.platform.sdl1 deleted file mode 160000 index e407020..0000000 --- a/unigi/unigi.platform.sdl1 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e407020c2118d7ad2f4d43eca5214b6360a0b7cc From b2963910d92457c20b1712cf10de3ef92512d1df Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Wed, 11 Sep 2024 03:17:57 -0400 Subject: [PATCH 02/10] Build unigi yeah --- Makefile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index c2cb5be..88b1a2d 100644 --- a/Makefile +++ b/Makefile @@ -21,24 +21,24 @@ else endif HALOOLIB = haloo3d/build/haloo3d_full.a -UNIGILIBDIR = unigi.platform.sdl1 -UNIGILIB = unigi.platform.sdl1.o +UNIGIPLAT = $(BUILDD)/unigi.platform.sdl1.o +UNIGILIB = $(BUILDD)/unigi.a .PHONY: clean -.PHONY: full -.PHONY: unigi +.PHONY: libs -full: - @echo "Please specify a sample to build (ends with .exe)" +libs: $(UNIGILIB) $(HALOOLIB) + @echo "Built libs!" $(HALOOLIB): cd haloo3d && $(MAKE) full -$(UNIGILIB): $(UNIGILIBDIR)/main.c - $(CC) $(CFLAGS) -c $< -o $@ +$(UNIGIPLAT): unigi.platform.sdl1/main.c + mkdir -p $(BUILDD) + $(CC) $(CFLAGS) -I. -c $< -o $@ -unigi: $(UNIGILIB) - @echo "Built unigi!" +$(UNIGILIB): $(UNIGIPLAT) + ar -vr $@ $^ # Rule to build .o files in main folder $(BUILDD)/%.o: %.c %.h @@ -46,7 +46,7 @@ $(BUILDD)/%.o: %.c %.h $(CC) $(CFLAGS) -c $< -o $@ # Rule to build any sample. We ALWAYS need math so... link it -%.exe: %.o $(HALOOLIB) $(UNIGILIB) +%.exe: %.o $(UNIGILIB) $(HALOOLIB) $(CC) $(CFLAGS) $^ -o $@ -lm -lSDL # Rule to clean the build files From dfa6176182b3a52b15b469c43fa04467a45f82a3 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Wed, 11 Sep 2024 18:42:08 -0400 Subject: [PATCH 03/10] Unigi updates --- unigi | 2 +- unigi.platform.sdl1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unigi b/unigi index b7bb4c4..cc36d7c 160000 --- a/unigi +++ b/unigi @@ -1 +1 @@ -Subproject commit b7bb4c428b1b5776b58b33be89057bf66082dfa2 +Subproject commit cc36d7c9da306334e3b7001ad5d60e6fec48958e diff --git a/unigi.platform.sdl1 b/unigi.platform.sdl1 index e6443ef..c2bb042 160000 --- a/unigi.platform.sdl1 +++ b/unigi.platform.sdl1 @@ -1 +1 @@ -Subproject commit e6443ef40a27de8e305eda755f43299eb1c6b651 +Subproject commit c2bb042dcb29e55879f9b0b415c2989afed56132 From 1d17372d8ec2d0e186dbe293b8ae0fb0b91bf222 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Thu, 12 Sep 2024 02:58:48 -0400 Subject: [PATCH 04/10] Unified ps2 build --- Makefile_PS2 | 44 +++++++++++++++++++++++++++++++++++++++ make_ps2.sh | 9 ++++++++ maze.c | 41 +++++++++++++++++++++++++++--------- {ps2 => ps2_old}/Makefile | 0 {ps2 => ps2_old}/maze.c | 0 5 files changed, 84 insertions(+), 10 deletions(-) create mode 100644 Makefile_PS2 create mode 100755 make_ps2.sh rename {ps2 => ps2_old}/Makefile (100%) rename {ps2 => ps2_old}/maze.c (100%) diff --git a/Makefile_PS2 b/Makefile_PS2 new file mode 100644 index 0000000..e85ff3b --- /dev/null +++ b/Makefile_PS2 @@ -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 diff --git a/make_ps2.sh b/make_ps2.sh new file mode 100755 index 0000000..2f5e524 --- /dev/null +++ b/make_ps2.sh @@ -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" diff --git a/maze.c b/maze.c index 9fb3102..457c718 100644 --- a/maze.c +++ b/maze.c @@ -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 -// 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; diff --git a/ps2/Makefile b/ps2_old/Makefile similarity index 100% rename from ps2/Makefile rename to ps2_old/Makefile diff --git a/ps2/maze.c b/ps2_old/maze.c similarity index 100% rename from ps2/maze.c rename to ps2_old/maze.c From 2a8cb45651f09f9ff404988e52a4a83eefcad221 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Thu, 12 Sep 2024 03:13:52 -0400 Subject: [PATCH 05/10] Having trouble with submodules again --- .gitmodules | 3 +++ Makefile | 4 ++-- unigi | 1 - unigi.platform.sdl2 | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) delete mode 160000 unigi create mode 160000 unigi.platform.sdl2 diff --git a/.gitmodules b/.gitmodules index 354e146..1df9da6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "unigi/unigi.platform.sdl1"] path = unigi.platform.sdl1 url = https://git.lumen.sh/Fierelier/unigi.platform.sdl1.git +[submodule "unigi.platform.sdl2"] + path = unigi.platform.sdl2 + url = https://git.lumen.sh/Fierelier/unigi.platform.sdl2.git diff --git a/Makefile b/Makefile index 88b1a2d..d69d00b 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ else endif HALOOLIB = haloo3d/build/haloo3d_full.a -UNIGIPLAT = $(BUILDD)/unigi.platform.sdl1.o +UNIGIPLAT = $(BUILDD)/unigi.platform.sdl2.o UNIGILIB = $(BUILDD)/unigi.a .PHONY: clean @@ -33,7 +33,7 @@ libs: $(UNIGILIB) $(HALOOLIB) $(HALOOLIB): cd haloo3d && $(MAKE) full -$(UNIGIPLAT): unigi.platform.sdl1/main.c +$(UNIGIPLAT): unigi.platform.sdl2/main.c mkdir -p $(BUILDD) $(CC) $(CFLAGS) -I. -c $< -o $@ diff --git a/unigi b/unigi deleted file mode 160000 index cc36d7c..0000000 --- a/unigi +++ /dev/null @@ -1 +0,0 @@ -Subproject commit cc36d7c9da306334e3b7001ad5d60e6fec48958e diff --git a/unigi.platform.sdl2 b/unigi.platform.sdl2 new file mode 160000 index 0000000..f5adfe0 --- /dev/null +++ b/unigi.platform.sdl2 @@ -0,0 +1 @@ +Subproject commit f5adfe0495095576721ab639fe4044147488c473 From 7b530a67f119f724997a556137f62026ea966a7b Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Thu, 12 Sep 2024 03:28:43 -0400 Subject: [PATCH 06/10] Submodules might be ok --- .gitmodules | 12 ++++++------ unigi | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) create mode 160000 unigi diff --git a/.gitmodules b/.gitmodules index 1df9da6..9e4db3e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,12 +1,12 @@ [submodule "haloo3d"] path = haloo3d url = https://github.com/randomouscrap98/haloo3d.git -[submodule "unigi/unigi"] - path = unigi - url = https://git.lumen.sh/Fierelier/unigi.git -[submodule "unigi/unigi.platform.sdl1"] - path = unigi.platform.sdl1 - url = https://git.lumen.sh/Fierelier/unigi.platform.sdl1.git [submodule "unigi.platform.sdl2"] path = unigi.platform.sdl2 url = https://git.lumen.sh/Fierelier/unigi.platform.sdl2.git +[submodule "unigi.platform.sdl1"] + path = unigi.platform.sdl1 + url = https://git.lumen.sh/Fierelier/unigi.platform.sdl1.git +[submodule "unigi"] + path = unigi + url = https://git.lumen.sh/Fierelier/unigi.git diff --git a/unigi b/unigi new file mode 160000 index 0000000..8767a3d --- /dev/null +++ b/unigi @@ -0,0 +1 @@ +Subproject commit 8767a3dd8538c6650ab06f36c15d926d12a4b081 From 93d91134513de6ca3a2f6d71cbc11e7b4d7c7738 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Thu, 12 Sep 2024 03:50:38 -0400 Subject: [PATCH 07/10] Setting up more ps2 (but it doesn't work) --- Makefile | 3 ++- maze.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d69d00b..2c58111 100644 --- a/Makefile +++ b/Makefile @@ -47,11 +47,12 @@ $(BUILDD)/%.o: %.c %.h # Rule to build any sample. We ALWAYS need math so... link it %.exe: %.o $(UNIGILIB) $(HALOOLIB) - $(CC) $(CFLAGS) $^ -o $@ -lm -lSDL + $(CC) $(CFLAGS) $^ -o $@ -lm -lSDL2 # Rule to clean the build files clean: rm -rf $(BUILDD) + rm -f *.o *.elf find . -name "*.exe" -type f -delete cd haloo3d && $(MAKE) clean diff --git a/maze.c b/maze.c index 457c718..1dc728c 100644 --- a/maze.c +++ b/maze.c @@ -1,14 +1,20 @@ #ifdef PS2 #define DIRECTBUILD +#define H3D_VOLATILE_FLOATS #endif #ifdef DIRECTBUILD +#define MATHC_USE_UNIONS +#define MATHC_NO_STRUCT_FUNCTIONS +#include "haloo3d/lib/mathc.c" +#define FNL_IMPL #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 "haloo3d/lib/FastNoiseLite.h" #include "unigi.platform.sdl2/main.c" #else #include "haloo3d/haloo3d.h" @@ -989,7 +995,11 @@ void create_paintingobj(haloo3d_obj *obj) { } } +#ifdef PS2 +int main(int argc, char *argv[]) { +#else int main() { // int argc, char **argv) { +#endif srand(clock()); From 1de3a60aefbed18b32c1f749257d9109ccb27efa Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Thu, 12 Sep 2024 04:46:47 -0400 Subject: [PATCH 08/10] It runs on the ps2, barely (broken) --- Makefile_PS2 | 8 ++++---- make_ps2.sh | 10 ++++++++-- maze.c | 17 +++++++++++------ 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Makefile_PS2 b/Makefile_PS2 index e85ff3b..821ad0c 100644 --- a/Makefile_PS2 +++ b/Makefile_PS2 @@ -6,14 +6,14 @@ # Licenced under Academic Free License version 2.0 # Review ps2sdk README & LICENSE files for further details. -EE_BIN = $(PROGRAM).elf +EE_BIN = $(PROGRAM_PS2).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 +EE_OBJS = $(PROGRAM_PS2).o +EE_CFLAGS += -DPS2 -fdata-sections -ffunction-sections -I$(PS2SDK)/ports/include -Wformat=0 +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) EE_CFLAGS += -DDUMMY_TIMEZONE diff --git a/make_ps2.sh b/make_ps2.sh index 2f5e524..ee64278 100755 --- a/make_ps2.sh +++ b/make_ps2.sh @@ -1,9 +1,15 @@ #!/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 "pass in just 'maze'" exit 1 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 diff --git a/maze.c b/maze.c index 1dc728c..8824bee 100644 --- a/maze.c +++ b/maze.c @@ -4,18 +4,20 @@ #endif #ifdef DIRECTBUILD +// clang-format off #define MATHC_USE_UNIONS #define MATHC_NO_STRUCT_FUNCTIONS #include "haloo3d/lib/mathc.c" #define FNL_IMPL +#include "haloo3d/lib/FastNoiseLite.h" #include "haloo3d/haloo3d.c" -#include "haloo3d/haloo3dex_console.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 "haloo3d/lib/FastNoiseLite.h" #include "unigi.platform.sdl2/main.c" +// clang-format on #else #include "haloo3d/haloo3d.h" #include "haloo3d/haloo3dex_console.h" @@ -995,11 +997,10 @@ void create_paintingobj(haloo3d_obj *obj) { } } -#ifdef PS2 int main(int argc, char *argv[]) { -#else -int main() { // int argc, char **argv) { -#endif + + // We HAVE to use argc and argv + eprintf("Argc: %d, prog: %s\n", argc, argv[0]); srand(clock()); @@ -1120,6 +1121,7 @@ int main() { // int argc, char **argv) { // render.camera.pitch = MPI - 0.1; // 2.2; // ceili->pos.y = -10; +#ifndef PS2 haloo3d_debugconsole 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/pitch.f", &render.camera.pitch); 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. mecs ecs; @@ -1238,9 +1241,11 @@ int main() { // int argc, char **argv) { case unigi_enum_event_input_keyboard: if (event.data.input_keyboard.down) { switch (event.data.input_keyboard.button) { +#ifndef PS2 case KEY_SPACE: haloo3d_debugconsole_beginprompt(&dc); break; +#endif default: exit(0); } From aa65ae81423f0431c686ec1151a6b4ea3434164e Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Thu, 12 Sep 2024 05:00:19 -0400 Subject: [PATCH 09/10] FINALLY WORKING --- Makefile_PS2 | 5 +++-- maze.c | 47 +++++++++++++++-------------------------------- 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/Makefile_PS2 b/Makefile_PS2 index 821ad0c..9dcdbfc 100644 --- a/Makefile_PS2 +++ b/Makefile_PS2 @@ -11,9 +11,10 @@ EE_BIN = $(PROGRAM_PS2).elf # KERNEL_NOPATCH = 1 # NEWLIB_NANO = 1 +# NOTE: CANNOT USE JUST 'PS2' AS A DEFINE, IT BREAKS EVERYTHING! EE_OBJS = $(PROGRAM_PS2).o -EE_CFLAGS += -DPS2 -fdata-sections -ffunction-sections -I$(PS2SDK)/ports/include -Wformat=0 -EE_LDFLAGS += -L$(PS2SDK)/ports/lib -L$(GSKIT)/lib -lSDL2 -lSDL2main -lkernel -lpatches -lgskit -ldmakit -lps2_drivers -lm -Wl,--gc-sections +EE_CFLAGS += -DBUILDTOYS_PS2 -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 ifeq ($(DUMMY_TIMEZONE), 1) EE_CFLAGS += -DDUMMY_TIMEZONE diff --git a/maze.c b/maze.c index 8824bee..87c7422 100644 --- a/maze.c +++ b/maze.c @@ -1,4 +1,5 @@ -#ifdef PS2 +// NOTE: CANNOT USE JUST 'PS2' AS A DEFINE, IT BREAKS EVERYTHING +#ifdef BUILDTOYS_PS2 #define DIRECTBUILD #define H3D_VOLATILE_FLOATS #endif @@ -11,7 +12,7 @@ #define FNL_IMPL #include "haloo3d/lib/FastNoiseLite.h" #include "haloo3d/haloo3d.c" -// #include "haloo3d/haloo3dex_console.c" +#include "haloo3d/haloo3dex_console.c" #include "haloo3d/haloo3dex_easy.c" #include "haloo3d/haloo3dex_gen.c" #include "haloo3d/haloo3dex_obj.c" @@ -46,7 +47,7 @@ #define NUMMICE 1 // #define NOWALLS -#ifdef PS2 +#ifdef BUILDTOYS_PS2 #define WIDTH 160 #define HEIGHT 120 #define SCREENSCALE 4 @@ -997,13 +998,20 @@ void create_paintingobj(haloo3d_obj *obj) { } } -int main(int argc, char *argv[]) { - - // We HAVE to use argc and argv - eprintf("Argc: %d, prog: %s\n", argc, argv[0]); +int main() { // int argc, char *argv[]) { srand(clock()); + // Init unigi system + unigi_type_event event; + unigi_type_resolution res; + res.width = SWIDTH; + res.height = SHEIGHT; + res.depth = 0; + + unigi_graphics_init(); + unigi_window_create(res, "maze.exe"); // render.printbuf); + haloo3d_easystore storage; haloo3d_easystore_init(&storage); @@ -1102,26 +1110,11 @@ int main(int argc, char *argv[]) { init_billboard(endi, 0.25); eprintf("Setup all static object instances\n"); - unigi_type_event event; - unigi_type_resolution res; - res.width = SWIDTH; - res.height = SHEIGHT; - res.depth = 0; - int totaldrawn = 0; eprintf("Scene has %d tris, %d verts\n", render.totalfaces, render.totalverts); - // Init unigi system - unigi_graphics_init(); - unigi_window_create(res, "maze.exe"); // render.printbuf); - - // render.camera.pos.y = 4; // 5; - // render.camera.pitch = MPI - 0.1; // 2.2; - // ceili->pos.y = -10; - -#ifndef PS2 haloo3d_debugconsole dc; haloo3d_debugconsole_init(&dc); @@ -1136,7 +1129,6 @@ int main(int argc, char *argv[]) { 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, "obj/ceil/pos_y.f", &ceili->pos.y); -#endif // Set up ECS entities. For this game, we mostly have global entities. mecs ecs; @@ -1224,28 +1216,19 @@ int main(int argc, char *argv[]) { while (1) { haloo3d_easytimer_start(&frametimer); - // render.camera.yaw += 0.008; haloo3d_perspective(render.perspective, fov, ASPECT, NEARCLIP, FARCLIP); haloo3d_easyrender_beginframe(&render); haloo3d_fb_clear(&render.window, sky); - // walli->scale.y = fabs(sin(3 * render.camera.yaw)); - // render.camera.up.x = sin(render.camera.yaw); - // render.camera.up.y = cos(render.camera.yaw); - // walli->up.x = sin(3 * render.camera.yaw); - // walli->up.y = cos(4 * render.camera.yaw); - do { unigi_event_get(&event); switch (event.type) { case unigi_enum_event_input_keyboard: if (event.data.input_keyboard.down) { switch (event.data.input_keyboard.button) { -#ifndef PS2 case KEY_SPACE: haloo3d_debugconsole_beginprompt(&dc); break; -#endif default: exit(0); } From 8ffad9e6b9160e4479bc8baf7f275f8e611b201d Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Thu, 12 Sep 2024 13:58:08 -0400 Subject: [PATCH 10/10] Fully working maze on ps2 thank you unigi --- Makefile_PS2 | 2 +- make_ps2.sh | 1 + maze.c | 9 ++++----- unigi.platform.sdl2 | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile_PS2 b/Makefile_PS2 index 9dcdbfc..158e5d2 100644 --- a/Makefile_PS2 +++ b/Makefile_PS2 @@ -13,7 +13,7 @@ EE_BIN = $(PROGRAM_PS2).elf # NOTE: CANNOT USE JUST 'PS2' AS A DEFINE, IT BREAKS EVERYTHING! EE_OBJS = $(PROGRAM_PS2).o -EE_CFLAGS += -DBUILDTOYS_PS2 -fdata-sections -ffunction-sections -I$(PS2SDK)/ports/include -Wformat=0 +EE_CFLAGS += -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 ifeq ($(DUMMY_TIMEZONE), 1) diff --git a/make_ps2.sh b/make_ps2.sh index ee64278..38091c2 100755 --- a/make_ps2.sh +++ b/make_ps2.sh @@ -11,5 +11,6 @@ make -f Makefile_PS2 PROGRAM_PS2="$1" if [ "$#" -gt "1" ]; then echo "Running on $2" ps2client -h "$2" reset + sleep 1 ps2client -h "$2" execee host:$1.elf fi diff --git a/maze.c b/maze.c index 87c7422..2249aa9 100644 --- a/maze.c +++ b/maze.c @@ -1,5 +1,5 @@ // NOTE: CANNOT USE JUST 'PS2' AS A DEFINE, IT BREAKS EVERYTHING -#ifdef BUILDTOYS_PS2 +#ifdef _EE #define DIRECTBUILD #define H3D_VOLATILE_FLOATS #endif @@ -47,14 +47,13 @@ #define NUMMICE 1 // #define NOWALLS -#ifdef BUILDTOYS_PS2 +#ifdef _EE #define WIDTH 160 #define HEIGHT 120 #define SCREENSCALE 4 #define DITHERSTART 2.5 #define DITHEREND 3.5 -int fps = 24; -uint16_t sky = 0xF644; +int fps = 20; #else #define WIDTH 480 #define HEIGHT 300 @@ -63,7 +62,6 @@ uint16_t sky = 0xF644; #define DITHERSTART 10000 #define DITHEREND 10000 int fps = 30; -uint16_t sky = 0xF000; #endif #define ASPECT ((float)WIDTH / HEIGHT) @@ -128,6 +126,7 @@ const char POLYNAMES[NUMPOLYS][20] = {"tetrahedron"}; float fov = 90.0; float minlight = 0.15; float speed = 1.0; +uint16_t sky = 0xF644; struct vec2i dirtovec(uint8_t dir) { struct vec2i result; diff --git a/unigi.platform.sdl2 b/unigi.platform.sdl2 index f5adfe0..7761a39 160000 --- a/unigi.platform.sdl2 +++ b/unigi.platform.sdl2 @@ -1 +1 @@ -Subproject commit f5adfe0495095576721ab639fe4044147488c473 +Subproject commit 7761a397a86b0e94bf5d7280b3c2c65e3713fae8