/** * 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 "error/error.h" #include #define ASSET_COUNT_MAX 128 #define ASSET_FILENAME_MAX 128 #if ASSET_TYPE == wad #else #error "Unsupported ASSET_TYPE" #endif typedef struct { char_t header[3]; union { assetpalette_t palette; assettileset_t tileset; }; } assetdata_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; } asset_t; static const char_t ASSET_SEARCH_PATHS[][FILENAME_MAX] = { "%s/%s", "./%s", "../%s", "../../%s", "data/%s", "../data/%s", }; #define ASSET_SEARCH_PATHS_COUNT (\ sizeof(ASSET_SEARCH_PATHS) / FILENAME_MAX\ ) extern asset_t ASSET; /** * Initializes the asset system. */ errorret_t assetInit(void); /** * Gets an asset by filename, does not load it. * * @param filename The filename of the asset to get. * @return The asset. */ void assetLoad(const char_t *filename); /** * Disposes/cleans up the asset system. */ void assetDispose(void);