Files
dusk/src/asset/asset.h

60 lines
1.1 KiB
C

/**
* 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 <zip.h>
#if ASSET_TYPE == wad
#else
#error "Unsupported ASSET_TYPE"
#endif
#define ASSET_FILE "dusk.dsk"
static const char_t *ASSET_SEARCH_PATHS[] = {
"%s/%s",
"%s",
"../%s",
"../../%s",
"data/%s",
"../data/%s",
NULL
};
#pragma pack(push, 1)
typedef struct {
char_t header[3];
} assetheader_t;
#pragma pack(pop)
typedef struct {
zip_t *zip;
char_t systemPath[FILENAME_MAX];
uint8_t assetCount;
} asset_t;
static asset_t ASSET;
/**
* Initializes the asset system.
*/
errorret_t assetInit(void);
/**
* Loads an asset by its filename, the output type depends on the asset type.
*
* @param filename The filename of the asset to retrieve.
* @param output The output pointer to store the loaded asset data.
* @return An error code if the asset could not be loaded.
*/
errorret_t assetLoad(const char_t *filename, void *output);
/**
* Disposes/cleans up the asset system.
*/
void assetDispose(void);