Skip to Content
The Alchemy Project

src/field/field_tile_animation.c

Timed map changes: the tileset animations that redraw a map's tiles in turn, the blend script that changes over time how its layers blend, and the palette cycles, which nothing starts. More…

Included by field.c.

Macros

NameDescription
#defineTILESET_ANIM_LOOP 0xffffBack to the start of the script.
#defineTILESET_ANIM_OPCODE_MASK 0xff00The high byte: the command.
#defineTILESET_ANIM_JUMP 0xfe00Low byte: the halfword pair to jump to.
#defineTILESET_ANIM_STOP 0xffTILESET_ANIM_JUMP's low byte to stop.
#defineTILESET_ANIM_ARGUMENT_MASK 0xffThe low byte: the command's argument.
#defineTILESET_ANIM_WIDE_TILE_BYTES (TILE_SIZE_4BPP * 2)A layout with wide tiles animates 64-byte (256-colour) tiles in char block 2; others animate 16-colour ones in char block 1.
#defineTILESET_ANIM_MARKER 0xfd00In the map's list of scripts, the start of one; low four bits: the animation it starts.
#defineTILESET_ANIM_MARKER_PAUSED 0x80A marker's bit: start it paused.
#defineTILESET_ANIM_MARKER_ANIMATION_MASK 0xfA marker's animation.
#defineTILESET_ANIM_RAM_TILE 1536The first source tile read from MapGridAnimationTiles rather than VRAM, for 32-byte and for 64-byte (wide) tiles: counted from RamDecodeBuffer or from RamMetatileTiles, both reach its start.
#defineTILESET_ANIM_RAM_WIDE_TILE 512
#defineBLEND_SCRIPT_LOOP 0xffffThe blend script's commands (fdBlendScriptRun): as the tileset animations', and a BLDCNT value, told apart by its top four bits.
#defineBLEND_SCRIPT_OPCODE_MASK 0xff00
#defineBLEND_SCRIPT_JUMP 0xfe00
#defineBLEND_SCRIPT_STOP 0xff
#defineBLEND_SCRIPT_ARGUMENT_MASK 0xff
#defineBLEND_SCRIPT_BLDCNT_MASK 0xf000
#defineBLEND_SCRIPT_BLDCNT (BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD)
#defineBLDCNT_EFFECT_MASK 0x00c0BLDCNT's effect, bits 7 and 6 (BLDCNT_EFFECT_NONE to BLDCNT_EFFECT_DARKEN).

Functions

NameDescription
voidfdTilesetAnimationUpdate (void)Each tick: runs the 16 tileset animations.
voidfdTilesetAnimationResume (Uint32 channelIndex)Lets tileset animation channelIndex run on from where it was held.
voidfdTilesetAnimationPause (Uint32 channelIndex)Holds tileset animation channelIndex on the tiles it shows now.
voidfdTilesetAnimationStartAll (const Uint16 *script)Starts the tileset animations a map's animation script lists: each TILESET_ANIM_MARKER starts the tileset animation its low four bits name there (paused with TILESET_ANIM_MARKER_PAUSED).
voidfdTilesetAnimationSuspendAll (void)Suspends the tileset animations, unless the world map's still image is shown.
voidfdTilesetAnimationResumeAll (void)Resumes the tileset animations, unless the world map's still image is shown.
voidfdBlendScriptRun (void)Each tick: runs the map's blend script.
voidfdBlendScriptStart (Uint16 *script)Starts a map's blend script, which then runs each tick; a map whose script is empty keeps its blend as it is.
voidfdBlendScriptSuspend (void)Suspends the blend script.
voidfdBlendScriptResume (void)Resumes the blend script, through fdBlendScriptResumeStub.
voidfdPaletteCycleInit (void)Unused: allocates the palette cycling queue (HEAP_SLOT_PALETTE_CYCLES) with its four entries cleared.
Sint32fdPaletteCycleAdd (Sint16 paletteNumber, Sint16 firstColor, Sint16 delay, Sint16 colorCount)Unused: adds a palette cycle: colorCount colours of background palette paletteNumber from firstColor, rotated by one every delay + 1 ticks.
voidfdPaletteCycleStop (void)Unused: stops the palette cycles and frees their queue (HEAP_SLOT_PALETTE_CYCLES).
voidfdPaletteCycleStart (void)Unused: starts running the palette cycles each tick.
voidfdPaletteCycleStep (void)Each tick: advances each palette cycle whose timer has run out by one colour, writing the rotated colours back to the palette.

