Main Page   Modules   Data Structures   File List   Globals  

msh_bg.h File Reference

Tile background functions. More...


Data Structures

struct  _bgofs_t
struct  _bgrotdata_t

Defines

#define set_bg_prio(bg, prio)   SET_BG_PRIO(bg, prio)
#define set_bg_tilebase(bg, tilebase)   SET_BG_TILEBASE(bg, tilebase)
#define set_bg_mosaic(bg, mosaic)   SET_BG_MOSAIC(bg, mosaic)
#define set_bg_colmod(bg, colmod)   SET_BG_COLMOD(bg, colmod)
#define set_bg_mapbase(bg, mapbase)   SET_BG_MAPBASE(bg, mapbase)
#define set_bg_overflow(bg, overflow)   SET_BG_OVERFLOW(bg, overflow)
#define set_bg_size(bg, size)   SET_BG_SIZE(bg, size)
#define get_bg_prio(bg)   GET_BG_PRIO(bg)
#define get_bg_tilebase(bg)   GET_BG_TILEBASE(bg)
#define get_bg_mosaic(bg)   GET_BG_MOSAIC(bg)
#define get_bg_colmod(bg)   GET_BG_COLMOD(bg)
#define get_bg_mapbase(bg)   GET_BG_MAPBASE(bg)
#define get_bg_overflow(bg)   GET_BG_OVERFLOW(bg)
#define get_bg_size(bg)   GET_BG_SIZE(bg)
#define set_bg_rotdata_pa(bg, pa)   SET_BG_ROTDATA_PA(bg, pa)
#define set_bg_rotdata_pb(bg, pb)   SET_BG_ROTDATA_PB(bg, pb)
#define set_bg_rotdata_pc(bg, pc)   SET_BG_ROTDATA_PC(bg, pc)
#define set_bg_rotdata_pd(bg, pd)   SET_BG_ROTDATA_PD(bg, pd)
#define set_bg_rotdata_x(bg, x)   SET_BG_ROTDATA_X(bg, x)
#define set_bg_rotdata_y(bg, y)   SET_BG_ROTDATA_Y(bg, y)
#define set_bg_hofs(bg, hofs)   SET_BG_HOFS_BUF(bg, hofs)
#define set_bg_vofs(bg, vofs)   SET_BG_VOFS_BUF(bg, vofs)
#define get_bg_hofs(bg)   GET_BG_HOFS_BUF(bg)
#define get_bg_vofs(bg)   GET_BG_VOFS_BUF(bg)
#define load_bgtiles(data, index, length, channel)   LOAD_BGTILES(data, index, length, channel)
#define set_map_tile(mapdata, mapwidth, x, y, tile)   SET_MAP_TILE(mapdata, mapwidth, x, y, tile)
#define get_map_tile(mapdata, mapwidth, x, y)   GET_MAP_TILE(mapdata, mapwidth, x, y)
#define set_rotmap_tile(mapdata, mapwidth, x, y, tile)   SET_ROTMAP_TILE(mapdata, mapwidth, x, y, tile)
#define get_rotmap_tile(mapdata, mapwidth, x, y)   GET_ROTMAP_TILE(mapdata, mapwidth, x, y)
#define set_bg(bg, size, colmod, tilebase, mapbase)   SET_BG(bg, size, colmod, tilebase, mapbase)

Functions

void copy_bgmap (void *dst, u16 dw, u16 dx, u16 dy, void *src, u16 sw, u16 sx, u16 sy, u16 sx_num, u16 sy_num, bool maptype, u8 channel)
void load_bgmap (void *data, u8 mapbase, u16 dw, u16 dx, u16 dy, u16 sx_num, u16 sy_num, bool maptype, u8 channel)


Detailed Description


Define Documentation

#define SET_ATTR_BG_PRIO bgcnt,
prio   
 

Value:

{(bgcnt) &= _BG_PRIO_MASK; \
    (bgcnt) |= (prio);}

#define SET_ATTR_BG_TILEBASE bgcnt,
tilebase   
 

Value:

{(bgcnt) &= _BG_TILEBASE_MASK; \
    (bgcnt) |= (tilebase) << _BG_TILEBASE_POS;}

#define SET_ATTR_BG_MOSAIC bgcnt,
mosaic   
 

Value:

{(bgcnt) &= _BG_MOSAIC_MASK; \
    (bgcnt) |= (mosaic) << _BG_MOSAIC_POS;}

#define SET_ATTR_BG_COLMOD bgcnt,
colmod   
 

Value:

{(bgcnt) &= _BG_COLMOD_MASK; \
    (bgcnt) |= (colmod) << _BG_COLMOD_POS;}

