src/field/field_sprite_viewer.c
The debug sprite viewer: one sprite shown once for each way it can face, in a ring, with up to four sprite animations laid over it and the keys to change each one's sprite, animation, priority and colour mode. More…
Included by field.c.
Structures
| Name | Description | |
|---|---|---|
struct | SPR_VIEWER_LAYER | One sprite animation the sprite viewer edits. |
Macros
| Name | Description | |
|---|---|---|
#define | ANGLE_BITS 16 | An angle's bits: shifted up and back down, a value keeps only them. |
#define | SPRITE_VIEWER_DEFINE_SET_LAYER (name, field) | Defines name(layerIndex, value), which sets field of sprite animation layerIndex (0 to 3) of each of the viewer's ten sprites to value. |
Enumerations
| Name | Description | |
|---|---|---|
enum | anonymous enum { SPRITE_VIEWER_COPY_COUNT, SPRITE_VIEWER_SPRITE_LIMIT, SPRITE … } | |
enum | SPR_VIEWER_EDIT_MODE { SPRITE_VIEWER_EDIT_ANIMATION, SPRITE_VIEWER_EDIT_SPRITE, SPR … } | What left and right choose for L and R to change on the selected sprite animation. |
Functions
| Name | Description | |
|---|---|---|
void | fdSpriteViewerRun (void) | A debug sprite viewer, which never returns. |
Sint32 | fdSpriteViewerStepSpriteId (Sint32 spriteId, Sint32 direction) | Returns the next sprite id after spriteId, stepping by direction (1 or -1) and wrapping within 0-511, whose metadata has an image (a nonzero width). |
void | fdSpriteViewerLayOutRing (Sint32 centerX, Sint32 centerY, SPR_PLACEMENT *positions) | Lays out the sprite viewer's ring around (centerX, centerY), in pixels: one position per facing of the first sprite's facing kind (6, 8, 10 or 4, or two opposite pairs for ANIM_FACING_TWO_PART), 56 pixels out (40 for a two-part sprite). |
void | fdSpriteViewerStartStaggeredAnimations (Sint32 layerIndex, Sint32 animationIndex) | Starts animationIndex on layerIndex of each of the viewer's ten sprites, each one a tick (16 timer units) behind the last, so the copies are staggered. |
void | fdSpriteViewerSetLayerSprite (Sint32 layerIndex, Sint32 spriteId) | Sets spriteId on layerIndex of each of the viewer's ten sprites. |
void | fdSpriteViewerPlaceRing (void) | Each tick in the sprite viewer: places each copy of the sprite at its ring position, facing the way that position stands for. |
Variables
| Name | Description | |
|---|---|---|
extern const SPR_SCALE | SpriteViewerScale | The debug sprite viewer's ring scale (sprite_viewer_scale.c). |
Description
The debug sprite viewer: one sprite shown once for each way it can face, in a
ring, with up to four sprite animations laid over it and the keys to change
each one's sprite, animation, priority and colour mode. Part of field.c.
Macros in detail
ANGLE_BITS
#define ANGLE_BITS 16
An angle's bits: shifted up and back down, a value keeps only them.
Referenced by fdSpriteViewerLayOutRing().
Definition at line 25 of file field_sprite_viewer.c.
SPRITE_VIEWER_DEFINE_SET_LAYER
#define SPRITE_VIEWER_DEFINE_SET_LAYER(name, field)
Defines name(layerIndex, value), which sets field of sprite animation
layerIndex (0 to 3) of each of the viewer's ten sprites to value.
Definition at line 617 of file field_sprite_viewer.c.
Enumerations in detail
anonymous enum
enum { SPRITE_VIEWER_COPY_COUNT, SPRITE_VIEWER_SPRITE_LIMIT, SPRITE_VIEWER_ANIMATION_LIMIT, SPRITE_VIEWER_HIDDEN_PRIORITY, … }
| Enumerator | Value | Description |
|---|---|---|
SPRITE_VIEWER_COPY_COUNT | 10 | The copies of the sprite and their places on the ring; a facing kind uses 4, 6, 8 or 10 of them (fdSpriteViewerLayOutRing). |
SPRITE_VIEWER_SPRITE_LIMIT | 512 | Sprite ids 0 to 511 are offered. |
SPRITE_VIEWER_ANIMATION_LIMIT | 100 | Animations 0 to 99. |
SPRITE_VIEWER_HIDDEN_PRIORITY | 8 | A sprite animation priority above 3, which fdSpriteComposePicture skips. |
SPRITE_VIEWER_FAST_STEP | 10 | The sprites with an image L and R step over while Start is held. |
Definition at line 10 of file field_sprite_viewer.c.
SPR_VIEWER_EDIT_MODE
enum SPR_VIEWER_EDIT_MODE
What left and right choose for L and R to change on the selected sprite animation.
| Enumerator | Value | Description |
|---|---|---|
SPRITE_VIEWER_EDIT_ANIMATION | ||
SPRITE_VIEWER_EDIT_SPRITE | ||
SPRITE_VIEWER_EDIT_PRIORITY | ||
SPRITE_VIEWER_EDIT_COLOR | ||
SPRITE_VIEWER_EDIT_COUNT |
Definition at line 29 of file field_sprite_viewer.c.
Functions in detail
fdSpriteViewerRun
void fdSpriteViewerRun(void)
A debug sprite viewer, which never returns. It shows a sprite (with up to three more sprite animations) once for each of its facings, in a ring.
References DebugMode, DecodeFillByte, fdActorSystemInit(), fdSpriteAddAnimation(), fdSpriteCreate(), fdSpritePictureCacheLoad(), fdSpriteViewerLayOutRing(), fdSpriteViewerPlaceRing(), fdSpriteViewerSetLayerColorMode(), fdSpriteViewerSetLayerPriority(), fdSpriteViewerSetLayerSprite(), fdSpriteViewerStartStaggeredAnimations(), fdSpriteViewerStepSpriteId(), PerData, PerPush, PerRepeat, Sint32, StubsResource, syDummyReturnZero(), syHeapInit(), syHeapSlotAllocateEWRAM(), syInitEvent(), syResourceGetMetadataRecordStub(), syScreenFadeFromBlack(), sySetEvent(), sySynch() and syVRAMCacheReset().
Definition at line 50 of file field_sprite_viewer.c.
fdSpriteViewerStepSpriteId
Sint32 fdSpriteViewerStepSpriteId(Sint32 spriteId, Sint32 direction)
Returns the next sprite id after spriteId, stepping by direction (1 or -1) and wrapping within 0-511, whose metadata has an image (a nonzero width).
References Sint32 and syResourceGetMetadataRecordStub().
Referenced by fdSpriteViewerRun().
Definition at line 457 of file field_sprite_viewer.c.
fdSpriteViewerLayOutRing
void fdSpriteViewerLayOutRing(Sint32 centerX, Sint32 centerY, SPR_PLACEMENT *positions)
Lays out the sprite viewer's ring around (centerX, centerY), in pixels: one
position per facing of the first sprite's facing kind (6, 8, 10 or 4, or two
opposite pairs for ANIM_FACING_TWO_PART), 56 pixels out (40 for a two-part
sprite).
References FrameCount, PerData, Sint32, sySpritePlacementValues() and syVectorAddPolarOffset().
Referenced by fdSpriteViewerRun().
Definition at line 488 of file field_sprite_viewer.c.
fdSpriteViewerStartStaggeredAnimations
void fdSpriteViewerStartStaggeredAnimations(Sint32 layerIndex, Sint32 animationIndex)
Starts animationIndex on layerIndex of each of the viewer's ten sprites, each one a tick (16 timer units) behind the last, so the copies are staggered. Also sets each copy's offsetY and clears its rotation.
References Sint32 and syResourceGetMetadataRecordStub().
Referenced by fdSpriteViewerRun().
Definition at line 639 of file field_sprite_viewer.c.
fdSpriteViewerSetLayerSprite
void fdSpriteViewerSetLayerSprite(Sint32 layerIndex, Sint32 spriteId)
Sets spriteId on layerIndex of each of the viewer's ten sprites. Resets each sprite animation from its new metadata.
References fdSpriteAnimationReset(), Sint32 and syResourceGetMetadataRecordStub().
Referenced by fdSpriteViewerRun().
Definition at line 679 of file field_sprite_viewer.c.
fdSpriteViewerPlaceRing
void fdSpriteViewerPlaceRing(void)
Each tick in the sprite viewer: places each copy of the sprite at its ring position, facing the way that position stands for.
References fdRenderApplyProjectedPlacement() and SpriteViewerScale.
Referenced by fdSpriteViewerRun().
Definition at line 700 of file field_sprite_viewer.c.