Skip to Content
The Alchemy Project

src/field/field_tile_animation.c

World map tile preloading and still image, and timed map changes: the map animations, the blend script, the palette cycle and the World Map region tint. 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 0xfd00Marker command and flags; a marker comes before an animation's script.
#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: both bases put it at its start.
#defineTILESET_ANIM_RAM_WIDE_TILE 512
#defineBLEND_SCRIPT_OPCODE_MASK 0xff00The blend script's other commands (fdBlendScriptRun; BLEND_SCRIPT_LOOP and BLEND_SCRIPT_JUMP are map_grid.h's): as the tileset animations', and a BLDCNT value, told apart by its top four bits.
#defineBLEND_SCRIPT_STOP 0xff
#defineBLEND_SCRIPT_ARGUMENT_MASK 0xff
#defineBLEND_SCRIPT_BLDCNT_MASK 0xf000
#defineBLEND_SCRIPT_BLDCNT (BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BD)
#defineWORLD_MAP_COLLISION_TILE_BYTES 8A world map collision tile: 4 by 4 values of 4 bits, each for 4 by 4 pixels, in 8 bytes.
#defineWORLD_MAP_COLLISION_TILES 256
#defineWORLD_MAP_COLLISION_FLYABLE_LAST 8The last world map collision the flying ship crosses once it is up, counting on from the sea and the shallows (fdWorldMapIsFlyable); of the collisions after it, only 10 lets it over.
#defineWORLD_MAP_RELOAD_STEPS 12The ticks a world map graphics set takes to reload, one step a tick, counted down from this: its palette, animations and shapes, then each tile set decoded and copied to VRAM.
#defineTINT_SEA_OF_TIME_REGION 9The encounter regions the world map is tinted in (WORLD_MAP_ENCOUNTER_REGION), and their tints in BLDY's sixteenths: the Sea of Time brightened, and the land around Kibombo darkened until the Gabomba ceremony ends.
#defineTINT_BRIGHT 12
#defineTINT_KIBOMBO_REGION 18
#defineTINT_DARK 6

Functions

NameDescription
voidfdWorldMapPreloadCurrentTileBlock (void)Loads the first of the 2x2 world map tiles around the player that is not shown yet (at most one a tick), without drawing it.
voidfdWorldMapPresentStillImage (void)VBlank: shows BG1 and copies the decoded picture's tiles into VRAM.
voidfdWorldMapStartStillImage (void)Freezes the world map's perspective view as a still image on BG1: decodes the area's tiles again where a field Psynergy used their buffer, saves BG1's tiles, draws the current affine frame into pixels and hands the window and VBlank to it.
voidfdWorldMapEndStillImage (void)VBlank: shows BG1 and copies the area's tiles back into VRAM.
voidfdWorldMapLoadAreaGraphics (void)Reloads the world map area's palette and tiles after the still image, puts the default metatiles back and returns to the perspective view.
voidfdWorldMapLoadDefaultMetatilesAndUpdateBlock (void)Puts the default world map metatiles back after the still image and returns to the perspective view, without reloading the area's palette or tiles.
voidfdTilesetAnimationUpdate (void)Each tick: runs the 16 tileset animations.
voidfdTilesetAnimationResume (Uint32 channelIndex)Resumes tileset animation channelIndex.
voidfdTilesetAnimationPause (Uint32 channelIndex)Pauses tileset animation channelIndex.
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, unless it is empty.
voidfdBlendScriptSuspend (void)Suspends the blend script; scenes reach it through fdBlendScriptSuspendStub.
voidfdBlendScriptResume (void)Resumes the blend script, through fdBlendScriptResumeStub.
voidfdPaletteQueueStop (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.
voidfdWorldMapUpdateRegionTint (Sint32 region, Sint32 gradual)Tints the world map for the encounter region under the party, any region but the Sea of Time's and Kibombo's clearing the tint.

Description

World map tile preloading and still image, and timed map changes: the map animations, the blend script, the palette cycle and the World Map region tint. 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 10 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 11 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 12 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 13 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 14 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 18 of file field_tile_animation.c.

TILESET_ANIM_MARKER

#define TILESET_ANIM_MARKER 0xfd00

Marker command and flags; a marker comes before an animation's script.

low four bits: the animation it starts

Referenced by fdTilesetAnimationStartAll().

Definition at line 21 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 22 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 23 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: both bases put it at its start.

Referenced by fdTilesetAnimationUpdate().

Definition at line 27 of file field_tile_animation.c.

TILESET_ANIM_RAM_WIDE_TILE

#define TILESET_ANIM_RAM_WIDE_TILE 512

Referenced by fdTilesetAnimationUpdate().

Definition at line 28 of file field_tile_animation.c.

BLEND_SCRIPT_OPCODE_MASK

#define BLEND_SCRIPT_OPCODE_MASK 0xff00

The blend script's other commands (fdBlendScriptRun; BLEND_SCRIPT_LOOP and BLEND_SCRIPT_JUMP are map_grid.h's): as the tileset animations', and a BLDCNT value, told apart by its top four bits.