#define SET_ATTR_BG_MAPBASE bgcnt,
mapbase   
 

Value:

{(bgcnt) &= _BG_MAPBASE_MASK; \
    (bgcnt) |= (mapbase) << _BG_MAPBASE_POS;}

#define SET_ATTR_BG_OVERFLOW bgcnt,
overflow   
 

Value:

{(bgcnt) &= _BG_OVERFLOW_MASK; \
    (bgcnt) |= (overflow) << _BG_OVERFLOW_POS;}

#define SET_ATTR_BG_SIZE bgcnt,
size   
 

Value:

{(bgcnt) &= _BG_SIZE_MASK; \
    (bgcnt) |= (size) << _BG_SIZE_POS;}

#define SET_BG_HOFS_BUF bg,
hscroll   
 

Value:

{_bgofs_buf[bg].hofs = (hscroll) & 0x01FF; \
    SET_BG_HOFS(bg, hscroll);}

#define SET_BG_VOFS_BUF bg,
vscroll   
 

Value:

{_bgofs_buf[bg].vofs = (vscroll) & 0x01FF; \
    SET_BG_VOFS(bg, vscroll);}

#define SET_BG bg,
size,
colmod,
tilebase,
mapbase   
 

Value:

{SET_BG_SIZE(bg, size); \
    SET_BG_COLMOD(bg, colmod); \
    SET_BG_TILEBASE(bg, tilebase); \
    SET_BG_MAPBASE(bg, mapbase);}

#define set_bg_prio bg,
prio       SET_BG_PRIO(bg, prio)
 

Parameters:
bg  u8 [0..3] Background
prio  u8 [0..3] Priority
Priority 0 puts the background in front, priority 3 puts it to the back. If a sprite has the same priority as a background, it will be displayed on top of the background.

#define set_bg_tilebase bg,
tilebase       SET_BG_TILEBASE(bg, tilebase)
 

Parameters:
bg  u8 [0..3] Background
tilebase  u8 [0..3] Tilebase
Sets the starting location of tiledata for the background.

#define set_bg_mosaic bg,
mosaic       SET_BG_MOSAIC(bg, mosaic)
 

Parameters:
bg  u8 [0..3] Background
mosaic  bool [TRUE or FALSE] Enable/Disable Mosaic

#define set_bg_colmod bg,
colmod       SET_BG_COLMOD(bg, colmod)
 

Parameters:
bg  u8 [0..3] Background
colmod  bool [BG_COLMOD] Color Mode
BG Color Mode defines:
 */
#define BG_COLMOD_16
#define BG_COLMOD_256

#define set_bg_mapbase bg,
mapbase       SET_BG_MAPBASE(bg, mapbase)
 

Parameters:
bg  u8 [0..3] Background
mapbase  u8 [0..31] Mapbase
Sets the starting location of mapdata for the background.

#define set_bg_overflow bg,
overflow       SET_BG_OVERFLOW(bg, overflow)
 

Parameters:
bg  u8 [0..3] Background
overflow  bool [TRUE or FALSE] Enable/Disable Overflow

#define set_bg_size bg,
size       SET_BG_SIZE(bg, size)
 

Parameters:
bg  u8 [0..3] Background
size  u8 [BG_SIZE or BG_ROTSIZE] Background Size
BG Map Size defines:
 */
#define BG_SIZE_256x256
#define BG_SIZE_512x256
#define BG_SIZE_256x512
#define BG_SIZE_512x512

BG Rotate Map Size defines:
 */
#define BG_ROTSIZE_128x128
#define BG_ROTSIZE_256x256
#define BG_ROTSIZE_512x512
#define BG_ROTSIZE_1024x1024

#define get_bg_prio bg       GET_BG_PRIO(bg)
 

Parameters:
bg  u8 [0..3] Background
Returns:
u8 [0..3] Priority
Priority 0 puts the background in front, priority 3 puts it to the back. If a sprite has the same priority as a background, it will be displayed on top of the background.

#define get_bg_tilebase bg       GET_BG_TILEBASE(bg)
 

Parameters:
bg  u8 [0..3] Background
Returns:
u8 [0..3] Tilebase
Sets the starting location of tiledata for the background.

#define get_bg_mosaic bg       GET_BG_MOSAIC(bg)
 

Parameters:
bg  u8 [0..3] Background
Returns:
bool [TRUE or FALSE] Enable/Disable Mosaic

#define get_bg_colmod bg       GET_BG_COLMOD(bg)
 

Parameters:
bg  u8 [0..3] Background
Returns:
bool [BG_COLMOD] Color Mode
BG Color Mode defines:
 */
