sgdk
|
MAP (large background map) management unit. More...
Go to the source code of this file.
Classes | |
struct | MapDefinition |
MapDefinition structure which contains data for large level background. It's optimized to encode large map using 128x128 block chunk (block chunk are organized in metatile). More... | |
struct | Map |
Map structure containing information for large background/plane update based on MapDefinition. More... | |
Typedefs | |
typedef struct Map | Map |
Map structure containing information for large background/plane update based on MapDefinition. | |
Functions | |
Map * | MAP_create (const MapDefinition *mapDef, VDPPlane plane, u16 baseTile) |
Create and return a Map structure required to use all MAP_xxx functions from a given MapDefinition. When you're done with the map just use MEM_free(map) to release it. | |
void | MAP_scrollTo (Map *map, u32 x, u32 y) |
Scroll map to specified position. The fonction takes care of updating the VDP tilemap which will be transfered by DMA queue then VDP background scrolling is automatically set on VBlank (into the SYS_doVBlankProcess() tasks). WARNING: first MAP_scrollTo(..) call will do a full plane update, for a 64x32 sized plane this represents 4KB of data. That means you can't initialize 2 MAPs in the same frame (limited to 7.2 KB of data per frame) so take care of calling SYS_doVBlankProcess() in between. | |
void | MAP_scrollToEx (Map *map, u32 x, u32 y, bool forceRedraw) |
Exactly as MAP_scrollTo(..) except we can force complete map drawing. | |
u16 | MAP_getMetaTile (Map *map, u16 x, u16 y) |
Returns given metatile attribute (a metatile is a block of 2x2 tiles = 16x16 pixels) | |
u16 | MAP_getTile (Map *map, u16 x, u16 y) |
Returns given tile attribute (note than map->baseTile isn't added to the result) | |
void | MAP_getMetaTilemapRect (Map *map, u16 x, u16 y, u16 w, u16 h, u16 *dest) |
Returns metatiles attribute for the specified region (a metatile is a block of 2x2 tiles = 16x16 pixels) | |
void | MAP_getTilemapRect (Map *map, u16 x, u16 y, u16 w, u16 h, bool column, u16 *dest) |
Returns tiles attribute data for the specified region (map->baseTile is used as base tiles attribute, see MAP_create(..)) |
MAP (large background map) management unit.
This unit provides methods to manipulate / scroll large background MAP:
Map structure containing information for large background/plane update based on MapDefinition.
w | map width in block (128x128 pixels block) |
h | map height in block (128x128 pixels block) |
metaTiles | internal - unpacked data of MapDefinition.metaTiles |
blocks | internal - unpacked data of MapDefinition.blocks |
blockIndexes | internal - unpacked data of MapDefinition.blockIndexes |
blockRowOffsets | internal - direct access of MapDefinition.blockRowOffsets |
plane | VDP plane where MAP is draw |
baseTile | Base tile attributes used to provide base tile index offset and base palette index (see TILE_ATTR_FULL() macro) |
posX | current view position X set using MAP_scrollTo(..) method |
posY | current view position Y set using MAP_scrollTo(..) method |
wMask | internal |
hMask | internal |
planeWidthMask | internal |
planeHeightMask | internal |
lastXT | internal |
lastYT | internal |
prepareMapDataColumnCB | internal |
prepareMapDataRowCB | internal |
hScrollTable | internal |
vScrollTable | internal |
getMetaTileCB | internal |
getMetaTilemapRectCB | internal |
Map* MAP_create | ( | const MapDefinition * | mapDef, |
VDPPlane | plane, | ||
u16 | baseTile | ||
) |
Create and return a Map structure required to use all MAP_xxx functions from a given MapDefinition.
When you're done with the map just use MEM_free(map) to release it.
mapDef | MapDefinition structure containing background/plane data. |
plane | Plane where we want to draw the Map (for MAP_scrollTo(..) method). Accepted values are:
|
baseTile | Used to provide base tile index and base palette index (see TILE_ATTR_FULL() macro). Note that you can also use it to force HIGH priority but in that case your map should only contains LOW priority tiles otherwise the HIGH priority tiles will be set in LOW priority instead (mutually exclusive). |
Returns given metatile attribute (a metatile is a block of 2x2 tiles = 16x16 pixels)
map | source Map structure containing map information. |
x | metatile X position |
y | metatile Y position |
Returns metatiles attribute for the specified region (a metatile is a block of 2x2 tiles = 16x16 pixels)
map | source Map structure containing map information. |
x | Region X start position (in metatile). |
y | Region Y start position (in metatile). |
w | Region Width (in metatile). |
h | Region Heigh (in metatile). |
dest | destination pointer receiving metatiles attribute data |
Returns given tile attribute (note than map->baseTile isn't added to the result)
map | source Map structure containing map information. |
x | tile X position |
y | tile Y position |
Returns tiles attribute data for the specified region (map->baseTile is used as base tiles attribute, see MAP_create(..))
map | source Map structure containing map information. |
x | Region X start position (in metatile) |
y | Region Y start position (in metatile) |
w | Region Width (in metatile) |
h | Region Heigh (in metatile) |
column | if set to TRUE then tilemap data is stored by column order [Y,X] instead of row order [X,Y]. |
dest | destination pointer receiving tiles attribute data |
Scroll map to specified position.
The fonction takes care of updating the VDP tilemap which will be transfered by DMA queue then VDP background scrolling is automatically set on VBlank (into the SYS_doVBlankProcess() tasks).
WARNING: first MAP_scrollTo(..) call will do a full plane update, for a 64x32 sized plane this represents 4KB of data.
That means you can't initialize 2 MAPs in the same frame (limited to 7.2 KB of data per frame) so take care of calling SYS_doVBlankProcess() in between.
map | Map structure containing map information. |
x | view position X we want to scroll on |
y | view position Y we want to scroll on |
Exactly as MAP_scrollTo(..) except we can force complete map drawing.
map | Map structure containing map information. |
x | view position X we want to scroll on |
y | view position Y we want to scroll on |
forceRedraw | Set to TRUE to force a complete map redraw (take more time) |