maug
Quick and dirty C mini-augmentation library.
Loading...
Searching...
No Matches
RetroTile Parser
Collaboration diagram for RetroTile Parser:

Data Structures

struct  RETROTILE_PARSER
 

Macros

#define RETROTILE_PARSER_MSTATE_TABLE(f)
 

Typedefs

typedef MERROR_RETVAL(* retrotile_tj_parse_cb) (const char *dirname, const char *filename, MAUG_MHANDLE *p_tm_h, struct MDATA_VECTOR *p_td, mparser_wait_cb_t wait_cb, void *wait_data, mparser_parse_token_cb token_cb, void *token_cb_data, uint8_t passes)
 

Functions

MERROR_RETVAL retrotile_parse_json_c (struct RETROTILE_PARSER *parser, char c)
 
mfix_t retrotile_static_rotation_from_dir (const char *dir)
 Convert a less-or-equal-to-two-character string to a direction in degrees.
 
MERROR_RETVAL retrotile_parse_json_file (const char *dirname, const char *filename, MAUG_MHANDLE *p_tilemap_h, struct MDATA_VECTOR *p_tile_defs, mparser_wait_cb_t wait_cb, void *wait_data, mparser_parse_token_cb token_cb, void *token_cb_data, uint8_t passes)
 Parse the JSON file at the given path into a heap-allocated tilemap with a RETROTILE struct header.
 

Detailed Description

Macro Definition Documentation

◆ RETROTILE_PARSER_MSTATE_TABLE

#define RETROTILE_PARSER_MSTATE_TABLE ( f)
Value:
f( MTILESTATE_NONE, 0, "", 0, 0 ) \
f( MTILESTATE_HEIGHT, 1, "height", 0 , 0 ) \
f( MTILESTATE_WIDTH, 2, "width", 0 , 0 ) \
f( MTILESTATE_LAYERS, 3, "layers", 0 , 0 ) \
f( MTILESTATE_LAYER_DATA, 4, "data", 15 /* LAYER */ , 0 ) \
f( MTILESTATE_LAYER_NAME, 5, "name", 15 /* LAYER */ , 0 ) \
f( MTILESTATE_TILES, 6, "tiles", 0 , 1 ) \
f( MTILESTATE_TILES_ID, 7, "id", 6 /* TILES */ , 1 ) \
f( MTILESTATE_TILES_IMAGE, 8, "image", 6 /* TILES */ , 1 ) \
f( MTILESTATE_TILESETS, 9, "tilesets", 0 , 0 ) \
f( MTILESTATE_TILESETS_SRC, 10, "source", 9 /* TILESETS */ , 0 ) \
f( MTILESTATE_TILESETS_FGID, 11, "firstgid", 9 /* TILESETS */ , 0 ) \
f( MTILESTATE_TILESETS_PROP, 12, "firstgid", 9 /* TILESETS */ , 0 ) \
f( MTILESTATE_GRID, 13, "grid", 0 , 1 ) \
f( MTILESTATE_TILES_PROP, 14, "properties", 6 /* TILES */ , 1 ) \
f( MTILESTATE_LAYER, 15, "layers", /* [sic] */ 3 , 0 ) \
f( MTILESTATE_TILES_PROP_NAME, 16, "name", 14 /* TIL_PROP */ , 1 ) \
f( MTILESTATE_TILES_PROP_VAL, 17, "value", 14 /* TIL_PROP */ , 1 ) \
f( MTILESTATE_PROP, 18, "properties", 0 /* NONE */ , 0 ) \
f( MTILESTATE_PROP_NAME, 19, "name", 18 /* PROP */ , 0 ) \
f( MTILESTATE_PROP_VAL, 20, "value", 18 /* PROP */ , 0 ) \
f( MTILESTATE_LAYER_CLASS, 21, "class", 15 /* LAYER */ , 0 ) \
f( MTILESTATE_TILES_CLASS, 22, "type", 6 /* TILES */ , 1 )

Function Documentation

◆ retrotile_parse_json_file()

MERROR_RETVAL retrotile_parse_json_file ( const char * dirname,
const char * filename,
MAUG_MHANDLE * p_tilemap_h,
struct MDATA_VECTOR * p_tile_defs,
mparser_wait_cb_t wait_cb,
void * wait_data,
mparser_parse_token_cb token_cb,
void * token_cb_data,
uint8_t passes )

Parse the JSON file at the given path into a heap-allocated tilemap with a RETROTILE struct header.

Parameters
dirnameBase directory from which to load the tilemap and its accompanying data files. This includes external tileset files and tile graphics.
filenameName of tilemap JSON file to parse, inside of dirname.
p_tilemap_hPointer to a MAUG_MHANDLE to allocate and load the tilemap into. The handle targeted should be NULL and, if this is successful, will no longer be NULL afterward.
p_tile_defsPointer to a MDATA_VECTOR to be loaded with RETROTILE_TILE_DEF structs from the given tilemap.
wait_cbCallback to call every so often during loading (e.g. to update a loading animation or similar).
wait_dataArbitrary data to pass to wait_cb when it is called.
token_cbCallback to parse engine-specific custom tokens from the tilemap JSON. Should return MERROR_PREEMPT if parsing is successful and should override standard parsing.
passesNumber of passes to make on parsed tilemap. This can be combined with token_cb for more advanced operations. The minimum is 2.
Returns
MERROR_OK if successful or other MERROR_RETVAL otherwise.
Note
This function ignores RETROFLAT_STATE::assets_path.

◆ retrotile_static_rotation_from_dir()

mfix_t retrotile_static_rotation_from_dir ( const char * dir)

Convert a less-or-equal-to-two-character string to a direction in degrees.

This function is useful for converting a prerendered isometric tileset to modifications for a realtime-rendered ::RETRO3DP_MODEL.