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

Detailed Description

Design Philosophy

These functions load and free plaintext assets which are compiled into the filesystem into RAM. Once loaded into RAM, the text data is a string that may be used for whatever purpose.

For information on asset processing, see assets_preprocessor.

Usage

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

Free when done using freeTxt(). If text is not freed, the memory will leak.

Example

char* txtStr = loadTxt("story.txt", true);
// Free the txt
freeTxt(&txtStr);
char * loadTxt(const char *name, bool spiRam)
Load a TXT from ROM to RAM. TXTs placed in the assets_image folder before compilation will be automat...
Definition fs_txt.c:30
void freeTxt(char *txtStr)
Free an allocated TXT string.
Definition fs_txt.c:49

Go to the source code of this file.

Functions

char * loadTxt (const char *name, bool spiRam)
 Load a TXT from ROM to RAM. TXTs placed in the assets_image folder before compilation will be automatically flashed to ROM.
 
void freeTxt (char *txtStr)
 Free an allocated TXT string.
 

Function Documentation

◆ loadTxt()

char * loadTxt ( const char * name,
bool spiRam )

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

Parameters
nameThe filename of the TXT to load
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
A pointer to a null terminated TXT string. May be NULL if the load fails. Must be freed after use

◆ freeTxt()

void freeTxt ( char * txtStr)

Free an allocated TXT string.

Parameters
txtStrthe TXT string to free