diff --git a/CMakeLists.txt b/CMakeLists.txt
index caea886..d123bd9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -82,7 +82,7 @@ endif()
add_subdirectory(tools)
# Assets
-add_subdirectory(assets)
+# add_subdirectory(assets)
# Add libraries
if(DUSK_TARGET_SYSTEM STREQUAL "linux")
@@ -176,16 +176,16 @@ if(ENABLE_TESTS)
endif()
# Build assets
-dusk_run_python(
- DUSK_ASSETS_BUILT
- tools.asset.bundle
- --assets ${DUSK_ASSETS_DIR}
- --output-assets ${DUSK_BUILT_ASSETS_DIR}
- --output-file ${DUSK_BUILD_DIR}/dusk.dsk
- --headers-dir ${DUSK_GENERATED_HEADERS_DIR}
- --input ${DUSK_ASSETS}
-)
-add_dependencies(${DUSK_LIBRARY_TARGET_NAME} DUSK_ASSETS_BUILT)
+# dusk_run_python(
+# DUSK_ASSETS_BUILT
+# tools.asset.bundle
+# --assets ${DUSK_ASSETS_DIR}
+# --output-assets ${DUSK_BUILT_ASSETS_DIR}
+# --output-file ${DUSK_BUILD_DIR}/dusk.dsk
+# --headers-dir ${DUSK_GENERATED_HEADERS_DIR}
+# --input ${DUSK_ASSETS}
+# )
+# add_dependencies(${DUSK_LIBRARY_TARGET_NAME} DUSK_ASSETS_BUILT)
# Include generated headers
target_include_directories(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
diff --git a/tools/asset/args.py b/archive/asset/args.py
similarity index 100%
rename from tools/asset/args.py
rename to archive/asset/args.py
diff --git a/tools/asset/bundle/__main__.py b/archive/asset/bundle/__main__.py
similarity index 100%
rename from tools/asset/bundle/__main__.py
rename to archive/asset/bundle/__main__.py
diff --git a/tools/asset/cache.py b/archive/asset/cache.py
similarity index 100%
rename from tools/asset/cache.py
rename to archive/asset/cache.py
diff --git a/tools/asset/path.py b/archive/asset/path.py
similarity index 100%
rename from tools/asset/path.py
rename to archive/asset/path.py
diff --git a/tools/asset/process/asset.py b/archive/asset/process/asset.py
similarity index 100%
rename from tools/asset/process/asset.py
rename to archive/asset/process/asset.py
diff --git a/tools/asset/process/image.py b/archive/asset/process/image.py
similarity index 100%
rename from tools/asset/process/image.py
rename to archive/asset/process/image.py
diff --git a/tools/asset/process/language.py b/archive/asset/process/language.py
similarity index 100%
rename from tools/asset/process/language.py
rename to archive/asset/process/language.py
diff --git a/tools/asset/process/map.py b/archive/asset/process/map.py
similarity index 100%
rename from tools/asset/process/map.py
rename to archive/asset/process/map.py
diff --git a/tools/asset/process/palette.py b/archive/asset/process/palette.py
similarity index 100%
rename from tools/asset/process/palette.py
rename to archive/asset/process/palette.py
diff --git a/tools/asset/process/script.py b/archive/asset/process/script.py
similarity index 100%
rename from tools/asset/process/script.py
rename to archive/asset/process/script.py
diff --git a/tools/asset/process/tileset.py b/archive/asset/process/tileset.py
similarity index 100%
rename from tools/asset/process/tileset.py
rename to archive/asset/process/tileset.py
diff --git a/tools/dusk/chunk.py b/archive/dusk/chunk.py
similarity index 100%
rename from tools/dusk/chunk.py
rename to archive/dusk/chunk.py
diff --git a/tools/dusk/defs.py b/archive/dusk/defs.py
similarity index 100%
rename from tools/dusk/defs.py
rename to archive/dusk/defs.py
diff --git a/tools/dusk/entity.py b/archive/dusk/entity.py
similarity index 100%
rename from tools/dusk/entity.py
rename to archive/dusk/entity.py
diff --git a/tools/dusk/event.py b/archive/dusk/event.py
similarity index 100%
rename from tools/dusk/event.py
rename to archive/dusk/event.py
diff --git a/tools/dusk/map.py b/archive/dusk/map.py
similarity index 100%
rename from tools/dusk/map.py
rename to archive/dusk/map.py
diff --git a/tools/dusk/region.py b/archive/dusk/region.py
similarity index 100%
rename from tools/dusk/region.py
rename to archive/dusk/region.py
diff --git a/tools/dusk/tile.py b/archive/dusk/tile.py
similarity index 100%
rename from tools/dusk/tile.py
rename to archive/dusk/tile.py
diff --git a/tools/editor/__main__.py b/archive/editor/__main__.py
similarity index 100%
rename from tools/editor/__main__.py
rename to archive/editor/__main__.py
diff --git a/tools/editor/cutscene/cutsceneitemeditor.py b/archive/editor/cutscene/cutsceneitemeditor.py
similarity index 100%
rename from tools/editor/cutscene/cutsceneitemeditor.py
rename to archive/editor/cutscene/cutsceneitemeditor.py
diff --git a/tools/editor/cutscene/cutscenemenubar.py b/archive/editor/cutscene/cutscenemenubar.py
similarity index 100%
rename from tools/editor/cutscene/cutscenemenubar.py
rename to archive/editor/cutscene/cutscenemenubar.py
diff --git a/tools/editor/cutscene/cutscenetext.py b/archive/editor/cutscene/cutscenetext.py
similarity index 100%
rename from tools/editor/cutscene/cutscenetext.py
rename to archive/editor/cutscene/cutscenetext.py
diff --git a/tools/editor/cutscene/cutscenewait.py b/archive/editor/cutscene/cutscenewait.py
similarity index 100%
rename from tools/editor/cutscene/cutscenewait.py
rename to archive/editor/cutscene/cutscenewait.py
diff --git a/tools/editor/cutscenetool.py b/archive/editor/cutscenetool.py
similarity index 100%
rename from tools/editor/cutscenetool.py
rename to archive/editor/cutscenetool.py
diff --git a/tools/editor/langtool.py b/archive/editor/langtool.py
similarity index 100%
rename from tools/editor/langtool.py
rename to archive/editor/langtool.py
diff --git a/tools/editor/map/camera.py b/archive/editor/map/camera.py
similarity index 100%
rename from tools/editor/map/camera.py
rename to archive/editor/map/camera.py
diff --git a/tools/editor/map/chunkpanel.py b/archive/editor/map/chunkpanel.py
similarity index 100%
rename from tools/editor/map/chunkpanel.py
rename to archive/editor/map/chunkpanel.py
diff --git a/tools/editor/map/entitypanel.py b/archive/editor/map/entitypanel.py
similarity index 100%
rename from tools/editor/map/entitypanel.py
rename to archive/editor/map/entitypanel.py
diff --git a/tools/editor/map/glwidget.py b/archive/editor/map/glwidget.py
similarity index 100%
rename from tools/editor/map/glwidget.py
rename to archive/editor/map/glwidget.py
diff --git a/tools/editor/map/grid.py b/archive/editor/map/grid.py
similarity index 100%
rename from tools/editor/map/grid.py
rename to archive/editor/map/grid.py
diff --git a/tools/editor/map/mapinfopanel.py b/archive/editor/map/mapinfopanel.py
similarity index 100%
rename from tools/editor/map/mapinfopanel.py
rename to archive/editor/map/mapinfopanel.py
diff --git a/tools/editor/map/mapleftpanel.py b/archive/editor/map/mapleftpanel.py
similarity index 100%
rename from tools/editor/map/mapleftpanel.py
rename to archive/editor/map/mapleftpanel.py
diff --git a/tools/editor/map/menubar.py b/archive/editor/map/menubar.py
similarity index 100%
rename from tools/editor/map/menubar.py
rename to archive/editor/map/menubar.py
diff --git a/tools/editor/map/regionpanel.py b/archive/editor/map/regionpanel.py
similarity index 100%
rename from tools/editor/map/regionpanel.py
rename to archive/editor/map/regionpanel.py
diff --git a/tools/editor/map/selectbox.py b/archive/editor/map/selectbox.py
similarity index 100%
rename from tools/editor/map/selectbox.py
rename to archive/editor/map/selectbox.py
diff --git a/tools/editor/map/statusbar.py b/archive/editor/map/statusbar.py
similarity index 100%
rename from tools/editor/map/statusbar.py
rename to archive/editor/map/statusbar.py
diff --git a/tools/editor/map/vertexbuffer.py b/archive/editor/map/vertexbuffer.py
similarity index 100%
rename from tools/editor/map/vertexbuffer.py
rename to archive/editor/map/vertexbuffer.py
diff --git a/tools/editor/maptool.py b/archive/editor/maptool.py
similarity index 100%
rename from tools/editor/maptool.py
rename to archive/editor/maptool.py
diff --git a/assets/map/CMakeLists.txt b/archive/map/CMakeLists.txt
similarity index 100%
rename from assets/map/CMakeLists.txt
rename to archive/map/CMakeLists.txt
diff --git a/assets/map/testmap/CMakeLists.txt b/archive/map/testmap/CMakeLists.txt
similarity index 100%
rename from assets/map/testmap/CMakeLists.txt
rename to archive/map/testmap/CMakeLists.txt
diff --git a/assets/map/testmap/chunks/-1_-1_0.json b/archive/map/testmap/chunks/-1_-1_0.json
similarity index 100%
rename from assets/map/testmap/chunks/-1_-1_0.json
rename to archive/map/testmap/chunks/-1_-1_0.json
diff --git a/assets/map/testmap/chunks/-1_-1_1.json b/archive/map/testmap/chunks/-1_-1_1.json
similarity index 100%
rename from assets/map/testmap/chunks/-1_-1_1.json
rename to archive/map/testmap/chunks/-1_-1_1.json
diff --git a/assets/map/testmap/chunks/-1_0_0.json b/archive/map/testmap/chunks/-1_0_0.json
similarity index 100%
rename from assets/map/testmap/chunks/-1_0_0.json
rename to archive/map/testmap/chunks/-1_0_0.json
diff --git a/assets/map/testmap/chunks/-2_1_0.json b/archive/map/testmap/chunks/-2_1_0.json
similarity index 100%
rename from assets/map/testmap/chunks/-2_1_0.json
rename to archive/map/testmap/chunks/-2_1_0.json
diff --git a/assets/map/testmap/chunks/0_-1_0.json b/archive/map/testmap/chunks/0_-1_0.json
similarity index 100%
rename from assets/map/testmap/chunks/0_-1_0.json
rename to archive/map/testmap/chunks/0_-1_0.json
diff --git a/assets/map/testmap/chunks/0_-1_1.json b/archive/map/testmap/chunks/0_-1_1.json
similarity index 100%
rename from assets/map/testmap/chunks/0_-1_1.json
rename to archive/map/testmap/chunks/0_-1_1.json
diff --git a/assets/map/testmap/chunks/0_0_0.json b/archive/map/testmap/chunks/0_0_0.json
similarity index 100%
rename from assets/map/testmap/chunks/0_0_0.json
rename to archive/map/testmap/chunks/0_0_0.json
diff --git a/assets/map/testmap/chunks/1_0_0.json b/archive/map/testmap/chunks/1_0_0.json
similarity index 100%
rename from assets/map/testmap/chunks/1_0_0.json
rename to archive/map/testmap/chunks/1_0_0.json
diff --git a/assets/map/testmap/chunks/2_0_0.json b/archive/map/testmap/chunks/2_0_0.json
similarity index 100%
rename from assets/map/testmap/chunks/2_0_0.json
rename to archive/map/testmap/chunks/2_0_0.json
diff --git a/assets/map/testmap/chunks/3_0_0.json b/archive/map/testmap/chunks/3_0_0.json
similarity index 100%
rename from assets/map/testmap/chunks/3_0_0.json
rename to archive/map/testmap/chunks/3_0_0.json
diff --git a/assets/map/testmap/chunks/4_0_0.json b/archive/map/testmap/chunks/4_0_0.json
similarity index 100%
rename from assets/map/testmap/chunks/4_0_0.json
rename to archive/map/testmap/chunks/4_0_0.json
diff --git a/assets/map/testmap/chunks/5_0_0.json b/archive/map/testmap/chunks/5_0_0.json
similarity index 100%
rename from assets/map/testmap/chunks/5_0_0.json
rename to archive/map/testmap/chunks/5_0_0.json
diff --git a/assets/map/testmap/testmap.json b/archive/map/testmap/testmap.json
similarity index 100%
rename from assets/map/testmap/testmap.json
rename to archive/map/testmap/testmap.json
diff --git a/assets/CMakeLists.txt b/assets/CMakeLists.txt
deleted file mode 100644
index b4d88af..0000000
--- a/assets/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-# 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 "Game assets directory")
-
-# Palette asset needs to be added before any images.
-add_subdirectory(palette)
-
-# Languages need to be added before anything that uses text.
-add_subdirectory(locale)
-
-# Rest, order doesn't matter
-add_asset(SCRIPT init.lua)
-
-# Subdirs
-# add_subdirectory(entity)
-# add_subdirectory(map)
-add_subdirectory(ui)
-add_subdirectory(minesweeper)
-add_subdirectory(scene)
diff --git a/assets/entity/CMakeLists.txt b/assets/entity/CMakeLists.txt
deleted file mode 100644
index 6cee926..0000000
--- a/assets/entity/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright (c) 2025 Dominic Masters
-#
-# This software is released under the MIT License.
-# https://opensource.org/licenses/MIT
-
-add_asset(TILESET entities.tsx)
\ No newline at end of file
diff --git a/assets/entity/entities.png b/assets/entity/entities.png
deleted file mode 100644
index fc417a8..0000000
Binary files a/assets/entity/entities.png and /dev/null differ
diff --git a/assets/entity/entities.tsx b/assets/entity/entities.tsx
deleted file mode 100644
index c7d7ecf..0000000
--- a/assets/entity/entities.tsx
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/assets/locale/CMakeLists.txt b/assets/locale/CMakeLists.txt
deleted file mode 100644
index 49e7742..0000000
--- a/assets/locale/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright (c) 2025 Dominic Masters
-#
-# This software is released under the MIT License.
-# https://opensource.org/licenses/MIT
-
-add_asset(LANGUAGE en_US.po)
\ No newline at end of file
diff --git a/assets/locale/en_US.po b/assets/locale/en_US.po
index 41e2025..2b86067 100644
--- a/assets/locale/en_US.po
+++ b/assets/locale/en_US.po
@@ -7,9 +7,3 @@ msgstr ""
msgid "ui.test"
msgstr "Hello this is a test."
-
-msgid "map.test"
-msgstr "This is a map test."
-
-msgid "test.test2"
-msgstr "This is another test."
diff --git a/assets/palette/CMakeLists.txt b/assets/palette/CMakeLists.txt
deleted file mode 100644
index 52b3842..0000000
--- a/assets/palette/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright (c) 2025 Dominic Masters
-#
-# This software is released under the MIT License.
-# https://opensource.org/licenses/MIT
-
-add_asset(PALETTE palette0.png)
-add_asset(PALETTE paletteMinesweeper.png)
\ No newline at end of file
diff --git a/assets/palette/palette0.png b/assets/palette/palette0.png
deleted file mode 100644
index e60ee7f..0000000
Binary files a/assets/palette/palette0.png and /dev/null differ
diff --git a/assets/palette/palette0.pxo b/assets/palette/palette0.pxo
deleted file mode 100644
index 070274a..0000000
Binary files a/assets/palette/palette0.pxo and /dev/null differ
diff --git a/assets/palette/paletteMinesweeper.png b/assets/palette/paletteMinesweeper.png
deleted file mode 100644
index 7193630..0000000
Binary files a/assets/palette/paletteMinesweeper.png and /dev/null differ
diff --git a/assets/scene/CMakeLists.txt b/assets/scene/CMakeLists.txt
deleted file mode 100644
index dae18d6..0000000
--- a/assets/scene/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright (c) 2025 Dominic Masters
-#
-# This software is released under the MIT License.
-# https://opensource.org/licenses/MIT
-
-add_asset(SCRIPT initial.lua)
-add_asset(SCRIPT minesweeper.lua)
\ No newline at end of file
diff --git a/assets/scene/initial.lua b/assets/scene/initial.lua
deleted file mode 100644
index d029c63..0000000
--- a/assets/scene/initial.lua
+++ /dev/null
@@ -1,43 +0,0 @@
-module('spritebatch')
-module('camera')
-module('color')
-module('text')
-module('screen')
-module('time')
-module('glm')
-
-screenSetBackground(colorBlack())
-camera = cameraCreate(CAMERA_PROJECTION_TYPE_ORTHOGRAPHIC)
-
-text = "Hello World"
-
-function sceneDispose()
-end
-
-function sceneUpdate()
-end
-
-function sceneRender()
- -- UI Test
- cameraPushMatrix(camera)
- camera.bottom = screenGetHeight()
- camera.right = screenGetWidth()
-
- width, height = textMeasure(text)
- x = (screenGetWidth() - width)
- x = math.sin(TIME.time * 2) * (x / 2) + (x / 2)
- y = (screenGetHeight() - height) / 2
- y = math.cos(TIME.time * 3) * (y) + (y)
-
- -- For each letter
- for i = 1, #text do
- letter = text:sub(i, i)
- letterWidth, _ = textMeasure(letter)
-
- -- Draw letter with rainbow color
- textDraw(x, y, letter, colorRainbow((i - 1) * 0.1, 8))
- x = x + letterWidth
- end
-
- cameraPopMatrix()
-end
\ No newline at end of file
diff --git a/assets/tileset/prarie.png b/assets/tileset/prarie.png
deleted file mode 100644
index 324cdd0..0000000
Binary files a/assets/tileset/prarie.png and /dev/null differ
diff --git a/assets/tileset/prarie.pxo b/assets/tileset/prarie.pxo
deleted file mode 100644
index 34d9b81..0000000
Binary files a/assets/tileset/prarie.pxo and /dev/null differ
diff --git a/assets/tileset/prarie.tsx b/assets/tileset/prarie.tsx
deleted file mode 100644
index dfaa242..0000000
--- a/assets/tileset/prarie.tsx
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/src/asset/asset.c b/src/asset/asset.c
index aa03e7a..877353c 100644
--- a/src/asset/asset.c
+++ b/src/asset/asset.c
@@ -232,6 +232,20 @@ errorret_t assetLoad(const char_t *filename, void *output) {
assertStrLenMax(filename, FILENAME_MAX, "Filename too long.");
assertNotNull(output, "Output pointer cannot be NULL.");
+ // Determine the asset type by reading the extension
+ const assettypedef_t *def = NULL;
+ for(uint_fast8_t i = 0; i < ASSET_TYPE_COUNT; i++) {
+ const assettypedef_t *cmp = &ASSET_TYPE_DEFINITIONS[i];
+ assertNotNull(cmp, "Asset type definition cannot be NULL.");
+ assertNotNull(cmp->extension, "Asset type definition has NULL extension.");
+ if(!stringEndsWithCaseInsensitive(filename, cmp->extension)) continue;
+ def = cmp;
+ break;
+ }
+ if(def == NULL) {
+ errorThrow("Unknown asset type for file: %s", filename);
+ }
+
// Get file size of the asset.
zip_stat_t st;
zip_stat_init(&st);
@@ -241,8 +255,8 @@ errorret_t assetLoad(const char_t *filename, void *output) {
// Minimum file size.
zip_int64_t fileSize = (zip_int64_t)st.size;
- if(fileSize < sizeof(assetheader_t)) {
- errorThrow("Asset file too small to contain header: %s", filename);
+ if(fileSize <= 0) {
+ errorThrow("Asset file is empty: %s", filename);
}
// Try to open the file
@@ -250,61 +264,19 @@ errorret_t assetLoad(const char_t *filename, void *output) {
if(file == NULL) {
errorThrow("Failed to open asset file: %s", filename);
}
-
- // Read the header.
- zip_int64_t bytesRemaining = fileSize;
- assetheader_t header;
- memoryZero(&header, sizeof(assetheader_t));
- zip_int64_t bytesRead = zip_fread(
- file,
- &header,
- (zip_uint64_t)sizeof(assetheader_t)
- );
- if((size_t)bytesRead != sizeof(assetheader_t)) {
- zip_fclose(file);
- errorThrow("Failed to read asset header for: %s", filename);
- }
- bytesRemaining -= (zip_uint64_t)bytesRead;
- assertTrue(sizeof(assetheader_t) == ASSET_HEADER_SIZE, "Asset header size mismatch.");
- assertTrue(bytesRead == ASSET_HEADER_SIZE, "Asset header read size mismatch.");
-
- // Find the asset type based on the header
- const assettypedef_t *def = NULL;
- for(uint_fast8_t i = 0; i < ASSET_TYPE_COUNT; i++) {
- const assettypedef_t *cmp = &ASSET_TYPE_DEFINITIONS[i];
- if(cmp->header == NULL) continue;
-
- // strcmp didn't work because it's a fixed char_t[3] I think, or maybe
- // because of the packed struct?
- bool_t match = true;
- for(size_t h = 0; h < ASSET_HEADER_SIZE; h++) {
- if(header.header[h] == cmp->header[h]) continue;
- match = false;
- break;
- }
- if(!match) continue;
-
- def = cmp;
- break;
- }
- if(def == NULL) {
- zip_fclose(file);
- errorThrow("Unknown asset type for file: %s", filename);
- }
-
- // We found the asset type, now load the asset data
+ // Load the asset data
switch(def->loadStrategy) {
case ASSET_LOAD_STRAT_ENTIRE:
assertNotNull(def->entire, "Asset load function cannot be NULL.");
// Must have more to read
- if(bytesRemaining <= 0) {
+ if(fileSize <= 0) {
zip_fclose(file);
errorThrow("No data remaining to read for asset: %s", filename);
}
- if(bytesRemaining > def->dataSize) {
+ if(fileSize > def->dataSize) {
zip_fclose(file);
errorThrow(
"Asset file has too much data remaining after header: %s",
@@ -313,20 +285,20 @@ errorret_t assetLoad(const char_t *filename, void *output) {
}
// Create space to read the entire asset data
- void *data = memoryAllocate(bytesRemaining);
+ void *data = memoryAllocate(fileSize);
if(!data) {
zip_fclose(file);
errorThrow("Failed to allocate memory for asset data of file: %s", filename);
}
// Read in the asset data.
- bytesRead = zip_fread(file, data, bytesRemaining);
- if(bytesRead == 0 || bytesRead > bytesRemaining) {
+ zip_int64_t bytesRead = zip_fread(file, data, fileSize);
+ if(bytesRead == 0 || bytesRead > fileSize) {
memoryFree(data);
zip_fclose(file);
errorThrow("Failed to read asset data for file: %s", filename);
}
- bytesRemaining -= bytesRead;
+ fileSize -= bytesRead;
// Close the file now we have the data
zip_fclose(file);
diff --git a/src/asset/asset.h b/src/asset/asset.h
index fbcd8ec..b786952 100644
--- a/src/asset/asset.h
+++ b/src/asset/asset.h
@@ -72,12 +72,6 @@ static const char_t *ASSET_SEARCH_PATHS[] = {
NULL
};
-#pragma pack(push, 1)
-typedef struct {
- char_t header[ASSET_HEADER_SIZE];
-} assetheader_t;
-#pragma pack(pop)
-
typedef struct {
zip_t *zip;
char_t systemPath[FILENAME_MAX];
diff --git a/src/asset/assettype.h b/src/asset/assettype.h
index c7cbcc9..91de6d2 100644
--- a/src/asset/assettype.h
+++ b/src/asset/assettype.h
@@ -6,8 +6,7 @@
*/
#pragma once
-#include "type/assetpaletteimage.h"
-#include "type/assetalphaimage.h"
+#include "type/assettexture.h"
#include "type/assetlanguage.h"
#include "type/assetscript.h"
#include "type/assetmap.h"
@@ -17,8 +16,7 @@
typedef enum {
ASSET_TYPE_NULL,
- ASSET_TYPE_PALETTE_IMAGE,
- ASSET_TYPE_ALPHA_IMAGE,
+ ASSET_TYPE_TEXTURE,
ASSET_TYPE_LANGUAGE,
ASSET_TYPE_SCRIPT,
ASSET_TYPE_MAP,
@@ -38,7 +36,7 @@ typedef struct assetcustom_s {
} assetcustom_t;
typedef struct {
- const char_t *header;
+ const char_t *extension;
const size_t dataSize;
const assetloadstrat_t loadStrategy;
union {
@@ -52,41 +50,34 @@ static const assettypedef_t ASSET_TYPE_DEFINITIONS[ASSET_TYPE_COUNT] = {
0
},
- [ASSET_TYPE_PALETTE_IMAGE] = {
- .header = "DPI",
+ [ASSET_TYPE_TEXTURE] = {
+ .extension = "dpt",
.loadStrategy = ASSET_LOAD_STRAT_ENTIRE,
- .dataSize = sizeof(assetpaletteimage_t),
- .entire = assetPaletteImageLoad
- },
-
- [ASSET_TYPE_ALPHA_IMAGE] = {
- .header = "DAI",
- .loadStrategy = ASSET_LOAD_STRAT_ENTIRE,
- .dataSize = sizeof(assetalphaimage_t),
- .entire = assetAlphaImageLoad
+ .dataSize = sizeof(assettexture_t),
+ .entire = assetTextureLoad
},
[ASSET_TYPE_LANGUAGE] = {
- .header = "DLF",
+ .extension = "DLF",
.loadStrategy = ASSET_LOAD_STRAT_CUSTOM,
.custom = assetLanguageHandler
},
[ASSET_TYPE_SCRIPT] = {
- .header = "DSF",
+ .extension = "lua",
.loadStrategy = ASSET_LOAD_STRAT_CUSTOM,
.custom = assetScriptHandler
},
- [ASSET_TYPE_MAP] = {
- .header = "DMF",
- .loadStrategy = ASSET_LOAD_STRAT_CUSTOM,
- .custom = assetMapHandler
- },
+ // [ASSET_TYPE_MAP] = {
+ // .extension = "DMF",
+ // .loadStrategy = ASSET_LOAD_STRAT_CUSTOM,
+ // .custom = assetMapHandler
+ // },
- [ASSET_TYPE_MAP_CHUNK] = {
- .header = "DMC",
- .loadStrategy = ASSET_LOAD_STRAT_CUSTOM,
- .custom = assetMapChunkHandler
- },
+ // [ASSET_TYPE_MAP_CHUNK] = {
+ // .extension = "DMC",
+ // .loadStrategy = ASSET_LOAD_STRAT_CUSTOM,
+ // .custom = assetMapChunkHandler
+ // },
};
\ No newline at end of file
diff --git a/src/asset/type/CMakeLists.txt b/src/asset/type/CMakeLists.txt
index 32eb64a..b43aa18 100644
--- a/src/asset/type/CMakeLists.txt
+++ b/src/asset/type/CMakeLists.txt
@@ -6,8 +6,7 @@
# Sources
target_sources(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
- assetalphaimage.c
- assetpaletteimage.c
+ assettexture.c
assetlanguage.c
assetscript.c
assetmap.c
diff --git a/src/asset/type/assetalphaimage.c b/src/asset/type/assetalphaimage.c
deleted file mode 100644
index bdf80d6..0000000
--- a/src/asset/type/assetalphaimage.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright (c) 2025 Dominic Masters
- *
- * This software is released under the MIT License.
- * https://opensource.org/licenses/MIT
- */
-
-#include "assetalphaimage.h"
-#include "assert/assert.h"
-#include "display/texture.h"
-
-#include "debug/debug.h"
-
-errorret_t assetAlphaImageLoad(void *data, void *output) {
- assertNotNull(data, "Data pointer cannot be NULL.");
- assertNotNull(output, "Output pointer cannot be NULL.");
-
- assetalphaimage_t *dataPtr = (assetalphaimage_t *)data;
- texture_t *outputPtr = (texture_t *)output;
-
- // Fix endian
- dataPtr->width = le32toh(dataPtr->width);
- dataPtr->height = le32toh(dataPtr->height);
-
- textureInit(
- outputPtr,
- dataPtr->width,
- dataPtr->height,
- TEXTURE_FORMAT_ALPHA,
- (texturedata_t){ .alpha = { .data = dataPtr->pixels } }
- );
-
- errorOk();
-}
\ No newline at end of file
diff --git a/src/asset/type/assetalphaimage.h b/src/asset/type/assetalphaimage.h
deleted file mode 100644
index c197c82..0000000
--- a/src/asset/type/assetalphaimage.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 "error/error.h"
-
-#define ASSET_ALPHA_IMAGE_WIDTH_MAX 256
-#define ASSET_ALPHA_IMAGE_HEIGHT_MAX 256
-#define ASSET_ALPHA_IMAGE_SIZE_MAX ( \
- ASSET_ALPHA_IMAGE_WIDTH_MAX * ASSET_ALPHA_IMAGE_HEIGHT_MAX \
-)
-
-#pragma pack(push, 1)
-typedef struct {
- uint32_t width;
- uint32_t height;
- uint8_t pixels[ASSET_ALPHA_IMAGE_SIZE_MAX];
-} assetalphaimage_t;
-#pragma pack(pop)
-
-/**
- * Loads an alpha image asset from the given asset structure. The asset must
- * be of type ASSET_TYPE_ALPHA_IMAGE and must be loaded.
- *
- * @param asset The asset to load the alpha image from.
- * @return An error code.
- */
-errorret_t assetAlphaImageLoad(void *data, void *output);
\ No newline at end of file
diff --git a/src/asset/type/assetlanguage.h b/src/asset/type/assetlanguage.h
index 676a6b3..5ece212 100644
--- a/src/asset/type/assetlanguage.h
+++ b/src/asset/type/assetlanguage.h
@@ -6,7 +6,6 @@
*/
#pragma once
-#include "locale/language/keys.h"
#include "error/error.h"
#include "duskdefs.h"
#include
diff --git a/src/asset/type/assetpaletteimage.h b/src/asset/type/assetpaletteimage.h
deleted file mode 100644
index d5d45ae..0000000
--- a/src/asset/type/assetpaletteimage.h
+++ /dev/null
@@ -1,34 +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"
-
-#define ASSET_PALETTE_IMAGE_WIDTH_MAX 256
-#define ASSET_PALETTE_IMAGE_HEIGHT_MAX 256
-#define ASSET_PALETTE_IMAGE_SIZE_MAX ( \
- ASSET_PALETTE_IMAGE_WIDTH_MAX * ASSET_PALETTE_IMAGE_HEIGHT_MAX \
-)
-
-#pragma pack(push, 1)
-typedef struct {
- uint32_t width;
- uint32_t height;
- uint8_t paletteIndex;
- uint8_t palette[ASSET_PALETTE_IMAGE_SIZE_MAX];
-} assetpaletteimage_t;
-#pragma pack(pop)
-
-/**
- * Loads a palette image asset from the given data pointer into the output
- * texture.
- *
- * @param data Pointer to the raw assetpaletteimage_t data.
- * @param output Pointer to the texture_t to load the image into.
- * @return An error code.
- */
-errorret_t assetPaletteImageLoad(void *data, void *output);
\ No newline at end of file
diff --git a/src/asset/type/assetpaletteimage.c b/src/asset/type/assettexture.c
similarity index 51%
rename from src/asset/type/assetpaletteimage.c
rename to src/asset/type/assettexture.c
index 3baada1..4d8a8c5 100644
--- a/src/asset/type/assetpaletteimage.c
+++ b/src/asset/type/assettexture.c
@@ -5,37 +5,38 @@
* https://opensource.org/licenses/MIT
*/
-#include "assetpaletteimage.h"
+#include "assettexture.h"
#include "assert/assert.h"
#include "display/texture.h"
-#include "display/palette/palettelist.h"
errorret_t assetPaletteImageLoad(void *data, void *output) {
assertNotNull(data, "Data pointer cannot be NULL.");
assertNotNull(output, "Output pointer cannot be NULL.");
- assetpaletteimage_t *assetData = (assetpaletteimage_t *)data;
+ assettexture_t *assetData = (assettexture_t *)data;
texture_t *texture = (texture_t *)output;
// Fix endian
assetData->width = le32toh(assetData->width);
assetData->height = le32toh(assetData->height);
-
- const palette_t *pal = PALETTE_LIST[assetData->paletteIndex];
- assertNotNull(pal, "Palette index is out of bounds");
- textureInit(
- texture,
- assetData->width,
- assetData->height,
- TEXTURE_FORMAT_PALETTE,
- (texturedata_t){
- .palette = {
- .palette = pal,
- .data = assetData->palette
- }
- }
- );
+ errorThrow("Hello World\n");
- errorOk();
+ // const palette_t *pal = PALETTE_LIST[assetData->paletteIndex];
+ // assertNotNull(pal, "Palette index is out of bounds");
+
+ // textureInit(
+ // texture,
+ // assetData->width,
+ // assetData->height,
+ // TEXTURE_FORMAT_PALETTE,
+ // (texturedata_t){
+ // .palette = {
+ // .palette = pal,
+ // .data = assetData->palette
+ // }
+ // }
+ // );
+
+ // errorOk();
}
\ No newline at end of file
diff --git a/src/asset/type/assettexture.h b/src/asset/type/assettexture.h
new file mode 100644
index 0000000..68bfa43
--- /dev/null
+++ b/src/asset/type/assettexture.h
@@ -0,0 +1,34 @@
+/**
+ * Copyright (c) 2025 Dominic Masters
+ *
+ * This software is released under the MIT License.
+ * https://opensource.org/licenses/MIT
+ */
+
+#pragma once
+#include "error/error.h"
+
+#define ASSET_TEXTURE_WIDTH_MAX 256
+#define ASSET_TEXTURE_HEIGHT_MAX 256
+#define ASSET_TEXTURE_SIZE_MAX ( \
+ ASSET_TEXTURE_WIDTH_MAX * ASSET_TEXTURE_HEIGHT_MAX \
+)
+
+#pragma pack(push, 1)
+typedef struct {
+ uint32_t width;
+ uint32_t height;
+ uint8_t paletteIndex;
+ uint8_t palette[ASSET_TEXTURE_SIZE_MAX];
+} assettexture_t;
+#pragma pack(pop)
+
+/**
+ * Loads a palettized texture from the given data pointer into the output
+ * texture.
+ *
+ * @param data Pointer to the raw assettexture_t data.
+ * @param output Pointer to the texture_t to load the image into.
+ * @return An error code.
+ */
+errorret_t assetTextureLoad(void *data, void *output);
\ No newline at end of file
diff --git a/src/display/palette/CMakeLists.txt b/src/display/palette/CMakeLists.txt
index 0b31e39..be5f8fb 100644
--- a/src/display/palette/CMakeLists.txt
+++ b/src/display/palette/CMakeLists.txt
@@ -6,4 +6,5 @@
# Sources
target_sources(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
+ palette.c
)
\ No newline at end of file
diff --git a/src/display/palette/palette.c b/src/display/palette/palette.c
new file mode 100644
index 0000000..288a243
--- /dev/null
+++ b/src/display/palette/palette.c
@@ -0,0 +1,8 @@
+/**
+ * Copyright (c) 2026 Dominic Masters
+ *
+ * This software is released under the MIT License.
+ * https://opensource.org/licenses/MIT
+ */
+
+#include "palette.h"
\ No newline at end of file
diff --git a/src/display/palette/palette.h b/src/display/palette/palette.h
index ecce9e8..fe8a594 100644
--- a/src/display/palette/palette.h
+++ b/src/display/palette/palette.h
@@ -8,7 +8,11 @@
#pragma once
#include "display/color.h"
+#define PALETTE_COUNT 4
+
typedef struct {
const uint8_t colorCount;
const color_t *colors;
-} palette_t;
\ No newline at end of file
+} palette_t;
+
+extern palette_t PALETTES[PALETTE_COUNT];
\ No newline at end of file
diff --git a/src/display/text.c b/src/display/text.c
index d1a0f5a..9e6d5fa 100644
--- a/src/display/text.c
+++ b/src/display/text.c
@@ -12,14 +12,15 @@
#include "asset/asset.h"
texture_t DEFAULT_FONT_TEXTURE;
+tileset_t DEFAULT_FONT_TILESET;
errorret_t textInit(void) {
- errorChain(assetLoad(DEFAULT_FONT_TILESET.image, &DEFAULT_FONT_TEXTURE));
+ // errorChain(assetLoad(DEFAULT_FONT_TILESET.image, &DEFAULT_FONT_TEXTURE));
errorOk();
}
void textDispose(void) {
- textureDispose(&DEFAULT_FONT_TEXTURE);
+ // textureDispose(&DEFAULT_FONT_TEXTURE);
}
void textDrawChar(
diff --git a/src/display/text.h b/src/display/text.h
index cfdddc8..4f622ed 100644
--- a/src/display/text.h
+++ b/src/display/text.h
@@ -9,12 +9,11 @@
#include "asset/asset.h"
#include "display/texture.h"
#include "display/tileset/tileset.h"
-#include "display/tileset/tileset_minogram.h"
#define TEXT_CHAR_START '!'
-extern texture_t DEFAULT_FONT_TEXTURE;
-#define DEFAULT_FONT_TILESET TILESET_MINOGRAM
+// extern texture_t DEFAULT_FONT_TEXTURE;
+// #define DEFAULT_FONT_TILESET TILESET_MINOGRAM
/**
* Initializes the text system.
diff --git a/src/display/texture.c b/src/display/texture.c
index 03d6a02..f368a2a 100644
--- a/src/display/texture.c
+++ b/src/display/texture.c
@@ -10,7 +10,6 @@
#include "util/memory.h"
#include "util/math.h"
#include "util/string.h"
-#include "display/palette/palettelist.h"
#include "debug/debug.h"
const texture_t *TEXTURE_BOUND = NULL;
diff --git a/src/display/tileset/tileset.c b/src/display/tileset/tileset.c
index de618e7..a4c782f 100644
--- a/src/display/tileset/tileset.c
+++ b/src/display/tileset/tileset.c
@@ -6,7 +6,6 @@
*/
#include "tileset.h"
-#include "display/tileset/tilesetlist.h"
#include "assert/assert.h"
#include "util/string.h"
@@ -34,13 +33,4 @@ void tilesetPositionGetUV(
outUV[1] = ((float_t)row) * tileset->uv[1];
outUV[2] = outUV[0] + tileset->uv[0];
outUV[3] = outUV[1] + tileset->uv[1];
-}
-
-const tileset_t * tilesetGetByName(const char_t *name) {
- assertStrLenMin(name, 1, "Tileset name cannot be empty");
- for(uint32_t i = 0; i < TILESET_LIST_COUNT; i++) {
- if(stringCompare(TILESET_LIST[i]->name, name) != 0) continue;
- return TILESET_LIST[i];
- }
- return NULL;
}
\ No newline at end of file
diff --git a/src/display/tileset/tileset.h b/src/display/tileset/tileset.h
index d8ffce6..01e3405 100644
--- a/src/display/tileset/tileset.h
+++ b/src/display/tileset/tileset.h
@@ -45,12 +45,4 @@ void tilesetPositionGetUV(
const uint16_t column,
const uint16_t row,
vec4 outUV
-);
-
-/**
- * Gets a tileset by its name.
- *
- * @param name The name of the tileset to get.
- * @return The tileset with the given name, or NULL if not found.
- */
-const tileset_t* tilesetGetByName(const char_t *name);
\ No newline at end of file
+);
\ No newline at end of file
diff --git a/src/locale/locale.h b/src/locale/locale.h
new file mode 100644
index 0000000..2b1ac0d
--- /dev/null
+++ b/src/locale/locale.h
@@ -0,0 +1,13 @@
+/**
+ * Copyright (c) 2026 Dominic Masters
+ *
+ * This software is released under the MIT License.
+ * https://opensource.org/licenses/MIT
+ */
+
+#pragma once
+#include "dusk.h"
+
+typedef struct {
+ void *nothing;
+} dusklocale_t;
\ No newline at end of file
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 72d1f95..fc27de7 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -4,14 +4,4 @@
# https://opensource.org/licenses/MIT
add_subdirectory(run_python)
-add_subdirectory(env_to_h)
-
-# Function that adds an asset to be compiled
-function(add_asset ASSET_TYPE ASSET_PATH)
- set(FULL_ASSET_PATH "${CMAKE_CURRENT_LIST_DIR}/${ASSET_PATH}")
- string(JOIN "%" ASSETS_ARGS ${ARGN})
- list(APPEND DUSK_ASSETS
- "${ASSET_TYPE}#${FULL_ASSET_PATH}#${ASSETS_ARGS}"
- )
- set(DUSK_ASSETS ${DUSK_ASSETS} CACHE INTERNAL ${DUSK_CACHE_TARGET})
-endfunction()
\ No newline at end of file
+add_subdirectory(env_to_h)
\ No newline at end of file
diff --git a/tools/display/color/csv/__main__.py b/tools/display/color/csv/__main__.py
index 1536334..7a97686 100644
--- a/tools/display/color/csv/__main__.py
+++ b/tools/display/color/csv/__main__.py
@@ -1,7 +1,6 @@
import argparse
import os
import csv
-from tools.util.type import detectType, stringToCType, typeToCType
parser = argparse.ArgumentParser(description="Color CSV to .h defines")
parser.add_argument("--csv", required=True, help="Path to color CSV file")
diff --git a/tools/input/csv/__main__.py b/tools/input/csv/__main__.py
index 5e954b8..f10f9d6 100644
--- a/tools/input/csv/__main__.py
+++ b/tools/input/csv/__main__.py
@@ -1,7 +1,6 @@
import argparse
import os
import csv
-from tools.util.type import detectType, stringToCType, typeToCType
parser = argparse.ArgumentParser(description="Input CSV to .h defines")
parser.add_argument("--csv", required=True, help="Path to Input CSV file")
diff --git a/tools/item/csv/__main__.py b/tools/item/csv/__main__.py
index bf2dffe..f065aec 100644
--- a/tools/item/csv/__main__.py
+++ b/tools/item/csv/__main__.py
@@ -1,7 +1,6 @@
import argparse
import os
import csv
-from tools.util.type import detectType, stringToCType, typeToCType
parser = argparse.ArgumentParser(description="Item CSV to .h defines")
parser.add_argument("--csv", required=True, help="Path to item CSV file")
diff --git a/tools/palette-indexer.html b/tools/palette-indexer.html
new file mode 100644
index 0000000..06e97ec
--- /dev/null
+++ b/tools/palette-indexer.html
@@ -0,0 +1,698 @@
+
+
+
+
+
+ Dusk Tools / Palette Indexer
+
+
+
+
+
+
Dusk Palette Indexer
+
+ This tool takes an input image and creates a palettized version of it.
+ You will get two files, a .dpf (Dusk Palette File) and a .dpt
+ (Dusk Palettized Texture). The first being the palette, which I recommend
+ reusing across multiple images, and the second being the indexed image,
+ which uses the colors from the palette.
+
+
+ Also, dusk previously supported Alpha textures, but due to so many little
+ platform differences I realized it is simpler and about as much work to
+ get palettized textures working instead. As a result I suggest creating a
+ single palette for your alpha textures, and reusing that globally.
+
+
+
+
Input Image
+
+
+
+
+
+
+
+
+
Palette
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Palette Preview
+
+
Palette
+
+
+
+
+
+
+
Indexed Image
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tools/story/csv/__main__.py b/tools/story/csv/__main__.py
index a230ccd..e99e3b4 100644
--- a/tools/story/csv/__main__.py
+++ b/tools/story/csv/__main__.py
@@ -1,7 +1,6 @@
import argparse
import os
import csv
-from tools.util.type import detectType, stringToCType, typeToCType
parser = argparse.ArgumentParser(description="Story CSV to .h defines")
parser.add_argument("--csv", required=True, help="Path to story CSV file")
diff --git a/tools/tile-joiner.html b/tools/tile-joiner.html
new file mode 100644
index 0000000..adb303f
--- /dev/null
+++ b/tools/tile-joiner.html
@@ -0,0 +1,223 @@
+
+
+
+
+
+ Dusk Tools / Tile Joiner
+
+
+
+
+
+
Dusk Tile Joiner
+
+ Joins multiple tiles together into a single tileset image. Optimizing and
+ allowing it to work on multiple platforms. Output width and height will
+ always be a power of two. This tool will take a while to process images,
+ since all images need to be loaded into memory.
+
+
+
+
+
+
+
+
+
+
+
+
Settings
+
+
+
+
+
+
+
+
Joined Preview
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tools/tile-slicer.html b/tools/tile-slicer.html
new file mode 100644
index 0000000..dcc6247
--- /dev/null
+++ b/tools/tile-slicer.html
@@ -0,0 +1,391 @@
+
+
+
+
+
+ Dusk Tools / Tile Slicer
+
+
+
+
+
+
Dusk Tile Slicer
+
+ Tool allows you to take a single image and slice it into individual tiles.
+ This should be done as the first step of optimizing tilesets for your
+ dusk game.
+
+
+
+
+
+
+
+
+
Input Preview
+
+
+
+
+
Settings
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Sliced Preview
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tools/util/type.py b/tools/util/type.py
deleted file mode 100644
index 32dd36a..0000000
--- a/tools/util/type.py
+++ /dev/null
@@ -1,44 +0,0 @@
-def detectType(value: str) -> str:
- val = value.strip()
- # Boolean check
- if val.lower() in {'true', 'false'}:
- return 'Boolean'
-
- # Int check
- try:
- int(val)
- return 'Int'
- except ValueError:
- pass
-
- # Float check
- try:
- float(val)
- return 'Float'
- except ValueError:
- pass
-
- # Default to String
- return 'String'
-
-def typeToCType(valType: str) -> str:
- if valType == 'Int':
- return 'int'
- elif valType == 'Float':
- return 'float'
- elif valType == 'Boolean':
- return 'bool'
- else:
- return 'char_t*'
-
-def stringToCType(value: str) -> str:
- valType = detectType(value)
- if valType == 'Int':
- return str(int(value))
- elif valType == 'Float':
- return str(float(value))
- elif valType == 'Boolean':
- return 'true' if value.lower() == 'true' else 'false'
- else:
- escaped = value.replace('\\', '\\\\').replace('"', '\\"')
- return f'"{escaped}"'
\ No newline at end of file