a bunch of schizoshit to get dreamcast target to boot (crashes from a memory pool assert) while simultaneously shrinking the .elf (3.60MB=>3.06MB)

This commit is contained in:
ecker 2026-07-24 22:45:57 -05:00
parent 9597916568
commit c61e502dcb
96 changed files with 1213 additions and 733 deletions

4
.gitignore vendored
View File

@ -67,4 +67,6 @@ default/
maps/
models/
llm/
tmp/
tmp/
engine/lib/dreamcast/gcc/opengl/

View File

@ -1,12 +1,12 @@
# Defaults
ARCH = $(shell cat "./makefiles/default/arch")
CC = $(shell cat "./makefiles/default/cc")
COMPILER = $(shell cat "./makefiles/default/cc")
RENDERER = $(shell cat "./makefiles/default/renderer")
TARGET_NAME = program
TARGET_EXTENSION = .exe
DLIB_EXTENSION = .dll
SLIB_EXTENSION = .a
PREFIX = $(ARCH).$(CC).$(RENDERER)
PREFIX = $(ARCH).$(COMPILER).$(RENDERER)
# Basic Paths
7Z ?= /c/Program\ Files/7-Zip/7z.exe
@ -28,17 +28,18 @@ FLAGS += -std=c++2b $(OPTIMIZATIONS) $(WARNINGS) -fdiagnostics-color=always
# Base Library Definitions
LIB_NAME += uf
EXT_LIB_NAME += ext
PREFIX_PATH = $(ARCH)/$(CC)/$(RENDERER)
PREFIX_PATH = $(ARCH)/$(COMPILER)/$(RENDERER)
INC_DIR += $(ENGINE_INC_DIR)
LIB_DIR += $(ENGINE_LIB_DIR)
INCS += -I$(ENGINE_INC_DIR) -I./dep/include/
LIBS += -L$(ENGINE_LIB_DIR) -L$(LIB_DIR)/$(PREFIX_PATH)/ -L$(LIB_DIR)/$(ARCH)/$(CC)/ -L$(LIB_DIR)/$(ARCH)/
LIBS += -L$(ENGINE_LIB_DIR) -L$(LIB_DIR)/$(PREFIX_PATH)/ -L$(LIB_DIR)/$(ARCH)/$(COMPILER)/ -L$(LIB_DIR)/$(ARCH)/
LINKS += $(UF_LIBS) $(EXT_LIBS) $(DEPS)
# DLL
SRCS_DLL := $(shell find $(ENGINE_SRC_DIR) -name "*.cpp") $(shell find $(DEP_SRC_DIR) -name "*.cpp")
OBJS_DLL += $(patsubst %.cpp,%.$(PREFIX).o,$(SRCS_DLL))
SRCS_DLL_C := $(shell find $(ENGINE_SRC_DIR) -name "*.c") $(shell find $(DEP_SRC_DIR) -name "*.c")
OBJS_DLL += $(patsubst %.cpp,%.$(PREFIX).o,$(SRCS_DLL)) $(patsubst %.c,%.$(PREFIX).o,$(SRCS_DLL_C))
BASE_DLL += lib$(LIB_NAME)
IM_DLL += $(ENGINE_LIB_DIR)/$(PREFIX_PATH)/$(BASE_DLL)$(DLIB_EXTENSION)
@ -71,7 +72,7 @@ TARGET_SHADERS += $(patsubst %.glsl,%.spv,$(SRCS_SHADERS))
.PHONY: $(PREFIX) clean run run-debug clean-shaders backup
.FORCE:
include makefiles/platforms/$(ARCH).$(CC).mk
include makefiles/platforms/$(ARCH).$(COMPILER).mk
ifneq (,$(findstring win64,$(ARCH)))
include makefiles/platforms/win64.mk
@ -90,6 +91,9 @@ $(PREFIX): $(EX_DLL) $(EXT_EX_DLL) $(TARGET) $(TARGET_SHADERS)
%.$(PREFIX).o: %.cpp
$(CXX) $(FLAGS) $(INCS) -c $< -o $@
%.$(PREFIX).o: %.c
$(CC) $(FLAGS) $(INCS) -c $< -o $@
ifneq ($(ARCH),dreamcast)
$(TARGET): $(OBJS)
$(CXX) $(FLAGS) $(OBJS) $(LIBS) $(INCS) $(LINKS) -l$(LIB_NAME) -l$(EXT_LIB_NAME) -o $(TARGET)
@ -116,13 +120,13 @@ clean-shaders:
run:
@echo -n $(ARCH) > "./bin/exe/default/arch"
@echo -n $(CC) > "./bin/exe/default/cc"
@echo -n $(COMPILER) > "./bin/exe/default/cc"
@echo -n $(RENDERER) > "./bin/exe/default/renderer"
./program.sh
run-debug:
@echo -n $(ARCH) > "./bin/exe/default/arch"
@echo -n $(CC) > "./bin/exe/default/cc"
@echo -n $(COMPILER) > "./bin/exe/default/cc"
@echo -n $(RENDERER) > "./bin/exe/default/renderer"
./debug.sh

View File