Description

Timed map changes: the tileset animations that redraw a map's tiles in turn, the blend script that changes over time how its layers blend, and the palette cycles, which nothing starts. Part of field.c.

Macros in detail

TILESET_ANIM_LOOP

#define TILESET_ANIM_LOOP 0xffff

Back to the start of the script.

Referenced by fdTilesetAnimationStartAll() and fdTilesetAnimationUpdate().

Definition at line 11 of file field_tile_animation.c.

TILESET_ANIM_OPCODE_MASK

#define TILESET_ANIM_OPCODE_MASK 0xff00

The high byte: the command.

Referenced by fdTilesetAnimationStartAll() and fdTilesetAnimationUpdate().

Definition at line 13 of file field_tile_animation.c.

TILESET_ANIM_JUMP

#define TILESET_ANIM_JUMP 0xfe00

Low byte: the halfword pair to jump to.

Referenced by fdTilesetAnimationUpdate().

Definition at line 15 of file field_tile_animation.c.

TILESET_ANIM_STOP

#define TILESET_ANIM_STOP 0xff

TILESET_ANIM_JUMP's low byte to stop.

Referenced by fdTilesetAnimationUpdate().

Definition at line 17 of file field_tile_animation.c.

TILESET_ANIM_ARGUMENT_MASK

#define TILESET_ANIM_ARGUMENT_MASK 0xff

The low byte: the command's argument.

Referenced by fdTilesetAnimationUpdate().

Definition at line 19 of file field_tile_animation.c.

TILESET_ANIM_WIDE_TILE_BYTES

#define TILESET_ANIM_WIDE_TILE_BYTES (TILE_SIZE_4BPP * 2)

A layout with wide tiles animates 64-byte (256-colour) tiles in char block 2; others animate 16-colour ones in char block 1.

Referenced by fdTilesetAnimationUpdate().

Definition at line 22 of file field_tile_animation.c.

TILESET_ANIM_MARKER

#define TILESET_ANIM_MARKER 0xfd00

In the map's list of scripts, the start of one; low four bits: the animation it starts.

Referenced by fdTilesetAnimationStartAll().

Definition at line 25 of file field_tile_animation.c.

TILESET_ANIM_MARKER_PAUSED

#define TILESET_ANIM_MARKER_PAUSED 0x80

A marker's bit: start it paused.

Referenced by fdTilesetAnimationStartAll().

Definition at line 27 of file field_tile_animation.c.

TILESET_ANIM_MARKER_ANIMATION_MASK

#define TILESET_ANIM_MARKER_ANIMATION_MASK 0xf

A marker's animation.

Referenced by fdTilesetAnimationStartAll().

Definition at line 29 of file field_tile_animation.c.

TILESET_ANIM_RAM_TILE

#define TILESET_ANIM_RAM_TILE 1536

The first source tile read from MapGridAnimationTiles rather than VRAM, for 32-byte and for 64-byte (wide) tiles: counted from RamDecodeBuffer or from RamMetatileTiles, both reach its start.

Referenced by fdTilesetAnimationUpdate().

Definition at line 33 of file field_tile_animation.c.

TILESET_ANIM_RAM_WIDE_TILE

#define TILESET_ANIM_RAM_WIDE_TILE 512

Referenced by fdTilesetAnimationUpdate().

Definition at line 34 of file field_tile_animation.c.

BLEND_SCRIPT_LOOP