#define BG_COLMOD_16
#define BG_COLMOD_256

#define get_bg_mapbase bg       GET_BG_MAPBASE(bg)
 

Parameters:
bg  u8 [0..3] Background
Returns:
u8 [0..31] Mapbase
Sets the starting location of mapdata for the background.

#define get_bg_overflow bg       GET_BG_OVERFLOW(bg)
 

Parameters:
bg  u8 [0..3] Background
Returns:
bool [TRUE or FALSE] Enable/Disable Overflow

#define get_bg_size bg       GET_BG_SIZE(bg)
 

Parameters:
bg  u8 [0..3] Background
Returns:
u8 [BG_SIZE or BG_ROTSIZE] Background Size
BG Map Size defines:
 */
#define BG_SIZE_256x256
#define BG_SIZE_512x256
#define BG_SIZE_256x512
#define BG_SIZE_512x512

BG Rotate Map Size defines:
 */
#define BG_ROTSIZE_128x128
#define BG_ROTSIZE_256x256
#define BG_ROTSIZE_512x512
#define BG_ROTSIZE_1024x1024

#define set_bg_rotdata_pa bg,
pa       SET_BG_ROTDATA_PA(bg, pa)
 

Parameters:
bg  u8 [2..3] Background
pa  u16 PA

#define set_bg_rotdata_pb bg,
pb       SET_BG_ROTDATA_PB(bg, pb)
 

Parameters:
bg  u8 [2..3] Background
pb  u16 PB

#define set_bg_rotdata_pc bg,
pc       SET_BG_ROTDATA_PC(bg, pc)
 

Parameters:
bg  u8 [2..3] Background
pc  u16 PC

#define set_bg_rotdata_pd bg,
pd       SET_BG_ROTDATA_PD(bg, pd)
 

Parameters:
bg  u8 [2..3] Background
pd  u16 PD

#define set_bg_rotdata_x bg,
     SET_BG_ROTDATA_X(bg, x)
 

Parameters:
bg  u8 [2..3] Background
x  u32 X

#define set_bg_rotdata_y bg,
     SET_BG_ROTDATA_Y(bg, y)
 

Parameters:
bg  u8 [2..3] Background
y  u32 Y

#define set_bg_hofs bg,
hofs       SET_BG_HOFS_BUF(bg, hofs)
 

Parameters:
bg  u8 [0..3] Background
hofs  u16 [0..511] Horizontal Scroll Offset
Sets the horizontal scroll offset of the BG. This determines which horizontal pixel of the BG will be set in the left edge of the screen.

#define set_bg_vofs bg,
vofs       SET_BG_VOFS_BUF(bg, vofs)
 

Parameters:
bg  u8 [0..3] Background
vofs  u16 [0..511] Vertical Scroll Offset
Sets the vertical scroll offset of the BG. This determines which vertical pixel of the BG will be set in the top edge of the screen.

#define get_bg_hofs bg       GET_BG_HOFS_BUF(bg)
 

Parameters:
bg  u8 [0..3] Background
Returns:
u16 [0..511] Horizontal Scroll Offset
Returns the horizontal scroll offset of the BG.

#define get_bg_vofs bg       GET_BG_VOFS_BUF(bg)
 

Parameters:
bg  u8 [0..3] Background
Returns:
u16 [0..511] Vertical Scroll Offset
Returns the vertical scroll offset of the BG.

#define load_bgtiles data,
index,
length,
channel       LOAD_BGTILES(data, index, length, channel)
 

Parameters:
data  void* Pointer to tile data
index  u16 [0..2047] Start tile
length  u16 [0..2048] Number of tiles
channel  u8 [CPY] Copy type
Tiles are 32 bytes each. For 256 color tiles (64 bytes), you need to enter double the number of tiles as the length. And 256 color tiles must have an even starting index.

dmemcpy() type defines:
These are Mushroom specific, not GBA values.
 */
#define CPY_DMA0
#define CPY_DMA1
#define CPY_DMA2
#define CPY_DMA3
#define CPY_MEMCPY

#define set_map_tile mapdata,
mapwidth,
x,
y,
tile       SET_MAP_TILE(mapdata, mapwidth, x, y, tile)
 

Parameters:
mapdata  void* Pointer to Map
mapwidth  u16 Map Width (in tiles)
x  u16 X Tile Offset
y  u16 Y Tile Offset
tile  u16 Tile
Lets you set any tile on any map. Use BG_MAPBASE() macro to write to BG MEM. Use BG_TILE() macro to set specific options on a tile. If you are using a rotational map then use set_rotmap_tile() instead of this function.

