src/field/field_map_grid.c
Layered maps: decoding their tilemaps and palette, loading, drawing and scrolling, copying metatiles, and the edits flags apply. More…
Included by field.c.
Macros
| Name | Description | |
|---|---|---|
#define | MAPGRID_METATILE_TILES_ID_MASK 0x00000fff | The metatile tiles number. |
#define | MAPGRID_ATTRIBUTE_MASK 0xfffff000 | The metatile's attributes. |
#define | MAPGRID_DRAWN_PICTURE_MASK 0x7ff | The metatile tiles number the renderer draws, the low 11 bits: the copies that use MAPGRID_METATILE_TILES_ID_MASK carry the bit above it as well. |
#define | MAPGRID_DRAWN_PICTURE_SHIFT 21 | The shift that leaves a metatile word's drawn picture number on top, the bits above it shifted out. |
#define | MAPGRID_METATILES ((Uint32 *)RamMapGridMetatileBuffer) | The map's 128 by 128 metatile words. |
#define | MAPGRID_VISIBLE_WIDTH 16 | A layer's visible area in metatiles: the screen's 15 by 10, and the row and column partly scrolled in. |
#define | MAPGRID_VISIBLE_HEIGHT 12 | |
#define | MAPGRID_SCREEN_METATILES 16 | A layer's BG map in metatiles, 16 by 16 (32 by 32 tiles), and the bytes of one row of its tiles. |
#define | MAPGRID_SCREEN_ROW_BYTES 64 | |
#define | MAPGRID_SCREEN_TILE_MASK (BG_SCREEN_WIDTH - 2) | A metatile's top tile row or left tile column in a layer's BG map, even, wrapping at the map's 32; its row as tile entries from the map's start. |
#define | MAPGRID_SCREEN_ROW_MASK (MAPGRID_SCREEN_TILE_MASK * BG_SCREEN_WIDTH) | |
#define | MAPGRID_SCREEN_MAPS BG_SCREEN_BLOCK(5) | The three layers' BG maps, one after another MAPGRID_LAYER_SCREEN_BYTES apart from screen block 5. |
#define | MAPGRID_TILE (coordinate) ((Uint32)(coordinate) >> 19) | The 8-pixel tile a 16.16 layer coordinate lies in, as FIELD_METATILE the 16-pixel metatile, and a map's width and height in those tiles. |
#define | MAPGRID_TILES (MAPGRID_SIZE * MAPGRID_METATILE_PIXELS / 8) | |
#define | MAP_PALETTE_BYTES (14 * 16 * sizeof(Uint16)) | A map's palette: the first 14 of the 16 BG palettes, 224 colours. |
#define | MAPGRID_SHAPE_TABLE_BYTES 8192 | The metatile shapes' buffer, four bytes a shape, cleared to -1 before a map's shapes are decoded into it; the map's script is decoded after it. |
#define | WORLD_MAP_TILE_METATILES 16 | A world map tile's 16 by 16 blocks, as fdWorldMapWriteLayerMetatileTile decodes one. |
#define | WORLD_MAP_LOWER_TILE_MAP BG_SCREEN_BLOCK(8) | The world map's two tile maps, of 64 by 64 one-byte tiles: BG3's, the lower layer, and BG2's, the upper, right after it (fdWorldMapEndStillImage). |
#define | WORLD_MAP_UPPER_TILE_MAP BG_SCREEN_BLOCK(10) | |
#define | WORLD_MAP_TILE_MAP_WIDTH 64 | |
#define | WORLD_MAP_VIEW_LAYER_BYTES | The world map metatiles in view (RamMapBlocks): WORLD_MAP_VIEW_METATILES square for the lower layer, then as many for the upper, each metatile 2 by 2 tiles of its tile map. |
#define | MAPGRID_BYTE_PLANES_BYTES (2 * MAPGRID_SIZE * MAPGRID_SIZE) | A map's metatiles as they are decoded: two planes of a byte a metatile, the metatiles' attribute bytes, then a plane of their metatile tiles numbers, a halfword a metatile. |
#define | MAPGRID_RESOURCE (offset) | A layout's resource, counted in MapsWork from the empty map. |
#define | MAP_EDIT_FLAG_MASK 0xfff | A map edit's flag word: the flag in its low 12 bits, and a bit that makes it copy the metatiles' attributes rather than their pictures. |
#define | MAP_EDIT_ATTRIBUTES 0x1000 | |
#define | MAP_EDITS_END 0xffff | The flag word of all ones that ends a map's edits, the one that one more wraps to 0. |
#define | MAP_EDIT_RECT_BYTES 6 | The bytes after an edit's flag word: source x and y, destination x and y, width and height. |
Functions
| Name | Description | |
|---|---|---|
void | fdSpriteColorRemapPixels (Uint8 *bytes, Sint32 byteCount) | Remaps byteCount bytes in place through SpriteColorGreyTable. |
void | fdTileMapDecodeStagedBuffer (Sint32 size) | Unpacks a map's metatile tiles, decoded into the map metatile buffer from its second byte, into MetatileTiles. |
void | fdTileMapConvertBuffer (void) | Joins a decoded map's planes in place into its metatile words, with the ARM function copied to RAM, which reads the byte planes from a copy. |
void | fdMapCopyPalette (Sint32 map, void *dest) | Decodes the palette resource of a map's header row (its second halfword) and copies its 224 colors to destination, keeping the current backdrop color in the first entry. |
Sint32 | fdMapGridLoadMap (Sint32 index) | Loads layout index from MapsWork: its metatile tiles, collision (cleared to -1 first), metatiles, shapes, tileset animations, blend script and script; sets up the three background layers' origins, parallax and wrap from the layout header; loads the palette and tile graphics unless FLAG_KEEP_LAYER_GRAPHICS says they are loaded; and starts the layer scrolling (fdMapGridUpdateLayerScroll). |
void | fdMapGridCenterOnFollowedPoint (void) | Centres the camera on the point the map follows (origin: x, height, z), or on (0, 0) when there is none, and scrolls the layers there. |
void | fdMapGridRenderMetatileTilesRow (Uint32 layer, Sint32 tileX, Sint32 tileY) | Draws the metatile tiles of a row of 16 of a layer's metatiles (32 tiles) into its BG map (screen block 5 + layer), starting at tile (tileX, tileY); the BG map wraps every 32 tiles and the metatiles wrap at the layer's window, which The Broken Seal's function does not have. |
static __inline__ void | fdMapGridCopyMetatileTilesHalfColumn (Uint32 *metatile, Uint8 *screenMap, Uint32 screenRowOffset, Uint32 screenColumnOffset, Uint32 tileHalf) | Copies one column (tileHalf 0 or 1) of a metatile's 2 by 2 picture tiles into the screen map at the row and column offsets. |
void | fdMapGridRenderMetatileTilesColumn (Uint32 layer, Sint32 tileX, Sint32 tileY) | Draws the metatile tiles of a column of 11 of a layer's metatiles, one tile wide, into its BG map from tile (tileX, tileY), as The Broken Seal's function of the same name; tileX's low bit picks the metatile tiles' left or right half. |
void | fdMapGridUpdateLayerScroll (void) | Each tick on a layered map: centres the view on the point the map follows (origin), clamped to the map's bounds and shaken by any decaying screen shake; then scrolls each of the three layers by its parallax scale and automatic scroll (wrapping at its period), draws the metatile tiles column or row that scrolls into view, and sets its BG scroll. |
static __inline__ void | fdMapGridCopyMetatileTilesToScreen (Uint32 *metatile, Uint8 *screenMap, Uint32 screenRowOffset, Uint32 screenColumnOffset) | Copies a metatile's 2 by 2 picture tiles into the screen map at the row and column offsets. |
void | fdMapGridSetCameraCenter (FIXED x, FIXED y) | Centres the view on (x, y) in 16.16 pixels, clamped to the map's bounds, and redraws every enabled layer's BG map around it. |
void | fdMapGridCopyMetatileTilesIndicesRect (Sint32 srcX, Sint32 srcY, Uint32 destX, Uint32 destY, Uint32 width, Uint32 height) | Copies the metatile tiles numbers of a rectangle of metatiles from (srcX, srcY) to (destX, destY), width by height metatiles, keeping each destination's attributes, and redraws the copied metatiles that are on screen. |
void | fdMapGridPlayMapEdit (const Uint16 *steps, Sint32 destX, Uint32 destY) | Plays a map edit, a list of MAP_EDIT_STEP ended by MAP_EDIT_STEPS_END: copies each step's rectangle of metatile tiles numbers to (destX, destY) and waits its delay in ticks. |
void | fdMapCopyMetatilesRect (Sint32 srcX, Sint32 srcY, Sint32 width, Sint32 height, Sint32 destX, Sint32 destY) | Copies a rectangle of width by height metatiles from (srcX, srcY) to (destX, destY), their pictures and their attributes both. |
void | fdMapCopyMetatileAttributeRect (Sint32 srcX, Sint32 srcY, Sint32 width, Sint32 height, Sint32 destX, Sint32 destY) | Copies the attributes and shapes of a rectangle of metatiles from (srcX, srcY) to (destX, destY), width by height metatiles, keeping each destination's picture. |
void | fdMapGridCopyDrawnPicturesRect (Sint32 srcX, Sint32 srcY, Sint32 width, Sint32 height, Sint32 destX, Sint32 destY) | Copies the drawn metatile tiles numbers (MAPGRID_DRAWN_PICTURE_MASK) of a rectangle of metatiles from (srcX, srcY) to (destX, destY), width by height metatiles, keeping each destination's bits above them, and redraws the copied metatiles that are on screen. |
void | fdMapCopyRawMetatilesRect (Sint32 srcX, Sint32 srcY, Sint32 width, Sint32 height, Sint32 destX, Sint32 destY) | Copies a rectangle of map metatiles as they are, with their shape grid bytes, from (srcX, srcY) to (destX, destY), width by height metatiles. |
void | fdMapGridSetShownLayers (Uint32 layerFlags) | Sets which of BG1-BG3 the map shows (bits 9-11 of its display flags, as in REG_DISPCNT) from layerFlags, keeping its other flags. |
void | fdMapApplySetFlagEdits (void) | Plays every edit of the map whose flag is set, as fdMapApplyFlagEdits does, MAP_EDIT_ATTRIBUTES in an edit's flag word choosing attributes over pictures: the map as the story has left it, as the player enters. |
Uint32 | fdMapReadEditU16 (Uint8 **cursor) | Reads the little-endian halfword at *cursor, which may be unaligned, and moves the cursor past it. |
void | fdMapSetFlagAndApplyEdits (Sint32 flag) | Sets flag (its low 12 bits) and plays its map edits on the metatiles' pictures. |
void | fdMapSetFlagAndApplyAttributeEdits (Sint32 flag) | Sets flag (its low 12 bits) and plays its map edits on the metatiles' attributes. |
void | fdMapApplyFlagEdits (Sint32 flag, Sint32 attributes) | Plays the map's edits for flag: each copies a rectangle of metatiles (their pictures, or with attributes their attributes and shapes) from one place of the map to another. |
void | fdMapGetCameraBounds (Sint32 map, Sint32 *bounds) | Reads map's camera bounds from its header, in 8-pixel tiles: bounds[0] its left, bounds[1] its right, bounds[2] its top and bounds[3] its bottom, a right or bottom of 0 standing for the map's whole MAPGRID_TILES. |
void | fdMapLoadMetatilesAndShapes (void) | Decodes the current map's metatiles into the map metatile buffer and converts them, then decodes its metatile shapes into MapShapeGrid. |
Sint32 | fdWorldMapWriteLayerMetatileTile ( Sint32 layer, Sint32 x, Sint32 y, Sint32 tile, Sint32 update) | Loads world map tile tile into quarter (x & 1, y & 1) of a layer's metatiles in view, decompressing it from the area's graphics, and with update set also draws it into the layer's tile map. |
Description
Layered maps: decoding their tilemaps and palette, loading, drawing and
scrolling, copying metatiles, and the edits flags apply. Part of field.c.
Macros in detail
MAPGRID_METATILE_TILES_ID_MASK
#define MAPGRID_METATILE_TILES_ID_MASK 0x00000fff
The metatile tiles number.
Referenced by fdMapCopyMetatileAttributeRect(), fdMapGridCopyDrawnPicturesRect() and fdMapGridCopyMetatileTilesIndicesRect().
Definition at line 8 of file field_map_grid.c.
MAPGRID_ATTRIBUTE_MASK
#define MAPGRID_ATTRIBUTE_MASK 0xfffff000
The metatile's attributes.
Referenced by fdMapCopyMetatileAttributeRect() and fdMapGridCopyMetatileTilesIndicesRect().
Definition at line 10 of file field_map_grid.c.
MAPGRID_DRAWN_PICTURE_MASK
#define MAPGRID_DRAWN_PICTURE_MASK 0x7ff
The metatile tiles number the renderer draws, the low 11 bits: the copies
that use MAPGRID_METATILE_TILES_ID_MASK carry the bit above it as well.
Referenced by fdMapGridCopyDrawnPicturesRect().
Definition at line 13 of file field_map_grid.c.
MAPGRID_DRAWN_PICTURE_SHIFT
#define MAPGRID_DRAWN_PICTURE_SHIFT 21
The shift that leaves a metatile word's drawn picture number on top, the bits
above it shifted out. Shifted back down by one less it is the number times 2,
the picture's offset in words in RamMapBlocks (a word for each of its two
rows of 2 tiles); by two less, times 4, its offset in halfwords.
Referenced by fdMapGridCopyMetatileTilesHalfColumn(), fdMapGridCopyMetatileTilesToScreen() and fdMapGridRenderMetatileTilesRow().
Definition at line 18 of file field_map_grid.c.
MAPGRID_METATILES
#define MAPGRID_METATILES ((Uint32 *)RamMapGridMetatileBuffer)
The map's 128 by 128 metatile words.
Definition at line 20 of file field_map_grid.c.
MAPGRID_VISIBLE_WIDTH
#define MAPGRID_VISIBLE_WIDTH 16
A layer's visible area in metatiles: the screen's 15 by 10, and the row and column partly scrolled in.
Referenced by fdMapGridCopyDrawnPicturesRect() and fdMapGridCopyMetatileTilesIndicesRect().
Definition at line 23 of file field_map_grid.c.
MAPGRID_VISIBLE_HEIGHT
#define MAPGRID_VISIBLE_HEIGHT 12
Referenced by fdMapGridCopyDrawnPicturesRect() and fdMapGridCopyMetatileTilesIndicesRect().
Definition at line 24 of file field_map_grid.c.
MAPGRID_SCREEN_METATILES
#define MAPGRID_SCREEN_METATILES 16
A layer's BG map in metatiles, 16 by 16 (32 by 32 tiles), and the bytes of one row of its tiles.
Referenced by fdMapGridCopyDrawnPicturesRect(), fdMapGridCopyMetatileTilesIndicesRect(), fdMapGridRenderMetatileTilesRow() and fdMapGridSetCameraCenter().
Definition at line 27 of file field_map_grid.c.
MAPGRID_SCREEN_ROW_BYTES
#define MAPGRID_SCREEN_ROW_BYTES 64
Referenced by fdMapGridCopyDrawnPicturesRect(), fdMapGridCopyMetatileTilesHalfColumn(), fdMapGridCopyMetatileTilesIndicesRect(), fdMapGridCopyMetatileTilesToScreen() and fdMapGridRenderMetatileTilesRow().
Definition at line 28 of file field_map_grid.c.
MAPGRID_SCREEN_TILE_MASK
#define MAPGRID_SCREEN_TILE_MASK (BG_SCREEN_WIDTH - 2)
A metatile's top tile row or left tile column in a layer's BG map, even, wrapping at the map's 32; its row as tile entries from the map's start.
Referenced by fdMapGridRenderMetatileTilesColumn(), fdMapGridRenderMetatileTilesRow() and fdMapGridSetCameraCenter().
Definition at line 31 of file field_map_grid.c.
MAPGRID_SCREEN_ROW_MASK
#define MAPGRID_SCREEN_ROW_MASK (MAPGRID_SCREEN_TILE_MASK * BG_SCREEN_WIDTH)
Referenced by fdMapGridRenderMetatileTilesColumn() and fdMapGridSetCameraCenter().
Definition at line 32 of file field_map_grid.c.
MAPGRID_SCREEN_MAPS
#define MAPGRID_SCREEN_MAPS BG_SCREEN_BLOCK(5)
The three layers' BG maps, one after another MAPGRID_LAYER_SCREEN_BYTES apart
from screen block 5.
Referenced by fdMapGridCopyDrawnPicturesRect(), fdMapGridCopyMetatileTilesIndicesRect(), fdMapGridRenderMetatileTilesColumn(), fdMapGridRenderMetatileTilesRow() and fdMapGridSetCameraCenter().
Definition at line 35 of file field_map_grid.c.
MAPGRID_TILE
#define MAPGRID_TILE(coordinate) ((Uint32)(coordinate) >> 19)
The 8-pixel tile a 16.16 layer coordinate lies in, as FIELD_METATILE the
16-pixel metatile, and a map's width and height in those tiles.
Referenced by fdMapGridUpdateLayerScroll().
Definition at line 38 of file field_map_grid.c.
MAPGRID_TILES
#define MAPGRID_TILES (MAPGRID_SIZE * MAPGRID_METATILE_PIXELS / 8)
Referenced by fdMapGetCameraBounds().
Definition at line 39 of file field_map_grid.c.
MAP_PALETTE_BYTES
#define MAP_PALETTE_BYTES (14 * 16 * sizeof(Uint16))
A map's palette: the first 14 of the 16 BG palettes, 224 colours.
Referenced by fdMapCopyPalette() and fdMapGridLoadMap().
Definition at line 41 of file field_map_grid.c.
MAPGRID_SHAPE_TABLE_BYTES
#define MAPGRID_SHAPE_TABLE_BYTES 8192
The metatile shapes' buffer, four bytes a shape, cleared to -1 before a map's shapes are decoded into it; the map's script is decoded after it.
Referenced by fdMapGridLoadMap().
Definition at line 44 of file field_map_grid.c.
WORLD_MAP_TILE_METATILES
#define WORLD_MAP_TILE_METATILES 16
A world map tile's 16 by 16 blocks, as fdWorldMapWriteLayerMetatileTile
decodes one.
Referenced by fdWorldMapWriteLayerMetatileTile().
Definition at line 47 of file field_map_grid.c.
WORLD_MAP_LOWER_TILE_MAP
#define WORLD_MAP_LOWER_TILE_MAP BG_SCREEN_BLOCK(8)
The world map's two tile maps, of 64 by 64 one-byte tiles: BG3's, the lower
layer, and BG2's, the upper, right after it (fdWorldMapEndStillImage).
Referenced by fdWorldMapDrawMetatileColumn(), fdWorldMapDrawMetatileRow(), fdWorldMapGetCollision() and fdWorldMapWriteLayerMetatileTile().
Definition at line 51 of file field_map_grid.c.
WORLD_MAP_UPPER_TILE_MAP
#define WORLD_MAP_UPPER_TILE_MAP BG_SCREEN_BLOCK(10)
Referenced by fdWorldMapGetCollision().
Definition at line 52 of file field_map_grid.c.
WORLD_MAP_TILE_MAP_WIDTH
#define WORLD_MAP_TILE_MAP_WIDTH 64
Referenced by fdWorldMapCopyMetatileTiles(), fdWorldMapDrawMetatileColumn(), fdWorldMapDrawMetatileRow(), fdWorldMapGetCollision() and fdWorldMapWriteLayerMetatileTile().
Definition at line 53 of file field_map_grid.c.
WORLD_MAP_VIEW_LAYER_BYTES
#define WORLD_MAP_VIEW_LAYER_BYTES
The world map metatiles in view (RamMapBlocks): WORLD_MAP_VIEW_METATILES
square for the lower layer, then as many for the upper, each metatile 2 by 2
tiles of its tile map.
Referenced by fdWorldMapDrawMetatileRow().
Definition at line 57 of file field_map_grid.c.
MAPGRID_BYTE_PLANES_BYTES
#define MAPGRID_BYTE_PLANES_BYTES (2 * MAPGRID_SIZE * MAPGRID_SIZE)
A map's metatiles as they are decoded: two planes of a byte a metatile, the metatiles' attribute bytes, then a plane of their metatile tiles numbers, a halfword a metatile.
Referenced by fdTileMapConvertBuffer().
Definition at line 128 of file field_map_grid.c.
MAPGRID_RESOURCE
#define MAPGRID_RESOURCE(offset)
A layout's resource, counted in MapsWork from the empty map.
Referenced by fdMapCopyPalette(), fdMapGetCameraBounds(), fdMapGridLoadMap() and fdMapLoadMetatilesAndShapes().
Definition at line 150 of file field_map_grid.c.
MAP_EDIT_FLAG_MASK
#define MAP_EDIT_FLAG_MASK 0xfff
A map edit's flag word: the flag in its low 12 bits, and a bit that makes it copy the metatiles' attributes rather than their pictures.
Referenced by fdMapApplyFlagEdits(), fdMapApplySetFlagEdits(), fdMapSetFlagAndApplyAttributeEdits() and fdMapSetFlagAndApplyEdits().
Definition at line 1081 of file field_map_grid.c.
MAP_EDIT_ATTRIBUTES
#define MAP_EDIT_ATTRIBUTES 0x1000
Referenced by fdMapApplySetFlagEdits().
Definition at line 1082 of file field_map_grid.c.
MAP_EDITS_END
#define MAP_EDITS_END 0xffff
The flag word of all ones that ends a map's edits, the one that one more wraps to 0.
Referenced by fdMapApplyFlagEdits() and fdMapApplySetFlagEdits().
Definition at line 1085 of file field_map_grid.c.
MAP_EDIT_RECT_BYTES
#define MAP_EDIT_RECT_BYTES 6
The bytes after an edit's flag word: source x and y, destination x and y, width and height.
Referenced by fdMapApplyFlagEdits() and fdMapApplySetFlagEdits().
Definition at line 1088 of file field_map_grid.c.
Functions in detail
fdSpriteColorRemapPixels
void fdSpriteColorRemapPixels(Uint8 *bytes, Sint32 byteCount)
Remaps byteCount bytes in place through SpriteColorGreyTable.
References Sint32 and SpriteColorGreyTable.
Definition at line 62 of file field_map_grid.c.
fdTileMapDecodeStagedBuffer
void fdTileMapDecodeStagedBuffer(Sint32 size)
Unpacks a map's metatile tiles, decoded into the map metatile buffer from its
second byte, into MetatileTiles. The buffer's second byte is how they are
packed (METATILE_TILES_PACKING) and the halfwords follow it; size counts from
that byte, and an even size leaves nothing to unpack.
References MapGridMetatileBuffer, MetatileTiles and Sint32.
Referenced by fdMapGridLoadMap().
Definition at line 77 of file field_map_grid.c.
fdTileMapConvertBuffer
void fdTileMapConvertBuffer(void)
Joins a decoded map's planes in place into its metatile words, with the ARM function copied to RAM, which reads the byte planes from a copy.
References fdRenderConvertMapCode, fdRenderConvertMapCodeSize, MapGridMetatileBuffer, syHeapAllocateEWRAM(), syHeapRelease() and syWordsCopy().
Referenced by fdMapGridLoadMap() and fdMapLoadMetatilesAndShapes().
Definition at line 132 of file field_map_grid.c.
fdMapCopyPalette
void fdMapCopyPalette(Sint32 map, void *dest)
Decodes the palette resource of a map's header row (its second halfword) and copies its 224 colors to destination, keeping the current backdrop color in the first entry.
References MapsWork, Sint32, syDecompressTaggedLZ(), syDMAXCopy(), syHeapAllocate() and syHeapRelease().
Referenced by scMarsLighthouseStarRoomUseMarsStar() and scPrepareMap().
Definition at line 156 of file field_map_grid.c.
fdMapGridLoadMap
Sint32 fdMapGridLoadMap(Sint32 index)
Loads layout index from MapsWork: its metatile tiles, collision (cleared to
-1 first), metatiles, shapes, tileset animations, blend script and script;
sets up the three background layers' origins, parallax and wrap from the
layout header; loads the palette and tile graphics unless
FLAG_KEEP_LAYER_GRAPHICS says they are loaded; and starts the layer scrolling
(fdMapGridUpdateLayerScroll). Returns 2, as The Broken Seal's does; no caller
reads it.
References fdBlendScriptStart(), fdMapGridUpdateLayerScroll(), fdTileMapConvertBuffer(), fdTileMapDecodeStagedBuffer(), fdTilesetAnimationStartAll(), MapGridAnimationTiles, MapShapeGrid, MapsWork, Sint32, syDecompressMoveToFrontLZ(), syDecompressTaggedLZ(), syGameFlagClear(), syGameFlagGet(), syHeapAllocate(), syHeapRelease(), syHeapSlotAllocateEWRAM(), syScreenFadeFromBlack() and sySetEvent().
Definition at line 178 of file field_map_grid.c.
fdMapGridCenterOnFollowedPoint
void fdMapGridCenterOnFollowedPoint(void)
Centres the camera on the point the map follows (origin: x, height, z), or on (0, 0) when there is none, and scrolls the layers there. A followed point whose view would overlap one of the map's camera boxes is first moved to the box's nearest edge, so the view starts outside it.
References fdMapGridSetCameraCenter(), fdMapGridUpdateLayerScroll() and Sint32.
Referenced by scAirsRockBlowGust(), scAirsRockInsideBlowGust(), scAirsRockInsideLandInHall(), scAirsRockWhirlwindClearsWall(), scAnkohlRuinsLandFromFall(), scAquaRockInsideDouseFloodedHallEastMoai(), scAquaRockInsideDouseFloodedHallWestMoai(), scAquaRockInsideDouseLowerExitMoai(), scAquaRockInsideDouseWaterfallMoai(), scAquaRockInsideWaterSinks(), scContigoInitVillage(), scCrackedTileDropIn(), scCrackedTilePlaceLanding(), scDehkanPlateauCannonDropsPoundCube(), scDehkanPlateauLandFromFall(), scGabombaStatueChamberAkafubuOffersToHelp(), scGabombaStatueChamberInitLift(), scGabombaStatueChamberRideLiftBackUp(), scGabombaStatueInitEyes(), scGabombaStatueLandFromFall(), scGabombaStatueSawEnergyFlow(), scGaiaRockInsideRaiseDust(), scGarohRoomsWakeAtInn(), scIdejimaBreakAwayFromGondowan(), scIdejimaFelixWakes(), scIdejimaFindFelixAndSheba(), scInit(), scJupiterLighthouseBeaconIsLit(), scJupiterLighthouseRaiseElevator(), scKandoreanTempleLandFromAbove(), scKibomboCeremonyEnds(), scKibomboStatueFlashes(), scLeaderLift(), scLemurianShipDeckHoldOnToTiller(), scLemurianShipDeckTakeTheTiller(), scLemurianShipParchHold(), scLemurianShipSetBlackCrystal(), scLemurianShipSetUpHold(), scLinkLobbyDrawThreeDigitValue(), scMagmaRockDropLeaderFromSummit(), scMagmaRockInsideRaiseLava(), scMarsLighthouseAerieWatchGoldenSunRise(), scMarsLighthouseStarRoomWakeAfterBattle(), scPrepareMap(), scShamanVillageBlowAwaySand(), scShamanVillageRestartTrial(), scShamanVillageSuggestQuitting(), scShrineOfTheSeaGodInitRightProng(), scShrineOfTheSeaGodLowerWater(), scShrineOfTheSeaGodRiseOnWater() and 3 more.
Definition at line 338 of file field_map_grid.c.
fdMapGridRenderMetatileTilesRow
void fdMapGridRenderMetatileTilesRow(Uint32 layer, Sint32 tileX, Sint32 tileY)
Draws the metatile tiles of a row of 16 of a layer's metatiles (32 tiles)
into its BG map (screen block 5 + layer), starting at tile (tileX, tileY);
the BG map wraps every 32 tiles and the metatiles wrap at the layer's window,
which The Broken Seal's function does not have. Called by
fdMapGridUpdateLayerScroll when a layer scrolls onto a new row of metatile
pictures.
References Sint32.
Referenced by fdMapGridUpdateLayerScroll().
Definition at line 398 of file field_map_grid.c.
fdMapGridCopyMetatileTilesHalfColumn
static __inline__ void fdMapGridCopyMetatileTilesHalfColumn(Uint32 *metatile, Uint8 *screenMap, Uint32 screenRowOffset, Uint32 screenColumnOffset, Uint32 tileHalf)
Copies one column (tileHalf 0 or 1) of a metatile's 2 by 2 picture tiles into the screen map at the row and column offsets.
Referenced by fdMapGridRenderMetatileTilesColumn().
Definition at line 458 of file field_map_grid.c.
fdMapGridRenderMetatileTilesColumn
void fdMapGridRenderMetatileTilesColumn(Uint32 layer, Sint32 tileX, Sint32 tileY)
Draws the metatile tiles of a column of 11 of a layer's metatiles, one tile wide, into its BG map from tile (tileX, tileY), as The Broken Seal's function of the same name; tileX's low bit picks the metatile tiles' left or right half.
References fdMapGridCopyMetatileTilesHalfColumn() and Sint32.
Referenced by fdMapGridUpdateLayerScroll().
Definition at line 485 of file field_map_grid.c.
fdMapGridUpdateLayerScroll
void fdMapGridUpdateLayerScroll(void)
Each tick on a layered map: centres the view on the point the map follows (origin), clamped to the map's bounds and shaken by any decaying screen shake; then scrolls each of the three layers by its parallax scale and automatic scroll (wrapping at its period), draws the metatile tiles column or row that scrolls into view, and sets its BG scroll.
References BgScrollWork, fdMapGridRenderMetatileTilesColumn(), fdMapGridRenderMetatileTilesRow(), Sint32 and syRandom().
Referenced by fdMapGridCenterOnFollowedPoint() and fdMapGridLoadMap().
Definition at line 540 of file field_map_grid.c.
fdMapGridCopyMetatileTilesToScreen
static __inline__ void fdMapGridCopyMetatileTilesToScreen(Uint32 *metatile, Uint8 *screenMap, Uint32 screenRowOffset, Uint32 screenColumnOffset)
Copies a metatile's 2 by 2 picture tiles into the screen map at the row and column offsets.
Referenced by fdMapGridSetCameraCenter().
Definition at line 651 of file field_map_grid.c.
fdMapGridSetCameraCenter
void fdMapGridSetCameraCenter(FIXED x, FIXED y)
Centres the view on (x, y) in 16.16 pixels, clamped to the map's bounds, and redraws every enabled layer's BG map around it.
References fdMapGridCopyMetatileTilesToScreen().
Referenced by fdMapGridCenterOnFollowedPoint().
Definition at line 673 of file field_map_grid.c.
fdMapGridCopyMetatileTilesIndicesRect
void fdMapGridCopyMetatileTilesIndicesRect(Sint32 srcX, Sint32 srcY, Uint32 destX, Uint32 destY, Uint32 width, Uint32 height)
Copies the metatile tiles numbers of a rectangle of metatiles from (srcX, srcY) to (destX, destY), width by height metatiles, keeping each destination's attributes, and redraws the copied metatiles that are on screen.
References Sint32.
Referenced by fdMapApplyFlagEdits(), fdMapApplySetFlagEdits(), fdMapCopyMetatilesRect(), fdMapGridCopyMetatilesTo(), fdMapGridPlayMapEdit(), scAirsRockInsideBlowGust(), scAirsRockInsideOpenTabletRoomDoor(), scAirsRockInsideWakeEntranceStatue(), scAirsRockInsideWakeHallStatue(), scCavernsOpenOseniaPassage(), scContigoHideMiddleDoor(), scContigoLockDoors(), scContigoOpenSanctumDoor(), scContigoRevealMiddleDoor(), scDehkanPlateauCannonCracksPillars(), scDehkanPlateauCannonFleesOverCracks(), scDehkanPlateauCannonPoundsLeaderThrough(), scDehkanPlateauCannonPoundsStake(), scDehkanPlateauInitCaves(), scDehkanPlateauInitPillars(), scDehkanPlateauInitTightropes(), scDehkanPlateauPoundLeaderThrough(), scDehkanPlateauRestorePoundCubeCracks(), scDehkanPlateauStepOnCrack(), scGabombaStatueChamberOpenSecondHole(), scGabombaStatueChamberUnrollTongue(), scKandoreanTempleLowerTheLadder(), scKandoreanTempleOpenTheCaveDoor(), scKandoreanTempleOpenTheTempleDoor(), scKandoreanTempleStartChestbeaterRoom(), scKandoreanTempleStartGate(), scKibomboSetStatueTongue(), scKibomboUncoverEastMark(), scKibomboUncoverNorthMark(), scKibomboUncoverSouthMark(), scKibomboUncoverVent(), scKibomboUncoverWestMark(), scPrepareMap(), scSeaOfTimeFacePoseidon(), scTundariaTowerBurstBrownWall(), scTundariaTowerBurstCrystal(), scTundariaTowerBurstMirrorWall(), scTundariaTowerEndRevealHiddenWay(), scTundariaTowerRevealHiddenWay(), scTundariaTowerShrinkIceColumn(), scVenusLighthouseStepOnFloorSwitch(), scYampiDesertHideRockHint(), scYampiDesertOpenGeyser(), scYampiDesertOpenLadderPit(), scYampiDesertOpenScoopHole() and 4 more.
Definition at line 767 of file field_map_grid.c.
fdMapGridPlayMapEdit
void fdMapGridPlayMapEdit(const Uint16 *steps, Sint32 destX, Uint32 destY)
Plays a map edit, a list of MAP_EDIT_STEP ended by MAP_EDIT_STEPS_END: copies
each step's rectangle of metatile tiles numbers to (destX, destY) and waits
its delay in ticks.
References fdMapGridCopyMetatileTilesIndicesRect(), Sint32 and sySynch().
Referenced by fdMapGridAnimateMetatiles(), scAlhafraOpenDoorAndEnter(), scAnemosInnerSanctumAnimateDoor(), scChampaCliffCavesObabaAsksForBriggs() and scChampaCliffCavesOpenDoorAndEnter().
Definition at line 861 of file field_map_grid.c.
fdMapCopyMetatilesRect
void fdMapCopyMetatilesRect(Sint32 srcX, Sint32 srcY, Sint32 width, Sint32 height, Sint32 destX, Sint32 destY)
Copies a rectangle of width by height metatiles from (srcX, srcY) to (destX, destY), their pictures and their attributes both.
References fdMapCopyMetatileAttributeRect(), fdMapGridCopyMetatileTilesIndicesRect() and Sint32.
Referenced by dbShopTestDigMetatiles(), fdMapGridCopyMetatiles(), scAquaRockMoaiStepAside() and scInit().
Definition at line 881 of file field_map_grid.c.
fdMapCopyMetatileAttributeRect
void fdMapCopyMetatileAttributeRect(Sint32 srcX, Sint32 srcY, Sint32 width, Sint32 height, Sint32 destX, Sint32 destY)
Copies the attributes and shapes of a rectangle of metatiles from (srcX, srcY) to (destX, destY), width by height metatiles, keeping each destination's picture.
References MapShapeGrid and Sint32.
Referenced by fdMapApplyFlagEdits(), fdMapApplySetFlagEdits(), fdMapCopyMetatilesRect(), fdMapGridCopyMetatileAttributes(), scAirsRockInsideBlowGust(), scAirsRockInsideSetLedgeMetatilesByLevel(), scAquaRockDouseSummitWaterStone(), scAttekaInletSetUpTheHeights(), scAttekaInletShipwrightsStopTheParty(), scCavernsInitIndra(), scCavernsMoveIndraPillar(), scCavernsPrepareAngara(), scChampaCliffCavesHidePath(), scChampaCliffCavesRevealPath(), scContigoLockDoors(), scDehkanPlateauDropEntrancePillarIntoGap(), scDehkanPlateauPlacePillarsStonePillar(), scDehkanPlateauPlaceTightropesPillar(), scDehkanPlateauPlaceVinePillar(), scGabombaCatacombsHideWall(), scGabombaCatacombsRevealWall(), scGabombaStatueChamberUncoverPassage(), scGaiaRockInsidePlaceDollOnCobwebAltar(), scGaiaRockInsidePlaceDollOnEastAltar(), scGaiaRockInsidePlaceDollOnWestAltar(), scInit(), scIsletCaveRideSecondLogEast(), scIsletCaveRideSecondLogWest(), scIsletCaveRideSeventhLogNorth(), scIsletCaveRideSeventhLogSouth(), scKandoreanTempleFinishMovingPot(), scPrepareMap(), scShrineOfTheSeaGodBreakFirstBridge(), scShrineOfTheSeaGodBreakSecondBridge(), scShrineOfTheSeaGodInitBrokenBridges(), scShrineOfTheSeaGodPushPillarIntoHole(), scTrialRoadShowTraps() and scYampiDesertOpenLadderPit().
Definition at line 896 of file field_map_grid.c.
fdMapGridCopyDrawnPicturesRect
void fdMapGridCopyDrawnPicturesRect(Sint32 srcX, Sint32 srcY, Sint32 width, Sint32 height, Sint32 destX, Sint32 destY)
Copies the drawn metatile tiles numbers (MAPGRID_DRAWN_PICTURE_MASK) of a
rectangle of metatiles from (srcX, srcY) to (destX, destY), width by height
metatiles, keeping each destination's bits above them, and redraws the copied
metatiles that are on screen. The loop of
fdMapGridCopyMetatileTilesIndicesRect with the narrower mask, and the size
before the destination; the game keeps both routines.
References MapGridMetatileBuffer and Sint32.
Referenced by fdMapGridCopyMetatilesLayered(), scAquaRockDouseDryMoai(), scAquaRockDouseSummitWaterStone(), scChampaCliffCavesHidePath(), scChampaCliffCavesRevealPath(), scGabombaCatacombsHideWall(), scGabombaCatacombsRevealWall(), scInit() and scPrepareMap().
Definition at line 938 of file field_map_grid.c.
fdMapCopyRawMetatilesRect
void fdMapCopyRawMetatilesRect(Sint32 srcX, Sint32 srcY, Sint32 width, Sint32 height, Sint32 destX, Sint32 destY)
Copies a rectangle of map metatiles as they are, with their shape grid bytes, from (srcX, srcY) to (destX, destY), width by height metatiles.
References MapShapeGrid and Sint32.
Referenced by scMapGridCopyRawMetatiles() and scPrepareMap().
Definition at line 1032 of file field_map_grid.c.
fdMapGridSetShownLayers
void fdMapGridSetShownLayers(Uint32 layerFlags)
Sets which of BG1-BG3 the map shows (bits 9-11 of its display flags, as in
REG_DISPCNT) from layerFlags, keeping its other flags.
Referenced by scInit().
Definition at line 1066 of file field_map_grid.c.
fdMapApplySetFlagEdits
void fdMapApplySetFlagEdits(void)
Plays every edit of the map whose flag is set, as fdMapApplyFlagEdits does,
MAP_EDIT_ATTRIBUTES in an edit's flag word choosing attributes over pictures:
the map as the story has left it, as the player enters.
References fdMapCopyMetatileAttributeRect(), fdMapGridCopyMetatileTilesIndicesRect(), fdMapReadEditU16(), MapScene, MapSceneEditsOffset, Sint32 and syGameFlagGet().
Definition at line 1093 of file field_map_grid.c.
fdMapReadEditU16
Uint32 fdMapReadEditU16(Uint8 **cursor)
Reads the little-endian halfword at *cursor, which may be unaligned, and moves the cursor past it.
Referenced by fdMapApplyFlagEdits() and fdMapApplySetFlagEdits().
Definition at line 1129 of file field_map_grid.c.
fdMapSetFlagAndApplyEdits
void fdMapSetFlagAndApplyEdits(Sint32 flag)
Sets flag (its low 12 bits) and plays its map edits on the metatiles' pictures.
References fdMapApplyFlagEdits(), Sint32 and syGameFlagSet().
Definition at line 1139 of file field_map_grid.c.
fdMapSetFlagAndApplyAttributeEdits
void fdMapSetFlagAndApplyAttributeEdits(Sint32 flag)
Sets flag (its low 12 bits) and plays its map edits on the metatiles' attributes.
References fdMapApplyFlagEdits(), Sint32 and syGameFlagSet().
Definition at line 1148 of file field_map_grid.c.
fdMapApplyFlagEdits
void fdMapApplyFlagEdits(Sint32 flag, Sint32 attributes)
Plays the map's edits for flag: each copies a rectangle of metatiles (their pictures, or with attributes their attributes and shapes) from one place of the map to another. The map's extra data lists the edits, each a flag then source x and y, destination x and y, width and height in bytes, ended by a flag halfword of all ones.
References fdMapCopyMetatileAttributeRect(), fdMapGridCopyMetatileTilesIndicesRect(), fdMapReadEditU16(), MapScene, MapSceneEditsOffset and Sint32.
Referenced by fdMapSetFlagAndApplyAttributeEdits() and fdMapSetFlagAndApplyEdits().
Definition at line 1160 of file field_map_grid.c.
fdMapGetCameraBounds
void fdMapGetCameraBounds(Sint32 map, Sint32 *bounds)
Reads map's camera bounds from its header, in 8-pixel tiles: bounds[0] its
left, bounds[1] its right, bounds[2] its top and bounds[3] its bottom, a
right or bottom of 0 standing for the map's whole MAPGRID_TILES.
References MapsWork and Sint32.
Definition at line 1197 of file field_map_grid.c.
fdMapLoadMetatilesAndShapes
void fdMapLoadMetatilesAndShapes(void)
Decodes the current map's metatiles into the map metatile buffer and converts
them, then decodes its metatile shapes into MapShapeGrid.
References fdTileMapConvertBuffer(), MainRoutineStateWork, MapShapeGrid, MapsWork and syDecompressTaggedLZ().
Referenced by scAquaRockInsideDouseFloodedHallEastMoai(), scAquaRockInsideDouseFloodedHallWestMoai(), scAquaRockInsideDouseLowerExitMoai() and scAquaRockInsideDouseWaterfallMoai().
Definition at line 1216 of file field_map_grid.c.
fdWorldMapWriteLayerMetatileTile
Sint32 fdWorldMapWriteLayerMetatileTile( Sint32 layer, Sint32 x, Sint32 y, Sint32 tile, Sint32 update)
Loads world map tile tile into quarter (x & 1, y & 1) of a layer's
metatiles in view, decompressing it from the area's graphics, and with update
set also draws it into the layer's tile map. Returns 0, doing nothing, when
the quarter already holds the tile and update is clear; otherwise 1.
References Sint32, syDecompressByteLZ(), syDMAXCopy(), syHeapSlotAllocate() and syHeapSlotRelease().
Referenced by fdWorldMapPreloadCurrentTileBlock(), fdWorldMapSetWindowMetatileTile(), fdWorldMapSetWindowMetatileTileAndDraw() and fdWorldMapUpdateCurrentTileBlock().
Definition at line 1233 of file field_map_grid.c.