include/field/sprite.h
Animated sprites: their layers, the sprite picture caches and the actor system's state.
#include "edition.h"#include "fixed_math.h"#include "types.h"#include "static_assert.h"#include "graphics/render_placement.h"
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
| Name | Description | |
|---|---|---|
struct | SPR_ANIMATION | One animation layer of a sprite: its animation id, pictures, running script and timer. |
struct | SPR_PICTURE_CACHE | A sprite picture cache: the tag of the animation loaded into it (slot number and animation id) and the buffer holding its pictures. |
struct | ACTOR_SYSTEM_STATE | The 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). |
struct | ANIMATION_SPR_PART | The 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. |
struct | SPR | An animated sprite: its image, scale, rotation, size, its shadow and up to four sprite animations. |
struct | PLACED_SPR | An 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
| Name | Description | |
|---|---|---|
#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. |
#define | SPRITE_PICTURE_NONE 255 | SPR_ANIMATION.picture and pictureBase when no picture is shown. |
#define | SPRITE_ANIMATION_KEEP_PLACE 0x80 | An animation number's bit 7: keep the place and timer of the script already running. |
#define | SPRITE_ANIMATION_INDEX_MASK 0x7f | |
#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. |
#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. |
#define | SPRITE_ID_MASK 0xfff | A battle sprite id's low twelve bits, the sprite. |
#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. |
#define | VRAM_CACHE_ENTRY_ACTOR_SHADOW 93 | The VRAM cache entry of the actors' shared shadow (ActorShadowTiles), each sprite's part 1. |
#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). |
#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. |
#define | SHADOW_HALF_HEIGHT 4 | |
#define | ANIM_STEP_NORMAL 16 | SPR_ANIMATION.step at normal speed, as fdActorSetAnimationSpeed sets it: a timed command's ticks run as written. |
#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. |
Enumerations
| Name | Description | |
|---|---|---|
enum | SPR_COL_MODE { SPRITE_COLOR_NORMAL, SPRITE_COLOR_GRB, SPRITE_COLOR_RBG, SPR … } | SPR_ANIMATION.param: how fdRenderDecodePicture colours a layer's pixels. |
enum | SPR_FLAG { SPRITE_FLAG_SHADOW, SPRITE_FLAG_OUTLINED, SPRITE_FLAG_SHADED … } | SPR.flags. |
enum | ANIMATION_COMMAND { ANIMCMD_END, ANIMCMD_SET_KIND, ANIMCMD_HOLD, ANIMCMD_OFFSET_ … } | Animation script commands. |
enum | ACTOR_ANIMATION { ANIM_STILL, ANIM_STAND, ANIM_WALK, ANIM_NOD, ANIM_SHAKE_HEAD … } | Animation numbers of a person's sprite, for fdActorSetAnimation. |
enum | PARTICLE_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
SPRITE_COLOR_BLINK
#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.
| Enumerator | Value | Description |
|---|---|---|
SPRITE_COLOR_NORMAL | 0 | |
SPRITE_COLOR_GRB | 1 | red and green swapped |
SPRITE_COLOR_RBG | 2 | green and blue swapped |
SPRITE_COLOR_BGR | 3 | red and blue swapped |
SPRITE_COLOR_GBR | 4 | red to blue, green to red, blue to green |
SPRITE_COLOR_BRG | 5 | red to green, green to blue, blue to red |
SPRITE_COLOR_GREY | 6 | greyscale |
SPRITE_COLOR_WHITE | 7 | solid colour 15, white |
SPRITE_COLOR_BLUE_TINT | 9 | blue raised to full |
SPRITE_COLOR_RED_TINT | 10 | red raised to full |
SPRITE_COLOR_GREEN_TINT | 11 | green raised to full |
SPRITE_COLOR_DARK | 12 | drawn dark (reads past the colour tables) |
SPRITE_COLOR_FILL | 13 | solid DecodeFillByte |
SPRITE_COLOR_BLACK | 14 | solid colour 1, black |
SPRITE_COLOR_HIDDEN | 15 | solid colour 0, transparent |
Definition at line 21 of file sprite.h.
SPR_FLAG
enum SPR_FLAG
SPR.flags.
| Enumerator | Value | Description |
|---|---|---|
SPRITE_FLAG_SHADOW | 1 << 0 | Its shadow is drawn; set when created. |
SPRITE_FLAG_OUTLINED | 1 << 1 | Drawn as an outline, in the actor system's edge and fill colours. |
SPRITE_FLAG_SHADED | 1 << 2 | Its bottom sunkRows rows drawn in shade, as the leader wading (fdActorUpdatePlayerControl). |
SPRITE_FLAG_SUNK | 1 << 3 | Drawn 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_PICTURE | 1 << 5 | Keeps 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.
| Enumerator | Value | Description |
|---|---|---|
ANIMCMD_END | 239 | blank the layer and stop its script |
ANIMCMD_SET_KIND | 240 | use facing table arg |
ANIMCMD_HOLD | 241 | stay on this command and tick for good |
ANIMCMD_OFFSET_Y | 242 | set the sprite's offsetY to arg |
ANIMCMD_OFFSET_X | 243 | set the sprite's offsetX to arg |
ANIMCMD_UNUSED_FIRST | ANIMCMD_OFFSET_X + 1 | |
ANIMCMD_WAIT | 245 | keep the current tick arg ticks longer |
ANIMCMD_UNUSED_LAST | 250 | |
ANIMCMD_SOUND | 252 | play sound arg |
ANIMCMD_JUMP | 253 | continue at script position arg |
ANIMCMD_PLAY | 254 | switch to animation arg |
ANIMCMD_BLANK | 255 | show 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.
| Enumerator | Value | Description |
|---|---|---|
ANIM_STILL | 0 | Standing still: the sprite's first frame held, without the blinks and small gestures of ANIM_STAND. |
ANIM_STAND | 1 | |
ANIM_WALK | 2 | |
ANIM_NOD | 3 | |
ANIM_SHAKE_HEAD | 4 | |
ANIM_LEADER_RUN | 5 | Running, 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_SPRING | 6 | Leaning back for a moment before a jump. |
ANIM_LEADER_LEAP | 7 | In mid-stride, leaning forward. |
ANIM_PUSH | 8 | The leader leaning into what it pushes, as when it walks into a pushable actor (fdActorUpdatePlayerControl). |
ANIM_LEADER_LOOK_AROUND | 9 | ANIM_STAND's idle with more glances to each side, as when the leader's step is blocked. |
ANIM_LEADER_CLIMB | 10 | Climbing a wall, seen from behind. |
ANIM_LEADER_CLIMB_OVER_TOP | 11 | Stepping off the top of a ladder onto the ground above. |
ANIM_LEADER_CLING | 12 | Still on a wall, seen from behind. |
ANIM_LEADER_CLIMB_DOWN_FROM_TOP | 13 | ANIM_LEADER_CLIMB_OVER_TOP played backwards: stepping from the top of a ladder onto its rungs. |
ANIM_LEADER_CLIMB_EAST | 14 | Reaching along a wall as he climbs east. |
ANIM_LEADER_CLIMB_WEST | 15 | Reaching along a wall as he climbs west. |
ANIM_LEADER_SWING | 16 | Leaping from a hanging vine, stretched out level in the air. |
ANIM_CAST_PSYNERGY | 17 | Holding out a glowing hand, as the party's sprites cast Psynergy. |
ANIM_LEADER_TUMBLE_IN_WATER | 18 | Tumbling head over heels in a burst of spray, as a current sweeps the leader along. |
ANIM_COLLAPSE | 19 | Lying collapsed on the ground. |
ANIM_CAST_PSYNERGY_START | 20 | ANIM_CAST_PSYNERGY's first two |
ANIM_CAST_PSYNERGY_END | 21 | pictures, 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_BACK | 22 | Leaning back, his head thrown back. |
ANIM_LEADER_ARRIVE_ALTERNATE | 23 | The 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_ARRIVE | 24 | |
ANIM_LEADER_LEAVE_ALTERNATE | 25 | |
ANIM_LEADER_LEAVE | 26 | |
ANIM_LEADER_WALK_BACKWARDS | 27 | ANIM_WALK's six pictures in reverse order. |
ANIM_LEADER_ARMS_RAISED | 28 | Both arms raised over his head. |
ANIM_LEADER_CROSS_ROPE | 29 | Hanging from a rope by his hands as he crosses it. |
ANIM_PARTY_RUN | 30 | ANIM_LEADER_RUN again, on every party member's sprite sheet. |
ANIM_LEADER_HANG | 32 | Hanging from a vine, seen from behind with an arm raised. |
ANIM_LEADER_FALL_ON_FACE | 36 | Slumping and falling forward onto his face, then lying there: the leader as the whole party falls. |
ANIM_LEADER_STILL | 38 | ANIM_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_TOSS | 39 | Swinging an arm out to throw something. |
ANIM_LEADER_FLAIL | 40 | Seen from behind, arms flung up and waving: the leader carried over a waterfall. |
ANIM_LEADER_LIE_ON_BACK | 41 | Lying on his back, seen from his |
ANIM_LEADER_SIT_UP | 42 | feet: the leader washed up or put to bed. Sitting up, legs out in front of him. |
ANIM_LEADER_SWING_RIGHT_ARM | 45 | Swinging each arm and kicking out each leg, as Felix checks himself for injuries on Idejima's beach. |
ANIM_LEADER_SWING_LEFT_ARM | 46 | |
ANIM_LEADER_KICK_RIGHT_LEG | 47 | |
ANIM_LEADER_KICK_LEFT_LEG | 48 | |
ANIM_LEADER_SIT | 49 | Sitting 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.
| Enumerator | Value | Description |
|---|---|---|
ANIM_PARTICLE_FADE | 2 | Its glow shrinking to a speck and gone. |
ANIM_PARTICLE_TWINKLE | 7 | Its full glow and the next size down in turn, 3 ticks each. |
ANIM_PARTICLE_SLOW_SWELL | 9 | Its swells, from a speck to its full glow, |
ANIM_PARTICLE_QUICK_SWELL | 10 | held 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.