Tile & Map Functions
set_tile_address( unsigned int vram );
Set tile graphics data at vram
address.
set_tile_data( unsigned char __far *tiles, unsigned char num_tiles, unsigned char __far *palette_table, unsigned char tile_type );
Define an array of tile to be used by all the tile and map functions. tile_data
is the address of the tile graphics data in memory, nb_tile
is the number of tile (max. 256), and pal_ref
is the address of a palette-index array to use for tiles; each tile has its own palette index attached to it (note that palette indexes must be shifted to the left by four bits, ie. 0x40 for palette index 4).
The new 1-parameter form is used together with #inctile_ex()
or #incchr_ex()
directives, where all other relevant data is already conveyed in the #incxxx_ex()
directive. Also, this form automatically recognizes whether it is being used with 8x8 (incchr_ex
) or 16x16 (inctile_ex
) tiles.
load_vram( unsigned int vram, unsigned char __far *data, unsigned int num_words );
Generic function to load data (BAT, CG, sprites) in video memory, at address vram
.
num_words
is the number of 16-bit words to load.
load_tile( unsigned int vram );
Load tile graphics data in video memory, at address vram
You must first have defined a tile array with set_tile_data()
before using this function.
load_bat( unsigned int vram, unsigned char __far *data, unsigned char tiles_w, unsigned char tiles_h );
Load a rectangular character attribute table (BAT) of width 'w' and of height 'h' in video memory at address 'vram'.
put_tile( unsigned char tile, unsigned char bat_x, unsigned char bat_y );
Put individual tiles on the screen, either directly at video memory location 'vaddr', or at screen coordinates 'x/y' (in tile unit). 'tile' is a tile index in the tile array defined by the most recent call to set_tile_data()
.
map_put_tile( unsigned char map_x, unsigned char map_y, unsigned char tile );
Modifies the map data (sets a map element to a new tile ID), but works only when the map is stored in RAM - ie. a Super CDROM game which is loaded into RAM, and executes there. 'x' and 'y' are specified in the same units as map_get_tile()
(ie. pixels, not tiles).
map_get_tile( unsigned char map_x, unsigned char map_y );
Return the tile index as defined in the tile array used in the most recent call to set_tile_data()
. The 'x/y' argument is in pixel units, unlike the put_tile functions and thus this function is ideal for colision routines.
load_map( unsigned char bat_x, unsigned char bat_y, int map_x, int map_y, unsigned char tiles_w, unsigned char tiles_h );
Load a part of a map on the screen. 'sx' and 'sy' are screen coordinates (in tile unit; 16 pixels), 'mx' and 'my' are position in the map, and 'w' and 'h' are respectively the number of tile-index to load horizontaly and verticaly. This function doesn't do any screen clipping, so you must not pass incorrect or too big screen coordinates to it as that would corrupt the video memory.
set_map_data( unsigned char __far *map, unsigned char w, unsigned char h );
set_map_pals( unsigned char __far *palette_table );
set_map_tile_type( unsigned char tile_type );
set_map_tile_base( unsigned int vram );
load_background( unsigned char __far *tiles, unsigned char __far *palettes, unsigned char __far *bat, unsigned char w, unsigned char h );
This function is an all-in-one function, it is used to display an entire background image on the screen, like a game title image. It will load BG character data, it will load the palette, and finaly if will load the BAT. Use it with directives #incchr, #incpal and #incbat to manage the different types of data. The BG character data will be stored at address 0x1000 to 0x5000 in video memory.
Last updated