Referenced by fdBlendScriptRun().

Definition at line 33 of file field_tile_animation.c.

BLEND_SCRIPT_STOP

#define BLEND_SCRIPT_STOP 0xff

Referenced by fdBlendScriptRun().

Definition at line 34 of file field_tile_animation.c.

BLEND_SCRIPT_ARGUMENT_MASK

#define BLEND_SCRIPT_ARGUMENT_MASK 0xff

Referenced by fdBlendScriptRun().

Definition at line 35 of file field_tile_animation.c.

BLEND_SCRIPT_BLDCNT_MASK

#define BLEND_SCRIPT_BLDCNT_MASK 0xf000

Referenced by fdBlendScriptRun().

Definition at line 36 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 37 of file field_tile_animation.c.

WORLD_MAP_COLLISION_TILE_BYTES

#define WORLD_MAP_COLLISION_TILE_BYTES 8

A world map collision tile: 4 by 4 values of 4 bits, each for 4 by 4 pixels, in 8 bytes. The collision buffer holds the 256 tiles of the lower layer's, then the upper layer's.

Referenced by fdWorldMapGetCollision().

Definition at line 42 of file field_tile_animation.c.

WORLD_MAP_COLLISION_TILES

#define WORLD_MAP_COLLISION_TILES 256

Referenced by fdWorldMapGetCollision().

Definition at line 43 of file field_tile_animation.c.

WORLD_MAP_COLLISION_FLYABLE_LAST

#define WORLD_MAP_COLLISION_FLYABLE_LAST 8

The last world map collision the flying ship crosses once it is up, counting on from the sea and the shallows (fdWorldMapIsFlyable); of the collisions after it, only 10 lets it over.

Referenced by fdWorldMapIsFlyable().

Definition at line 48 of file field_tile_animation.c.

WORLD_MAP_RELOAD_STEPS

#define WORLD_MAP_RELOAD_STEPS 12

The ticks a world map graphics set takes to reload, one step a tick, counted down from this: its palette, animations and shapes, then each tile set decoded and copied to VRAM.

Referenced by fdWorldMapPreloadCurrentTileBlock().

Definition at line 53 of file field_tile_animation.c.

TINT_SEA_OF_TIME_REGION

#define TINT_SEA_OF_TIME_REGION 9

The encounter regions the world map is tinted in (WORLD_MAP_ENCOUNTER_REGION), and their tints in BLDY's sixteenths: the Sea of Time brightened, and the land around Kibombo darkened until the Gabomba ceremony ends.

Referenced by fdWorldMapUpdateRegionTint().

Definition at line 704 of file field_tile_animation.c.

TINT_BRIGHT

#define TINT_BRIGHT 12

Referenced by fdWorldMapUpdateRegionTint().

Definition at line 705 of file field_tile_animation.c.

TINT_KIBOMBO_REGION

#define TINT_KIBOMBO_REGION 18

Referenced by fdWorldMapUpdateRegionTint().

Definition at line 706 of file field_tile_animation.c.

TINT_DARK

#define TINT_DARK 6

Referenced by fdWorldMapUpdateRegionTint().

