From aa65ae81423f0431c686ec1151a6b4ea3434164e Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Thu, 12 Sep 2024 05:00:19 -0400 Subject: [PATCH] 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); }