Difference between revisions of "Tile and Map Functions"

From Archaic Pixels
Jump to: navigation, search
(Created page with "= Tile and Map Functions = == set_tile_data == {| |- | [b][color=#00AA00]void[/color] set_tile_data([color=#AA0000]char[/color] *tile_ex);[/b][float=right][tt][ 3.20+ ][/tt][/flo...")
 
m (map_get_tile)
 
(6 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
{{:HuC Function Style}}
 
= Tile and Map Functions =
 
= Tile and Map Functions =
 +
 
== set_tile_data ==
 
== set_tile_data ==
 
{|
 
{|
 
|-
 
|-
| [b][color=#00AA00]void[/color] set_tile_data([color=#AA0000]char[/color] *tile_ex);[/b][float=right][tt][ 3.20+ ][/tt][/float]<br />[b][color=#00AA00]void[/color] set_tile_data([color=#AA0000]char[/color] *tile_data, [color=#0000AA]int[/color] nb_tile, [color=#AA0000]char[/color] *pal_ref);[/b]
+
! [color=#00AA00]void[/color] set_tile_data([color=#AA0000]char[/color] *tile_ex); [b][ 3.20+ ][/b]
 +
|-
 +
! [color=#00AA00]void[/color] set_tile_data([color=#AA0000]char[/color] *tile_data, [color=#0000AA]int[/color] nb_tile, [color=#AA0000]char[/color] *pal_ref);
 
|-
 
|-
 
|
 
|
Line 15: Line 19:
 
     shifted to the left by four bits, ie. 0x40 for
 
     shifted to the left by four bits, ie. 0x40 for
 
     palette index 4).
 
     palette index 4).
|-
+
 
|
+
 
     The new 1-parameter form is used together with #inctile_ex()
 
     The new 1-parameter form is used together with #inctile_ex()
 
     or #incchr_ex() directives, where all other relevant data is
 
     or #incchr_ex() directives, where all other relevant data is
Line 23: Line 26:
 
     8x8 (incchr_ex) or 16x16 (inctile_ex) tiles.
 
     8x8 (incchr_ex) or 16x16 (inctile_ex) tiles.
 
|}
 
|}
 +
 +
 
== load_tile ==
 
== load_tile ==
 
{|
 
{|
 
|-
 
|-
| [b][color=#00AA00]void[/color] load_tile([color=#0000AA]int[/color] vaddr);[/b]
+
! [color=#00AA00]void[/color] load_tile([color=#0000AA]int[/color] vaddr);
 
|-
 
|-
 
|
 
|
Line 33: Line 38:
 
     set_tile_data() before using this function.
 
     set_tile_data() before using this function.
 
|}
 
|}
 +
 +
 
== put_tile ==
 
== put_tile ==
 
{|
 
{|
 
|-
 
|-
| [b][color=#00AA00]void[/color] put_tile([color=#0000AA]int[/color] num, [color=#0000AA]int[/color] vaddr);<br />[color=#00AA00]void[/color] put_tile([color=#0000AA]int[/color] num, [color=#AA0000]char[/color] x, [color=#AA0000]char[/color] y);[/b]
+
! [color=#00AA00]void[/color] put_tile([color=#0000AA]int[/color] num, [color=#0000AA]int[/color] vaddr);
 +
|-
 +
! [color=#00AA00]void[/color] put_tile([color=#0000AA]int[/color] num, [color=#AA0000]char[/color] x, [color=#AA0000]char[/color] y);
 
|-
 
|-
 
|
 
|
Line 44: 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 ==
 
{|
 
{|
 
|-
 
|-
| [b][color=#00AA00]void[/color] map_put_tile([color=#AA0000]char[/color] x, [color=#AA0000]char[/color] y, [color=#AA0000]char[/color] tile);[/b][float=right][tt][ 3.20+ ][/tt][/float]<br />
+
! [color=#00AA00]void[/color] map_put_tile([color=#AA0000]char[/color] x, [color=#AA0000]char[/color] y, [color=#AA0000]char[/color] tile); [b][ 3.20+ ][/b]
 +
|-
 +
|
 
|-
 
|-
 
|
 
|
Line 55: 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 ==
 
{|
 
{|
 
|-
 
|-
| [b][color=#AA0000]char[/color]  get_tile([color=#AA0000]char[/color] x, [color=#AA0000]char[/color] y);[/b][float=right][tt][ 1.5 - 3.11, RENAMED IN 3.20 ][/tt][/float]<br />
+
! [color=#AA0000]char[/color]  get_tile([color=#AA0000]char[/color] x, [color=#AA0000]char[/color] y); [b][ 1.5 - 3.11, RENAMED IN 3.20 ][/b]
 
|-
 
|-
 
|
 
|
Line 66: Line 81:
 
     for colision routines.
 
     for colision routines.
 
|}
 
|}
 +
 +
 
== map_get_tile ==
 
== map_get_tile ==
 
{|
 
{|
 
|-
 
|-
| [b][color=#00AA00]char[/color] map_get_tile([color=#AA0000]char[/color] x, [color=#AA0000]char[/color] y);[/b][float=right][tt][ 3.20+ ][/tt][/float]<br />
+
! [color=#00AA00]char[/color] map_get_tile([color=#AA0000]char[/color] x, [color=#AA0000]char[/color] y); [b][ 3.20+ ][/b]
 
|-
 
|-
 
|
 
|
 
     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 pixel
+
     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.
 
|}
 
|}
 +
 
== set_map_data ==
 
== set_map_data ==
 
{|
 
{|
 
|-
 
|-
| [b][color=#00AA00]void[/color] set_map_data([color=#AA0000]char[/color] *map, [color=#AA0000]char[/color] w, [color=#AA0000]char[/color] h);[/b]
+
! [color=#00AA00]void[/color] set_map_data([color=#AA0000]char[/color] *map, [color=#AA0000]char[/color] w, [color=#AA0000]char[/color] h);
 
|-
 
|-
 
|
 
|
Line 87: Line 105:
 
     and of height 'h' (max. 255).
 
     and of height 'h' (max. 255).
 
|}
 
|}
 +
 +
 
== load_map ==
 
== load_map ==
 
{|
 
{|
 
|-
 
|-
| [b][color=#00AA00]void[/color] load_map([color=#AA0000]char[/color] sx, [color=#AA0000]char[/color] sy, [color=#0000AA]int[/color] mx, [color=#0000AA]int[/color] my, [color=#AA0000]char[/color] w, [color=#AA0000]char[/color] h);[/b]
+
! [color=#00AA00]void[/color] load_map([color=#AA0000]char[/color] sx, [color=#AA0000]char[/color] sy, [color=#0000AA]int[/color] mx, [color=#0000AA]int[/color] my, [color=#AA0000]char[/color] w, [color=#AA0000]char[/color] h);
 
|-
 
|-
 
|
 
|
Line 101: Line 121:
 
     that would corrupt the video memory.
 
     that would corrupt the video memory.
 
|}
 
|}
 +
 +
 
== scroll ==
 
== scroll ==
 
{|
 
{|
 
|-
 
|-
| [b][color=#00AA00]void[/color] scroll([color=#AA0000]char[/color] num, [color=#0000AA]int[/color] x, [color=#0000AA]int[/color] y, [color=#AA0000]char[/color] top, [color=#AA0000]char[/color] bottom, [color=#AA0000]char[/color] disp);[/b]
+
! [color=#00AA00]void[/color] scroll([color=#AA0000]char[/color] num, [color=#0000AA]int[/color] x, [color=#0000AA]int[/color] y, [color=#AA0000]char[/color] top, [color=#AA0000]char[/color] bottom, [color=#AA0000]char[/color] disp);
 
|-
 
|-
 
|
 
|
Line 118: Line 140:
 
     the window.
 
     the window.
 
|}
 
|}
 +
 +
 
== scroll_disable ==
 
== scroll_disable ==
 
{|
 
{|
 
|-
 
|-
| [b][color=#00AA00]void[/color] scroll_disable([color=#AA0000]char[/color] num);[/b][float=right][tt][ 1.5+ ][/tt][/float]<br />
+
! [color=#00AA00]void[/color] scroll_disable([color=#AA0000]char[/color] num); [b][ 1.5+ ][/b]
 
|-
 
|-
 
|
 
|
 
     Disable scrolling for the screen window 'num'.
 
     Disable scrolling for the screen window 'num'.
 
|}
 
|}

Latest revision as of 01:38, 8 May 2020

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'.