#define BLEND_SCRIPT_LOOP 0xffff

The blend script's commands (fdBlendScriptRun): as the tileset animations', and a BLDCNT value, told apart by its top four bits.

Referenced by fdBlendScriptRun() and fdBlendScriptStart().

Definition at line 38 of file field_tile_animation.c.

BLEND_SCRIPT_OPCODE_MASK

#define BLEND_SCRIPT_OPCODE_MASK 0xff00

Referenced by fdBlendScriptRun().

Definition at line 39 of file field_tile_animation.c.

BLEND_SCRIPT_JUMP

#define BLEND_SCRIPT_JUMP 0xfe00

Referenced by fdBlendScriptRun().

Definition at line 40 of file field_tile_animation.c.

BLEND_SCRIPT_STOP

#define BLEND_SCRIPT_STOP 0xff

Referenced by fdBlendScriptRun().

Definition at line 41 of file field_tile_animation.c.

BLEND_SCRIPT_ARGUMENT_MASK

#define BLEND_SCRIPT_ARGUMENT_MASK 0xff

Referenced by fdBlendScriptRun().

Definition at line 42 of file field_tile_animation.c.

BLEND_SCRIPT_BLDCNT_MASK

#define BLEND_SCRIPT_BLDCNT_MASK 0xf000

Referenced by fdBlendScriptRun().

Definition at line 43 of file field_tile_animation.c.

BLEND_SCRIPT_BLDCNT

#define BLEND_SCRIPT_BLDCNT (BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD)

Referenced by fdBlendScriptRun().

Definition at line 44 of file field_tile_animation.c.

BLDCNT_EFFECT_MASK

#define BLDCNT_EFFECT_MASK 0x00c0

BLDCNT's effect, bits 7 and 6 (BLDCNT_EFFECT_NONE to BLDCNT_EFFECT_DARKEN).

Referenced by fdBlendScriptRun().

Definition at line 47 of file field_tile_animation.c.

Functions in detail

fdTilesetAnimationUpdate

void fdTilesetAnimationUpdate(void)

Each tick: runs the 16 tileset animations.

References syDMAXCopy().

Referenced by fdTilesetAnimationResumeAll(), fdTilesetAnimationStartAll(), fdTilesetAnimationSuspendAll(), fdWorldMapLoadAreaGraphics(), fdWorldMapLoadDefaultMetatilesAndUpdateBlock() and fdWorldMapStartStillImage().

Definition at line 50 of file field_tile_animation.c.

fdTilesetAnimationResume

void fdTilesetAnimationResume(Uint32 channelIndex)

Lets tileset animation channelIndex run on from where it was held.

Referenced by scBabiPalaceLeaveThroughDoor(), scBattleArenaEnterBattle(), scColosseumNavampaMatchStopSidewalk(), scCottageRoomsBDoraWakesIsaac(), scCottageRoomsBVisitSickDora(), scHammetPalaceLeaveThroughDoor(), scInit(), scMcCoyPalaceCaptainTalksAboutBarricade(), scMcCoyPalaceWalkThroughDoor(), scSolSanctumLunaSolRoomsRiseToElementalStarRoom(), scValePrologueFlashLightning() and scValePrologueShowBoulderSweepingDownriver().

Definition at line 150 of file field_tile_animation.c.

fdTilesetAnimationPause

void fdTilesetAnimationPause(Uint32 channelIndex)

Holds tileset animation channelIndex on the tiles it shows now.

Referenced by scBabiPalacePauseDoorAnimations(), scBattleArenaEnterBattle(), scColosseumNavampaMatchStopSidewalk(), scCottageRoomsBDoraWakesIsaac(), scCottageRoomsBVisitSickDora(), scHammetPalaceLeaveThroughDoor(), scHammetPalaceSetUpEntrance(), scInit(), scMcCoyPalaceCaptainTalksAboutBarricade(), scMcCoyPalaceWalkThroughDoor(), scValePrologueFlashLightning() and scValePrologueShowBoulderSweepingDownriver().