Definition at line 707 of file field_tile_animation.c.

Functions in detail

fdWorldMapPreloadCurrentTileBlock

void fdWorldMapPreloadCurrentTileBlock(void)

Loads the first of the 2x2 world map tiles around the player that is not shown yet (at most one a tick), without drawing it. When the region under the party picks another graphics set, reloads that set over the next WORLD_MAP_RELOAD_STEPS ticks, unless a screen transition is running.

References BgTileBuffer, fdPaletteFadeLoadPaletteStub(), fdScreenTransitionIsScanlineActiveStub(), fdTilesetAnimationStartAll(), fdWorldMapGetRegionGroupGraphics(), fdWorldMapUpdateRegionTint(), fdWorldMapWriteLayerMetatileTile(), MapGridAnimationTiles, MapGridShapes, Sint32, syDecompressByteLZ(), syDecompressTaggedLZ(), syDMAXCopy(), syHeapAllocate(), syHeapRelease(), syResourceGetTableEntry(), WorldMapGraphicsResources and WorldMapStateWork.

Referenced by fdWorldMapUpdateView().

Definition at line 59 of file field_tile_animation.c.

fdWorldMapPresentStillImage

void fdWorldMapPresentStillImage(void)

VBlank: shows BG1 and copies the decoded picture's tiles into VRAM.

References syDMAXCopy().

Referenced by fdWorldMapStartStillImage().

Definition at line 212 of file field_tile_animation.c.

fdWorldMapStartStillImage

void fdWorldMapStartStillImage(void)

Freezes the world map's perspective view as a still image on BG1: decodes the area's tiles again where a field Psynergy used their buffer, saves BG1's tiles, draws the current affine frame into pixels and hands the window and VBlank to it.

References BgTileBuffer, DecodeBuffer, fdTileMapDrawRowsFromRam(), fdTilesetAnimationUpdate(), fdWorldMapPresentStillImage(), syDecompressTaggedLZ(), syDMAXCopy(), syResourceGetTableEntry(), sySuspendEvent(), sySynch(), TickCount and UserFunction().

Definition at line 233 of file field_tile_animation.c.

fdWorldMapEndStillImage

void fdWorldMapEndStillImage(void)

VBlank: shows BG1 and copies the area's tiles back into VRAM.

References BgTileBuffer and syDMAXCopy().

Referenced by fdWorldMapLoadAreaGraphics() and fdWorldMapLoadDefaultMetatilesAndUpdateBlock().

Definition at line 265 of file field_tile_animation.c.

fdWorldMapLoadAreaGraphics

void fdWorldMapLoadAreaGraphics(void)

Reloads the world map area's palette and tiles after the still image, puts the default metatiles back and returns to the perspective view.

References BgTileBuffer, fdTilesetAnimationUpdate(), fdWorldMapEndStillImage(), fdWorldMapUpdateCurrentTileBlock(), fdWorldMapUpdateRegionTint(), MapGridAnimationTiles, syDecompressByteLZ(), syDecompressTaggedLZ(), syDMAXCopy(), syResourceGetTableEntry(), syResumeEvent(), sySynch(), UserFunction() and WorldMapStateWork.

Definition at line 282 of file field_tile_animation.c.

fdWorldMapLoadDefaultMetatilesAndUpdateBlock

void fdWorldMapLoadDefaultMetatilesAndUpdateBlock(void)

Puts the default world map metatiles back after the still image and returns to the perspective view, without reloading the area's palette or tiles.

References fdTilesetAnimationUpdate(), fdWorldMapEndStillImage(), fdWorldMapUpdateCurrentTileBlock(), syDecompressTaggedLZ(), syResourceGetTableEntry(), syResumeEvent(), sySynch() and UserFunction().

Definition at line 337 of file field_tile_animation.c.

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 354 of file field_tile_animation.c.

fdTilesetAnimationResume

void fdTilesetAnimationResume(Uint32 channelIndex)

Resumes tileset animation channelIndex.

Referenced by scAirsRockEnterTheRock(), scAquaRockDouseWaterStone(), scChampaEnterDoor(), scInit(), scLemurianShipDeckShowArrival(), scLinkLobbyEnterBattle() and scPrepareMap().

