Skip to Content
The Alchemy Project

include/field/sprite.h

Animated sprites: their layers, the sprite picture caches and the actor system's state.

Included by battle_internal.h, battle_effect_internal.h, actor_scripts.c, field_effect_advance_motion.c, field_effect_move.c, field_effect_spawn_resident.c, field_engine_internal.h, field_internal.h, field_psynergy_internal.h, script_commands_internal.h, script_commands_scripts.c, speaker_voices.c, menu_internal.h, field_effect_advance_motion_priority.c, world_map_objects.c, window_internal.h, battle.h, field.h, field_psynergy.h, ground_mask.h, hanging_vine.h, system_call.h and scene.h.

Structures

NameDescription
structSPR_ANIMATIONOne animation layer of a sprite: its animation id, pictures, running script and timer.
structSPR_PICTURE_CACHEA sprite picture cache: the tag of the animation loaded into it (slot number and animation id) and the buffer holding its pictures.
structACTOR_SYSTEM_STATEThe actor system's state: the flag that suspends sprite projection, the outline's edge and fill colours, and the sprite picture caches (HEAP_SLOT_ACTOR_SYSTEM).
structANIMATION_SPR_PARTThe hardware sprite attributes one part of an animated sprite (its image or its shadow) is drawn with: the link to the next part queued at its depth, then the OAM entry's attributes 0 to 3.
structSPRAn animated sprite: its image, scale, rotation, size, its shadow and up to four sprite animations.
structPLACED_SPRAn actor's sprite (SPR) as the code that sets its image and shadow priorities reads it (the actors' freeze and placement, an actor taking the leader's layer): a byte at a time, under SPR's names.

Macros

NameDescription
#defineSPRITE_COLOR_BLINK 0x100Passed to fdActorConfigureSpriteColor in place of a SPR_COL_MODE: the actor blinks white every few ticks (fdActorUpdateBlink) until it is given a mode again.
#defineSPRITE_PICTURE_NONE 255SPR_ANIMATION.picture and pictureBase when no picture is shown.
#defineSPRITE_ANIMATION_KEEP_PLACE 0x80An animation number's bit 7: keep the place and timer of the script already running.
#defineSPRITE_ANIMATION_INDEX_MASK 0x7f
#defineSPRITE_LAYER_NOT_DRAWN 9A sprite layer's priority past the four drawn ones (SPR_ANIMATION's priority above 3): the layer is kept but not drawn.
#defineSPRITE_PICTURE_TAG (slot, id) ((id) + ((slot) << 12))A sprite id with the sprite picture cache its pictures load into, as a SPR_PICTURE_CACHE's tag holds them.
#defineSPRITE_ID_MASK 0xfffA battle sprite id's low twelve bits, the sprite.
#defineSPRITE_SECOND_PART SPRITE_PICTURE_TAG(2, 1)What a two-part enemy's second part adds to its first (the Serpent, the Kraken, the Fusion Dragon, Poseidon and the Doom Dragon): the next sprite, its pictures two slots on, past the two slots a large enemy's first part takes.
#defineVRAM_CACHE_ENTRY_ACTOR_SHADOW 93The VRAM cache entry of the actors' shared shadow (ActorShadowTiles), each sprite's part 1.
#defineANIM_OBJECT_COUNT 64How many the actor system's pools hold: its sprites (HEAP_SLOT_SPRITES) and its sprite animations (HEAP_SLOT_SPRITE_ANIMATIONS).
#defineSHADOW_HALF_WIDTH 8A sprite's shadow, 16 by 8 pixels: its half width and half height, both doubled when the sprite is drawn double-size.
#defineSHADOW_HALF_HEIGHT 4
#defineANIM_STEP_NORMAL 16SPR_ANIMATION.step at normal speed, as fdActorSetAnimationSpeed sets it: a timed command's ticks run as written.
#defineDJINNI_ANIMATION_EXCITED 3A Djinni's lively animation on the four Djinn sprite sheets, facing the player: Venus bounces, Mars, Jupiter and Mercury wave their arms.

Enumerations

