From db3fd5aac9c66e64aa56fabc1a865fb64a65fc1c Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Mon, 1 Sep 2025 14:50:07 -0700 Subject: Add support for single-image tile sets (not yet tested). --- include/isogfx/asset.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/isogfx/asset.h b/include/isogfx/asset.h index 9aeb55d..6050500 100644 --- a/include/isogfx/asset.h +++ b/include/isogfx/asset.h @@ -25,8 +25,15 @@ typedef struct Ts_Tile { uint32_t pixels; // Byte offset into the Ts_TileSet's 'pixels'. } Ts_Tile; +// Tileset. +// +// Tile dimensions may be larger than the baseline tile dimensions of the +// tileset if the tileset contains supertiles. Regardless, tile dimensions are +// always a multiple of baseline dimensions along each axis. typedef struct Ts_TileSet { uint16_t num_tiles; + uint16_t tile_width; // Baseline tile width. + uint16_t tile_height; // Baseline tile height. uint16_t _pad; Ts_Tile tiles[1]; // Count: num_tiles. Pixel pixels[]; // Count: sum_i(tile[i].width * tile[i].height). @@ -64,8 +71,8 @@ typedef struct Tm_Map { /// /// Pixels are 8-bit indices into the sprite sheet's colour palette. typedef struct Ss_Row { - uint16_t num_cols; /// Number of columns in this row. - uint8_t pixels[1]; /// Count: num_cols * sprite_width * sprite_height. + uint16_t num_cols; // Number of columns in this row. + uint8_t pixels[1]; // Count: num_cols * sprite_width * sprite_height. } Ss_Row; typedef struct Ss_Palette { @@ -77,11 +84,11 @@ typedef struct Ss_Palette { /// /// Sprite width and height are assumed constant throughout the sprite sheet. typedef struct Ss_SpriteSheet { - uint16_t sprite_width; /// Sprite width in pixels. - uint16_t sprite_height; /// Sprite height in pixels. + uint16_t sprite_width; // Sprite width in pixels. + uint16_t sprite_height; // Sprite height in pixels. uint16_t num_rows; - Ss_Palette palette; /// Variable size. - Ss_Row rows[1]; /// Count: num_rows. Variable offset. + Ss_Palette palette; // Variable size. + Ss_Row rows[1]; // Count: num_rows. Variable offset. } Ss_SpriteSheet; // ----------------------------------------------------------------------------- -- cgit v1.2.3