Difference between revisions of "Tile and Map Functions"
From Archaic Pixels
m (→map_get_tile) |
|||
(One intermediate revision by one other user not shown) | |||
Line 26: | Line 26: | ||
8x8 (incchr_ex) or 16x16 (inctile_ex) tiles. | 8x8 (incchr_ex) or 16x16 (inctile_ex) tiles. | ||
|} | |} | ||
+ | |||
== load_tile == | == load_tile == | ||
Line 37: | Line 38: | ||
set_tile_data() before using this function. | set_tile_data() before using this function. | ||
|} | |} | ||
+ | |||
== put_tile == | == put_tile == | ||
Line 51: | Line 53: | ||
array defined by the most recent call to set_tile_data(). | array defined by the most recent call to set_tile_data(). | ||
|} | |} | ||
+ | |||
== map_put_tile == | == map_put_tile == | ||
Line 65: | Line 68: | ||
specified in the same units as map_get_tile() (ie. pixels, not tiles). | specified in the same units as map_get_tile() (ie. pixels, not tiles). | ||
|} | |} | ||
+ | |||
== get_tile == | == get_tile == | ||
Line 77: | Line 81: | ||
for colision routines. | for colision routines. | ||
|} | |} | ||
+ | |||
== map_get_tile == | == map_get_tile == | ||
Line 85: | Line 90: | ||
| | | | ||
Return the tile index as defined in the tile array used in the most | 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 | + | recent call to set_tile_data(). The 'x/y' argument is in tile |
units, unlike the put_tile functions and thus this function is ideal | units, unlike the put_tile functions and thus this function is ideal | ||
for colision routines. | for colision routines. | ||
Line 100: | Line 105: | ||
and of height 'h' (max. 255). | and of height 'h' (max. 255). | ||
|} | |} | ||
+ | |||
== load_map == | == load_map == | ||
Line 115: | Line 121: | ||
that would corrupt the video memory. | that would corrupt the video memory. | ||
|} | |} | ||
+ | |||
== scroll == | == scroll == | ||
Line 133: | Line 140: | ||
the window. | the window. | ||
|} | |} | ||
+ | |||
== scroll_disable == | == scroll_disable == |
Latest revision as of 01:38, 8 May 2020
Contents
Tile and Map Functions
set_tile_data
void set_tile_data(char *tile_ex); [ 3.20+ ] |
---|
void set_tile_data(char *tile_data, int nb_tile, char *pal_ref); |
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. 255), 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_tile
void load_tile(int vaddr); |
---|
Load tile graphics data in video memory, at address 'vaddr'. You must first have defined a tile array with set_tile_data() before using this function. |
put_tile
void put_tile(int num, int vaddr); |
---|
void put_tile(int num, char x, char y); |
Put individual tiles on the screen, either directly at video memory location 'vaddr', or at screen coordinates 'x/y' (in tile unit). 'num' is a tile index in the tile array defined by the most recent call to set_tile_data(). |
map_put_tile
void map_put_tile(char x, char y, char tile); [ 3.20+ ] |
---|
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). |
get_tile
char get_tile(char x, char y); [ 1.5 - 3.11, RENAMED IN 3.20 ] |
---|
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. |
map_get_tile
char map_get_tile(char x, char y); [ 3.20+ ] |
---|
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 tile units, unlike the put_tile functions and thus this function is ideal for colision routines. |
set_map_data
void set_map_data(char *map, char w, char h); |
---|
Define a tile-index map to be used by load_map(). 'map' is the address of a map of width 'w' (max. 255) and of height 'h' (max. 255). |
load_map
void load_map(char sx, char sy, int mx, int my, char w, char 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, that would corrupt the video memory. |
scroll
void scroll(char num, int x, int y, char top, char bottom, char disp); |
---|
Define screen window 'num'. Up to four window can be defined. 'top' and 'bottom' are the screen top and bottom limits of the window (limits are included in the window area). 'disp' controls the type of the window, if bit 7 is set background graphics will be displayed in this window, and if bit 6 is set sprites will also be displayed. If none of these bits are set the window will stay blank. 'x' and 'y' are the top-left coordinates of the area in the virtual screen that will be displayed in the window. |
scroll_disable
void scroll_disable(char num); [ 1.5+ ] |
---|
Disable scrolling for the screen window 'num'. |