map.h
games/tbs/include/map.h on GitHub
Structures
MapCell
struct MapCell
One cell of a map layer: its metatile and flags, its collision code and an attribute indexing the collision table.
| Field | Declared as | |
|---|---|---|
metatileAndFlags | u16 metatileAndFlags | bits: 15..12 flags (15..14 read by Map_GetCellHighFlags) | 11..0 metatile |
collisionCode | u8 collisionCode | The step code: 1 to 239 scene events, 240 and 241 encounter ground, 250 hazard, 252 to 254 for Field_RunPushTileEvent, 0xff a wall. |
attributeB | u8 attributeB | Indexes the 4-byte collision entries (gMapCollision): terrain kind in the first byte's low four bits, then its height samples. |
Used by CheckMapPositionCellOccupied, CrossboneIslePillarRooms_ReadMapCell, CrossboneIslePillarRooms_SetCellAttributes, Field_ProcessStep, Field_RunScene, GetMapCellCollision, KolimaForestBend_CheckLogFits, Map_CheckObjectStep, Map_GetCellAttributeLowNibble, Map_GetCellHighFlags, Map_GetTerrainHeight, Map_LoadLayeredScene, MercuryLighthouse_HopAcrossPool, MercuryLighthouse_RestoreLights, ObjectTable_ResetForObject, Object_MoveByKeys, SetMapCellCollision, StagedActor_FillGridAttributeRectangle.
MapLayer
struct MapLayer
A map layer's scroll record, seen from its cells.
| Field | Declared as | |
|---|---|---|
cells | struct MapCell *cells | the layer's first cell (MapLayerScroll's cells) |
unk04 | u8 unk04[0x2c] | the next layer's scroll values; not named by TBS code |
BlendScriptState
struct BlendScriptState
The map's running blend script, which sets the blend registers over time.
| Field | Declared as | |
|---|---|---|
script | u16 *script | |
cursor | u16 *cursor | |
delay | u16 delay | frames |
paused | u16 paused |
Used by DisplayBlend_RunScript, DisplayBlend_StartScript.
MapAnimation
struct MapAnimation
One of the 16 tile animation channels, which copy tiles into VRAM by script.
| Field | Declared as | |
|---|---|---|
start | const u16 *start | |
cursor | const u16 *cursor | |
timer | u16 timer | frames |
paused | u16 paused |
Used by MapAnimation_StartChannels, Map_ClearLayerEntryFlag, Map_SetLayerEntryFlag, Map_ShowWorldMap.
MapState
struct MapState
The map work in heap slot 8 (struct MapScrollWork), seen as its tile animation channels, blend script and layers' cells.
| Field | Declared as | |
|---|---|---|
unk000 | u8 unk000[0x14] | MapScrollWork's origin, shake and script |
flags | u16 flags | REG_DISPCNT bits; Map_SetShownLayers sets BG1 to BG3 |
wideTiles | u8 wideTiles | nonzero: tile animations copy 64-byte tiles |
unk17 | u8 unk17 | MapScrollWork's footprints; Bilibin Cave sets it |
anim | struct MapAnimation anim[16] | |
blend | struct BlendScriptState blend | |
unke4 | u8 unke4[0x1f] | MapScrollWork's view, bounds and shown layers |
blendControl | u8 blendControl | The last BLDCNT the blend script wrote; with mode 1 in bits 7..6 its values go to BLDALPHA, else to BLDY. |
unk104 | u8 unk104[0x2c] | the first layer's scroll values; not named by TBS code |
layers | struct MapLayer layers[4] | Each layer's cells, at MapScrollWork's layers[i].cells; readers mask the layer with 3, and the fourth entry lies past MapScrollWork's end. |
Used by CheckMapPositionCellOccupied, DisplayBlend_RunScript, DisplayBlend_StartScript, Event_ClearMapTriggerFlag, Event_SetMapTriggerFlag, FieldFx_CheckCloakTile, Field_GetCollisionAheadOfLeader, Field_ProcessStep, GetMapCellCollision, Imil_UpdateMapLayerByLeaderPosition, MapAnimation_StartChannels, MapAnimation_Update, Map_CheckObjectStep, Map_ClearLayerEntryFlag, Map_GetCellAttributeLowNibble, Map_GetTerrainHeight, Map_SetLayerEntryFlag, Map_SetShownLayers, Map_ShowWorldMap, SetMapCellCollision, TolbiSpring_RiseAndFadeIn.
WorldPosition
struct WorldPosition
A position on the world map, as its walkability check reads it.
| Field | Declared as | |
|---|---|---|
x | s32 x | 16.16 fixed-point pixels |
height | s32 height | 16.16 fixed-point pixels |
y | s32 y | 16.16 fixed-point pixels |
Used by CheckMapPositionCellOccupied, CheckWorldMapWalkable, Field_ClimbDown, Field_ClimbUp, GetWorldMapCollision, GetWorldMapTerrainBehavior, Object_MoveByKeys, Object_MoveOnWorldMap.
Globals, without a comment: gMapBlocks, gMapLayerData, gMapCollision, gBgTileBuffer, gMapAnimationPages.