@ -1,7 +1,7 @@
{
"engine": {
"scenes": {
"start": "Dark",
"start": "StartMenu",
"lights": { "enabled": true,
"lightmaps": true,
"max": 32,
@ -425,7 +425,7 @@
},
"loader": {
"assert": true,
"async": false
"async": false // to-do: fix
},
"hooks": {
"defer lazy calls": true

View File

@ -1,57 +0,0 @@
{
"import": "./base_sourceengine.json",
"assets": [
// { "filename": "./models/animal_crossing.glb" },
{ "filename": "./models/animal_crossing/graph.json" }/*,
// { "filename": "./models/animal_crossing_small.glb" },
// { "filename": "./models/animal_crossing_small/graph.json" },
{ "filename": "/craeture.json", "delay": 2.0 },
{ "filename": "/craeture2.json", "delay": 2.0 }*/
],
"metadata": {
"graph": {
"bgm": {
"load": "./audio/music/5pm.ogg"
},
"tags": {
// exact matches
// "func_door_rotating_5473": { "action": "load", "payload": { "import": "/door.json", "metadata": { "angle":-1.570795, "normal": [1,0,0] } } },
// "func_door_rotating_5509": { "action": "load", "payload": { "import": "/door.json", "metadata": { "angle":-1.570795, "normal": [1,0,0] } } },
// "func_door_rotating_5568": { "action": "load", "payload": { "import": "/door.json", "metadata": { "angle":-1.570795, "normal": [1,0,0] } } },
// "func_door_rotating_5584": { "action": "load", "payload": { "import": "/door.json", "metadata": { "angle":-1.570795, "normal": [1,0,0] } } },
// regex matches
// "/^prop_physics_override/": { "action": "load", "payload": { "import": "/prop.json", "metadata": { "physics": { "gravity": [ 0, 0, 0 ] } } } },
// "/^prop_physics_[^o]/": { "action": "load", "payload": { "import": "/prop.json" } },
"light_environment": { "ignore": false,
"transform": {
"position": [250.3781, 148.704, 202.286]
},
"light": {
// "color": [0.95, 0.25, 0.25],
"power": 1000000,
"global": true,
"bias": {
"constant": 0,
"slope": 5,
"shader": 0.0000175
},
"radius": [0.9999999, 0],
"resolution": 2048
}
},
"/^tools\\/toolsnodraw/": { "material": {
"base": [ 1.0, 1.0, 1.0, 1.0 ],
"emissive": [ 0.0, 0.0, 0.0, 0.0 ],
"fMetallic": 0.0,
"fRoughness": 0.10000000149011612,
"fOcclusion": 1.0,
"fAlphaCutoff": 0.5,
"iAlbedo": 27,
"modeAlpha": 1
} }
}
}
}
}

View File

@ -1,44 +0,0 @@
{
"import": "/model.json",
"metadata": {
"graph": {
"renderer": { "separate": false },
"exporter": {
"optimize": { "simplify": 0, "lods": true, "print": true }
},
"baking": { "enabled": true },
"tags": {
// exact matches
"worldspawn": {
"physics": { "type": "mesh", "static": true, "mass": 0 },
"grid": { "size": [8,1,8], "epsilon": 0.001, "cleanup": true, "print": true, "clip": true },
"unwrap mesh": true
},
"light_environment": { "ignore": false, "light": {
// "color": [0.1, 0.1, 0.1],
"power": 1000,
"global": true,
"bias": {
"constant": 0,
"slope": 5,
"shader": 0.000025
},
"radius": [0.9999999, 0],
"resolution": 2048
} },
// "/^light_[^e]/": { "ignore": true },
// regexp matches
// "/^worldspawn_/": { "physics": { "type": "mesh", "static": true } },
"/^func_door_/": { "action": "load", "payload": { "import": "/door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"/^prop_door_/": { "action": "load", "payload": { "import": "/door.json", "metadata": { "angle":-1.570795, "normal": [-1,0,0] } } },
"/^prop_static/": { /*"action": "load", "payload": { "import": "/prop.json", "metadata": { "physics": { "gravity": [ 0, 0, 0 ] } } }*/ },
"/^prop_dynamic/": { /*"action": "load", "payload": { "import": "/prop.json", "metadata": { "physics": { "gravity": [ 0, 0, 0 ] } } }*/ },
"/^func_physbox/": { "action": "load", "payload": { "import": "/prop.json" } },
"/^prop_physics/": { "action": "load", "payload": { "import": "/prop.json" } },
"/^tools\\/toolsnodraw/": { "material": { "base": [ 1.0, 1.0, 1.0, 0.0 ] } }
}
}
}
}

View File

@ -1,25 +0,0 @@
{
"import": "./base_sourceengine.json",
"assets": [
{ "filename": "./models/gm_construct.glb" }
// { "filename": "./models/gm_construct/graph.json" }
],
"metadata": {
"graph": {
"bgm": "./audio/soundscape/ambience.ogg",
"tags": {
// exact matches
// "worldspawn_skybox": { "ignore": true },
"worldspawn_water": {},
// regex matches
"/^gm_construct\\/water/": { "material": {
"base": [ 0.027, 0.227, 0.259, 0.5 ],
"fRoughness": 0.3,
"fAlphaCutoff": 0.5,
"modeAlpha": "blend"
} }
}
}
}
}

View File

@ -1,32 +0,0 @@
{
"name": "Gui: Loading",
"type": "Object",
"behaviors": [
"GuiBehavior"
],
"assets": [
{ "filename": "./sourceengine.json", "delay": 0 }
],
"ignore": false,
"transform": {
"position": [ -0.830591, -0.699509, 0 ],
"rotation": {
"axis": [ 1, 0, 0 ],
"angle": 0
},
"scale": [ 0.258737, 0.115371, 1 ]
},
"metadata": {
"uv": [ 0, 0, 1, 1 ],
"color": [ 1, 1, 1, 0.1 ],
"location": "",
"scaling": "relative",
"text settings": {
"stroke": [ 1, 0.749, 0.368, 1 ],
"color": [ 1, 0.749, 0.368, 1 ],
"string": "Loading...",
"string1": "コマンド"
}
}
}

View File

@ -1,41 +0,0 @@
{
"import": "./base_sourceengine.json",
"assets": [
{ "filename": "./models/mds_mcdonalds.glb" }
// { "filename": "./models/mds_mcdonalds/graph.json" }
// ,{ "filename": "/ball.json", "delay": 1 }
// ,{ "filename": "/ragdoll.json", "delay": 1 }
// ,{ "filename": "/craeture.json", "delay": 2.0 }
// ,{ "filename": "/cesiumMan.json", "delay": 2.0 }
],
"metadata": {
"graph": {
"bgm": "./audio/soundscape/sh2_ambience.wav",
"tags": {
// exact matches
"func_door_rotating_5473": { "action": "load", "payload": { "import": "/door.json", "metadata": { "angle":-1.570795, "normal": [1,0,0] } } },
"func_door_rotating_5509": { "action": "load", "payload": { "import": "/door.json", "metadata": { "angle":-1.570795, "normal": [1,0,0] } } },
"func_door_rotating_5568": { "action": "load", "payload": { "import": "/door.json", "metadata": { "angle":-1.570795, "normal": [1,0,0] } } },
"func_door_rotating_5584": { "action": "load", "payload": { "import": "/door.json", "metadata": { "angle":-1.570795, "normal": [1,0,0] } } },
// "prop_physics_override_5813": { "action": "load", "payload": { "import": "/physics_prop.json" } },
// regex matches
"/^prop_physics_[^o]/": { "action": "load", "payload": { "import": "/prop.json" } },
"/^tools\\/toolsnodraw/": { "material": {
"base": [ 1.0, 1.0, 1.0, 1.0 ],
"emissive": [ 0.0, 0.0, 0.0, 0.0 ],
"fMetallic": 0.0,
"fRoughness": 0.10000000149011612,
"fOcclusion": 1.0,
"fAlphaCutoff": 0.5,
"iAlbedo": 27,
"modeAlpha": 1
} },
"/alpha_mtl/": { "material": { "modeAlpha": 1 } },
"/offwndwb/": { "material": { "modeAlpha": 1 } }
}
}
}
}

View File

@ -1,10 +0,0 @@
{
"import": "/player.json",
"assets": [
// { "filename": "/gui/hud/hud.json", "delay": 0 }
],
"transform": {
// "orientation": [ 0, 1, 0, 0 ]
}
// "metadata": { "physics": { "gravity": [ 0, 0, 0 ] } }
}

View File

@ -1,22 +0,0 @@
{
"import": "./base_sourceengine.json",
"assets": [
{ "filename": "./models/rp_downtown_v2.glb" }
// { "filename": "./models/rp_downtown_v2/graph.json" }
],
"metadata": {
"graph": {
"bgm": "./audio/soundscape/ambience.ogg",
"renderer": { "separate": true },
"tags": {
// exact matches
"worldspawn_skybox": { "ignore": true },
// regex matches
"/^light_/": { "ignore": true },
"/^func/": { "ignore": true },
"/^prop/": { "ignore": true }
}
}
}
}

View File

@ -1,28 +0,0 @@
{
"imports": [
"/scene.json",
"./sourceengine.json"
],
"assets": [
// { "filename": "./loading.json", "delay": 0.5 }
],
"metadata": {
"light": {
"fog-": {
// "color": [ 0.1, 0.1, 0.1 ],
// "color": [ 0.2, 0.2, 0.2 ],
"color": [ 0.3, 0.3, 0.3 ],
"range": [ 64, 256 ],
"step scale": 4,
"absorbtion": 0.125,
"density": {
"threshold": 0.35,
"multiplier": 1.0,
"scale": 25.0,
"offset": [0.2, 0, 1],
"timescale": 32
}
}
}
}
}

View File

@ -1,56 +0,0 @@
{
"import": "./base_sourceengine.json",
"assets": [
// { "filename": "./models/sh2_mcdonalds.glb" }
{ "filename": "./models/sh2_mcdonalds/graph.json" }
],
"metadata": {
"graph": {
"lights": {
"scale": 2
},
"bgm": {
"load": "./audio/soundscape/sh2_ambience.ogg"
},
"tags": {
// exact matches
/*
"worldspawn_sh2": {
"physics": { "type": "mesh", "static": true },
"grid": { "size": [9,1,9], "epsilon": 1.0, "cleanup": true, "print": true },
"unwrap mesh": true,
"optimize mesh": { "simplify": 0 }
},
*/
"/^worldspawn_barrier$/": { "ignore": true },
"/^worldspawn_skybox/": { "ignore": true },
"func_door_rotating_5473": { "action": "load", "payload": { "import": "/door.json", "metadata": { "angle":-1.570795, "normal": [1,0,0] } } },
"func_door_rotating_5509": { "action": "load", "payload": { "import": "/door.json", "metadata": { "angle":-1.570795, "normal": [1,0,0] } } },
"func_door_rotating_5568": { "action": "load", "payload": { "import": "/door.json", "metadata": { "angle":-1.570795, "normal": [1,0,0] } } },
"func_door_rotating_5584": { "action": "load", "payload": { "import": "/door.json", "metadata": { "angle":-1.570795, "normal": [1,0,0] } } },
"func_door_rotating_9120": { "action": "load", "payload": { "import": "/door.json", "metadata": { "angle":-1.570795, "normal": [0,0,1] } } },
// regex matches
// "/^prop_physics_[^o]/": { "action": "load", "payload": { "import": "/prop.json" } },
// "/^prop_physics_override/": { "action": "load", "payload": {} },
// "/^prop_physics_/": { "action": "load", "payload": {} },
// "/^func_physbox/": { "action": "load", "payload": {} },
"/^.+?_phys.+?[^o]/": { "action": "load", "payload": { "import": "/prop.json" } },
"materials/models/props_wasteland/prison_lamp001a": { "material": { "emissive": [0, 0, 0, 0] } },
"/^tools\\/toolsnodraw/": { "material": {
"base": [ 1.0, 1.0, 1.0, 1.0 ],
"emissive": [ 0.0, 0.0, 0.0, 0.0 ],
"fMetallic": 0.0,
"fRoughness": 0.10000000149011612,
"fOcclusion": 1.0,
"fAlphaCutoff": 0.5,
"iAlbedo": 27,
"modeAlpha": 1
} },
"/alpha_mtl/": { "material": { "modeAlpha": "blend" } }
}
}
}
}

View File

@ -1,9 +0,0 @@
{
// "import": "./rp_downtown_v2.json"
// "import": "./ss2_medsci1.json"
// "import": "./test_grid.json"
// "import": "./sh2_mcdonalds.json"
// "import": "./animal_crossing.json"
"import": "./mds_mcdonalds.json"
// "import": "./gm_construct.json"
}

View File

@ -1,20 +0,0 @@
{
"import": "./base_sourceengine.json",
"assets": [
// { "filename": "./models/ss2_medsci1.glb" }
{ "filename": "./models/ss2_medsci1/graph.json" }
// { "filename": "./models/ss2_medsci1_small.glb" }
// { "filename": "./models/ss2_medsci1_small/graph.json" }
// { "filename": "./models/ss2_medsci1_smallish.glb" }
// { "filename": "./models/ss2_medsci1_smallish/graph.json" }
],
"metadata": {
"graph": {
"bgm": "./audio/music/medsci1.ogg",
"tags": {
"/^prop_/": { "ignore": true, "action": "load", "payload": { "import": "/prop.json", "metadata": { "physics": { "gravity": [ 0, 0, 0 ] } } } },
"/^func_/": { "ignore": true, "action": "load", "payload": { "import": "/prop.json", "metadata": { "physics": { "gravity": [ 0, 0, 0 ] } } } }
}
}
}
}

View File

@ -1,7 +0,0 @@
{
"import": "./base_sourceengine.json",
"assets": [
// { "filename": "./models/test_grid.glb" }
{ "filename": "./models/test_grid/graph.json" }
]
}

View File

@ -1,10 +0,0 @@
{
"import": "/player.json",
"assets": [
// { "filename": "/gui/hud/hud.json", "delay": 0 }
],
"transform": {
// "orientation": [ 0, 1, 0, 0 ]
}
// "metadata": { "physics": { "gravity": [ 0, 0, 0 ] } }
}

View File

@ -1,25 +0,0 @@
{
"imports": [
"/scene.json",
"./sponza.json"
],
"metadata": {
"light": {
"fog-": {
// "color": [ 0.1, 0.1, 0.1 ],
// "color": [ 0.2, 0.2, 0.2 ],
"color": [ 0.3, 0.3, 0.3 ],
"range": [ 64, 256 ],
"step scale": 4,
"absorbtion": 0.125,
"density": {
"threshold": 0.35,
"multiplier": 1.0,
"scale": 25.0,
"offset": [0.2, 0, 1],
"timescale": 32
}
}
}
}
}

View File

@ -1,36 +0,0 @@
{
"import": "/model.json",
"assets": [
// "./models/sponza.glb"
"./models/sponza/graph.json"
],
"metadata": {
"graph": {
"renderer": { "separate": false },
"exporter": {
"optimize": { "simplify": 0, "lods": true, "print": true }
},
"baking": { "enabled": true },
"tags": {
"worldspawn": {
"physics": { "type": "mesh", "static": true, "mass": 0 },
"grid": { "size": [8,1,8], "epsilon": 0.001, "cleanup": true, "print": true, "clip": true },
"unwrap mesh": true
},
"info_player_spawn": { "action": "attach", "filename": "./player.json", "transform": { "orientation": [ 0, 1, 0, 0 ] } },
"light_environment": {"light": {
// "color": [0.1, 0.1, 0.1],
"power": 1000,
"global": true,
"bias": {
"constant": 0,
"slope": 5,
"shader": 0.000025
},
"radius": [0.9999999, 0],
"resolution": 2048
} }
}
}
}
}

View File

@ -2,10 +2,8 @@
"engine": {
"scenes": {
"start": "StartMenu",
"matrix": { "reverseInfinite": true },
"meshes": { "interleaved": false },
"lights": { "enabled": false,
"useLightmaps": true,
"lightmaps": true,
"max": 1
},
"textures": {
@ -18,7 +16,7 @@
},
"graph": {
"initial buffer elements": 128,
"global storage": false
"storage mode": "scene"
},
"ext": {
"opengl": {
@ -65,30 +63,43 @@
},
"imgui": {
"enabled": false
},
"reactphysics": {
"global storage": false,
"timescale": 0.01666666666,
"interpolate": true,
"gravity": {
"mode": "default",
"constant": 6.67408e-11
},
"debug draw": {
"enabled": false,
"line width": 8,
"layer": "",
"rate": 0.0125
}
}
},
"physics": {
"solvers": {
"warmup": true,
"block": true,
"resolve invalid": true,
"iterations": 10,
"gjk": false
},
"correction": {
"ngs": true,
"percent": 0.2,
"slop": 0.01, // 0.005
"max": 0.1 // 0.2
},
"debug draw": {
"static": false,
"dynamic": false,
"trigger": false,
"contacts": false,
"constraints": false,
"rays": false,
"depthTest": true
},
"async": false,
"fixed step": true,
"substeps": 2,
"flatten transforms": false
},
"audio": {
"mute": true,
"async update": false,
"streams by default": true,
"buffers": {
"size": 24576,
"count": 6
"size": 32768,
"count": 4
},
"volumes": {
"sfx": 1.0,
@ -115,7 +126,7 @@
},
"threads": {
"workers" : 1,
"frame limiter": 15 // 60 // "auto"
"frame limiter": "auto"
},
"debug": {
"framerate": {
@ -138,7 +149,7 @@
},
"loader": {
"assert": true,
"async": true
"async": false
},
"hooks": {
"defer lazy calls": true

View File

@ -79,7 +79,6 @@ int main(int argc, char** argv){
std::string string(argv[i]);
// uf::arguments.emplace_back(string);
}
std::atexit(::handlers::exit);
signal(SIGABRT, ::handlers::abrt);
signal(SIGSEGV, ::handlers::segv);

View File

@ -11,7 +11,7 @@ All code under this folder is not mine and are licensed under their respective l
Some dependencies of mine rely on some modifications of the original dependencies for extra features or to function on other platforms.
* [nlohmann/json](https://github.com/nlohmann/json): Dreamcast only; requires some hacks for `m4-single-only` due to `sizeof(float) == sizeof(double)` (for prior toolchains, this allegedly changed but I still get a crash with an unmodified `nlohmann/json`)
* [nlohmann/json](https://github.com/nlohmann/json): ~~Dreamcast only; requires some hacks for `m4-single-only` due to `sizeof(float) == sizeof(double)` (for prior toolchains, this allegedly changed but I still get a crash with an unmodified `nlohmann/json`)~~ should be fixed with proper templating
* this is a header-only project so its changes live locally under `./dep/dreamcast/include/nlohmann/`
* [DanielChappuis/reactphysics3d](https://git.ecker.tech/ecker/reactphysics3d): adds in support for `float16`/`bfloat16`/quantized `uint16_t` triangle meshes
* Dreamcast requires some edits due to `sizeof(int) != sizeof(int32)` / `sizeof(uint) != sizeof(uint32)`, extra compile flags, and disabling exceptions

View File

@ -30,7 +30,7 @@
#define DRACO_LOGE printf
#endif
#include <iostream>
//#include <iostream>
namespace draco {
#ifndef DISALLOW_COPY_AND_ASSIGN

View File

@ -28,7 +28,7 @@ SOFTWARE.
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <iostream>
//#include <iostream>
#include <limits>
#include <map>
#include <memory>

65
dep/include/re.h Normal file
View File

@ -0,0 +1,65 @@
/*
*
* Mini regex-module inspired by Rob Pike's regex code described in:
*
* http://www.cs.princeton.edu/courses/archive/spr09/cos333/beautiful.html
*
*
*
* Supports:
* ---------
* '.' Dot, matches any character
* '^' Start anchor, matches beginning of string
* '$' End anchor, matches end of string
* '*' Asterisk, match zero or more (greedy)
* '+' Plus, match one or more (greedy)
* '?' Question, match zero or one (non-greedy)
* '[abc]' Character class, match if one of {'a', 'b', 'c'}
* '[^abc]' Inverted class, match if NOT one of {'a', 'b', 'c'} -- NOTE: feature is currently broken!
* '[a-zA-Z]' Character ranges, the character set of the ranges { a-z | A-Z }
* '\s' Whitespace, \t \f \r \n \v and spaces
* '\S' Non-whitespace
* '\w' Alphanumeric, [a-zA-Z0-9_]
* '\W' Non-alphanumeric
* '\d' Digits, [0-9]
* '\D' Non-digits
*
*
*/
#ifndef _TINY_REGEX_C
#define _TINY_REGEX_C
#ifndef RE_DOT_MATCHES_NEWLINE
/* Define to 0 if you DON'T want '.' to match '\r' + '\n' */
#define RE_DOT_MATCHES_NEWLINE 1
#endif
#ifdef __cplusplus
extern "C"{
#endif
/* Typedef'd pointer to get abstract datatype. */
typedef struct regex_t* re_t;
/* Compile regex string pattern to a regex_t-array. */
re_t re_compile(const char* pattern);
/* Find matches of the compiled pattern inside text. */
int re_matchp(re_t pattern, const char* text, int* matchlength);
/* Find matches of the txt pattern inside text (will compile automatically first). */
int re_match(const char* pattern, const char* text, int* matchlength);
#ifdef __cplusplus
}
#endif
#endif /* ifndef _TINY_REGEX_C */

View File

@ -1,6 +1,6 @@
#pragma once
#include <iostream>
//#include <iostream>
#include <fstream>
#include <chrono>
#include <cmath>

528
dep/src/re/re.c Normal file
View File

@ -0,0 +1,528 @@
/*
*
* Mini regex-module inspired by Rob Pike's regex code described in:
*
* http://www.cs.princeton.edu/courses/archive/spr09/cos333/beautiful.html
*
*
*
* Supports:
* ---------
* '.' Dot, matches any character
* '^' Start anchor, matches beginning of string
* '$' End anchor, matches end of string
* '*' Asterisk, match zero or more (greedy)
* '+' Plus, match one or more (greedy)
* '?' Question, match zero or one (non-greedy)
* '[abc]' Character class, match if one of {'a', 'b', 'c'}
* '[^abc]' Inverted class, match if NOT one of {'a', 'b', 'c'} -- NOTE: feature is currently broken!
* '[a-zA-Z]' Character ranges, the character set of the ranges { a-z | A-Z }
* '\s' Whitespace, \t \f \r \n \v and spaces
* '\S' Non-whitespace
* '\w' Alphanumeric, [a-zA-Z0-9_]
* '\W' Non-alphanumeric
* '\d' Digits, [0-9]
* '\D' Non-digits
*
*
*/
#include "re.h"
#include <stdio.h>
#include <ctype.h>
/* Definitions: */
#define MAX_REGEXP_OBJECTS 30 /* Max number of regex symbols in expression. */
#define MAX_CHAR_CLASS_LEN 40 /* Max length of character-class buffer in. */
enum { UNUSED, DOT, BEGIN, END, QUESTIONMARK, STAR, PLUS, CHAR, CHAR_CLASS, INV_CHAR_CLASS, DIGIT, NOT_DIGIT, ALPHA, NOT_ALPHA, WHITESPACE, NOT_WHITESPACE, /* BRANCH */ };
typedef struct regex_t
{
unsigned char type; /* CHAR, STAR, etc. */
union
{
unsigned char ch; /* the character itself */
unsigned char* ccl; /* OR a pointer to characters in class */
} u;
} regex_t;
/* Private function declarations: */
static int matchpattern(regex_t* pattern, const char* text, int* matchlength);
static int matchcharclass(char c, const char* str);
static int matchstar(regex_t p, regex_t* pattern, const char* text, int* matchlength);
static int matchplus(regex_t p, regex_t* pattern, const char* text, int* matchlength);
static int matchone(regex_t p, char c);
static int matchdigit(char c);
static int matchalpha(char c);
static int matchwhitespace(char c);
static int matchmetachar(char c, const char* str);
static int matchrange(char c, const char* str);
static int matchdot(char c);
static int ismetachar(char c);
/* Public functions: */
int re_match(const char* pattern, const char* text, int* matchlength)
{
return re_matchp(re_compile(pattern), text, matchlength);
}
int re_matchp(re_t pattern, const char* text, int* matchlength)
{
*matchlength = 0;
if (pattern != 0)
{
if (pattern[0].type == BEGIN)
{
return ((matchpattern(&pattern[1], text, matchlength)) ? 0 : -1);
}
else
{
int idx = -1;
do
{
idx += 1;
if (matchpattern(pattern, text, matchlength))
{
if (text[0] == '\0')
return -1;
return idx;
}
}
while (*text++ != '\0');
}
}
return -1;
}
re_t re_compile(const char* pattern)
{
/* The sizes of the two static arrays below substantiates the static RAM usage of this module.
MAX_REGEXP_OBJECTS is the max number of symbols in the expression.
MAX_CHAR_CLASS_LEN determines the size of buffer for chars in all char-classes in the expression. */
static regex_t re_compiled[MAX_REGEXP_OBJECTS];
static unsigned char ccl_buf[MAX_CHAR_CLASS_LEN];
int ccl_bufidx = 1;
char c; /* current char in pattern */
int i = 0; /* index into pattern */
int j = 0; /* index into re_compiled */
while (pattern[i] != '\0' && (j+1 < MAX_REGEXP_OBJECTS))
{
c = pattern[i];
switch (c)
{
/* Meta-characters: */
case '^': { re_compiled[j].type = BEGIN; } break;
case '$': { re_compiled[j].type = END; } break;
case '.': { re_compiled[j].type = DOT; } break;
case '*': { re_compiled[j].type = STAR; } break;
case '+': { re_compiled[j].type = PLUS; } break;
case '?': { re_compiled[j].type = QUESTIONMARK; } break;
/* case '|': { re_compiled[j].type = BRANCH; } break; <-- not working properly */
/* Escaped character-classes (\s \w ...): */
case '\\':
{
if (pattern[i+1] != '\0')
{
/* Skip the escape-char '\\' */
i += 1;
/* ... and check the next */
switch (pattern[i])
{
/* Meta-character: */
case 'd': { re_compiled[j].type = DIGIT; } break;
case 'D': { re_compiled[j].type = NOT_DIGIT; } break;
case 'w': { re_compiled[j].type = ALPHA; } break;
case 'W': { re_compiled[j].type = NOT_ALPHA; } break;
case 's': { re_compiled[j].type = WHITESPACE; } break;
case 'S': { re_compiled[j].type = NOT_WHITESPACE; } break;
/* Escaped character, e.g. '.' or '$' */
default:
{
re_compiled[j].type = CHAR;
re_compiled[j].u.ch = pattern[i];
} break;
}
}
/* '\\' as last char in pattern -> invalid regular expression. */
/*
else
{
re_compiled[j].type = CHAR;
re_compiled[j].ch = pattern[i];
}
*/
} break;
/* Character class: */
case '[':
{
/* Remember where the char-buffer starts. */
int buf_begin = ccl_bufidx;
/* Look-ahead to determine if negated */
if (pattern[i+1] == '^')
{
re_compiled[j].type = INV_CHAR_CLASS;
i += 1; /* Increment i to avoid including '^' in the char-buffer */
if (pattern[i+1] == 0) /* incomplete pattern, missing non-zero char after '^' */
{
return 0;
}
}
else
{
re_compiled[j].type = CHAR_CLASS;
}
/* Copy characters inside [..] to buffer */
while ( (pattern[++i] != ']')
&& (pattern[i] != '\0')) /* Missing ] */
{
if (pattern[i] == '\\')
{
if (ccl_bufidx >= MAX_CHAR_CLASS_LEN - 1)
{
//fputs("exceeded internal buffer!\n", stderr);
return 0;
}
if (pattern[i+1] == 0) /* incomplete pattern, missing non-zero char after '\\' */
{
return 0;
}
ccl_buf[ccl_bufidx++] = pattern[i++];
}
else if (ccl_bufidx >= MAX_CHAR_CLASS_LEN)
{
//fputs("exceeded internal buffer!\n", stderr);
return 0;
}
ccl_buf[ccl_bufidx++] = pattern[i];
}
if (ccl_bufidx >= MAX_CHAR_CLASS_LEN)
{
/* Catches cases such as [00000000000000000000000000000000000000][ */
//fputs("exceeded internal buffer!\n", stderr);
return 0;
}
/* Null-terminate string end */
ccl_buf[ccl_bufidx++] = 0;
re_compiled[j].u.ccl = &ccl_buf[buf_begin];
} break;
/* Other characters: */
default:
{
re_compiled[j].type = CHAR;
re_compiled[j].u.ch = c;
} break;
}
/* no buffer-out-of-bounds access on invalid patterns - see https://github.com/kokke/tiny-regex-c/commit/1a279e04014b70b0695fba559a7c05d55e6ee90b */
if (pattern[i] == 0)
{
return 0;
}
i += 1;
j += 1;
}
/* 'UNUSED' is a sentinel used to indicate end-of-pattern */
re_compiled[j].type = UNUSED;
return (re_t) re_compiled;
}
void re_print(regex_t* pattern)
{
const char* types[] = { "UNUSED", "DOT", "BEGIN", "END", "QUESTIONMARK", "STAR", "PLUS", "CHAR", "CHAR_CLASS", "INV_CHAR_CLASS", "DIGIT", "NOT_DIGIT", "ALPHA", "NOT_ALPHA", "WHITESPACE", "NOT_WHITESPACE", "BRANCH" };
int i;
int j;
char c;
for (i = 0; i < MAX_REGEXP_OBJECTS; ++i)
{
if (pattern[i].type == UNUSED)
{
break;
}
printf("type: %s", types[pattern[i].type]);
if (pattern[i].type == CHAR_CLASS || pattern[i].type == INV_CHAR_CLASS)
{
printf(" [");
for (j = 0; j < MAX_CHAR_CLASS_LEN; ++j)
{
c = pattern[i].u.ccl[j];
if ((c == '\0') || (c == ']'))
{
break;
}
printf("%c", c);
}
printf("]");
}
else if (pattern[i].type == CHAR)
{
printf(" '%c'", pattern[i].u.ch);
}
printf("\n");
}
}
/* Private functions: */
static int matchdigit(char c)
{
return isdigit(c);
}
static int matchalpha(char c)
{
return isalpha(c);
}
static int matchwhitespace(char c)
{
return isspace(c);
}
static int matchalphanum(char c)
{
return ((c == '_') || matchalpha(c) || matchdigit(c));
}
static int matchrange(char c, const char* str)
{
return ( (c != '-')
&& (str[0] != '\0')
&& (str[0] != '-')
&& (str[1] == '-')
&& (str[2] != '\0')
&& ( (c >= str[0])
&& (c <= str[2])));
}
static int matchdot(char c)
{
#if defined(RE_DOT_MATCHES_NEWLINE) && (RE_DOT_MATCHES_NEWLINE == 1)
(void)c;
return 1;
#else
return c != '\n' && c != '\r';
#endif
}
static int ismetachar(char c)
{
return ((c == 's') || (c == 'S') || (c == 'w') || (c == 'W') || (c == 'd') || (c == 'D'));
}
static int matchmetachar(char c, const char* str)
{
switch (str[0])
{
case 'd': return matchdigit(c);
case 'D': return !matchdigit(c);
case 'w': return matchalphanum(c);
case 'W': return !matchalphanum(c);
case 's': return matchwhitespace(c);
case 'S': return !matchwhitespace(c);
default: return (c == str[0]);
}
}
static int matchcharclass(char c, const char* str)
{
do
{
if (matchrange(c, str))
{
return 1;
}
else if (str[0] == '\\')
{
/* Escape-char: increment str-ptr and match on next char */
str += 1;
if (matchmetachar(c, str))
{
return 1;
}
else if ((c == str[0]) && !ismetachar(c))
{
return 1;
}
}
else if (c == str[0])
{
if (c == '-')
{
return ((str[-1] == '\0') || (str[1] == '\0'));
}
else
{
return 1;
}
}
}
while (*str++ != '\0');
return 0;
}
static int matchone(regex_t p, char c)
{
switch (p.type)
{
case DOT: return matchdot(c);
case CHAR_CLASS: return matchcharclass(c, (const char*)p.u.ccl);
case INV_CHAR_CLASS: return !matchcharclass(c, (const char*)p.u.ccl);
case DIGIT: return matchdigit(c);
case NOT_DIGIT: return !matchdigit(c);
case ALPHA: return matchalphanum(c);
case NOT_ALPHA: return !matchalphanum(c);
case WHITESPACE: return matchwhitespace(c);
case NOT_WHITESPACE: return !matchwhitespace(c);
default: return (p.u.ch == c);
}
}
static int matchstar(regex_t p, regex_t* pattern, const char* text, int* matchlength)
{
int prelen = *matchlength;
const char* prepoint = text;
while ((text[0] != '\0') && matchone(p, *text))
{
text++;
(*matchlength)++;
}
while (text >= prepoint)
{
if (matchpattern(pattern, text--, matchlength))
return 1;
(*matchlength)--;
}
*matchlength = prelen;
return 0;
}
static int matchplus(regex_t p, regex_t* pattern, const char* text, int* matchlength)
{
const char* prepoint = text;
while ((text[0] != '\0') && matchone(p, *text))
{
text++;
(*matchlength)++;
}
while (text > prepoint)
{
if (matchpattern(pattern, text--, matchlength))
return 1;
(*matchlength)--;
}
return 0;
}
static int matchquestion(regex_t p, regex_t* pattern, const char* text, int* matchlength)
{
if (p.type == UNUSED)
return 1;
if (matchpattern(pattern, text, matchlength))
return 1;
if (*text && matchone(p, *text++))
{
if (matchpattern(pattern, text, matchlength))
{
(*matchlength)++;
return 1;
}
}
return 0;
}
#if 0
/* Recursive matching */
static int matchpattern(regex_t* pattern, const char* text, int *matchlength)
{
int pre = *matchlength;
if ((pattern[0].type == UNUSED) || (pattern[1].type == QUESTIONMARK))
{
return matchquestion(pattern[1], &pattern[2], text, matchlength);
}
else if (pattern[1].type == STAR)
{
return matchstar(pattern[0], &pattern[2], text, matchlength);
}
else if (pattern[1].type == PLUS)
{
return matchplus(pattern[0], &pattern[2], text, matchlength);
}
else if ((pattern[0].type == END) && pattern[1].type == UNUSED)
{
return text[0] == '\0';
}
else if ((text[0] != '\0') && matchone(pattern[0], text[0]))
{
(*matchlength)++;
return matchpattern(&pattern[1], text+1);
}
else
{
*matchlength = pre;
return 0;
}
}
#else
/* Iterative matching */
static int matchpattern(regex_t* pattern, const char* text, int* matchlength)
{
int pre = *matchlength;
do
{
if ((pattern[0].type == UNUSED) || (pattern[1].type == QUESTIONMARK))
{
return matchquestion(pattern[0], &pattern[2], text, matchlength);
}
else if (pattern[1].type == STAR)
{
return matchstar(pattern[0], &pattern[2], text, matchlength);
}
else if (pattern[1].type == PLUS)
{
return matchplus(pattern[0], &pattern[2], text, matchlength);
}
else if ((pattern[0].type == END) && pattern[1].type == UNUSED)
{
return (text[0] == '\0');
}
/* Branching is not working properly
else if (pattern[1].type == BRANCH)
{
return (matchpattern(pattern, text) || matchpattern(&pattern[2], text));
}
*/
(*matchlength)++;
}
while ((text[0] != '\0') && matchone(*pattern++, *text++));
*matchlength = pre;
return 0;
}
#endif

View File

@ -2,7 +2,7 @@
#if UF_USE_DC_TEXCONV
#include <cmath>
#include <iostream>
//#include <iostream>
#include <texconv/common.h>
#include <texconv/imagecontainer.h>

View File

@ -1,7 +1,7 @@
#include <uf/config.h>
#if UF_USE_DC_TEXCONV
#include <iostream>
//#include <iostream>
#include <texconv/imagecontainer.h>
#include <texconv/twiddler.h>

View File

@ -1,7 +1,7 @@
#include <uf/config.h>
#if UF_USE_DC_TEXCONV
#include <iostream>
//#include <iostream>
#include <texconv/imagecontainer.h>
#include <texconv/twiddler.h>

View File

@ -1,7 +1,7 @@
#include <uf/config.h>
#if UF_USE_DC_TEXCONV
#include <iostream>
//#include <iostream>
#include <stb/stb_image.h>
#include <stb/stb_image_write.h>
@ -25,7 +25,7 @@ bool Image::loadFromFile(const uf::stl::string& path ) {
uint8_t* pixels = stbi_load(path.c_str(), &w, &h, &channels, STBI_rgb_alpha);
if ( !pixels ) {
std::cerr<<"[ERROR] Failed to load image: "<<path<<"\n";
//std::cerr<<"[ERROR] Failed to load image: "<<path<<"\n";
return false;
}

View File

@ -1,7 +1,7 @@
#include <uf/config.h>
#if UF_USE_DC_TEXCONV
#include <iostream>
//#include <iostream>
#include <algorithm>
#include <texconv/imagecontainer.h>

View File

@ -29,11 +29,12 @@ namespace pod {
type_t type = TYPE(void);
Traits traits{};
typedef std::function<void(uf::Object&)> function_t;
function_t initialize = function_t();
function_t tick = function_t();
function_t render = function_t();
function_t destroy = function_t();
// typedef std::function<void(uf::Object&)> function_t;
typedef void(*function_t)(uf::Object&);
function_t initialize = NULL;
function_t tick = NULL;
function_t render = NULL;
function_t destroy = NULL;
};
}
@ -72,7 +73,6 @@ namespace uf {
void generateGraph();
};
}
#include "macros.inl"

View File

@ -9,6 +9,11 @@ namespace uf {
UF_BEHAVIOR_DEFINE_TYPE();
UF_BEHAVIOR_DEFINE_TRAITS();
UF_BEHAVIOR_DEFINE_FUNCTIONS();
UF_BEHAVIOR_DEFINE_METADATA();
UF_BEHAVIOR_DEFINE_METADATA(
uf::stl::vector<LUA_FUN> initialize;
uf::stl::vector<LUA_FUN> tick;
uf::stl::vector<LUA_FUN> render;
uf::stl::vector<LUA_FUN> destroy;
);
}
}

View File

@ -14,6 +14,19 @@
#define JSON_HAS_STATIC_RTTI 0
#endif
#if UF_ENV_DREAMCAST
#define float64_t decltype(1.0L)
namespace std {
using ::snprintf;
using ::strtoull;
using ::strtoll;
using ::strtold;
}
#else
#define float64_t double
#endif
#include <nlohmann/json.hpp>
#include <nlohmann/fifo_map.hpp>
@ -24,11 +37,6 @@ namespace uf {
class UF_API Serializer;
}
#if UF_ENV_DREAMCAST
#define float64_t decltype(1.0L)
#else
#define float64_t double
#endif
namespace ext {
namespace json {

View File

@ -64,5 +64,11 @@ namespace ext {
}
#include "lua.inl"
#else
#define UF_LUA_REGISTER_USERTYPE_MEMBER(...)
#define UF_LUA_REGISTER_USERTYPE(...)
#define UF_LUA_REGISTER_COMPONENT(...)
#define UF_LUA_REGISTER_USERTYPE_AND_COMPONENT(...)
#endif

View File

@ -5,7 +5,6 @@
#include <vk_mem_alloc.h>
#include <typeinfo>
#include <iostream>
#include <cassert>
#include <mutex>

View File

@ -10,14 +10,6 @@
#endif
#include <uf/utils/memory/string.h>
namespace uf {
template <typename... Args>
inline uf::stl::string _fmt_format(fmt::format_string<Args...> fmt_str, Args&&... args) {
fmt::memory_buffer buffer;
fmt::format_to(std::back_inserter(buffer), fmt_str, std::forward<Args>(args)...);
return uf::stl::string(buffer.data(), buffer.size());
}
}
namespace uf {
#if UF_USE_FMT
@ -27,4 +19,13 @@ namespace uf {
// void UF_API exception( const uf::stl::string& message );
uf::stl::string UF_API log( const uf::stl::string& category, const uf::stl::string& file, const uf::stl::string& function, size_t line, const uf::stl::string& message );
}
}
namespace uf {
template <typename... Args>
inline uf::stl::string _fmt_format(fmt::format_string<Args...> fmt_str, Args&&... args) {
fmt::memory_buffer buffer;
fmt::format_to(std::back_inserter(buffer), fmt_str, std::forward<Args>(args)...);
return uf::stl::string(buffer.data(), buffer.size());
}
}

View File

@ -3,7 +3,6 @@
#include <uf/utils/memory/string.h>
#include <iostream>
#include <sstream>
#include <uf/utils/memory/vector.h>
#include <uf/utils/memory/unordered_map.h>

View File

@ -8,14 +8,13 @@
#include "sh4.h"
#include <dc/matrix.h>
#define UF_EZ_VEC4(vec, size) vec[0], size > 1 ? vec[1] : 0, size > 2 ? vec[2] : 0, size > 3 ? vec[3] : 0
#undef M_PI
#endif
#define NUM pod::Math::num_t
#ifndef M_PI
#define M_PI 3.141592653589793f
#endif
#define M_PI 3.141592653589793f
#define EPS 1.0e-6f
#define EPS2 (EPS * EPS)

View File

@ -6,7 +6,12 @@
#include <type_traits>
#define UF_MEMORYPOOL_USE_ALLOCATOR 1
#define UF_MEMORYPOOL_OVERRIDE_NEW_DELETE 1
#if __clang__
#define UF_MEMORYPOOL_OVERRIDE_NEW_DELETE 0
#else
#define UF_MEMORYPOOL_OVERRIDE_NEW_DELETE 1
#endif
namespace uf {
namespace allocator {
@ -28,7 +33,6 @@ namespace uf {
T* allocate( size_t n ) {
void* p = uf::allocator::allocate( n * sizeof(T) );
if ( !p ) throw std::bad_alloc();
return static_cast<T*>(p);
}
@ -53,7 +57,6 @@ namespace uf {
T* allocate( size_t n ) {
void* p = uf::allocator::malloc_m( n * sizeof(T) );
if ( !p ) throw std::bad_alloc();
return static_cast<T*>( p );
}

View File

@ -60,6 +60,7 @@ namespace uf {
}
// to-do: #if C++ >= 20 or something
/*
template<typename T>
std::span<const T> view( size_t count ) {
size_t bytes = count * sizeof(T);
@ -68,6 +69,7 @@ namespace uf {
m_offset += bytes;
return view;
}
*/
template<typename T>
const T* peek() const {

View File

@ -655,6 +655,7 @@ namespace uf {
//
template<typename T, typename U> void compile( uf::Mesh& mesh, const uf::stl::vector<uf::Meshlet_T<T, U>>& meshlets, uf::stl::vector<pod::Primitive>& primitives );
template<typename K, typename V> inline void compile( uf::Mesh& mesh, const uf::stl::unordered_map<K, V>& meshlets, uf::stl::vector<pod::Primitive>& primitives );
template<typename K, typename V> inline uf::stl::vector<pod::Primitive> compile( uf::Mesh& mesh, const uf::stl::unordered_map<K, V>& meshlets );
template<typename T> inline uf::stl::vector<pod::Primitive> compile( uf::Mesh& mesh, const uf::stl::vector<T>& meshlets );

View File

@ -2,12 +2,13 @@
#include <uf/config.h>
#include "encoding.h"
#include <uf/utils/memory/string.h>
#include <locale>
#include <cstring>
#if UF_USE_DEPRECATED_STRING
#include "encoding.h"
#include <uf/utils/memory/string.h>
#include <cstring>
#include <locale>
namespace uf {
class UF_API String {
public:

View File

@ -1,10 +1,8 @@
#include <uf/engine/asset/asset.h>
#include <regex>
#include <functional>
#include <iomanip>
#include <sys/stat.h>
#include <fstream>
#include <iostream>
#include <uf/utils/image/image.h>
#include <uf/utils/audio/audio.h>

View File

@ -1,7 +1,6 @@
#include <uf/engine/ext.h>
#include <fstream>
#include <iostream>
#include <regex>
#include <cstdlib>
@ -441,19 +440,6 @@ void UF_API uf::initialize() {
uf::config.path(keyString) = value;
modified = true;
}
/*
{
std::regex regex("^--(.+?)=(.+?)$");
std::cmatch match;
if ( std::regex_search( arg, match, regex ) ) {
uf::stl::string keyString = match[1].str();
uf::stl::string valueString = match[2].str();
uf::Serializer value; value.deserialize(valueString);
uf::config.path(keyString) = value;
modified = true;
}
}
*/
}
// UF_MSG_DEBUG("Arguments: {}", uf::Serializer(arguments));
if ( modified ) UF_MSG_DEBUG("New config: {}", uf::config.serialize());
@ -477,31 +463,32 @@ void UF_API uf::initialize() {
// check if we are even allowed to use memory pools
bool enabled = configMemoryPoolJson["enabled"].as(true);
auto deduceSize = [enabled]( const ext::json::Value& value )->size_t{
if ( !enabled ) return 0;
if ( value.is<size_t>() ) return value.as<size_t>();
if ( value.is<uf::stl::string>() ) {
uf::stl::string str = value.as<uf::stl::string>();
std::regex regex("^(\\d+) ?((?:K|M|G)?(?:i?B)?)$");
auto deduceSize = [enabled]( const ext::json::Value& value ) -> size_t {
if ( !enabled ) return 0;
if ( value.is<size_t>() ) return value.as<size_t>();
if ( value.is<uf::stl::string>() ) {
uf::stl::string str = value.as<uf::stl::string>();
if (str.empty()) return 0;
std::cmatch match;
if ( std::regex_search( str.c_str(), match, regex ) ) {
size_t requested = std::stoi( match[1].str() );
char* endPtr = nullptr;
size_t requested = std::strtoull(str.c_str(), &endPtr, 10);
uf::stl::string prefix(match[2].first, match[2].length());
if (endPtr == str.c_str()) return 0;
if (prefix.length() > 0) {
switch ( prefix.at(0) ) {
case 'K': return requested * 1024;
case 'M': return requested * 1024 * 1024;
case 'G': return requested * 1024 * 1024 * 1024;
}
}
return requested;
while (*endPtr == ' ') endPtr++;
// Check for the multiplier
if (*endPtr != '\0') {
switch (*endPtr) {
case 'K': case 'k': return requested * 1024;
case 'M': case 'm': return requested * 1024 * 1024;
case 'G': case 'g': return requested * 1024 * 1024 * 1024;
}
}
return 0;
};
return requested;
}
return 0;
};
// set memory pool alignment requirements
uf::memoryPool::alignment = configMemoryPoolJson["alignment"].as( uf::memoryPool::alignment );
// set memory pool sizes

View File

@ -61,11 +61,13 @@ void ext::PlayerCameraBehavior::initialize( uf::Object& self ) {
size = uf::vector::decode(uf::config["window"]["size"], pod::Vector2ui{});
raidou = (float) size.x / (float) size.y;
}
#if UF_USE_OPENVR
if ( ext::openvr::enabled ) {
camera.setProjection( ext::openvr::hmdProjectionMatrix(0, range.x, range.y), 0 );
camera.setProjection( ext::openvr::hmdProjectionMatrix(1, range.x, range.y), 1 );
} else {
} else
#endif
{
camera.setProjection( uf::matrix::perspective( fov, raidou, range.x, range.y ) );
}
}

View File

@ -159,9 +159,11 @@ void ext::ExtSceneBehavior::initialize( uf::Object& self ) {
#endif
renderMode.scale = 1.0f; // ::json["engine"]["ext"]["vulkan"]["framebuffer"]["size"].as(1.0f);
UF_MSG_DEBUG("Geometry render scale: {:.3f}", renderMode.scale);
#if UF_USE_OPENVR
if ( ext::openvr::enabled ) {
renderMode.metadata.eyes = 2;
}
#endif
#if UF_USE_VULKAN
if ( uf::renderer::settings::pipelines::deferred ) {
renderMode.metadata.pipelines.emplace_back(uf::renderer::settings::pipelines::names::deferred);

View File

@ -1085,44 +1085,6 @@ void uf::graph::process( pod::Graph& graph ) {
material.indexAlbedo = -1;
}
}
if ( ext::json::isObject( graphMetadataDark ) ) {
// set transparent
if ( name.find("glass") != uf::stl::string::npos ||
name.find("trans") != uf::stl::string::npos ||
name.find("grate") != uf::stl::string::npos ) {
material.modeAlpha = pod::Material::AlphaMode::BLEND;
material.modeCull = pod::Material::CullMode::NONE;
}
// set emissive
for ( auto nodeID = 0; nodeID < graph.nodes.size(); ++nodeID ) {
auto& node = graph.nodes[nodeID];
// check if owns a light
auto lightName = node.name;
auto nameID = FMT_FORMAT( "{}_{}", node.name, nodeID );
if ( graph.lights.count( nameID ) > 0 ) lightName = nameID;
if ( graph.lights.count( lightName ) == 0 ) {
continue;
}
auto& light = graph.lights[lightName];
if ( !(0 <= node.mesh && node.mesh < graph.meshes.size()) ) continue;
// iterate primitives for materials
auto& primitives = storage.primitives.map[graph.primitives[node.mesh]];
for ( auto& primitive : primitives ) {
auto materialID = primitive.instance.materialID;
if ( !(0 <= materialID && materialID <= graph.materials.size()) ) {
UF_MSG_DEBUG("node={}, lightName={} has invalid material: {}", node.name, lightName, materialID);
continue;
}
auto& materialName = graph.materials[materialID];
// set emissive
material.modeAlpha = pod::Material::AlphaMode::EMISSIVE;
material.colorEmissive = light.color * light.intensity;
UF_MSG_DEBUG("name={}, light={}, emissive={}", node.name, lightName, uf::vector::toString( material.colorEmissive ));
}
}
}
auto tag = ext::json::find( name, graphMetadataJson["tags"] );
if ( ext::json::isObject( tag ) ) {

View File

@ -135,7 +135,7 @@ bool uf::instantiator::valid( uf::Entity* pointer ) {
}
void uf::instantiator::registerBehavior( const uf::stl::string& name, const pod::Behavior& behavior ) {
if ( !uf::instantiator::behaviors ) uf::instantiator::behaviors = new uf::stl::unordered_map<uf::stl::string, pod::Behavior>;\
if ( !uf::instantiator::behaviors ) uf::instantiator::behaviors = new uf::stl::unordered_map<uf::stl::string, pod::Behavior>;
(*uf::instantiator::behaviors)[name] = behavior;
#if UF_INSTANTIATOR_ANNOUNCE
UF_MSG_DEBUG("Registered behavior for {} | {}", name, behavior.type.name().str());

View File

@ -12,6 +12,18 @@
#include <uf/engine/asset/asset.h>
#include <uf/ext/lua/lua.h>
namespace {
void invoke( uf::Object& self, const uf::stl::vector<LUA_FUN>& functions ) {
for ( auto& script : functions ) {
auto result = script(self);
if ( !result.valid() ) {
sol::error err = result;
UF_MSG_ERROR("{}", err.what());
}
}
}
}
UF_BEHAVIOR_REGISTER_CPP(uf::LuaBehavior)
UF_BEHAVIOR_TRAITS_CPP(uf::LuaBehavior, ticks = false, renders = false, thread = "")
#define this (&self)
@ -38,11 +50,23 @@ void uf::LuaBehavior::initialize( uf::Object& self ) {
ext::lua::run( script );
*/
});
auto& metadata = self.getComponent<uf::LuaBehavior::Metadata>();
::invoke( self, metadata.initialize );
#endif
}
void uf::LuaBehavior::destroy( uf::Object& self ) {}
void uf::LuaBehavior::tick( uf::Object& self ) {}
void uf::LuaBehavior::render( uf::Object& self ) {}
void uf::LuaBehavior::destroy( uf::Object& self ) {
auto& metadata = self.getComponent<uf::LuaBehavior::Metadata>();
::invoke( self, metadata.destroy );
}
void uf::LuaBehavior::tick( uf::Object& self ) {
auto& metadata = self.getComponent<uf::LuaBehavior::Metadata>();
::invoke( self, metadata.tick );
}
void uf::LuaBehavior::render( uf::Object& self ) {
auto& metadata = self.getComponent<uf::LuaBehavior::Metadata>();
::invoke( self, metadata.tick );
}
void uf::LuaBehavior::Metadata::serialize( uf::Object& self, uf::Serializer& serializer ) {}
void uf::LuaBehavior::Metadata::deserialize( uf::Object& self, uf::Serializer& serializer ) {}
#undef this

View File

@ -9,7 +9,6 @@
#include <uf/utils/io/fmt.h>
#include <uf/utils/io/vfs.h>
#include <uf/engine/ext.h>
#include <regex>
UF_OBJECT_REGISTER_BEGIN(uf::Scene)
// UF_OBJECT_REGISTER_BEHAVIOR(uf::EntityBehavior)

View File

@ -7,7 +7,6 @@
#include <uf/ext/audio/pcm.h>
#include <uf/utils/memory/pool.h>
#include <iostream>
#include <cstdio>
void ext::pcm::load( pod::AudioClip& clip, const pod::PCM& pcm ) {

View File

@ -8,7 +8,6 @@
#include <uf/ext/audio/vorbis.h>
#include <uf/utils/memory/pool.h>
#include <uf/utils/io/vfs.h>
#include <iostream>
#include <vector>
#include <cstring>

View File

@ -8,7 +8,6 @@
#include <uf/ext/audio/wav.h>
#include <uf/utils/memory/pool.h>
#include <uf/utils/io/vfs.h>
#include <iostream>
#include <cstdio>
#include <cstring>

View File

@ -7,7 +7,6 @@
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <thread>
#include <uf/utils/memory/vector.h>
@ -304,7 +303,6 @@ void ext::discord::tick() {
/*
#include <cstdio>
#include <iostream>
#include <assert.h>
#define DISCORD_REQUIRE(x) assert(x == DiscordResult_Ok)

View File

@ -1,4 +1,3 @@
#include <iostream>
#if UF_USE_FREETYPE
#include <uf/ext/freetype/freetype.h>
#include <uf/utils/io/file.h>

View File

@ -1,3 +1,4 @@
#if UF_USE_IMGUI
#include "behavior.h"
#include <uf/utils/hook/hook.h>
@ -7,14 +8,12 @@
#include <uf/utils/window/payloads.h>
#include <uf/utils/thread/thread.h>
#if UF_USE_IMGUI
#include <uf/ext/imgui/imgui.h>
#include <imgui/imgui.h>
#include <imgui/imgui_stdlib.h>
#include <uf/ext/imgui/imgui.h>
#include <imgui/imgui.h>
#include <imgui/imgui_stdlib.h>
#include "consoleWindow.inl"
#include "threadMetrics.inl"
#endif
#include "consoleWindow.inl"
#include "threadMetrics.inl"
UF_BEHAVIOR_REGISTER_CPP(ext::ImguiBehavior)
UF_BEHAVIOR_TRAITS_CPP(ext::ImguiBehavior, ticks = false, renders = false, thread = "")
@ -55,4 +54,5 @@ void ext::ImguiBehavior::Metadata::serialize( uf::Object& self, uf::Serializer&
}
void ext::ImguiBehavior::Metadata::deserialize( uf::Object& self, uf::Serializer& serializer ){
}
#undef this
#undef this
#endif

View File

@ -193,6 +193,24 @@ namespace impl {
uint32_t pad;
};
struct PropertyJointPos {
float el[6];
};
struct PropertyBitmapWorldspace {
float x_size;
float y_size;
float x_feet_per_tile;
float y_feet_per_tile;
};
enum PropertyRenderTypeEnum : int32_t {
RENDER_NORMALLY = 0,
RENDER_NOT_AT_ALL = 1,
RENDER_UNLIT = 2,
RENDER_EDITOR_ONLY = 3,
};
struct PropertyPhysType {
enum int32_t {
OBB = 0,
@ -445,6 +463,17 @@ namespace impl {
uf::stl::unordered_map<int32_t, int32_t> tripFlags;
uf::stl::unordered_map<int32_t, uf::stl::vector<uf::stl::string>> script;
uf::stl::unordered_map<int32_t, int32_t> hasRefs;
uf::stl::unordered_map<int32_t, float> renderAlpha;
uf::stl::unordered_map<int32_t, float> selfIllum;
uf::stl::unordered_map<int32_t, int32_t> objShad;
uf::stl::unordered_map<int32_t, int32_t> renderType;
uf::stl::unordered_map<int32_t, int32_t> invisible;
uf::stl::unordered_map<int32_t, PropertyJointPos> jointPos;
uf::stl::unordered_map<int32_t, PropertyBitmapWorldspace> bitmapWorldspace;
uf::stl::unordered_map<int32_t, int32_t> bitmapAnimation;
} properties;
uf::stl::unordered_map<uf::stl::string, uf::stl::string> fileDatabase;
@ -1110,12 +1139,89 @@ namespace impl {
material.indexMetallicRoughness = -1;
material.indexOcclusion = -1;
material.indexCubemap = -1;
if ( matName.find("glass") != uf::stl::string::npos ) {
material.modeAlpha = pod::Material::AlphaMode::BLEND;
} else if ( hasTransparency ) {
/*
if ( hasTransparency ) {
material.modeAlpha = pod::Material::AlphaMode::MASK;
}
*/
uf::stl::string mtlPath = targetPath;
size_t extPos = mtlPath.find_last_of('.');
if ( extPos != uf::stl::string::npos ) {
mtlPath = mtlPath.substr(0, extPos) + ".mtl";
}
uf::stl::vector<uint8_t> mtlBuffer;
if ( uf::io::exists( mtlPath ) && uf::io::readAsBuffer( mtlBuffer, mtlPath ) ) {
uf::stl::string mtlText(mtlBuffer.begin(), mtlBuffer.end());
std::transform(mtlText.begin(), mtlText.end(), mtlText.begin(), ::tolower);
UF_MSG_DEBUG("Found NewDark MTL for: {}: {}", matName, mtlText);
}
}
}
void processMaterials( pod::Graph& graph, impl::DarkContext& ctx ) {
auto& storage = uf::graph::getStorage(graph);
uf::stl::unordered_set<uf::stl::string> updated;
for ( auto nodeID = 0; nodeID < graph.nodes.size(); ++nodeID ) {
auto& node = graph.nodes[nodeID];
if ( !(0 <= node.mesh && node.mesh < graph.meshes.size()) ) continue;
auto& renderMeta = node.metadata["dark"]["render"];
if ( !renderMeta.isObject() ) continue;
float alpha = renderMeta["alpha"].as<float>(1.0f);
float selfIllum = renderMeta["emissive"].as<float>(0.0f);
bool unlit = renderMeta["unlit"].as<bool>(false);
// If this node uses standard opaque/lit rendering, no patching needed.
if ( alpha >= 1.0f && selfIllum <= 0.0f && !unlit ) continue;
// Check if this node owns a light (for tinting emissives)
auto nameID = FMT_FORMAT( "{}_{}", node.name, nodeID );
auto lightName = node.name;
if ( graph.lights.count( nameID ) > 0 ) lightName = nameID;
bool hasLight = graph.lights.count( lightName ) > 0;
// Iterate primitives for materials
auto& primitives = storage.primitives.map[graph.primitives[node.mesh]];
for ( auto& primitive : primitives ) {
auto materialID = primitive.instance.materialID;
if ( !(0 <= materialID && materialID <= graph.materials.size()) ) continue;
auto& materialName = graph.materials[materialID];
auto& material = storage.materials[materialName];
if ( updated.count( materialName ) ) continue;
updated.insert( materialName );
// Apply Alpha
if ( alpha < 1.0f ) {
// Only override to BLEND if it wasn't already set to MASK (grates/fences)
if ( material.modeAlpha != pod::Material::AlphaMode::MASK ) {
material.modeAlpha = pod::Material::AlphaMode::BLEND;
}
// Multiply base color alpha
material.colorBase.w *= alpha;
UF_MSG_DEBUG("node={}, material={}, alpha={}", node.name, materialName, alpha);
}
// Apply Emissive (SelfIllum or Unlit)
if ( selfIllum > 0.0f || unlit ) {
material.modeAlpha = pod::Material::AlphaMode::EMISSIVE;
float glow = (selfIllum > 0.0f) ? selfIllum : 1.0f;
if ( hasLight ) {
auto& light = graph.lights[lightName];
material.colorEmissive = light.color * (light.intensity * glow);
} else {
material.colorEmissive = { glow, glow, glow, 1.0f };
}
UF_MSG_DEBUG("node={}, material={}, emissive={}", node.name, materialName, uf::vector::toString(material.colorEmissive));
}
}
}
}
@ -1543,6 +1649,59 @@ namespace impl {
}
}
// bind render states
int32_t renderType = impl::PropertyRenderTypeEnum::RENDER_NORMALLY;
ctx.findInheritedProperty( objectID, ctx.properties.renderType, renderType );
int32_t isInvisible = 0;
ctx.findInheritedProperty( objectID, ctx.properties.invisible, isInvisible );
if ( renderType == impl::PropertyRenderTypeEnum::RENDER_NOT_AT_ALL ||
renderType == impl::PropertyRenderTypeEnum::RENDER_EDITOR_ONLY ||
isInvisible != 0 )
{
metadata["render"]["visible"] = false;
} else {
metadata["render"]["visible"] = true;
}
if ( renderType == impl::PropertyRenderTypeEnum::RENDER_UNLIT ) {
metadata["render"]["unlit"] = true;
}
float renderAlpha = 1.0f;
if ( ctx.findInheritedProperty( objectID, ctx.properties.renderAlpha, renderAlpha ) ) {
metadata["render"]["alpha"] = renderAlpha;
}
float selfIllum = 0.0f;
if ( ctx.findInheritedProperty( objectID, ctx.properties.selfIllum, selfIllum ) ) {
metadata["render"]["emissive"] = selfIllum;
}
int32_t objShad = 1;
if ( ctx.findInheritedProperty( objectID, ctx.properties.objShad, objShad ) ) {
metadata["render"]["cast_shadows"] = (objShad != 0);
}
PropertyJointPos jointPos;
if ( ctx.findInheritedProperty( objectID, ctx.properties.jointPos, jointPos ) ) {
for (int j = 0; j < 6; ++j) {
metadata["render"]["joints"].emplace_back(jointPos.el[j]);
}
}
PropertyBitmapWorldspace bmpWorld;
if ( ctx.findInheritedProperty( objectID, ctx.properties.bitmapWorldspace, bmpWorld ) ) {
metadata["render"]["bitmap_worldspace"]["x_size"] = bmpWorld.x_size;
metadata["render"]["bitmap_worldspace"]["y_size"] = bmpWorld.y_size;
}
int32_t bmpAnim = 0;
if ( ctx.findInheritedProperty( objectID, ctx.properties.bitmapAnimation, bmpAnim ) ) {
metadata["render"]["bitmap_animation_flags"] = bmpAnim;
}
// bind trip f l ags
int32_t tripFlags = 0;
if ( ctx.findInheritedProperty( objectID, ctx.properties.tripFlags, tripFlags ) ) {
@ -1555,9 +1714,9 @@ namespace impl {
if ( ctx.findInheritedProperty(objectID, ctx.properties.frobInfo, frob) ) {
isFrobbable = frob.world_action != 0;
metadata["frob"]["world"] = frob.world_action;
metadata["frob"]["inv"] = frob.inv_action;
metadata["frob"]["tool"] = frob.tool_action;
metadata["frob"]["world"] = frob.world_action;
metadata["frob"]["inv"] = frob.inv_action;
metadata["frob"]["tool"] = frob.tool_action;
}
// bind physics
@ -1878,6 +2037,16 @@ namespace impl {
impl::extractProperty( ctx, "SchAction", ctx.properties.schAction, 4 );
impl::extractProperty( ctx, "Scripts", ctx.properties.script );
impl::extractProperty( ctx, "HasRefs", ctx.properties.hasRefs );
impl::extractProperty( ctx, "RenderAlpha", ctx.properties.renderAlpha );
impl::extractProperty( ctx, "SelfIllum", ctx.properties.selfIllum );
impl::extractProperty( ctx, "ObjShad", ctx.properties.objShad );
impl::extractProperty( ctx, "RenderType", ctx.properties.renderType );
impl::extractProperty( ctx, "INVISIBLE", ctx.properties.invisible );
impl::extractProperty( ctx, "JointPos", ctx.properties.jointPos );
impl::extractProperty( ctx, "BitmapWorld", ctx.properties.bitmapWorldspace );
impl::extractProperty( ctx, "BitmapAnimation", ctx.properties.bitmapAnimation );
impl::extractProperty( ctx, "Position", ctx.properties.position );
impl::extractProperty( ctx, "Light", ctx.properties.light );
impl::extractProperty( ctx, "TransDoor", ctx.properties.transDoor );
@ -2093,6 +2262,7 @@ void ext::lgs::loadMis( pod::Graph& graph, const uf::stl::string& filename, cons
impl::processLinks( graph, ctx );
impl::processSongs( graph, ctx );
impl::processSchema( graph, ctx );
impl::processMaterials( graph, ctx );
graph.metadata["dark"]["_"] = true;

View File

@ -266,7 +266,7 @@ namespace binds {
if ( --count != 0 ) ::fmt::print("\t");
}
::fmt::print("\n");
std::cout.flush();
fflush(stdout);
};
}
namespace math {

View File

@ -51,6 +51,16 @@ namespace binds {
if ( !behaviorPointer ) return false;
pod::Behavior& behavior = *behaviorPointer;
auto& metadata = self.getComponent<uf::LuaBehavior::Metadata>();
uf::stl::vector<LUA_FUN>* functionPointer = NULL;
if ( type == "initialize" ) functionPointer = &metadata.initialize;
else if ( type == "tick" ) { functionPointer = &metadata.tick; behavior.traits.ticks = true; behavior.traits.thread = ""; }
else if ( type == "render" ) { functionPointer = &metadata.render; behavior.traits.renders = true; }
else if ( type == "destroy" ) functionPointer = &metadata.destroy;
if ( !functionPointer ) return false;
functionPointer->emplace_back( fun );
#if 0
pod::Behavior::function_t* functionPointer = NULL;
if ( type == "initialize" ) functionPointer = &behavior.initialize;
else if ( type == "tick" ) { functionPointer = &behavior.tick; behavior.traits.ticks = true; behavior.traits.thread = ""; }
@ -92,6 +102,7 @@ namespace binds {
};
}
#endif
#endif
self.generateGraph();
return true;
}

View File

@ -218,7 +218,7 @@ bool ext::lz4::decompressFromMemory( uf::stl::vector<uint8_t>& dst, const void*
}
return true;
}
#if !UF_ENV_DREAMCAST
size_t ext::lz4::compressToFile( const uf::stl::string& filename, const void* data, size_t size ) {
LZ4F_preferences_t prefs = {};
size_t bound = LZ4F_compressFrameBound(size, &prefs);
@ -229,4 +229,5 @@ size_t ext::lz4::compressToFile( const uf::stl::string& filename, const void* da
if ( LZ4F_isError(compressedSize) ) return 0;
return uf::vfs::write( filename, compressedData.data(), compressedSize );
}
}
#endif

View File

@ -5,7 +5,6 @@
#include <uf/utils/memory/pool.h>
#include <uf/utils/string/io.h>
#include <uf/utils/audio/audio.h>
#include <iostream>
namespace {
ALCdevice* device = NULL;
@ -248,6 +247,41 @@ void ext::al::Buffer::buffer(ALenum format, const ALvoid* data, ALsizei size, AL
AL_CHECK_RESULT(alBufferData(this->m_indices[i], format, data, size, frequency));
}
#if UF_ENV_DREAMCAST
void ext::al::Filter::initialize() {
}
void ext::al::Filter::destroy() {
}
ALuint ext::al::Filter::getIndex() const {
return this->m_index;
}
void ext::al::Filter::set( ALenum name, ALfloat x ) {
}
void ext::al::Filter::set( ALenum name, ALint x ) {
}
void ext::al::Effect::initialize() {
}
void ext::al::Effect::destroy() {
}
ALuint ext::al::Effect::getIndex() const { return this->m_index; }
void ext::al::Effect::set( ALenum name, ALfloat x ) {
}
void ext::al::Effect::set( ALenum name, ALint x ) {
}
void ext::al::EffectSlot::initialize() {
}
void ext::al::EffectSlot::destroy() {
}
ALuint ext::al::EffectSlot::getIndex() const { return this->m_index; }
void ext::al::EffectSlot::set( ALenum name, ALfloat x ) {
}
void ext::al::EffectSlot::set( ALenum name, ALint x ) {
}
#else
void ext::al::Filter::initialize() {
if ( this->m_index ) this->destroy();
AL_CHECK_RESULT(alGenFilters(1, &this->m_index));
@ -308,5 +342,6 @@ void ext::al::EffectSlot::set( ALenum name, ALfloat x ) {
void ext::al::EffectSlot::set( ALenum name, ALint x ) {
AL_CHECK_RESULT_ENUM( alAuxiliaryEffectSloti, this->m_index, name, x );
}
#endif
#endif

View File

@ -89,7 +89,7 @@ void ext::opengl::BaseRenderMode::initialize( Device& device ) {
// GL_ERROR_CHECK(glEnable(GL_COLOR_MATERIAL));
// GL_ERROR_CHECK(glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE));
// GL_ERROR_CHECK(glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR));
#if UF_USE_DREAMCAST
#if UF_ENV_DREAMCAST
//profiler_enable();
// GL_ERROR_CHECK(glEnable(GL_NEARZ_CLIPPING_KOS));

View File

@ -8,7 +8,6 @@
#include <uf/ext/gltf/gltf.h>
#include <fstream>
#include <regex>
namespace {
uint32_t VERTEX_BUFFER_BIND_ID = 0;

View File

@ -3,7 +3,6 @@
#include <uf/config.h>
#if UF_USE_DC_TEXCONV
#include <iostream>
#include <fstream>
#include <algorithm>

View File

@ -10,7 +10,6 @@
#include <spirv_cross/spirv_cross.hpp>
#include <spirv_cross/spirv_glsl.hpp>
#include <fstream>
#include <regex>
#define USE_SHARED_PIPELINES 0

View File

@ -236,7 +236,7 @@ ext::vulkan::userdata_t ext::vulkan::jsonToUserdata( const ext::json::Value& pay
std::regex regex("^(?:(.+?)\\<)?(.+?)(?:\\>)?(?:\\[(\\d+)\\])?$");
std::smatch match;
if ( !std::regex_search( type, match, regex ) ) {
std::cout << "Ill formatted typename: " << definition["name"].as<uf::stl::string>() << std::endl;
UF_MSG_ERROR("Ill formatted typename: {}", definition["name"].as<uf::stl::string>());
return;
}
uf::stl::string vectorMatrix = match[1].str();

View File

@ -225,6 +225,7 @@ bool ext::zlib::decompressScatter( const uf::stl::string& filename, uf::stl::vec
return success;
}
#if !UF_ENV_DREAMCAST
size_t ext::zlib::compressToFile( const uf::stl::string& filename, const void* data, size_t size ) {
z_stream strm{};
// 31 means gzip format
@ -249,6 +250,7 @@ size_t ext::zlib::compressToFile( const uf::stl::string& filename, const void* d
return uf::vfs::write( filename, compressedData.data(), compressedData.size() );
}
#endif
bool ext::zlib::directory( const uf::stl::vector<uint8_t>& buffer, uf::stl::unordered_map<uf::stl::string, pod::ZipEntry>& entries ) {
if ( buffer.size() < 22 ) return false;

View File

@ -2,7 +2,6 @@
#ifdef UF_ENV_LINUX
#include <iostream>
#include <locale>
#include <unistd.h>
#include <termios.h>

View File

@ -2,8 +2,10 @@
#include <uf/utils/io/iostream.h>
#include <uf/utils/string/locale.h>
#if !UF_ENV_DREAMCAST
#include <locale>
#include <clocale>
#endif
spec::Terminal spec::terminal;
@ -18,7 +20,7 @@ void spec::uni::Terminal::hide() {
void spec::uni::Terminal::show() {
}
void spec::uni::Terminal::setLocale() {
#if !UF_ENV_DREAMCAST
#if UF_USE_DEPRECATED_STRING
const char* locales[4] = {
"", "C.utf8", "C", "POSIX"
};
@ -30,7 +32,7 @@ void spec::uni::Terminal::setLocale() {
uf::locale::current = name;
break;
} catch ( ... ) {
std::cout << "Attempted to set invalid locale: " << name << std::endl;
UF_MSG_ERROR("Attempted to set invalid locale: {}", name);
continue;
}
}

View File

@ -1,5 +1,29 @@
#include <uf/spec/time/time.h>
#if UF_ENV_DREAMCAST
#include <sys/time.h>
#include <stddef.h>
namespace {
inline spec::uni::time::time_t get_time_us() {
struct timeval tv;
gettimeofday(&tv, NULL);
return static_cast<spec::uni::time::time_t>(tv.tv_sec) * 1000000ULL + tv.tv_usec;
}
inline spec::uni::time::time_t& startPoint() {
static spec::uni::time::time_t start = get_time_us();
return start;
}
}
spec::uni::time::time_t spec::uni::time::unixTime() {
return get_time_us();
}
spec::uni::time::time_t spec::uni::time::getTime() {
return get_time_us() - startPoint();
}
#else
#include <chrono>
namespace {
@ -20,15 +44,4 @@ spec::uni::time::time_t spec::uni::time::getTime() {
std::chrono::duration<double> elapsed = getTimePoint() - startPoint();
return elapsed.count() * 1000000;
}
/*
spec::uni::Time::time_t spec::uni::Time::unixTime() {
return std::chrono::duration_cast<std::chrono::microseconds>(getTimePoint().time_since_epoch()).count();
}
spec::uni::Time::time_t spec::uni::Time::getTime() {
std::chrono::duration<double> elapsed = getTimePoint() - startPoint();
return elapsed.count() * 1000000;
}
spec::uni::Time::exp_t spec::uni::Time::unit = -6;
*/
#endif

View File

@ -28,7 +28,6 @@
#include <unistd.h>
#include <cstring>
#include <iostream>
#define None 0L
#define Success 0

View File

@ -4,25 +4,24 @@
#if UF_USE_CURL
#include <curl/curl.h>
#endif
#include <iostream>
namespace {
bool exists( pod::Mount& mount, const uf::stl::string& p ) {
bool vfs_exists( pod::Mount& mount, const uf::stl::string& p ) {
uf::stl::string url = mount.prefix + p;
uf::Http http = uf::http::head(url);
return ( http.code >= 200 && http.code < 300 );
}
size_t size( pod::Mount& mount, const uf::stl::string& p ) {
size_t vfs_size( pod::Mount& mount, const uf::stl::string& p ) {
uf::stl::string url = mount.prefix + p;
uf::Http http = uf::http::head(url);
return http.contentLength;
}
size_t mtime( pod::Mount& mount, const uf::stl::string& p ) {
size_t vfs_mtime( pod::Mount& mount, const uf::stl::string& p ) {
uf::stl::string url = mount.prefix + p;
uf::Http http = uf::http::head(url);
return http.mtime;
}
bool read( pod::Mount& mount, const uf::stl::string& p, uf::stl::vector<uint8_t>& buffer ) {
bool vfs_read( pod::Mount& mount, const uf::stl::string& p, uf::stl::vector<uint8_t>& buffer ) {
uf::stl::string url = mount.prefix + p;
uf::Http http = uf::http::get(url);
@ -34,7 +33,7 @@ namespace {
buffer.assign(http.response.begin(), http.response.end());
return true;
}
size_t write( pod::Mount& mount, const uf::stl::string& p, const void* buffer, size_t size ) {
size_t vfs_write( pod::Mount& mount, const uf::stl::string& p, const void* buffer, size_t size ) {
uf::stl::string url = mount.prefix + p;
uf::Http http = uf::http::post(url, buffer, size);
@ -56,11 +55,11 @@ namespace impl {
.prefix = prefix,
.path = path,
.priority = priority,
.exists = ::exists,
.size = ::size,
.mtime = ::mtime,
.read = ::read,
.write = ::write,
.exists = ::vfs_exists,
.size = ::vfs_size,
.mtime = ::vfs_mtime,
.read = ::vfs_read,
.write = ::vfs_write,
};
}
}

View File

@ -1,5 +1,4 @@
#include <uf/utils/image/atlas.h>
#include <iostream>
#include <bit>
#define STB_RECT_PACK_IMPLEMENTATION

View File

@ -5,7 +5,6 @@
#include <sys/stat.h>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <uf/utils/io/file.h>
#include <uf/utils/io/iostream.h>
@ -237,8 +236,10 @@ bool uf::io::decompress( uf::stl::vector<uint8_t>& buffer, const uf::stl::string
}
size_t uf::io::compress( const uf::stl::string& filename, const void* buffer, size_t size ) {
uf::stl::string extension = uf::io::extension( filename );
#if !UF_ENV_DREAMCAST
if ( extension == "gz" ) return ext::zlib::compressToFile( filename, buffer, size );
if ( extension == "lz4" ) return ext::lz4::compressToFile( filename, buffer, size );
#endif
UF_MSG_ERROR("unsupported compression format requested: {}", extension);
return 0;
}

View File

@ -6,7 +6,6 @@
#include <uf/utils/io/console.h>
#include <uf/utils/io/fmt.h>
#include <iostream>
#include <sstream>
/*
@ -18,7 +17,7 @@ uf::stl::string uf::io::log( const uf::stl::string& category, const uf::stl::str
auto string = FMT_FORMAT("[{}] [{}:{}@{}]: {}", category, file, function, line, message);
::fmt::print("{}\n", string);
uf::iostream.pushHistory(string);
std::cout.flush();
fflush(stdout);
uf::console::print( string );

View File

@ -8,7 +8,6 @@
#include <uf/spec/terminal/terminal.h>
#include <sstream>
#include <iostream>
#include <uf/utils/memory/vector.h>
@ -82,43 +81,49 @@ void uf::IoStream::pushHistory( const uf::stl::string& str ) {
void uf::IoStream::back() {
}
char uf::IoStream::readChar(const bool& loop) {
/*
auto ch = std::cin.get();
addCh(ch);
// ::info.input.history.push_back( FMT_FORMAT("{}", ch) );
return ch;
*/
}
uf::stl::string uf::IoStream::readString(const bool& loop) {
/*
uf::stl::string str;
std::getline(std::cin, str);
addStr(str);
// ::info.input.history.push_back( str );
return str;
*/
}
#if UF_USE_DEPRECATED_STRING
uf::String uf::IoStream::readUString(const bool& loop) {
/*
uf::stl::string str;
std::getline(std::cin, str);
addStr(str);
// ::info.input.history.push_back( str );
return str;
*/
}
#endif
char uf::IoStream::writeChar( char ch ) {
addCh(ch);
if ( ch == '\n' ) std::cout << std::endl;
else std::cout << ch;
// if ( ch == '\n' ) std::cout << std::endl;
// else std::cout << ch;
// ::info.input.history.push_back( FMT_FORMAT("{}", ch) );
return ch;
}
const uf::stl::string& uf::IoStream::writeString( const uf::stl::string& str ) {
addStr(str);
if ( str == "\n" ) std::cout << std::endl;
else std::cout << str;
// if ( str == "\n" ) std::cout << std::endl;
// else std::cout << str;
// ::info.input.history.push_back( str );
return str;
}
@ -126,7 +131,7 @@ const uf::stl::string& uf::IoStream::writeString( const uf::stl::string& str ) {
const uf::String& uf::IoStream::writeUString( const uf::String& str ) {
addUStr(str);
std::cout << (const char*) str.getString().c_str();
// std::cout << (const char*) str.getString().c_str();
// ::info.input.history.push_back( str );
return str;
}

View File

@ -2,16 +2,52 @@
#include <uf/utils/io/file.h>
#include <uf/utils/math/hash.h>
#include <algorithm>
#include <filesystem>
#include <sys/stat.h>
#if UF_ENV_DREAMCAST
#include <kos/fs.h>
#include <kos/limits.h>
#else
#include <filesystem>
#endif
namespace {
#if UF_ENV_DREAMCAST
void ls_kos( const uf::stl::string& basePath, const uf::stl::string& currentSubDir, const uf::stl::string& extension, bool recursive, uf::stl::vector<uf::stl::string>& files ) {
uf::stl::string fullPath = basePath + currentSubDir;
file_t fd = fs_open(fullPath.c_str(), O_DIR | O_RDONLY);
if (fd == FILEHND_INVALID) return;
const dirent_t* entry;
while ( (entry = fs_readdir(fd)) != nullptr ) {
if (entry->name[0] == '.' && (entry->name[1] == '\0' || (entry->name[1] == '.' && entry->name[2] == '\0'))) {
continue;
}
uf::stl::string fname = entry->name;
uf::stl::string relPath = currentSubDir.empty() ? fname : currentSubDir + "/" + fname;
bool isDir = (entry->size < 0) || (entry->attr & O_DIR);
if ( isDir ) {
if ( recursive ) {
::ls_kos(basePath, relPath, extension, recursive, files);
}
} else {
if (extension.empty() || fname.ends_with(extension)) {
files.emplace_back(relPath);
}
}
}
fs_close(fd);
}
#endif
bool vfs_exists( pod::Mount& mount, const uf::stl::string& file ) {
uf::stl::string path = mount.path + file;
#if UF_ENV_DREAMCAST
FILE* file = fopen(path.c_str(), "r");
if ( file ) {
fclose(file);
FILE* f = fopen(path.c_str(), "r");
if ( f ) {
fclose(f);
return true;
}
return false;
@ -57,8 +93,12 @@ namespace {
uf::stl::vector<uf::stl::string> vfs_list( pod::Mount& mount, const uf::stl::string& dir, const uf::stl::string& extension = "", bool recursive = false ) {
uf::stl::vector<uf::stl::string> files;
uf::stl::string path = mount.path + dir;
#if UF_ENV_DREAMCAST
if ( !path.ends_with("/") ) path += "/";
::ls_kos( path, "", extension, recursive, files );
#else
if ( !std::filesystem::exists(path) ) return files;
if ( recursive ) {
@ -84,6 +124,7 @@ namespace {
}
}
}
#endif
return files;
}
@ -450,19 +491,20 @@ uf::stl::string uf::vfs::resolveBase( const uf::stl::string& path ) {
return path;
}
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "mdl://./data/models", 100 );
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "scene://./data/scenes", 100 );
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "ent://./data/entities", 100 );
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "tex://./data/textures", 100 );
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "snd://./data/audio", 100 );
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "spv://./data/shaders", 100 );
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "lua://./data/scripts", 100 );
#if UF_USE_DREAMCAST
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "data:///cd/", 50 );
#if UF_ENV_DREAMCAST
#define VFS_BASE "/cd/"
#else
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "data://./data", 50 );
#define VFS_BASE "./data/"
#endif
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "", 0 );
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "mdl://" VFS_BASE "models", 100 );
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "scene://" VFS_BASE "scenes", 100 );
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "ent://" VFS_BASE "entities", 100 );
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "tex://" VFS_BASE "textures", 100 );
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "snd://" VFS_BASE "audio", 100 );
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "spv://" VFS_BASE "shaders", 100 );
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "lua://" VFS_BASE "scripts", 100 );
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "data://" VFS_BASE, 50 );
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "", 0 );
UF_VFS_MOUNT_CPP( uf::vfs::createDiskMount, "sys://", 999 );

View File

@ -83,7 +83,7 @@ void uf::physics::terminate( pod::World& world ) {
}
// Implementation
void uf::physics::substep( pod::World& world, float dt, int32_t substeps ) {
void uf::physics::substep( pod::World& world, float dt, int substeps ) {
float h = dt / substeps;
for ( auto i = 0; i < substeps; ++i ) {
uf::physics::step( world, h );

View File

@ -1,6 +1,5 @@
#include <uf/utils/memory/allocator.h>
#include <uf/utils/memory/pool.h>
#include <iostream>
bool uf::allocator::override = true;
@ -8,7 +7,7 @@ void* uf::allocator::allocate( size_t n ) {
if ( override && uf::memoryPool::global.size() > 0 ) {
return uf::memoryPool::global.alloc( n );
}
return std::malloc( n );
return uf::allocator::malloc_m( n );
}
void uf::allocator::deallocate( void* p, size_t n ) {
@ -17,11 +16,13 @@ void uf::allocator::deallocate( void* p, size_t n ) {
if ( override && uf::memoryPool::global.size() > 0 ) {
uf::memoryPool::global.free( p, n );
}
else std::free( p );
else uf::allocator::free_m( p );
}
void* uf::allocator::malloc_m( size_t n ) {
return std::malloc( n );
void* p = std::malloc( n );
if ( !p ) UF_EXCEPTION("bad alloc");
return p;
}
void uf::allocator::free_m( void* p, size_t n ) {
@ -31,7 +32,6 @@ void uf::allocator::free_m( void* p, size_t n ) {
#if UF_MEMORYPOOL_OVERRIDE_NEW_DELETE
void* operator new( size_t n ) {
void* p = uf::allocator::malloc_m( n );
if ( !p ) throw std::bad_alloc();
return p;
}
@ -41,7 +41,6 @@ void operator delete( void* p ) noexcept {
void* operator new[]( size_t n ) {
void* p = uf::allocator::malloc_m( n );
if ( !p ) throw std::bad_alloc();
return p;
}

View File

@ -4,7 +4,6 @@
#include <uf/utils/userdata/userdata.h>
#include <cstring>
#include <iostream>
#include <sstream>
#include <uf/utils/serialize/serializer.h>
#include <uf/utils/thread/perthread.h>

View File

@ -4,43 +4,82 @@
#include <iomanip>
#include <sstream>
#include <cmath>
#include <iostream>
#include <re.h>
#include <regex>
/*
bool uf::string::match( const uf::stl::string& str, const uf::stl::string& r ) {
std::regex regex(r);
std::smatch match;
return std::regex_search( str, match, regex );
}
*/
bool uf::string::isRegex( const uf::stl::string& str ) {
return str.size() > 2 && str.front() == '/' && str.back() == '/';
}
uf::stl::vector<uf::stl::string> uf::string::match( const uf::stl::string& str, const uf::stl::string& r ) {
bool uf::string::matched( const uf::stl::string& str, const uf::stl::string& r ) {
uf::stl::string pattern = uf::string::isRegex(r) ? r.substr(1, r.length() - 2) : r;
std::regex regex(pattern.c_str());
std::cmatch match;
int match_length;
int match_idx = re_match(pattern.c_str(), str.c_str(), &match_length);
return (match_idx != -1);
}
uf::stl::vector<uf::stl::string> uf::string::match( const uf::stl::string& str, const uf::stl::string& r ) {
uf::stl::vector<uf::stl::string> matches;
uf::stl::string pattern = uf::string::isRegex(r) ? r.substr(1, r.length() - 2) : r;
if ( std::regex_search( str.c_str(), match, regex ) ) {
for ( auto& m : match ) {
matches.emplace_back(m.first, m.length());
re_t regex = re_compile(pattern.c_str());
if ( !regex ) return matches;
const char* cursor = str.c_str();
int match_length = 0;
int match_idx;
while ( (match_idx = re_matchp(regex, cursor, &match_length)) != -1 ) {
matches.emplace_back(cursor + match_idx, match_length);
cursor += match_idx + match_length;
if ( match_length == 0 ) {
if (*cursor == '\0') break;
cursor++;
}
}
return matches;
}
bool uf::string::matched( const uf::stl::string& str, const uf::stl::string& r ) {
uf::stl::string pattern = uf::string::isRegex(r) ? r.substr(1, r.length() - 2) : r;
std::regex regex(pattern.c_str());
std::cmatch match;
uf::stl::string uf::string::replace( const uf::stl::string& string, const uf::stl::string& search, const uf::stl::string& replace, bool regexp ) {
uf::stl::string result;
return std::regex_search( str.c_str(), match, regex );
if ( !regexp ) {
result = string;
if ( search.empty() ) return result;
size_t start_pos = 0;
while ( (start_pos = result.find(search, start_pos)) != uf::stl::string::npos ) {
result.replace(start_pos, search.length(), replace);
start_pos += replace.length();
}
return result;
}
uf::stl::string pattern = search.substr(1, search.length() - 2);
re_t regex = re_compile(pattern.c_str());
if ( !regex ) return string;
const char* cursor = string.c_str();
int match_length = 0;
int match_idx = 0;
while ( (match_idx = re_matchp(regex, cursor, &match_length)) != -1 ) {
result.append(cursor, match_idx);
result.append(replace);
cursor += match_idx + match_length;
if ( match_length == 0 ) {
if (*cursor == '\0') break;
result.push_back(*cursor);
cursor++;
}
}
result.append(cursor);
return result;
}
uf::stl::string uf::string::lowercase( const uf::stl::string& str ) {
@ -114,23 +153,7 @@ uf::stl::string uf::string::trim( const uf::stl::string& str ) {
uf::stl::string uf::string::replace( const uf::stl::string& string, const uf::stl::string& search, const uf::stl::string& replace ) {
return uf::string::replace( string, search, replace, uf::string::isRegex( search ) );
}
uf::stl::string uf::string::replace( const uf::stl::string& string, const uf::stl::string& search, const uf::stl::string& replace, bool regexp ) {
uf::stl::string result = string;
if ( regexp ) {
std::regex regex(search.substr(1,search.length()-2));
return std::regex_replace( string, regex, replace );
}
if ( search.empty() ) return result;
size_t start_pos = 0;
while ( (start_pos = result.find(search, start_pos)) != uf::stl::string::npos ) {
result.replace(start_pos, search.length(), replace);
start_pos += replace.length();
}
return result;
}
bool uf::string::contains( const uf::stl::string& string, const uf::stl::string& search ) {
return string.find(search) != uf::stl::string::npos;
}

View File

@ -1,7 +1,6 @@
/*
#include <uf/utils/string/rle.h>
#include <iostream>
pod::RLE::string_t uf::rle::encode( const uf::stl::vector<uint16_t>& source ) {
pod::RLE::string_t destination;
destination.reserve( source.size() );

View File

@ -1,9 +1,10 @@
#if UF_USE_DEPRECATED_STRING
uf::stl::string uf::locale::current;
#include <uf/utils/string/string.h>
#include <uf/utils/string/encoding.h>
uf::stl::string uf::locale::current;
#if UF_USE_DEPRECATED_STRING
uf::String::String() {
}
// ANSI literals/strings

View File

@ -1,5 +1,4 @@
#include <uf/utils/text/glyph.h>
#include <iostream>
#if UF_USE_FREETYPE

View File

@ -1,6 +1,5 @@
#include <uf/utils/thread/thread.h>
#include <uf/utils/io/iostream.h>
#include <iostream>
#include <future>
uf::thread::container_t uf::thread::threads;

View File

@ -2,7 +2,6 @@
#include <uf/utils/string/base64.h> // base64
#include <cstdlib> // malloc, free
#include <cstring> // memcpy
#include <iostream>
// Constructs a pod::PointeredUserdata struct
pod::PointeredUserdata uf::pointeredUserdata::create( size_t len, const void* data, UF_USERDATA_CTTI_TYPE type ) {

View File

@ -2,7 +2,6 @@
#include <uf/utils/string/base64.h> // base64
#include <cstdlib> // malloc, free
#include <cstring> // memcpy
#include <iostream>
uf::MemoryPool uf::userdata::memoryPool;
bool uf::userdata::autoDestruct = true;

View File

@ -1,7 +1,9 @@
ifneq (,$(findstring ffx:sdk,$(REQ_DEPS)))
ifneq (,$(findstring vulkan,$(REQ_DEPS)))
FLAGS += -DUF_USE_FFX_SDK=3
DEPS := -lffx_fsr3_x64 -lffx_fsr2_x64 -lffx_fsr3upscaler_x64 -lffx_frameinterpolation_x64 -lffx_opticalflow_x64 -lffx_backend_vk_x64 -lamd_fidelityfx_vk $(DEPS)
ifneq (,$(findstring gcc,$(REQ_DEPS)))
FLAGS += -DUF_USE_FFX_SDK=3
DEPS := -lffx_fsr3_x64 -lffx_fsr2_x64 -lffx_fsr3upscaler_x64 -lffx_frameinterpolation_x64 -lffx_opticalflow_x64 -lffx_backend_vk_x64 -lamd_fidelityfx_vk $(DEPS)
endif
endif
endif

View File

@ -1,11 +1,12 @@
ARCH = dreamcast
CDIR =
CC = gcc
COMPILER = gcc
CC = $(KOS_CC)
CXX = $(KOS_CCPLUS)
RENDERER = opengl
OPTIMIZATIONS = -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -fstrict-aliasing -ffast-math -fno-unroll-all-loops -fno-optimize-sibling-calls -fschedule-insns2 -fomit-frame-pointer -DUF_NO_EXCEPTIONS -fno-exceptions -g # -flto
OPTIMIZATIONS = -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -fstrict-aliasing -ffast-math -fno-unroll-all-loops -fno-optimize-sibling-calls -fschedule-insns2 -fomit-frame-pointer -DUF_NO_EXCEPTIONS -fno-exceptions -g -flto=auto -ffat-lto-objects
WARNINGS = -Wall -Wno-unknown-pragmas -Wno-unused-function -Wno-unused-variable -Wno-switch -Wno-reorder -Wno-sign-compare -Wno-unused-but-set-variable -Wno-ignored-attributes -Wno-narrowing -Wno-misleading-indentation -Wno-attributes -Wno-conversion-null
FLAGS += $(KOS_CPPFLAGS) -m4-single -std=c++2b $(OPTIMIZATIONS) $(WARNINGS) -fdiagnostics-color=always
FLAGS += $(KOS_CPPFLAGS) -m4-single -std=c++2b $(OPTIMIZATIONS) $(WARNINGS) -fdiagnostics-color=always
TARGET_EXTENSION = .elf

View File

@ -1,5 +1,5 @@
FLAGS += -DUF_ENV_DREAMCAST
REQ_DEPS += opengl gldc json:nlohmann zlib lz4 lua simd ctti fmt freetype openal aldc ogg wav png
REQ_DEPS += opengl gldc json:nlohmann zlib lz4 lua simd ctti fmt freetype openal aldc ogg wav png # to-do: gut freetype to gut libpng
INCS := -I./dep/dreamcast/include $(INCS)
@ -31,8 +31,11 @@ endif
DEPS += -lkallisti -lc -lm -lgcc -lstdc++
SRCS_DLL = $(shell find $(ENGINE_SRC_DIR) -name "*.cpp") $(shell find $(DEP_SRC_DIR) -name "*.cpp")
OBJS_DLL = $(patsubst %.cpp,%.$(PREFIX).o,$(SRCS_DLL))
OBJS = $(patsubst %.cpp,%.$(PREFIX).o,$(SRCS_DLL)) $(patsubst %.cpp,%.$(PREFIX).o,$(SRCS_EXT_DLL)) $(patsubst %.cpp,%.$(PREFIX).o,$(SRCS))
SRCS_DLL_C = $(shell find $(ENGINE_SRC_DIR) -name "*.c") $(shell find $(DEP_SRC_DIR) -name "*.c")
OBJS_DLL = $(patsubst %.cpp,%.$(PREFIX).o,$(SRCS_DLL)) $(patsubst %.c,%.$(PREFIX).o,$(SRCS_DLL_C))
OBJS = $(patsubst %.cpp,%.$(PREFIX).o,$(SRCS_DLL)) $(patsubst %.c,%.$(PREFIX).o,$(SRCS_DLL_C)) $(patsubst %.cpp,%.$(PREFIX).o,$(SRCS_EXT_DLL)) $(patsubst %.cpp,%.$(PREFIX).o,$(SRCS))
KOS_AR = /opt/dreamcast/sh-elf/bin/sh-elf-gcc-ar
KOS_RANLIB = /opt/dreamcast/sh-elf/bin/sh-elf-gcc-ranlib
$(PREFIX): $(TARGET) ./bin/dreamcast/$(TARGET_NAME).cdi
@ -55,7 +58,7 @@ $(EXT_EX_DLL): $(OBJS_EXT_DLL)
$(KOS_BASE)/utils/bin2o/bin2o ./bin/dreamcast/romdisk.img romdisk ./bin/dreamcast/romdisk.o
$(TARGET): $(OBJS) #./bin/dreamcast/romdisk.o
$(CXX) $(FLAGS) $(INCS) -D_arch_dreamcast -D_arch_sub_pristine -Wall -fno-builtin -ml -Wl,-Ttext=0x8c010000 -T/opt/dreamcast/kos/utils/ldscripts/shlelf.xc -nodefaultlibs $(KOS_LIB_PATHS) $(LIBS) -o $(TARGET) $(OBJS) -Wl,--start-group $(DEPS) -Wl,--end-group
$(CXX) $(FLAGS) $(INCS) -D_arch_dreamcast -D_arch_sub_pristine -Wall -fno-builtin -ml -Wl,-Ttext=0x8c010000 -T/opt/dreamcast/kos/utils/ldscripts/shlelf.xc -nostartfiles -nodefaultlibs $(KOS_LIB_PATHS) $(LIBS) -o $(TARGET) $(OBJS) $(KOS_KOS_INIT) -Wl,--start-group $(DEPS) -Wl,--end-group
cp $(TARGET) $(TARGET).unstripped
$(KOS_STRIP) --strip-unneeded $(TARGET)
@ -69,7 +72,7 @@ run-dreamcast:
$(KOS_EMU) ./bin/dreamcast/$(TARGET_NAME).cdi
run-debug-dreamcast:
$(KOS_EMU_DEBUG) ./bin/dreamcast/$(TARGET_NAME).cdi
$(KOS_EMU_DEBUG) ./bin/dreamcast/$(TARGET_NAME).cdi $(TARGET).unstripped
clean-dreamcast:
@-rm ./bin/dreamcast/build/*

View File

@ -1,6 +1,7 @@
ARCH = linux
CDIR =
CC = clang
COMPILER = $(CC)
CXX = clang++
OPTIMIZATIONS = -O3 -fstrict-aliasing -DUF_NO_EXCEPTIONS # -flto # -march=native
WARNINGS = -Wall -Wno-pointer-arith -Wno-unused-function -Wno-unused-variable -Wno-switch -Wno-reorder-ctor -Wno-ignored-attributes -Wno-c++11-narrowing -Wno-unknown-pragmas -Wno-nullability-completeness -Wno-defaulted-function-deleted -Wno-mismatched-tags

View File

@ -1,6 +1,7 @@
ARCH = linux
CDIR =
CC = gcc
COMPILER = $(CC)
CXX = g++
OPTIMIZATIONS = -O3 -fstrict-aliasing -DUF_NO_EXCEPTIONS
WARNINGS = -Wall -Wno-attributes -Wno-dangling-reference -Wno-unknown-pragmas -Wno-unused-function -Wno-unused-variable -Wno-switch -Wno-reorder -Wno-sign-compare -Wno-unused-but-set-variable -Wno-ignored-attributes -Wno-narrowing -Wno-misleading-indentation

View File

@ -1,5 +1,5 @@
ifneq (,$(findstring -DUF_DEV_ENV,$(FLAGS)))
REQ_DEPS += toml xatlas curl dc:texconv # meshoptimizer ffx:fsr cpptrace vall_e # ncurses openvr draco discord bullet ultralight-ux
REQ_DEPS += toml xatlas curl dc:texconv valve lgs # meshoptimizer ffx:fsr cpptrace vall_e # ncurses openvr draco discord bullet ultralight-ux
FLAGS += -march=native -g # -flto # -g
endif

View File

@ -1,14 +1,15 @@
ARCH = win64
CDIR =
CC = clang
COMPILER = $(CC)
CXX = clang++
OPTIMIZATIONS = -O3 -fstrict-aliasing -DUF_NO_EXCEPTIONS # -flto # -march=native
WARNINGS = -Wall -Wno-missing-braces -Wno-deprecated-literal-operator -Wno-pointer-arith -Wno-unused-function -Wno-unused-variable -Wno-switch -Wno-reorder-ctor -Wno-ignored-attributes -Wno-c++11-narrowing -Wno-unknown-pragmas -Wno-nullability-completeness -Wno-defaulted-function-deleted -Wno-mismatched-tags
SANITIZE = -fsanitize=address,undefined # -fuse-ld=lld -fno-omit-frame-pointer
SANITIZE = -fuse-ld=lld # -fsanitize=address,undefined # -fuse-ld=lld -fno-omit-frame-pointer
FLAGS += -std=c++2b $(OPTIMIZATIONS) $(WARNINGS) $(SANITIZE) -fcolor-diagnostics -fansi-escape-codes
# MSYS2
INCS += -I/clang64/include/
INCS += -I/clang64/include/
LIBS += -L/clang64/lib/ -L/mingw64/lib/
TARGET_EXTENSION = .exe

View File

@ -1,8 +1,9 @@
ARCH = win64
CDIR =
CC = gcc
COMPILER = $(CC)
CXX = g++
OPTIMIZATIONS = -O3 -fstrict-aliasing -DUF_NO_EXCEPTIONS
OPTIMIZATIONS = -O3 -fstrict-aliasing -DUF_NO_EXCEPTIONS -flto
WARNINGS = -Wall -Wno-unknown-pragmas -Wno-unused-function -Wno-unused-variable -Wno-switch -Wno-reorder -Wno-sign-compare -Wno-unused-but-set-variable -Wno-ignored-attributes -Wno-narrowing -Wno-misleading-indentation
FLAGS += -std=c++2b $(OPTIMIZATIONS) $(WARNINGS) -fdiagnostics-color=always