Alchemy
Loading...
Searching...
No Matches

map_animation.c File Reference

Timed map effects: tile animation, the blend script, palette cycles. More...

Go to the source code of this file.

Functions

void MapAnimation_Update (void)
 Each frame: runs the 16 tile animation channels.
void Map_ClearLayerEntryFlag (u32 channelIndex)
 Resumes tile animation channel channelIndex by clearing its paused byte.
void Map_SetLayerEntryFlag (u32 channelIndex)
 Pauses tile animation channel channelIndex by setting its paused byte.
void MapAnimation_StartChannels (const u16 *script)
 Starts the tile animation channels a map's animation script lists: each 0xfdNN marker starts channel NN & 15 there (paused when bit 7 is set).
void MapAnimation_Suspend (void)
 Suspends the tile animations, unless the world map's still view is shown.
void MapAnimation_Resume (void)
 Resumes the tile animations, unless the world map's still view is shown.
void DisplayBlend_RunScript (void)
 Each frame: runs the map's blend script.
void DisplayBlend_StartScript (u16 *script)
 Starts a map's blend script, unless it is empty.
void DisplayBlend_SuspendScript (void)
 Suspends the blend script.
void DisplayBlend_ResumeScript (void)
 Resumes the blend script, through DisplayBlend_ResumeScriptFar.
UNUSED void PaletteQueue_Initialize (void)
 Allocates the palette cycling queue (heap slot 28) with its four entries cleared.
UNUSED s32 PaletteQueue_Add (s16 paletteBank, s16 firstColor, s16 delay, s16 colorCount)
 Adds a palette cycle: colorCount colours of background palette paletteBank from firstColor, rotated by one every delay + 1 frames.
UNUSED void PaletteQueue_Stop (void)
 Stops the palette cycles and frees their queue (heap slot 28).
UNUSED void PaletteQueue_Start (void)
 Starts running the palette cycles each frame.
void PaletteQueue_StepCycles (void)
 Each frame: advances each palette cycle whose timer has run out by one colour, writing the rotated colours back to the palette.

Detailed Description

Timed map effects: tile animation, the blend script, palette cycles.

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

Definition in file map_animation.c.

Function Documentation

◆ MapAnimation_Update()

void MapAnimation_Update ( void )

Each frame: runs the 16 tile animation channels.

A channel script is groups of four halfwords (source tile, count, destination tile, frames to wait) that copy tiles into VRAM; 0xfeNN jumps to halfword offset NN * 2, 0xfeff stops, and 0xffff loops to the start. MapAnimation_StartChannels schedules it (order 0xc80); the world map's still view (WorldMap_BeginStillView) suspends it. Moves each channel's cursor and timer in the map work. The retries stay gotos: as an inner for (;;) loop with continue and break, loop.c reshapes the channel loop.

Definition at line 15 of file map_animation.c.

Referenced by Map_LoadAreaGraphics(), Map_LoadDefaultCellsAndUpdateBlock(), MapAnimation_Resume(), MapAnimation_StartChannels(), MapAnimation_Suspend(), MapAnimation_Update(), and WorldMap_BeginStillView().

◆ Map_ClearLayerEntryFlag()

◆ Map_SetLayerEntryFlag()

◆ MapAnimation_StartChannels()

void MapAnimation_StartChannels ( const u16 * script)

Starts the tile animation channels a map's animation script lists: each 0xfdNN marker starts channel NN & 15 there (paused when bit 7 is set).

Clears all 16 channels first, and schedules MapAnimation_Update when any starts. Called by Map_LoadLayeredScene with the map's own script, and by Map_InitializePerspectiveScene with the world map's default one.

Definition at line 113 of file map_animation.c.

Referenced by Map_InitializePerspectiveScene(), Map_LoadLayeredScene(), and MapAnimation_StartChannels().

◆ MapAnimation_Suspend()

void MapAnimation_Suspend ( void )

Suspends the tile animations, unless the world map's still view is shown.

Menu_SuspendFieldTasks (menu/menu/common.c) calls it through MapAnimation_SuspendFar.