NameDescription
enumSPR_COL_MODE { SPRITE_COLOR_NORMAL, SPRITE_COLOR_GRB, SPRITE_COLOR_RBG, SPR … }SPR_ANIMATION.param: how fdRenderDecodePicture colours a layer's pixels.
enumSPR_FLAG { SPRITE_FLAG_SHADOW, SPRITE_FLAG_OUTLINED, SPRITE_FLAG_SHADED … }SPR.flags.
enumANIMATION_COMMAND { ANIMCMD_END, ANIMCMD_SET_KIND, ANIMCMD_HOLD, ANIMCMD_OFFSET_ … }Animation script commands.
enumACTOR_ANIMATION { ANIM_STILL, ANIM_STAND, ANIM_WALK, ANIM_NOD, ANIM_SHAKE_HEAD … }Animation numbers of a person's sprite, for fdActorSetAnimation.
enumPARTICLE_ANIMATION { ANIM_PARTICLE_FADE, ANIM_PARTICLE_TWINKLE, ANIM_PARTICLE_SLO … }SPRITE_PARTICLE's animations.

Description

Animated sprites: their layers, the sprite picture caches and the actor system's state.

Macros in detail

#define SPRITE_COLOR_BLINK 0x100

Passed to fdActorConfigureSpriteColor in place of a SPR_COL_MODE: the actor blinks white every few ticks (fdActorUpdateBlink) until it is given a mode again.

Referenced by fdActorConfigureSpriteColor(), scAirsRockInsideShebaLearnsReveal(), scAirsRockInsideWakeEntranceStatue(), scAirsRockInsideWakeHallStatue(), scAquaRockInsidePiersLearnsParch(), scGaiaRockInsideFelixLearnsSand(), scInit(), scJupiterLighthouseAlexAppears(), scKandoreanTempleTestTheStudents(), scMagmaRockInsideLearnBlaze() and scMarsLighthouseAerieFaceDoomDragon().

Definition at line 43 of file sprite.h.

SPRITE_PICTURE_NONE

#define SPRITE_PICTURE_NONE 255

SPR_ANIMATION.picture and pictureBase when no picture is shown.

Referenced by btEffectTintBattler(), btMotionPlayFall(), btMotionShowDowned(), btObjectSetColorMode(), btPlaybackRun(), fdSpriteAnimationAllocate(), fdSpriteAnimationReset(), fdSpriteComposePicture(), fdSpriteResetAnimations(), fdSpriteSkipToStop(), fdSpriteViewerStartStaggeredAnimations() and scLemuriaSpringSetActorAppearance().

Definition at line 46 of file sprite.h.

SPRITE_ANIMATION_KEEP_PLACE

#define SPRITE_ANIMATION_KEEP_PLACE 0x80

An animation number's bit 7: keep the place and timer of the script already running.

Referenced by fdSpriteAnimationStart() and fdSpriteStartAnimation().

Definition at line 50 of file sprite.h.

SPRITE_ANIMATION_INDEX_MASK

#define SPRITE_ANIMATION_INDEX_MASK 0x7f

Referenced by fdSpriteStartAnimation().

Definition at line 51 of file sprite.h.

SPRITE_LAYER_NOT_DRAWN

#define SPRITE_LAYER_NOT_DRAWN 9

A sprite layer's priority past the four drawn ones (SPR_ANIMATION's priority above 3): the layer is kept but not drawn.

Referenced by btObjectUpdateSpritePriorities(), fdActorMoveAsSandOnWorldMap(), fdActorMoveOnWorldMap(), fdActorResetForLeader() and scTaopoSwampStepOnFirmGround().

Definition at line 55 of file sprite.h.

SPRITE_PICTURE_TAG

#define SPRITE_PICTURE_TAG(slot, id) ((id) + ((slot) << 12))

A sprite id with the sprite picture cache its pictures load into, as a SPR_PICTURE_CACHE's tag holds them.

Referenced by fdSpriteViewerRun().

Definition at line 93 of file sprite.h.

SPRITE_ID_MASK

#define SPRITE_ID_MASK 0xfff

A battle sprite id's low twelve bits, the sprite. The bits above hold the enemy sprite slot its pictures are loaded into (btEnemySpriteLoadIntoSlots).

Referenced by btObjectSpawnObjectsForList().

Definition at line 96 of file sprite.h.

SPRITE_SECOND_PART

#define SPRITE_SECOND_PART SPRITE_PICTURE_TAG(2, 1)

What a two-part enemy's second part adds to its first (the Serpent, the Kraken, the Fusion Dragon, Poseidon and the Doom Dragon): the next sprite, its pictures two slots on, past the two slots a large enemy's first part takes.

Referenced by btEffectRunStarfieldFall() and btObjectSpawnObjectsForList().

