From 22e2f703dbc47bb23452f41edf7001c21ad2cac1 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Wed, 1 Oct 2025 13:20:34 -0500 Subject: [PATCH] Refact --- CMakeLists.txt | 7 +- archive/FindSDL2.cmake | 42 -- archive/Findlibzip.cmake | 86 ---- archive/asset/CMakeLists.txt | 19 - archive/asset/asset.c | 156 ------ archive/asset/asset.h | 118 ----- archive/asset/assetpalette.c | 18 - archive/asset/assetpalette.h | 22 - archive/asset/assetpaletteimage.c | 12 - archive/asset/assetpalleteimage.h | 23 - archive/asset/assettileset.h | 24 - archive/dusk/CMakeLists.txt | 37 -- archive/dusk/assert/assert.c | 85 ---- archive/dusk/assert/assert.h | 143 ------ archive/dusk/display/CMakeLists.txt | 11 - archive/dusk/display/renderbase.c | 8 - archive/dusk/display/renderbase.h | 31 -- archive/dusk/display/scene.c | 51 -- archive/dusk/display/scene.h | 47 -- archive/dusk/dusk.h | 23 - archive/dusk/ecs/CMakeLists.txt | 11 - archive/dusk/ecs/ecscomponent.c | 124 ----- archive/dusk/ecs/ecscomponent.h | 111 ---- archive/dusk/ecs/ecsentity.h | 18 - archive/dusk/ecs/ecssystem.c | 66 --- archive/dusk/ecs/ecssystem.h | 50 -- archive/dusk/entity/CMakeLists.txt | 13 - archive/dusk/entity/direction.c | 53 -- archive/dusk/entity/direction.h | 41 -- archive/dusk/entity/entity.c | 131 ----- archive/dusk/entity/entity.h | 99 ---- archive/dusk/entity/npc.c | 45 -- archive/dusk/entity/npc.h | 44 -- archive/dusk/entity/player.c | 94 ---- archive/dusk/entity/player.h | 43 -- archive/dusk/error/error.c | 125 ----- archive/dusk/error/error.h | 137 ----- archive/dusk/event/CMakeLists.txt | 11 - archive/dusk/event/event.c | 73 --- archive/dusk/event/event.h | 46 -- archive/dusk/event/eventdata.h | 14 - archive/dusk/event/eventitem.h | 26 - archive/dusk/event/eventtext.c | 26 - archive/dusk/event/eventtext.h | 36 -- archive/dusk/game.c | 57 --- archive/dusk/game.h | 49 -- archive/dusk/input.c | 39 -- archive/dusk/input.h | 80 --- archive/dusk/item/inventory.c | 68 --- archive/dusk/item/inventory.h | 63 --- archive/dusk/item/itemstack.h | 14 - archive/dusk/item/itemtype.h | 24 - archive/dusk/locale/CMakeLists.txt | 10 - archive/dusk/locale/language.c | 145 ------ archive/dusk/locale/language.h | 65 --- archive/dusk/time.c | 37 -- archive/dusk/time.h | 52 -- archive/dusk/ui/CMakeLists.txt | 10 - archive/dusk/ui/font.h | 9 - archive/dusk/ui/uitextbox.c | 191 ------- archive/dusk/ui/uitextbox.h | 77 --- archive/dusk/util/CMakeLists.txt | 12 - archive/dusk/util/math.c | 19 - archive/dusk/util/math.h | 17 - archive/dusk/util/memory.c | 96 ---- archive/dusk/util/memory.h | 107 ---- archive/dusk/util/string.c | 128 ----- archive/dusk/util/string.h | 118 ----- archive/dusk/world/chunk.c | 321 ------------ archive/dusk/world/chunk.h | 84 --- archive/dusk/world/chunkdata.h | 16 - archive/dusk/world/overworld.c | 72 --- archive/dusk/world/overworld.h | 30 -- archive/dusk/world/tile.h | 26 - archive/duskpsp/CMakeLists.txt | 40 -- archive/duskpsp/duskpsp.c | 11 - archive/duskpsp/duskpsp.h | 13 - archive/dusksdl2/CMakeLists.txt | 41 -- archive/dusksdl2/display/CMakeLists.txt | 21 - .../dusksdl2/display/camera/CMakeLists.txt | 10 - archive/dusksdl2/display/camera/camera.c | 125 ----- archive/dusksdl2/display/camera/camera.h | 39 -- .../display/framebuffer/CMakeLists.txt | 10 - .../display/framebuffer/framebuffer.c | 59 --- .../display/framebuffer/framebuffer.h | 45 -- archive/dusksdl2/display/mesh/CMakeLists.txt | 12 - archive/dusksdl2/display/mesh/mesh.c | 82 --- archive/dusksdl2/display/mesh/mesh.h | 58 --- archive/dusksdl2/display/mesh/quad.c | 62 --- archive/dusksdl2/display/mesh/quad.h | 44 -- .../dusksdl2/display/overworld/CMakeLists.txt | 10 - .../display/overworld/renderoverworld.c | 125 ----- .../display/overworld/renderoverworld.h | 39 -- archive/dusksdl2/display/render.c | 119 ----- archive/dusksdl2/display/render.h | 27 - archive/dusksdl2/display/renderbackbuffer.c | 93 ---- archive/dusksdl2/display/renderbackbuffer.h | 42 -- archive/dusksdl2/display/scene/CMakeLists.txt | 13 - archive/dusksdl2/display/scene/renderscene.c | 42 -- archive/dusksdl2/display/scene/renderscene.h | 32 -- .../display/spritebatch/CMakeLists.txt | 13 - .../display/spritebatch/spritebatch.c | 75 --- .../display/spritebatch/spritebatch.h | 52 -- .../dusksdl2/display/texture/CMakeLists.txt | 13 - archive/dusksdl2/display/texture/texture.c | 78 --- archive/dusksdl2/display/texture/texture.h | 46 -- archive/dusksdl2/display/ui/CMakeLists.txt | 14 - archive/dusksdl2/display/ui/renderconsole.c | 29 -- archive/dusksdl2/display/ui/renderconsole.h | 14 - archive/dusksdl2/display/ui/renderfps.c | 46 -- archive/dusksdl2/display/ui/renderfps.h | 13 - archive/dusksdl2/display/ui/rendertext.c | 159 ------ archive/dusksdl2/display/ui/rendertext.h | 74 --- archive/dusksdl2/display/ui/rendertextbox.c | 70 --- archive/dusksdl2/display/ui/rendertextbox.h | 10 - archive/dusksdl2/display/ui/renderui.c | 63 --- archive/dusksdl2/display/ui/renderui.h | 32 -- archive/dusksdl2/dusksdl2.h | 16 - archive/dusksdl2/dusksdl2input.c | 44 -- archive/dusksdl2/dusksdl2input.h | 63 --- archive/dusksdl2/main.c | 35 -- archive/dusksdl2/time.c | 19 - archive/tool2/processimage.py | 120 ----- archive/tool2/processtileset.py | 84 --- archive/tools/eventcompile/CMakeLists.txt | 20 - archive/tools/eventcompile/eventcompile.py | 103 ---- archive/tools/fontcompile/CMakeLists.txt | 20 - archive/tools/fontcompile/fontcompile.py | 153 ------ archive/tools/languagecompile/CMakeLists.txt | 20 - .../tools/languagecompile/languagecompile.py | 147 ------ archive/tools/mapcompile/CMakeLists.txt | 21 - archive/tools/mapcompile/chunkParser.py | 127 ----- archive/tools/mapcompile/constants.py | 6 - archive/tools/mapcompile/entityParser.py | 64 --- archive/tools/mapcompile/inputParser.py | 32 -- archive/tools/mapcompile/mapParser.py | 159 ------ archive/tools/mapcompile/mapcompile.py | 146 ------ archive/tools/tilecompile/CMakeLists.txt | 20 - archive/tools/tilecompile/tilecompile.py | 109 ---- assets/CMakeLists.txt | 13 +- assets/minesweeper/CMakeLists.txt | 10 + .../{ => minesweeper}/config/CMakeLists.txt | 0 assets/{ => minesweeper}/config/init.dcf | 0 assets/{ => minesweeper}/config/init_psp.dcf | 0 .../{ => minesweeper}/palette/CMakeLists.txt | 0 assets/{ => minesweeper}/palette/palette0.png | Bin assets/{ => minesweeper}/palette/palette0.pxo | Bin assets/{ => minesweeper}/ui/CMakeLists.txt | 0 assets/{ => minesweeper}/ui/minogram.png | Bin assets/rpg/CMakeLists.txt | 13 + .../rpg/config}/CMakeLists.txt | 7 +- assets/rpg/config/init.dcf | 17 + assets/rpg/config/init_psp.dcf | 17 + assets/{ => rpg}/entity/CMakeLists.txt | 0 assets/{ => rpg}/entity/entities.png | Bin assets/{ => rpg}/entity/entities.tsx | 0 assets/{ => rpg}/map/CMakeLists.txt | 0 assets/{ => rpg}/map/untitled.tmx | 0 .../rpg/palette}/CMakeLists.txt | 6 +- assets/rpg/palette/palette0.png | Bin 0 -> 241 bytes assets/rpg/palette/palette0.pxo | Bin 0 -> 1576 bytes assets/{ => rpg}/tileset/prarie.png | Bin assets/{ => rpg}/tileset/prarie.pxo | Bin assets/{ => rpg}/tileset/prarie.tsx | 0 .../world => assets/rpg/ui}/CMakeLists.txt | 7 +- assets/rpg/ui/minogram.png | Bin 0 -> 1260 bytes assets/{ => rpg}/untitled.tiled-project | 0 assets/{ => rpg}/untitled.tiled-session | 0 data/entities.png | Bin 336 -> 0 bytes data/entities.pxo | Bin 974 -> 0 bytes data/entities.tsx | 4 - data/events/test_event.json | 13 - data/languages/en.json | 13 - data/map project.tiled-project | 42 -- data/map project.tiled-session | 74 --- data/map.tmj | 477 ------------------ data/minogram.tsx | 4 - data/minogram_6x10.png | Bin 1128 -> 0 bytes data/overworld.tsx | 21 - data/templates/NPC.tx | 10 - data/tilemap.png | Bin 9781 -> 0 bytes data/tilemap.pxo | Bin 8703 -> 0 bytes src/CMakeLists.txt | 3 +- src/asset/asset.c | 3 - src/asset/asset.h | 3 - src/asset/type/CMakeLists.txt | 1 - src/asset/type/assetrpgmap.c | 98 ---- src/asset/type/assetrpgmap.h | 64 --- src/display/framebuffer/framebuffer.c | 4 +- src/display/scene/CMakeLists.txt | 4 +- src/display/scene/scene.h | 12 +- src/display/scene/scenemanager.c | 65 ++- src/display/scene/scenemanager.h | 2 +- src/display/ui/ui.c | 16 +- src/display/ui/ui.h | 7 + src/display/ui/uiconsole.c | 7 +- src/display/ui/uifps.c | 7 +- src/display/ui/uitext.c | 52 +- src/display/ui/uitext.h | 33 +- src/engine/engine.c | 9 +- src/game/CMakeLists.txt | 18 + src/game/game.h | 16 + src/game/gamescene.h | 16 + .../game/minesweeper}/CMakeLists.txt | 6 +- .../game/minesweeper/game.c | 14 +- src/game/minesweeper/game.h | 24 + .../ecs/ecs.h => src/game/minesweeper/scene.h | 2 +- src/{ => game}/rpg/CMakeLists.txt | 0 src/{ => game}/rpg/entity/CMakeLists.txt | 0 src/{ => game}/rpg/entity/direction.c | 0 src/{ => game}/rpg/entity/direction.h | 0 src/{ => game}/rpg/entity/entity.c | 0 src/{ => game}/rpg/entity/entity.h | 0 src/{ => game}/rpg/entity/npc.c | 0 src/{ => game}/rpg/entity/npc.h | 0 src/{ => game}/rpg/entity/player.c | 0 src/{ => game}/rpg/entity/player.h | 0 .../rpg}/overworld/CMakeLists.txt | 0 .../rpg}/overworld/sceneoverworld.c | 0 .../rpg}/overworld/sceneoverworld.h | 0 src/{ => game}/rpg/rpg.c | 0 src/{ => game}/rpg/rpg.h | 0 .../scene => game/rpg}/test/CMakeLists.txt | 0 .../scene => game/rpg}/test/scenetest.c | 0 .../scene => game/rpg}/test/scenetest.h | 0 src/{ => game}/rpg/world/CMakeLists.txt | 0 src/{ => game}/rpg/world/map.c | 0 src/{ => game}/rpg/world/map.h | 0 src/{ => game}/rpg/world/tile.h | 0 229 files changed, 272 insertions(+), 8941 deletions(-) delete mode 100644 archive/FindSDL2.cmake delete mode 100644 archive/Findlibzip.cmake delete mode 100644 archive/asset/CMakeLists.txt delete mode 100644 archive/asset/asset.c delete mode 100644 archive/asset/asset.h delete mode 100644 archive/asset/assetpalette.c delete mode 100644 archive/asset/assetpalette.h delete mode 100644 archive/asset/assetpaletteimage.c delete mode 100644 archive/asset/assetpalleteimage.h delete mode 100644 archive/asset/assettileset.h delete mode 100644 archive/dusk/CMakeLists.txt delete mode 100644 archive/dusk/assert/assert.c delete mode 100644 archive/dusk/assert/assert.h delete mode 100644 archive/dusk/display/CMakeLists.txt delete mode 100644 archive/dusk/display/renderbase.c delete mode 100644 archive/dusk/display/renderbase.h delete mode 100644 archive/dusk/display/scene.c delete mode 100644 archive/dusk/display/scene.h delete mode 100644 archive/dusk/dusk.h delete mode 100644 archive/dusk/ecs/CMakeLists.txt delete mode 100644 archive/dusk/ecs/ecscomponent.c delete mode 100644 archive/dusk/ecs/ecscomponent.h delete mode 100644 archive/dusk/ecs/ecsentity.h delete mode 100644 archive/dusk/ecs/ecssystem.c delete mode 100644 archive/dusk/ecs/ecssystem.h delete mode 100644 archive/dusk/entity/CMakeLists.txt delete mode 100644 archive/dusk/entity/direction.c delete mode 100644 archive/dusk/entity/direction.h delete mode 100644 archive/dusk/entity/entity.c delete mode 100644 archive/dusk/entity/entity.h delete mode 100644 archive/dusk/entity/npc.c delete mode 100644 archive/dusk/entity/npc.h delete mode 100644 archive/dusk/entity/player.c delete mode 100644 archive/dusk/entity/player.h delete mode 100644 archive/dusk/error/error.c delete mode 100644 archive/dusk/error/error.h delete mode 100644 archive/dusk/event/CMakeLists.txt delete mode 100644 archive/dusk/event/event.c delete mode 100644 archive/dusk/event/event.h delete mode 100644 archive/dusk/event/eventdata.h delete mode 100644 archive/dusk/event/eventitem.h delete mode 100644 archive/dusk/event/eventtext.c delete mode 100644 archive/dusk/event/eventtext.h delete mode 100644 archive/dusk/game.c delete mode 100644 archive/dusk/game.h delete mode 100644 archive/dusk/input.c delete mode 100644 archive/dusk/input.h delete mode 100644 archive/dusk/item/inventory.c delete mode 100644 archive/dusk/item/inventory.h delete mode 100644 archive/dusk/item/itemstack.h delete mode 100644 archive/dusk/item/itemtype.h delete mode 100644 archive/dusk/locale/CMakeLists.txt delete mode 100644 archive/dusk/locale/language.c delete mode 100644 archive/dusk/locale/language.h delete mode 100644 archive/dusk/time.c delete mode 100644 archive/dusk/time.h delete mode 100644 archive/dusk/ui/CMakeLists.txt delete mode 100644 archive/dusk/ui/font.h delete mode 100644 archive/dusk/ui/uitextbox.c delete mode 100644 archive/dusk/ui/uitextbox.h delete mode 100644 archive/dusk/util/CMakeLists.txt delete mode 100644 archive/dusk/util/math.c delete mode 100644 archive/dusk/util/math.h delete mode 100644 archive/dusk/util/memory.c delete mode 100644 archive/dusk/util/memory.h delete mode 100644 archive/dusk/util/string.c delete mode 100644 archive/dusk/util/string.h delete mode 100644 archive/dusk/world/chunk.c delete mode 100644 archive/dusk/world/chunk.h delete mode 100644 archive/dusk/world/chunkdata.h delete mode 100644 archive/dusk/world/overworld.c delete mode 100644 archive/dusk/world/overworld.h delete mode 100644 archive/dusk/world/tile.h delete mode 100644 archive/duskpsp/CMakeLists.txt delete mode 100644 archive/duskpsp/duskpsp.c delete mode 100644 archive/duskpsp/duskpsp.h delete mode 100644 archive/dusksdl2/CMakeLists.txt delete mode 100644 archive/dusksdl2/display/CMakeLists.txt delete mode 100644 archive/dusksdl2/display/camera/CMakeLists.txt delete mode 100644 archive/dusksdl2/display/camera/camera.c delete mode 100644 archive/dusksdl2/display/camera/camera.h delete mode 100644 archive/dusksdl2/display/framebuffer/CMakeLists.txt delete mode 100644 archive/dusksdl2/display/framebuffer/framebuffer.c delete mode 100644 archive/dusksdl2/display/framebuffer/framebuffer.h delete mode 100644 archive/dusksdl2/display/mesh/CMakeLists.txt delete mode 100644 archive/dusksdl2/display/mesh/mesh.c delete mode 100644 archive/dusksdl2/display/mesh/mesh.h delete mode 100644 archive/dusksdl2/display/mesh/quad.c delete mode 100644 archive/dusksdl2/display/mesh/quad.h delete mode 100644 archive/dusksdl2/display/overworld/CMakeLists.txt delete mode 100644 archive/dusksdl2/display/overworld/renderoverworld.c delete mode 100644 archive/dusksdl2/display/overworld/renderoverworld.h delete mode 100644 archive/dusksdl2/display/render.c delete mode 100644 archive/dusksdl2/display/render.h delete mode 100644 archive/dusksdl2/display/renderbackbuffer.c delete mode 100644 archive/dusksdl2/display/renderbackbuffer.h delete mode 100644 archive/dusksdl2/display/scene/CMakeLists.txt delete mode 100644 archive/dusksdl2/display/scene/renderscene.c delete mode 100644 archive/dusksdl2/display/scene/renderscene.h delete mode 100644 archive/dusksdl2/display/spritebatch/CMakeLists.txt delete mode 100644 archive/dusksdl2/display/spritebatch/spritebatch.c delete mode 100644 archive/dusksdl2/display/spritebatch/spritebatch.h delete mode 100644 archive/dusksdl2/display/texture/CMakeLists.txt delete mode 100644 archive/dusksdl2/display/texture/texture.c delete mode 100644 archive/dusksdl2/display/texture/texture.h delete mode 100644 archive/dusksdl2/display/ui/CMakeLists.txt delete mode 100644 archive/dusksdl2/display/ui/renderconsole.c delete mode 100644 archive/dusksdl2/display/ui/renderconsole.h delete mode 100644 archive/dusksdl2/display/ui/renderfps.c delete mode 100644 archive/dusksdl2/display/ui/renderfps.h delete mode 100644 archive/dusksdl2/display/ui/rendertext.c delete mode 100644 archive/dusksdl2/display/ui/rendertext.h delete mode 100644 archive/dusksdl2/display/ui/rendertextbox.c delete mode 100644 archive/dusksdl2/display/ui/rendertextbox.h delete mode 100644 archive/dusksdl2/display/ui/renderui.c delete mode 100644 archive/dusksdl2/display/ui/renderui.h delete mode 100644 archive/dusksdl2/dusksdl2.h delete mode 100644 archive/dusksdl2/dusksdl2input.c delete mode 100644 archive/dusksdl2/dusksdl2input.h delete mode 100644 archive/dusksdl2/main.c delete mode 100644 archive/dusksdl2/time.c delete mode 100644 archive/tool2/processimage.py delete mode 100644 archive/tool2/processtileset.py delete mode 100644 archive/tools/eventcompile/CMakeLists.txt delete mode 100644 archive/tools/eventcompile/eventcompile.py delete mode 100644 archive/tools/fontcompile/CMakeLists.txt delete mode 100644 archive/tools/fontcompile/fontcompile.py delete mode 100644 archive/tools/languagecompile/CMakeLists.txt delete mode 100644 archive/tools/languagecompile/languagecompile.py delete mode 100644 archive/tools/mapcompile/CMakeLists.txt delete mode 100644 archive/tools/mapcompile/chunkParser.py delete mode 100644 archive/tools/mapcompile/constants.py delete mode 100644 archive/tools/mapcompile/entityParser.py delete mode 100644 archive/tools/mapcompile/inputParser.py delete mode 100644 archive/tools/mapcompile/mapParser.py delete mode 100644 archive/tools/mapcompile/mapcompile.py delete mode 100644 archive/tools/tilecompile/CMakeLists.txt delete mode 100644 archive/tools/tilecompile/tilecompile.py create mode 100644 assets/minesweeper/CMakeLists.txt rename assets/{ => minesweeper}/config/CMakeLists.txt (100%) rename assets/{ => minesweeper}/config/init.dcf (100%) rename assets/{ => minesweeper}/config/init_psp.dcf (100%) rename assets/{ => minesweeper}/palette/CMakeLists.txt (100%) rename assets/{ => minesweeper}/palette/palette0.png (100%) rename assets/{ => minesweeper}/palette/palette0.pxo (100%) rename assets/{ => minesweeper}/ui/CMakeLists.txt (100%) rename assets/{ => minesweeper}/ui/minogram.png (100%) create mode 100644 assets/rpg/CMakeLists.txt rename {archive/dusk/error => assets/rpg/config}/CMakeLists.txt (65%) create mode 100644 assets/rpg/config/init.dcf create mode 100644 assets/rpg/config/init_psp.dcf rename assets/{ => rpg}/entity/CMakeLists.txt (100%) rename assets/{ => rpg}/entity/entities.png (100%) rename assets/{ => rpg}/entity/entities.tsx (100%) rename assets/{ => rpg}/map/CMakeLists.txt (100%) rename assets/{ => rpg}/map/untitled.tmx (100%) rename {archive/dusk/item => assets/rpg/palette}/CMakeLists.txt (64%) create mode 100644 assets/rpg/palette/palette0.png create mode 100644 assets/rpg/palette/palette0.pxo rename assets/{ => rpg}/tileset/prarie.png (100%) rename assets/{ => rpg}/tileset/prarie.pxo (100%) rename assets/{ => rpg}/tileset/prarie.tsx (100%) rename {archive/dusk/world => assets/rpg/ui}/CMakeLists.txt (60%) create mode 100644 assets/rpg/ui/minogram.png rename assets/{ => rpg}/untitled.tiled-project (100%) rename assets/{ => rpg}/untitled.tiled-session (100%) delete mode 100644 data/entities.png delete mode 100644 data/entities.pxo delete mode 100644 data/entities.tsx delete mode 100644 data/events/test_event.json delete mode 100644 data/languages/en.json delete mode 100644 data/map project.tiled-project delete mode 100644 data/map project.tiled-session delete mode 100644 data/map.tmj delete mode 100644 data/minogram.tsx delete mode 100644 data/minogram_6x10.png delete mode 100644 data/overworld.tsx delete mode 100644 data/templates/NPC.tx delete mode 100644 data/tilemap.png delete mode 100644 data/tilemap.pxo delete mode 100644 src/asset/type/assetrpgmap.c delete mode 100644 src/asset/type/assetrpgmap.h create mode 100644 src/game/CMakeLists.txt create mode 100644 src/game/game.h create mode 100644 src/game/gamescene.h rename {archive/dusk/assert => src/game/minesweeper}/CMakeLists.txt (88%) rename archive/asset/assettileset.c => src/game/minesweeper/game.c (54%) create mode 100644 src/game/minesweeper/game.h rename archive/dusk/ecs/ecs.h => src/game/minesweeper/scene.h (85%) rename src/{ => game}/rpg/CMakeLists.txt (100%) rename src/{ => game}/rpg/entity/CMakeLists.txt (100%) rename src/{ => game}/rpg/entity/direction.c (100%) rename src/{ => game}/rpg/entity/direction.h (100%) rename src/{ => game}/rpg/entity/entity.c (100%) rename src/{ => game}/rpg/entity/entity.h (100%) rename src/{ => game}/rpg/entity/npc.c (100%) rename src/{ => game}/rpg/entity/npc.h (100%) rename src/{ => game}/rpg/entity/player.c (100%) rename src/{ => game}/rpg/entity/player.h (100%) rename src/{display/scene => game/rpg}/overworld/CMakeLists.txt (100%) rename src/{display/scene => game/rpg}/overworld/sceneoverworld.c (100%) rename src/{display/scene => game/rpg}/overworld/sceneoverworld.h (100%) rename src/{ => game}/rpg/rpg.c (100%) rename src/{ => game}/rpg/rpg.h (100%) rename src/{display/scene => game/rpg}/test/CMakeLists.txt (100%) rename src/{display/scene => game/rpg}/test/scenetest.c (100%) rename src/{display/scene => game/rpg}/test/scenetest.h (100%) rename src/{ => game}/rpg/world/CMakeLists.txt (100%) rename src/{ => game}/rpg/world/map.c (100%) rename src/{ => game}/rpg/world/map.h (100%) rename src/{ => game}/rpg/world/tile.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c0c9fdc..53562f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,11 @@ if(NOT DEFINED DUSK_TARGET_SYSTEM) # set(DUSK_TARGET_SYSTEM "psp") endif() +if(NOT DEFINED DUSK_TARGET_GAME) + set(DUSK_TARGET_GAME "minesweeper") + # set(DUSK_TARGET_GAME "rpg") +endif() + # Prep cache set(DUSK_CACHE_TARGET "dusk-target") @@ -98,7 +103,7 @@ target_include_directories(${DUSK_TARGET_NAME} PUBLIC add_custom_target(DUSK_ASSETS_BUILT ALL COMMAND ${Python3_EXECUTABLE} ${DUSK_TOOLS_DIR}/assetstool/main.py - --assets ${DUSK_ASSETS_DIR} + --assets ${DUSK_GAME_ASSETS_DIR} --build-type wad --output-assets ${DUSK_BUILT_ASSETS_DIR} --output-file ${DUSK_BUILD_DIR}/dusk.dsk diff --git a/archive/FindSDL2.cmake b/archive/FindSDL2.cmake deleted file mode 100644 index 042742e..0000000 --- a/archive/FindSDL2.cmake +++ /dev/null @@ -1,42 +0,0 @@ -# Try to find SDL2 in common locations -find_path(SDL2_INCLUDE_DIR SDL.h - PATHS - /usr/include/SDL2 - /usr/local/include/SDL2 - $ENV{SDL2_DIR}/include - PATH_SUFFIXES SDL2 -) - -find_library(SDL2_LIBRARY - NAMES SDL2 - PATHS - /usr/lib - /usr/local/lib - $ENV{SDL2_DIR}/lib -) - -if(SDL2_INCLUDE_DIR AND SDL2_LIBRARY) - set(SDL2_FOUND TRUE) - set(SDL2_LIBRARIES ${SDL2_LIBRARY}) - set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR}) -endif() - -# If not found, use FetchContent to acquire SDL2 -if(NOT SDL2_FOUND) - include(FetchContent) - FetchContent_Declare( - SDL2 - GIT_REPOSITORY https://github.com/libsdl-org/SDL.git - GIT_TAG release-2.28.5 # Change to desired version - ) - FetchContent_MakeAvailable(SDL2) - set(SDL2_FOUND TRUE) - set(SDL2_LIBRARIES SDL2) - set(SDL2_INCLUDE_DIRS ${sdl2_SOURCE_DIR}/include) -endif() - -# Provide variables for downstream usage -if(SDL2_FOUND) - set(SDL2_INCLUDE_DIR ${SDL2_INCLUDE_DIRS} CACHE PATH "SDL2 include directory") - set(SDL2_LIBRARY ${SDL2_LIBRARIES} CACHE FILEPATH "SDL2 library") -endif() diff --git a/archive/Findlibzip.cmake b/archive/Findlibzip.cmake deleted file mode 100644 index 52c9247..0000000 --- a/archive/Findlibzip.cmake +++ /dev/null @@ -1,86 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -set(LIBZIP_ALLOW_FETCH ON CACHE BOOL "Allow fetching libzip if not found") -set(LIBZIP_FETCH_GIT_REPO "https://github.com/nih-at/libzip.git" CACHE STRING "libzip Git repository") -set(LIBZIP_FETCH_GIT_TAG "v1.11.1" CACHE STRING "libzip Git tag to fetch") -set(LIBZIP_MIN_VERSION "" CACHE STRING "Required minimum libzip version (optional)") - -unset(LIBZIP_FOUND CACHE) -unset(LIBZIP_TARGET CACHE) -unset(LIBZIP_INCLUDE_DIRS CACHE) -unset(LIBZIP_LIBRARIES CACHE) - -set(_find_args CONFIG QUIET) -if(LIBZIP_MIN_VERSION) - list(PREPEND _find_args ${LIBZIP_MIN_VERSION}) -endif() - -find_package(libzip ${_find_args}) - -if(TARGET libzip::zip) - set(LIBZIP_FOUND ON) - set(LIBZIP_TARGET libzip::zip) -elseif(TARGET zip) # some builds expose an un-namespaced "zip" - add_library(libzip::zip ALIAS zip) - set(LIBZIP_FOUND ON) - set(LIBZIP_TARGET libzip::zip) -endif() - -if(NOT LIBZIP_FOUND) - find_package(PkgConfig QUIET) - if(PkgConfig_FOUND) - pkg_check_modules(LIBZIP_PC QUIET libzip) - if(LIBZIP_PC_FOUND) - # Create a consistent imported target matching libzip::zip - add_library(libzip::zip INTERFACE IMPORTED) - set_target_properties(libzip::zip PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${LIBZIP_PC_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${LIBZIP_PC_LINK_LIBRARIES}" - ) - set(LIBZIP_FOUND ON) - set(LIBZIP_TARGET libzip::zip) - set(LIBZIP_INCLUDE_DIRS "${LIBZIP_PC_INCLUDE_DIRS}") - set(LIBZIP_LIBRARIES "${LIBZIP_PC_LINK_LIBRARIES}") - endif() - endif() -endif() - -# ---- 3) FetchContent as a last resort --------------------------------------- -if(NOT LIBZIP_FOUND AND LIBZIP_ALLOW_FETCH) - include(FetchContent) - - set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) - set(LIBZIP_DO_INSTALL OFF CACHE BOOL "" FORCE) - set(ENABLE_BZIP2 OFF CACHE BOOL "" FORCE) - set(ENABLE_LZMA OFF CACHE BOOL "" FORCE) - set(ENABLE_ZSTD OFF CACHE BOOL "" FORCE) - - FetchContent_Declare( - libzip_fetch - GIT_REPOSITORY "${LIBZIP_FETCH_GIT_REPO}" - GIT_TAG "${LIBZIP_FETCH_GIT_TAG}" - ) - FetchContent_MakeAvailable(libzip_fetch) - - if(NOT TARGET libzip::zip) - if(TARGET zip) - add_library(libzip::zip ALIAS zip) - endif() - endif() - - if(TARGET libzip::zip) - set(LIBZIP_FOUND ON) - set(LIBZIP_TARGET libzip::zip) - else() - message(FATAL_ERROR "libzip fetch succeeded but target 'libzip::zip' (or 'zip') was not created.") - endif() -endif() - -# Final guard -if(NOT LIBZIP_FOUND) - message(FATAL_ERROR "libzip not found and fetching is disabled or failed. " - "Set LIBZIP_ALLOW_FETCH=ON or install libzip development files.") -endif() diff --git a/archive/asset/CMakeLists.txt b/archive/asset/CMakeLists.txt deleted file mode 100644 index f542548..0000000 --- a/archive/asset/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - asset.c - assetpalette.c - assettileset.c - assetpaletteimage.c -) - -# Compile definitions -target_compile_definitions(${DUSK_TARGET_NAME} - PRIVATE - ASSET_TYPE=wad -) \ No newline at end of file diff --git a/archive/asset/asset.c b/archive/asset/asset.c deleted file mode 100644 index 4e08f35..0000000 --- a/archive/asset/asset.c +++ /dev/null @@ -1,156 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "asset.h" -#include "util/memory.h" -#include "console/console.h" -#include "util/string.h" -#include "assert/assert.h" - -#define ASSET_ASSET_FILE "dusk.dsk" - -asset_t ASSET; - -errorret_t assetInit(void) { - memoryZero(&ASSET, sizeof(asset_t)); - - // Open zip file - char_t searchPath[FILENAME_MAX]; - consolevar_t *var = consoleVarGet("sys_path"); - const char_t *sysPath = var ? var->value : "."; - for(int32_t i = 0; i < ASSET_SEARCH_PATHS_COUNT; i++) { - sprintf( - searchPath, - ASSET_SEARCH_PATHS[i], - sysPath, - ASSET_ASSET_FILE - ); - - // Try open - ASSET.zip = zip_open(searchPath, ZIP_RDONLY, NULL); - if(ASSET.zip == NULL) continue; - consolePrint("Opened asset file: %s", searchPath); - break; - } - - // Did we open the asset? - if(ASSET.zip == NULL) errorThrow("Failed to open asset file."); - - errorOk(); -} - -void assetLoad( - const char_t *filename, - void (*callback)(void* data), - void *data -) { - assertNotNull(filename, "Filename cannot be NULL."); - assertTrue(strlen(filename) < ASSET_FILENAME_MAX, "Filename too long."); - assertTrue(strlen(filename) > 0, "Filename cannot be empty."); - - assertTrue( - ASSET.state != ASSET_STATE_LOADING, - "Asset system is already loading an asset." - ); - - // Determine the asset map type we are expecting based on the extension. - const assetmap_t *expected = &ASSET_MAP[0]; - do { - if(stringEndsWith(filename, expected->extension)) break; - expected++; - } while(expected->extension); - assertNotNull(expected->extension, "Unknown asset type."); - - // Pass off to the thread to begin loading. - ASSET.callback = callback; - ASSET.callbackData = data; - ASSET.errorState = ERROR_STATE_INIT; - ASSET.state = ASSET_STATE_LOADING; - stringCopy(ASSET.filename, filename, ASSET_FILENAME_MAX); - memoryZero(&ASSET.data, sizeof(ASSET.data)); - - // For the sake of testing I'm going to do blocking load, fun stuff. - zip_file_t *file = zip_fopen(ASSET.zip, filename, 0); - if(file == NULL) { - ASSET.state = ASSET_STATE_ERROR; - ASSET.error = errorCreate( - &ASSET.errorState, - "Failed to open asset: %s", - filename - ); - if(ASSET.callback) ASSET.callback(ASSET.callbackData); - return; - } - - printf("Loading asset: %s\n", filename); - - // Determine length of the file (uncompressed) - struct zip_stat st; - if(zip_stat(ASSET.zip, filename, 0, &st) != 0) { - zip_fclose(file); - ASSET.state = ASSET_STATE_ERROR; - ASSET.error = errorCreate( - &ASSET.errorState, - "Failed to stat asset: %s", - filename - ); - if(ASSET.callback) ASSET.callback(ASSET.callbackData); - return; - } - - if(st.size > sizeof(ASSET.data.palette)) { - zip_fclose(file); - ASSET.state = ASSET_STATE_ERROR; - ASSET.error = errorCreate( - &ASSET.errorState, - "Asset size mismatch: %s (got %d, expected %d)", - filename, - (int)st.size, - (int)sizeof(ASSET.data.palette) - ); - if(ASSET.callback) ASSET.callback(ASSET.callbackData); - return; - } - - // Read entire file into the asset data. - zip_fread(file, &ASSET.data, st.size); - zip_fclose(file); - ASSET.state = ASSET_STATE_LOADED; - - if(memoryCompare( - ASSET.data.header, expected->header, ASSET_HEADER_LENGTH - ) != 0) { - ASSET.state = ASSET_STATE_ERROR; - ASSET.error = errorCreate( - &ASSET.errorState, - "Asset header mismatch: %s (got %c%c%c, expected %c%c%c)", - filename, - ASSET.data.header[0], - ASSET.data.header[1], - ASSET.data.header[2], - expected->header[0], - expected->header[1], - expected->header[2] - ); - if(ASSET.callback) ASSET.callback(ASSET.callbackData); - return; - } - - // Parse the asset. - assertNotNull(expected->parser, "Asset parser cannot be NULL."); - expected->parser(); - - printf("Loaded asset: %s\n", filename); - if(ASSET.callback) ASSET.callback(ASSET.callbackData); -} - -void assetDispose(void) { - if(ASSET.zip != NULL) { - zip_close(ASSET.zip); - ASSET.zip = NULL; - } -} \ No newline at end of file diff --git a/archive/asset/asset.h b/archive/asset/asset.h deleted file mode 100644 index 6c37182..0000000 --- a/archive/asset/asset.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" -#include "assetpalette.h" -#include "assettileset.h" -#include "assetpalleteimage.h" -#include "error/error.h" -#include -#include "display/texture/texture.h" - -#define ASSET_COUNT_MAX 128 -#define ASSET_FILENAME_MAX 128 -#define ASSET_HEADER_LENGTH 3 - -#if ASSET_TYPE == wad -#else - #error "Unsupported ASSET_TYPE" -#endif - -#pragma pack(push, 1) -typedef struct { - char_t header[ASSET_HEADER_LENGTH]; - union { - assetpalette_t palette; - assettileset_t tileset; - assetpaletteimage_t paletteImage; - }; -} assetdata_t; -#pragma pack(pop) - -typedef struct { - union { - texture_t palette; - assettileset_t *tileset; - texture_t paletteImage; - }; -} assetloaded_t; - -typedef enum { - ASSET_STATE_NONE, - ASSET_STATE_LOADING, - ASSET_STATE_LOADED, - ASSET_STATE_ERROR -} assetstate_t; - -typedef struct { - int32_t nothing; - zip_t *zip; - // thread_t thread; - - errorstate_t errorState; - errorret_t error; - assetstate_t state; - char_t filename[ASSET_FILENAME_MAX]; - assetdata_t data; - assetloaded_t loaded; - - void (*callback)(void* data); - void *callbackData; -} asset_t; - -typedef struct { - const char_t *header; - const char_t *extension; - void (*parser)(); -} assetmap_t; - -static const char_t ASSET_SEARCH_PATHS[][FILENAME_MAX] = { - "%s/%s", - "./%s", - "../%s", - "../../%s", - "data/%s", - "../data/%s", -}; - -static const assetmap_t ASSET_MAP[] = { - { "DPF", ".dpf", assetParsePalette }, - { "DPT", ".dpt", assetParseTileset }, - { "DPI", ".dpi", assetParsePaletteImage }, - { NULL, NULL, NULL } -}; - -#define ASSET_SEARCH_PATHS_COUNT (\ - sizeof(ASSET_SEARCH_PATHS) / FILENAME_MAX\ -) - -extern asset_t ASSET; - -/** - * Initializes the asset system. - */ -errorret_t assetInit(void); - -/** - * Loads an asset by filename, blocking. - * - * @param filename The filename of the asset to get. - * @param callback The callback to call when the asset is loaded. - * @param data The data for the callback function. - * @return The asset. - */ -void assetLoad( - const char_t *filename, - void (*callback)(void* data), - void *data -); - -/** - * Disposes/cleans up the asset system. - */ -void assetDispose(void); \ No newline at end of file diff --git a/archive/asset/assetpalette.c b/archive/asset/assetpalette.c deleted file mode 100644 index 6b47abe..0000000 --- a/archive/asset/assetpalette.c +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "asset.h" - -void assetParsePalette() { - textureInit( - &ASSET.loaded.palette, - ASSET.data.palette.colorCount, - 1, - TEXTURE_FORMAT_RGBA, - ASSET.data.palette.colors - ); -} \ No newline at end of file diff --git a/archive/asset/assetpalette.h b/archive/asset/assetpalette.h deleted file mode 100644 index 585275c..0000000 --- a/archive/asset/assetpalette.h +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" -#include "display/color.h" - -#define ASSET_PALETTE_COLOR_COUNT_MAX 256 - -typedef struct { - int32_t colorCount; - color4b_t colors[ASSET_PALETTE_COLOR_COUNT_MAX]; -} assetpalette_t; - -/** - * Parse the palette from the loaded raw data. - */ -void assetParsePalette(void); \ No newline at end of file diff --git a/archive/asset/assetpaletteimage.c b/archive/asset/assetpaletteimage.c deleted file mode 100644 index 049732f..0000000 --- a/archive/asset/assetpaletteimage.c +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "asset.h" - -void assetParsePaletteImage(void) { - printf("nothin doin\n"); -} \ No newline at end of file diff --git a/archive/asset/assetpalleteimage.h b/archive/asset/assetpalleteimage.h deleted file mode 100644 index dbcd483..0000000 --- a/archive/asset/assetpalleteimage.h +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" - -#define ASSET_PALETTE_IMAGE_PIXELS_MAX (256*256) - -typedef struct { - int32_t width; - int32_t height; - uint8_t paletteIndex; - uint8_t paletteIndexes[ASSET_PALETTE_IMAGE_PIXELS_MAX]; -} assetpaletteimage_t; - -/** - * Parse the palette image from the loaded raw data. - */ -void assetParsePaletteImage(void); \ No newline at end of file diff --git a/archive/asset/assettileset.h b/archive/asset/assettileset.h deleted file mode 100644 index e2ba190..0000000 --- a/archive/asset/assettileset.h +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" - -typedef struct assetimage_s assetimage_t; - -typedef struct { - int32_t tileWidth; - int32_t tileHeight; - int32_t tileCount; - int32_t columns; - char_t tilesetName[256]; -} assettileset_t; - -/** - * Parse the tileset from the loaded raw data. - */ -void assetParseTileset(void); \ No newline at end of file diff --git a/archive/dusk/CMakeLists.txt b/archive/dusk/CMakeLists.txt deleted file mode 100644 index c4a5c7f..0000000 --- a/archive/dusk/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Libs -target_link_libraries(${DUSK_TARGET_NAME} - PUBLIC - m -) - -# Includes -target_include_directories(${DUSK_TARGET_NAME} - PRIVATE - ${CMAKE_CURRENT_LIST_DIR} -) - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - game.c - input.c - time.c -) - -# Subdirs -add_subdirectory(assert) -add_subdirectory(console) -add_subdirectory(display) -add_subdirectory(error) -add_subdirectory(entity) -add_subdirectory(event) -add_subdirectory(item) -add_subdirectory(locale) -add_subdirectory(ui) -add_subdirectory(util) -add_subdirectory(world) \ No newline at end of file diff --git a/archive/dusk/assert/assert.c b/archive/dusk/assert/assert.c deleted file mode 100644 index 2f02a16..0000000 --- a/archive/dusk/assert/assert.c +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Copyright (c) 2023 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "assert.h" - -#ifndef ASSERTIONS_FAKED - void assertTrueImpl( - const char *file, - const int32_t line, - const bool x, - const char *message - ) { - if(x != true) { - fprintf( - stderr, - "Assertion Failed in %s:%i\n\n%s\n", - file, - line, - message - ); - abort(); - } - } - - void assertFalseImpl( - const char *file, - const int32_t line, - bool x, - const char *message - ) { - assertTrueImpl(file, line, !x, message); - } - - void assertUnreachableImpl( - const char *file, - const int32_t line, - const char *message - ) { - assertTrueImpl(file, line, false, message); - } - - void assertNotNullImpl( - const char *file, - const int32_t line, - const void *pointer, - const char *message - ) { - assertTrueImpl( - file, - line, - pointer != NULL, - message - ); - - // Ensure we can touch it - volatile char temp; - temp = *((char*)pointer); - } - - void assertNullImpl( - const char *file, - const int32_t line, - const void *pointer, - const char *message - ) { - assertTrueImpl( - file, - line, - pointer == NULL, - message - ); - } - - void assertDeprecatedImpl( - const char *file, - const int32_t line, - const char *message - ) { - assertUnreachableImpl(file, line, message); - } -#endif \ No newline at end of file diff --git a/archive/dusk/assert/assert.h b/archive/dusk/assert/assert.h deleted file mode 100644 index 03e401e..0000000 --- a/archive/dusk/assert/assert.h +++ /dev/null @@ -1,143 +0,0 @@ -/** - * Copyright (c) 2023 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" - -#ifndef ASSERTIONS_FAKED - /** - * Assert a given value to be true. - * - * @param file File that the assertion is being made from. - * @param line Line that the assertion is being made from. - * @param x Value to assert as true. - * @param message Message to throw against assertion failure. - */ - void assertTrueImpl( - const char *file, - const int32_t line, - const bool_t x, - const char *message - ); - - /** - * Asserts a given statement to be false. - * - * @param file File that the assertion is being made from. - * @param line Line that the assertion is being made from. - * @param x Value to assert as false. - * @param message Message to throw against assertion failure. - */ - void assertFalseImpl( - const char *file, - const int32_t line, - const bool_t x, - const char *message - ); - - /** - * Asserts that a given line of code is unreachable. Essentially a forced - * assertion failure, good for "edge cases" - * - * @param file File that the assertion is being made from. - * @param line Line that the assertion is being made from. - * @param message Message to throw against assertion failure. - */ - void assertUnreachableImpl( - const char *file, - const int32_t line, - const char *message - ); - - /** - * Assert a given pointer to not point to a null pointer. - * - * @param file File that the assertion is being made from. - * @param line Line that the assertion is being made from. - * @param pointer Pointer to assert is not a null pointer. - * @param message Message to throw against assertion failure. - */ - void assertNotNullImpl( - const char *file, - const int32_t line, - const void *pointer, - const char *message - ); - - /** - * Asserts a given pointer to be a nullptr. - * - * @param file File that the assertion is being made from. - * @param line Line that the assertion is being made from. - * @param pointer Pointer to assert is nullptr. - * @param message Message to throw against assertion failure. - */ - void assertNullImpl( - const char *file, - const int32_t line, - const void *pointer, - const char *message - ); - - /** - * Asserts a function as being deprecated. - * - * @param file File that the assertion is being made from. - * @param line Line that the assertion is being made from. - * @param message Message to throw against assertion failure. - */ - void assertDeprecatedImpl( - const char *file, - const int32_t line, - const char *message - ); - - void assertMemoryRangeMatchesImpl( - const char *file, - const int32_t line, - const void *start, - const void *end, - const size_t size, - const char *message - ); - - #define assertTrue(x, message) \ - assertTrueImpl(__FILE__, __LINE__, x, message) - - #define assertFalse(x, message) \ - assertFalseImpl(__FILE__, __LINE__, x, message) - - #define assertUnreachable(message) \ - assertUnreachableImpl(__FILE__, __LINE__, message) - - #define assertNotNull(pointer, message) \ - assertNotNullImpl(__FILE__, __LINE__, pointer, message) - - #define assertNull(pointer, message) \ - assertNullImpl(__FILE__, __LINE__, pointer, message) - - #define assertDeprecated(message) \ - assertDeprecatedImpl(__FILE__, __LINE__, message) - - #define assertStrLenMax(str, len, message) \ - assertTrue(strlen(str) < len, message) - - #define assertStrLenMin(str, len, message) \ - assertTrue(strlen(str) >= len, message) - -#else - // If assertions are faked, we define the macros to do nothing. - #define assertTrue(x, message) ((void)0) - #define assertFalse(x, message) ((void)0) - #define assertUnreachable(message) ((void)0) - #define assertNotNull(pointer, message) ((void)0) - #define assertNull(pointer, message) ((void)0) - #define assertDeprecated(message) ((void)0) - #define assertStrLenMax(str, len, message) ((void)0) - #define assertStrLenMin(str, len, message) ((void)0) - -#endif \ No newline at end of file diff --git a/archive/dusk/display/CMakeLists.txt b/archive/dusk/display/CMakeLists.txt deleted file mode 100644 index 6213aa6..0000000 --- a/archive/dusk/display/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - renderbase.c - scene.c -) \ No newline at end of file diff --git a/archive/dusk/display/renderbase.c b/archive/dusk/display/renderbase.c deleted file mode 100644 index 9331e01..0000000 --- a/archive/dusk/display/renderbase.c +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "display/render.h" \ No newline at end of file diff --git a/archive/dusk/display/renderbase.h b/archive/dusk/display/renderbase.h deleted file mode 100644 index 2039247..0000000 --- a/archive/dusk/display/renderbase.h +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "error/error.h" - -#ifndef RENDER_WIDTH - #define RENDER_WIDTH 320 -#endif -#ifndef RENDER_HEIGHT - #define RENDER_HEIGHT 240 -#endif - -/** - * Initializes the rendering system. - */ -errorret_t renderInit(void); - -/** - * Tells the rendering system to actually draw the frame. - */ -errorret_t renderDraw(void); - -/** - * Disposes of the rendering system. - */ -errorret_t renderDispose(void); \ No newline at end of file diff --git a/archive/dusk/display/scene.c b/archive/dusk/display/scene.c deleted file mode 100644 index 56d40df..0000000 --- a/archive/dusk/display/scene.c +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "scene.h" -#include "world/overworld.h" - -scene_t SCENE_CURRENT; -scenecallback_t SCENE_CALLBACKS[SCENE_COUNT] = { - [SCENE_INITIAL] = { - .init = NULL, - .update = NULL - }, - - [SCENE_OVERWORLD] = { - .init = overworldInit, - .update = overworldUpdate, - .dispose = NULL - } -}; - -void sceneInit(void) { - for(uint8_t i = 0; i < SCENE_COUNT; i++) { - if(SCENE_CALLBACKS[i].init) { - SCENE_CALLBACKS[i].init(); - } - } - - SCENE_CURRENT = SCENE_OVERWORLD; -} - -void sceneSet(const scene_t scene) { - SCENE_CURRENT = scene; -} - -void sceneUpdate(void) { - if(SCENE_CALLBACKS[SCENE_CURRENT].update) { - SCENE_CALLBACKS[SCENE_CURRENT].update(); - } -} - -void sceneDispose(void) { - for(uint8_t i = 0; i < SCENE_COUNT; i++) { - if(SCENE_CALLBACKS[i].dispose) { - SCENE_CALLBACKS[i].dispose(); - } - } -} \ No newline at end of file diff --git a/archive/dusk/display/scene.h b/archive/dusk/display/scene.h deleted file mode 100644 index 1529f00..0000000 --- a/archive/dusk/display/scene.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" - -typedef enum { - SCENE_INITIAL, - SCENE_OVERWORLD, - - SCENE_COUNT -} scene_t; - -typedef struct { - void (*init)(void); - void (*update)(void); - void (*dispose)(void); -} scenecallback_t; - -extern scene_t SCENE_CURRENT; -extern scenecallback_t SCENE_CALLBACKS[SCENE_COUNT]; - -/** - * Initializes the scene module. - */ -void sceneInit(void); - -/** - * Sets the current scene. - * - * @param scene The scene to set. - */ -void sceneSet(const scene_t scene); - -/** - * Updates the current scene. - */ -void sceneUpdate(void); - -/** - * Disposes of the current scene. - */ -void sceneDispose(void); \ No newline at end of file diff --git a/archive/dusk/dusk.h b/archive/dusk/dusk.h deleted file mode 100644 index 8dd5e00..0000000 --- a/archive/dusk/dusk.h +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -typedef bool bool_t; -typedef int int_t; -typedef float float_t; -typedef char char_t; \ No newline at end of file diff --git a/archive/dusk/ecs/CMakeLists.txt b/archive/dusk/ecs/CMakeLists.txt deleted file mode 100644 index 18a4ba5..0000000 --- a/archive/dusk/ecs/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - ecssystem.c - ecscomponent.c -) \ No newline at end of file diff --git a/archive/dusk/ecs/ecscomponent.c b/archive/dusk/ecs/ecscomponent.c deleted file mode 100644 index 49c81c7..0000000 --- a/archive/dusk/ecs/ecscomponent.c +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "ecscomponent.h" -#include "ecssystem.h" -#include "assert/assert.h" -#include "util/memory.h" - -void ecsComponentInitialize(ecscomponent_t *cmp) { - assertNotNull(cmp, "Component pointer cannot be NULL."); - assertTrue( - ECS_SYSTEM.componentCount < ECS_SYSTEM_ECS_COMPONENTS_MAX, - "ECS Component count exceeded maximum limit." - ); - - memoryZero(cmp->data, sizeof(ecscomponent_t)); - - if(cmp->callbacks.init) cmp->callbacks.init(); - cmp->componentFlags |= ECS_COMPONENT_FLAG_INITIALIZED; - - ECS_SYSTEM.components[ECS_SYSTEM.componentCount++] = cmp; -} - -bool_t ecsComponentIsInitialized(const ecscomponent_t *cmp) { - assertNotNull(cmp, "Component pointer cannot be NULL."); - return (cmp->componentFlags & ECS_COMPONENT_FLAG_INITIALIZED) != 0; -} - - -bool_t ecsComponentDataHas(const ecscomponent_t *cmp, const ecsid_t id) { - assertTrue( - id >= 0 && id < ECS_ENTITY_COUNT_MAX, - "Invalid entity ID." - ); - if(!ecsComponentIsInitialized(cmp)) return false; - - return cmp->entityFlags[id] & ECS_COMPONENT_ENTITY_FLAG_USED; -} - -void * ecsComponentDataGet(const ecscomponent_t *cmp, const ecsid_t id) { - assertTrue(ecsComponentDataHas(cmp, id), "No data for entity ID."); - return (void *)((uint8_t *)cmp->data + (id * cmp->dataSize)); -} - -void * ecsComponentDataAdd(ecscomponent_t *cmp, const ecsid_t id) { - if(!ecsComponentIsInitialized(cmp)) ecsComponentInitialize(cmp); - - assertTrue(id >= 0 && id < ECS_ENTITY_COUNT_MAX, "Invalid entity ID."); - assertFalse(ecsComponentDataHas(cmp, id), "Entity already has data."); - - memoryZero( - (uint8_t *)cmp->data + (id * cmp->dataSize), - cmp->dataSize - ); - cmp->entityFlags[id] |= ECS_COMPONENT_ENTITY_FLAG_USED; - if(cmp->callbacks.entityAdd) cmp->callbacks.entityAdd(id); - cmp->entitiesWithData[cmp->entitiesWithDataCount++] = id; - - return ecsComponentDataGet(cmp, id); -} - -void ecsComponentDataRemove(ecscomponent_t *cmp, const ecsid_t id) { - assertTrue( - ecsComponentIsInitialized(cmp), "Component was never initialized." - ); - assertTrue(ecsComponentDataHas(cmp, id), "Entity does not have data."); - - cmp->entityFlags[id] = 0; - - // Remove entity from the entitiesWithData array by finding its index and - // shifting the rest of the array down. Use memoryCopy to avoid - // unnecessary loops. - uint32_t index = 0; - for(; index < cmp->entitiesWithDataCount; index++) { - if(cmp->entitiesWithData[index] == id) break; - } - assertTrue( - index < cmp->entitiesWithDataCount, - "Entity not found in entitiesWithData?" - ); - memoryCopy( - &cmp->entitiesWithData[index], - &cmp->entitiesWithData[index + 1], - sizeof(ecsid_t) * (cmp->entitiesWithDataCount - index - 1) - ); - - if(cmp->callbacks.entityRemove) cmp->callbacks.entityRemove(id); -} - -uint32_t ecsComponentGetAll(const ecscomponent_t *cmp, ecsid_t *out) { - assertTrue( - ecsComponentIsInitialized(cmp), - "Component was never initialized." - ); - - if(!out) return cmp->entitiesWithDataCount; - - memoryCopy( - out, - cmp->entitiesWithData, - sizeof(ecsid_t) * cmp->entitiesWithDataCount - ); - return cmp->entitiesWithDataCount; -} - -void ecsComponentDispose(ecscomponent_t *cmp) { - assertNotNull(cmp, "Component pointer cannot be NULL."); - assertTrue( - ecsComponentIsInitialized(cmp), - "Component was never initialized." - ); - - for(uint32_t i = 0; i < cmp->entitiesWithDataCount; i++) { - if(cmp->callbacks.entityRemove) - cmp->callbacks.entityRemove(cmp->entitiesWithData[i]); - } - memoryZero(cmp->entityFlags, sizeof(cmp->entityFlags)); - cmp->entitiesWithDataCount = 0; - cmp->componentFlags = 0; -} \ No newline at end of file diff --git a/archive/dusk/ecs/ecscomponent.h b/archive/dusk/ecs/ecscomponent.h deleted file mode 100644 index b52daad..0000000 --- a/archive/dusk/ecs/ecscomponent.h +++ /dev/null @@ -1,111 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "ecs/ecsentity.h" - -#define ECS_COMPONENT_ENTITY_FLAG_USED (1 << 0) - -#define ECS_COMPONENT_FLAG_INITIALIZED (1 << 0) - -typedef struct { - void (*init)(); - void (*entityAdd)(const ecsid_t id); - void (*entityRemove)(const ecsid_t id); -} ecscomponentcallbacks_t; - -typedef struct { - void *data; - size_t dataSize; - uint8_t entityFlags[ECS_ENTITY_COUNT_MAX]; - uint8_t componentFlags; - ecscomponentcallbacks_t callbacks; - - ecsid_t entitiesWithData[ECS_ENTITY_COUNT_MAX]; - uint32_t entitiesWithDataCount;; -} ecscomponent_t; - -/** - * Initializes an ECS Component. - * - * @param dPointer Pointer to the data that the component owns. - * @param cbs Callback functions for the component. - */ -#define ecsComponentInit(dPointer, cbs) \ - (ecscomponent_t){ \ - .data = dPointer, \ - .dataSize = sizeof(*dPointer), \ - .entityFlags = 0, \ - .componentFlags = 0, \ - .callbacks = (cbs) \ - } - -/** - * Initializes an ECS Component. - * - * @param cmp Pointer to the ecscomponent_t to initialize. - */ -void ecsComponentInitialize(ecscomponent_t *cmp); - -/** - * Checks if the component is initialized. - * - * @param cmp Pointer to the ecscomponent_t. - * @return True if the component is initialized, false otherwise. - */ -bool_t ecsComponentIsInitialized(const ecscomponent_t *cmp); - -/** - * Checks if the component has data for a specific entity. - * - * @param cmp Pointer to the ecscomponent_t. - * @param id The ID of the entity to check. - * @return True if the component has data for the entity, false otherwise. - */ -bool_t ecsComponentDataHas(const ecscomponent_t *cmp, const ecsid_t id); - -/** - * Gets the data for a specific entity in the component. - * - * @param cmp Pointer to the ecscomponent_t. - * @param id The ID of the entity to get data for. - * @return Pointer to the data for the entity. - */ -void * ecsComponentDataGet(const ecscomponent_t *cmp, const ecsid_t id); - -/** - * Adds data for a specific entity in the component. - * - * @param cmp Pointer to the ecscomponent_t. - * @param id The ID of the entity to add data for. - */ -void * ecsComponentDataAdd(ecscomponent_t *cmp, const ecsid_t id); - -/** - * Removes data for a specific entity in the component. - * - * @param cmp Pointer to the ecscomponent_t. - * @param id The ID of the entity to remove data for. - */ -void ecsComponentDataRemove(ecscomponent_t *cmp, const ecsid_t id); - -/** - * Gets all entities that have data in the component. Passing NULL for out will - * just return the count of entities. - * - * @param cmp Pointer to the ecscomponent_t. - * @param out Pointer to an array to store the entity IDs. - * @return The number of entities with data. - */ -uint32_t ecsComponentGetAll(const ecscomponent_t *cmp, ecsid_t *out); - -/** - * Disposes the component, freeing any resources it holds. - * - * @param cmp Pointer to the ecscomponent_t to dispose. - */ -void ecsComponentDispose(ecscomponent_t *cmp); \ No newline at end of file diff --git a/archive/dusk/ecs/ecsentity.h b/archive/dusk/ecs/ecsentity.h deleted file mode 100644 index cfe0817..0000000 --- a/archive/dusk/ecs/ecsentity.h +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "ecs.h" - -#define ECS_ENTITY_FLAG_USED (1 << 0) - -#define ECS_ENTITY_COUNT_MAX 2048 - -typedef struct ecsentity_s { - ecsid_t id; - uint8_t flags; -} ecsentity_t; \ No newline at end of file diff --git a/archive/dusk/ecs/ecssystem.c b/archive/dusk/ecs/ecssystem.c deleted file mode 100644 index f00d0ef..0000000 --- a/archive/dusk/ecs/ecssystem.c +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "ecssystem.h" -#include "util/memory.h" -#include "assert/assert.h" - -ecssystem_t ECS_SYSTEM; - -void ecsSystemInit() { - memoryZero(&ECS_SYSTEM, sizeof(ecssystem_t)); - - // Fill ECS ids - for(uint32_t i = 0; i < ECS_ENTITY_COUNT_MAX; i++) { - ECS_SYSTEM.entities[i].id = i; - } - - // Fill the available array. - for(uint32_t i = 0; i < ECS_ENTITY_COUNT_MAX; i++) { - ECS_SYSTEM.available[i] = &ECS_SYSTEM.entities[i]; - } - ECS_SYSTEM.availableCount = ECS_ENTITY_COUNT_MAX; -} - -ecsid_t ecsEntityAdd() { - assertTrue(ECS_SYSTEM.availableCount > 0, "No available entities to create"); - - // Pop off the last available entity. - ecsentity_t *entity = ECS_SYSTEM.available[--ECS_SYSTEM.availableCount]; - assertTrue((entity->flags & ECS_ENTITY_FLAG_USED) == 0, "Entity is used."); - assertTrue(entity->id >= 0, "Entity is invalid."); - assertTrue(entity->id < ECS_ENTITY_COUNT_MAX, "Entity ID out of bounds"); - - entity->flags |= ECS_ENTITY_FLAG_USED; - - return entity->id; -} - -void ecsEntityRemove(const ecsid_t id) { - assertTrue(id < ECS_ENTITY_COUNT_MAX, "Invalid entity ID"); - - ecsentity_t *entity = &ECS_SYSTEM.entities[id]; - assertTrue(entity->id >= 0, "Entity is invalid."); - assertTrue((entity->flags & ECS_ENTITY_FLAG_USED) != 0, "Entity is not used."); - - // Mark the entity as available. - ECS_SYSTEM.available[ECS_SYSTEM.availableCount++] = entity; - assertTrue( - ECS_SYSTEM.availableCount <= ECS_ENTITY_COUNT_MAX, - "Available count exceeded maximum limit" - ); -} - -void ecsSystemDispose() { - for(uint32_t i = 0; i < ECS_SYSTEM.componentCount; i++) { - ecscomponent_t *cmp = ECS_SYSTEM.components[i]; - ecsComponentDispose(cmp); - assertTrue(cmp->entitiesWithDataCount == 0, "Component still has data."); - } - - memoryZero(&ECS_SYSTEM, sizeof(ecssystem_t)); -} \ No newline at end of file diff --git a/archive/dusk/ecs/ecssystem.h b/archive/dusk/ecs/ecssystem.h deleted file mode 100644 index e1561d8..0000000 --- a/archive/dusk/ecs/ecssystem.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "ecsentity.h" -#include "ecscomponent.h" - -#define ECS_SYSTEM_ECS_COMPONENTS_MAX 64 - -typedef struct { - ecsentity_t entities[ECS_ENTITY_COUNT_MAX]; - - ecsentity_t *available[ECS_ENTITY_COUNT_MAX]; - uint32_t availableCount; - - ecscomponent_t *components[ECS_SYSTEM_ECS_COMPONENTS_MAX]; - uint32_t componentCount; -} ecssystem_t; - -extern ecssystem_t ECS_SYSTEM; - -/** - * Initialize the ECS system. - */ -void ecsSystemInit(); - -/** - * Create a new entity in the ECS. This locks an id and gives it to the caller, - * who will be responsible for managing the entity's lifecycle. - * - * @return The ID of the newly created entity. - */ -ecsid_t ecsEntityAdd(); - -/** - * Disposes an entity in the ECS. This will free the entity's ID and make it - * available for reuse. - * - * @param id The ID of the entity to destroy. - */ -void ecsEntityRemove(const ecsid_t id); - -/** - * Dispose the ECS system, freeing all resources. - */ -void ecsSystemDispose(); \ No newline at end of file diff --git a/archive/dusk/entity/CMakeLists.txt b/archive/dusk/entity/CMakeLists.txt deleted file mode 100644 index fe59ea9..0000000 --- a/archive/dusk/entity/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - direction.c - entity.c - player.c - npc.c -) \ No newline at end of file diff --git a/archive/dusk/entity/direction.c b/archive/dusk/entity/direction.c deleted file mode 100644 index e4f0e5e..0000000 --- a/archive/dusk/entity/direction.c +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "direction.h" -#include "assert/assert.h" - -float_t directionToAngle(const direction_t dir) { - switch(dir) { - case DIRECTION_NORTH: return (M_PI_2); - case DIRECTION_SOUTH: return -(M_PI_2); - case DIRECTION_EAST: return 0; - case DIRECTION_WEST: return (M_PI); - default: return 0; // Should never happen - } -} - -void directionGetCoordinates( - const direction_t dir, - int8_t *x, int8_t *y -) { - assertNotNull(x, "X coordinate pointer cannot be NULL"); - assertNotNull(y, "Y coordinate pointer cannot be NULL"); - - switch(dir) { - case DIRECTION_NORTH: - *x = 0; - *y = -1; - break; - - case DIRECTION_SOUTH: - *x = 0; - *y = 1; - break; - - case DIRECTION_EAST: - *x = 1; - *y = 0; - break; - - case DIRECTION_WEST: - *x = -1; - *y = 0; - break; - - default: - assertUnreachable("Invalid direction"); - break; - } -} \ No newline at end of file diff --git a/archive/dusk/entity/direction.h b/archive/dusk/entity/direction.h deleted file mode 100644 index 65d6f2e..0000000 --- a/archive/dusk/entity/direction.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" - -typedef enum { - DIRECTION_SOUTH = 0, - DIRECTION_EAST = 1, - DIRECTION_WEST = 2, - DIRECTION_NORTH = 3, - - DIRECTION_UP = DIRECTION_NORTH, - DIRECTION_DOWN = DIRECTION_SOUTH, - DIRECTION_LEFT = DIRECTION_WEST, - DIRECTION_RIGHT = DIRECTION_EAST, -} direction_t; - -/** - * Converts a direction to an angle in float_t format. - * - * @param dir The direction to convert. - * @return The angle corresponding to the direction. - */ -float_t directionToAngle(const direction_t dir); - -/** - * Gets the relative coordinates for a given direction. - * - * @param dir The direction to get coordinates for. - * @param x Pointer to store the x coordinate. - * @param y Pointer to store the y coordinate. - */ -void directionGetCoordinates( - const direction_t dir, - int8_t *x, int8_t *y -); \ No newline at end of file diff --git a/archive/dusk/entity/entity.c b/archive/dusk/entity/entity.c deleted file mode 100644 index 973e336..0000000 --- a/archive/dusk/entity/entity.c +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "entity.h" -#include "assert/assert.h" -#include "util/memory.h" -#include "world/world.h" -#include "world/tiledata.h" -#include "time.h" - -entity_t ENTITIES[ENTITY_COUNT_MAX] = {0}; - -entitycallback_t ENTITY_CALLBACKS[ENTITY_TYPE_COUNT] = { - {NULL}, // ENTITY_TYPE_NULL - { - .load = playerEntityLoad, - .update = playerEntityUpdate, - }, - { - .load = npcLoad, - .update = npcUpdate, - .interact = npcInteract, - }, -}; - -void entityLoad(entity_t *entity, const entity_t *source) { - assertNotNull(entity, "Entity pointer cannot be NULL"); - assertNotNull(source, "Source entity pointer cannot be NULL"); - assertTrue(source->type != ENTITY_TYPE_NULL, "Source entity type NULL"); - assertTrue(source->type < ENTITY_TYPE_COUNT, "Source entity type bad"); - assertNotNull( - ENTITY_CALLBACKS[source->type].load, - "Entity type has no i nit callback" - ); - - memoryZero(entity, sizeof(entity_t)); - - entity->type = source->type; - entity->x = source->x; - entity->y = source->y; - entity->dir = source->dir; - entity->id = source->id; - - ENTITY_CALLBACKS[entity->type].load(entity, source); -} - -void entityUpdate(entity_t *entity) { - assertNotNull(entity, "Entity pointer cannot be NULL"); - assertTrue(entity->type != ENTITY_TYPE_NULL, "Entity type NULL"); - assertTrue(entity->type < ENTITY_TYPE_COUNT, "Entity type out of bounds"); - assertNotNull( - ENTITY_CALLBACKS[entity->type].update, - "Entity type has no update callback" - ); - - ENTITY_CALLBACKS[entity->type].update(entity); - - if(entity->subX > 0) { - entity->subX -= entity->moveSpeed; - } else if(entity->subX < 0) { - entity->subX += entity->moveSpeed; - } - - if(entity->subY > 0) { - entity->subY -= entity->moveSpeed; - } else if(entity->subY < 0) { - entity->subY += entity->moveSpeed; - } -} - -void entityMove(entity_t *entity, const uint8_t moveSpeed) { - assertNotNull(entity, "Entity pointer cannot be NULL"); - assertTrue(entity->type != ENTITY_TYPE_NULL, "Entity type NULL"); - assertTrue(entity->type < ENTITY_TYPE_COUNT, "Entity type out of bounds"); - assertFalse( - entityIsMoving(entity), - "Entity is already moving, cannot move again" - ); - - int8_t x = 0, y = 0; - directionGetCoordinates(entity->dir, &x, &y); - - // entity in way? - entity_t *ent = entityGetAt(entity->x + x, entity->y + y); - if(ent != NULL) return; - - entity->x += x; - entity->y += y; - entity->subX = TILE_WIDTH_HEIGHT * -x; - entity->subY = TILE_WIDTH_HEIGHT * -y; - entity->moveSpeed = moveSpeed; -} - -void entityTurn(entity_t *entity, const direction_t dir) { - assertNotNull(entity, "Entity pointer cannot be NULL"); - assertTrue(entity->type != ENTITY_TYPE_NULL, "Entity type NULL"); - assertTrue(entity->type < ENTITY_TYPE_COUNT, "Entity type out of bounds"); - assertTrue( - dir >= DIRECTION_SOUTH && dir <= DIRECTION_NORTH, "Invalid direction" - ); - assertFalse( - entityIsMoving(entity), "Entity is already moving, cannot turn" - ); - - entity->dir = dir; -} - -bool_t entityIsMoving(const entity_t *entity) { - assertNotNull(entity, "Entity pointer cannot be NULL"); - assertTrue(entity->type != ENTITY_TYPE_NULL, "Entity type NULL"); - assertTrue(entity->type < ENTITY_TYPE_COUNT, "Entity type out of bounds"); - return entity->subX != 0 || entity->subY != 0; -} - -entity_t * entityGetAt( - const uint32_t tileX, - const uint32_t tileY -) { - entity_t *entity = ENTITIES; - - do { - if(entity->type == ENTITY_TYPE_NULL) continue; - if(entity->x == tileX && entity->y == tileY) return entity; - } while((entity++) < &ENTITIES[ENTITY_COUNT_MAX - 1]); - - return NULL; -} diff --git a/archive/dusk/entity/entity.h b/archive/dusk/entity/entity.h deleted file mode 100644 index afa6f59..0000000 --- a/archive/dusk/entity/entity.h +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "direction.h" -#include "player.h" -#include "npc.h" - -#define ENTITY_COUNT_MAX 32 -#define ENTITY_TURN_DURATION 0.075f // Duration for turning in seconds -#define ENTITY_MOVE_DURATION 0.1f // Duration for moving 1 tile, in seconds. - -typedef enum { - ENTITY_TYPE_NULL = 0, - ENTITY_TYPE_PLAYER = 1, - ENTITY_TYPE_NPC = 2, -} entitytype_t; -#define ENTITY_TYPE_COUNT 3 - -typedef struct _entity_t { - uint32_t id;// Completely unique ID for this entity. - uint32_t x, y; - int8_t subX, subY; - uint8_t moveSpeed; - - entitytype_t type; - direction_t dir; - - - union { - npc_t npc; - playerentity_t player; - }; -} entity_t; - -typedef struct { - void (*load) (entity_t *entity, const entity_t *source); - void (*update) (entity_t *entity); - void (*interact)(entity_t *player, entity_t *self); -} entitycallback_t; - -extern entity_t ENTITIES[ENTITY_COUNT_MAX]; -extern entitycallback_t ENTITY_CALLBACKS[ENTITY_TYPE_COUNT]; - -/** - * Loads an entity from the generated entity data. - * - * @param entity Pointer to the entity to initialize. - * @param source Pointer to the source entity data. - */ -void entityLoad(entity_t *entity, const entity_t *source); - -/** - * Updates the entity's state. - * - * @param entity Pointer to the entity to update. - */ -void entityUpdate(entity_t *entity); - -/** - * Moves the entity by the specified x and y offsets. - * - * @param entity Pointer to the entity to move. - * @param moveSpeed The speed at which to move the entity. - */ -void entityMove(entity_t *entity, const uint8_t moveSpeed); - -/** - * Turns the entity to face the specified direction. - * - * @param entity Pointer to the entity to turn. - * @param dir The direction to turn the entity to. - */ -void entityTurn(entity_t *entity, const direction_t dir); - -/** - * Returns whether or not an entity is currently moving. - * - * @param entity Pointer to the entity to check. - * @return True if the entity is moving, false otherwise. - */ -bool_t entityIsMoving(const entity_t *entity); - -/** - * Gets the entity at the specified tile coordinates. - * - * @param tileX The x coordinate of the tile to get the entity from. - * @param tileY The y coordinate of the tile to get the entity from. - * @return Pointer to the entity at the specified coordinates, or NULL if no - * entity exists there. - */ -entity_t *entityGetAt( - const uint32_t tileX, - const uint32_t tileY -); \ No newline at end of file diff --git a/archive/dusk/entity/npc.c b/archive/dusk/entity/npc.c deleted file mode 100644 index 67408c4..0000000 --- a/archive/dusk/entity/npc.c +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "entity.h" -#include "ui/uitextbox.h" -#include "locale/language.h" -#include "assert/assert.h" - -void npcLoad(entity_t *entity, const entity_t *source) { - assertNotNull(entity, "Entity pointer cannot be NULL"); - assertNotNull(source, "Source entity pointer cannot be NULL"); - assertTrue(source->type == ENTITY_TYPE_NPC, "Source entity type must be NPC"); - - entity->npc = source->npc; -} - -void npcUpdate(entity_t *entity) { -} - -void npcInteract(entity_t *player, entity_t *self) { - assertTrue(self->type == ENTITY_TYPE_NPC, "Entity must be of type NPC"); - - switch(self->npc.interactType) { - case NPC_INTERACT_TYPE_NONE: - break; - - case NPC_INTERACT_TYPE_TEXT: - uiTextboxSetText(languageGet(self->npc.text)); - break; - - case NPC_INTERACT_TYPE_CONVO: - break; - - case NPC_INTERACT_TYPE_EVENT: - eventSetActive(self->npc.eventData); - break; - - default: - assertUnreachable("Unknown NPC interaction type"); - } -} \ No newline at end of file diff --git a/archive/dusk/entity/npc.h b/archive/dusk/entity/npc.h deleted file mode 100644 index bc903d9..0000000 --- a/archive/dusk/entity/npc.h +++ /dev/null @@ -1,44 +0,0 @@ - -#pragma once -#include "event/eventlist.h" - -typedef struct _entity_t entity_t; - -typedef enum { - NPC_INTERACT_TYPE_NONE = 0, - NPC_INTERACT_TYPE_TEXT = 1, - NPC_INTERACT_TYPE_CONVO = 2, - NPC_INTERACT_TYPE_EVENT = 3, -} npcinteracttype_t; - -typedef struct { - npcinteracttype_t interactType; - - union { - const char_t* text; - const eventdata_t *eventData; - }; -} npc_t; - -/** - * Initializes the NPC entity. - * - * @param entity The entity to initialize. - * @param source The source entity to copy data from. - */ -void npcLoad(entity_t *entity, const entity_t *source); - -/** - * Updates the NPC entity. - * - * @param entity The entity to update. - */ -void npcUpdate(entity_t *entity); - -/** - * Handles interaction between the player and the NPC. - * - * @param player The player entity interacting with the NPC. - * @param self The NPC entity being interacted with. - */ -void npcInteract(entity_t *player, entity_t *self); \ No newline at end of file diff --git a/archive/dusk/entity/player.c b/archive/dusk/entity/player.c deleted file mode 100644 index d296bf6..0000000 --- a/archive/dusk/entity/player.c +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "entity.h" -#include "assert/assert.h" -#include "input.h" -#include "display/render.h" -#include "world/world.h" - -#include "ui/uitextbox.h" - -inventory_t PLAYER_INVENTORY; - -void playerInit() { - entity_t *ent = &ENTITIES[0]; - - entity_t playerEntityData = { - .id = PLAYER_ENTITY_ID, - .type = ENTITY_TYPE_PLAYER, - .x = WORLD_PLAYER_SPAWN_X, - .y = WORLD_PLAYER_SPAWN_Y, - }; - - entityLoad(ent, &playerEntityData); - inventoryInit(&PLAYER_INVENTORY, INVENTORY_SIZE_MAX); -} - -void playerEntityLoad(entity_t *entity, const entity_t *source) { - assertNotNull(entity, "Entity pointer cannot be NULL"); - assertNotNull(source, "Source entity pointer cannot be NULL"); - assertTrue(entity->type == ENTITY_TYPE_PLAYER, "Entity type must be PLAYER"); - assertTrue(source->type == entity->type, "Source/Entity type mismatch"); -} - -void playerEntityUpdate(entity_t *entity) { - assertNotNull(entity, "Entity pointer cannot be NULL"); - assertTrue(entity->type == ENTITY_TYPE_PLAYER, "Entity type must be PLAYER"); - - // TODO: make this just a method somewhere. - if(UI_TEXTBOX.visible) return; - if(entityIsMoving(entity)) return; - - const uint8_t moveSpeed = inputIsDown(INPUT_BIND_CANCEL) ? PLAYER_SPEED_RUN : PLAYER_SPEED_WALK; - - if(inputIsDown(INPUT_BIND_UP)) { - if(entity->dir != DIRECTION_NORTH) { - entityTurn(entity, DIRECTION_NORTH); - return; - } - entityMove(entity, moveSpeed); - return; - - } else if(inputIsDown(INPUT_BIND_DOWN)) { - if(entity->dir != DIRECTION_SOUTH) { - entityTurn(entity, DIRECTION_SOUTH); - return; - } - - entityMove(entity, moveSpeed); - return; - } else if(inputIsDown(INPUT_BIND_LEFT)) { - if(entity->dir != DIRECTION_WEST) { - entityTurn(entity, DIRECTION_WEST); - return; - } - entityMove(entity, moveSpeed); - return; - - } else if(inputIsDown(INPUT_BIND_RIGHT)) { - if(entity->dir != DIRECTION_EAST) { - entityTurn(entity, DIRECTION_EAST); - return; - } - - entityMove(entity, moveSpeed); - return; - } - - // Interact - if(inputPressed(INPUT_BIND_ACTION)) { - int8_t x, y; - directionGetCoordinates(entity->dir, &x, &y); - entity_t *ent = entityGetAt(entity->x + x, entity->y + y); - - if(ent != NULL && ENTITY_CALLBACKS[ent->type].interact != NULL) { - assertTrue(ent->type < ENTITY_TYPE_COUNT, "Entity type out of bounds"); - ENTITY_CALLBACKS[ent->type].interact(entity, ent); - } - } -} \ No newline at end of file diff --git a/archive/dusk/entity/player.h b/archive/dusk/entity/player.h deleted file mode 100644 index 0780cbb..0000000 --- a/archive/dusk/entity/player.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" -#include "item/inventory.h" - -#define PLAYER_SPEED_WALK 1 -#define PLAYER_SPEED_RUN 2 - -typedef struct _entity_t entity_t; - -typedef struct { - uint32_t nothing; -} playerentity_t; - -#define PLAYER_ENTITY_ID (UINT32_MAX-1) - -extern inventory_t PLAYER_INVENTORY; - -/** - * Initializes the player and all player-related entities. - */ -void playerInit(void); - -/** - * Loads the player entity. - * - * @param entity The entity to initialize. - * @param source The source entity to copy data from. - */ -void playerEntityLoad(entity_t *entity, const entity_t *source); - -/** - * Updates the player entity. - * - * @param entity The entity to update. - */ -void playerEntityUpdate(entity_t *entity); \ No newline at end of file diff --git a/archive/dusk/error/error.c b/archive/dusk/error/error.c deleted file mode 100644 index c6371fc..0000000 --- a/archive/dusk/error/error.c +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "assert/assert.h" -#include "error.h" -#include "util/memory.h" -#include "util/string.h" - -errorret_t errorThrowImpl( - errorstate_t *state, - errorcode_t code, - const char_t *file, - const char_t *function, - const int32_t line, - const char_t *message, - ... -) { - assertNotNull(state, "Error state cannot be NULL"); - assertTrue(code != ERROR_OK, "Error code must not be OK"); - assertNotNull(file, "File cannot be NULL"); - assertNotNull(function, "Function cannot be NULL"); - assertTrue(line >= 0, "File pointer must be valid"); - assertNotNull(message, "Message cannot be NULL"); - - memoryZero(state, sizeof(errorstate_t)); - state->code = code; - - // Format args. - va_list args; - va_start(args, message); - - // Get length of formatted message - va_list argsCopy; - va_copy(argsCopy, args); - int32_t len = stringFormatVA(NULL, 0, message, argsCopy); - va_end(argsCopy); - - // Create string to hold the formatted message - state->message = (char_t *)memoryAllocate(len + 1); - stringFormatVA(state->message, len + 1, message, args); - va_end(args); - - // Format lines - len = stringFormat(NULL, 0, ERROR_LINE_FORMAT, file, line, function); - assertTrue(len >= 0, "Line formatting failed"); - state->lines = (char_t *)memoryAllocate(len + 1); - stringFormat(state->lines, len + 1, ERROR_LINE_FORMAT, file, line, function); - - return (errorret_t) { - .code = code, - .state = state - }; -} - -errorret_t errorOkImpl() { - return (errorret_t) { - .code = ERROR_OK, - .state = NULL - }; -} - -errorret_t errorChainImpl( - const errorret_t retval, - const char_t *file, - const char_t *function, - const int32_t line -) { - if (retval.code == ERROR_OK) return retval; - - assertNotNull(retval.state, "Error state cannot be NULL"); - assertNotNull(retval.state->message, "Message cannot be NULL"); - - // Create a new line string. - int32_t newLineLen = snprintf(NULL, 0, ERROR_LINE_FORMAT, file, line, function); - assertTrue(newLineLen >= 0, "Line formatting failed"); - char_t *newLine = (char_t *)memoryAllocate(newLineLen + 1); - snprintf(newLine, newLineLen + 1, ERROR_LINE_FORMAT, file, line, function); - - // Resize the existing lines to accommodate the new line - size_t existingLen = strlen(retval.state->lines); - memoryResize( - (void**)&retval.state->lines, - existingLen, - existingLen + newLineLen + 1 - ); - - // Now append the new line to the existing lines - memoryCopy( - retval.state->lines + existingLen, - newLine, - newLineLen + 1 - ); - - // Cleanup the temporary new line - memoryFree(newLine); - return retval; -} - -void errorCatch(const errorret_t retval) { - if (retval.code == ERROR_OK) return; - - assertNotNull(retval.state, "Error state cannot be NULL"); - assertNotNull(retval.state->message, "Message cannot be NULL"); - - memoryFree((void*)retval.state->message); -} - -errorret_t errorPrint(const errorret_t retval) { - if (retval.code == ERROR_OK) return retval; - - assertNotNull(retval.state, "Error state cannot be NULL"); - assertNotNull(retval.state->message, "Message cannot be NULL"); - - printf( - ERROR_PRINT_FORMAT, - retval.state->code, - retval.state->message, - retval.state->lines - ); - return retval; -} \ No newline at end of file diff --git a/archive/dusk/error/error.h b/archive/dusk/error/error.h deleted file mode 100644 index c83c7df..0000000 --- a/archive/dusk/error/error.h +++ /dev/null @@ -1,137 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" - -typedef uint8_t errorcode_t; - -typedef struct { - errorcode_t code; - char_t *message; - char_t *lines; -} errorstate_t; - -typedef struct { - errorcode_t code; - errorstate_t *state; -} errorret_t; - -static const errorcode_t ERROR_OK = 0; -static const errorcode_t ERROR_NOT_OK = 1; -static const char_t *ERROR_PRINT_FORMAT = "Error (%d): %s\n%s"; -static const char_t *ERROR_LINE_FORMAT = " at %s:%d in function %s\n"; -static errorstate_t ERROR_STATE = { - .code = ERROR_OK, - .message = NULL, - .lines = NULL -}; - -/** - * Sets the error state with the provided code and message. - * - * @param state The error state to initialize. - * @param code The error code to set. - * @param file The file where the error occurred. - * @param function The function where the error occurred. - * @param line The line number where the error occurred. - * @param message The error message. - * @param args The arguments for the error message. - * @return The error code. - */ -errorret_t errorThrowImpl( - errorstate_t *state, - errorcode_t code, - const char_t *file, - const char_t *function, - const int32_t line, - const char_t *message, - ... -); - -/** - * Returns an error state with no error. - * - * @return An error state with code ERROR_OK. - */ -errorret_t errorOkImpl(); - -/** - * Chains an error state, allowing for error propagation. - * - * @param retval The return value containing the error state. - * @param file The file where the error occurred. - * @param function The function where the error occurred. - * @param line The line number where the error occurred. - * @return The error code if an error occurred, otherwise continues execution. - */ -errorret_t errorChainImpl( - const errorret_t retval, - const char_t *file, - const char_t *function, - const int32_t line -); - -/** - * Catches an error and handles it. - * - * @param retval The return value containing the error state. - */ -void errorCatch(const errorret_t retval); - -/** - * Prints the error state to the console. - * - * @param retval The return value containing the error state. - * @return Passed retval for chaining. - */ -errorret_t errorPrint(const errorret_t retval); - -/** - * Throws an error with a formatted message. - * - * @param code The error code to throw. - * @param message The format string for the error message. - * @param ... Additional arguments for the format string. - * @return The error code. - */ -#define errorThrowWithCode(code, message, ... ) \ - return errorThrowImpl(\ - &ERROR_STATE, (code), __FILE__, __func__, __LINE__, (message), \ - __VA_ARGS__ \ - ) - -/** - * Throws an error with a default error code of ERROR_NOT_OK. - * - * @param message The format string for the error message. - * @param ... Additional arguments for the format string. - * @return The error code. - */ -#define errorThrow(message, ...) \ - return errorThrowImpl(\ - &ERROR_STATE, ERROR_NOT_OK, __FILE__, __func__, __LINE__, (message), \ - __VA_ARGS__ \ - ) - -/** - * Checks if a child method errored, and if it did, then send it up the chain. - * @param retval The return value containing the error state. - * @return The error code if an error occurred, otherwise continues execution. - */ -#define errorChain(retval) \ - if ((retval).code != ERROR_OK) { \ - return errorChainImpl(retval, __FILE__, __func__, __LINE__); \ - } - -/** - * Returns without an error. - */ -#define errorOk() \ - return errorOkImpl() - -// EOF \ No newline at end of file diff --git a/archive/dusk/event/CMakeLists.txt b/archive/dusk/event/CMakeLists.txt deleted file mode 100644 index b052311..0000000 --- a/archive/dusk/event/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - event.c - eventtext.c -) \ No newline at end of file diff --git a/archive/dusk/event/event.c b/archive/dusk/event/event.c deleted file mode 100644 index fd391c8..0000000 --- a/archive/dusk/event/event.c +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "event.h" -#include "util/memory.h" -#include "assert/assert.h" - -eventcallback_t EVENT_CALLBACKS[] = { - [EVENT_TYPE_NULL] = { NULL, NULL }, - [EVENT_TYPE_TEXT] = { eventTextStart, eventTextUpdate }, -}; - -event_t EVENT; - -void eventInit() { - memoryZero(&EVENT, sizeof(event_t)); -} - -void eventUpdate() { - if(EVENT.active == NULL) { - return; // No active event to update - } - - const eventitem_t *item = &EVENT.active->items[EVENT.item]; - assertNotNull( - EVENT_CALLBACKS[item->type].update, - "Event type does not have an update callback" - ); - - EVENT_CALLBACKS[item->type].update(item); -} - -void eventSetActive(const eventdata_t *event) { - assertNotNull(event, "Event data cannot be NULL"); - assertTrue( - event->itemCount <= EVENT_ITEM_COUNT_MAX, - "Event count too high" - ); - assertTrue(event->itemCount > 0, "Event must have at least one item"); - - EVENT.active = event; - EVENT.item = 0; - - const eventitem_t *firstItem = &EVENT.active->items[EVENT.item]; - - assertNotNull( - EVENT_CALLBACKS[firstItem->type].start, - "Event type does not have a start callback" - ); - EVENT_CALLBACKS[firstItem->type].start(firstItem); -} - -void eventNext() { - assertNotNull(EVENT.active, "No active event to proceed with"); - assertTrue(EVENT.item < EVENT.active->itemCount, "No more items in the event"); - - EVENT.item++; - if (EVENT.item >= EVENT.active->itemCount) { - EVENT.active = NULL; - return; - } - - const eventitem_t *nextItem = &EVENT.active->items[EVENT.item]; - assertNotNull( - EVENT_CALLBACKS[nextItem->type].start, - "Event type does not have a start callback" - ); - EVENT_CALLBACKS[nextItem->type].start(nextItem); -} \ No newline at end of file diff --git a/archive/dusk/event/event.h b/archive/dusk/event/event.h deleted file mode 100644 index 42ede28..0000000 --- a/archive/dusk/event/event.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "eventdata.h" - -typedef struct { - eventdata_t data; - const eventdata_t *active; - uint8_t item; -} event_t; - -typedef struct { - void (*start)(const eventitem_t *item); - void (*update)(const eventitem_t *item); -} eventcallback_t; - -extern eventcallback_t EVENT_CALLBACKS[EVENT_TYPE_COUNT]; -extern event_t EVENT; - -/** - * Initializes the event system. - */ -void eventInit(); - -/** - * Updates the active event. - */ -void eventUpdate(); - -/** - * Sets the active event. - * - * @param event The event to set as active. - */ -void eventSetActive(const eventdata_t *eventData); - -/** - * Goes to the next item in the active event. Only meant to be called by - * event items. - */ -void eventNext(); \ No newline at end of file diff --git a/archive/dusk/event/eventdata.h b/archive/dusk/event/eventdata.h deleted file mode 100644 index 75799a0..0000000 --- a/archive/dusk/event/eventdata.h +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "eventitem.h" - -typedef struct { - uint8_t itemCount; - eventitem_t items[EVENT_ITEM_COUNT_MAX]; -} eventdata_t; diff --git a/archive/dusk/event/eventitem.h b/archive/dusk/event/eventitem.h deleted file mode 100644 index 3174f31..0000000 --- a/archive/dusk/event/eventitem.h +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma ocne -#include "eventtext.h" - -typedef enum { - EVENT_TYPE_NULL = 0, - EVENT_TYPE_TEXT, -} eventtype_t; - -#define EVENT_TYPE_COUNT 2 - -typedef struct _eventitem_t { - eventtype_t type; - - union { - eventtext_t text; - }; -} eventitem_t; - -#define EVENT_ITEM_COUNT_MAX 32 \ No newline at end of file diff --git a/archive/dusk/event/eventtext.c b/archive/dusk/event/eventtext.c deleted file mode 100644 index f9eee4c..0000000 --- a/archive/dusk/event/eventtext.c +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "event.h" -#include "ui/uitextbox.h" -#include "assert/assert.h" - -void eventTextStart(const eventitem_t *item) { - assertNotNull(item, "Event item cannot be NULL"); - assertTrue(item->type == EVENT_TYPE_TEXT, "Event item must be of type TEXT"); - assertNotNull(item->text, "Event item must have at least one text"); - uiTextboxSetText(item->text); -} - -void eventTextUpdate(const eventitem_t *item) { - assertNotNull(item, "Event item cannot be NULL"); - assertTrue(item->type == EVENT_TYPE_TEXT, "Event item must be of type TEXT"); - - if(!UI_TEXTBOX.visible) { - eventNext(); - } -} \ No newline at end of file diff --git a/archive/dusk/event/eventtext.h b/archive/dusk/event/eventtext.h deleted file mode 100644 index bddb2ca..0000000 --- a/archive/dusk/event/eventtext.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" - -typedef struct _eventitem_t eventitem_t; - -#define EVENT_TEXT_STRING_COUNT_MAX 8 - -typedef const char_t* eventtext_t; - -/** - * Starts the text event for the given item. - * - * @param item The event item to start. - */ -void eventTextStart(const eventitem_t *item); - -/** - * Updates the text event for the given item. - * - * @param item The event item to update. - */ -void eventTextUpdate(const eventitem_t *item); - -/** - * Query whether the text event is done or not. - * - * @param item The event item to check. - */ -bool_t eventTextIsDone(const eventitem_t *item); \ No newline at end of file diff --git a/archive/dusk/game.c b/archive/dusk/game.c deleted file mode 100644 index e37b45a..0000000 --- a/archive/dusk/game.c +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "game.h" -#include "util/memory.h" -#include "world/chunk.h" -#include "display/scene.h" -#include "world/overworld.h" -#include "input.h" -#include "event/event.h" -#include "ui/uitextbox.h" -#include "console/console.h" -#include "util/memory.h" -#include "time.h" - -game_t GAME; - -void gameInit(void) { - memoryZero(&GAME, sizeof(game_t)); - GAME.running = true; - - timeInit(); - consoleInit(); - inputInit(); - eventInit(); - uiTextboxInit(); - sceneInit(); -} - -void gameUpdate(void) { - timeUpdate(); - - // Game logic is tied to 60FPS for now, saves me a lot of hassle with float - // issues - float_t timeSinceLastTick = TIME.time - TIME.lastTick; - while(timeSinceLastTick >= TIME_STEP) { - - sceneUpdate(); - uiTextboxUpdate(); - eventUpdate(); - inputUpdate(); - - timeSinceLastTick -= TIME_STEP; - TIME.lastTick = TIME.time; - } - - if(inputPressed(INPUT_BIND_QUIT)) consoleExec("quit"); - consoleUpdate(); -} - -void gameDispose(void) { - sceneDispose(); -} \ No newline at end of file diff --git a/archive/dusk/game.h b/archive/dusk/game.h deleted file mode 100644 index 566be6f..0000000 --- a/archive/dusk/game.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" - -typedef struct { - bool_t running; -} game_t; - -extern game_t GAME; - -/** - * Initializes the game, this should be called before any other game functions. - * This should be called by the parent platform at a time that it deems - * appropriate. Any game systems cannot be used until this function has - * been called. - * - * By the point this is called, we expect; - * - Rendering has initialized and is ready to draw. - * - Input has been initialized and is ready to be read. - * - If your system handles time dynamically, it should be ready to be used. - * - * The systems called (in order) are; - * - Console. - * - Input system (Not the platforms input, but the game's input system). - * - Time system (if applicable). - * - Event System - * - UI Systems. - * - Gameplay systems. - */ -void gameInit(void); - -/** - * Asks the game to update, this will not do any drawing and should be called - * in the main loop of the system, ideally either after or before the rendering - * has occured. - */ -void gameUpdate(void); - -/** - * Cleans up resources used by the game, rendering really should still be - * available at this point because we want to cleanup nicely. - */ -void gameDispose(void); \ No newline at end of file diff --git a/archive/dusk/input.c b/archive/dusk/input.c deleted file mode 100644 index a2a5849..0000000 --- a/archive/dusk/input.c +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "input.h" -#include "assert/assert.h" -#include "util/memory.h" - -input_t INPUT; - -void inputInit(void) { - memoryZero(&INPUT, sizeof(input_t)); -} - -void inputUpdate(void) { - INPUT.previous = INPUT.current; - INPUT.current = inputStateGet(); -} - -bool_t inputIsDown(const inputbind_t bind) { - assertTrue(bind < INPUT_BIND_COUNT, "Input bind out of bounds"); - return (INPUT.current & bind) != 0; -} - -bool_t inputWasDown(const inputbind_t bind) { - assertTrue(bind < INPUT_BIND_COUNT, "Input bind out of bounds"); - return (INPUT.previous & bind) != 0; -} - -bool_t inputPressed(const inputbind_t bind) { - return inputIsDown(bind) && !inputWasDown(bind); -} - -bool_t inputReleased(const inputbind_t bind) { - return !inputIsDown(bind) && inputWasDown(bind); -} \ No newline at end of file diff --git a/archive/dusk/input.h b/archive/dusk/input.h deleted file mode 100644 index 5dc43ba..0000000 --- a/archive/dusk/input.h +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" - -typedef uint8_t inputbind_t; -typedef inputbind_t inputstate_t; - -#define INPUT_BIND_UP (1 << 0) -#define INPUT_BIND_DOWN (1 << 1) -#define INPUT_BIND_LEFT (1 << 2) -#define INPUT_BIND_RIGHT (1 << 3) -#define INPUT_BIND_ACTION (1 << 4) -#define INPUT_BIND_CANCEL (1 << 5) -#define INPUT_BIND_CONSOLE (1 << 6) -#define INPUT_BIND_QUIT (1 << 7) - -#define INPUT_BIND_COUNT (INPUT_BIND_QUIT + 1) - -typedef struct { - uint8_t current; - uint8_t previous; -} input_t; - -extern input_t INPUT; - -/** - * Initialize the input system. - */ -void inputInit(void); - -/** - * Updates the input state. - */ -void inputUpdate(void); - -/** - * Gets the current input state as a bitmask. - * - * @return The current input state as a bitmask. - */ -inputstate_t inputStateGet(void); - -/** - * Checks if a specific input bind is currently pressed. - * - * @param bind The input bind to check. - * @return true if the bind is currently pressed, false otherwise. - */ -bool_t inputIsDown(const inputbind_t bind); - -/** - * Checks if a specific input bind was pressed in the last update. - * - * @param bind The input bind to check. - * @return true if the bind was pressed in the last update, false otherwise. - */ -bool_t inputWasDown(const inputbind_t bind); - -/** - * Checks if a specific input bind was down this frame but not in the the - * previous frame. - * - * @param bind The input bind to check. - * @return true if the bind is currently pressed, false otherwise. - */ -bool_t inputPressed(const inputbind_t bind); - -/** - * Checks if a specific input bind was released this frame. - * - * @param bind The input bind to check. - * @return true if the bind was released this frame, false otherwise. - */ -bool_t inputReleased(const inputbind_t bind); \ No newline at end of file diff --git a/archive/dusk/item/inventory.c b/archive/dusk/item/inventory.c deleted file mode 100644 index d123cf2..0000000 --- a/archive/dusk/item/inventory.c +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "inventory.h" -#include "util/memory.h" -#include "assert/assert.h" - -void inventoryInit(inventory_t *inventory, const uint8_t size) { - assertNotNull(inventory, "inventory must not be NULL"); - assertTrue(size <= INVENTORY_SIZE_MAX, "size exceeding INVENTORY_SIZE_MAX"); - assertTrue(size > 0, "size must be greater than 0"); - - memoryZero(inventory, sizeof(inventory_t)); - inventory->size = size; -} - -uint8_t inventoryItemIndexByType( - const inventory_t *inventory, - const itemtype_t type -) { - assertNotNull(inventory, "inventory must not be NULL"); - assertTrue(type > ITEM_TYPE_NULL, "type must be greater than ITEM_TYPE_NULL"); - - uint8_t item = inventory->itemCount; - while(item--) { - if(inventory->items[item].type == type) return item; - } - return INVENTORY_SIZE_MAX; -} - -uint8_t inventoryItemCount( - const inventory_t *inventory, - const itemtype_t type -) { - assertNotNull(inventory, "inventory must not be NULL"); - assertTrue(type > ITEM_TYPE_NULL, "type must be greater than ITEM_TYPE_NULL"); - - const uint8_t index = inventoryItemIndexByType(inventory, type); - if(index == INVENTORY_SIZE_MAX) return 0; - return inventory->items[index].count; -} - -void inventoryItemSet( - inventory_t *inventory, - const itemtype_t type, - const uint8_t count -) { - assertNotNull(inventory, "inventory must not be NULL"); - assertTrue(type > ITEM_TYPE_NULL, "type must be greater than ITEM_TYPE_NULL"); - assertTrue(count > 0, "count must be greater than 0"); - - const uint8_t index = inventoryItemIndexByType(inventory, type); - - if(index == INVENTORY_SIZE_MAX) { - // Item does not exist, add it - assertTrue(inventory->itemCount < inventory->size, "inventory is full"); - inventory->items[inventory->itemCount].type = type; - inventory->items[inventory->itemCount].count = count; - inventory->itemCount++; - } else { - // Item exists, update the count - inventory->items[index].count = count; - } -} \ No newline at end of file diff --git a/archive/dusk/item/inventory.h b/archive/dusk/item/inventory.h deleted file mode 100644 index 3515b96..0000000 --- a/archive/dusk/item/inventory.h +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "itemstack.h" - -#define INVENTORY_SIZE_MAX UINT8_MAX - -typedef struct { - itemstack_t items[INVENTORY_SIZE_MAX]; - uint8_t itemCount; - uint8_t size; -} inventory_t; - -/** - * Initializes an inventory with a specified size. - * - * @param inventory Pointer to the inventory to initialize. - * @param size The size of the inventory (maximum is INVENTORY_SIZE_MAX). - */ -void inventoryInit(inventory_t *inventory, const uint8_t size); - -/** - * Finds the index of the item of a specified type in the inventory. - * - * @param inventory Pointer to the inventory to search. - * @param type The type of item to find. - * @return The index of the item, or INVENTORY_SIZE_MAX if not found. - */ -uint8_t inventoryItemIndexByType( - const inventory_t *inventory, - const itemtype_t type -); - -/** - * Gets the count of items of a specified type in the inventory. - * - * @param inventory Pointer to the inventory to check. - * @param type The type of item to count. - * @return The count of items of the specified type. - */ -uint8_t inventoryItemCount( - const inventory_t *inventory, - const itemtype_t type -); - -/** - * Sets the count of items of a specified type in the inventory. - * If the item does not exist, it will be added. - * - * @param inventory Pointer to the inventory to modify. - * @param type The type of item to set. - * @param count The count of items to set. - */ -void inventoryItemSet( - inventory_t *inventory, - const itemtype_t type, - const uint8_t count -); \ No newline at end of file diff --git a/archive/dusk/item/itemstack.h b/archive/dusk/item/itemstack.h deleted file mode 100644 index b691d5d..0000000 --- a/archive/dusk/item/itemstack.h +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "itemtype.h" - -typedef struct { - itemtype_t type; - uint8_t count; -} itemstack_t; \ No newline at end of file diff --git a/archive/dusk/item/itemtype.h b/archive/dusk/item/itemtype.h deleted file mode 100644 index 3f07403..0000000 --- a/archive/dusk/item/itemtype.h +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" - -typedef enum { - ITEM_TYPE_NULL = 0, - - // MEDICINE - ITEM_TYPE_POTION, - - // INGREDIENTS - ITEM_TYPE_ONION, - ITEM_TYPE_SWEET_POTATO, - ITEM_TYPE_CARROT, - - // COOKED FOOD - ITEM_TYPE_BAKED_SWEET_POTATO, -} itemtype_t; \ No newline at end of file diff --git a/archive/dusk/locale/CMakeLists.txt b/archive/dusk/locale/CMakeLists.txt deleted file mode 100644 index ef60e6d..0000000 --- a/archive/dusk/locale/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - language.c -) \ No newline at end of file diff --git a/archive/dusk/locale/language.c b/archive/dusk/locale/language.c deleted file mode 100644 index 2c70fd1..0000000 --- a/archive/dusk/locale/language.c +++ /dev/null @@ -1,145 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "language.h" -#include "assert/assert.h" - -language_t LANGUAGE; - -void languageInit(void) { - LANGUAGE.current = LANGUAGE_EN; -} - -const char_t * languageGet(const char_t *key) { - assertNotNull(key, "Key cannot be NULL"); - assertTrue(LANGUAGE.current < LANGUAGE_COUNT, "Invalid language index"); - - int16_t keyIndex = -1; - for(uint16_t i = 0; i < LANGUAGE_COUNTS[LANGUAGE.current]; i++) { - if(strcmp(LANGUAGE_KEYS[LANGUAGE.current][i], key) != 0) continue; - keyIndex = i; - break; - } - assertTrue(keyIndex != -1, "Key not found in language"); - return LANGUAGE_VALUES[LANGUAGE.current][keyIndex]; -} - -uint16_t langaugeGetLength(const char_t *key) { - assertNotNull(key, "Key cannot be NULL"); - assertTrue(LANGUAGE.current < LANGUAGE_COUNT, "Invalid language index"); - - int16_t keyIndex = -1; - for(uint16_t i = 0; i < LANGUAGE_COUNTS[LANGUAGE.current]; i++) { - if(strcmp(LANGUAGE_KEYS[LANGUAGE.current][i], key) != 0) continue; - keyIndex = i; - break; - } - assertTrue(keyIndex != -1, "Key not found in language"); - return strlen(LANGUAGE_VALUES[LANGUAGE.current][keyIndex]); -} - -uint16_t languageFormat( - const char_t *key, - char_t *buffer, - uint16_t buffSize, - const char_t **keys, - const char_t **values, - const uint16_t valueCount -) { - if(buffer != NULL) { - assertTrue(buffSize > 0, "Buffer size must be greater than 0"); - } else { - assertTrue(buffSize == 0, "Buffer size must be 0 if buffer is NULL"); - } - - assertNotNull(key, "Key cannot be NULL"); - assertNotNull(keys, "Keys cannot be NULL"); - assertNotNull(values, "Values cannot be NULL"); - - const char_t *val = languageGet(key); - assertNotNull(val, "Value for key cannot be NULL"); - - char_t c; - uint16_t i = 0; - uint16_t j = 0; - uint8_t k = 0; - bool_t inBraces = false; - char_t braceBuffer[64] = {0}; - - #define bufferChar(c) ( \ - (buffer ? (buffer[j++] = c) : (j++)), \ - assertTrue(buffer ? j < buffSize : true, "Buffer overflow") \ - ) - - while((c = val[i++]) != '\0') { - if(c == '{' && val[i] == '{') { - goto startBraces; - } else if(c == '}' && val[i] == '}') { - goto endBraces; - } else if(inBraces) { - goto braceBuffering; - } else { - goto character; - } - - character: { - bufferChar(c); - continue; - } - - braceBuffering: { - assertFalse(val[i] == '\0', "Unexpected end of string."); - braceBuffer[k++] = c; - assertTrue(k < sizeof(braceBuffer), "Brace buffer overflow"); - if(val[i] == ' ') i++; - continue; - } - - startBraces: { - assertFalse(inBraces, "Nested braces are not allowed"); - - inBraces = true; - i++; - k = 0; - assertFalse(val[i] == '\0', "Unexpected end of string."); - if(val[i] == ' ') i++; - continue; - } - - endBraces: { - assertTrue(inBraces, "Unmatched closing brace found"); - - inBraces = false; - i++; - braceBuffer[k] = '\0'; - - uint16_t l; - for(l = 0; l < valueCount; l++) { - if(strcmp(braceBuffer, keys[l]) != 0) { - continue; - } - const char_t *replacement = values[l]; - - uint16_t r = 0; - while((c = replacement[r++]) != '\0') { - bufferChar(c); - } - break; - } - assertTrue(l < valueCount, "No string replacement found!"); - continue; - } - } - - if(buffer){ - assertTrue(j < buffSize, "Buffer overflow"); - buffer[j] = '\0'; - } - - assertFalse(inBraces, "Unmatched opening brace found"); - return j; -} \ No newline at end of file diff --git a/archive/dusk/locale/language.h b/archive/dusk/locale/language.h deleted file mode 100644 index d80d925..0000000 --- a/archive/dusk/locale/language.h +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "locale/language/languages.h" - -typedef struct { - uint8_t current; -} language_t; - -extern language_t LANGUAGE; - -/** - * Initializes the language system. - * - * This function sets up the language system, loading the default language - * and preparing any necessary resources for language handling. - */ -void languageInit(void); - -/** - * Gets a language string by its key. - * - * @param key The key for the language string. - * @return The language string associated with the key. - */ -const char_t * languageGet(const char_t *key); - -/** - * Gets the length of a language string by its key. - * - * @param key The key for the language string. - * @return The length of the language string associated with the key. - */ -uint16_t langaugeGetLength(const char_t *key); - -/** - * Formats a language string with given keys and values. - * - * This function replaces placeholders in the language string with the provided - * values based on the keys. - * - * If buffer is NULL, the function will instead calculate the length of the - * formatted string. - * - * @param key The key for the language string to format. - * @param buffer The buffer to store the formatted string. - * @param buffSize The size of the buffer. - * @param keys An array of keys to replace in the language string. - * @param values An array of values corresponding to the keys. - * @param valueCount The number of key-value pairs. - * @return The number of characters written to the buffer. - */ -uint16_t languageFormat( - const char_t *key, - char_t *buffer, - uint16_t buffSize, - const char_t **keys, - const char_t **values, - const uint16_t valueCount -); \ No newline at end of file diff --git a/archive/dusk/time.c b/archive/dusk/time.c deleted file mode 100644 index 0205a85..0000000 --- a/archive/dusk/time.c +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "time.h" -#include "util/memory.h" -#include "assert/assert.h" - -dusktime_t TIME; - -void timeInit(void) { - memoryZero(&TIME, sizeof(TIME)); - - // Set these to something non-zero. - TIME.lastTick = TIME_STEP; - TIME.delta = TIME.realDelta = TIME_STEP; - TIME.realTime = TIME.time = TIME_STEP * 2; -} - -void timeUpdate(void) { - TIME.realDelta = timeDeltaGet(); - - #if TIME_DYNAMIC - TIME.delta = TIME.realDelta; - #else - TIME.delta = TIME_PLATFORM_STEP; - #endif - - assertTrue(TIME.delta >= 0.0f, "Time delta is negative"); - assertTrue(TIME.realDelta >= 0.0f, "Real time delta is negative"); - - TIME.time += TIME.delta; - TIME.realTime += TIME.realDelta; -} \ No newline at end of file diff --git a/archive/dusk/time.h b/archive/dusk/time.h deleted file mode 100644 index 32c1cbb..0000000 --- a/archive/dusk/time.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" - -typedef struct { - float_t delta; - float_t lastTick; - float_t time; - float_t realDelta; - float_t realTime; -} dusktime_t; - -extern dusktime_t TIME; - -#define TIME_STEP (1.0f / 60.0f) // Default to 60FPS - -#ifndef TIME_DYNAMIC - #define TIME_DYNAMIC 1 -#endif - -#if TIME_DYNAMIC == 0 - #ifndef TIME_PLATFORM_STEP - #define TIME_PLATFORM_STEP TIME_STEP - #endif -#endif - -/** - * Initializes the time system. - */ -void timeInit(void); - -/** - * Updates the time system - */ -void timeUpdate(void); - -#if TIME_DYNAMIC == 1 - /** - * Gets the time delta since the last frame, in seconds. Tied to the - * platform. - * - * This will only get called once per gameUpdate. - */ - float_t timeDeltaGet(void); -#endif - diff --git a/archive/dusk/ui/CMakeLists.txt b/archive/dusk/ui/CMakeLists.txt deleted file mode 100644 index f01c8a4..0000000 --- a/archive/dusk/ui/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - uitextbox.c -) \ No newline at end of file diff --git a/archive/dusk/ui/font.h b/archive/dusk/ui/font.h deleted file mode 100644 index 418f1ed..0000000 --- a/archive/dusk/ui/font.h +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "ui/fontdata.h" \ No newline at end of file diff --git a/archive/dusk/ui/uitextbox.c b/archive/dusk/ui/uitextbox.c deleted file mode 100644 index aebb79a..0000000 --- a/archive/dusk/ui/uitextbox.c +++ /dev/null @@ -1,191 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "uitextbox.h" -#include "util/memory.h" -#include "assert/assert.h" -#include "input.h" - -uitextbox_t UI_TEXTBOX; - -void uiTextboxInit() { - memoryZero(&UI_TEXTBOX, sizeof(uitextbox_t)); -} - -void uiTextboxUpdate() { - if(UI_TEXTBOX.visible == false) return; - - if(UI_TEXTBOX.charsRevealed < UI_TEXTBOX.pageChars[UI_TEXTBOX.page]) { - UI_TEXTBOX.charsRevealed++; - if(inputIsDown(INPUT_BIND_ACTION)) { - UI_TEXTBOX.charsRevealed++; - } - - } else { - if(inputPressed(INPUT_BIND_ACTION)) { - if(UI_TEXTBOX.page < UI_TEXTBOX.pageCount - 1) { - UI_TEXTBOX.page++; - UI_TEXTBOX.charsRevealed = 0; - } else { - // Close the textbox - UI_TEXTBOX.visible = false; - UI_TEXTBOX.page = 0; - UI_TEXTBOX.charsRevealed = 0; - } - } - } -} - -void uiTextboxSetText(const char_t *text) { - assertNotNull(text, "Text pointer cannot be NULL, call uiTextboxClose()"); - - memoryZero(UI_TEXTBOX.text, sizeof(UI_TEXTBOX.text)); - memoryZero(UI_TEXTBOX.lineLengths, sizeof(UI_TEXTBOX.lineLengths)); - memoryZero(UI_TEXTBOX.pageChars, sizeof(UI_TEXTBOX.pageChars)); - UI_TEXTBOX.pageCount = 1;// Always at least one page. - UI_TEXTBOX.totalChars = 0; - UI_TEXTBOX.page = 0; - UI_TEXTBOX.charsRevealed = 0; - UI_TEXTBOX.visible = true; - - char_t c;// current char - uint16_t i = 0;// Index of character we are pulling - uint16_t lastWordStart = 0;// Index of the last word start (in src string). - uint8_t line = 0;// Which line we are currently writing to. - uint8_t page = 0; - bool_t startOfLine = true;// Are we at the start of a line? - - while((c = text[i++]) != '\0') { - // HARD disallowed characters. - assertTrue(c != '\r', "Carriage return characters not allowed."); - assertTrue(c != '\t', "Tab characters not allowed."); - - // Is this the beginning of a new line? - if(startOfLine) { - // Yes, we are at the start of a new line. - startOfLine = false; - // Is this the first line? - if(line == 0) { - // nothing to do, just continue. - } else { - // Yes, start of new line. Is this line the first line on a new page? - if((line % UI_TEXTBOX_LINES_PER_PAGE) == 0) { - // Yes, start a new page. - i--;// Rewind so that this character can go through the loop again. - goto newPage; - } - } - } - - // Change what we do depending on the character. - if(c == '\n') { - goto newline; - } else if(c == ' ') { - goto whitespace; - } else { - goto character; - } - - // Handle whitespace characters (not newlines) - whitespace: { - // Is this whitespace the last char of the line? - if(UI_TEXTBOX.lineLengths[line] == UI_TEXTBOX_CHARS_PER_LINE) { - goto newline; - } else if(UI_TEXTBOX.lineLengths[line] == 0) { - // If this is the first character of the line, we can just ignore it. - continue; - } - - lastWordStart = i; - goto appendCharacter; - } - - // Handle regular characters - character: { - // Is this character going to cause a wrap to occur? - if(UI_TEXTBOX.lineLengths[line] == UI_TEXTBOX_CHARS_PER_LINE) { - // How long ago was the last whitespace? - uint16_t charsSinceLastSpace = i - lastWordStart; - - // Is the word longer than a line can possibly hold? - assertTrue( - charsSinceLastSpace < UI_TEXTBOX_CHARS_PER_LINE, - "Word longer than a line can hold." - ); - - // Undo appending of all characters since the last whitespace. - UI_TEXTBOX.totalChars -= charsSinceLastSpace; - UI_TEXTBOX.lineLengths[line] -= charsSinceLastSpace; - UI_TEXTBOX.pageChars[page] -= charsSinceLastSpace; - - // Rewind the loop so that printing will begin on the new line at the - // start of the last word. - i -= charsSinceLastSpace; - - // Newline. - goto newline; - } - - // Append the character to the textbox. - goto appendCharacter; - } - - // Handle newlines - newline: { - // Ensure we don't exceed the maximum number of lines. - assertTrue( - line < UI_TEXTBOX_LINE_COUNT, - "Exceeded maximum number of lines in textbox." - ); - - // Add a line to the textbox. - line++; - startOfLine = true;// Next iteration will be a start of line. - lastWordStart = i;// We also mark this as the last word start. - continue; - } - - newPage: { - // Make sure we don't exceed the maximum number of pages. - assertTrue( - UI_TEXTBOX.pageCount < UI_TEXTBOX_PAGE_COUNT_MAX, - "Exceeded maximum number of pages in textbox." - ); - UI_TEXTBOX.pageCount++; - page++; - continue; - } - - appendCharacter: { - assertTrue( - UI_TEXTBOX.totalChars < UI_TEXTBOX_CHARS_MAX, - "Exceeded maximum number of characters in textbox." - ); - assertTrue( - line < UI_TEXTBOX_LINE_COUNT, - "Exceeded maximum number of lines in textbox." - ); - assertTrue( - UI_TEXTBOX.lineLengths[line] < UI_TEXTBOX_CHARS_PER_LINE, - "Exceeded maximum number of chars per line in textbox." - ); - - // Push the character to the textbox. - UI_TEXTBOX.text[ - line * UI_TEXTBOX_CHARS_PER_LINE + UI_TEXTBOX.lineLengths[line] - ] = c; - - // Increment the line length and page character count. - UI_TEXTBOX.totalChars++; - UI_TEXTBOX.lineLengths[line]++; - UI_TEXTBOX.pageChars[page]++; - continue; - } - - assertUnreachable("Code should not reach here, all cases handled."); - } -} \ No newline at end of file diff --git a/archive/dusk/ui/uitextbox.h b/archive/dusk/ui/uitextbox.h deleted file mode 100644 index 40ad790..0000000 --- a/archive/dusk/ui/uitextbox.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "display/renderbase.h" -#include "ui/font.h" - -#define UI_TEXTBOX_LINES_PER_PAGE 4 -#define UI_TEXTBOX_WIDTH RENDER_WIDTH -#define UI_TEXTBOX_HEIGHT_INNER ( \ - FONT_TILE_HEIGHT * UI_TEXTBOX_LINES_PER_PAGE \ -) - -#define UI_TEXTBOX_BORDER_WIDTH 4 -#define UI_TEXTBOX_BORDER_HEIGHT UI_TEXTBOX_BORDER_WIDTH -#define UI_TEXTBOX_PADDING_X 2 -#define UI_TEXTBOX_PADDING_Y UI_TEXTBOX_PADDING_X -#define UI_TEXTBOX_WIDTH_INNER ( \ - UI_TEXTBOX_WIDTH - (UI_TEXTBOX_BORDER_WIDTH * 2) - \ - (UI_TEXTBOX_PADDING_X * 2) \ -) -#define UI_TEXTBOX_HEIGHT ( \ - UI_TEXTBOX_HEIGHT_INNER + (UI_TEXTBOX_BORDER_HEIGHT * 2) + \ - (UI_TEXTBOX_PADDING_Y * 2) \ -) - -#define UI_TEXTBOX_CHARS_PER_LINE (UI_TEXTBOX_WIDTH_INNER / FONT_TILE_WIDTH) -#define UI_TEXTBOX_CHARS_PER_PAGE ( \ - UI_TEXTBOX_CHARS_PER_LINE * UI_TEXTBOX_LINES_PER_PAGE \ -) -#define UI_TEXTBOX_PAGE_COUNT_MAX 6 -#define UI_TEXTBOX_LINE_COUNT ( \ - UI_TEXTBOX_LINES_PER_PAGE * UI_TEXTBOX_PAGE_COUNT_MAX \ -) -#define UI_TEXTBOX_CHARS_MAX ( \ - UI_TEXTBOX_CHARS_PER_PAGE * UI_TEXTBOX_PAGE_COUNT_MAX \ -) - -#define UI_TEXTBOX_REVEAL_RATE 2 - -typedef struct { - char_t text[UI_TEXTBOX_CHARS_MAX]; - uint8_t lineLengths[UI_TEXTBOX_LINE_COUNT]; - uint8_t pageCount; - uint8_t pageChars[UI_TEXTBOX_PAGE_COUNT_MAX]; - uint16_t totalChars; - - uint8_t page; - uint8_t charsRevealed; - - bool_t visible; -} uitextbox_t; - -extern uitextbox_t UI_TEXTBOX; - -/** - * Initializes the UI textbox. - */ -void uiTextboxInit(void); - -/** - * Updates the UI textbox, handling text input and scrolling. - */ -void uiTextboxUpdate(void); - -/** - * Sets the text for the UI textbox. - * - * @param text The text to display in the textbox. - */ -void uiTextboxSetText( - const char_t *text -); \ No newline at end of file diff --git a/archive/dusk/util/CMakeLists.txt b/archive/dusk/util/CMakeLists.txt deleted file mode 100644 index 75b1187..0000000 --- a/archive/dusk/util/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - memory.c - string.c - math.c -) \ No newline at end of file diff --git a/archive/dusk/util/math.c b/archive/dusk/util/math.c deleted file mode 100644 index ac538d1..0000000 --- a/archive/dusk/util/math.c +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "math.h" - -uint32_t mathNextPowTwo(uint32_t value) { - if (value == 0) return 1; // Handle zero case - value--; - value |= value >> 1; - value |= value >> 2; - value |= value >> 4; - value |= value >> 8; - value |= value >> 16; - return value + 1; -} \ No newline at end of file diff --git a/archive/dusk/util/math.h b/archive/dusk/util/math.h deleted file mode 100644 index ac9bc07..0000000 --- a/archive/dusk/util/math.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" - -/** - * Finds the next power of two greater than or equal to the given value. - * - * @param value The value to find the next power of two for. - * @return The next power of two greater than or equal to the value. - */ -uint32_t mathNextPowTwo(uint32_t value); \ No newline at end of file diff --git a/archive/dusk/util/memory.c b/archive/dusk/util/memory.c deleted file mode 100644 index 3e0fea8..0000000 --- a/archive/dusk/util/memory.c +++ /dev/null @@ -1,96 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "memory.h" -#include "assert/assert.h" - -void * memoryAllocate(const size_t size) { - assertTrue(size > 0, "Cannot allocate 0 bytes of memory."); - void *ptr = malloc(size); - assertNotNull(ptr, "Memory allocation failed."); - return ptr; -} - -void memoryFree(void *ptr) { - assertNotNull(ptr, "Cannot free NULL memory."); - free(ptr); -} - - -void memoryCopy(void *dest, const void *src, const size_t size) { - assertNotNull(dest, "Cannot copy to NULL memory."); - assertNotNull(src, "Cannot copy from NULL memory."); - assertTrue(size > 0, "Cannot copy 0 bytes of memory."); - assertTrue(dest != src, "Cannot copy memory to itself."); - memcpy(dest, src, size); -} - -void memorySet(void *dest, const uint8_t value, const size_t size) { - assertNotNull(dest, "Cannot set NULL memory."); - assertTrue(size > 0, "Cannot set 0 bytes of memory."); - memset(dest, value, size); -} - -void memoryZero(void *dest, const size_t size) { - memorySet(dest, 0, size); -} - -void memoryCopyRangeSafe( - void *dest, - const void *start, - const void *end, - const size_t sizeMax -) { - assertFalse(start == end, "Start and end pointers are the same."); - assertTrue(end > start, "End pointer is not after start pointer."); - - size_t copy = (size_t)end - (size_t)start; - assertTrue(copy <= sizeMax, "Size of memory to copy is too large."); - memoryCopy(dest, start, copy); -} - -void memoryMove(void *dest, const void *src, const size_t size) { - assertNotNull(dest, "Cannot move to NULL memory."); - assertNotNull(src, "Cannot move from NULL memory."); - assertTrue(size > 0, "Cannot move 0 bytes of memory."); - assertTrue(dest != src, "Cannot move memory to itself."); - memmove(dest, src, size); -} - -int_t memoryCompare( - const void *a, - const void *b, - const size_t size -) { - assertNotNull(a, "Cannot compare NULL memory."); - assertNotNull(b, "Cannot compare NULL memory."); - assertTrue(size > 0, "Cannot compare 0 bytes of memory."); - return memcmp(a, b, size); -} - -void memoryReallocate(void **ptr, const size_t size) { - assertNotNull(ptr, "Cannot reallocate NULL pointer."); - assertTrue(size > 0, "Cannot reallocate to 0 bytes of memory."); - void *newPointer = memoryAllocate(size); - assertNotNull(newPointer, "Memory reallocation failed."); - memoryFree(*ptr); - *ptr = newPointer; -} - -void memoryResize(void **ptr, const size_t oldSize, const size_t newSize) { - assertNotNull(ptr, "Cannot resize NULL pointer."); - if(newSize == oldSize) return; - if(oldSize == 0) return memoryReallocate(ptr, newSize); - - assertTrue(newSize > oldSize, "New size must be greater than old size."); - - void *newPointer = memoryAllocate(newSize); - assertNotNull(newPointer, "Memory resizing failed."); - memoryCopy(newPointer, *ptr, oldSize); - memoryFree(*ptr); - *ptr = newPointer; -} \ No newline at end of file diff --git a/archive/dusk/util/memory.h b/archive/dusk/util/memory.h deleted file mode 100644 index 1e08137..0000000 --- a/archive/dusk/util/memory.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" - -/** - * Allocates memory. - * - * @param size The size of the memory to allocate. - * @return The allocated memory. - */ -void * memoryAllocate(const size_t size); - -/** - * Frees memory. - * - * @param ptr The memory to free. - */ -void memoryFree(void *ptr); - -/** - * Copies memory. - * - * @param dest The destination to copy to. - * @param src The source to copy from. - * @param size The size of the memory to copy. - */ -void memoryCopy(void *dest, const void *src, const size_t size); - -/** - * Sets memory. - * - * @param dest The destination to set. - * @param value The value to set. - * @param size The size of the memory to set. - */ -void memorySet(void *dest, const uint8_t value, const size_t size); - -/** - * Zeroes memory. - * - * @param dest The destination to zero. - * @param size The size of the memory to zero. - */ -void memoryZero(void *dest, const size_t size); - -/** - * Copies memory, ensuring that the memory range is as expected, typically this - * is done if you're trying to reshape data in a buffer. Extremely useful in - * copying data to a shader buffer. - * - * @param dest The destination to copy to. - * @param start The start of the source to copy from. - * @param end The end of the source to copy from. - * @param sizeMax The maximum size of the memory to copy. - */ -void memoryCopyRangeSafe( - void *dest, - const void *start, - const void *end, - const size_t sizeMax -); - -/** - * Moves memory. - * - * @param dest The destination to move to. - * @param src The source to move from. - * @param size The size of the memory to move. - */ -void memoryMove(void *dest, const void *src, const size_t size); - -/** - * Compares memory. - * - * @param a The first memory to compare. - * @param b The second memory to compare. - * @param size The size of the memory to compare. - * @return 0 if the memory is equal, < 0 if a < b, > 0 if a > b. - */ -int_t memoryCompare( - const void *a, - const void *b, - const size_t size -); - -/** - * Reallocates memory. - * - * @param ptr The pointer to the memory to reallocate. - * @param size The new size of the memory. - */ -void memoryReallocate(void **ptr, const size_t size); - -/** - * Reallocates memory, but copies existing data to the new memory. - * - * @param ptr The pointer to the memory to resize. - * @param oldSize The old size of the memory. - * @param newSize The new size of the memory. - */ -void memoryResize(void **ptr, const size_t oldSize, const size_t newSize); \ No newline at end of file diff --git a/archive/dusk/util/string.c b/archive/dusk/util/string.c deleted file mode 100644 index 264a158..0000000 --- a/archive/dusk/util/string.c +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "string.h" -#include "assert/assert.h" -#include "util/memory.h" - -bool_t stringIsWhitespace(const char_t c) { - return isspace(c); -} - -void stringCopy(char_t *dest, const char_t *src, const size_t destSize) { - assertNotNull(dest, "dest must not be NULL"); - assertNotNull(src, "src must not be NULL"); - assertTrue(destSize > 0, "destSize must be greater than 0"); - assertStrLenMax(src, destSize, "src is too long"); - memoryCopy(dest, src, strlen(src) + 1); -} - -int stringCompare(const char_t *str1, const char_t *str2) { - assertNotNull(str1, "str1 must not be NULL"); - assertNotNull(str2, "str2 must not be NULL"); - return strcmp(str1, str2); -} - -void stringTrim(char_t *str) { - assertNotNull(str, "str must not be NULL"); - - // Trim leading whitespace - char_t *start = str; - while(stringIsWhitespace(*start)) start++; - - // Trim trailing whitespace - char_t *end = start + strlen(start) - 1; - while (end >= start && stringIsWhitespace(*end)) end--; - - // Null-terminate the string - *(end + 1) = '\0'; - - // Move trimmed string to the original buffer - if (start != str) memmove(str, start, end - start + 2); -} - -char_t * stringToken(char_t *str, const char_t *delim) { - assertNotNull(str, "str must not be NULL"); - assertNotNull(delim, "delim must not be NULL"); - return strtok(str, delim); -} - -int32_t stringFormat( - char_t *dest, - const size_t destSize, - const char_t *format, - ... -) { - va_list args; - va_start(args, format); - int32_t len = stringFormatVA(dest, destSize, format, args); - va_end(args); - return len; -} - -int32_t stringFormatVA( - char_t *dest, - const size_t destSize, - const char_t *format, - const va_list args -) { - assertNotNull(format, "format must not be NULL"); - - if(dest == NULL) { - int32_t ret = vsnprintf(NULL, 0, format, args); - assertTrue(ret >= 0, "Failed to format string."); - return ret; - } - - assertTrue(destSize > 0, "destSize must be greater than 0"); - int32_t ret = vsnprintf(dest, destSize, format, args); - assertTrue(ret >= 0, "Failed to format string."); - assertTrue(ret < destSize, "Formatted string is too long."); - return ret; -} - -bool_t stringToI32(const char_t *str, int32_t *out) { - assertNotNull(str, "str must not be NULL"); - assertNotNull(out, "out must not be NULL"); - - char_t *endptr; - errno = 0; - long int result = strtol(str, &endptr, 10); - if (errno != 0 || *endptr != '\0') { - return false; - } - *out = (int32_t)result; - return true; -} - -bool_t stringToI64(const char_t *str, int64_t *out) { - assertNotNull(str, "str must not be NULL"); - assertNotNull(out, "out must not be NULL"); - - char_t *endptr; - errno = 0; - long long int result = strtoll(str, &endptr, 10); - if (errno != 0 || *endptr != '\0') { - return false; - } - *out = (int64_t)result; - return true; -} - -bool_t stringToU16(const char_t *str, uint16_t *out) { - assertNotNull(str, "str must not be NULL"); - assertNotNull(out, "out must not be NULL"); - - char_t *endptr; - errno = 0; - unsigned long int result = strtoul(str, &endptr, 10); - if (errno != 0 || *endptr != '\0' || result > UINT16_MAX) { - return false; - } - *out = (uint16_t)result; - return true; -} \ No newline at end of file diff --git a/archive/dusk/util/string.h b/archive/dusk/util/string.h deleted file mode 100644 index 77c5fb0..0000000 --- a/archive/dusk/util/string.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" - -/** - * Determines if a character is whitespace. - * - * @param c The character to check. - * @return TRUE if the character is whitespace, FALSE otherwise. - */ -bool_t stringIsWhitespace(const char_t c); - -/** - * Copies a string from src to dest, ensuring the dest string is null-terminated - * and does not exceed the specified size. - * - * @param dest The destination string. - * @param src The source string. - * @param destSize The size of the destination string exc. null terminator. - */ -void stringCopy(char_t *dest, const char_t *src, const size_t destSize); - -/** - * Compares two strings. - * - * @param str1 The first string. - * @param str2 The second string. - * @return 0 if the strings are equal, -1 if str1 is less than str2, 1 if str1 - * is greater than str2. - */ -int stringCompare(const char_t *str1, const char_t *str2); - -/** - * Trims whitespace from the beginning and end of a string. - * - * @param str The string to trim. - */ -void stringTrim(char_t *str); - -/** - * Gets the next token in a string using a delimiter. - * e.g. input: "Hello, World, Happy Monday!" with stringToken(input, ",") will - * return "Hello" then " World" then " Happy Monday!" on each subsequent call. - * - * @param str The string to split. - * @param delim The delimiter to split by. - * @return A pointer to the next token in the string. - */ -char_t * stringToken(char_t *str, const char_t *delim); - -/** - * Formats a string. - * - * @param dest The destination string, or NULL to get the length of the - * formatted string. - * @param destSize The size of the destination string exc. null terminator, can - * be anything if dest is NULL. - * @param format The format string. - * @param ... The arguments to format. - * @return The number of characters written. - */ -int32_t stringFormat( - char_t *dest, - const size_t destSize, - const char_t *format, - ... -); - -/** - * Formats a string using a va_list. - * - * @param dest The destination string, or NULL to get the length of the - * formatted string. - * @param destSize The size of the destination string exc. null terminator, can - * be anything if dest is NULL. - * @param format The format string. - * @param args The va_list of arguments. - * @return The number of characters written. - */ -int32_t stringFormatVA( - char_t *dest, - const size_t destSize, - const char_t *format, - const va_list args -); - -/** - * Converts a string to an integer. - * - * @param str The string to convert. - * @param out The output integer. - * @return TRUE if the conversion was successful, FALSE otherwise. - */ -bool_t stringToI32(const char_t *str, int32_t *out); - -/** - * Converts a string to a signed 16-bit integer. - * - * @param str The string to convert. - * @param out The output signed integer. - * @return TRUE if the conversion was successful, FALSE otherwise. - */ -bool_t stringToI16(const char_t *str, int16_t *out); - -/** - * Converts a string to an unsigned 16-bit integer. - * - * @param str The string to convert. - * @param out The output unsigned integer. - * @return TRUE if the conversion was successful, FALSE otherwise. - */ -bool_t stringToU16(const char_t *str, uint16_t *out); \ No newline at end of file diff --git a/archive/dusk/world/chunk.c b/archive/dusk/world/chunk.c deleted file mode 100644 index 9bd2fbd..0000000 --- a/archive/dusk/world/chunk.c +++ /dev/null @@ -1,321 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "chunk.h" -#include "util/memory.h" -#include "assert/assert.h" -#include "world/world.h" - -void renderChunkUpdated(chunk_t *chunk); - -chunkmap_t CHUNK_MAP; - -void chunkMapInit() { - memoryZero(&CHUNK_MAP, sizeof(chunkmap_t)); - - // Load default chunks, YX order. - uint16_t i = 0; - chunk_t *chunk; - for(uint8_t y = 0; y < CHUNK_MAP_HEIGHT; y++) { - for(uint8_t x = 0; x < CHUNK_MAP_WIDTH; x++) { - assertTrue(i < CHUNK_MAP_COUNT, "Chunk index out of bounds"); - - chunk = CHUNK_MAP.chunks + i; - CHUNK_MAP.chunkOrder[i] = chunk; - - chunkLoad(chunk, x, y); - assertTrue( - chunk->x == x && chunk->y == y, - "Chunk coordinates do not match expected values" - ); - - i++; - } - } -} - -void chunkMapShift(const int16_t x, const int16_t y) { - if(x == 0 && y == 0) assertUnreachable("ChunkMapShift called with no shift"); - - chunk_t *newChunkOrder[CHUNK_MAP_COUNT]; - chunk_t *unloadedChunks[CHUNK_MAP_COUNT]; - chunk_t *chunk; - uint8_t i, j; - uint16_t - /** New Map Coordinates */ - newX, newY, - newChunkX, newChunkY - ; - - // Calculate the new map coordinates - newX = CHUNK_MAP.topLeftX + x; - newY = CHUNK_MAP.topLeftY + y; - - // Zero the new chunk order - memoryZero(newChunkOrder, sizeof(newChunkOrder)); - - // For each chunk... - j = 0; - chunk = CHUNK_MAP.chunks; - do { - // Is this chunk still going to be within the map bounds? - if( - chunk->x < newX || chunk->y < newY || - chunk->x >= newX + CHUNK_MAP_WIDTH || - chunk->y >= newY + CHUNK_MAP_HEIGHT - ) { - // No, it's not, let's unload it and make it available for reuse. - chunkUnload(chunk); - assertTrue( - j < CHUNK_MAP_COUNT, - "Unloaded chunk index out of bounds" - ); - unloadedChunks[j++] = chunk; - chunk++; - continue; - } - - // Yes it is still valid, determine the new index that it will be at - i = (chunk->y - newY) * CHUNK_MAP_WIDTH + (chunk->x - newX); - assertTrue( - i < CHUNK_MAP_COUNT, - "Chunk index out of bounds after shifting" - ); - assertNull( - newChunkOrder[i], - "New chunk order index is already occupied" - ); - - // Set the new chunk order - newChunkOrder[i] = chunk; - chunk++; - } while(chunk < CHUNK_MAP.chunks + CHUNK_MAP_COUNT); - - // Now check the new chunk order list for missing chunks. - i = 0; - do { - assertTrue( - i < CHUNK_MAP_COUNT, - "New chunk order index out of bounds after shifting" - ); - - // Is this chunk loaded still? - chunk = newChunkOrder[i]; - if(chunk != NULL) { - i++; - continue; - } - - // Determine the new chunk coordinates. - newChunkX = i % CHUNK_MAP_WIDTH + newX; - newChunkY = i / CHUNK_MAP_WIDTH + newY; - assertTrue( - newChunkX >= newX && newChunkX < newX + CHUNK_MAP_WIDTH, - "New chunk X coordinate out of bounds after shifting" - ); - assertTrue( - newChunkY >= newY && newChunkY < newY + CHUNK_MAP_HEIGHT, - "New chunk Y coordinate out of bounds after shifting" - ); - - // Pop a chunk from the unloaded chunks list. - assertTrue(j > 0, "No unloaded chunks available to reuse"); - chunk = unloadedChunks[--j]; - assertNotNull(chunk, "Unloaded chunk pointer is null"); - - // Load the chunk at the new coordinates. - chunkLoad(chunk, newChunkX, newChunkY); - assertTrue( - chunk->x == newChunkX && chunk->y == newChunkY, - "Chunk coordinates do not match expected values after shifting" - ); - - // Set it in order. - newChunkOrder[i] = chunk; - i++; - } while(i < CHUNK_MAP_COUNT); - - // Update Absolutes. - CHUNK_MAP.topLeftX = newX; - CHUNK_MAP.topLeftY = newY; - - // Update the chunk order. - memoryCopy( - CHUNK_MAP.chunkOrder, - newChunkOrder, - sizeof(CHUNK_MAP.chunkOrder) - ); -} - -void chunkMapSetPosition(const uint16_t x, const uint16_t y) { - if(x == CHUNK_MAP.topLeftX && y == CHUNK_MAP.topLeftY) { - return; - } - - int16_t shiftX = x - CHUNK_MAP.topLeftX; - int16_t shiftY = y - CHUNK_MAP.topLeftY; - - // Are we shifting the entire map? - if( - shiftX >= CHUNK_MAP_WIDTH || shiftX < -CHUNK_MAP_WIDTH || - shiftY >= CHUNK_MAP_HEIGHT || shiftY < -CHUNK_MAP_HEIGHT - ) { - printf("Shifting chunk map to new position (%u, %u)\n", x, y); - } - - // Shift the chunk map by the specified offsets. - chunkMapShift(shiftX, shiftY); -} - -chunk_t * chunkGetChunkAt(const uint16_t chunkX, const uint16_t chunkY) { - assertTrue( - chunkX < WORLD_WIDTH && chunkY < WORLD_HEIGHT, - "Chunk coordinates out of bounds" - ); - - chunk_t *chunk = CHUNK_MAP.chunks; - do { - if(chunk->x == chunkX && chunk->y == chunkY) return chunk; - chunk++; - } while(chunk < CHUNK_MAP.chunks + CHUNK_MAP_COUNT); - return NULL; -} - -void chunkLoad(chunk_t *chunk, const uint16_t x, const uint16_t y) { - assertNotNull(chunk, "Chunk pointer is null"); - - // Zero out the chunk data. - memoryZero(chunk, sizeof(chunk_t)); - - // Set the chunk coordinates. - chunk->x = x; - chunk->y = y; - - // Only load data if the chunk is within bounds. - if(x >= WORLD_WIDTH || y >= WORLD_HEIGHT) { - memorySet(chunk->tilesBase, 0, sizeof(chunk->tilesBase)); - memorySet(chunk->tilesBaseOverlay, 0, sizeof(chunk->tilesBaseOverlay)); - return; - } - - // Is chunk data defined? - const chunkdata_t *chunkData = WORLD_CHUNKS[y * WORLD_WIDTH + x]; - if(chunkData == NULL) { - memorySet(chunk->tilesBase, 0, sizeof(chunk->tilesBase)); - memorySet(chunk->tilesBaseOverlay, 0, sizeof(chunk->tilesBaseOverlay)); - return; - } - - // Load tile data into chunk - // printf("Loading chunk at (%u, %u)\n", x, y); - memoryCopy( - chunk->tilesBase, - chunkData->layerBase, - sizeof(chunk->tilesBase) - ); - memoryCopy( - chunk->tilesBaseOverlay, - chunkData->layerBaseOverlay, - sizeof(chunk->tilesBaseOverlay) - ); - - // Load chunk entities - const entity_t *data; - entity_t *entity; - data = chunkData->entities; - while(data < chunkData->entities + CHUNK_ENTITY_COUNT_MAX) { - if(data->type == ENTITY_TYPE_NULL) break; - - // Store that this chunk owns this entity ID. - chunk->entityIDs[chunk->entityCount++] = data->id; - - // Check entity isn't loaded (still). - entity = ENTITIES; - do { - if(entity->type != ENTITY_TYPE_NULL && entity->id == data->id) break; - entity++; - } while(entity < ENTITIES + ENTITY_COUNT_MAX); - - if(entity != ENTITIES + ENTITY_COUNT_MAX) { - // Entity is already loaded, skip it. - printf("Entity ID %u already loaded, skipping...\n", data->id); - data++; - continue; - } - - // Find an empty entity slot. - entity = ENTITIES; - while(true) { - assertTrue( - entity < ENTITIES + ENTITY_COUNT_MAX, - "Out of available entities" - ); - - if(entity->type == ENTITY_TYPE_NULL) break; - entity++; - }; - - // Load this entity. - entityLoad(entity, data); - data++; - } - - // Allow the rendering platform to know this chunk is loaded. - renderChunkUpdated(chunk); -} - -void chunkUnload(chunk_t *chunk) { - uint8_t i; - entity_t *entity; - uint32_t id; - assertNotNull(chunk, "Chunk pointer is null"); - - // Iterate over each entity this chunk owns. - i = 0; - while(i < chunk->entityCount) { - id = chunk->entityIDs[i++]; - - // Now, do we need to unload this entity? - bool_t shouldUnload = false; - - // Now, find the entity loaded with this ID. It should be impossible for - // this entity to be unloaded (but may change in future). - entity = ENTITIES; - do { - if(entity->type != ENTITY_TYPE_NULL && entity->id == id) break; - entity++; - } while(entity < ENTITIES + ENTITY_COUNT_MAX); - - assertTrue( - entity < ENTITIES + ENTITY_COUNT_MAX, - "Entity ID not found in ENTITIES array, cannot unload" - ); - - // If the entity is still within our chunk bounds, it's getting unloaded - if( - floorf(entity->x) >= chunk->x * CHUNK_WIDTH * TILE_WIDTH_HEIGHT && - ceilf(entity->x) < (chunk->x + 1) * CHUNK_WIDTH * TILE_WIDTH_HEIGHT && - floorf(entity->y) >= chunk->y * CHUNK_HEIGHT * TILE_WIDTH_HEIGHT && - ceilf(entity->y) < (chunk->y + 1) * CHUNK_HEIGHT * TILE_WIDTH_HEIGHT - ) { - shouldUnload = true; - } else { - assertUnreachable( - "Entity has left its chunk bounds, we should not be unloading it but " - "I have yet to implement that properly. It will need to self-manage " - "its own unloading somehow, and also not be in a null chunk " - "when it does so." - ); - } - - // This entity is still in use, leave it loaded. - if(!shouldUnload) continue; - - // NULL the entity type, effectively unloading it. - entity->type = ENTITY_TYPE_NULL; - } -} \ No newline at end of file diff --git a/archive/dusk/world/chunk.h b/archive/dusk/world/chunk.h deleted file mode 100644 index c2bcf36..0000000 --- a/archive/dusk/world/chunk.h +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "tile.h" -#include "display/render.h" - -#define CHUNK_WIDTH 8 -#define CHUNK_HEIGHT 8 -#define CHUNK_TILE_COUNT (CHUNK_WIDTH * CHUNK_HEIGHT) -#define CHUNK_ENTITY_COUNT_MAX 8 - -#define CHUNK_MAP_WIDTH (((RENDER_WIDTH / TILE_WIDTH_HEIGHT)/CHUNK_WIDTH)+2) -#define CHUNK_MAP_HEIGHT (((RENDER_HEIGHT / TILE_WIDTH_HEIGHT)/CHUNK_HEIGHT)+2) -#define CHUNK_MAP_COUNT (CHUNK_MAP_WIDTH * CHUNK_MAP_HEIGHT) - -typedef struct { - uint16_t x, y; - tile_t tilesBase[CHUNK_TILE_COUNT]; - tile_t tilesBaseOverlay[CHUNK_TILE_COUNT]; - uint32_t entityIDs[CHUNK_ENTITY_COUNT_MAX]; - uint8_t entityCount; -} chunk_t; - -typedef struct { - chunk_t chunks[CHUNK_MAP_COUNT]; - chunk_t *chunkOrder[CHUNK_MAP_COUNT]; - - uint16_t topLeftX; - uint16_t topLeftY; -} chunkmap_t; - -extern chunkmap_t CHUNK_MAP; - -/** - * Initializes the chunk map. - */ -void chunkMapInit(); - -/** - * Shifts the chunk map by the specified x and y offsets. - * - * @param x The x offset to shift the chunk map. - * @param y The y offset to shift the chunk map. - */ -void chunkMapShift(const int16_t x, const int16_t y); - -/** - * Sets the position of the chunk map to the specified coordinates. - * - * @param x The x coordinate of the top-left chunk. - * @param y The y coordinate of the top-left chunk. - */ -void chunkMapSetPosition(const uint16_t x, const uint16_t y); - -/** - * Gets the chunk at the specified chunk coordinates. - * - * @param chunkX The x coordinate of the chunk. - * @param chunkY The y coordinate of the chunk. - * @return A pointer to the chunk at the specified chunk coordinates, or NULL if - * no chunk exists at those coordinates. - */ -chunk_t * chunkGetChunkAt(const uint16_t chunkX, const uint16_t chunkY); - -/** - * Loads a chunk at the specified coordinates. - * - * @param chunk The chunk to load. - * @param x The x coordinate of the chunk. - * @param y The y coordinate of the chunk. - */ -void chunkLoad(chunk_t *chunk, const uint16_t x, const uint16_t y); - -/** - * Unloads a chunk (that is currently loaded). - * - * @param chunk The chunk to unload. - */ -void chunkUnload(chunk_t *chunk); \ No newline at end of file diff --git a/archive/dusk/world/chunkdata.h b/archive/dusk/world/chunkdata.h deleted file mode 100644 index ecd2c31..0000000 --- a/archive/dusk/world/chunkdata.h +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "chunk.h" -#include "entity/entity.h" - -typedef struct { - uint8_t layerBase[CHUNK_TILE_COUNT]; - uint8_t layerBaseOverlay[CHUNK_TILE_COUNT]; - entity_t entities[CHUNK_ENTITY_COUNT_MAX]; -} chunkdata_t; \ No newline at end of file diff --git a/archive/dusk/world/overworld.c b/archive/dusk/world/overworld.c deleted file mode 100644 index de51e28..0000000 --- a/archive/dusk/world/overworld.c +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "overworld.h" -#include "chunk.h" -#include "display/render.h" -#include "assert/assert.h" -#include "entity/entity.h" - -uint32_t OVERWORLD_CAMERA_X; -uint32_t OVERWORLD_CAMERA_Y; -overworldcameratype_t OVERWORLD_CAMERA_TYPE; - -void overworldInit(void) { - playerInit(); - chunkMapInit(); - - OVERWORLD_CAMERA_X = 0; - OVERWORLD_CAMERA_Y = 0; - OVERWORLD_CAMERA_TYPE = OVERWORLD_CAMERA_TYPE_CENTERED_POSITION; -} - -void overworldUpdate() { - entity_t *entity; - - assertTrue( - OVERWORLD_CAMERA_X < OVERWORLD_CAMERA_LIMIT_X, - "Camera position limit (just because I haven't tested properly)" - ); - assertTrue( - OVERWORLD_CAMERA_Y < OVERWORLD_CAMERA_LIMIT_Y, - "Camera position limit (just because I haven't tested properly)" - ); - - entity = ENTITIES; - do { - entityUpdate(entity++); - } while(entity->type != ENTITY_TYPE_NULL); - - // Testing, follow player - entity = &ENTITIES[0]; // Player entity - assertTrue( - entity->type == ENTITY_TYPE_PLAYER, - "First entity must be player" - ); - OVERWORLD_CAMERA_X = entity->x * TILE_WIDTH_HEIGHT + entity->subX; - OVERWORLD_CAMERA_Y = entity->y * TILE_WIDTH_HEIGHT + entity->subY; - - uint16_t x, y; - uint16_t halfWidth, halfHeight; - halfWidth = ((CHUNK_MAP_WIDTH - 1) * CHUNK_WIDTH * TILE_WIDTH_HEIGHT) / 2; - halfHeight = ((CHUNK_MAP_HEIGHT - 1) * CHUNK_HEIGHT * TILE_WIDTH_HEIGHT) / 2; - - // Calculate the chunk map position based on the camera position. - if(OVERWORLD_CAMERA_X < halfWidth) { - x = 0; - } else { - x = (OVERWORLD_CAMERA_X - halfWidth) / (CHUNK_WIDTH*TILE_WIDTH_HEIGHT); - } - - if(OVERWORLD_CAMERA_Y < halfHeight) { - y = 0; - } else { - y = (OVERWORLD_CAMERA_Y - halfHeight) / (CHUNK_HEIGHT*TILE_WIDTH_HEIGHT); - } - - chunkMapSetPosition(x, y); -} \ No newline at end of file diff --git a/archive/dusk/world/overworld.h b/archive/dusk/world/overworld.h deleted file mode 100644 index 10d7f5b..0000000 --- a/archive/dusk/world/overworld.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" - -typedef enum { - OVERWORLD_CAMERA_TYPE_CENTERED_POSITION, -} overworldcameratype_t; - -extern uint32_t OVERWORLD_CAMERA_X; -extern uint32_t OVERWORLD_CAMERA_Y; -extern overworldcameratype_t OVERWORLD_CAMERA_TYPE; - -#define OVERWORLD_CAMERA_LIMIT_X (UINT32_MAX / 4) -#define OVERWORLD_CAMERA_LIMIT_Y (UINT32_MAX / 4) - -/** - * Initializes the overworld. - */ -void overworldInit(void); - -/** - * Updates the overworld. - */ -void overworldUpdate(void); \ No newline at end of file diff --git a/archive/dusk/world/tile.h b/archive/dusk/world/tile.h deleted file mode 100644 index 1e285ea..0000000 --- a/archive/dusk/world/tile.h +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" - -#define TILE_WIDTH_HEIGHT 16 - -typedef uint8_t tile_t; - -typedef enum { - TILE_SOLID_NONE = 0, - TILE_SOLID_FULL = 1, - TILE_SOLID_TRIANGLE_TOP_RIGHT = 2, - TILE_SOLID_TRIANGLE_TOP_LEFT = 3, - TILE_SOLID_TRIANGLE_BOTTOM_RIGHT = 4, - TILE_SOLID_TRIANGLE_BOTTOM_LEFT = 5, -} tilesolidtype_t; - -typedef struct { - tilesolidtype_t solidType; -} tilemetadata_t; \ No newline at end of file diff --git a/archive/duskpsp/CMakeLists.txt b/archive/duskpsp/CMakeLists.txt deleted file mode 100644 index d7dfc0a..0000000 --- a/archive/duskpsp/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Libs -find_package(pspsdk REQUIRED) -find_package(SDL2 REQUIRED) - -target_link_libraries(${DUSK_TARGET_NAME} - PRIVATE - # pspsdk - ${SDL2_LIBRARIES} -) - -# Compile definitions -target_compile_definitions(${DUSK_TARGET_NAME} - PRIVATE - RENDER_WIDTH=480 - RENDER_HEIGHT=272 - RENDER_WINDOW_WIDTH_DEFAULT=480 - RENDER_WINDOW_HEIGHT_DEFAULT=272 - # DUSK_TIME_DYNAMIC=0 - DUSK_TIME_DYNAMIC=1 -) - -# Includes -target_include_directories(${DUSK_TARGET_NAME} - PRIVATE - ${CMAKE_CURRENT_LIST_DIR} - ${SDL2_INCLUDE_DIRS} -) - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - duskpsp.c -) - -# Subdirs \ No newline at end of file diff --git a/archive/duskpsp/duskpsp.c b/archive/duskpsp/duskpsp.c deleted file mode 100644 index bf5f011..0000000 --- a/archive/duskpsp/duskpsp.c +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "duskpsp.h" - -// PSP_MODULE_INFO("Dusk", 0, 1, 0); -// PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER | THREAD_ATTR_VFPU); \ No newline at end of file diff --git a/archive/duskpsp/duskpsp.h b/archive/duskpsp/duskpsp.h deleted file mode 100644 index c60c3d0..0000000 --- a/archive/duskpsp/duskpsp.h +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" -#include -#include -#include -#include \ No newline at end of file diff --git a/archive/dusksdl2/CMakeLists.txt b/archive/dusksdl2/CMakeLists.txt deleted file mode 100644 index c60259c..0000000 --- a/archive/dusksdl2/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Compile defs -target_compile_definitions(${DUSK_TARGET_NAME} - PUBLIC - # DUSK_KEYBOARD_SUPPORT=1 -) - -# Libs -find_package(SDL2 REQUIRED) -find_package(OpenGL REQUIRED) -find_package(cglm REQUIRED) - -target_link_libraries(${DUSK_TARGET_NAME} - PUBLIC - SDL2::SDL2 - OpenGL::GL - GL - cglm -) - - -# Includes -target_include_directories(${DUSK_TARGET_NAME} - PUBLIC - ${CMAKE_CURRENT_LIST_DIR} -) - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - dusksdl2input.c - main.c - time.c -) - -# Subdirs -add_subdirectory(display) \ No newline at end of file diff --git a/archive/dusksdl2/display/CMakeLists.txt b/archive/dusksdl2/display/CMakeLists.txt deleted file mode 100644 index f705193..0000000 --- a/archive/dusksdl2/display/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - render.c - renderbackbuffer.c -) - -# Subdirs -add_subdirectory(camera) -add_subdirectory(framebuffer) -add_subdirectory(mesh) -add_subdirectory(overworld) -add_subdirectory(texture) -add_subdirectory(spritebatch) -add_subdirectory(scene) -add_subdirectory(ui) \ No newline at end of file diff --git a/archive/dusksdl2/display/camera/CMakeLists.txt b/archive/dusksdl2/display/camera/CMakeLists.txt deleted file mode 100644 index c638530..0000000 --- a/archive/dusksdl2/display/camera/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - camera.c -) \ No newline at end of file diff --git a/archive/dusksdl2/display/camera/camera.c b/archive/dusksdl2/display/camera/camera.c deleted file mode 100644 index 2843e6b..0000000 --- a/archive/dusksdl2/display/camera/camera.c +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "camera.h" -#include "display/render.h" - -#include "world/overworld.h" - -void cameraUIPush(void) { - glPushMatrix(); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - glViewport(0, 0, RENDER_WIDTH, RENDER_HEIGHT); - - mat4 ortho; - glm_ortho( - 0.0f, (float_t)RENDER_WIDTH, - (float_t)RENDER_HEIGHT, 0.0f, - -1.0f, 1.0f, - ortho - ); - glLoadMatrixf((const GLfloat*)ortho); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -void cameraUIPop(void) { - glPopMatrix(); -} - -void cameraScreenPush(void) { - glPushMatrix(); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - mat4 ortho; - #if RENDER_USE_FRAMEBUFFER - int32_t windowWidth, windowHeight; - SDL_GetWindowSize(RENDER_WINDOW, &windowWidth, &windowHeight); - - glViewport(0, 0, windowWidth, windowHeight); - glm_ortho( - 0.0f, (float_t) windowWidth, - (float_t)windowHeight, 0.0f, - -1.0f, 1.0f, - ortho - ); - #else - glm_ortho( - 0.0f, (float_t)RENDER_WIDTH, - (float_t)RENDER_HEIGHT, 0.0f, - -1.0f, 1.0f, - ortho - ); - #endif - glLoadMatrixf((const GLfloat*)ortho); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -void cameraScreenPop(void) { - glPopMatrix(); -} - -void cameraOverworldPush(void) { - glPushMatrix(); - glLoadIdentity(); - - #if RENDER_USE_FRAMEBUFFER - glViewport(0, 0, RENDER_WIDTH, RENDER_HEIGHT); - #endif - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - const float_t fov = glm_rad(75.0f); - const float_t camOffset = 12.0f; - const float_t aspect = (float_t)RENDER_WIDTH / (float_t)RENDER_HEIGHT; - const float_t pixelPerfectOffset = ( - tanf((glm_rad(180) - fov) / 2.0f) * - ((float_t)RENDER_HEIGHT/ 2.0f) - ); - - vec3 look = { - OVERWORLD_CAMERA_X, - OVERWORLD_CAMERA_Y, - 0.0f - }; - vec3 eye = { - look[0], - look[1] + camOffset, - look[2] + pixelPerfectOffset - }; - vec3 up = { 0.0f, 1.0f, 0.0f }; - - mat4 proj; - glm_perspective(fov, aspect, 0.1f, 1000.0f, proj); - - // Flips rendering on the Y axis, so that it is still right-down even in 3D; - proj[1][1] = -proj[1][1]; - - mat4 view; - glm_lookat(eye, look, up, view); - - mat4 pv; - glm_mat4_mul(proj, view, pv); - - glLoadMatrixf((const GLfloat*)pv); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -void cameraOverworldPop(void) { - glPopMatrix(); -} \ No newline at end of file diff --git a/archive/dusksdl2/display/camera/camera.h b/archive/dusksdl2/display/camera/camera.h deleted file mode 100644 index 5547f25..0000000 --- a/archive/dusksdl2/display/camera/camera.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusksdl2.h" - -/** - * Pushes the UI camera matrix onto the stack. - */ -void cameraUIPush(void); - -/** - * Pops the UI camera matrix from the stack. - */ -void cameraUIPop(void); - -/** - * Pushes the screen space camera matrix onto the stack. - */ -void cameraScreenPush(void); - -/** - * Pops the screen space camera matrix. - */ -void cameraScreenPop(void); - -/** - * Pushes the overworld camera matrix onto the stack. - */ -void cameraOverworldPush(void); - -/** - * Pops the overworld camera matrix. - */ -void cameraOverworldPop(void); \ No newline at end of file diff --git a/archive/dusksdl2/display/framebuffer/CMakeLists.txt b/archive/dusksdl2/display/framebuffer/CMakeLists.txt deleted file mode 100644 index 9f0656b..0000000 --- a/archive/dusksdl2/display/framebuffer/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - framebuffer.c -) \ No newline at end of file diff --git a/archive/dusksdl2/display/framebuffer/framebuffer.c b/archive/dusksdl2/display/framebuffer/framebuffer.c deleted file mode 100644 index cdd9e5a..0000000 --- a/archive/dusksdl2/display/framebuffer/framebuffer.c +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "framebuffer.h" -#include "assert/assert.h" -#include "util/memory.h" - -#if RENDER_USE_FRAMEBUFFER - void frameBufferInit( - framebuffer_t *framebuffer, - const uint32_t width, - const uint32_t height - ) { - assertNotNull(framebuffer, "Framebuffer cannot be NULL"); - assertTrue(width > 0 && height > 0, "Width & height must be greater than 0"); - - memoryZero(framebuffer, sizeof(framebuffer_t)); - textureInit(&framebuffer->texture, width, height, GL_RGBA, NULL); - - // Generate the framebuffer object using EXT - glGenFramebuffersEXT(1, &framebuffer->id); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer->id); - - // Attach the texture to the framebuffer - glFramebufferTexture2DEXT( - GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, - GL_TEXTURE_2D, framebuffer->texture.id, 0 - ); - - // Check if the framebuffer is complete - if(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) { - assertUnreachable("Framebuffer is not complete"); - } - - // Unbind the framebuffer - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - } - - void frameBufferBind(const framebuffer_t *framebuffer) { - if(framebuffer == NULL) { - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - return; - } - - // Bind the framebuffer for rendering - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer->id); - } - - void frameBufferDispose(framebuffer_t *framebuffer) { - assertNotNull(framebuffer, "Framebuffer cannot be NULL"); - - glDeleteFramebuffersEXT(1, &framebuffer->id); - textureDispose(&framebuffer->texture); - } -#endif \ No newline at end of file diff --git a/archive/dusksdl2/display/framebuffer/framebuffer.h b/archive/dusksdl2/display/framebuffer/framebuffer.h deleted file mode 100644 index 7a59783..0000000 --- a/archive/dusksdl2/display/framebuffer/framebuffer.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "display/render.h" -#include "display/texture/texture.h" - -#if RENDER_USE_FRAMEBUFFER - typedef struct { - GLuint id; - texture_t texture; - } framebuffer_t; - - /** - * Initializes a framebuffer using EXT methods. - * - * @param framebuffer The framebuffer to initialize. - * @param width The width of the framebuffer. - * @param height The height of the framebuffer. - * @return An error code indicating success or failure. - */ - void frameBufferInit( - framebuffer_t *framebuffer, - const uint32_t width, - const uint32_t height - ); - - /** - * Binds the framebuffer for rendering using EXT methods. - * - * @param framebuffer The framebuffer to bind, or NULL to unbind. - */ - void frameBufferBind(const framebuffer_t *framebuffer); - - /** - * Disposes of the framebuffer using EXT methods. - * - * @param framebuffer The framebuffer to dispose of. - */ - void frameBufferDispose(framebuffer_t *framebuffer); -#endif \ No newline at end of file diff --git a/archive/dusksdl2/display/mesh/CMakeLists.txt b/archive/dusksdl2/display/mesh/CMakeLists.txt deleted file mode 100644 index 45708f9..0000000 --- a/archive/dusksdl2/display/mesh/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - mesh.c - quad.c - meshrenderer.c -) \ No newline at end of file diff --git a/archive/dusksdl2/display/mesh/mesh.c b/archive/dusksdl2/display/mesh/mesh.c deleted file mode 100644 index ca7fd9a..0000000 --- a/archive/dusksdl2/display/mesh/mesh.c +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "mesh.h" -#include "util/memory.h" -#include "assert/assert.h" - -#include "console/console.h" - -void meshInit( - mesh_t *mesh, - const GLenum primitiveType, - const int32_t vertexCount, - const meshvertex_t *vertices -) { - assertNotNull(mesh, "Mesh cannot be NULL"); - assertNotNull(vertices, "Vertices cannot be NULL"); - assertTrue(vertexCount > 0, "Vertex count must be greater than 0"); - - memoryZero(mesh, sizeof(mesh_t)); - - mesh->primitiveType = primitiveType; - mesh->vertexCount = vertexCount; - mesh->vertices = vertices; -} - -void meshDraw( - const mesh_t *mesh, - const int32_t vertexOffset, - const int32_t vertexCount -) { - const int32_t offset = vertexOffset == -1 ? 0 : vertexOffset; - const int32_t count = vertexCount == -1 ? mesh->vertexCount : vertexCount; - - assertNotNull(mesh, "Mesh cannot be NULL"); - assertTrue(offset >= 0, "Vertex offset must be non-negative"); - assertTrue(count >= 0, "Vertex count must be non-negative"); - assertTrue(offset + count <= mesh->vertexCount, - "Vertex offset + count must not exceed vertex count" - ); - - #if 1 - // PSP style pointer legacy OpenGL - const GLsizei stride = sizeof(meshvertex_t); - - glColorPointer( - MESH_VERTEX_COLOR_SIZE, - GL_UNSIGNED_BYTE, - stride, - (const GLvoid*)&mesh->vertices[offset].color[0] - ); - glTexCoordPointer( - MESH_VERTEX_UV_SIZE, - GL_FLOAT, - stride, - (const GLvoid*)&mesh->vertices[offset].uv[0] - ); - glVertexPointer( - MESH_VERTEX_POS_SIZE, - GL_FLOAT, - stride, - (const GLvoid*)&mesh->vertices[offset].pos[0] - ); - - glDrawArrays( - mesh->primitiveType, - 0, - count - ); - #else - #error "Need to support modern OpenGL with VAOs and VBOs" - #endif -} - -void meshDispose(mesh_t *mesh) { - assertNotNull(mesh, "Mesh cannot be NULL"); - memoryZero(mesh, sizeof(mesh_t)); -} \ No newline at end of file diff --git a/archive/dusksdl2/display/mesh/mesh.h b/archive/dusksdl2/display/mesh/mesh.h deleted file mode 100644 index b0d00fd..0000000 --- a/archive/dusksdl2/display/mesh/mesh.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2025 Dominic Masters -// -// This software is released under the MIT License. -// https://opensource.org/licenses/MIT - -#pragma once -#include "dusksdl2.h" - -#define MESH_VERTEX_COLOR_SIZE 4 -#define MESH_VERTEX_UV_SIZE 2 -#define MESH_VERTEX_POS_SIZE 3 - -typedef struct { - GLubyte color[MESH_VERTEX_COLOR_SIZE]; - GLfloat uv[MESH_VERTEX_UV_SIZE]; - GLfloat pos[MESH_VERTEX_POS_SIZE]; -} meshvertex_t; - -typedef struct { - const meshvertex_t *vertices; - int32_t vertexCount; - GLenum primitiveType; -} mesh_t; - -/** - * Initializes a mesh. - * - * @param mesh The mesh to initialize. - * @param primitiveType The OpenGL primitive type (e.g., GL_TRIANGLES). - * @param vertexCount The number of vertices in the mesh. - * @param vertices The vertex data for the mesh. - */ -void meshInit( - mesh_t *mesh, - const GLenum primitiveType, - const int32_t vertexCount, - const meshvertex_t *vertices -); - -/** - * Draws a mesh. - * - * @param mesh The mesh to draw. - * @param vertexOffset The offset in the vertex array to start drawing from. - * @param vertexCount The number of vertices to draw. If -1, draws all vertices. - */ -void meshDraw( - const mesh_t *mesh, - const int32_t vertexOffset, - const int32_t vertexCount -); - -/** - * Disposes a mesh. - * - * @param mesh The mesh to dispose. - */ -void meshDispose(mesh_t *mesh); \ No newline at end of file diff --git a/archive/dusksdl2/display/mesh/quad.c b/archive/dusksdl2/display/mesh/quad.c deleted file mode 100644 index acf02f8..0000000 --- a/archive/dusksdl2/display/mesh/quad.c +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "quad.h" -#include "assert/assert.h" - -void quadBuffer( - meshvertex_t *vertices, - const float_t minX, - const float_t minY, - const float_t maxX, - const float_t maxY, - const uint8_t r, - const uint8_t g, - const uint8_t b, - const uint8_t a, - const float_t u0, - const float_t v0, - const float_t u1, - const float_t v1 -) { - const float_t z = 0.0f; // Z coordinate for 2D rendering - assertNotNull(vertices, "Vertices cannot be NULL"); - - // First triangle - vertices[0] = (meshvertex_t) { - { r, g, b, a }, // Color - { u0, v0 }, // UV - { minX, minY, z } // Position - }; - vertices[1] = (meshvertex_t) { - { r, g, b, a }, // Color - { u1, v0 }, // UV - { maxX, minY, z } // Position - }; - vertices[2] = (meshvertex_t) { - { r, g, b, a }, // Color - { u1, v1 }, // UV - { maxX, maxY, z } // Position - }; - - // Second triangle - vertices[3] = (meshvertex_t) { - { r, g, b, a }, // Color - { u0, v0 }, // UV - { minX, minY, z } // Position - }; - vertices[4] = (meshvertex_t) { - { r, g, b, a }, // Color - { u1, v1 }, // UV - { maxX, maxY, z } // Position - }; - vertices[5] = (meshvertex_t) { - { r, g, b, a }, // Color - { u0, v1 }, // UV - { minX, maxY, z } // Position - }; -} \ No newline at end of file diff --git a/archive/dusksdl2/display/mesh/quad.h b/archive/dusksdl2/display/mesh/quad.h deleted file mode 100644 index 3ef25fb..0000000 --- a/archive/dusksdl2/display/mesh/quad.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "mesh.h" - -#define QUAD_VERTEX_COUNT 6 - -/** - * Buffers a quad into the provided vertex array. - * - * @param vertices The vertex array to buffer into. - * @param minX The minimum X coordinate of the quad. - * @param minY The minimum Y coordinate of the quad. - * @param maxX The maximum X coordinate of the quad. - * @param maxY The maximum Y coordinate of the quad. - * @param r The red color component (0-255). - * @param g The green color component (0-255). - * @param b The blue color component (0-255). - * @param a The alpha color component (0-255). - * @param u0 The U texture coordinate for the first vertex. - * @param v0 The V texture coordinate for the first vertex. - * @param u1 The U texture coordinate for the second vertex. - * @param v1 The V texture coordinate for the second vertex. - */ -void quadBuffer( - meshvertex_t *vertices, - const float_t minX, - const float_t minY, - const float_t maxX, - const float_t maxY, - const uint8_t r, - const uint8_t g, - const uint8_t b, - const uint8_t a, - const float_t u0, - const float_t v0, - const float_t u1, - const float_t v1 -); \ No newline at end of file diff --git a/archive/dusksdl2/display/overworld/CMakeLists.txt b/archive/dusksdl2/display/overworld/CMakeLists.txt deleted file mode 100644 index 2802ef1..0000000 --- a/archive/dusksdl2/display/overworld/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - renderoverworld.c -) \ No newline at end of file diff --git a/archive/dusksdl2/display/overworld/renderoverworld.c b/archive/dusksdl2/display/overworld/renderoverworld.c deleted file mode 100644 index f9cc155..0000000 --- a/archive/dusksdl2/display/overworld/renderoverworld.c +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "renderoverworld.h" -#include "util/memory.h" -#include "assert/assert.h" -#include "display/camera/camera.h" -#include "entity/entity.h" -#include "display/spritebatch/spritebatch.h" - -renderoverworld_t RENDER_OVERWORLD; - -void renderOverworldInit(void) { - memoryZero(&RENDER_OVERWORLD, sizeof(RENDER_OVERWORLD)); - - for(uint8_t i = 0; i < CHUNK_MAP_COUNT; i++) { - renderchunk_t *chunk = &RENDER_OVERWORLD.chunks[i]; - - meshInit( - &chunk->meshBase, - GL_TRIANGLES, - CHUNK_TILE_COUNT * QUAD_VERTEX_COUNT, - chunk->verticesBase - ); - - meshInit( - &chunk->meshBaseOverlay, - GL_TRIANGLES, - CHUNK_TILE_COUNT, - chunk->verticesBaseOverlay - ); - } -} - -void renderOverworldDraw(void) { - cameraOverworldPush(); - - for(uint8_t i = 0; i < CHUNK_MAP_COUNT; i++) { - renderchunk_t *chunk = &RENDER_OVERWORLD.chunks[i]; - meshDraw(&chunk->meshBase, -1, -1); - } - - for(uint8_t i = 0; i < ENTITY_COUNT_MAX; i++) { - entity_t *entity = &ENTITIES[i]; - if(entity->type == ENTITY_TYPE_NULL) continue; - - float_t x = (entity->x * TILE_WIDTH_HEIGHT) + entity->subX; - float_t y = (entity->y * TILE_WIDTH_HEIGHT) + entity->subY; - - // Draw the entity - spriteBatchPush( - NULL, - x, y, - x + TILE_WIDTH_HEIGHT, y + TILE_WIDTH_HEIGHT, - 0xFF, 0x00, 0xFF, 0XFF, - 0.0f, 0.0f, 1.0f, 1.0f - ); - } - - spriteBatchFlush(); - cameraOverworldPop(); -} - -void renderChunkUpdated(chunk_t *chunk) { - uint8_t r, g, b; - assertNotNull(chunk, "Chunk pointer is null"); - - int32_t chunkIndex = chunk - CHUNK_MAP.chunks; - assertTrue( - chunkIndex >= 0 && chunkIndex < CHUNK_MAP_COUNT, - "Chunk index out of bounds" - ); - - for(uint32_t i = 0; i < CHUNK_TILE_COUNT; i++) { - tile_t base = chunk->tilesBase[i]; - tile_t overlay = chunk->tilesBaseOverlay[i]; - - float_t posX = (i % CHUNK_WIDTH) + (chunk->x * CHUNK_WIDTH); - float_t posY = (i / CHUNK_WIDTH) + (chunk->y * CHUNK_HEIGHT); - - switch(base) { - case 0: - r = 0; g = 0; b = 0; // Black for empty - break; - case 1: - r = 34; g = 139; b = 34; // Forest Green - break; - case 2: - r = 0; g = 191; b = 255; // Deep Sky Blue - break; - case 3: - r = 139; g = 69; b = 19; // Saddle Brown - break; - case 4: - r = 255; g = 255; b = 0; // Yellow - break; - default: - r = 255; g = 20; b = 147; // Pink for unknown - break; - } - - quadBuffer( - &RENDER_OVERWORLD.chunks[chunkIndex].verticesBase[i * QUAD_VERTEX_COUNT], - posX * TILE_WIDTH_HEIGHT, - posY * TILE_WIDTH_HEIGHT, - (posX + 1) * TILE_WIDTH_HEIGHT, - (posY + 1) * TILE_WIDTH_HEIGHT, - r, g, b, 255, - 0, 0, 1, 1 - ); - } -} - -void renderOverworldDispose(void) { - // Clean up overworld rendering resources here - for(uint8_t i = 0; i < CHUNK_MAP_COUNT; i++) { - renderchunk_t *chunk = &RENDER_OVERWORLD.chunks[i]; - meshDispose(&chunk->meshBase); - meshDispose(&chunk->meshBaseOverlay); - } -} \ No newline at end of file diff --git a/archive/dusksdl2/display/overworld/renderoverworld.h b/archive/dusksdl2/display/overworld/renderoverworld.h deleted file mode 100644 index 01a080d..0000000 --- a/archive/dusksdl2/display/overworld/renderoverworld.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "world/chunk.h" -#include "display/mesh/quad.h" - -typedef struct { - mesh_t meshBase; - meshvertex_t verticesBase[CHUNK_TILE_COUNT * QUAD_VERTEX_COUNT]; - - mesh_t meshBaseOverlay; - meshvertex_t verticesBaseOverlay[CHUNK_TILE_COUNT]; -} renderchunk_t; - -typedef struct { - renderchunk_t chunks[CHUNK_MAP_COUNT]; -} renderoverworld_t; - -extern renderoverworld_t RENDER_OVERWORLD; - -/** - * Initializes the render overworld. - */ -void renderOverworldInit(void); - -/** - * Draws the render overworld. - */ -void renderOverworldDraw(void); - -/** - * Disposes of the render overworld. - */ -void renderOverworldDispose(void); \ No newline at end of file diff --git a/archive/dusksdl2/display/render.c b/archive/dusksdl2/display/render.c deleted file mode 100644 index 1fdbaa7..0000000 --- a/archive/dusksdl2/display/render.c +++ /dev/null @@ -1,119 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "dusksdl2input.h" -#include "render.h" -#include "renderbackbuffer.h" -#include "display/scene/renderscene.h" -#include "display/spritebatch/spritebatch.h" -#include "display/ui/renderui.h" - -SDL_Window *RENDER_WINDOW; -SDL_GLContext RENDER_GL_CONTEXT; -bool_t RENDER_RUNNING; - -errorret_t renderInit(void) { - // Init SDL - uint32_t flags = SDL_INIT_VIDEO; - #if INPUT_SUPPORT_GAMEPAD - flags |= SDL_INIT_GAMECONTROLLER; - #endif - - if(SDL_Init(flags) != 0) { - errorThrow( - "SDL Failed to Initialize: %s", - SDL_GetError() - ); - } - - // Set OpenGL attributes (Needs to be done now or later?) - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - - // Create window with OpenGL flag. - RENDER_WINDOW = SDL_CreateWindow( - "DuskSDL2", - SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, - RENDER_WINDOW_WIDTH_DEFAULT, - RENDER_WINDOW_HEIGHT_DEFAULT, - SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | - SDL_WINDOW_OPENGL - ); - if(!RENDER_WINDOW) { - errorThrow("SDL_CreateWindow failed: %s", SDL_GetError()); - } - - // Create OpenGL context - RENDER_GL_CONTEXT = SDL_GL_CreateContext(RENDER_WINDOW); - if(!RENDER_GL_CONTEXT) { - errorThrow("SDL_GL_CreateContext failed: %s", SDL_GetError()); - } - - SDL_GL_SetSwapInterval(1); - glDisable(GL_DEPTH_TEST); - glDisable(GL_CULL_FACE); - glDisable(GL_LIGHTING);// PSP defaults this on? - glShadeModel(GL_SMOOTH); // Fixes color on PSP? - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - glEnableClientState(GL_COLOR_ARRAY);// To confirm: every frame on PSP? - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glEnableClientState(GL_VERTEX_ARRAY); - - spriteBatchInit(); - renderBackBufferInit(); - renderSceneInit(); - renderUIInit(); - - RENDER_RUNNING = true; - errorOk(); -} - -errorret_t renderDraw(void) { - SDL_Event event; - while(SDL_PollEvent(&event)) { - switch(event.type) { - case SDL_QUIT: - RENDER_RUNNING = false; - break; - - default: - break; - } - } - - // Reset the state - spriteBatchClear(); - renderBackBufferBind(); - - renderSceneDraw(); - renderUIDraw(); - - // Finish rendering, now render back buffer. - renderBackBufferUnbind(); - renderBackBufferDraw(); - textureBind(NULL); - - SDL_GL_SwapWindow(RENDER_WINDOW); - errorOk(); -} - -errorret_t renderDispose(void) { - renderUIDispose(); - renderSceneDispose(); - renderBackBufferDispose(); - spriteBatchDispose(); - - // Destroy OpenGL context - SDL_GL_DeleteContext(RENDER_GL_CONTEXT); - SDL_DestroyWindow(RENDER_WINDOW); - SDL_Quit(); - - errorOk(); -} \ No newline at end of file diff --git a/archive/dusksdl2/display/render.h b/archive/dusksdl2/display/render.h deleted file mode 100644 index 740426b..0000000 --- a/archive/dusksdl2/display/render.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusksdl2.h" -#include "display/renderbase.h" - -#ifndef RENDER_WINDOW_WIDTH_DEFAULT - #define RENDER_WINDOW_WIDTH_DEFAULT RENDER_WIDTH * 3 -#endif -#ifndef RENDER_WINDOW_HEIGHT_DEFAULT - #define RENDER_WINDOW_HEIGHT_DEFAULT RENDER_HEIGHT * 3 -#endif - -#if RENDER_WIDTH == RENDER_WINDOW_WIDTH_DEFAULT && RENDER_HEIGHT == RENDER_WINDOW_HEIGHT_DEFAULT - #define RENDER_USE_FRAMEBUFFER 0 -#else - #define RENDER_USE_FRAMEBUFFER 1 -#endif - -extern SDL_Window *RENDER_WINDOW; -extern SDL_Renderer *RENDER_RENDERER; -extern bool_t RENDER_RUNNING; \ No newline at end of file diff --git a/archive/dusksdl2/display/renderbackbuffer.c b/archive/dusksdl2/display/renderbackbuffer.c deleted file mode 100644 index b6a9fb6..0000000 --- a/archive/dusksdl2/display/renderbackbuffer.c +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "renderbackbuffer.h" -#include "render.h" -#include "display/spritebatch/spritebatch.h" -#include "display/camera/camera.h" - -#if RENDER_USE_FRAMEBUFFER - framebuffer_t RENDER_BACKBUFFER; -#endif - -errorret_t renderBackBufferInit(void) { - #if RENDER_USE_FRAMEBUFFER - frameBufferInit( - &RENDER_BACKBUFFER, - RENDER_WIDTH, - RENDER_HEIGHT - ); - #else - // No back buffer needed for window rendering - #endif - - errorOk(); -} - -void renderBackBufferBind(void) { - #if RENDER_USE_FRAMEBUFFER - frameBufferBind(&RENDER_BACKBUFFER); - #endif - - // Fill background with cornflower blue. - glClearColor(0.392f, 0.584f, 0.929f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); -} - -void renderBackBufferUnbind(void) { - #if RENDER_USE_FRAMEBUFFER - frameBufferBind(NULL); - #endif -} - -void renderBackBufferDraw(void) { - #if RENDER_USE_FRAMEBUFFER - int32_t windowWidth, windowHeight; - SDL_GetWindowSize(RENDER_WINDOW, &windowWidth, &windowHeight); - - // Set viewport to match window size - cameraScreenPush(); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - // Create a quad that is scaled to fit but maintain original aspect ratio - int32_t renderWidth, renderHeight, renderX, renderY; - if(RENDER_WIDTH * windowHeight > RENDER_HEIGHT * windowWidth) { - renderWidth = windowWidth; - renderHeight = (RENDER_HEIGHT * windowWidth) / RENDER_WIDTH; - renderX = 0; - renderY = (windowHeight - renderHeight) / 2; - } else { - renderWidth = (RENDER_WIDTH * windowHeight) / RENDER_HEIGHT; - renderHeight = windowHeight; - renderX = (windowWidth - renderWidth) / 2; - renderY = 0; - } - - // Draw the back buffer texture - spriteBatchClear(); - spriteBatchPush( - &RENDER_BACKBUFFER.texture, - renderX, renderY, - renderX+renderWidth, renderY+renderHeight, - 0xFF, 0xFF, 0xFF, 0xFF, - 0, 1, 1, 0 - ); - spriteBatchFlush(); - cameraScreenPop(); - #else - // No back buffer to draw - #endif -} - -errorret_t renderBackBufferDispose(void) { - #if RENDER_USE_FRAMEBUFFER - frameBufferDispose(&RENDER_BACKBUFFER); - #endif - - errorOk(); -} \ No newline at end of file diff --git a/archive/dusksdl2/display/renderbackbuffer.h b/archive/dusksdl2/display/renderbackbuffer.h deleted file mode 100644 index 6d65919..0000000 --- a/archive/dusksdl2/display/renderbackbuffer.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "display/renderbase.h" -#include "display/framebuffer/framebuffer.h" - -#if RENDER_USE_FRAMEBUFFER - extern framebuffer_t RENDER_BACKBUFFER; -#endif - -/** - * Initializes the render back buffer. May be either a framebuffer or a texture - * depending on the render settings. - */ -errorret_t renderBackBufferInit(void); - -/** - * Binds the render back buffer as the current render target. - */ -void renderBackBufferBind(void); - -/** - * Unbinds the render back buffer, returning to the default render target. - */ -void renderBackBufferUnbind(void); - -/** - * Draws the render back buffer to the screen, scaling it to fit the window. - */ -void renderBackBufferDraw(void); - -/** - * Disposes of the render back buffer, freeing any resources it holds. - * - * @return An error state if an error occurred, otherwise OK. - */ -errorret_t renderBackBufferDispose(void); \ No newline at end of file diff --git a/archive/dusksdl2/display/scene/CMakeLists.txt b/archive/dusksdl2/display/scene/CMakeLists.txt deleted file mode 100644 index 43eb585..0000000 --- a/archive/dusksdl2/display/scene/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - renderscene.c -) - -# Subdirs -# add_subdirectory(draw) \ No newline at end of file diff --git a/archive/dusksdl2/display/scene/renderscene.c b/archive/dusksdl2/display/scene/renderscene.c deleted file mode 100644 index b1fe916..0000000 --- a/archive/dusksdl2/display/scene/renderscene.c +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "renderscene.h" -#include "display/overworld/renderoverworld.h" - -renderscenecallback_t RENDER_SCENE_CALLBACKS[SCENE_COUNT] = { - [SCENE_INITIAL] = { - .init = NULL, - .draw = NULL, - .dispose = NULL - }, - - [SCENE_OVERWORLD] = { - .init = renderOverworldInit, - .draw = renderOverworldDraw, - .dispose = renderOverworldDispose - }, -}; - -void renderSceneInit(void) { - for(int32_t i = 0; i < SCENE_COUNT; i++) { - if(!RENDER_SCENE_CALLBACKS[i].init) continue; - RENDER_SCENE_CALLBACKS[i].init(); - } -} - -void renderSceneDraw(void) { - if(!RENDER_SCENE_CALLBACKS[SCENE_CURRENT].draw) return; - RENDER_SCENE_CALLBACKS[SCENE_CURRENT].draw(); -} - -void renderSceneDispose(void) { - for(int32_t i = 0; i < SCENE_COUNT; i++) { - if(!RENDER_SCENE_CALLBACKS[i].dispose) continue; - RENDER_SCENE_CALLBACKS[i].dispose(); - } -} \ No newline at end of file diff --git a/archive/dusksdl2/display/scene/renderscene.h b/archive/dusksdl2/display/scene/renderscene.h deleted file mode 100644 index c21665f..0000000 --- a/archive/dusksdl2/display/scene/renderscene.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "display/scene.h" - -typedef struct { - void (*init)(void); - void (*draw)(void); - void (*dispose)(void); -} renderscenecallback_t; - -extern renderscenecallback_t RENDER_SCENE_CALLBACKS[SCENE_COUNT]; - -/** - * Initializes the render scene module. - */ -void renderSceneInit(void); - -/** - * Draws the current scene. - */ -void renderSceneDraw(void); - -/** - * Disposes of the render scene module. - */ -void renderSceneDispose(void); \ No newline at end of file diff --git a/archive/dusksdl2/display/spritebatch/CMakeLists.txt b/archive/dusksdl2/display/spritebatch/CMakeLists.txt deleted file mode 100644 index 5b2d7dd..0000000 --- a/archive/dusksdl2/display/spritebatch/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - spritebatch.c -) - -# Subdirs -# add_subdirectory(draw) \ No newline at end of file diff --git a/archive/dusksdl2/display/spritebatch/spritebatch.c b/archive/dusksdl2/display/spritebatch/spritebatch.c deleted file mode 100644 index 8e2bac9..0000000 --- a/archive/dusksdl2/display/spritebatch/spritebatch.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "spritebatch.h" -#include "assert/assert.h" -#include "util/memory.h" -#include "console/console.h" - -spritebatch_t SPRITEBATCH; - -void spriteBatchInit() { - SPRITEBATCH.spriteCount = 0; - SPRITEBATCH.currentTexture = NULL; - - meshInit( - &SPRITEBATCH.mesh, - GL_TRIANGLES, - SPRITEBATCH_VERTEX_COUNT, - &SPRITEBATCH.vertices[0] - ); -} - -void spriteBatchPush( - texture_t *texture, - const float_t minX, - const float_t minY, - const float_t maxX, - const float_t maxY, - const uint8_t r, - const uint8_t g, - const uint8_t b, - const uint8_t a, - const float_t u0, - const float_t v0, - const float_t u1, - const float_t v1 -) { - // Need to flush? - if( - SPRITEBATCH.currentTexture != texture || - SPRITEBATCH.spriteCount >= SPRITEBATCH_SPRITES_MAX - ) { - spriteBatchFlush(); - SPRITEBATCH.currentTexture = texture; - } - - quadBuffer( - &SPRITEBATCH.vertices[SPRITEBATCH.spriteCount * QUAD_VERTEX_COUNT], - minX, minY, maxX, maxY, - r, g, b, a, - u0, v0, u1, v1 - ); - - SPRITEBATCH.spriteCount++; -} - -void spriteBatchClear() { - SPRITEBATCH.spriteCount = 0; - SPRITEBATCH.currentTexture = NULL; -} - -void spriteBatchFlush() { - if(SPRITEBATCH.spriteCount == 0) return; - textureBind(SPRITEBATCH.currentTexture); - meshDraw(&SPRITEBATCH.mesh, 0, QUAD_VERTEX_COUNT * SPRITEBATCH.spriteCount); - spriteBatchClear(); -} - -void spriteBatchDispose() { - meshDispose(&SPRITEBATCH.mesh); -} \ No newline at end of file diff --git a/archive/dusksdl2/display/spritebatch/spritebatch.h b/archive/dusksdl2/display/spritebatch/spritebatch.h deleted file mode 100644 index 83de8d2..0000000 --- a/archive/dusksdl2/display/spritebatch/spritebatch.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "display/mesh/quad.h" -#include "display/texture/texture.h" - -#define SPRITEBATCH_SPRITES_MAX 1 -#define SPRITEBATCH_VERTEX_COUNT (SPRITEBATCH_SPRITES_MAX * QUAD_VERTEX_COUNT) - - -typedef struct { - mesh_t mesh; - int32_t spriteCount; - texture_t *currentTexture; - meshvertex_t vertices[SPRITEBATCH_VERTEX_COUNT]; -} spritebatch_t; - -extern spritebatch_t SPRITEBATCH; - -/** - * Initializes a sprite batch. - * - * @param spriteBatch The sprite batch to initialize. - */ -void spriteBatchInit(); - -void spriteBatchPush( - texture_t *texture, - const float_t minX, - const float_t minY, - const float_t maxX, - const float_t maxY, - const uint8_t r, - const uint8_t g, - const uint8_t b, - const uint8_t a, - const float_t u0, - const float_t v0, - const float_t u1, - const float_t v1 -); - -void spriteBatchClear(); - -void spriteBatchFlush(); - -void spriteBatchDispose(); \ No newline at end of file diff --git a/archive/dusksdl2/display/texture/CMakeLists.txt b/archive/dusksdl2/display/texture/CMakeLists.txt deleted file mode 100644 index 369aaac..0000000 --- a/archive/dusksdl2/display/texture/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - texture.c -) - -# Subdirs -# add_subdirectory(draw) \ No newline at end of file diff --git a/archive/dusksdl2/display/texture/texture.c b/archive/dusksdl2/display/texture/texture.c deleted file mode 100644 index a169431..0000000 --- a/archive/dusksdl2/display/texture/texture.c +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "texture.h" -#include "assert/assert.h" -#include "util/memory.h" -#include "util/math.h" - -void textureInit( - texture_t *texture, - const int32_t width, - const int32_t height, - const GLenum format, - const uint8_t *data -) { - assertNotNull(texture, "Texture cannot be NULL"); - assertTrue(width > 0 && height > 0, "Width and height must be greater than 0"); - - #if PSP - assertTrue( - width == mathNextPowTwo(width), - "Width must be powers of 2 for PSP" - ); - assertTrue( - height == mathNextPowTwo(height), - "Height must be powers of 2 for PSP" - ); - #endif - - memoryZero(texture, sizeof(texture_t)); - texture->width = width; - texture->height = height; - - glGenTextures(1, &texture->id); - glBindTexture(GL_TEXTURE_2D, texture->id); - glTexImage2D( - GL_TEXTURE_2D, 0, format, width, height, 0, - format, GL_UNSIGNED_BYTE, data - ); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - glBindTexture(GL_TEXTURE_2D, 0); -} - -void textureBind(const texture_t *texture) { - if(texture == NULL) { - glDisable(GL_TEXTURE_2D); - // glBindTexture(GL_TEXTURE_2D, 0); - return; - } - - assertTrue( - texture->id != 0, - "Texture ID must not be 0" - ); - assertTrue( - texture->width > 0 && texture->height > 0, - "Texture width and height must be greater than 0" - ); - - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, texture->id); -} - -void textureDispose(texture_t *texture) { - assertNotNull(texture, "Texture cannot be NULL"); - assertTrue(texture->id != 0, "Texture ID must not be 0"); - - glDeleteTextures(1, &texture->id); -} \ No newline at end of file diff --git a/archive/dusksdl2/display/texture/texture.h b/archive/dusksdl2/display/texture/texture.h deleted file mode 100644 index afec530..0000000 --- a/archive/dusksdl2/display/texture/texture.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusksdl2.h" - -typedef struct { - GLuint id; - int32_t width; - int32_t height; -} texture_t; - -/** - * Initializes a texture. - * - * @param texture The texture to initialize. - * @param width The width of the texture. - * @param height The height of the texture. - * @param format The format of the texture (e.g., GL_RGBA, GL_ALPHA). - * @param data The pixel data for the texture. - */ -void textureInit( - texture_t *texture, - const int32_t width, - const int32_t height, - const GLenum format, - const uint8_t *data -); - -/** - * Binds a texture for rendering. - * - * @param texture The texture to bind. - */ -void textureBind(const texture_t *texture); - -/** - * Disposes a texture. - * - * @param texture The texture to dispose. - */ -void textureDispose(texture_t *texture); \ No newline at end of file diff --git a/archive/dusksdl2/display/ui/CMakeLists.txt b/archive/dusksdl2/display/ui/CMakeLists.txt deleted file mode 100644 index 2ca6934..0000000 --- a/archive/dusksdl2/display/ui/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - renderconsole.c - renderfps.c - rendertext.c - renderui.c - rendertextbox.c -) \ No newline at end of file diff --git a/archive/dusksdl2/display/ui/renderconsole.c b/archive/dusksdl2/display/ui/renderconsole.c deleted file mode 100644 index 0c6b0c5..0000000 --- a/archive/dusksdl2/display/ui/renderconsole.c +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "renderconsole.h" -#include "console/console.h" -#include "display/ui/rendertext.h" - -void renderConsoleDraw(void) { - if(!CONSOLE.visible) return; - - int32_t i = 0; - char_t *line; - do { - line = CONSOLE.line[i]; - if(line[0] == '\0') { - i++; - continue; - } - renderTextDraw( - 0, (CONSOLE_HISTORY_MAX - i - 1) * FONT_TILE_HEIGHT, line, - 0xFF, 0xFF, 0xFF - ); - i++; - } while(i < CONSOLE_HISTORY_MAX); -} \ No newline at end of file diff --git a/archive/dusksdl2/display/ui/renderconsole.h b/archive/dusksdl2/display/ui/renderconsole.h deleted file mode 100644 index 0d90454..0000000 --- a/archive/dusksdl2/display/ui/renderconsole.h +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusksdl2.h" - -/** - * Draws the console overlay. - */ -void renderConsoleDraw(void); \ No newline at end of file diff --git a/archive/dusksdl2/display/ui/renderfps.c b/archive/dusksdl2/display/ui/renderfps.c deleted file mode 100644 index 7c4fdce..0000000 --- a/archive/dusksdl2/display/ui/renderfps.c +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "renderfps.h" -#include "display/render.h" -#include "display/ui/rendertext.h" -#include "time.h" -#include "game.h" - -float_t RENDER_FPS_AVG = -1.0f; -float_t RENDER_TPS_AVG = -1.0f; - -void renderFPSDraw(void) { - - if(TIME.delta > 0) { - float_t fps = 1.0f / TIME.realDelta; - - if(RENDER_FPS_AVG == -1.0f) { - RENDER_FPS_AVG = fps; - } else { - RENDER_FPS_AVG = (RENDER_FPS_AVG + fps) / 2.0f; - } - } - - if(TIME.time != TIME.lastTick) { - float_t timeSinceLastTick = TIME.realTime - TIME.lastTick; - float_t tps = 1.0f / timeSinceLastTick; - - if(RENDER_TPS_AVG == -1.0f) { - RENDER_TPS_AVG = tps; - } else { - RENDER_TPS_AVG = (RENDER_TPS_AVG + tps) / 2.0f; - } - } - - char_t buffer[64]; - snprintf(buffer, sizeof(buffer), "%.1f/%.1f", RENDER_FPS_AVG, RENDER_TPS_AVG); - - int32_t width, height; - renderTextMeasure(buffer, &width, &height); - renderTextDraw(RENDER_WIDTH - width, 0, buffer, 0x00, 0xFF, 0x00); -} \ No newline at end of file diff --git a/archive/dusksdl2/display/ui/renderfps.h b/archive/dusksdl2/display/ui/renderfps.h deleted file mode 100644 index 739256c..0000000 --- a/archive/dusksdl2/display/ui/renderfps.h +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once - -/** - * Draws the FPS overlay. - */ -void renderFPSDraw(void); \ No newline at end of file diff --git a/archive/dusksdl2/display/ui/rendertext.c b/archive/dusksdl2/display/ui/rendertext.c deleted file mode 100644 index b14105a..0000000 --- a/archive/dusksdl2/display/ui/rendertext.c +++ /dev/null @@ -1,159 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "rendertext.h" -#include "display/render.h" -#include "assert/assert.h" -#include "display/spritebatch/spritebatch.h" -#include "util/memory.h" -#include "util/math.h" - -texture_t RENDER_TEXT_TEXTURE; - -static mesh_t RENDER_TEXT_QUAD_MESH; - -void renderTextInit(void) { - const int32_t cols = FONT_COLUMN_COUNT; - const int32_t rows = (FONT_TILE_COUNT + cols - 1) / cols; - const int32_t inputFontWidth = cols * FONT_TILE_WIDTH; - const int32_t inputFontHeight = rows * FONT_TILE_HEIGHT; - - int32_t outputFontWidth = inputFontWidth; - int32_t outputFontHeight = inputFontHeight; - - // Round up to nearest power of 2 - #if PSP - outputFontWidth = mathNextPowTwo(inputFontWidth); - outputFontHeight = mathNextPowTwo(inputFontHeight); - #endif - - uint8_t *pixels = (uint8_t *)memoryAllocate( - outputFontWidth * outputFontHeight * - sizeof(uint8_t) - ); - - // Buffer the pixels. - for(int tileIndex = 0; tileIndex < FONT_TILE_COUNT; ++tileIndex) { - const int32_t tileX = (tileIndex % FONT_COLUMN_COUNT) * FONT_TILE_WIDTH; - const int32_t tileY = (tileIndex / FONT_COLUMN_COUNT) * FONT_TILE_HEIGHT; - const uint8_t* tile = TILE_PIXEL_DATA[tileIndex]; - - for (int y = 0; y < FONT_TILE_HEIGHT; ++y) { - for (int x = 0; x < FONT_TILE_WIDTH; ++x) { - const int32_t pixel = (tileY + y) * outputFontWidth + (tileX + x); - const int32_t pixelOffset = pixel; - uint8_t value = tile[y * FONT_TILE_WIDTH + x]; - pixels[pixel] = value ? 0xFF : 0x00; // Alpha channel - } - } - } - - textureInit( - &RENDER_TEXT_TEXTURE, - outputFontWidth, outputFontHeight, - GL_ALPHA, pixels - ); - memoryFree(pixels); -} - -void renderTextDrawChar( - const float_t x, - const float_t y, - const char_t c, - const uint8_t r, - const uint8_t g, - const uint8_t b -) { - int32_t tileIndex = (int32_t)(c) - FONT_CHAR_START; - assertTrue( - tileIndex >= 0 && tileIndex < FONT_TILE_COUNT, - "Character is out of bounds for font tiles" - ); - - const float_t w = (float)RENDER_TEXT_TEXTURE.width; - const float_t h = (float)RENDER_TEXT_TEXTURE.height; - const int32_t tileX = (tileIndex % FONT_COLUMN_COUNT); - const int32_t tileY = (tileIndex / FONT_COLUMN_COUNT); - - spriteBatchPush( - &RENDER_TEXT_TEXTURE, - x, y, - x + FONT_TILE_WIDTH, y + FONT_TILE_HEIGHT, - r, g, b, 0xFF, - (tileX * FONT_TILE_WIDTH) / w, - (tileY * FONT_TILE_HEIGHT) / h, - ((tileX + 1) * FONT_TILE_WIDTH) / w, - ((tileY + 1) * FONT_TILE_HEIGHT) / h - ); -} - -void renderTextDraw( - const float_t x, - const float_t y, - const char_t *text, - const uint8_t r, - const uint8_t g, - const uint8_t b -) { - assertNotNull(text, "Text cannot be NULL"); - - float_t posX = x; - float_t posY = y; - - char_t c; - int32_t i = 0; - while((c = text[i++]) != '\0') { - if(c == '\n') { - posX = x; - posY += FONT_TILE_HEIGHT; - continue; - } - - renderTextDrawChar(posX, posY, c, r, g, b); - posX += FONT_TILE_WIDTH; - } -} - -void renderTextMeasure( - const char_t *text, - int32_t *outWidth, - int32_t *outHeight -) { - assertNotNull(text, "Text cannot be NULL"); - assertNotNull(outWidth, "Output width pointer cannot be NULL"); - assertNotNull(outHeight, "Output height pointer cannot be NULL"); - - int32_t width = 0; - int32_t height = FONT_TILE_HEIGHT; - int32_t lineWidth = 0; - - char_t c; - int32_t i = 0; - while((c = text[i++]) != '\0') { - if(c == '\n') { - if(lineWidth > width) { - width = lineWidth; - } - lineWidth = 0; - height += FONT_TILE_HEIGHT; - continue; - } - - lineWidth += FONT_TILE_WIDTH; - } - - if(lineWidth > width) { - width = lineWidth; - } - - *outWidth = width; - *outHeight = height; -} - -void renderTextDispose(void) { - textureDispose(&RENDER_TEXT_TEXTURE); -} \ No newline at end of file diff --git a/archive/dusksdl2/display/ui/rendertext.h b/archive/dusksdl2/display/ui/rendertext.h deleted file mode 100644 index 6536c62..0000000 --- a/archive/dusksdl2/display/ui/rendertext.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusksdl2.h" -#include "ui/font.h" -#include "display/texture/texture.h" - -extern texture_t RENDER_TEXT_TEXTURE; - -/** - * Initializes the text rendering system. - */ -void renderTextInit(void); - -/** - * Draws a single character at the specified position. - * - * @param x The x-coordinate to draw the character at. - * @param y The y-coordinate to draw the character at. - * @param c The character to draw. - * @param r The red component of the color (0-255). - * @param g The green component of the color (0-255). - * @param b The blue component of the color (0-255). - */ -void renderTextDrawChar( - const float_t x, - const float_t y, - const char_t c, - const uint8_t r, - const uint8_t g, - const uint8_t b -); - -/** - * Draws a string of text at the specified position. - * - * @param x The x-coordinate to draw the text at. - * @param y The y-coordinate to draw the text at. - * @param text The null-terminated string of text to draw. - * @param r The red component of the color (0-255). - * @param g The green component of the color (0-255). - * @param b The blue component of the color (0-255). - */ -void renderTextDraw( - const float_t x, - const float_t y, - const char_t *text, - const uint8_t r, - const uint8_t g, - const uint8_t b -); - -/** - * Measures the width and height of the given text string when rendered. - * - * @param text The null-terminated string of text to measure. - * @param outWidth Pointer to store the measured width in pixels. - * @param outHeight Pointer to store the measured height in pixels. - */ -void renderTextMeasure( - const char_t *text, - int32_t *outWidth, - int32_t *outHeight -); - -/** - * Disposes of the text rendering system, freeing any allocated resources. - */ -void renderTextDispose(void); \ No newline at end of file diff --git a/archive/dusksdl2/display/ui/rendertextbox.c b/archive/dusksdl2/display/ui/rendertextbox.c deleted file mode 100644 index a6684fd..0000000 --- a/archive/dusksdl2/display/ui/rendertextbox.c +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "rendertextbox.h" -#include "ui/uitextbox.h" -#include "display/ui/rendertext.h" -#include "display/spritebatch/spritebatch.h" -#include "assert/assert.h" - -void renderTextboxDraw(void) { - if(!UI_TEXTBOX.visible) return; - - // Background - spriteBatchPush( - NULL, - 0, RENDER_HEIGHT - UI_TEXTBOX_HEIGHT, - RENDER_WIDTH, RENDER_HEIGHT, - 0x00, 0x00, 0x00, 0xFF, - 0.0f, 0.0f, 1.0f, 1.0f - ); - - uint32_t x = 0; - uint32_t y = RENDER_HEIGHT - UI_TEXTBOX_HEIGHT; - - if(UI_TEXTBOX.charsRevealed > 0) { - uint8_t charsRendered = 0; - - // For each line - for(uint8_t i = 0; i < UI_TEXTBOX_LINES_PER_PAGE; i++) { - // Get count of chars in the line - uint8_t lineLength = UI_TEXTBOX.lineLengths[ - i + (UI_TEXTBOX.page * UI_TEXTBOX_LINES_PER_PAGE) - ]; - if(lineLength == 0) continue; - - // Determine how many chars left to render - uint8_t lineChars = UI_TEXTBOX.charsRevealed - charsRendered; - - // Don't render more than in line - if(lineChars > lineLength) lineChars = lineLength; - assertTrue(lineChars > 0, "Line chars must be greater than 0"); - - // Update how many rendered - charsRendered += lineChars; - - for(uint8_t j = 0; j < lineChars; j++) { - renderTextDrawChar( - x + UI_TEXTBOX_PADDING_X + UI_TEXTBOX_BORDER_WIDTH + ( - j * FONT_TILE_WIDTH - ), - y + UI_TEXTBOX_PADDING_Y + UI_TEXTBOX_BORDER_HEIGHT + ( - i * FONT_TILE_HEIGHT - ), - UI_TEXTBOX.text[ - (i * UI_TEXTBOX_CHARS_PER_LINE) + j + - (UI_TEXTBOX.page * UI_TEXTBOX_CHARS_PER_PAGE) - ], - 0xFF, 0xFF, 0xFF - ); - } - - // Check if we're done rendering text - if(UI_TEXTBOX.charsRevealed - charsRendered == 0) break; - } - } -} \ No newline at end of file diff --git a/archive/dusksdl2/display/ui/rendertextbox.h b/archive/dusksdl2/display/ui/rendertextbox.h deleted file mode 100644 index ce657b9..0000000 --- a/archive/dusksdl2/display/ui/rendertextbox.h +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once - -void renderTextboxDraw(void); \ No newline at end of file diff --git a/archive/dusksdl2/display/ui/renderui.c b/archive/dusksdl2/display/ui/renderui.c deleted file mode 100644 index 238118c..0000000 --- a/archive/dusksdl2/display/ui/renderui.c +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "renderui.h" -#include "display/ui/rendertext.h" -#include "display/ui/renderconsole.h" -#include "display/ui/renderfps.h" -#include "display/ui/rendertextbox.h" -#include "display/spritebatch/spritebatch.h" -#include "display/camera/camera.h" - -renderuicallback_t RENDER_UI_CALLBACKS[] = { - { - .init = renderTextInit, - .dispose = renderTextDispose - }, - - { - .draw = renderTextboxDraw, - }, - - { - .draw = renderConsoleDraw, - }, - - { - .draw = renderFPSDraw, - }, -}; - -#define RENDER_UI_CALLBACKS_COUNT ( \ - sizeof(RENDER_UI_CALLBACKS) / sizeof(RENDER_UI_CALLBACKS[0]) \ -) - -void renderUIInit(void) { - for (int32_t i = 0; i < RENDER_UI_CALLBACKS_COUNT; i++) { - if(!RENDER_UI_CALLBACKS[i].init) continue; - RENDER_UI_CALLBACKS[i].init(); - } -} - -void renderUIDraw(void) { - cameraUIPush(); - - for (int32_t i = 0; i < RENDER_UI_CALLBACKS_COUNT; i++) { - if(!RENDER_UI_CALLBACKS[i].draw) continue; - RENDER_UI_CALLBACKS[i].draw(); - } - - spriteBatchFlush(); - cameraUIPop(); -} - -void renderUIDispose(void) { - for (int32_t i = 0; i < RENDER_UI_CALLBACKS_COUNT; i++) { - if(!RENDER_UI_CALLBACKS[i].dispose) continue; - RENDER_UI_CALLBACKS[i].dispose(); - } -} \ No newline at end of file diff --git a/archive/dusksdl2/display/ui/renderui.h b/archive/dusksdl2/display/ui/renderui.h deleted file mode 100644 index b35d1f6..0000000 --- a/archive/dusksdl2/display/ui/renderui.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusksdl2.h" - -typedef struct { - void (*init)(void); - void (*draw)(void); - void (*dispose)(void); -} renderuicallback_t; - -extern renderuicallback_t RENDER_UI_CALLBACKS[]; - -/** - * Initialize the UI rendering system. - */ -void renderUIInit(void); - -/** - * Draw the UI elements. - */ -void renderUIDraw(void); - -/** - * Dispose of the UI rendering system. - */ -void renderUIDispose(void); \ No newline at end of file diff --git a/archive/dusksdl2/dusksdl2.h b/archive/dusksdl2/dusksdl2.h deleted file mode 100644 index 1000059..0000000 --- a/archive/dusksdl2/dusksdl2.h +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" -#include - -#define GL_GLEXT_PROTOTYPES -#include -#include - -#include \ No newline at end of file diff --git a/archive/dusksdl2/dusksdl2input.c b/archive/dusksdl2/dusksdl2input.c deleted file mode 100644 index 58d76ca..0000000 --- a/archive/dusksdl2/dusksdl2input.c +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "dusksdl2input.h" - -inputstate_t inputStateGet() { - inputstate_t state = 0; - - #if INPUT_SUPPORT_GAMEPAD - // Get gamepad state. - for(int32_t i = 0; i < SDL_NumJoysticks(); i++) { - if(!SDL_IsGameController(i)) continue; - - SDL_GameController *controller = SDL_GameControllerOpen(i); - if(!controller) continue; - - inputsdlbuttonmap_t *map = INPUT_SDL_BUTTON_MAP; - do { - if(SDL_GameControllerGetButton(controller, map->button)) { - state |= map->bind; - } - map++; - } while(map->bind != 0); - } - #endif - - // Get keyboard state. - #if INPUT_SUPPORT_KEYBOARD - const uint8_t *keyboardState = SDL_GetKeyboardState(NULL); - inputsdlkbmap_t *kbmap = INPUT_SDL_KEYBOARD_MAP; - do { - if(keyboardState[kbmap->code]) { - state |= kbmap->bind; - } - kbmap++; - } while(kbmap->bind != 0); - #endif - - return state; -} \ No newline at end of file diff --git a/archive/dusksdl2/dusksdl2input.h b/archive/dusksdl2/dusksdl2input.h deleted file mode 100644 index 2a095e7..0000000 --- a/archive/dusksdl2/dusksdl2input.h +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusksdl2.h" -#include "input.h" - -#ifndef INPUT_SUPPORT_GAMEPAD - #define INPUT_SUPPORT_GAMEPAD 1 -#endif - -#ifndef INPUT_SUPPORT_KEYBOARD - #define INPUT_SUPPORT_KEYBOARD 1 -#endif - -#if INPUT_SUPPORT_GAMEPAD - typedef struct { - const SDL_GameControllerButton button; - const inputbind_t bind; - } inputsdlbuttonmap_t; - - static const inputsdlbuttonmap_t INPUT_SDL_BUTTON_MAP[] = { - { SDL_CONTROLLER_BUTTON_DPAD_UP, INPUT_BIND_UP }, - { SDL_CONTROLLER_BUTTON_DPAD_DOWN, INPUT_BIND_DOWN }, - { SDL_CONTROLLER_BUTTON_DPAD_LEFT, INPUT_BIND_LEFT }, - { SDL_CONTROLLER_BUTTON_DPAD_RIGHT, INPUT_BIND_RIGHT }, - { SDL_CONTROLLER_BUTTON_A, INPUT_BIND_ACTION }, - { SDL_CONTROLLER_BUTTON_B, INPUT_BIND_CANCEL }, - { SDL_CONTROLLER_BUTTON_BACK, INPUT_BIND_CONSOLE }, - { 0, 0 } - }; -#endif - -#if INPUT_SUPPORT_KEYBOARD - typedef struct { - SDL_Scancode code; - inputbind_t bind; - } inputsdlkbmap_t; - - static const inputsdlkbmap_t INPUT_SDL_KEYBOARD_MAP[] = { - { SDL_SCANCODE_W, INPUT_BIND_UP }, - { SDL_SCANCODE_S, INPUT_BIND_DOWN }, - { SDL_SCANCODE_A, INPUT_BIND_LEFT }, - { SDL_SCANCODE_D, INPUT_BIND_RIGHT }, - { SDL_SCANCODE_LEFT, INPUT_BIND_LEFT }, - { SDL_SCANCODE_RIGHT, INPUT_BIND_RIGHT }, - { SDL_SCANCODE_UP, INPUT_BIND_UP }, - { SDL_SCANCODE_DOWN, INPUT_BIND_DOWN }, - { SDL_SCANCODE_RETURN, INPUT_BIND_ACTION }, - { SDL_SCANCODE_SPACE, INPUT_BIND_ACTION }, - { SDL_SCANCODE_E, INPUT_BIND_ACTION }, - { SDL_SCANCODE_ESCAPE, INPUT_BIND_CANCEL }, - { SDL_SCANCODE_BACKSPACE, INPUT_BIND_CANCEL }, - { SDL_SCANCODE_TAB, INPUT_BIND_CONSOLE }, - { SDL_SCANCODE_GRAVE, INPUT_BIND_CONSOLE }, - { SDL_SCANCODE_Q, INPUT_BIND_QUIT }, - { 0, 0 } - }; -#endif \ No newline at end of file diff --git a/archive/dusksdl2/main.c b/archive/dusksdl2/main.c deleted file mode 100644 index 6018ead..0000000 --- a/archive/dusksdl2/main.c +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "display/render.h" -#include "game.h" -#include "input.h" - -#define mainError(ret) \ - if((ret).code != ERROR_OK) { \ - errorPrint(ret); \ - return (ret).code; \ - } - -int main(int argc, char *argv[]) { - errorret_t ret; - - mainError(renderInit()); - gameInit(); - - while(RENDER_RUNNING) { - gameUpdate(); - mainError(renderDraw()); - - if(!GAME.running) break; - } - - gameDispose(); - mainError(renderDispose()); - - return 0; -} \ No newline at end of file diff --git a/archive/dusksdl2/time.c b/archive/dusksdl2/time.c deleted file mode 100644 index c9a0dd1..0000000 --- a/archive/dusksdl2/time.c +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "time.h" -#include "dusksdl2.h" - -uint32_t TIME_LAST = 0; - -float_t timeDeltaGet(void) { - // Get the current time in milliseconds - uint32_t currentTime = SDL_GetTicks(); - float_t delta = (currentTime - TIME_LAST) / 1000.0f; - TIME_LAST = currentTime; - return delta; -} \ No newline at end of file diff --git a/archive/tool2/processimage.py b/archive/tool2/processimage.py deleted file mode 100644 index f2e3cb9..0000000 --- a/archive/tool2/processimage.py +++ /dev/null @@ -1,120 +0,0 @@ -import os -from args import args -from PIL import Image -import struct -import sys -from assethelpers import getAssetRelativePath - -PALETTES = [] - -def extractPaletteFromImage(image): - # goes through and finds all unique colors in the image - if image.mode != 'RGBA': - image = image.convert('RGBA') - pixels = list(image.getdata()) - uniqueColors = [] - for color in pixels: - # We treat alpha 0 as rgba(0,0,0,0) for palette purposes - if color[3] == 0: - color = (0, 0, 0, 0) - if color not in uniqueColors: - uniqueColors.append(color) - return uniqueColors - -def savePalette(pixels, outputFilePath): - colorCount = len(pixels) - buf = bytearray(b"DPF") - buf += struct.pack("', '/', '*', ':', '#', '%', - '!', '?', '.', ',', "'", '"', '@', '&', '$', ' ' -] -CHAR_START = 0x20 # ASCII space character -CHAR_END = 0x7E # ASCII tilde character (exclusive) -CHARS_TOTAL = CHAR_END - CHAR_START - -# Check if the script is run with the correct arguments -parser = argparse.ArgumentParser(description="Generate chunk header files") -parser.add_argument('--output', required=True, help='File to write header') -parser.add_argument('--input', required=True, help='Input XML from tiled') -args = parser.parse_args() - -# Ensure outdir exists -outputFile = args.output -outputDir = os.path.dirname(outputFile) -os.makedirs(outputDir, exist_ok=True) - -# Read the XML file -inputFile = args.input -if not os.path.exists(inputFile): - print(f"Error: Input file '{inputFile}' does not exist.") - sys.exit(1) - -# Find root element -tree = ET.parse(inputFile) -root = tree.getroot() -# Check if the root element is 'tileset' -if root.tag != 'tileset': - print(f"Error: Expected root element 'tileset', found '{root.tag}'") - sys.exit(1) - -# Shoul have tilewidth and tileheight attributes -if 'tilewidth' not in root.attrib or 'tileheight' not in root.attrib: - print("Error: 'tileset' element must have 'tilewidth' and 'tileheight' attributes") - sys.exit(1) - -if 'tilecount' not in root.attrib: - print("Error: 'tileset' element must have 'tilecount' attribute") - sys.exit(1) - -# Find image element -image = root.find('image') -if image is None: - print("Error: 'tileset' element must contain an 'image' element") - sys.exit(1) - -# Ensure image has 'source' attribute -if 'source' not in image.attrib: - print("Error: 'image' element must have a 'source' attribute") - sys.exit(1) - -# Ensure image source exists -inputDir = os.path.dirname(inputFile) - -imageSource = os.path.join(inputDir, image.attrib['source']) -if not os.path.exists(imageSource): - print(f"Error: Image source '{imageSource}' does not exist.") - sys.exit(1) - -# Ensure image has 'width' and 'height' attributes -if 'width' not in image.attrib or 'height' not in image.attrib: - print("Error: 'image' element must have 'width' and 'height' attributes") - sys.exit(1) - -# Ensure image is readable -try: - img = Image.open(imageSource) -except Exception as e: - print(f"Error: Unable to open image '{imageSource}': {e}") - sys.exit(1) - -# Ensure image dimensions match the attributes -if img.width != int(image.attrib['width']) or img.height != int(image.attrib['height']): - print(f"Error: Image dimensions ({img.width}x{img.height}) do not match attributes ({image.attrib['width']}x{image.attrib['height']})") - sys.exit(1) - -# Prepare header content -now = datetime.now().strftime("%Y-%m-%d %H:%M:%S") -tileCount = int(root.attrib['tilecount']) - -outputTileIndexes = [] -for i in range(CHARS_TOTAL): - # For some reason the input tilemap is not in ASCII, so we are going to map - # the tiles to the ASCII characters we expect, we start at 0x20 (space) - - # Find the index of the character in the CHARACTER_MAP - inputIndex = -1 - for j, char in enumerate(CHARACTER_MAP): - if ord(char) == (CHAR_START + i): - inputIndex = j - break - - if inputIndex == -1: - print(f"Warning: Character '{chr(CHAR_START + i)}' not found in CHARACTER_MAP") - outputTileIndexes.append(0) # Use 0 for missing characters (space) - continue - - outputTileIndexes.append(inputIndex) - -with open(outputFile, 'w') as f: - f.write(f"// Generated at {now}\n") - f.write("#pragma once\n") - f.write("#include \"dusk.h\"\n\n") - f.write(f"#define FONT_TILE_WIDTH {root.attrib['tilewidth']}\n") - f.write(f"#define FONT_TILE_HEIGHT {root.attrib['tileheight']}\n") - f.write(f"#define FONT_TILE_COUNT {len(outputTileIndexes)}\n") - f.write(f"#define FONT_CHAR_START {CHAR_START}\n") - f.write(f"#define FONT_CHAR_END {CHAR_END}\n") - f.write(f"#define FONT_CHAR_COUNT {CHARS_TOTAL}\n") - f.write(f"#define FONT_COLUMN_COUNT {img.width // int(root.attrib['tilewidth'])}\n") - f.write(f"#define FONT_ROW_COUNT {img.height // int(root.attrib['tileheight'])}\n\n") - - f.write("static const uint8_t TILE_INDEXES[FONT_CHAR_COUNT] = {\n") - f.write(" ") - for i in range(len(outputTileIndexes)): - tileIndex = outputTileIndexes[i] - f.write(f"{tileIndex}, ") - f.write("\n};\n\n") - - f.write("static const uint8_t TILE_PIXEL_DATA[FONT_TILE_COUNT][FONT_TILE_WIDTH * FONT_TILE_HEIGHT] = {\n") - for i in range(len(outputTileIndexes)): - tileIndex = outputTileIndexes[i] - f.write(f" // Character {i} ('{chr(CHAR_START + i)}'). Read from {tileIndex} tile.\n") - f.write(f" {{") - - # Read the tile from the image - tileX = (tileIndex % (img.width // int(root.attrib['tilewidth']))) * int(root.attrib['tilewidth']) - tileY = (tileIndex // (img.width // int(root.attrib['tilewidth']))) * int(root.attrib['tileheight']) - tile = img.crop((tileX, tileY, tileX + int(root.attrib['tilewidth']), tileY + int(root.attrib['tileheight']))) - - # Pixel is either 0 (transparent) or 1 (opaque) - for y in range(int(root.attrib['tileheight'])): - for x in range(int(root.attrib['tilewidth'])): - pixel = tile.getpixel((x, y)) - f.write(f"0x{1 if pixel[3] > 0 else 0:02X}, ") - f.write("},\n\n") - - - f.write("};\n\n") \ No newline at end of file diff --git a/archive/tools/languagecompile/CMakeLists.txt b/archive/tools/languagecompile/CMakeLists.txt deleted file mode 100644 index c10b92c..0000000 --- a/archive/tools/languagecompile/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -find_package(Python3 COMPONENTS Interpreter REQUIRED) - -# Custom command to generate all header files -add_custom_target(DUSK_LANGUAGES - COMMAND - ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/languagecompile.py - --output ${DUSK_GENERATED_HEADERS_DIR}/locale/language/ - --input ${DUSK_DATA_DIR}/languages/ - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/languagecompile.py - COMMENT "Generating language header files" - VERBATIM -) - -# Ensure headers are generated before compiling main -add_dependencies(${DUSK_TARGET_NAME} DUSK_LANGUAGES) \ No newline at end of file diff --git a/archive/tools/languagecompile/languagecompile.py b/archive/tools/languagecompile/languagecompile.py deleted file mode 100644 index d745e80..0000000 --- a/archive/tools/languagecompile/languagecompile.py +++ /dev/null @@ -1,147 +0,0 @@ -import sys, os -import argparse -from datetime import datetime - -# Check if the script is run with the correct arguments -parser = argparse.ArgumentParser(description="Generate chunk header files") -parser.add_argument('--output', required=True, help='Dir to write headers') -parser.add_argument('--input', required=True, help='Input directory containing language files') -args = parser.parse_args() - -# Ensure outdir exists -outputFile = args.output -outputDir = args.output -os.makedirs(outputDir, exist_ok=True) - -inputDir = args.input -# Scan for .json files in the input directory -if not os.path.exists(inputDir): - print(f"Error: Input directory '{inputDir}' does not exist.") - sys.exit(1) - -jsonFiles = [f for f in os.listdir(inputDir) if f.endswith('.json')] -if not jsonFiles or len(jsonFiles) == 0: - print(f"Error: No JSON files found in '{inputDir}'.") - sys.exit(1) - -# take JSON from form { "a": { "b": { "c": "d" } } } to "a.b.c": "d" -def flattenJson(y): - keyValues = {} - for key, value in y.items(): - if isinstance(value, dict): - # If the value is a dictionary, recurse into it - subKeyValues = flattenJson(value) - for subKey, subValue in subKeyValues.items(): - keyValues[f"{key}.{subKey}"] = subValue - else: - # If the value is not a dictionary, add it to the keyValues - keyValues[key] = value - return keyValues - -def escapeString(s): - # Escape double quotes and backslashes in the string - return s.replace('\\', '\\\\').replace('"', '\\"') - -# For each language file... -now = datetime.now().strftime("%Y-%m-%d %H:%M:%S") -isFirstLanguage = True - -# Because I code in english, I am going to reorder the langs so it is first. -jsonFiles.sort(key=lambda x: x.lower() if x.lower() == 'en.json' else "zz_" + x.lower()) - -keysExpected = [] - -languages = [] -for jsonFile in jsonFiles: - inputFile = os.path.join(inputDir, jsonFile) - languageName = os.path.splitext(jsonFile)[0] - langUpper = languageName.upper() - outputFile = os.path.join(outputDir, f"{languageName}.h") - - # Read the JSON file - with open(inputFile, 'r', encoding='utf-8') as f: - content = f.read() - - # Write the header file - with open(outputFile, 'w', encoding='utf-8') as f: - f.write(f"// Generated from {jsonFile} on {now}\n") - f.write("#pragma once\n") - f.write("#include \"dusk.h\"\n\n") - f.write(f"// Language: {languageName} from {jsonFile}\n") - - keyValues = flattenJson(eval(content)) - - if 'meta.language.name' not in keyValues: - print(f"Error: 'meta.language.name' not found in {jsonFile}.") - sys.exit(1) - - f.write(f"#define LANGUAGE_{langUpper}_CODE \"{languageName}\"\n") - f.write(f"#define LANGUAGE_{langUpper}_NAME \"{keyValues['meta.language.name']}\"\n") - f.write(f"#define LANGUAGE_{langUpper}_COUNT {len(keyValues)}\n\n") - - # Write keys - f.write(f"static const char_t *LANGUAGE_{langUpper}_KEYS[] = {{\n") - for key in keyValues.keys(): - f.write(f' "{escapeString(key)}",\n') - f.write("};\n\n") - - # Write values - f.write(f"static const char_t *LANGUAGE_{langUpper}_VALUES[] = {{\n") - for value in keyValues.values(): - f.write(f' "{escapeString(value)}",\n') - f.write("};\n\n") - - languages.append(langUpper) - - if isFirstLanguage: - # For the first language, we also write the keysExpected - keysExpected = list(keyValues.keys()) - else: - for key in keysExpected: - if key in keyValues: - continue - print(f"Error, expected language translation key: '{key}' was not found in {jsonFile}.") - sys.exit(1) - -# Now write the main header file -mainOutputFile = os.path.join(outputDir, "languages.h") -with open(mainOutputFile, 'w', encoding='utf-8') as f: - f.write("// Generated from languagecompile.py\n") - f.write("#pragma once\n") - f.write("#include \"dusk.h\"\n") - for lang in languages: - f.write(f'#include "locale/language/{lang.lower()}.h"\n') - f.write("\n") - - f.write(f"#define LANGUAGE_COUNT {len(languages)}\n\n") - - index = 0 - for lang in languages: - f.write(f"#define LANGUAGE_{lang} {index}\n") - index += 1 - f.write("\n") - - f.write("static const char_t* LANGUAGE_CODES[] = {\n") - for lang in languages: - f.write(f' LANGUAGE_{lang}_CODE,\n') - f.write("};\n\n") - - f.write("static const char_t* LANGUAGE_NAMES[] = {\n") - for lang in languages: - f.write(f' LANGUAGE_{lang}_NAME,\n') - f.write("};\n\n") - - f.write("static const char_t** LANGUAGE_KEYS[] = {\n") - for lang in languages: - f.write(f' LANGUAGE_{lang}_KEYS,\n') - f.write("};\n\n") - - f.write("static const int LANGUAGE_COUNTS[] = {\n") - for lang in languages: - f.write(f' LANGUAGE_{lang}_COUNT,\n') - f.write("};\n\n") - - f.write("static const char_t** LANGUAGE_VALUES[] = {\n") - for lang in languages: - f.write(f' LANGUAGE_{lang}_VALUES,\n') - f.write("};\n\n") \ No newline at end of file diff --git a/archive/tools/mapcompile/CMakeLists.txt b/archive/tools/mapcompile/CMakeLists.txt deleted file mode 100644 index 7effe6c..0000000 --- a/archive/tools/mapcompile/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -find_package(Python3 COMPONENTS Interpreter REQUIRED) - -# Custom command to generate all header files -add_custom_target(DUSK_CHUNKS - # OUTPUT ${DUSK_GENERATED_HEADERS_DIR}/world/world.h - COMMAND - ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/mapcompile.py - --output ${DUSK_GENERATED_HEADERS_DIR} - --input ${DUSK_DATA_DIR}/map.tmj - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/mapcompile.py - COMMENT "Generating chunk header files" - VERBATIM -) - -# Ensure headers are generated before compiling main -add_dependencies(${DUSK_TARGET_NAME} DUSK_CHUNKS) \ No newline at end of file diff --git a/archive/tools/mapcompile/chunkParser.py b/archive/tools/mapcompile/chunkParser.py deleted file mode 100644 index 6ae4ce3..0000000 --- a/archive/tools/mapcompile/chunkParser.py +++ /dev/null @@ -1,127 +0,0 @@ -import sys -from constants import CHUNK_WIDTH, CHUNK_HEIGHT, CHUNK_TILE_COUNT, TILE_WIDTH_HEIGHT -from entityParser import parseEntity -import math - -def parseChunkLayerData(layer, mapData, chunkData): - layerData = [] - for y in range(CHUNK_HEIGHT): - for x in range(CHUNK_WIDTH): - inputTileIndex = chunkGetTileIndex(x, y, mapData, chunkData) - outputTileIndex = chunkGetOutputTileIndex(x, y) - layerData.append(layer['data'][inputTileIndex]) - - if len(layerData) != CHUNK_TILE_COUNT: - print(f"Error: Layer data length {len(layerData)} does not match expected chunk tile count {CHUNK_TILE_COUNT}.") - sys.exit(1) - - return layerData - -def parseChunk(chunkX, chunkY, mapData): - chunkData = { } - chunkData['topLeftTileX'] = chunkX * CHUNK_WIDTH - chunkData['topLeftTileY'] = chunkY * CHUNK_HEIGHT - chunkData['inputTopLeftTileX'] = math.floor( - float(chunkData['topLeftTileX']) / float(mapData['inputLayerWidthInTiles']) - ) * mapData['inputLayerWidthInTiles'] - chunkData['inputTopLeftTileY'] = math.floor( - float(chunkData['topLeftTileY']) / float(mapData['inputLayerHeightInTiles']) - ) * mapData['inputLayerHeightInTiles'] - - # Get the data for this chunk out of the map data. - chunkData['layers'] = [] - for layer in mapData['tileLayers']: - foundChunk = None - - if 'chunks' not in layer or not isinstance(layer['chunks'], list): - print(f"Error: Layer '{layer['name']}' does not contain 'chunks' key or it is not a list.") - sys.exit(1) - - for chunk in layer['chunks']: - if 'x' not in chunk or 'y' not in chunk: - print(f"Error: Chunk in layer '{layer['name']}' does not contain 'x' or 'y' key.") - sys.exit(1) - - # Check if this chunk is within the bounds of the top left tile. - if chunk['x'] != chunkData['inputTopLeftTileX'] or chunk['y'] != chunkData['inputTopLeftTileY']: - continue - - foundChunk = chunk - break - - if foundChunk is None: - chunkData['layers'].append(None) - continue - - # Is layer empty? - layerEmpty = True - for tile in foundChunk['data']: - if tile == 0: - continue - layerEmpty = False - break - - if layerEmpty: - chunkData['layers'].append(None) - else: - chunkData['layers'].append(foundChunk) - - # Any layers for this chunk? - if all(chunk is None for chunk in chunkData['layers']): - return None - - if len(chunkData['layers']) == 0: - return None - - # Parse Layer Data - chunkData['layerBase'] = chunkData['layers'][0] - chunkData['layerBaseOverlay'] = None - if len(chunkData['layers']) > 1: - chunkData['layerBaseOverlay'] = chunkData['layers'][1] - - chunkData['layerBaseData'] = parseChunkLayerData(chunkData['layerBase'], mapData, chunkData) - if chunkData['layerBaseOverlay'] is not None: - chunkData['layerBaseOverlayData'] = parseChunkLayerData(chunkData['layerBaseOverlay'], mapData, chunkData) - else: - chunkData['layerBaseOverlayData'] = [] - - # Parse chunk entities. - chunkData['entities'] = [] - for ob in mapData['objectLayer']['objects']: - if 'x' not in ob or 'y' not in ob: - print(f"Error: Object in object layer does not contain 'x' or 'y' key.") - sys.exit(1) - - # Is this object within the chunk? - if ob['x'] < chunkData['topLeftTileX'] * TILE_WIDTH_HEIGHT: - continue - if ob['x'] >= (chunkData['topLeftTileX'] + CHUNK_WIDTH) * TILE_WIDTH_HEIGHT: - continue - if ob['y'] < chunkData['topLeftTileY'] * TILE_WIDTH_HEIGHT: - continue - if ob['y'] >= (chunkData['topLeftTileY'] + CHUNK_HEIGHT) * TILE_WIDTH_HEIGHT: - continue - - ent = parseEntity(ob, chunkData) - if ent is None: - continue - - chunkData['entities'].append(ent) - - return chunkData - -def chunkGetLocalTileX(absoluteTileX, mapData): - return absoluteTileX % mapData['inputLayerWidthInTiles'] - -def chunkGetLocalTileY(absoluteTileY, mapData): - return absoluteTileY % mapData['inputLayerHeightInTiles'] - -def chunkGetTileIndex(localX, localY, mapData, chunkData): - absoluteTileX = chunkData['topLeftTileX'] + localX - absoluteTileY = chunkData['topLeftTileY'] + localY - inputLocalTileX = chunkGetLocalTileX(absoluteTileX, mapData) - inputLocalTileY = chunkGetLocalTileY(absoluteTileY, mapData) - return inputLocalTileY * mapData['inputLayerWidthInTiles'] + inputLocalTileX - -def chunkGetOutputTileIndex(localX, localY): - return localY * CHUNK_WIDTH + localX \ No newline at end of file diff --git a/archive/tools/mapcompile/constants.py b/archive/tools/mapcompile/constants.py deleted file mode 100644 index 824c01c..0000000 --- a/archive/tools/mapcompile/constants.py +++ /dev/null @@ -1,6 +0,0 @@ -# Values defined within C -CHUNK_WIDTH = 8 -CHUNK_HEIGHT = 8 -CHUNK_TILE_COUNT = CHUNK_WIDTH * CHUNK_HEIGHT -CHUNK_ENTITY_COUNT_MAX = 8 -TILE_WIDTH_HEIGHT = 16 \ No newline at end of file diff --git a/archive/tools/mapcompile/entityParser.py b/archive/tools/mapcompile/entityParser.py deleted file mode 100644 index df2e1d1..0000000 --- a/archive/tools/mapcompile/entityParser.py +++ /dev/null @@ -1,64 +0,0 @@ -import sys -from constants import TILE_WIDTH_HEIGHT - -ENTITY_TYPE_MAP = { - 'templates/NPC.tx': 'ENTITY_TYPE_NPC', -} - -def parseEntity(obj, chunkData): - if 'type' in obj: - if obj['type'] not in ENTITY_TYPE_MAP: - print(f"Unknown entity type: {obj['type']}") - return None - - entType = ENTITY_TYPE_MAP[obj['type']] - - elif 'template' in obj: - if obj['template'] not in ENTITY_TYPE_MAP: - print(f"Unknown entity template: {obj['template']}") - return None - entType = ENTITY_TYPE_MAP[obj['template']] - - else: - return None - - if 'properties' not in obj: - obj['properties'] = {} - - obj['localX'] = obj['x'] - (chunkData['topLeftTileX'] * TILE_WIDTH_HEIGHT) - obj['localY'] = obj['y'] - (chunkData['topLeftTileY'] * TILE_WIDTH_HEIGHT) - obj['dir'] = 'DIRECTION_SOUTH' - obj['type'] = entType - - def getProperty(propName): - for prop in obj['properties']: - if prop['name'] == propName: - return prop['value'] - return None - - # Handle per-type properties - if entType == 'ENTITY_TYPE_NPC': - interactType = getProperty('interactType') - if interactType is None: - print(f"NPC entity missing 'interactType' property: {obj['id']}") - sys.exit(1) - - obj['data'] = {} - obj['data']['npc'] = {} - obj['data']['npc']['interactType'] = interactType - - if interactType == 'NPC_INTERACT_TYPE_TEXT': - text = getProperty('interactText') - if text is None: - print(f"NPC entity missing 'interactText' property: {obj['id']}") - sys.exit(1) - obj['data']['npc']['text'] = text - - elif interactType == 'NPC_INTERACT_TYPE_EVENT': - event = getProperty('interactEvent') - if event is None: - print(f"NPC entity missing 'interactEvent' property: {obj['id']}") - sys.exit(1) - obj['data']['npc']['eventData'] = f'&EVENT_{event.upper()}' - - return obj \ No newline at end of file diff --git a/archive/tools/mapcompile/inputParser.py b/archive/tools/mapcompile/inputParser.py deleted file mode 100644 index c0863fb..0000000 --- a/archive/tools/mapcompile/inputParser.py +++ /dev/null @@ -1,32 +0,0 @@ -import os -import sys -import json - -def parseInputFile(inputFile): - if not os.path.isfile(inputFile): - print(f"Error: Input file '{inputFile}' does not exist.") - sys.exit(1) - - data = None - with open(inputFile, 'r') as f: - data = json.load(f) - - # Data should have height key - if 'height' not in data or 'width' not in data: - print(f"Error: Input file '{inputFile}' does not contain 'height' or 'width' key.") - sys.exit(1) - - if 'tilewidth' not in data or 'tileheight' not in data: - print(f"Error: Input file '{inputFile}' does not contain 'tilewidth' or 'tileheight' key.") - sys.exit(1) - - if 'infinite' not in data or not isinstance(data['infinite'], bool): - print(f"Error: Input file '{inputFile}' does not contain 'infinite' key.") - sys.exit(1) - - # Need layers - if 'layers' not in data or not isinstance(data['layers'], list) or len(data['layers']) == 0: - print(f"Error: Input file '{inputFile}' does not contain 'layers' key.") - sys.exit(1) - - return data \ No newline at end of file diff --git a/archive/tools/mapcompile/mapParser.py b/archive/tools/mapcompile/mapParser.py deleted file mode 100644 index d074d78..0000000 --- a/archive/tools/mapcompile/mapParser.py +++ /dev/null @@ -1,159 +0,0 @@ -import sys -from constants import TILE_WIDTH_HEIGHT, CHUNK_WIDTH, CHUNK_HEIGHT -import math - -def parseMap(data): - mapData = { - 'layers': data['layers'], - 'playerSpawnX': 0, - 'playerSpawnY': 0, - } - - # Object layer - for layer in mapData['layers']: - if layer.get('type') == 'objectgroup': - mapData['objectLayer'] = layer - break - - if mapData['objectLayer'] is None: - print(f"Error: Data does not contain an object layer.") - sys.exit(1) - - if 'objects' not in mapData['objectLayer'] or not isinstance(mapData['objectLayer']['objects'], list): - print(f"Error: Object layer does not contain 'objects' key or it is not a list.") - sys.exit(1) - - # Tile Layers - mapData['tileLayers'] = [] - for layer in mapData['layers']: - if layer.get('type') == 'tilelayer': - mapData['tileLayers'].append(layer) - - if len(mapData['tileLayers']) == 0: - print(f"Error: Data does not contain any tile layers.") - sys.exit(1) - - # First layer - mapData['firstLayer'] = mapData['tileLayers'][0] - if 'width' not in mapData['firstLayer'] or 'height' not in mapData['firstLayer']: - print(f"Error: First layer does not contain 'width' or 'height' key.") - sys.exit(1) - - if 'chunks' not in mapData['firstLayer'] or not isinstance(mapData['firstLayer']['chunks'], list): - print(f"Error: First layer does not contain 'chunks' key.") - sys.exit(1) - - if len(mapData['firstLayer']['chunks']) == 0: - print(f"Error: First layer does not contain any chunks.") - sys.exit(1) - - mapData['firstLayerFirstChunk'] = mapData['firstLayer']['chunks'][0] - - # Now determine the input map bounds. - isMinXFound = False - isMaxXFound = False - isMinYFound = False - isMaxYFound = False - mapData['inputMapLowestX'] = 0 - mapData['inputMapHighestX'] = 0 - mapData['inputMapLowestY'] = 0 - mapData['inputMapHighestY'] = 0 - mapData['inputLayerWidthInTiles'] = mapData['firstLayerFirstChunk']['width'] - mapData['inputLayerHeightInTiles'] = mapData['firstLayerFirstChunk']['height'] - - for chunk in mapData['firstLayer']['chunks']: - if 'x' not in chunk or 'y' not in chunk: - print(f"Error: Chunk in first layer does not contain 'x' or 'y' key.") - sys.exit(1) - - # Check chunk is not empty - if 'data' not in chunk or not isinstance(chunk['data'], list): - print(f"Error: Chunk in first layer does not contain 'data' key or it is not a list.") - sys.exit(1) - - if len(chunk['data']) != mapData['inputLayerWidthInTiles'] * mapData['inputLayerHeightInTiles']: - print(f"Error: Chunk in first layer does not contain the expected number of tiles.") - sys.exit(1) - - chunkEmpty = True - for tile in chunk['data']: - if tile == 0: - continue - chunkEmpty = False - break - - if chunkEmpty: - print(f"Warning: Chunk at ({chunk['x']}, {chunk['y']}) is empty, skipping.") - continue - - chunkX = chunk['x'] - chunkY = chunk['y'] - - if mapData['inputMapLowestX'] > chunkX or not isMinXFound: - mapData['inputMapLowestX'] = chunkX - isMinXFound = True - if mapData['inputMapHighestX'] < chunkX or not isMaxXFound: - mapData['inputMapHighestX'] = chunkX - isMaxXFound = True - - if mapData['inputMapLowestY'] > chunkY or not isMinYFound: - mapData['inputMapLowestY'] = chunkY - isMinYFound = True - if mapData['inputMapHighestY'] < chunkY or not isMaxYFound: - mapData['inputMapHighestY'] = chunkY - isMaxYFound = True - - mapData['inputMapHighestX'] += mapData['inputLayerWidthInTiles'] - mapData['inputMapHighestY'] += mapData['inputLayerHeightInTiles'] - - # We now offset all chunks by the lowest X/Y values to make them start at (0, 0). - for layerIndex, layer in enumerate(mapData['tileLayers']): - for chunkIndex, chunk in enumerate(layer['chunks']): - chunk['x'] -= mapData['inputMapLowestX'] - chunk['y'] -= mapData['inputMapLowestY'] - layer['chunks'][chunkIndex] = chunk - - mapData['layers'][layerIndex] = layer - - # Same for object layers - for obIndex, ob in enumerate(mapData['objectLayer']['objects']): - if 'x' not in ob or 'y' not in ob: - print(f"Error: Object in object layer does not contain 'x' or 'y' key.") - sys.exit(1) - - if 'id' not in ob: - print(f"Error: Object in object layer does not contain 'id' key.") - sys.exit(1) - - ob['x'] -= mapData['inputMapLowestX'] * TILE_WIDTH_HEIGHT - ob['y'] -= mapData['inputMapLowestY'] * TILE_WIDTH_HEIGHT - - # Objects are bottom aligned in tiled, so we need to adjust the Y coordinate. - ob['y'] -= TILE_WIDTH_HEIGHT - - # Round off the coordinates - ob['x'] = round(ob['x']) - ob['y'] = round(ob['y']) - - mapData['objectLayer']['objects'][obIndex] = ob - - mapData['mapWidthInTiles'] = mapData['inputMapHighestX'] - mapData['inputMapLowestX'] - mapData['mapHeightInTiles'] = mapData['inputMapHighestY'] - mapData['inputMapLowestY'] - mapData['mapWidthInRealChunks'] = math.ceil(float(mapData['mapWidthInTiles']) / float(CHUNK_WIDTH)) - mapData['mapHeightInRealChunks'] = math.ceil(float(mapData['mapHeightInTiles']) / float(CHUNK_HEIGHT)) - - if mapData['inputLayerWidthInTiles'] < CHUNK_WIDTH or mapData['inputLayerHeightInTiles'] < CHUNK_HEIGHT: - print(f"Error: Input layer size is smaller than chunk size.") - sys.exit(1) - - # Extract player spawn point - for ob in mapData['objectLayer']['objects']: - if 'type' not in ob or ob['type'] != 'player_spawn': - continue - if 'x' not in ob or 'y' not in ob: - print(f"Error: Player spawn object does not contain 'x' or 'y' key.") - sys.exit(1) - mapData['playerSpawnX'] = ob['x'] - mapData['playerSpawnY'] = ob['y'] - - return mapData \ No newline at end of file diff --git a/archive/tools/mapcompile/mapcompile.py b/archive/tools/mapcompile/mapcompile.py deleted file mode 100644 index 2c28807..0000000 --- a/archive/tools/mapcompile/mapcompile.py +++ /dev/null @@ -1,146 +0,0 @@ -import sys, os -import argparse -from datetime import datetime -import math -from inputParser import parseInputFile -from mapParser import parseMap -from chunkParser import parseChunk -from constants import CHUNK_WIDTH, CHUNK_HEIGHT, TILE_WIDTH_HEIGHT - -# Check if the script is run with the correct arguments -parser = argparse.ArgumentParser(description="Generate chunk header files") -parser.add_argument('--output', required=True, help='Dir to output headers') -parser.add_argument('--input', required=True, help='Input JSON file from tiled') -args = parser.parse_args() - -# Ensure outdir exists -outputDir = args.output -os.makedirs(outputDir, exist_ok=True) - -# Create world directory if it does not exist -worldDir = os.path.join(outputDir, "world") -os.makedirs(worldDir, exist_ok=True) - -# Create chunks directory if it does not exist -chunksDir = os.path.join(worldDir, "chunk") -os.makedirs(chunksDir, exist_ok=True) - -# Some vars used during printing -now = datetime.now().strftime("%Y-%m-%d %H:%M:%S") - -# Read the input JSON file -data = parseInputFile(args.input) -mapData = parseMap(data) - -# For each output chunk. -worldWidth = 0 -worldHeight = 0 -chunksDone = set() - -for chunkY in range(mapData['mapHeightInRealChunks']): - for chunkX in range(mapData['mapWidthInRealChunks']): - chunkData = parseChunk(chunkX, chunkY, mapData) - if chunkData is None: - continue - - # This is a valid chunk. - worldWidth = max(worldWidth, chunkX + 1) - worldHeight = max(worldHeight, chunkY + 1) - chunksDone.add((chunkX, chunkY)) - - chunkHeaderPath = os.path.join(chunksDir, f"chunk_{chunkX}_{chunkY}.h") - with open(chunkHeaderPath, 'w') as f: - f.write(f"// Generated chunk header for chunk at position ({chunkX}, {chunkY})\n") - f.write(f"// Generated at {now}\n") - f.write("#pragma once\n") - f.write("#include \"world/chunkdata.h\"\n\n") - f.write(f"static const chunkdata_t CHUNK_{chunkX}_{chunkY} = {{\n") - f.write(f" .layerBase = {{\n") - for y in range(CHUNK_HEIGHT): - f.write(f" ") - for x in range(CHUNK_WIDTH): - i = y * CHUNK_WIDTH + x - byte = chunkData['layerBaseData'][i] - f.write(f"0x{byte:02x}, ") - f.write(f"\n") - f.write(" },\n\n") - - f.write(" .layerBaseOverlay = {\n") - if chunkData['layerBaseOverlay'] is not None: - for y in range(CHUNK_HEIGHT): - f.write(f" ") - for x in range(CHUNK_WIDTH): - i = y * CHUNK_WIDTH + x - byte = chunkData['layerBaseOverlayData'][i] - f.write(f"0x{byte:02x}, ") - f.write(f"\n") - f.write(" },\n\n") - - f.write(f" .entities = {{\n") - for entity in chunkData['entities']: - - f.write(" {\n") - f.write(f" .id = {entity['id']},\n") - f.write(f" .type = {entity['type']},\n") - f.write(f" .x = {round(entity['x'] / TILE_WIDTH_HEIGHT)},\n") - f.write(f" .y = {round(entity['y'] / TILE_WIDTH_HEIGHT)},\n") - - if 'dir' in entity: - f.write(f" .dir = {entity['dir']},\n") - - def printRecurse(obj, tabs = " "): - for key, value in obj: - if isinstance(value, dict): - f.write(f"{tabs}.{key} = {{\n") - printRecurse(value.items(), tabs + " ") - f.write(f"{tabs}}},\n") - elif isinstance(value, list): - f.write(f"{tabs}.{key} = {{\n") - for item in value: - f.write(f"{tabs} {item},\n") - f.write(f"{tabs}}},\n") - else: - f.write(f"{tabs}.{key} = {value},\n") - - - if 'data' in entity: - printRecurse(entity['data'].items()) - - f.write(" },\n") - f.write(f" }},\n") - - f.write("};\n\n") - -# Output header file. -headerPath = os.path.join(worldDir, "world.h") -with open(headerPath, 'w') as f: - f.write(f"// Generated chunks file. Generated at {now}\n\n") - f.write("#pragma once\n") - f.write("#include \"dusk.h\"\n") - - # Now, for each chunk, include its header file - for (x, y) in chunksDone: - f.write(f"#include \"world/chunk/chunk_{x}_{y}.h\"\n") - - f.write("\n") - f.write(f"#define WORLD_WIDTH {worldWidth}\n") - f.write(f"#define WORLD_HEIGHT {worldHeight}\n") - - # Write out other global variables. - f.write(f"#define WORLD_PLAYER_SPAWN_X ({round(mapData['playerSpawnX'] / TILE_WIDTH_HEIGHT)})\n") - f.write(f"#define WORLD_PLAYER_SPAWN_Y ({round(mapData['playerSpawnY'] / TILE_WIDTH_HEIGHT)})\n") - - f.write("\n") - - f.write(f"static const chunkdata_t* WORLD_CHUNKS[] = {{\n") - for i in range(worldHeight): - f.write(" ") - for j in range(worldWidth): - if(j, i) in chunksDone: - f.write(f"&CHUNK_{j}_{i}, ") - else: - f.write("NULL, ") - f.write("\n") - f.write("};\n\n") - -print(f"chunks.h generated at: {headerPath}") \ No newline at end of file diff --git a/archive/tools/tilecompile/CMakeLists.txt b/archive/tools/tilecompile/CMakeLists.txt deleted file mode 100644 index 25ce346..0000000 --- a/archive/tools/tilecompile/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) 2025 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -find_package(Python3 COMPONENTS Interpreter REQUIRED) - -# Custom command to generate all header files -add_custom_target(DUSK_TILES - COMMAND - ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tilecompile.py - --output ${DUSK_GENERATED_HEADERS_DIR} - --input ${DUSK_DATA_DIR}/overworld.tsx - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tilecompile.py - COMMENT "Generating tile header file" - VERBATIM -) - -# Ensure headers are generated before compiling main -add_dependencies(${DUSK_TARGET_NAME} DUSK_TILES) \ No newline at end of file diff --git a/archive/tools/tilecompile/tilecompile.py b/archive/tools/tilecompile/tilecompile.py deleted file mode 100644 index 01270ed..0000000 --- a/archive/tools/tilecompile/tilecompile.py +++ /dev/null @@ -1,109 +0,0 @@ -import sys, os -import argparse -from datetime import datetime -import xml.etree.ElementTree as ET - -# Check if the script is run with the correct arguments -parser = argparse.ArgumentParser(description="Generate chunk header files") -parser.add_argument('--output', required=True, help='Dir to output headers') -parser.add_argument('--input', required=True, help='Input XML file from tiled') -args = parser.parse_args() - -# Ensure outdir exists -outputDir = args.output -os.makedirs(outputDir, exist_ok=True) - -# Create world directory if it does not exist -worldDir = os.path.join(outputDir, "world") -os.makedirs(worldDir, exist_ok=True) - -# Some vars used during printing -now = datetime.now().strftime("%Y-%m-%d %H:%M:%S") - -# Read the input JSON file -inputFile = args.input -if not os.path.isfile(inputFile): - print(f"Error: Input file '{inputFile}' does not exist.") - sys.exit(1) - -with open(inputFile, 'r') as f: - data = f.read() - -# Parse the XML data -try: - root = ET.fromstring(data) -except ET.ParseError as e: - print(f"Error parsing XML: {e}") - sys.exit(1) - -if root.tag != 'tileset': - print("Error: Input file is not a valid Tiled XML file.") - sys.exit(1) - -if 'tilewidth' not in root.attrib or 'tileheight' not in root.attrib: - print("Error: Missing tilewidth or tileheight attributes in the tileset.") - sys.exit(1) - -if 'tilecount' not in root.attrib or 'columns' not in root.attrib: - print("Error: Missing tilecount or columns attributes in the tileset.") - sys.exit(1) - -tileWidth = int(root.get('tilewidth', 0)) -tileHeight = int(root.get('tileheight', 0)) -tileCount = int(root.get('tilecount', 0)) + 1 # +1 because maps are 1 indexed -columns = int(root.get('columns', 0)) - -tilesById = {} -for tile in root.findall('tile'): - if 'id' not in tile.attrib: - print("Error: Tile element missing 'id' attribute.") - continue - - tileId = int(tile.get('id', -1)) + 1 # +1 because maps are 1 indexed - if tileId < 0 or tileId >= tileCount: - print(f"Error: Invalid tile ID {tileId} in tile element.") - continue - - tilesById[tileId] = tile - -# Create the header file -headerFile = os.path.join(worldDir, "tiledata.h") -with open(headerFile, 'w') as f: - f.write(f"// Generated on {now}\n") - f.write(f"#include \"world/tile.h\"\n\n") - f.write(f"#define TILE_WIDTH {tileWidth}\n") - f.write(f"#define TILE_HEIGHT {tileHeight}\n") - f.write(f"#define TILE_WIDTH_HEIGHT {tileWidth}\n") - f.write(f"#define TILE_COUNT {tileCount}\n") - - f.write("static const tilemetadata_t TILE_META_DATA[TILE_COUNT] = {\n") - for tileId in range(tileCount): - tile = tilesById.get(tileId, None) - if tile is None: - f.write(f" {{ 0 }},\n") - continue - - properties = tile.find('properties') - if properties is None: - f.write(f" {{ 0 }},\n") - continue - - def findProp(name, expectedType=''): - for prop in properties.findall('property'): - if prop.get('name') == name: - if len(expectedType) > 0: - if 'type' in prop.attrib and prop.get('type') != expectedType: - continue - if 'propertytype' in prop.attrib and prop.get('propertytype') != expectedType: - continue - return prop.get('value', '') - return None - - f.write(f" {{\n") - - propSolid = findProp('solidType', 'tileSolidType') - if propSolid is not None: - f.write(f" .solidType = {propSolid},\n") - - f.write(f" }},\n") - f.write("};\n\n") \ No newline at end of file diff --git a/assets/CMakeLists.txt b/assets/CMakeLists.txt index 334492b..f4eb068 100644 --- a/assets/CMakeLists.txt +++ b/assets/CMakeLists.txt @@ -3,9 +3,10 @@ # This software is released under the MIT License. # https://opensource.org/licenses/MIT -add_subdirectory(palette)# Palette asset needs to be added before any images. - -add_subdirectory(config) -add_subdirectory(entity) -add_subdirectory(map) -add_subdirectory(ui) \ No newline at end of file +if(DUSK_TARGET_GAME STREQUAL "rpg") + add_subdirectory(rpg) +elseif(DUSK_TARGET_GAME STREQUAL "minesweeper") + add_subdirectory(minesweeper) +else() + message(FATAL_ERROR "Unknown game specified: ${DUSK_TARGET_GAME}") +endif() \ No newline at end of file diff --git a/assets/minesweeper/CMakeLists.txt b/assets/minesweeper/CMakeLists.txt new file mode 100644 index 0000000..1f51776 --- /dev/null +++ b/assets/minesweeper/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (c) 2025 Dominic Masters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +set(DUSK_GAME_ASSETS_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL ${DUSK_CACHE_TARGET}) + +add_subdirectory(palette)# Palette asset needs to be added before any images. +add_subdirectory(config) +add_subdirectory(ui) \ No newline at end of file diff --git a/assets/config/CMakeLists.txt b/assets/minesweeper/config/CMakeLists.txt similarity index 100% rename from assets/config/CMakeLists.txt rename to assets/minesweeper/config/CMakeLists.txt diff --git a/assets/config/init.dcf b/assets/minesweeper/config/init.dcf similarity index 100% rename from assets/config/init.dcf rename to assets/minesweeper/config/init.dcf diff --git a/assets/config/init_psp.dcf b/assets/minesweeper/config/init_psp.dcf similarity index 100% rename from assets/config/init_psp.dcf rename to assets/minesweeper/config/init_psp.dcf diff --git a/assets/palette/CMakeLists.txt b/assets/minesweeper/palette/CMakeLists.txt similarity index 100% rename from assets/palette/CMakeLists.txt rename to assets/minesweeper/palette/CMakeLists.txt diff --git a/assets/palette/palette0.png b/assets/minesweeper/palette/palette0.png similarity index 100% rename from assets/palette/palette0.png rename to assets/minesweeper/palette/palette0.png diff --git a/assets/palette/palette0.pxo b/assets/minesweeper/palette/palette0.pxo similarity index 100% rename from assets/palette/palette0.pxo rename to assets/minesweeper/palette/palette0.pxo diff --git a/assets/ui/CMakeLists.txt b/assets/minesweeper/ui/CMakeLists.txt similarity index 100% rename from assets/ui/CMakeLists.txt rename to assets/minesweeper/ui/CMakeLists.txt diff --git a/assets/ui/minogram.png b/assets/minesweeper/ui/minogram.png similarity index 100% rename from assets/ui/minogram.png rename to assets/minesweeper/ui/minogram.png diff --git a/assets/rpg/CMakeLists.txt b/assets/rpg/CMakeLists.txt new file mode 100644 index 0000000..280a291 --- /dev/null +++ b/assets/rpg/CMakeLists.txt @@ -0,0 +1,13 @@ +# Copyright (c) 2025 Dominic Masters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +set(DUSK_GAME_ASSETS_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL ${DUSK_CACHE_TARGET}) + +add_subdirectory(palette)# Palette asset needs to be added before any images. + +add_subdirectory(config) +add_subdirectory(entity) +add_subdirectory(map) +add_subdirectory(ui) \ No newline at end of file diff --git a/archive/dusk/error/CMakeLists.txt b/assets/rpg/config/CMakeLists.txt similarity index 65% rename from archive/dusk/error/CMakeLists.txt rename to assets/rpg/config/CMakeLists.txt index b246fdb..bd115c1 100644 --- a/archive/dusk/error/CMakeLists.txt +++ b/assets/rpg/config/CMakeLists.txt @@ -3,8 +3,5 @@ # This software is released under the MIT License. # https://opensource.org/licenses/MIT -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - error.c -) \ No newline at end of file +add_asset(CONFIG init.dcf) +add_asset(CONFIG init_psp.dcf) \ No newline at end of file diff --git a/assets/rpg/config/init.dcf b/assets/rpg/config/init.dcf new file mode 100644 index 0000000..714d2c7 --- /dev/null +++ b/assets/rpg/config/init.dcf @@ -0,0 +1,17 @@ +echo " = Dawn Init = "; + +bind ` toggleconsole; +bind w up; +bind s down; +bind a left; +bind d right; +bind up up; +bind down down; +bind left left; +bind right right; +bind e accept; +bind enter accept; +bind q cancel; +bind esc quit; + +fps 1; \ No newline at end of file diff --git a/assets/rpg/config/init_psp.dcf b/assets/rpg/config/init_psp.dcf new file mode 100644 index 0000000..18162c5 --- /dev/null +++ b/assets/rpg/config/init_psp.dcf @@ -0,0 +1,17 @@ +echo " = Dawn PSP = "; + +bind up up; +bind down down; +bind left left; +bind right right; +bind cross accept; +bind circle cancel; +bind select toggleconsole; +bind start toggleconsole; + +bind lstick_negative_y up; +bind lstick_positive_y down; +bind lstick_negative_x left; +bind lstick_positive_x right; + +fps 1; \ No newline at end of file diff --git a/assets/entity/CMakeLists.txt b/assets/rpg/entity/CMakeLists.txt similarity index 100% rename from assets/entity/CMakeLists.txt rename to assets/rpg/entity/CMakeLists.txt diff --git a/assets/entity/entities.png b/assets/rpg/entity/entities.png similarity index 100% rename from assets/entity/entities.png rename to assets/rpg/entity/entities.png diff --git a/assets/entity/entities.tsx b/assets/rpg/entity/entities.tsx similarity index 100% rename from assets/entity/entities.tsx rename to assets/rpg/entity/entities.tsx diff --git a/assets/map/CMakeLists.txt b/assets/rpg/map/CMakeLists.txt similarity index 100% rename from assets/map/CMakeLists.txt rename to assets/rpg/map/CMakeLists.txt diff --git a/assets/map/untitled.tmx b/assets/rpg/map/untitled.tmx similarity index 100% rename from assets/map/untitled.tmx rename to assets/rpg/map/untitled.tmx diff --git a/archive/dusk/item/CMakeLists.txt b/assets/rpg/palette/CMakeLists.txt similarity index 64% rename from archive/dusk/item/CMakeLists.txt rename to assets/rpg/palette/CMakeLists.txt index 19db837..d8eda53 100644 --- a/archive/dusk/item/CMakeLists.txt +++ b/assets/rpg/palette/CMakeLists.txt @@ -3,8 +3,4 @@ # This software is released under the MIT License. # https://opensource.org/licenses/MIT -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - inventory.c -) \ No newline at end of file +add_asset(PALETTE palette0.png) \ No newline at end of file diff --git a/assets/rpg/palette/palette0.png b/assets/rpg/palette/palette0.png new file mode 100644 index 0000000000000000000000000000000000000000..e60ee7f03b8203942557e7c074c2a48812e84763 GIT binary patch literal 241 zcmeAS@N?(olHy`uVBq!ia0vp^W*#=i1b8AR%#qqQstn z``@3-=$>}U=4HrSV4$B{aFadA`RJL~3YUHQdn=`K602tM@4fuB_ppWURp#AXdeZx9 z0{IV}KNR?5ckQNooqyjRu<-Ahf9j=YjQB&5ca2UOuD|BJbJ!dpx^({}zmS$!E+5@? oElzfP-Bo8T#q8FVdQ&MBb@0Pmh#umAu6 literal 0 HcmV?d00001 diff --git a/assets/rpg/palette/palette0.pxo b/assets/rpg/palette/palette0.pxo new file mode 100644 index 0000000000000000000000000000000000000000..070274afbdfd1fc0eef1d4f6e873b51cbf7d8a86 GIT binary patch literal 1576 zcmWIWW@Zs#VBp|jU=1>g4oRH7^$jxv!v$dm22KVBhLpsTM7^xy{Jh>7uZvb02po?; zdUE+?$=iw(3aZ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90sBJDZrbR Q4Wx+~2rmL@M^+FI09ARJfdBvi literal 0 HcmV?d00001 diff --git a/assets/tileset/prarie.png b/assets/rpg/tileset/prarie.png similarity index 100% rename from assets/tileset/prarie.png rename to assets/rpg/tileset/prarie.png diff --git a/assets/tileset/prarie.pxo b/assets/rpg/tileset/prarie.pxo similarity index 100% rename from assets/tileset/prarie.pxo rename to assets/rpg/tileset/prarie.pxo diff --git a/assets/tileset/prarie.tsx b/assets/rpg/tileset/prarie.tsx similarity index 100% rename from assets/tileset/prarie.tsx rename to assets/rpg/tileset/prarie.tsx diff --git a/archive/dusk/world/CMakeLists.txt b/assets/rpg/ui/CMakeLists.txt similarity index 60% rename from archive/dusk/world/CMakeLists.txt rename to assets/rpg/ui/CMakeLists.txt index 446cdbf..ffe622f 100644 --- a/archive/dusk/world/CMakeLists.txt +++ b/assets/rpg/ui/CMakeLists.txt @@ -3,9 +3,4 @@ # This software is released under the MIT License. # https://opensource.org/licenses/MIT -# Sources -target_sources(${DUSK_TARGET_NAME} - PRIVATE - chunk.c - overworld.c -) \ No newline at end of file +add_asset(TILESET minogram.png type=ALPHA tileWidth=6 tileHeight=10 columns=16 rows=6) \ No newline at end of file diff --git a/assets/rpg/ui/minogram.png b/assets/rpg/ui/minogram.png new file mode 100644 index 0000000000000000000000000000000000000000..c41f917ac2882308e41c4beb580f5753860562e8 GIT binary patch literal 1260 zcmV z?Q*Oj42Gf8`@dz+pVG-m-+Vz3ba`fW++swO5Xp->t=Dyx!#ZlMOV9uHvz5Hy681~w zT3x@ei_^{FHh?dWywYz<`aDpBO;2lf1 ztz&BW+ezGJHmjqAcCA}4A%+O!4D0V0i(A^;y**2td?nkQI9N4GY=K*^M zY|-%z?;JpTJV+r9*=qJyl#p(;mO@5u^hoY5iCJ59Hp1fo){UWx9zU)K_cMr7X>olZGQUZduIRi`)Y zT|&kjVD?4Ks(+S7@F+YwKx3pMdXzx#LQ!vfqSvE|I^MdrOan{tNvR_tYa|WyI1fT= zZ?xkyBFf$tolc>PK}gQ^@YFDvDamfvv0i!}0h*%a9j(^LkFKuq?_R}{M}mx*`j(2H zL_K-&T6Xzu;Ne60I3-Xb`mW&Wk(&kmT>yXEMSBazV~FR^rw34?kq5fwPeWoXBF%f#CUhxRg_)@(9+*MfFA&Wu$r! zgpr?z&jfX}6!xt;4hrp+ut-SHwAVs9IyQ=>>_wJ?UkO(Nsg(Lre5ww>CxP#{s)L)e z7O;?DdnThJ`(KIlMo{E!9M4-io~*(1 z{(yB}scvn*l?iy-BDKeBzYJ+Dpb=RMkm}LwshzZzV6~@}YY{}+?@a^g_4TfmNcKy~ zSPt&Zqch*ji}JDQE+@kQJe|1PjoxkLav4Yoq(l~jqqWK<_Bkp2aJG=U=S@?D|Sr#zYc1euYX`IbVZ>92sFkl|wGz0J z$eiHy?*v}#Q`nYYe8e6ddsjJX=Ye1;fpnjwbTwuRJCYiw**7vWf|bJ6G`#;ZhJJ51 zV)m%YQV)@RPe^}V=ajZo~z$+<7&iTqt%fwOw5!$L2%DuJv(TJ8pJyPtn z`q3OgI*-L`9SQx%5KB(&(fze!G<)<2LVriv?`>C)-Q(C*35;?Szr*2hI2;a#0RI5C W$o0rJ!cj&50000B&-@joS{ z(|>~ZO*#FlIO<-_#;rA_vTFAHUz}WWPENn<-?02?d3;uG%%hv1Rqswewd|AF!KY_ntC-PW@`nINPfx=pN9LO39Fzuw(bu jCx1W34D=v5fW3_Q==p_uAC?$@0BQGh^>bP0l+XkKX3vC> diff --git a/data/entities.pxo b/data/entities.pxo deleted file mode 100644 index a147dda01648ef1c68556de33005b79e57b4e21a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 974 zcmWIWW@Zs#VBp|j*zIy5>as!I-7H21hA&JE44e!M3@M2viF#SZ`FX8DZ?g^?@YGCQ z7%#nKspgwzo5S}KL>8-gY0tWGtZdhgrSI)5eQ&k#x*a$&>0M3vH_2`5K39JVsL3_b z@J*hR;nv(}2bSzyoKAGI#D8<5Y|FajD|K_KzJN&y!UH7io(Q#{4vBZrRg8w|` z-rC)_`ea1`TC$TcMDBkex zO-HU~0}5|6lvA@&A7*Wxq?#|M`9S=G)7*Ki})WoTvNmujyT8 zuqQ|-%=e&$Nbh^5OCZC5sgyw(h_Qu8W?o8Wa%yorG-Q$)fMzfPlQiyx4ssaCL - - - diff --git a/data/events/test_event.json b/data/events/test_event.json deleted file mode 100644 index 0d2e838..0000000 --- a/data/events/test_event.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "key": "test_event", - "items": [ - { - "type": "text", - "text": "This is a bucket" - }, - { - "type": "text", - "text": "Dear God" - } - ] -} \ No newline at end of file diff --git a/data/languages/en.json b/data/languages/en.json deleted file mode 100644 index e5825ea..0000000 --- a/data/languages/en.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "meta": { - "language": { - "name": "English", - "code": "en" - } - }, - "test": { - "npc": { - "text": "Hello, {{ name }}." - } - } -} \ No newline at end of file diff --git a/data/map project.tiled-project b/data/map project.tiled-project deleted file mode 100644 index bf2dde3..0000000 --- a/data/map project.tiled-project +++ /dev/null @@ -1,42 +0,0 @@ -{ - "automappingRulesFile": "", - "commands": [ - ], - "compatibilityVersion": 1100, - "extensionsPath": "extensions", - "folders": [ - "." - ], - "properties": [ - ], - "propertyTypes": [ - { - "id": 1, - "name": "npcInteractType", - "storageType": "string", - "type": "enum", - "values": [ - "NPC_INTERACT_TYPE_NONE", - "NPC_INTERACT_TYPE_TEXT", - "NPC_INTERACT_TYPE_CONVO", - "NPC_INTERACT_TYPE_EVENT" - ], - "valuesAsFlags": false - }, - { - "id": 2, - "name": "tileSolidType", - "storageType": "string", - "type": "enum", - "values": [ - "TILE_SOLID_NONE", - "TILE_SOLID_FULL", - "TILE_SOLID_TRIANGLE_TOP_RIGHT", - "TILE_SOLID_TRIANGLE_TOP_LEFT", - "TILE_SOLID_TRIANGLE_BOTTOM_RIGHT", - "TILE_SOLID_TRIANGLE_BOTTOM_LEFT" - ], - "valuesAsFlags": false - } - ] -} diff --git a/data/map project.tiled-session b/data/map project.tiled-session deleted file mode 100644 index aaf4404..0000000 --- a/data/map project.tiled-session +++ /dev/null @@ -1,74 +0,0 @@ -{ - "Map/SizeTest": { - "height": 4300, - "width": 2 - }, - "activeFile": "/home/yourwishes/htdocs/dusk/assets/map/untitled.tmx", - "expandedProjectPaths": [ - "templates", - "." - ], - "fileStates": { - "/home/yourwishes/htdocs/dusk/assets/entity/entities.tsx": { - "scaleInDock": 1, - "scaleInEditor": 1 - }, - "/home/yourwishes/htdocs/dusk/assets/map/untitled.tmx": { - "scale": 1.9163281249999997, - "selectedLayer": 0, - "viewCenter": { - "x": 546.8792042072649, - "y": 320.14350360797425 - } - }, - ":/automap-tiles.tsx": { - "scaleInDock": 1 - }, - "entities.tsx": { - "scaleInDock": 1, - "scaleInEditor": 1 - }, - "map.tmj": { - "scale": 3, - "selectedLayer": 2, - "viewCenter": { - "x": 6912, - "y": 6911.833333333333 - } - }, - "minogram.tsx": { - "scaleInDock": 1, - "scaleInEditor": 16 - }, - "overworld.tsx": { - "scaleInDock": 1, - "scaleInEditor": 4 - } - }, - "last.externalTilesetPath": "/home/yourwishes/htdocs/dusk/data", - "last.imagePath": "/home/yourwishes/htdocs/dusk/data", - "last.objectTemplatePath": "/home/yourwishes/htdocs/dusk/data/templates", - "map.lastUsedFormat": "tmx", - "openFiles": [ - "/home/yourwishes/htdocs/dusk/assets/map/untitled.tmx", - "/home/yourwishes/htdocs/dusk/assets/entity/entities.tsx" - ], - "project": "map project.tiled-project", - "property.type": "string", - "recentFiles": [ - "/home/yourwishes/htdocs/dusk/assets/entity/entities.tsx", - "/home/yourwishes/htdocs/dusk/assets/map/untitled.tmx", - "map.tmj", - "overworld.tsx", - "entities.tsx", - "minogram.tsx" - ], - "tileset.lastUsedFilter": "Tiled tileset files (*.tsx *.xml)", - "tileset.lastUsedFormat": "tsx", - "tileset.margin": 1, - "tileset.spacing": 1, - "tileset.tileSize": { - "height": 9, - "width": 5 - } -} diff --git a/data/map.tmj b/data/map.tmj deleted file mode 100644 index f5b013c..0000000 --- a/data/map.tmj +++ /dev/null @@ -1,477 +0,0 @@ -{ "compressionlevel":-1, - "height":720, - "infinite":true, - "layers":[ - { - "chunks":[ - { - "data":[0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1], - "height":16, - "width":16, - "x":384, - "y":416 - }, - { - "data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 1, 1, 1, 1, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 18, 19, 20, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 34, 35, 36, 1, 1], - "height":16, - "width":16, - "x":400, - "y":416 - }, - { - "data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 19, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], - "height":16, - "width":16, - "x":400, - "y":432 - }, - { - "data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 49, 49, 49, 49, 49, 49, 49, 49, 49, 1, 1, 1, 1, 1, - 1, 1, 49, 49, 49, 67, 49, 49, 49, 49, 49, 1, 1, 1, 1, 1, - 1, 1, 49, 49, 49, 49, 67, 49, 49, 49, 49, 1, 1, 1, 1, 1, - 1, 1, 49, 49, 49, 49, 67, 49, 49, 49, 49, 1, 1, 1, 1, 1, - 1, 1, 49, 49, 49, 49, 49, 67, 49, 49, 49, 1, 1, 1, 1, 1, - 1, 1, 49, 49, 49, 49, 49, 49, 49, 49, 49, 1, 1, 1, 1, 1, - 1, 1, 49, 49, 49, 49, 49, 49, 49, 67, 49, 1, 1, 1, 1, 1, - 1, 1, 49, 49, 49, 49, 49, 49, 49, 67, 49, 1, 1, 1, 1, 1, - 1, 1, 49, 49, 49, 49, 49, 49, 49, 49, 49, 1, 1, 1, 1, 1, - 1, 1, 49, 49, 49, 49, 49, 49, 49, 49, 49, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], - "height":16, - "width":16, - "x":416, - "y":432 - }, - { - "data":[1, 115, 115, 115, 115, 115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 115, 115, 115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 115, 115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 115, 115, 115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], - "height":16, - "width":16, - "x":464, - "y":432 - }], - "height":32, - "id":1, - "name":"Base Layer", - "opacity":1, - "startx":384, - "starty":416, - "type":"tilelayer", - "visible":true, - "width":96, - "x":0, - "y":0 - }, - { - "chunks":[ - { - "data":[0, 0, 0, 2, 3, 3, 3, 3, 4, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 18, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 18, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 18, 0, 0, 0, 0, 6, 3, 3, 3, 3, 3, 3, 3, - 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0,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, 0, 0, 0, 234, 0, 0, 0, 0, 0, 0, 0, 0, - 114, 0, 0, 0, 99, 99, 99, 100, 0, 0, 0, 0, 0, 0, 0, 0, - 114, 0, 0, 0, 0, 0, 0, 116, 0, 0, 0, 0, 0, 0, 0, 0], - "height":16, - "width":16, - "x":432, - "y":416 - }, - { - "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 50, 51, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 66, 0, 68, 0, 85, 0, 71, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 82, 69, 54, 52, 0, 55, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 39, 0, 66, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 82, 69, 0, 52, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 82, 69, 54, 52, 0, 0, 0, 0, 0, 0, - 0, 0, 71, 0, 0, 0, 0, 82, 69, 0, 52, 0, 0, 0, 0, 130, - 0, 0, 0, 0, 0, 55, 0, 0, 66, 0, 68, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 82, 83, 84, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - "height":16, - "width":16, - "x":416, - "y":432 - }, - { - "data":[114, 0, 0, 0, 0, 0, 0, 116, 0, 0, 0, 0, 0, 0, 0, 0, - 130, 131, 131, 0, 0, 0, 0, 116, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 98, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 132, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 132, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 132, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - "height":16, - "width":16, - "x":432, - "y":432 - }], - "height":32, - "id":5, - "locked":true, - "name":"Overlay Base Layer", - "opacity":1, - "startx":400, - "starty":416, - "type":"tilelayer", - "visible":true, - "width":48, - "x":0, - "y":0 - }, - { - "draworder":"topdown", - "id":3, - "name":"Object Layer 1", - "objects":[ - { - "gid":257, - "height":16, - "id":6, - "name":"Player Spawn", - "rotation":0, - "type":"player_spawn", - "visible":true, - "width":16, - "x":6578.25, - "y":6794.25 - }, - { - "id":13, - "properties":[ - { - "name":"interactEvent", - "type":"string", - "value":"test_event" - }, - { - "name":"interactText", - "type":"string", - "value":"test.npc.text" - }, - { - "name":"interactType", - "propertytype":"npcInteractType", - "type":"string", - "value":"NPC_INTERACT_TYPE_EVENT" - }], - "template":"templates\/NPC.tx", - "x":6539.95833333333, - "y":6849.66666666666 - }], - "opacity":1, - "type":"objectgroup", - "visible":true, - "x":0, - "y":0 - }], - "nextlayerid":6, - "nextobjectid":14, - "orientation":"orthogonal", - "renderorder":"right-down", - "tiledversion":"1.11.2", - "tileheight":16, - "tilesets":[ - { - "firstgid":1, - "source":"overworld.tsx" - }, - { - "firstgid":257, - "source":"entities.tsx" - }, - { - "firstgid":321, - "source":":\/automap-tiles.tsx" - }], - "tilewidth":16, - "type":"map", - "version":"1.10", - "width":500 -} \ No newline at end of file diff --git a/data/minogram.tsx b/data/minogram.tsx deleted file mode 100644 index 373dc3f..0000000 --- a/data/minogram.tsx +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/data/minogram_6x10.png b/data/minogram_6x10.png deleted file mode 100644 index a198a751f7e63efea5cdeb5c9caad6f9c8b53c2e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1128 zcmV-u1eg1XP)$Q00009a7bBm000XU z000XU0RWnu7ytkS8c9S!RCt{2T-%c5APCi|{Qoa!U)B^MTn>0iGLuu4>TN|N2nx78 zb>H{$A&%|;C)HjR+Gu-}URs%Iv|IeS3?3f}O0V&;#+|-z1|u$jH?c;qy@=Ls@wa$* zbP~`pmqq#sP9z~J>{Iwh6n!z6O{YDW)4^G2d@TORcF-eF^nFhB(jKP~XC@OT1=?vJ zqI3zCyw;uup}A@$PZV!GmbHTgLdI43gox`|Cp3q}-;=TZyBUGUhg%*jXZ_;197dd~ ze-fYKlJElHnHdF2-}=yqe@6R79_w(Jol$7?J(<7^i1FnQ{c<@MR83Sc>cQVRZZs(juEU(y!5>a+Ff; zw>X+D^ez-~xb*a&pjCh))mNk{i=3WF{mz?L<8AeOv79K2mgH-~MU!MnFdkd+mx{{M z+AWLK`q2RR5@e4!Rii1FB+P1bhf5S0;maOaS<3adWYjaivPFGiG`rk1Uqs<=@vIc;yfI{?=3`2FLlihDd-08HTppD2Cn z;{h*1Py4LEI2w>=+c_$|b3hqI=%uk<*?M+h?3LOj`i6skm8su5DZ72k2X9(lU< zV7|v$kvwga@aBWSf|)rqf=o!ES%Q^XN$n9ALyC`Hc)?}WwgS;0=pGlf7|*3>e8k5U zrQJ&DGT)`e(Dq*K{oz~{fo5sx6lMZO@mDQQGj-3Ty~rLp7!Vhm#ivWDUmTY}t@Tq} z7I#-iUJI@`Zhn?IN_8}^wie+(f<6jq|GuEsdQzNp3VCr|WW$Z}&&Z?kLE6yqdnwO# zRV$RR0$VHSMy=Jdx?_%2ii;=$&2c?NSe0QbaMwOhJXYR0pe~6h1yQb*mLZj1Z80D1 zs?ohq+Yhbp(wx$#xJXoSlCa*&M)r{?|BO5uAEXT(UrYHihZJ}?@*#lF;*#)wuey^b z3nY`!GLT5{y3_)^ABa@)tP+eDK&7xiJCu4C8HS~}yYCRt6O_kmOXNlmhn{MxHBKsV zqq2C#)u})fH@n2GK}*G?t3U68W;p2IR??u|GD#RMG~#-6Ut6}w$X|h29j`R2;Tt_| u=dPM@`7Vr% - - - - - - - - - - - - - - - - - - - - diff --git a/data/templates/NPC.tx b/data/templates/NPC.tx deleted file mode 100644 index 3a29790..0000000 --- a/data/templates/NPC.tx +++ /dev/null @@ -1,10 +0,0 @@ - - diff --git a/data/tilemap.png b/data/tilemap.png deleted file mode 100644 index b636c0fc426784fc4dfe0f7268b388e53a26bcfa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9781 zcmeHtG|wN(@K}0@B?vbi)wC z%o%_0x!w=wZ#Z9`y7qq7+H2i=uXV4zBh*#j5feNk0002Q3h!k#0RRm2BL)B;7kxAS zTx$LA%~kWAG@yEvb`Jn}0Z@>AtL>S2wCs~and3968>1wVs>!;V?xL$mia$5Uxb zqMrJlc7tIg%R8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9y&c}mRS=W@7yz}Yut^`1e0+nQ$Y6-cK*JZTZ%ft=gBt90!LW0`xxq$PRZZxAxb)P~I%HAMf6u;ur*t|sYam8{*c5)dW*M!@=32ParP_tI~ z5`LA>>@5jy!rYwjXWv@`R4k4HF^{VFAA*9hM)x0-UtxbTx=M1e8roND6ge! zJp?9}JipIVKA>-3w>e(FqQ2^${uz%x2nrNK%RWwT)SeV*9c^&*A2f^ogS1oP2YL*o z-KFVE)*)V?eX~Pm?5tRF7D-q1<0(>b^7Z(v#9B;iDfNiCttSmT>!^E2E8U$2zeuF6 zRsHR<^h>}3@p>F^y^qC;GM>-G)NsiW3ShKKR%rthwl7E`8HoX9P-w}O6HrE{U?3D2 ztbxH9ZSoJ!du-MKMHC)_#>_4-bblIWh^~<*9MNP!-gGo0BDf}z`uc}7BID0@ST4^} z0AfmmT_mmU|M|STRFy>mh@%Ab1eoA|K@t)=^|$yR%L11;}X2^oX< zIy$_FLK|ygcoCD@e|rpH)?LeBC2M5-5_JR)I**~l73sz?sr5RHTlyAotfg%&+;ssF z&+}<)Zu%y>ID;Mh|K&e&uqY33|MwYsGJ)kgD`R%fIM%=<@juMa-F=+g9i0Op|IE@I znHY0;X2uza|M_GDL($(F|6Kp=oWy^M{pSGxU)%qzsSJPqALIQ0RP>)w{2xW5=l}1D Y{v#$c!=uOk2(dDL!;Gt-_@96O3(5?@YybcN diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f8a6872..ebe534c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,10 +33,11 @@ add_subdirectory(console) add_subdirectory(display) add_subdirectory(engine) add_subdirectory(error) +add_subdirectory(game) add_subdirectory(input) # add_subdirectory(locale) add_subdirectory(physics) -add_subdirectory(rpg) +# add_subdirectory(rpg) add_subdirectory(thread) add_subdirectory(time) add_subdirectory(util) \ No newline at end of file diff --git a/src/asset/asset.c b/src/asset/asset.c index 949f374..3e115cf 100644 --- a/src/asset/asset.c +++ b/src/asset/asset.c @@ -21,9 +21,6 @@ assetdef_t ASSET_DEFINITIONS[ASSET_TYPE_COUNT] = { [ASSET_TYPE_CONFIG] = { "DCF", assetConfigLoad, assetConfigDispose }, - [ASSET_TYPE_RPG_MAP] = { - "DRM", assetRPGMapLoad, assetRPGMapDispose - }, }; errorret_t assetInit(asset_t *asset, const char_t *filename) { diff --git a/src/asset/asset.h b/src/asset/asset.h index d652b5f..bd9ca32 100644 --- a/src/asset/asset.h +++ b/src/asset/asset.h @@ -13,7 +13,6 @@ #include "asset/type/assetpaletteimage.h" #include "asset/type/assetalphaimage.h" #include "asset/type/assetconfig.h" -#include "asset/type/assetrpgmap.h" #define ASSET_HEADER_SIZE 3 #define ASSET_REFERENCE_COUNT_MAX 8 @@ -34,7 +33,6 @@ typedef enum { ASSET_TYPE_PALETTE_IMAGE, ASSET_TYPE_ALPHA_IMAGE, ASSET_TYPE_CONFIG, - ASSET_TYPE_RPG_MAP, ASSET_TYPE_COUNT } assettype_t; @@ -51,7 +49,6 @@ typedef struct asset_s { assetpaletteimage_t paletteImage; assetalphaimage_t alphaImage; assetconfig_t config; - assetrpgmap_t rpgMap; }; } asset_t; diff --git a/src/asset/type/CMakeLists.txt b/src/asset/type/CMakeLists.txt index aef79ac..7c2e9ea 100644 --- a/src/asset/type/CMakeLists.txt +++ b/src/asset/type/CMakeLists.txt @@ -9,5 +9,4 @@ target_sources(${DUSK_TARGET_NAME} assetalphaimage.c assetconfig.c assetpaletteimage.c - assetrpgmap.c ) \ No newline at end of file diff --git a/src/asset/type/assetrpgmap.c b/src/asset/type/assetrpgmap.c deleted file mode 100644 index e39f0ab..0000000 --- a/src/asset/type/assetrpgmap.c +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "assetrpgmap.h" -#include "asset/asset.h" -#include "assert/assert.h" -#include "display/tileset/tilesetlist.h" - -errorret_t assetRPGMapLoad(asset_t *asset) { - assertNotNull(asset, "Asset cannot be NULL."); - assertTrue( - asset->type == ASSET_TYPE_RPG_MAP, - "Asset is not of type ASSET_TYPE_RPG_MAP." - ); - - assetrpgmapraw_t raw; - - // Read map header info - zip_int64_t bytesRead = zip_fread( - asset->file, &raw.header, sizeof(assetrpgmapheader_t) - ); - if(bytesRead != sizeof(raw.header)) { - errorThrow("Failed to read RPG map header."); - } - - if(raw.header.mapWidth == 0 || raw.header.mapWidth > MAP_WIDTH_MAX) { - errorThrow("Invalid RPG map width."); - } - - if(raw.header.mapHeight == 0 || raw.header.mapHeight > MAP_HEIGHT_MAX) { - errorThrow("Invalid RPG map height."); - } - - if(raw.header.tilesetCount == 0) { - errorThrow("Invalid RPG map tileset count."); - } - - if(raw.header.tilesetCount > ASSET_RPG_MAP_TILESET_COUNT_MAX) { - errorThrow("Invalid RPG map tileset count."); - } - - if(raw.header.tileLayerCount == 0) { - errorThrow("Invalid RPG map layer count."); - } - - if(raw.header.tileLayerCount > MAP_LAYER_COUNT_MAX) { - errorThrow("Invalid RPG map layer count."); - } - - // Read layers - for(uint32_t layer = 0; layer < raw.header.tileLayerCount; layer++) { - // Read width * height tiles - bytesRead = zip_fread( - asset->file, - &raw.layers[layer].tiles, - sizeof(assetrpgmaptile_t) * raw.header.mapWidth * raw.header.mapHeight - ); - if(bytesRead != ( - sizeof(assetrpgmaptile_t) * raw.header.mapWidth * raw.header.mapHeight - )) errorThrow("Failed to read RPG map layer %u.", layer); - } - - // For each tileset - for(uint32_t tileset = 0; tileset < raw.header.tilesetCount; tileset++) { - // Read tileset - bytesRead = zip_fread( - asset->file, - &raw.tilesets[tileset], - sizeof(assetrpgmaptileset_t) - ); - if(bytesRead != sizeof(assetrpgmaptileset_t)) { - errorThrow("Failed to read RPG map tileset %u.", tileset); - } - } - - // Map data is loaded, we can load it into the map structure. - mapInit(&asset->rpgMap.map); - - entity_t *ent; - ent = mapEntityAdd(&asset->rpgMap.map); - entityInit(ent, ENTITY_TYPE_PLAYER, &asset->rpgMap.map); - - errorOk(); -} - -errorret_t assetRPGMapDispose(asset_t *asset) { - assertNotNull(asset, "Asset cannot be NULL."); - assertTrue( - asset->type == ASSET_TYPE_RPG_MAP, - "Asset is not of type ASSET_TYPE_RPG_MAP." - ); - - errorOk(); -} \ No newline at end of file diff --git a/src/asset/type/assetrpgmap.h b/src/asset/type/assetrpgmap.h deleted file mode 100644 index 6b3da24..0000000 --- a/src/asset/type/assetrpgmap.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - - -#pragma once -#include "error/error.h" -#include "rpg/world/map.h" - -typedef struct asset_s asset_t; - -#define ASSET_RPG_MAP_TILESET_COUNT_MAX 16 - -#pragma pack(push, 1) -typedef struct { - uint32_t mapWidth; - uint32_t mapHeight; - uint32_t tilesetCount; - uint32_t tileLayerCount; -} assetrpgmapheader_t; - -typedef struct { - uint32_t firstGid; - uint32_t tilesetIndex; -} assetrpgmaptileset_t; - -typedef struct { - uint32_t tilesetIndex; -} assetrpgmaptile_t; - -typedef struct { - assetrpgmaptile_t tiles[MAP_TILE_COUNT_MAX]; -} assetrpgmaplayer_t; - -typedef struct { - assetrpgmapheader_t header; - assetrpgmaplayer_t layers[MAP_LAYER_COUNT_MAX]; - assetrpgmaptileset_t tilesets[ASSET_RPG_MAP_TILESET_COUNT_MAX]; -} assetrpgmapraw_t; -#pragma pack(pop) - -typedef struct { - map_t map; -} assetrpgmap_t; - -/** - * Loads an RPG map asset from the given asset structure. The asset must be of - * type ASSET_TYPE_RPG_MAP and must be loaded. - * - * @param asset The asset to load the RPG map from. - * @return An error code. - */ -errorret_t assetRPGMapLoad(asset_t *asset); - -/** - * Disposes of an RPG map asset, freeing any allocated resources. - * - * @param asset The asset to dispose of. - * @return An error code. - */ -errorret_t assetRPGMapDispose(asset_t *asset); \ No newline at end of file diff --git a/src/display/framebuffer/framebuffer.c b/src/display/framebuffer/framebuffer.c index c430e00..7b7e340 100644 --- a/src/display/framebuffer/framebuffer.c +++ b/src/display/framebuffer/framebuffer.c @@ -28,10 +28,10 @@ void frameBufferInitBackbuffer() { ) { #if DISPLAY_SDL2 == 1 assertNotNull(framebuffer, "Framebuffer cannot be NULL"); - assertTrue(width > 0 && height > 0, "Width & height must be greater than 0"); + assertTrue(width > 0 && height > 0, "W/H must be greater than 0"); memoryZero(framebuffer, sizeof(framebuffer_t)); - textureInit(&framebuffer->texture, width, height, GL_RGBA, (texturedata_t){ + textureInit(&framebuffer->texture, width, height, GL_RGBA,(texturedata_t){ .rgba = { .colors = NULL } }); diff --git a/src/display/scene/CMakeLists.txt b/src/display/scene/CMakeLists.txt index 5d2933c..42368a3 100644 --- a/src/display/scene/CMakeLists.txt +++ b/src/display/scene/CMakeLists.txt @@ -9,6 +9,4 @@ target_sources(${DUSK_TARGET_NAME} scenemanager.c ) -# Subdirs -add_subdirectory(overworld) -add_subdirectory(test) \ No newline at end of file +# Subdirs \ No newline at end of file diff --git a/src/display/scene/scene.h b/src/display/scene/scene.h index 7599611..8c221cc 100644 --- a/src/display/scene/scene.h +++ b/src/display/scene/scene.h @@ -21,14 +21,4 @@ typedef struct { void (*sleep)(void); uint8_t flags; -} scene_t; - -typedef enum { - SCENE_TYPE_LOGO, - SCENE_TYPE_TEST, - SCENE_TYPE_OVERWORLD, - - SCENE_TYPE_COUNT -} scenetype_t; - -#define SCENE_TYPE_INITIAL SCENE_TYPE_OVERWORLD \ No newline at end of file +} scene_t; \ No newline at end of file diff --git a/src/display/scene/scenemanager.c b/src/display/scene/scenemanager.c index 7bf94c2..146c63e 100644 --- a/src/display/scene/scenemanager.c +++ b/src/display/scene/scenemanager.c @@ -7,55 +7,52 @@ #include "scenemanager.h" -#include "display/scene/overworld/sceneoverworld.h" -#include "display/scene/test/scenetest.h" - scenemanager_t SCENE_MANAGER; -scene_t SCENE_MANAGER_SCENES[SCENE_TYPE_COUNT] = { - [SCENE_TYPE_LOGO] = { 0 }, +// scene_t SCENE_MANAGER_SCENES[SCENE_TYPE_COUNT] = { +// [SCENE_TYPE_LOGO] = { 0 }, - [SCENE_TYPE_TEST] = { - .init = sceneTestInit, - .update = sceneTestUpdate, - .render = sceneTestRender, - .dispose = sceneTestDispose - }, +// [SCENE_TYPE_TEST] = { +// .init = sceneTestInit, +// .update = sceneTestUpdate, +// .render = sceneTestRender, +// .dispose = sceneTestDispose +// }, - [SCENE_TYPE_OVERWORLD] = { - .init = sceneOverworldInit, - .update = sceneOverworldUpdate, - .render = sceneOverworldRender, - .dispose = sceneOverworldDispose - } -}; +// [SCENE_TYPE_OVERWORLD] = { +// .init = sceneOverworldInit, +// .update = sceneOverworldUpdate, +// .render = sceneOverworldRender, +// .dispose = sceneOverworldDispose +// } +// }; errorret_t sceneManagerInit(void) { - scene_t *initial = &SCENE_MANAGER_SCENES[SCENE_TYPE_INITIAL]; - if(initial->init != NULL) errorChain(initial->init()); + // scene_t *initial = &SCENE_MANAGER_SCENES[SCENE_TYPE_INITIAL]; + // if(initial->init != NULL) errorChain(initial->init()); errorOk(); } void sceneManagerUpdate(void) { // For each scene. - for(uint8_t i = 0; i < SCENE_TYPE_COUNT; i++) { - scene_t *scene = &SCENE_MANAGER_SCENES[i]; - if((scene->flags & SCENE_FLAG_ACTIVE) == 0) continue; - if(scene->update != NULL) scene->update(); - } + // for(uint8_t i = 0; i < SCENE_TYPE_COUNT; i++) { + // scene_t *scene = &SCENE_MANAGER_SCENES[i]; + // if((scene->flags & SCENE_FLAG_ACTIVE) == 0) continue; + // if(scene->update != NULL) scene->update(); + // } } void sceneManagerRender(void) { - for(uint8_t i = 0; i < SCENE_TYPE_COUNT; i++) { - scene_t *scene = &SCENE_MANAGER_SCENES[i]; - if((scene->flags & SCENE_FLAG_VISIBLE) == 0) continue; - if(scene->render != NULL) scene->render(); - } + // for(uint8_t i = 0; i < SCENE_TYPE_COUNT; i++) { + // scene_t *scene = &SCENE_MANAGER_SCENES[i]; + // if((scene->flags & SCENE_FLAG_VISIBLE) == 0) continue; + // if(scene->render != NULL) scene->render(); + // } } void sceneManagerDispose(void) { - for(uint8_t i = 0; i < SCENE_TYPE_COUNT; i++) { - scene_t *scene = &SCENE_MANAGER_SCENES[i]; - if(scene->dispose != NULL) scene->dispose(); - } + // for(uint8_t i = 0; i < SCENE_TYPE_COUNT; i++) { + // scene_t *scene = &SCENE_MANAGER_SCENES[i]; + // if(scene->dispose != NULL) scene->dispose(); + // } } diff --git a/src/display/scene/scenemanager.h b/src/display/scene/scenemanager.h index 8e4c172..c819861 100644 --- a/src/display/scene/scenemanager.h +++ b/src/display/scene/scenemanager.h @@ -13,7 +13,7 @@ typedef struct { } scenemanager_t; extern scenemanager_t SCENE_MANAGER; -extern scene_t SCENE_MANAGER_SCENES[SCENE_TYPE_COUNT]; +// extern scene_t SCENE_MANAGER_SCENES[SCENE_TYPE_COUNT]; /** * Initializes the scene manager and the initial scene. diff --git a/src/display/ui/ui.c b/src/display/ui/ui.c index bc5fa44..e9768ec 100644 --- a/src/display/ui/ui.c +++ b/src/display/ui/ui.c @@ -13,12 +13,22 @@ #include "uifps.h" #include "util/memory.h" +#include "display/tileset/tileset_minogram.h" + ui_t UI; errorret_t uiInit(void) { memoryZero(&UI, sizeof(ui_t)); - errorChain(uiTextInit()); + // Load debug font. + UI.debugFontTileset = &TILESET_MINOGRAM; + errorChain(assetManagerLoadAsset( + UI.debugFontTileset->image, + &UI.debugFontAsset, + &UI.debugFontRef + )); + + // Setup UI Camera. cameraInit(&UI.camera); UI.camera.projType = CAMERA_PROJECTION_TYPE_ORTHOGRAPHIC; @@ -28,12 +38,12 @@ errorret_t uiInit(void) { UI.camera.orthographic.bottom = frameBufferGetHeight(&FRAMEBUFFER_BACKBUFFER); UI.camera.nearClip = -1.0f; UI.camera.farClip = 1.0f; - UI.camera.viewType = CAMERA_VIEW_TYPE_MATRIX; glm_mat4_identity(UI.camera.view); UI.scale = 1.0f; + // Setup FPS element. uiFPSInit(); errorOk(); @@ -61,5 +71,5 @@ void uiRender(void) { } void uiDispose(void) { - uiTextDispose(); + } \ No newline at end of file diff --git a/src/display/ui/ui.h b/src/display/ui/ui.h index 5a9f081..d2f93e7 100644 --- a/src/display/ui/ui.h +++ b/src/display/ui/ui.h @@ -8,10 +8,17 @@ #pragma once #include "error/error.h" #include "display/camera.h" +#include "display/texture/texture.h" +#include "display/tileset.h" +#include "asset/asset.h" typedef struct { camera_t camera; float_t scale; + + const tileset_t *debugFontTileset; + asset_t *debugFontAsset; + ref_t debugFontRef; } ui_t; extern ui_t UI; diff --git a/src/display/ui/uiconsole.c b/src/display/ui/uiconsole.c index f3a3d9e..023d778 100644 --- a/src/display/ui/uiconsole.c +++ b/src/display/ui/uiconsole.c @@ -8,6 +8,7 @@ #include "uiconsole.h" #include "uitext.h" #include "console/console.h" +#include "ui.h" void uiConsoleRender(void) { if(!CONSOLE.visible) return; @@ -21,7 +22,11 @@ void uiConsoleRender(void) { i--; continue; } - uiTextDraw(0, i * TILESET_MINOGRAM.tileHeight, line, COLOR_WHITE); + uiTextDraw( + 0, i * TILESET_MINOGRAM.tileHeight, + line, COLOR_WHITE, + UI.debugFontTileset, &UI.debugFontAsset->alphaImage.texture + ); i--; } while(i > 0); } \ No newline at end of file diff --git a/src/display/ui/uifps.c b/src/display/ui/uifps.c index 6115b04..c41cb1d 100644 --- a/src/display/ui/uifps.c +++ b/src/display/ui/uifps.c @@ -10,6 +10,7 @@ #include "time/time.h" #include "console/console.h" #include "util/string.h" +#include "ui.h" void uiFPSInit(void) { consoleRegVar("fps", "0", NULL); @@ -36,5 +37,9 @@ void uiFPSRender(void) { COLOR_RED ); - uiTextDraw(0, 0, buffer, color); + uiTextDraw( + 0, 0, + buffer, color, + UI.debugFontTileset, &UI.debugFontAsset->alphaImage.texture + ); } \ No newline at end of file diff --git a/src/display/ui/uitext.c b/src/display/ui/uitext.c index 197a705..3e41067 100644 --- a/src/display/ui/uitext.c +++ b/src/display/ui/uitext.c @@ -11,47 +11,32 @@ #include "util/memory.h" #include "display/spritebatch/spritebatch.h" -uitext_t UI_TEXT; - -errorret_t uiTextInit(void) { - memoryZero(&UI_TEXT, sizeof(uitext_t)); - - errorChain(assetManagerLoadAsset( - TILESET_MINOGRAM.image, &UI_TEXT.asset, &UI_TEXT.assetRef - )); - errorOk(); -} - -void uiTextDispose(void) { - if(UI_TEXT.asset) { - assetUnlock(UI_TEXT.asset, UI_TEXT.assetRef); - } -} - void uiTextDrawChar( const float_t x, const float_t y, const char_t c, - const color_t color + const color_t color, + const tileset_t *tileset, + texture_t *texture ) { int32_t tileIndex = (int32_t)(c) - UI_TEXT_CHAR_START; - if(tileIndex < 0 || tileIndex >= TILESET_MINOGRAM.tileCount) { + if(tileIndex < 0 || tileIndex >= tileset->tileCount) { tileIndex = ((int32_t)'@') - UI_TEXT_CHAR_START; } assertTrue( - tileIndex >= 0 && tileIndex <= TILESET_MINOGRAM.tileCount, + tileIndex >= 0 && tileIndex <= tileset->tileCount, "Character is out of bounds for font tiles" ); vec4 uv; - tilesetTileGetUV(&TILESET_MINOGRAM, tileIndex, uv); + tilesetTileGetUV(tileset, tileIndex, uv); spriteBatchPush( - &UI_TEXT.asset->alphaImage.texture, + texture, x, y, - x + TILESET_MINOGRAM.tileWidth, - y + TILESET_MINOGRAM.tileHeight, + x + tileset->tileWidth, + y + tileset->tileHeight, color, uv[0], uv[1], uv[2], uv[3] ); @@ -61,7 +46,9 @@ void uiTextDraw( const float_t x, const float_t y, const char_t *text, - const color_t color + const color_t color, + const tileset_t *tileset, + texture_t *texture ) { assertNotNull(text, "Text cannot be NULL"); @@ -73,22 +60,23 @@ void uiTextDraw( while((c = text[i++]) != '\0') { if(c == '\n') { posX = x; - posY += TILESET_MINOGRAM.tileHeight; + posY += tileset->tileHeight; continue; } if(c == ' ') { - posX += TILESET_MINOGRAM.tileWidth; + posX += tileset->tileWidth; continue; } - uiTextDrawChar(posX, posY, c, color); - posX += TILESET_MINOGRAM.tileWidth; + uiTextDrawChar(posX, posY, c, color, tileset, texture); + posX += tileset->tileWidth; } } void uiTextMeasure( const char_t *text, + const tileset_t *tileset, int32_t *outWidth, int32_t *outHeight ) { @@ -97,7 +85,7 @@ void uiTextMeasure( assertNotNull(outHeight, "Output height pointer cannot be NULL"); int32_t width = 0; - int32_t height = TILESET_MINOGRAM.tileHeight; + int32_t height = tileset->tileHeight; int32_t lineWidth = 0; char_t c; @@ -108,11 +96,11 @@ void uiTextMeasure( width = lineWidth; } lineWidth = 0; - height += TILESET_MINOGRAM.tileHeight; + height += tileset->tileHeight; continue; } - lineWidth += TILESET_MINOGRAM.tileWidth; + lineWidth += tileset->tileWidth; } if(lineWidth > width) { diff --git a/src/display/ui/uitext.h b/src/display/ui/uitext.h index c6581f8..8fa63d3 100644 --- a/src/display/ui/uitext.h +++ b/src/display/ui/uitext.h @@ -11,18 +11,6 @@ #define UI_TEXT_CHAR_START '!' -typedef struct { - ref_t assetRef; - asset_t *asset; -} uitext_t; - -extern uitext_t UI_TEXT; - -/** - * Initializes the text rendering system. - */ -errorret_t uiTextInit(void); - /** * Draws a single character at the specified position. * @@ -30,12 +18,16 @@ errorret_t uiTextInit(void); * @param y The y-coordinate to draw the character at. * @param c The character to draw. * @param color The color to draw the character in. + * @param tileset Font tileset to use for rendering. + * @param texture Texture containing the font tileset image. */ void uiTextDrawChar( const float_t x, const float_t y, const char_t c, - const color_t color + const color_t color, + const tileset_t *tileset, + texture_t *texture ); /** @@ -45,28 +37,29 @@ void uiTextDrawChar( * @param y The y-coordinate to draw the text at. * @param text The null-terminated string of text to draw. * @param color The color to draw the text in. + * @param tileset Font tileset to use for rendering. + * @param texture Texture containing the font tileset image. */ void uiTextDraw( const float_t x, const float_t y, const char_t *text, - const color_t color + const color_t color, + const tileset_t *tileset, + texture_t *texture ); /** * Measures the width and height of the given text string when rendered. * * @param text The null-terminated string of text to measure. + * @param tileset Font tileset to use for measurement. * @param outWidth Pointer to store the measured width in pixels. * @param outHeight Pointer to store the measured height in pixels. */ void uiTextMeasure( const char_t *text, + const tileset_t *tileset, int32_t *outWidth, int32_t *outHeight -); - -/** - * Disposes of the text rendering system, freeing any allocated resources. - */ -void uiTextDispose(void); \ No newline at end of file +); \ No newline at end of file diff --git a/src/engine/engine.c b/src/engine/engine.c index 0f569e7..21c3c34 100644 --- a/src/engine/engine.c +++ b/src/engine/engine.c @@ -12,7 +12,7 @@ #include "console/console.h" #include "display/display.h" #include "asset/assetmanager.h" -#include "rpg/rpg.h" +#include "game/game.h" engine_t ENGINE; @@ -29,7 +29,7 @@ errorret_t engineInit(void) { inputInit(); errorChain(assetManagerInit()); errorChain(displayInit()); - rpgInit(); + errorChain(gameInit()); // Init scripts #if PSP @@ -46,14 +46,15 @@ errorret_t engineUpdate(void) { inputUpdate(); consoleUpdate(); assetManagerUpdate(); - - rpgUpdate(); + + gameUpdate(); errorChain(displayUpdate()); errorOk(); } errorret_t engineDispose(void) { + gameDispose(); errorChain(displayDispose()); assetManagerDispose(); consoleDispose(); diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt new file mode 100644 index 0000000..7dcf24b --- /dev/null +++ b/src/game/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (c) 2025 Dominic Masters +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +if(NOT DEFINED DUSK_TARGET_GAME) + message(FATAL_ERROR "DUSK_TARGET_GAME is not defined.") +endif() + +string(TOUPPER "${DUSK_TARGET_GAME}" DUSK_TARGET_GAME_UPPER) + +target_compile_definitions(${DUSK_TARGET_NAME} + PRIVATE + DUSK_TARGET_GAME=${DUSK_TARGET_GAME} + DUSK_GAME_${DUSK_TARGET_GAME_UPPER}=1 +) + +add_subdirectory(${DUSK_TARGET_GAME}) \ No newline at end of file diff --git a/src/game/game.h b/src/game/game.h new file mode 100644 index 0000000..6ccd3e5 --- /dev/null +++ b/src/game/game.h @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2025 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once + +#if DUSK_GAME_RPG == 1 + #include "rpg/game.h" +#elif DUSK_GAME_MINESWEEPER == 1 + #include "minesweeper/game.h" +#else + #error "Unknown game specified" +#endif \ No newline at end of file diff --git a/src/game/gamescene.h b/src/game/gamescene.h new file mode 100644 index 0000000..9d93a5d --- /dev/null +++ b/src/game/gamescene.h @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2025 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once + +#if DUSK_GAME_RPG == 1 + #include "rpg/scene.h" +#elif DUSK_GAME_MINESWEEPER == 1 + #include "minesweeper/scene.h" +#else + #error "Unknown game specified" +#endif \ No newline at end of file diff --git a/archive/dusk/assert/CMakeLists.txt b/src/game/minesweeper/CMakeLists.txt similarity index 88% rename from archive/dusk/assert/CMakeLists.txt rename to src/game/minesweeper/CMakeLists.txt index ca33cd5..7868b61 100644 --- a/archive/dusk/assert/CMakeLists.txt +++ b/src/game/minesweeper/CMakeLists.txt @@ -6,5 +6,7 @@ # Sources target_sources(${DUSK_TARGET_NAME} PRIVATE - assert.c -) \ No newline at end of file + game.c +) + +# Subdirs \ No newline at end of file diff --git a/archive/asset/assettileset.c b/src/game/minesweeper/game.c similarity index 54% rename from archive/asset/assettileset.c rename to src/game/minesweeper/game.c index 4955d25..25b4377 100644 --- a/archive/asset/assettileset.c +++ b/src/game/minesweeper/game.c @@ -5,8 +5,16 @@ * https://opensource.org/licenses/MIT */ -#include "asset.h" +#include "game.h" -void assetParseTileset() { - ASSET.loaded.tileset = &ASSET.data.tileset; +errorret_t gameInit(void) { + errorOk(); +} + +void gameUpdate(void) { + +} + +void gameDispose(void) { + } \ No newline at end of file diff --git a/src/game/minesweeper/game.h b/src/game/minesweeper/game.h new file mode 100644 index 0000000..7312291 --- /dev/null +++ b/src/game/minesweeper/game.h @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2025 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "error/error.h" + +/** + * Initializes the game. + */ +errorret_t gameInit(void); + +/** + * Updates the game. + */ +void gameUpdate(void); + +/** + * Disposes of the game. + */ +void gameDispose(void); \ No newline at end of file diff --git a/archive/dusk/ecs/ecs.h b/src/game/minesweeper/scene.h similarity index 85% rename from archive/dusk/ecs/ecs.h rename to src/game/minesweeper/scene.h index 9783ab3..15ebdb9 100644 --- a/archive/dusk/ecs/ecs.h +++ b/src/game/minesweeper/scene.h @@ -8,4 +8,4 @@ #pragma once #include "dusk.h" -typedef int_fast16_t ecsid_t; \ No newline at end of file +#error TEST \ No newline at end of file diff --git a/src/rpg/CMakeLists.txt b/src/game/rpg/CMakeLists.txt similarity index 100% rename from src/rpg/CMakeLists.txt rename to src/game/rpg/CMakeLists.txt diff --git a/src/rpg/entity/CMakeLists.txt b/src/game/rpg/entity/CMakeLists.txt similarity index 100% rename from src/rpg/entity/CMakeLists.txt rename to src/game/rpg/entity/CMakeLists.txt diff --git a/src/rpg/entity/direction.c b/src/game/rpg/entity/direction.c similarity index 100% rename from src/rpg/entity/direction.c rename to src/game/rpg/entity/direction.c diff --git a/src/rpg/entity/direction.h b/src/game/rpg/entity/direction.h similarity index 100% rename from src/rpg/entity/direction.h rename to src/game/rpg/entity/direction.h diff --git a/src/rpg/entity/entity.c b/src/game/rpg/entity/entity.c similarity index 100% rename from src/rpg/entity/entity.c rename to src/game/rpg/entity/entity.c diff --git a/src/rpg/entity/entity.h b/src/game/rpg/entity/entity.h similarity index 100% rename from src/rpg/entity/entity.h rename to src/game/rpg/entity/entity.h diff --git a/src/rpg/entity/npc.c b/src/game/rpg/entity/npc.c similarity index 100% rename from src/rpg/entity/npc.c rename to src/game/rpg/entity/npc.c diff --git a/src/rpg/entity/npc.h b/src/game/rpg/entity/npc.h similarity index 100% rename from src/rpg/entity/npc.h rename to src/game/rpg/entity/npc.h diff --git a/src/rpg/entity/player.c b/src/game/rpg/entity/player.c similarity index 100% rename from src/rpg/entity/player.c rename to src/game/rpg/entity/player.c diff --git a/src/rpg/entity/player.h b/src/game/rpg/entity/player.h similarity index 100% rename from src/rpg/entity/player.h rename to src/game/rpg/entity/player.h diff --git a/src/display/scene/overworld/CMakeLists.txt b/src/game/rpg/overworld/CMakeLists.txt similarity index 100% rename from src/display/scene/overworld/CMakeLists.txt rename to src/game/rpg/overworld/CMakeLists.txt diff --git a/src/display/scene/overworld/sceneoverworld.c b/src/game/rpg/overworld/sceneoverworld.c similarity index 100% rename from src/display/scene/overworld/sceneoverworld.c rename to src/game/rpg/overworld/sceneoverworld.c diff --git a/src/display/scene/overworld/sceneoverworld.h b/src/game/rpg/overworld/sceneoverworld.h similarity index 100% rename from src/display/scene/overworld/sceneoverworld.h rename to src/game/rpg/overworld/sceneoverworld.h diff --git a/src/rpg/rpg.c b/src/game/rpg/rpg.c similarity index 100% rename from src/rpg/rpg.c rename to src/game/rpg/rpg.c diff --git a/src/rpg/rpg.h b/src/game/rpg/rpg.h similarity index 100% rename from src/rpg/rpg.h rename to src/game/rpg/rpg.h diff --git a/src/display/scene/test/CMakeLists.txt b/src/game/rpg/test/CMakeLists.txt similarity index 100% rename from src/display/scene/test/CMakeLists.txt rename to src/game/rpg/test/CMakeLists.txt diff --git a/src/display/scene/test/scenetest.c b/src/game/rpg/test/scenetest.c similarity index 100% rename from src/display/scene/test/scenetest.c rename to src/game/rpg/test/scenetest.c diff --git a/src/display/scene/test/scenetest.h b/src/game/rpg/test/scenetest.h similarity index 100% rename from src/display/scene/test/scenetest.h rename to src/game/rpg/test/scenetest.h diff --git a/src/rpg/world/CMakeLists.txt b/src/game/rpg/world/CMakeLists.txt similarity index 100% rename from src/rpg/world/CMakeLists.txt rename to src/game/rpg/world/CMakeLists.txt diff --git a/src/rpg/world/map.c b/src/game/rpg/world/map.c similarity index 100% rename from src/rpg/world/map.c rename to src/game/rpg/world/map.c diff --git a/src/rpg/world/map.h b/src/game/rpg/world/map.h similarity index 100% rename from src/rpg/world/map.h rename to src/game/rpg/world/map.h diff --git a/src/rpg/world/tile.h b/src/game/rpg/world/tile.h similarity index 100% rename from src/rpg/world/tile.h rename to src/game/rpg/world/tile.h