Merge branch 'master' into terrain

This commit is contained in:
Carlos Sanchez 2024-09-12 23:37:48 -04:00
commit 0ff396757b
16 changed files with 140 additions and 64 deletions

2
.clangd Normal file
View File

@ -0,0 +1,2 @@
CompileFlags: # Tweak the parse settings
Add: [-Iunigi/]

19
.gitmodules vendored
View File

@ -1,15 +1,12 @@
[submodule "haloo3d"] [submodule "haloo3d"]
path = haloo3d path = haloo3d
url = https://github.com/randomouscrap98/haloo3d.git url = https://github.com/randomouscrap98/haloo3d.git
[submodule "unigi/unigi"] [submodule "unigi.platform.sdl2"]
path = unigi/unigi path = unigi.platform.sdl2
url = https://git.lumen.sh/Fierelier/unigi.git url = https://git.lumen.sh/Fierelier/unigi.platform.sdl2.git
[submodule "unigi/unigi.headers"] [submodule "unigi.platform.sdl1"]
path = unigi/unigi.headers path = unigi.platform.sdl1
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
url = https://git.lumen.sh/Fierelier/unigi.platform.sdl1.git url = https://git.lumen.sh/Fierelier/unigi.platform.sdl1.git
[submodule "unigi"]
path = unigi
url = https://git.lumen.sh/Fierelier/unigi.git

View File

@ -21,28 +21,38 @@ else
endif endif
HALOOLIB = haloo3d/build/haloo3d_full.a HALOOLIB = haloo3d/build/haloo3d_full.a
UNIGIPLAT = $(BUILDD)/unigi.platform.sdl2.o
UNIGILIB = $(BUILDD)/unigi.a
.PHONY: clean .PHONY: clean
.PHONY: full .PHONY: libs
full: libs: $(UNIGILIB) $(HALOOLIB)
echo "Please specify a sample to build (ends with .exe)" @echo "Built libs!"
$(HALOOLIB): $(HALOOLIB):
cd haloo3d && $(MAKE) full cd haloo3d && $(MAKE) full
$(UNIGIPLAT): unigi.platform.sdl2/main.c
mkdir -p $(BUILDD)
$(CC) $(CFLAGS) -I. -c $< -o $@
$(UNIGILIB): $(UNIGIPLAT)
ar -vr $@ $^
# Rule to build .o files in main folder # Rule to build .o files in main folder
$(BUILDD)/%.o: %.c %.h $(BUILDD)/%.o: %.c %.h
mkdir -p $(BUILDD) mkdir -p $(BUILDD)
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
# Rule to build any sample. We ALWAYS need math so... link it # Rule to build any sample. We ALWAYS need math so... link it
%.exe: %.o $(HALOOLIB) %.exe: %.o $(UNIGILIB) $(HALOOLIB)
$(CC) $(CFLAGS) $< $(HALOOLIB) -o $@ -lm -lSDL $(CC) $(CFLAGS) $^ -o $@ -lm -lSDL2
# Rule to clean the build files # Rule to clean the build files
clean: clean:
rm -rf $(BUILDD) rm -rf $(BUILDD)
rm -f *.o *.elf
find . -name "*.exe" -type f -delete find . -name "*.exe" -type f -delete
cd haloo3d && $(MAKE) clean cd haloo3d && $(MAKE) clean

45
Makefile_PS2 Normal file
View File

@ -0,0 +1,45 @@
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ 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_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 += -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
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

16
make_ps2.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
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_PS2="$1"
if [ "$#" -gt "1" ]; then
echo "Running on $2"
ps2client -h "$2" reset
sleep 1
ps2client -h "$2" execee host:$1.elf
fi

85
maze.c
View File