Definition at line 102 of file sprite.h.

VRAM_CACHE_ENTRY_ACTOR_SHADOW

#define VRAM_CACHE_ENTRY_ACTOR_SHADOW 93

The VRAM cache entry of the actors' shared shadow (ActorShadowTiles), each sprite's part 1.

Referenced by btEffectSpriteCreateWithTiles(), fdActorShadowFreeTiles(), fdActorShadowLoadTiles(), fdActorSystemConfigure() and fdSpriteCreate().

Definition at line 174 of file sprite.h.

ANIM_OBJECT_COUNT

#define ANIM_OBJECT_COUNT 64

How many the actor system's pools hold: its sprites (HEAP_SLOT_SPRITES) and its sprite animations (HEAP_SLOT_SPRITE_ANIMATIONS).

Referenced by btAnimationObjectAllocateEmpty(), btEffectSpriteAcquire(), btEffectSpriteCreateWithTiles(), fdActorSailOnMap(), fdActorSystemConfigure(), fdSpriteAnimationAllocate() and fdSpriteCreate().

Definition at line 178 of file sprite.h.

SHADOW_HALF_WIDTH

#define SHADOW_HALF_WIDTH 8

A sprite's shadow, 16 by 8 pixels: its half width and half height, both doubled when the sprite is drawn double-size.

Referenced by fdRenderApplyProjectedPlacement(), fdRenderApplyProjectedPlacementAtDepth(), fdRenderPlaceProjectedSprite() and fdRenderPlaceSpritePartPair().

Definition at line 226 of file sprite.h.

SHADOW_HALF_HEIGHT

#define SHADOW_HALF_HEIGHT 4

Referenced by fdRenderApplyProjectedPlacement(), fdRenderApplyProjectedPlacementAtDepth() and fdRenderPlaceSpritePartPair().

Definition at line 227 of file sprite.h.

ANIM_STEP_NORMAL

#define ANIM_STEP_NORMAL 16

SPR_ANIMATION.step at normal speed, as fdActorSetAnimationSpeed sets it: a timed command's ticks run as written.

Referenced by btActionRunBuild(), btAutoBattleRunApproachAttack(), btAutoBattleRunAttackOrItem(), btDjinnRecoveryCountDownSide(), btEffectRunAgingGas(), btEffectRunAstralBlast(), btEffectRunCastingImpact(), btEffectRunCriticalHit(), btEffectRunDjinniCharge(), btEffectRunFireDance(), btEffectRunFlashingStrike(), btEffectRunGaspFamily(), btEffectRunGeode(), btEffectRunHeavyBlow(), btEffectRunMegiddo(), btEffectRunMineBall(), btEffectRunOdyssey(), btEffectRunRagnarok(), btEffectRunRisingDragon(), btEffectRunRushingStrike(), btEffectRunStoneJustice(), btEffectRunVolleyWithAction(), btEffectRunWyrdCurse(), btMotionCallBeast(), btObjectUpdatePose(), btProcessTurnEnd(), btStagingRunAttack(), btStagingRunItem(), btStagingRunPsynergyCast(), btUnitProcessActionEnd(), fdActorCrossRope(), fdActorCrossTightrope(), fdActorSpawnWaterSplash(), fdActorSteerByPad(), fdLeaderSlideOnIce(), fdLeaderSlideOnIceAhead(), fdPsynergyEndSand(), fdPsynergyResumeHaltedActor(), fdPsynergySand(), fdPsynergyStartCast(), fdPsynergyTremorOnTarget(), fdTalkToActor(), mnSanctumRunMemberIconBurst(), scAirsRockInsideDriftMote(), scAirsRockInsideMovePooledWhirlwind(), scAirsRockInsideMoveWhirlwind(), scAirsRockInsideUpdateVentPuff(), scAirsRockMoveWhirlwind(), scGabombaStatuePauseCogsInMenus(), scGaiaRockInsideRestoreSusa() and 15 more.

Definition at line 254 of file sprite.h.

DJINNI_ANIMATION_EXCITED

#define DJINNI_ANIMATION_EXCITED 3

A Djinni's lively animation on the four Djinn sprite sheets, facing the player: Venus bounces, Mars, Jupiter and Mercury wave their arms. It plays as the Djinni shrinks away on joining.

Referenced by fdDjinnRunMarsJoinEffect() and fdDjinnRunVenusJoinEffect().

Definition at line 376 of file sprite.h.

Enumerations in detail

