FINALLY WORKING

This commit is contained in:
Carlos Sanchez 2024-09-12 05:00:19 -04:00
parent 1de3a60aef
commit aa65ae8142
2 changed files with 18 additions and 34 deletions

View File

@ -11,9 +11,10 @@ EE_BIN = $(PROGRAM_PS2).elf
# KERNEL_NOPATCH = 1 # KERNEL_NOPATCH = 1
# NEWLIB_NANO = 1 # NEWLIB_NANO = 1
# NOTE: CANNOT USE JUST 'PS2' AS A DEFINE, IT BREAKS EVERYTHING!
EE_OBJS = $(PROGRAM_PS2).o EE_OBJS = $(PROGRAM_PS2).o
EE_CFLAGS += -DPS2 -fdata-sections -ffunction-sections -I$(PS2SDK)/ports/include -Wformat=0 EE_CFLAGS += -DBUILDTOYS_PS2 -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_LDFLAGS += -L$(PS2SDK)/ports/lib -L$(GSKIT)/lib -lSDL2 -lgskit -ldmakit -lps2_drivers -lm -Wl,--gc-sections
ifeq ($(DUMMY_TIMEZONE), 1) ifeq ($(DUMMY_TIMEZONE), 1)
EE_CFLAGS += -DDUMMY_TIMEZONE EE_CFLAGS += -DDUMMY_TIMEZONE

47
maze.c
View File

@ -1,4 +1,5 @@
#ifdef PS2 // NOTE: CANNOT USE JUST 'PS2' AS A DEFINE, IT BREAKS EVERYTHING
#ifdef BUILDTOYS_PS2
#define DIRECTBUILD #define DIRECTBUILD
#define H3D_VOLATILE_FLOATS #define H3D_VOLATILE_FLOATS
#endif #endif
@ -11,7 +12,7 @@
#define FNL_IMPL #define FNL_IMPL
#include "haloo3d/lib/FastNoiseLite.h" #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"
@ -46,7 +47,7 @@
#define NUMMICE 1 #define NUMMICE 1
// #define NOWALLS // #define NOWALLS
#ifdef PS2 #ifdef BUILDTOYS_PS2
#define WIDTH 160 #define WIDTH 160
#define HEIGHT 120 #define HEIGHT 120
#define SCREENSCALE 4 #define SCREENSCALE 4
@ -997,13 +998,20 @@ void create_paintingobj(haloo3d_obj *obj) {
} }
} }
int main(int argc, char *argv[]) { int main() { // int argc, char *argv[]) {
// We HAVE to use argc and argv
eprintf("Argc: %d, prog: %s\n", argc, argv[0]);
srand(clock()); 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 storage;
haloo3d_easystore_init(&storage); haloo3d_easystore_init(&storage);
@ -1102,26 +1110,11 @@ int main(int argc, char *argv[]) {
init_billboard(endi, 0.25); init_billboard(endi, 0.25);
eprintf("Setup all static object instances\n"); 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; int totaldrawn = 0;
eprintf("Scene has %d tris, %d verts\n", render.totalfaces, eprintf("Scene has %d tris, %d verts\n", render.totalfaces,
render.totalverts); 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 dc;
haloo3d_debugconsole_init(&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/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;
@ -1224,28 +1216,19 @@ int main(int argc, char *argv[]) {
while (1) { while (1) {
haloo3d_easytimer_start(&frametimer); haloo3d_easytimer_start(&frametimer);
// render.camera.yaw += 0.008;
haloo3d_perspective(render.perspective, fov, ASPECT, NEARCLIP, FARCLIP); haloo3d_perspective(render.perspective, fov, ASPECT, NEARCLIP, FARCLIP);
haloo3d_easyrender_beginframe(&render); haloo3d_easyrender_beginframe(&render);
haloo3d_fb_clear(&render.window, sky); 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 { do {
unigi_event_get(&event); unigi_event_get(&event);
switch (event.type) { switch (event.type) {
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);
} }