Definition at line 159 of file field_tile_animation.c.

fdTilesetAnimationStartAll

void fdTilesetAnimationStartAll(const Uint16 *script)

Starts the tileset animations a map's animation script lists: each TILESET_ANIM_MARKER starts the tileset animation its low four bits name there (paused with TILESET_ANIM_MARKER_PAUSED).

References fdTilesetAnimationUpdate(), Sint32 and sySetEvent().

Referenced by fdMapGridLoadMap() and fdWorldMapInitPerspective().

Definition at line 170 of file field_tile_animation.c.

fdTilesetAnimationSuspendAll

void fdTilesetAnimationSuspendAll(void)

Suspends the tileset animations, unless the world map's still image is shown.

References fdTilesetAnimationUpdate() and sySuspendEvent().

Definition at line 209 of file field_tile_animation.c.

fdTilesetAnimationResumeAll

void fdTilesetAnimationResumeAll(void)

Resumes the tileset animations, unless the world map's still image is shown.

References fdTilesetAnimationUpdate() and syResumeEvent().

Definition at line 216 of file field_tile_animation.c.

fdBlendScriptRun

void fdBlendScriptRun(void)

Each tick: runs the map's blend script.

Referenced by fdBlendScriptResume(), fdBlendScriptStart() and fdBlendScriptSuspend().

Definition at line 223 of file field_tile_animation.c.

fdBlendScriptStart

void fdBlendScriptStart(Uint16 *script)

Starts a map's blend script, which then runs each tick; a map whose script is empty keeps its blend as it is.

References fdBlendScriptRun(), Sint32, syDMAXCopy() and sySetEvent().

Referenced by fdMapGridLoadMap().

Definition at line 289 of file field_tile_animation.c.

fdBlendScriptSuspend

void fdBlendScriptSuspend(void)

Suspends the blend script. The lighthouse scenes and Vale's Babi script reach it through fdBlendScriptSuspendStub.

References fdBlendScriptRun() and sySuspendEvent().

Referenced by scCottageRoomsBHurryToThePlaza(), scInit() and scMercuryLighthouseRideLift().

Definition at line 313 of file field_tile_animation.c.

fdBlendScriptResume

void fdBlendScriptResume(void)

Resumes the blend script, through fdBlendScriptResumeStub.

References fdBlendScriptRun() and syResumeEvent().

Referenced by scInit().

Definition at line 319 of file field_tile_animation.c.

fdPaletteCycleInit

void fdPaletteCycleInit(void)

Unused: allocates the palette cycling queue (HEAP_SLOT_PALETTE_CYCLES) with its four entries cleared.

References syHeapSlotAllocateEWRAM().

Definition at line 326 of file field_tile_animation.c.

fdPaletteCycleAdd

Sint32 fdPaletteCycleAdd(Sint16 paletteNumber, Sint16 firstColor, Sint16 delay, Sint16 colorCount)

Unused: adds a palette cycle: colorCount colours of background palette paletteNumber from firstColor, rotated by one every delay + 1 ticks. 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.

References Sint32 and syDMAXCopy().

Definition at line 358 of file field_tile_animation.c.

fdPaletteCycleStop

void fdPaletteCycleStop(void)

Unused: stops the palette cycles and frees their queue (HEAP_SLOT_PALETTE_CYCLES).

References fdPaletteCycleStep(), syCloseEvent() and syHeapSlotRelease().

Definition at line 394 of file field_tile_animation.c.

fdPaletteCycleStart

void fdPaletteCycleStart(void)

Unused: starts running the palette cycles each tick.

References fdPaletteCycleStep() and sySetEvent().

Definition at line 401 of file field_tile_animation.c.

fdPaletteCycleStep

void fdPaletteCycleStep(void)

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

References syDMAXCopy().

Referenced by fdPaletteCycleStart() and fdPaletteCycleStop().

Definition at line 408 of file field_tile_animation.c.