SPR_COL_MODE

enum SPR_COL_MODE

SPR_ANIMATION.param: how fdRenderDecodePicture colours a layer's pixels. Modes 1 to 6 and 9 to 11 run them through a 256-byte table (the five SpriteColorTables, then SpriteColorGreyTable and SpriteColorTintTables); the solid modes paint every drawn pixel one colour of the basic sprite palette. Mode 8 is a second white, and mode 12 (SPRITE_COLOR_DARK) reads past the tables, used for the light grey footprints Breath shows in the sand of the Shrine of the Sea God and the beacon's fire on Mars Lighthouse as it goes out.

EnumeratorValueDescription
SPRITE_COLOR_NORMAL0
SPRITE_COLOR_GRB1red and green swapped
SPRITE_COLOR_RBG2green and blue swapped
SPRITE_COLOR_BGR3red and blue swapped
SPRITE_COLOR_GBR4red to blue, green to red, blue to green
SPRITE_COLOR_BRG5red to green, green to blue, blue to red
SPRITE_COLOR_GREY6greyscale
SPRITE_COLOR_WHITE7solid colour 15, white
SPRITE_COLOR_BLUE_TINT9blue raised to full
SPRITE_COLOR_RED_TINT10red raised to full
SPRITE_COLOR_GREEN_TINT11green raised to full
SPRITE_COLOR_DARK12drawn dark (reads past the colour tables)
SPRITE_COLOR_FILL13solid DecodeFillByte
SPRITE_COLOR_BLACK14solid colour 1, black
SPRITE_COLOR_HIDDEN15solid colour 0, transparent

Definition at line 21 of file sprite.h.

SPR_FLAG

enum SPR_FLAG

SPR.flags.

EnumeratorValueDescription
SPRITE_FLAG_SHADOW1 << 0Its shadow is drawn; set when created.
SPRITE_FLAG_OUTLINED1 << 1Drawn as an outline, in the actor system's edge and fill colours.
SPRITE_FLAG_SHADED1 << 2Its bottom sunkRows rows drawn in shade, as the leader wading (fdActorUpdatePlayerControl).
SPRITE_FLAG_SUNK1 << 3Drawn sunkRows rows lower, its bottom cut off, as sinking in Taopo Swamp's mud; it takes the place of SPRITE_FLAG_SHADED.
SPRITE_FLAG_KEEP_PICTURE1 << 5Keeps the picture last drawn and only turns to mirror it: set once a battle's motion releases the buffer its layer drew from (btMotionReleaseBuffer).

Definition at line 154 of file sprite.h.

ANIMATION_COMMAND

enum ANIMATION_COMMAND

Animation script commands. Commands ANIMCMD_UNUSED_FIRST to ANIMCMD_UNUSED_LAST are not used by any script and are skipped (ANIMCMD_WAIT lies among them); 251 is not one and shows as a picture.

EnumeratorValueDescription
ANIMCMD_END239blank the layer and stop its script
ANIMCMD_SET_KIND240use facing table arg
ANIMCMD_HOLD241stay on this command and tick for good
ANIMCMD_OFFSET_Y242set the sprite's offsetY to arg
ANIMCMD_OFFSET_X243set the sprite's offsetX to arg
ANIMCMD_UNUSED_FIRSTANIMCMD_OFFSET_X + 1
ANIMCMD_WAIT245keep the current tick arg ticks longer
ANIMCMD_UNUSED_LAST250
ANIMCMD_SOUND252play sound arg
ANIMCMD_JUMP253continue at script position arg
ANIMCMD_PLAY254switch to animation arg
ANIMCMD_BLANK255show nothing for arg

Definition at line 259 of file sprite.h.

ACTOR_ANIMATION

enum ACTOR_ANIMATION

Animation numbers of a person's sprite, for fdActorSetAnimation. A sprite that is not a person (a bird, a dragon, a pillar) numbers its own.