@ -1,13 +1,33 @@
// NOTE: CANNOT USE JUST 'PS2' AS A DEFINE, IT BREAKS EVERYTHING
#ifdef _EE
#define DIRECTBUILD
#define H3D_VOLATILE_FLOATS
#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_easy.c"
#include "haloo3d/haloo3dex_gen.c"
#include "haloo3d/haloo3dex_obj.c"
#include "haloo3d/haloo3dex_print.c"
#include "unigi.platform.sdl2/main.c"
// clang-format on
#else
#include "haloo3d/haloo3d.h" #include "haloo3d/haloo3d.h"
#include "haloo3d/haloo3dex_console.h" #include "haloo3d/haloo3dex_console.h"
#include "haloo3d/haloo3dex_easy.h" #include "haloo3d/haloo3dex_easy.h"
#include "haloo3d/haloo3dex_gen.h" #include "haloo3d/haloo3dex_gen.h"
// #include "haloo3d/haloo3dex_img.h"
#include "haloo3d/haloo3dex_obj.h" #include "haloo3d/haloo3dex_obj.h"
#include "haloo3d/haloo3dex_print.h" #include "haloo3d/haloo3dex_print.h"
#include "unigi/main.h"
#include "unigi/unigi.headers/src/main.h" #endif
#include "unigi/unigi.platform.sdl1/src/main.c"
#include "ecs2.h" #include "ecs2.h"
#include "keys.h" #include "keys.h"
@ -23,25 +43,34 @@
#include <stdlib.h> #include <stdlib.h>
// INteresting flags for debugging
#define FASTFILL #define FASTFILL
#define NUMMICE 1 #define NUMMICE 1
#define MOUSELOGGING
// #define NOWALLS // #define NOWALLS
#ifdef _EE
#define WIDTH 160
#define HEIGHT 120
#define SCREENSCALE 4
#define DITHERSTART 2.5
#define DITHEREND 3.5
int fps = 20;
#else
#define WIDTH 480 #define WIDTH 480
#define HEIGHT 300 #define HEIGHT 300
#define ASPECT ((float)WIDTH / HEIGHT)
#define SCREENSCALE 2 #define SCREENSCALE 2
#define MOUSELOGGING
#define DITHERSTART 10000
#define DITHEREND 10000
int fps = 30;
#endif
#define ASPECT ((float)WIDTH / HEIGHT)
#define SWIDTH (WIDTH * SCREENSCALE) #define SWIDTH (WIDTH * SCREENSCALE)
#define SHEIGHT (HEIGHT * SCREENSCALE) #define SHEIGHT (HEIGHT * SCREENSCALE)
#define NEARCLIP 0.01 #define NEARCLIP 0.01
#define FARCLIP 100.0 #define FARCLIP 100.0
#define LIGHTANG -MPI / 4.0 #define LIGHTANG -MPI / 4.0
#define AVGWEIGHT 0.85 #define AVGWEIGHT 0.85
// Try 0.5 and 3.5 or something
#define DITHERSTART 10000
#define DITHEREND 10000
// Game options // Game options
#define MAZESIZE 15 #define MAZESIZE 15
@ -97,8 +126,7 @@ const char POLYNAMES[NUMPOLYS][20] = {"tetrahedron"};
float fov = 90.0; float fov = 90.0;
float minlight = 0.15; float minlight = 0.15;
float speed = 1.0; float speed = 1.0;
int fps = 30; uint16_t sky = 0xF644;
uint16_t sky = 0xF000;
struct vec2i dirtovec(uint8_t dir) { struct vec2i dirtovec(uint8_t dir) {
struct vec2i result; struct vec2i result;
@ -969,10 +997,20 @@ void create_paintingobj(haloo3d_obj *obj) {
} }
} }
int main() { // int argc, char **argv) { int main() { // int argc, char *argv[]) {
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);
@ -1071,25 +1109,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;
haloo3d_debugconsole dc; haloo3d_debugconsole dc;
haloo3d_debugconsole_init(&dc); haloo3d_debugconsole_init(&dc);
@ -1191,17 +1215,10 @@ 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) {

1
unigi Submodule

@ -0,0 +1 @@
Subproject commit 8767a3dd8538c6650ab06f36c15d926d12a4b081

1
unigi.platform.sdl1 Submodule

@ -0,0 +1 @@
Subproject commit c2bb042dcb29e55879f9b0b415c2989afed56132

1
unigi.platform.sdl2 Submodule

@ -0,0 +1 @@
Subproject commit 7761a397a86b0e94bf5d7280b3c2c65e3713fae8

View File

@ -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

@ -1 +0,0 @@
Subproject commit 34aa7f0a1cd24939c2de879b5dcce03daa0c7de2

@ -1 +0,0 @@
Subproject commit cf21dd85c6d49509c946ab9f462edc2e8a73327c

@ -1 +0,0 @@
Subproject commit ab07d46aac8d7043399437b83f81ce8ce3bf1233

@ -1 +0,0 @@
Subproject commit e407020c2118d7ad2f4d43eca5214b6360a0b7cc