Alchemy
Loading...
Searching...
No Matches

view.c File Reference

Screen shake, the copied BG row drawer and the ground plane scanlines. More...

Go to the source code of this file.

Macros

#define MAP_SHAKE_SETTLE_FRAMES   300
#define MAP_SHAKE_SETTLE_MAX_AMPLITUDE   (Q16_ONE / 256 - 1)
#define TILEMAP_TILE_BANK_BYTES   (256 * (8 * 8))
#define TILEMAP_MAP_BANK_BYTES   (64 * 64)

Typedefs

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.

Functions

void Map_SetScreenShake (s32 shakeX, s32 shakeY, s32 shakeDecay)
 Changes the shake without restarting an axis whose argument is negative.
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.
void TileMap_DrawRowsFromRam (const struct MapAffinePair *lines, u8 *pixels)
 Draws the current affine page into the world map's still-view pixels.
void WorldMap_BuildScanlineTable (s32 pitchSlope, s32 *position, struct MapScanline *scanline)
 Rebuilds the ground plane's scanline terms when the world map pitch changes.

Detailed Description

Screen shake, the copied BG row drawer and the ground plane scanlines.

Part of field.c, the field object, compiled only through it.

Definition in file view.c.

Macro Definition Documentation

◆ MAP_SHAKE_SETTLE_FRAMES

#define MAP_SHAKE_SETTLE_FRAMES   300

Definition at line 7 of file view.c.

Referenced by Map_WaitForShakeToSettle().

◆ MAP_SHAKE_SETTLE_MAX_AMPLITUDE

#define MAP_SHAKE_SETTLE_MAX_AMPLITUDE   (Q16_ONE / 256 - 1)

Definition at line 8 of file view.c.

Referenced by Map_WaitForShakeToSettle().

◆ TILEMAP_TILE_BANK_BYTES

#define TILEMAP_TILE_BANK_BYTES   (256 * (8 * 8))

Definition at line 9 of file view.c.

Referenced by TileMap_DrawRowsFromRam().

◆ TILEMAP_MAP_BANK_BYTES

#define TILEMAP_MAP_BANK_BYTES   (64 * 64)

Definition at line 10 of file view.c.

Referenced by TileMap_DrawRowsFromRam().

Typedef Documentation

◆ 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.

Definition at line 56 of file view.c.

Function Documentation

◆ 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.

Definition at line 15 of file view.c.

Referenced by Map_SetScreenShake().

◆ 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.

Definition at line 36 of file view.c.

Referenced by GomaCaveWaterway_LeapStump(), GondowanCave_RunSpinningLeap(), and Map_WaitForShakeToSettle().

◆ 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.

Definition at line 64 of file view.c.

Referenced by TileMap_DrawRowsFromRam(), and WorldMap_BeginStillView().

◆ 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.

Definition at line 88 of file view.c.

Referenced by Map_InitializePerspectiveScene(), WorldMap_BuildScanlineTable(), and WorldMap_UpdateView().