Definition at line 150 of file map_animation.c.

Referenced by MapAnimation_Suspend().

◆ MapAnimation_Resume()

void MapAnimation_Resume ( void )

Resumes the tile animations, unless the world map's still view is shown.

Menu_ResumeFieldTasks (menu/menu/common.c) calls it through MapAnimation_ResumeFar.

Definition at line 158 of file map_animation.c.

Referenced by MapAnimation_Resume().

◆ DisplayBlend_RunScript()

void DisplayBlend_RunScript ( void )

Each frame: runs the map's blend script.

A 0x3NNN command sets BLDCNT; any other sets BLDALPHA (or BLDY when not alpha blending) and waits the halfword after it in frames; 0xfeNN jumps, 0xfeff stops and 0xffff loops. DisplayBlend_StartScript schedules it (order 0xc80). Writes REG_BLDCNT, REG_BLDALPHA and REG_BLDY, and keeps the last BLDCNT in the map work's blendControl.

Definition at line 169 of file map_animation.c.

Referenced by DisplayBlend_ResumeScript(), DisplayBlend_RunScript(), DisplayBlend_StartScript(), and DisplayBlend_SuspendScript().

◆ DisplayBlend_StartScript()

void DisplayBlend_StartScript ( u16 * script)

Starts a map's blend script, unless it is empty.

Clears the map work's three-word blend state first, then schedules DisplayBlend_RunScript. Called by Map_LoadLayeredScene when the map's header has a blend script.

Definition at line 234 of file map_animation.c.

Referenced by DisplayBlend_StartScript(), and Map_LoadLayeredScene().

◆ DisplayBlend_SuspendScript()

void DisplayBlend_SuspendScript ( void )

Suspends the blend script.

The lighthouse scenes and Vale's Babi scene reach it through DisplayBlend_SuspendScriptFar.

Definition at line 259 of file map_animation.c.

Referenced by DisplayBlend_SuspendScript(), Event_HurryToThePlaza(), MercuryLighthouse_Initialize(), MercuryLighthouse_RideLift(), and Scene_RunEntrySetup().

◆ DisplayBlend_ResumeScript()

void DisplayBlend_ResumeScript ( void )

Resumes the blend script, through DisplayBlend_ResumeScriptFar.

Definition at line 264 of file map_animation.c.

Referenced by DisplayBlend_ResumeScript(), and MercuryLighthouse_Initialize().

◆ PaletteQueue_Initialize()

UNUSED void PaletteQueue_Initialize ( void )

Allocates the palette cycling queue (heap slot 28) with its four entries cleared.

Definition at line 270 of file map_animation.c.

Referenced by PaletteQueue_Initialize().

◆ PaletteQueue_Add()

UNUSED s32 PaletteQueue_Add ( s16 paletteBank,
s16 firstColor,
s16 delay,
s16 colorCount )

Adds a palette cycle: colorCount colours of background palette paletteBank from firstColor, rotated by one every delay + 1 frames.

Returns 0, or -1 when all four cycles are taken. The cycle keeps a copy of the colours as they were, which every step rotates from.

Definition at line 297 of file map_animation.c.

Referenced by PaletteQueue_Add().

◆ PaletteQueue_Stop()

UNUSED void PaletteQueue_Stop ( void )

Stops the palette cycles and frees their queue (heap slot 28).

Definition at line 326 of file map_animation.c.

Referenced by PaletteQueue_Stop().

◆ PaletteQueue_Start()

UNUSED void PaletteQueue_Start ( void )

Starts running the palette cycles each frame.

Definition at line 332 of file map_animation.c.

Referenced by PaletteQueue_Start().

◆ PaletteQueue_StepCycles()

void PaletteQueue_StepCycles ( void )

Each frame: advances each palette cycle whose timer has run out by one colour, writing the rotated colours back to the palette.

Only PaletteQueue_Start schedules it, and nothing calls that, so no palette cycle runs in the game.

Definition at line 340 of file map_animation.c.

Referenced by PaletteQueue_Start(), PaletteQueue_StepCycles(), and PaletteQueue_Stop().