Refactor asset loading

This commit is contained in:
2025-11-04 22:23:44 -06:00
parent 7c11a7e5bc
commit 1ce1fdff8d
26 changed files with 198 additions and 1010 deletions

41
src/asset/assettype.h Normal file
View File

@@ -0,0 +1,41 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "type/assetpaletteimage.h"
#include "type/assetalphaimage.h"
typedef enum {
ASSET_TYPE_NULL,
ASSET_TYPE_PALETTE_IMAGE,
ASSET_TYPE_ALPHA_IMAGE,
ASSET_TYPE_COUNT,
} assettype_t;
typedef struct {
const char_t *header;
const size_t dataSize;
errorret_t (*load)(void *data, void *output);
} assettypedef_t;
static const assettypedef_t ASSET_TYPE_DEFINITIONS[ASSET_TYPE_COUNT] = {
[ASSET_TYPE_NULL] = {
0
},
[ASSET_TYPE_PALETTE_IMAGE] = {
.header = "DPI",
.dataSize = sizeof(assetpaletteimage_t),
.load = assetPaletteImageLoad
},
[ASSET_TYPE_ALPHA_IMAGE] = {
.header = "DAI",
.dataSize = sizeof(assetalphaimage_t),
.load = assetAlphaImageLoad
},
};