EnumeratorValueDescription
ANIM_STILL0Standing still: the sprite's first frame held, without the blinks and small gestures of ANIM_STAND.
ANIM_STAND1
ANIM_WALK2
ANIM_NOD3
ANIM_SHAKE_HEAD4
ANIM_LEADER_RUN5Running, leaning forward, four ticks a step to the walk's six. This and the leader's other poses below are as the leader's sprite draws them.
ANIM_LEADER_SPRING6Leaning back for a moment before a jump.
ANIM_LEADER_LEAP7In mid-stride, leaning forward.
ANIM_PUSH8The leader leaning into what it pushes, as when it walks into a pushable actor (fdActorUpdatePlayerControl).
ANIM_LEADER_LOOK_AROUND9ANIM_STAND's idle with more glances to each side, as when the leader's step is blocked.
ANIM_LEADER_CLIMB10Climbing a wall, seen from behind.
ANIM_LEADER_CLIMB_OVER_TOP11Stepping off the top of a ladder onto the ground above.
ANIM_LEADER_CLING12Still on a wall, seen from behind.
ANIM_LEADER_CLIMB_DOWN_FROM_TOP13ANIM_LEADER_CLIMB_OVER_TOP played backwards: stepping from the top of a ladder onto its rungs.
ANIM_LEADER_CLIMB_EAST14Reaching along a wall as he climbs east.
ANIM_LEADER_CLIMB_WEST15Reaching along a wall as he climbs west.
ANIM_LEADER_SWING16Leaping from a hanging vine, stretched out level in the air.
ANIM_CAST_PSYNERGY17Holding out a glowing hand, as the party's sprites cast Psynergy.
ANIM_LEADER_TUMBLE_IN_WATER18Tumbling head over heels in a burst of spray, as a current sweeps the leader along.
ANIM_COLLAPSE19Lying collapsed on the ground.
ANIM_CAST_PSYNERGY_START20ANIM_CAST_PSYNERGY's first two
ANIM_CAST_PSYNERGY_END21pictures, held on the second, and its last two, held on the last with the hand held out: the caster's start and end of a field Psynergy.
ANIM_LEADER_LEAN_BACK22Leaning back, his head thrown back.
ANIM_LEADER_ARRIVE_ALTERNATE23The arrivals and leavings of the animated exits, each four ticks of the leader turning: an arrival grows from a small figure seen side-on to full size facing the player, a leaving turns from his back to side-on as he shrinks and is then hidden.
ANIM_LEADER_ARRIVE24
ANIM_LEADER_LEAVE_ALTERNATE25
ANIM_LEADER_LEAVE26
ANIM_LEADER_WALK_BACKWARDS27ANIM_WALK's six pictures in reverse order.
ANIM_LEADER_ARMS_RAISED28Both arms raised over his head.
ANIM_LEADER_CROSS_ROPE29Hanging from a rope by his hands as he crosses it.
ANIM_PARTY_RUN30ANIM_LEADER_RUN again, on every party member's sprite sheet.
ANIM_LEADER_HANG32Hanging from a vine, seen from behind with an arm raised.
ANIM_LEADER_FALL_ON_FACE36Slumping and falling forward onto his face, then lying there: the leader as the whole party falls.
ANIM_LEADER_STILL38ANIM_STILL's picture held again on the leader's sprite sheet: the leader standing as he lands on a statue that rose under him.
ANIM_LEADER_TOSS39Swinging an arm out to throw something.
ANIM_LEADER_FLAIL40Seen from behind, arms flung up and waving: the leader carried over a waterfall.
ANIM_LEADER_LIE_ON_BACK41Lying on his back, seen from his
ANIM_LEADER_SIT_UP42feet: the leader washed up or put to bed. Sitting up, legs out in front of him.
ANIM_LEADER_SWING_RIGHT_ARM45Swinging each arm and kicking out each leg, as Felix checks himself for injuries on Idejima's beach.
ANIM_LEADER_SWING_LEFT_ARM46
ANIM_LEADER_KICK_RIGHT_LEG47
ANIM_LEADER_KICK_LEFT_LEG48
ANIM_LEADER_SIT49Sitting on the floor, legs out, arms flung up and then lowered: the leader knocked down.

Definition at line 277 of file sprite.h.

PARTICLE_ANIMATION

enum PARTICLE_ANIMATION

SPRITE_PARTICLE's animations.

EnumeratorValueDescription
ANIM_PARTICLE_FADE2Its glow shrinking to a speck and gone.
ANIM_PARTICLE_TWINKLE7Its full glow and the next size down in turn, 3 ticks each.
ANIM_PARTICLE_SLOW_SWELL9Its swells, from a speck to its full glow,
ANIM_PARTICLE_QUICK_SWELL10held 32 ticks, and back: slowly, 12 ticks a step, or quickly, 6. Jupiter Lighthouse's sparks and the motes of light inside Air's Rock take turns at them.

Definition at line 379 of file sprite.h.