Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
fs_wsg.h File Reference

Detailed Description

Design Philosophy

These functions load and free WSG assets which are images that are compressed and compiled into the filesystem into RAM. Once decompressed loaded into RAM, WSGs may be drawn to the display.

For more information about using WSGs, see wsg.h.

For information on asset processing, see assets_preprocessor.

Usage

Load WSGs from the filesystem to RAM using loadWsg(). WSGs may be loaded to normal RAM, which is smaller and faster, or SPI RAM, which is larger and slower.

Free when done using freeWsg(). If a wsg is not freed, the memory will leak.

Example

// Declare and load a WSG
wsg_t king_donut;
loadWsg("kid0.wsg", &king_donut, true);
// Draw the WSGto the display
drawWsg(&king_donut, 100, 10, false, false, 0);
// Free the WSG
freeWsg(&king_donut);
bool loadWsg(const char *name, wsg_t *wsg, bool spiRam)
Load a WSG from ROM to RAM. WSGs placed in the assets_image folder before compilation will be automat...
Definition fs_wsg.c:34
void freeWsg(wsg_t *wsg)
Free the memory for a loaded WSG.
Definition fs_wsg.c:167
void drawWsg(const wsg_t *wsg, int16_t xOff, int16_t yOff, bool flipLR, bool flipUD, int16_t rotateDeg)
Draw a WSG to the display.
Definition wsg.c:105
A sprite using paletteColor_t colors that can be drawn to the display.
Definition wsg.h:57

Go to the source code of this file.

Functions

bool loadWsg (const char *name, wsg_t *wsg, bool spiRam)
 Load a WSG from ROM to RAM. WSGs placed in the assets_image folder before compilation will be automatically flashed to ROM.
 
bool loadWsgNvs (const char *namespace, const char *key, wsg_t *wsg, bool spiRam)
 
bool saveWsgNvs (const char *namespace, const char *key, const wsg_t *wsg)
 
void freeWsg (wsg_t *wsg)
 Free the memory for a loaded WSG.
 

Function Documentation

◆ loadWsg()

bool loadWsg ( const char * name,
wsg_t * wsg,
bool spiRam )

Load a WSG from ROM to RAM. WSGs placed in the assets_image folder before compilation will be automatically flashed to ROM.

Parameters
nameThe filename of the WSG to load
wsgA handle to load the WSG to
spiRamtrue to load to SPI RAM, false to load to normal RAM. SPI RAM is more plentiful but slower to access than normal RAM
Returns
true if the WSG was loaded successfully, false if the WSG load failed and should not be used

◆ loadWsgNvs()

bool loadWsgNvs ( const char * namespace,
const char * key,
wsg_t * wsg,
bool spiRam )

◆ saveWsgNvs()

bool saveWsgNvs ( const char * namespace,
const char * key,
const wsg_t * wsg )

◆ freeWsg()

void freeWsg ( wsg_t * wsg)

Free the memory for a loaded WSG.

Parameters
wsgThe WSG handle to free memory from