Alchemy
Loading...
Searching...
No Matches

sprite_viewer.c File Reference

A debug sprite viewer. More...

Go to the source code of this file.

Data Structures

struct  UiSpriteViewerLayer
 One animation layer the sprite viewer edits. More...

Macros

#define UI_DEFINE_SET_GRID_COLUMN(name, field)
 Defines name(slot, value), which sets field of entry slot (0-3) in each of the first ten sprites to value.

Enumerations

enum  { UI_SPRITE_VIEWER_COPY_COUNT = 10 , UI_SPRITE_VIEWER_SPRITE_LIMIT = 512 , UI_SPRITE_VIEWER_ANIMATION_LIMIT = 100 , UI_SPRITE_VIEWER_HIDDEN_PRIORITY = 8 }
enum  UiSpriteViewerEditMode {
  UI_SPRITE_VIEWER_EDIT_ANIMATION , UI_SPRITE_VIEWER_EDIT_SPRITE , UI_SPRITE_VIEWER_EDIT_PRIORITY , UI_SPRITE_VIEWER_EDIT_COLOR ,
  UI_SPRITE_VIEWER_EDIT_COUNT
}

Functions

void Ui_RunIconMonitor (void)
 A debug sprite viewer, which never returns.
s32 Ui_FindNextSpriteWithImage (s32 spriteId, s32 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 Map_BuildProbeRing (s32 centerX, s32 centerY, struct SpritePlacement *positions)
 Lays out the sprite viewer's ring around pixel (x, z): one position per facing of the first sprite's facing kind (6, 8, 10 or 4, or two opposite pairs for kind 20), 56 pixels out (40 for kind 20).
void Ui_SetGridColumnParameter (s32 layerIndex, s32 value)
 Sets the draw parameter or the priority of one layer of the viewer's ten sprites.
void Ui_SetGridColumnPriority (s32 layerIndex, s32 value)
void Ui_FillGridColumnFromMetadata (s32 layerIndex, s32 animationIndex)
 Starts animationIndex on layerIndex of each of the viewer's ten sprites, each one a frame (16 timer units) behind the last, so the copies are staggered.
void Ui_SetGridColumnNumber (s32 layerIndex, s32 spriteId)
 Sets spriteId on layerIndex of each of the viewer's ten sprites.
void Battle_PlaceActorsByFormationKind (void)
 Each frame in the sprite viewer: places each copy of the sprite at its ring position, facing the way that position stands for.

Detailed Description

A debug sprite viewer.

Part of field.c, the field object, compiled only through it.

Definition in file sprite_viewer.c.

Macro Definition Documentation

◆ UI_DEFINE_SET_GRID_COLUMN

#define UI_DEFINE_SET_GRID_COLUMN ( name,
field )
Value:
void name(s32 layerIndex, s32 value) { \
struct AnimationObject *spriteGroup = gSpriteObjects; \
s32 spriteIndex; \
\
layerIndex &= ANIMATION_LAYER_COUNT - 1; \
for (spriteIndex = 0; spriteIndex < UI_SPRITE_VIEWER_COPY_COUNT; \
spriteIndex++) { \
spriteGroup->entries[layerIndex]->field = value; \
spriteGroup++; \
} \
}
@ ANIMATION_LAYER_COUNT
struct AnimationObject * gSpriteObjects
@ UI_SPRITE_VIEWER_COPY_COUNT
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
Definition animspr.h:108
struct AnimationEntry * entries[4]
its layers; empty ones null
Definition animspr.h:130
signed int s32
Definition types.h:14

Defines name(slot, value), which sets field of entry slot (0-3) in each of the first ten sprites to value.

Definition at line 533 of file sprite_viewer.c.

Referenced by Ui_SetGridColumnParameter(), and Ui_SetGridColumnPriority().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UI_SPRITE_VIEWER_COPY_COUNT 
UI_SPRITE_VIEWER_SPRITE_LIMIT 
UI_SPRITE_VIEWER_ANIMATION_LIMIT 
UI_SPRITE_VIEWER_HIDDEN_PRIORITY 

Definition at line 7 of file sprite_viewer.c.

◆ UiSpriteViewerEditMode

