Alchemy

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.

FieldDeclared as
metatileAndFlagsu16 metatileAndFlagsbits: 15..12 flags (15..14 read by Map_GetCellHighFlags) | 11..0 metatile
collisionCodeu8 collisionCodeThe step code: 1 to 239 scene events, 240 and 241 encounter ground, 250 hazard, 252 to 254 for Field_RunPushTileEvent, 0xff a wall.
attributeBu8 attributeBIndexes 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.

Line 13

MapLayer

struct MapLayer

A map layer's scroll record, seen from its cells.

FieldDeclared as
cellsstruct MapCell *cellsthe layer's first cell (MapLayerScroll's cells)
unk04u8 unk04[0x2c]the next layer's scroll values; not named by TBS code

Line 25

BlendScriptState

struct BlendScriptState

The map's running blend script, which sets the blend registers over time.

FieldDeclared as
scriptu16 *script
cursoru16 *cursor
delayu16 delayframes
pausedu16 paused

Used by DisplayBlend_RunScript, DisplayBlend_StartScript.

Line 31

MapAnimation

struct MapAnimation

One of the 16 tile animation channels, which copy tiles into VRAM by script.

FieldDeclared as
startconst u16 *start
cursorconst u16 *cursor
timeru16 timerframes
pausedu16 paused

Used by MapAnimation_StartChannels, Map_ClearLayerEntryFlag, Map_SetLayerEntryFlag, Map_ShowWorldMap.

Line 40

MapState

struct MapState

The map work in heap slot 8 (struct MapScrollWork), seen as its tile animation channels, blend script and layers' cells.

FieldDeclared as
unk000u8 unk000[0x14]MapScrollWork's origin, shake and script
flagsu16 flagsREG_DISPCNT bits; Map_SetShownLayers sets BG1 to BG3
wideTilesu8 wideTilesnonzero: tile animations copy 64-byte tiles
unk17u8 unk17MapScrollWork's footprints; Bilibin Cave sets it
animstruct MapAnimation anim[16]
blendstruct BlendScriptState blend
unke4u8 unke4[0x1f]MapScrollWork's view, bounds and shown layers
blendControlu8 blendControlThe last BLDCNT the blend script wrote; with mode 1 in bits 7..6 its values go to BLDALPHA, else to BLDY.
unk104u8 unk104[0x2c]the first layer's scroll values; not named by TBS code
layersstruct 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.

Line 49

WorldPosition

struct WorldPosition

A position on the world map, as its walkability check reads it.

FieldDeclared as
xs32 x16.16 fixed-point pixels
heights32 height16.16 fixed-point pixels
ys32 y16.16 fixed-point pixels

Used by CheckMapPositionCellOccupied, CheckWorldMapWalkable, Field_ClimbDown, Field_ClimbUp, GetWorldMapCollision, GetWorldMapTerrainBehavior, Object_MoveByKeys, Object_MoveOnWorldMap.

Line 74

Globals, without a comment: gMapBlocks, gMapLayerData, gMapCollision, gBgTileBuffer, gMapAnimationPages.

On this page