Example:
This will locate tile position (10, 12) on mapbase 31 of BG MEM.
Then it will set that tile to tile number 21 with palette 2, and no VFlip or HFlip.

  set_map_tile(BG_MAPBASE(31), 32, 10, 12, BG_TILE(21, 2, FALSE, FALSE));

#define get_map_tile mapdata,
mapwidth,
x,
     GET_MAP_TILE(mapdata, mapwidth, x, y)
 

Parameters:
mapdata  void* Pointer to Map
mapwidth  u16 Map Width (in tiles)
x  u16 X Tile Offset
y  u16 Y Tile Offset
Returns:
u16 Tile
Returns the tile at (x, y) from the specified map. If you are using a rotational map then use get_rotmap_tile().

#define set_rotmap_tile mapdata,
mapwidth,
x,
y,
tile       SET_ROTMAP_TILE(mapdata, mapwidth, x, y, tile)
 

Parameters:
mapdata  void* Pointer to Map
mapwidth  u16 Map Width (in tiles)
x  u16 X Tile Offset
y  u16 Y Tile Offset
tile  u8 Tile
Lets you set any tile on any rotational map.

#define get_rotmap_tile mapdata,
mapwidth,
x,
     GET_ROTMAP_TILE(mapdata, mapwidth, x, y)
 

Parameters:
mapdata  void* Pointer to Map
mapwidth  u16 Map Width (in tiles)
x  u16 X Tile Offset
y  u16 Y Tile Offset
Returns:
u8 Tile
Returns the tile at (x, y) from the specified rotational map.

#define set_bg bg,
size,
colmod,
tilebase,
mapbase       SET_BG(bg, size, colmod, tilebase, mapbase)
 

Parameters:
bg  u8 [0..3] Background
size  u8 [BG_SIZE or BG_ROTSIZE] Background Size
colmod  bool [BG_COLMOD] Color Mode
tilebase  u8 [0..3] Tilebase
mapbase  u8 [0..31] Mapbase
Sets a bunch of BG properties at once

BG Map Size defines:
 */
#define BG_SIZE_256x256
#define BG_SIZE_512x256
#define BG_SIZE_256x512
#define BG_SIZE_512x512

BG Rotate Map Size defines:
 */
#define BG_ROTSIZE_128x128
#define BG_ROTSIZE_256x256
#define BG_ROTSIZE_512x512
#define BG_ROTSIZE_1024x1024

BG Color Mode defines:
 */
#define BG_COLMOD_16
#define BG_COLMOD_256


Function Documentation

void copy_bgmap void *    dst,
u16    dw,
u16    dx,
u16    dy,
void *    src,
u16    sw,
u16    sx,
u16    sy,
u16    sx_num,
u16    sy_num,
bool    maptype,
u8    channel
 

Parameters:
dst  Destination Map
dw  Destination Map Width
dx  Destination X Offset
dy  Destination Y Offset
src  Source Map Data
sw  Source Map Width
sx  Source X Offset
sy  Source Y Offset
sx_num  Number of horizontal tiles to copy per row
sy_num  Number of rows to copy
maptype  [BG_MAPTYPE]
channel  [CPY] Copy type
BG Map Type defines:
These are Mushroom specific, not GBA values.
 */
#define BG_MAPTYPE_NORMAL
#define BG_MAPTYPE_ROTSCALE

dmemcpy() type defines:
These are Mushroom specific, not GBA values.
 */
#define CPY_DMA0
#define CPY_DMA1
#define CPY_DMA2
#define CPY_DMA3
#define CPY_MEMCPY

void load_bgmap void *    data,
u8    mapbase,
u16    dw,
u16    dx,
u16    dy,
u16    sx_num,
u16    sy_num,
bool    maptype,
u8    channel
 

Parameters:
data  Pointer to Map Data
mapbase  [0..31] Mapbase
dw  Destination Map Width
dx  Destination X Offset
dy  Destination Y Offset
sx_num  Width of source map
sy_num  Height of source map
maptype  [BG_MAPTYPE] Map Type
channel  [CPY] Copy type
Load mapdata onto a BG map.

BG Map Type defines:
These are Mushroom specific, not GBA values.
 */
#define BG_MAPTYPE_NORMAL
#define BG_MAPTYPE_ROTSCALE

dmemcpy() type defines:
These are Mushroom specific, not GBA values.
 */
#define CPY_DMA0
#define CPY_DMA1
#define CPY_DMA2
#define CPY_DMA3
#define CPY_MEMCPY


Generated on Wed May 19 21:45:08 2004 for Mushroom GBALib by doxygen 1.2.18