tile.h
1 #ifndef _TILE_FUNCS_H 2 #define _TILE_FUNCS_H 3 4 #include "pico/types.h" 5 6 typedef enum { 7 TILESIZE_8 = 0, 8 TILESIZE_16 9 } tilesize_t; 10 11 // Dubiously-erased function type for fill loops (cast out before calling): 12 typedef void (*tile_loop_t)(void *dst, const void *tileset, uint x0, uint x1); 13 14 // Rather than defining the pixel format, the tilebg object has a function 15 // pointer to a pixel fill loop appropriate for the format and tile size. 16 // 17 // The asm fill loops are specialised for format (as well as tile size), are 18 // pretty large, and live in RAM. If we dispatched those loops dynamically, 19 // the references to all the loops would prevent their link-time garbage 20 // collection, wasting RAM we would rather use for sprite/tile assets. 21 // Instead, the creator of the tilebg object explicitly adds references to 22 // the appropriate fill routine symbols when configuring the tilebgs. 23 24 typedef struct tilebg { 25 uint16_t xscroll; 26 uint16_t yscroll; 27 const void *tileset; 28 const uint8_t *tilemap; 29 uint8_t log_size_x; 30 uint8_t log_size_y; 31 tilesize_t tilesize; 32 tile_loop_t fill_loop; 33 } tilebg_t; 34 35 // ---------------------------------------------------------------------------- 36 // Functions from tile.S 37 38 // Signature of fill loops of a given pixel size: 39 typedef void (*tile16_loop_t)(uint16_t *dst, const uint16_t *tileset, uint x0, uint x1); 40 typedef void (*tile8_loop_t)(uint8_t *dst, const uint8_t *tileset, uint x0, uint x1); 41 42 void tile16_16px_alpha_loop(uint16_t *dst, const uint16_t *tileset, uint x0, uint x1); 43 void tile16_16px_loop(uint16_t *dst, const uint16_t *tileset, uint x0, uint x1); 44 45 // ---------------------------------------------------------------------------- 46 // Functions from tile.c 47 48 void tile16(uint16_t *scanbuf, const tilebg_t *bg, uint raster_y, uint raster_w); 49 50 51 52 #endif