Enumerator
UI_SPRITE_VIEWER_EDIT_ANIMATION 
UI_SPRITE_VIEWER_EDIT_SPRITE 
UI_SPRITE_VIEWER_EDIT_PRIORITY 
UI_SPRITE_VIEWER_EDIT_COLOR 
UI_SPRITE_VIEWER_EDIT_COUNT 

Definition at line 14 of file sprite_viewer.c.

Function Documentation

◆ Ui_RunIconMonitor()

void Ui_RunIconMonitor ( void )

A debug sprite viewer, which never returns.

It shows a sprite (with up to three more animation layers) once for each of its facings, in a ring. Start with the direction pad moves the ring; otherwise up and down choose a layer and left and right what to edit: 0 the animation, 1 the sprite number (ten at a time with Start), 2 the priority, 3 the draw parameter, changed with L and R. A restarts the animation, or in the other modes turns a layer on or off. Pressing Start toggles the shadows; B turns the ring when it is rebuilt with Start held. Select starts over; it passes a far-call resource set (the alternate one unless B is held) to RuntimeDispatch_ReturnZero, a stub that ignores it.

It has a bare veneer in the field far-call table, and no caller names it. Takes heap slot 9 for the ring of ten positions and runs Battle_PlaceActorsByFormationKind each frame to draw the copies.

Definition at line 45 of file sprite_viewer.c.

Referenced by Ui_RunIconMonitor().

◆ Ui_FindNextSpriteWithImage()

s32 Ui_FindNextSpriteWithImage ( s32 spriteId,
s32 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).

Called by Ui_RunIconMonitor.

Definition at line 386 of file sprite_viewer.c.

Referenced by Ui_FindNextSpriteWithImage(), and Ui_RunIconMonitor().

◆ Map_BuildProbeRing()

void Map_BuildProbeRing ( s32 centerX,
s32 centerY,
struct SpritePlacement * positions )

Lays out the sprite viewer's ring around pixel (x, z): one position per facing of the first sprite's facing kind (6, 8, 10 or 4, or two opposite pairs for kind 20), 56 pixels out (40 for kind 20).

B held turns the ring. Called by Ui_RunIconMonitor when it starts and while Start moves the ring.

Definition at line 415 of file sprite_viewer.c.

Referenced by Map_BuildProbeRing(), and Ui_RunIconMonitor().

◆ Ui_SetGridColumnParameter()

void Ui_SetGridColumnParameter ( s32 layerIndex,
s32 value )

Sets the draw parameter or the priority of one layer of the viewer's ten sprites.

Definition at line 548 of file sprite_viewer.c.

Referenced by Ui_RunIconMonitor(), and Ui_SetGridColumnParameter().

◆ Ui_SetGridColumnPriority()

void Ui_SetGridColumnPriority ( s32 layerIndex,
s32 value )

Definition at line 549 of file sprite_viewer.c.

Referenced by Ui_RunIconMonitor(), and Ui_SetGridColumnPriority().

◆ Ui_FillGridColumnFromMetadata()

void Ui_FillGridColumnFromMetadata ( s32 layerIndex,
s32 animationIndex )

Starts animationIndex on layerIndex of each of the viewer's ten sprites, each one a frame (16 timer units) behind the last, so the copies are staggered.

Also sets each copy's offsetY and clears its rotation. Called by Ui_RunIconMonitor.

Definition at line 555 of file sprite_viewer.c.

Referenced by Ui_FillGridColumnFromMetadata(), and Ui_RunIconMonitor().

◆ Ui_SetGridColumnNumber()

void Ui_SetGridColumnNumber ( s32 layerIndex,
s32 spriteId )

Sets spriteId on layerIndex of each of the viewer's ten sprites.

Resets each layer from its new metadata. Called by Ui_RunIconMonitor when a layer other than 0 gets a new sprite.

Definition at line 591 of file sprite_viewer.c.

Referenced by Ui_RunIconMonitor(), and Ui_SetGridColumnNumber().

◆ Battle_PlaceActorsByFormationKind()

void Battle_PlaceActorsByFormationKind ( void )

Each frame in the sprite viewer: places each copy of the sprite at its ring position, facing the way that position stands for.

Despite its name it belongs to the sprite viewer, which schedules it; its ring is the placements in heap slot 9 (HEAP_SLOT_BATTLE) and its sprites the pool in heap slot 4.

Definition at line 613 of file sprite_viewer.c.

Referenced by Battle_PlaceActorsByFormationKind(), and Ui_RunIconMonitor().