sgdk
Loading...
Searching...
No Matches
map.h
Go to the documentation of this file.
1
26#ifndef _MAP_H_
27#define _MAP_H_
28
29
30#include "vdp.h"
31#include "vdp_tile.h"
32#include "pal.h"
33
34
76typedef struct
77{
78 u16 w;
79 u16 h;
80 u16 hp;
81 u16 compression;
82 u16 numMetaTile;
83 u16 numBlock;
84 u16 *metaTiles;
85 void* blocks;
86 void* blockIndexes;
87 u16* blockRowOffsets;
89
90
140typedef struct Map
141{
142 u16 w;
143 u16 h;
144 u16* metaTiles;
145 void* blocks;
146 void* blockIndexes;
147 u16* blockRowOffsets;
148 VDPPlane plane;
149 u16 baseTile;
150 u32 posX;
151 u32 posY;
152 u16 wMask;
153 u16 hMask;
154 u16 planeWidthMask;
155 u16 planeHeightMask;
156 u16 lastXT;
157 u16 lastYT;
158 u16 hScrollTable[240];
159 u16 vScrollTable[20];
160 void (*prepareMapDataColumnCB)(struct Map *map, u16 *bufCol1, u16 *bufCol2, u16 xm, u16 ym, u16 height);
161 void (*prepareMapDataRowCB)(struct Map *map, u16 *bufRow1, u16 *bufRow2, u16 xm, u16 ym, u16 width);
162 u16 (*getMetaTileCB)(struct Map *map, u16 x, u16 y);
163 void (*getMetaTilemapRectCB)(struct Map *map, u16 x, u16 y, u16 w, u16 h, u16* dest);
165
166
187Map* MAP_create(const MapDefinition* mapDef, VDPPlane plane, u16 baseTile);
188
196void MAP_release(Map* map);
197
216void MAP_scrollTo(Map* map, u32 x, u32 y);
232void MAP_scrollToEx(Map* map, u32 x, u32 y, bool forceRedraw);
233
257u16 MAP_getMetaTile(Map* map, u16 x, u16 y);
281u16 MAP_getTile(Map* map, u16 x, u16 y);
310void MAP_getMetaTilemapRect(Map* map, u16 x, u16 y, u16 w, u16 h, u16* dest);
342void MAP_getTilemapRect(Map* map, u16 x, u16 y, u16 w, u16 h, bool column, u16* dest);
343
344
345#endif // _MAP_H_
void MAP_scrollToEx(Map *map, u32 x, u32 y, bool forceRedraw)
Exactly as MAP_scrollTo(..) except we can force complete map drawing.
Definition map.c:200
void MAP_release(Map *map)
Release the map and its resources (same as MEM_free(map))
Definition map.c:194
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....
Definition map.c:57
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 pixe...
Definition map.c:1529
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 ...
Definition map.c:277
u16 MAP_getTile(Map *map, u16 x, u16 y)
Returns given tile attribute (note than map->baseTile isn't added to the result)
Definition map.c:1522
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,...
Definition map.c:1534
u16 MAP_getMetaTile(Map *map, u16 x, u16 y)
Returns given metatile attribute (a metatile is a block of 2x2 tiles = 16x16 pixels)
Definition map.c:1517
Palette support (herited from vdp_pal.h unit)
MapDefinition structure which contains data for large level background. It's optimized to encode lar...
Definition map.h:77
Map structure containing information for large background/plane update based on MapDefinition.
Definition map.h:141
unsigned long u32
Definition types.h:105
unsigned short u16
Definition types.h:100
VDP main.
VDPPlane
Type used to define on which plane to work (used by some methods).
Definition vdp.h:519
VDP General Tile / Tilemap operations.