Sprites, their animation layers and the resource slots they draw from. More...
Go to the source code of this file.
Data Structures | |
| struct | ResourceSlotNumber |
| A row of gResourceSlot_NumberTable: the packed resource that holds an animation number's frames, ending at number 0. More... | |
Enumerations | |
| enum | { ANIMATION_SHADOW_CACHE_ENTRY = 93 , ANIMATION_SHADOW_TILE_BYTES = 16 * 8 , ANIMATION_OAM_FULL_COLOR = 1 << 13 , ANIMATION_OAM_PRIORITY_2 = 2 << 10 , ANIMATION_OAM_WIDE = 1 << 14 } |
Functions | |
| s32 | ResourceSlot_Load (u32 slot, u32 *buffer, s32 number, u32 variant) |
| Loads the frames of animation id number into resource slot slot's buffer: the resource listed for it in gResourceSlot_NumberTable, decoded, its frame offsets turned into pointers, and for variant 1-5 its pixel colours (those up to 0xdf) remapped through that variant's conversion table. | |
| s32 | Animation_LookupValueByKey (s32 tag) |
| Returns the buffer loaded into the resource slot with this tag, or 0. | |
| s32 | Animation_InitializeObjects (struct AnimationObject *sprite) |
| Resets each layer of a sprite from its animation's metadata: its facing kind, frames, scripts and codec, with no frame shown and no script running. | |
| void | Animation_InitWorkFromMetadata (struct AnimationEntry *layer) |
| Resets one animation layer from its animation's metadata, as Animation_InitializeObjects does for each layer. | |
| s32 | ResourceMetadata_Register (struct AnimationObject *sprite, s32 id) |
| Adds a layer of animation id to a sprite, in its first free layer of four. | |
| void | ResourceMetadata_Unregister (struct AnimationObject *sprite, s32 layer) |
| Removes the layer handle from a sprite and clears it, trimming the sprite's layer count when no later layer remains. | |
| void | ResourceMetadata_ReleaseSlot (struct AnimationObject *sprite, u32 index) |
| Removes and clears a sprite's layer number no (0-3), trimming the sprite's layer count when no later layer remains. | |
| void | Animation_SetWorkEntry (struct AnimationEntry *layer, s32 animation) |
| Starts the indexed animation on a layer when its metadata contains it. | |
| s32 | AnimationObjects_SelectAnimation (struct AnimationObject *sprite, s32 animation) |
| Starts animation flags & 0x7f on every layer of a sprite (bit 7 keeps each layer's place and timer), unless the sprite plays it already. | |
| s32 | AnimationObjects_SetActiveFrameTimers (struct AnimationObject *sprite, s32 frames) |
| Sets each animated layer's timer to the given duration in frames. | |
| void | AnimationObjects_SetActiveTimerSteps (struct AnimationObject *sprite, s32 step) |
| Sets the timer step, the animation speed, of each animated layer of a sprite (16 is normal speed). | |
| void | ObjectSystem_Configure (s32 mode) |
| Allocates and zeroes the 64 sprites and 64 animation layers (from the fixed blocks in mode 3, the heap otherwise), sets up the palette DMA, loads the shadow tiles into VRAM cache entry 93 and puts the sprite tile uploader in RAM. | |
| struct AnimationEntry * | AnimationObject_Allocate (s32 id) |
| Takes a free animation layer record and starts it on animation id's first animation. | |
| void | ResourceMetadata_ClearRecord (struct AnimationEntry *record) |
| Zeroes one animation layer (struct AnimationEntry); does nothing for NULL. | |
| struct AnimationObject * | ResourceObject_Create (s32 id) |
| Creates a sprite for animation id, taking one of the 64 free sprites and a VRAM cache entry for its tiles. | |
| void | ResourceObject_Release (struct AnimationObject *sprite) |
| Releases a sprite: its VRAM cache entry (unless retainCacheEntry is set), its four animation layers, and then zeroes its 56 bytes. | |
| s32 | ResourceMetadata_SumCommandLengths (s32 id, u32 animation, s32 frameCount) |
| Returns how long the first frameCount frames of animation number animation of id last: the sum of the arguments of its frame, wait and blank commands, up to frameCount of them or the first play, hold, jump or end command. | |
Variables | |
| struct ResourceSlotNumber | gResourceSlot_NumberTable [] |
Sprites, their animation layers and the resource slots they draw from.
Part of field.c, the field object, compiled only through it.
Definition in file animation.c.
| anonymous enum |
| Enumerator | |
|---|---|
| ANIMATION_SHADOW_CACHE_ENTRY | |
| ANIMATION_SHADOW_TILE_BYTES | 16x8 pixels, 256 colours |
| ANIMATION_OAM_FULL_COLOR | |
| ANIMATION_OAM_PRIORITY_2 | |
| ANIMATION_OAM_WIDE | |
Definition at line 7 of file animation.c.
Loads the frames of animation id number into resource slot slot's buffer: the resource listed for it in gResourceSlot_NumberTable, decoded, its frame offsets turned into pointers, and for variant 1-5 its pixel colours (those up to 0xdf) remapped through that variant's conversion table.
Returns the image's size in pixels (width * height), or 0 when the slot or id is not known. Sets the slot's tag to (slot << 12) | number and its buffer; with a null buffer and number 0 it does only that, which is how the battle frees a slot. Called by the sprite viewer and, as ResourceSlot_LoadFar, by the battle for its enemy sprites (variant is the class's palette).
Definition at line 34 of file animation.c.
Referenced by ResourceSlot_Load(), and Ui_RunIconMonitor().
Returns the buffer loaded into the resource slot with this tag, or 0.
An animation id that carries its slot in bits 12 and up finds its frames here; called by the layer set-up functions below.
Definition at line 103 of file animation.c.
Referenced by Animation_InitializeObjects(), Animation_InitWorkFromMetadata(), Animation_LookupValueByKey(), and AnimationObject_Allocate().
| s32 Animation_InitializeObjects | ( | struct AnimationObject * | sprite | ) |
Resets each layer of a sprite from its animation's metadata: its facing kind, frames, scripts and codec, with no frame shown and no script running.
The first layer also sets the sprite's size, scale and offsets. Returns 0. Called by Animation_SetIndexAndInitObjects.
Definition at line 118 of file animation.c.
Referenced by Animation_InitializeObjects(), and Animation_SetIndexAndInitObjects().
| void Animation_InitWorkFromMetadata | ( | struct AnimationEntry * | layer | ) |
Resets one animation layer from its animation's metadata, as Animation_InitializeObjects does for each layer.
Called by the sprite viewer.
Definition at line 160 of file animation.c.
Referenced by Animation_InitWorkFromMetadata(), and Ui_SetGridColumnNumber().
| s32 ResourceMetadata_Register | ( | struct AnimationObject * | sprite, |
| s32 | id ) |
Adds a layer of animation id to a sprite, in its first free layer of four.
The first layer also sets the sprite's size, scale and offsets. Returns the layer, 0 when no layer record is free, or -1 when the sprite has four layers already. Called by ResourceObject_Create for a sprite's first layer, by ObjectDispatch_RegisterChildMetadata and the sprite viewer, and as ResourceMetadata_RegisterFar by the battle, the Psynergy effects and the field scene's actors.
Definition at line 191 of file animation.c.
Referenced by AltinPeak_RollLog(), ObjectDispatch_RegisterChildMetadata(), ResourceMetadata_Register(), ResourceObject_Create(), and Ui_RunIconMonitor().
| void ResourceMetadata_Unregister | ( | struct AnimationObject * | sprite, |
| s32 | layer ) |
Removes the layer handle from a sprite and clears it, trimming the sprite's layer count when no later layer remains.
Called through ResourceMetadata_UnregisterFar by the battle's objects.
Definition at line 231 of file animation.c.
Referenced by ResourceMetadata_Unregister().
| void ResourceMetadata_ReleaseSlot | ( | struct AnimationObject * | sprite, |
| u32 | index ) |
Removes and clears a sprite's layer number no (0-3), trimming the sprite's layer count when no later layer remains.
Definition at line 258 of file animation.c.
Referenced by ResourceMetadata_ReleaseSlot().
| void Animation_SetWorkEntry | ( | struct AnimationEntry * | layer, |
| s32 | animation ) |
Starts the indexed animation on a layer when its metadata contains it.
Bit 7 preserves the command cursor and timer; it remains part of the index. Reached through the animation script's play command (Sprite_ComposeAnimationFrame) and, as Animation_SetWorkEntryFar, from the battle's motion and objects. XXX: unlike AnimationObjects_SelectAnimation it does not mask bit 7 off, so with bit 7 set the index passes animationCount only in a set of more than 128 animations; a script that plays with bit 7 would show whether that is an original bug.
Definition at line 289 of file animation.c.
Referenced by Animation_SetWorkEntry(), and Sprite_ComposeAnimationFrame().
| s32 AnimationObjects_SelectAnimation | ( | struct AnimationObject * | sprite, |
| s32 | animation ) |
Starts animation flags & 0x7f on every layer of a sprite (bit 7 keeps each layer's place and timer), unless the sprite plays it already.
The first layer's animation also sets the sprite's offsets. Returns 0. The engine's usual way to change what a sprite plays: called by the object dispatch and the player control, and as AnimationObjects_SelectAnimationFar by the battle, the shops, the menus, the battle and Psynergy effects and the scene scripts.
Definition at line 317 of file animation.c.
Referenced by AnimationObjects_SelectAnimation(), Bilibin_SpawnRiverEffect(), FieldObject_UpdatePlayerControl(), MercuryLighthouse_HopAcrossPool(), MercuryLighthouse_RestoreLights(), MercuryLighthouse_SpawnSparkPair(), Object_MoveOnWorldMap(), ObjectDispatch_SelectAnimation(), ObjectDispatch_SetAnimationAndSpeed(), OverlayObject_SpawnKind24AtObject(), OverlayObject_SpawnKind24AtObject(), SolSanctumEruption_SpawnEffectPair(), ValeHome_SpawnEffectPair(), VenusLighthouseAerie_SpawnLinkedPairEffects(), and WorldMap_CreateLinkedEffects().
| s32 AnimationObjects_SetActiveFrameTimers | ( | struct AnimationObject * | sprite, |
| s32 | frames ) |
Sets each animated layer's timer to the given duration in frames.
Returns 0.
Definition at line 367 of file animation.c.
Referenced by AnimationObjects_SetActiveFrameTimers().
| void AnimationObjects_SetActiveTimerSteps | ( | struct AnimationObject * | sprite, |
| s32 | step ) |
Sets the timer step, the animation speed, of each animated layer of a sprite (16 is normal speed).
Called by the object dispatch and, as AnimationObjects_SetActiveTimerStepsFar, by the Sanctum, which stops a party member's icon with 0 and restarts it with 16.
Definition at line 392 of file animation.c.
Referenced by AnimationObjects_SetActiveTimerSteps(), ObjectDispatch_SetAnimationAndSpeed(), and ObjectDispatch_SetAnimationSpeed().
| void ObjectSystem_Configure | ( | s32 | mode | ) |
Allocates and zeroes the 64 sprites and 64 animation layers (from the fixed blocks in mode 3, the heap otherwise), sets up the palette DMA, loads the shadow tiles into VRAM cache entry 93 and puts the sprite tile uploader in RAM.
Called by ObjectSystem_Initialize.
Definition at line 411 of file animation.c.
Referenced by ObjectSystem_Configure(), and ObjectSystem_Initialize().
| struct AnimationEntry * AnimationObject_Allocate | ( | s32 | id | ) |
Takes a free animation layer record and starts it on animation id's first animation.
Returns the layer, or NULL when none is free or the id has no image. Called by ResourceMetadata_Register.
Definition at line 445 of file animation.c.
Referenced by AnimationObject_Allocate(), and ResourceMetadata_Register().
| void ResourceMetadata_ClearRecord | ( | struct AnimationEntry * | record | ) |
Zeroes one animation layer (struct AnimationEntry); does nothing for NULL.
Zeroing kind frees the record for AnimationObject_Allocate. Called by the layer release functions here and, as ResourceMetadata_ClearRecordFar, by the Psynergy effects and scene scripts.
Definition at line 499 of file animation.c.
Referenced by AltinPeak_StopLogAndJumpOff(), Colosso_ShowItemIcon(), ResourceMetadata_ClearRecord(), ResourceMetadata_ReleaseSlot(), ResourceMetadata_Unregister(), and ResourceObject_Release().
| struct AnimationObject * ResourceObject_Create | ( | s32 | id | ) |
Creates a sprite for animation id, taking one of the 64 free sprites and a VRAM cache entry for its tiles.
Returns the sprite, or NULL when there is no room or the id has no image. Called by FieldObject_Create and the sprite viewer, and as ResourceObject_CreateFar by the battle, the battle effects, the Psynergy effects and the menus.
Definition at line 512 of file animation.c.
Referenced by FieldObject_Create(), ResourceObject_Create(), and Ui_RunIconMonitor().
| void ResourceObject_Release | ( | struct AnimationObject * | sprite | ) |
Releases a sprite: its VRAM cache entry (unless retainCacheEntry is set), its four animation layers, and then zeroes its 56 bytes.
Called by ObjectDispatch_Release and, as ResourceObject_ReleaseFar, by the battle and its effects, the Psynergy effects and the menus.
Definition at line 624 of file animation.c.
Referenced by ObjectDispatch_Release(), and ResourceObject_Release().
Returns how long the first frameCount frames of animation number animation of id last: the sum of the arguments of its frame, wait and blank commands, up to frameCount of them or the first play, hold, jump or end command.
Called through ResourceMetadata_SumCommandLengthsFar by the battle's staging.
Definition at line 646 of file animation.c.
Referenced by ResourceMetadata_SumCommandLengths().
|
extern |
Referenced by ResourceSlot_Load().