view.c
Screen shake, the copied BG row drawer and the ground plane scanlines.
games/tbs/src/field/field/view.c on GitHub
Screen shake, the copied BG row drawer and the ground plane scanlines. Part of field.c, the field object, compiled only through it.
Functions
Map_SetScreenShake
void Map_SetScreenShake(s32 shakeX, s32 shakeY, s32 shakeDecay)
Changes the shake without restarting an axis whose argument is negative. Amplitudes are 16.16 pixels and decay is a 16.16 multiplier per frame. Scene commands reach it through Map_SetShake and Map_SetScreenShakeFar.
Map_WaitForShakeToSettle
void Map_WaitForShakeToSettle(void)
Waits until both shake amplitudes are below 1/256 pixel, with a 300-frame limit for a shake whose decay never settles. Scene imports reach it as Map_WaitForShakeToSettleFar; it stops further shake after the wait.
Used by GomaCaveWaterway_LeapStump, GondowanCave_RunSpinningLeap.
TileMap_DrawRowsFromRam
void TileMap_DrawRowsFromRam(const struct MapAffinePair *lines, u8 *pixels)
Draws the current affine page into the world map's still-view pixels. WorldMap_BeginStillView supplies 160 pairs and a 240 by 160 byte output. The ARM kernel borrows HEAP_SLOT_TEMP_RENDERER for this synchronous call; it is released before returning, while both graphics buffers stay owned by the world map.
WorldMap_BuildScanlineTable
void WorldMap_BuildScanlineTable(s32 pitchSlope, s32 *position, struct MapScanline *scanline)
Rebuilds the ground plane's scanline terms when the world map pitch changes. Map_InitializePerspectiveScene and WorldMap_UpdateView supply the pitch's sine/cosine ratio and the followed position, both in 16.16. Each screen line gets a width scale and signed ground distance, or zeros above the horizon; Transform_UpdateVertices reads them to build the frame's affine page.
Types
TileMapRowDrawer
typedef void (*TileMapRowDrawer)(const struct MapAffinePair *lines, u8 *pixels, const u8 *tiles, const u8 *map);
The copied ARM kernel reads the BG2 affine row from each 32-byte pair and writes 240 by 160 pixels as 256-colour tiles.
Used by TileMap_DrawRowsFromRam.
Macros, without a comment: MAP_SHAKE_SETTLE_FRAMES, MAP_SHAKE_SETTLE_MAX_AMPLITUDE, TILEMAP_TILE_BANK_BYTES, TILEMAP_MAP_BANK_BYTES.