Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
|
Ths Swadge loads an assets "image" as cnfs_files
and cnfs_data
.
During the build, assets in the /assets/
folder, such as PNG images and MIDI songs, are processed into Swadge-friendly formats and written to the /assets_image/
folder. The contents of the /assets_image/
are then packaged into a matching cnfs_files
and cnfs_data
image which are stored as a C file and loaded alongside cnfs.c.
You don't need to call cnfsInit() or cnfsDeinit(). The system does that the appropriate time.
cnfsReadFile() may be used to read a file straight from cnfs, but this probably should not be done directly.
cnfsGetFile() gets a reference to the file in flash, to obviate need to "load it into RAM"
Each asset type has it's own file loader which handles things like decompression if the asset type is compressed, and writing values from the read file into a convenient struct. The loader functions are:
Assets may be loaded to either SPI RAM or normal RAM. There is more SPI RAM available, but it is slower to access than normal RAM. Swadge modes should use normal RAM if they can, and use SPI RAM if the mode is asset-heavy.
Go to the source code of this file.
Functions | |
bool | initCnfs (void) |
Initialize the CNFS file system. This is used to store assets like WSGs and fonts. | |
bool | deinitCnfs (void) |
De-initialize the CNFS file system (right now a noop) | |
const uint8_t * | cnfsGetFile (const char *fname, size_t *flen) |
Get a pointer to a file, without needing to read it. Same rules that apply to cnfsGetFile, and under the hood, cnfsGetFile uses this function. | |
uint8_t * | cnfsReadFile (const char *fname, size_t *outsize, bool readToSpiRam) |
Read a file from CNFS into an output array. Files that are in the assets_image folder before compilation and flashing will automatically be included in the firmware. | |
bool initCnfs | ( | void | ) |
Initialize the CNFS file system. This is used to store assets like WSGs and fonts.
bool deinitCnfs | ( | void | ) |
De-initialize the CNFS file system (right now a noop)
const uint8_t * cnfsGetFile | ( | const char * | fname, |
size_t * | flen ) |
Get a pointer to a file, without needing to read it. Same rules that apply to cnfsGetFile, and under the hood, cnfsGetFile uses this function.
fname | The name of the file to find. |
flen | A pointer to a size_t to return the size of the file. |
uint8_t * cnfsReadFile | ( | const char * | fname, |
size_t * | outsize, | ||
bool | readToSpiRam ) |
Read a file from CNFS into an output array. Files that are in the assets_image folder before compilation and flashing will automatically be included in the firmware.
fname | The name of the file to load |
outsize | A pointer to a size_t to return how much data was read |
readToSpiRam | true to use SPI RAM, false to use normal RAM |