Definition at line 454 of file field_tile_animation.c.

fdTilesetAnimationPause

void fdTilesetAnimationPause(Uint32 channelIndex)

Pauses tileset animation channelIndex.

Referenced by scAquaRockDouseWaterStone(), scInit(), scLinkLobbyEnterBattle(), scMikasallaDryTunnels(), scPrepareMap() and scProxSayFarewell().

Definition at line 463 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, syFindEvent() and sySetEvent().

Referenced by fdMapGridLoadMap(), fdWorldMapLoadGraphics() and fdWorldMapPreloadCurrentTileBlock().

Definition at line 474 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().

Referenced by scAirsRockInsideDriftMote(), scJupiterLighthouseUpdateSpark() and scYampiDesertUpdateSandFlow().

Definition at line 514 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().

Referenced by scAirsRockInsideDriftMote(), scJupiterLighthouseUpdateSpark() and scYampiDesertUpdateSandFlow().

Definition at line 521 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 528 of file field_tile_animation.c.

fdBlendScriptStart

void fdBlendScriptStart(Uint16 *script)

Starts a map's blend script, unless it is empty. Clears the map state's three-word blend state first, then adds fdBlendScriptRun as an event.

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

Referenced by fdMapGridLoadMap() and scPrepareMap().

Definition at line 594 of file field_tile_animation.c.

fdBlendScriptSuspend

void fdBlendScriptSuspend(void)

Suspends the blend script; scenes reach it through fdBlendScriptSuspendStub.

References fdBlendScriptRun() and sySuspendEvent().

Referenced by scAnemosInnerSanctumLightSymbol(), scAquaRockInsideBlockMoaiWithPillar(), scGabombaStatueChamberInitLift(), scGabombaStatueChamberRideLiftBackUp(), scGabombaStatueChamberRideLiftDown(), scGaiaRockInsideRaiseSandTablet(), scGaiaRockInsideReadSandTablet(), scInit(), scMarsLighthouseHallStartDoorways(), scShrineOfTheSeaGodLowerWater(), scShrineOfTheSeaGodUseSeaGodsTear(), scTaopoSwampDarkenRoom() and scTundariaTowerRevealHiddenWay().

Definition at line 622 of file field_tile_animation.c.

fdBlendScriptResume

void fdBlendScriptResume(void)

Resumes the blend script, through fdBlendScriptResumeStub.

References fdBlendScriptRun() and syResumeEvent().

Referenced by scAnemosInnerSanctumLightSymbol(), scAquaRockInsideBlockMoaiWithPillar(), scGaiaRockInsideRaiseSandTablet(), scGaiaRockInsideReadSandTablet(), scInit() and scTundariaTowerEndRevealHiddenWay().

Definition at line 628 of file field_tile_animation.c.

fdPaletteQueueStop

void fdPaletteQueueStop(void)

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

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

Definition at line 639 of file field_tile_animation.c.

fdPaletteCycleStart

void fdPaletteCycleStart(void)

Unused: starts running the palette cycles each tick.

References fdPaletteCycleStep() and sySetEvent().

Referenced by scIsletsArriveAtSecretSpot(), scIsletsArriveBackAtIsland() and scIsletsInitSeaOfTime().

Definition at line 646 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(), fdPaletteQueueStop(), scJupiterLighthouseLoadPalettes() and scPaletteCycleStop().

Definition at line 653 of file field_tile_animation.c.

fdWorldMapUpdateRegionTint

void fdWorldMapUpdateRegionTint(Sint32 region, Sint32 gradual)

Tints the world map for the encounter region under the party, any region but the Sea of Time's and Kibombo's clearing the tint. Gradually, the tint moves one step every 16 ticks; at once, it jumps there. While a menu is open the tint stays as it is.

References Sint32, syGameFlagGet() and TickCount.

Referenced by fdWorldMapLoadAreaGraphics(), fdWorldMapLoadGraphics() and fdWorldMapPreloadCurrentTileBlock().

Definition at line 713 of file field_tile_animation.c.