Draws a complete tilemap made of 2x4-bytes tiles.
void cpct_etm_drawTilemap2x4_f (u8 map_width, u8 map_height, u8* pvideomem, u8* ptilemap) __z88dk_callee;
(1B A) map_width | Width of the tilemap in tiles |
(1B C) map_height | Height of the tilemap in tiles |
(2B DE) pvidemem | Pointer to video memory location where the tilemap is to be drawn |
(2B HL) ptilemap | Pointer to the start of the tilemap definition (2D tile-index matrix) |
call cpct_etm_drawTilemap2x4_f_asm
This function draws a complete tilemap on the screen or on a backbuffer. The ptilemap parameter is expected to point to a 2D tile-index matrix structure, having 1-byte values for each tile-index. The function traverses the tilemap 2D matrix retrieving tiles one by one and drawing them on the screen or backbuffer.
This function uses an internal pointer to the tileset (ptileset). This internal pointer MUST BE SET BEFORE using this function; otherwise, a NULL (0x0000) pointer is used as pointer to the tileset, using information at the start of memory as if it contained pointers to tiles (leading to undefined behaviour). To set the ptileset pointer, the function cpct_etm_setTileset2x4 can be used.
A tileset is expected to contain an array of pointers (2-byte values) to tile definitions. Each pointed tile is expected to be an array of 2x4 bytes defining the pixels of the tile in screen pixel format. Each one of this tiles is drawn to screen or backbuffer using cpct_drawTileAligned2x4_f function (ASM bindings).
AF, BC, DE, HL AF’, BC’, DE’, HL’
C-bindings | 44 bytes (+ 33 bytes from cpct_drawTileAligned2x4_f) |
ASM-bindings | 38 bytes (+ 33 bytes from cpct_drawTileAligned2x4_f) |
Case | microSecs (us) | CPU Cycles | --------------------------------------------------------------------------------- Any | 27 + (21 + 103W)H + 9HO + 16HE | 108 + (84 + 412W)H + 36HO + 64HE | --------------------------------------------------------------------------------- ASM saving | - 17 | - 68 | --------------------------------------------------------------------------------- H=30, W=30 | 93.723 (4,69 VSYNCs) | 374.892 | Start=Pix0 | 0,094 secs | | --------------------------------------------------------------------------------- H=40, W=40 | 166.151 (8,32 VSYNCs) | 664.604 | Start=Pix4 | 0,166 secs | | ---------------------------------------------------------------------------------
W | Map width (number of horizontal tiles) |
H | Map height (number of vertical tiles) |
HO | Number of odd tile rows. |
HE | Number of even tile rows. For HO and HE, the first row is considered odd if it starts at a pixel line 4, and it is considered even otherwise. The last row of the tilemap is never taken into account (either for HO or HE). |