Alchemy
Loading...
Searching...
No Matches

sprites.c File Reference

Characters drawn into windows, and the per-frame sprite update. More...

Go to the source code of this file.

Data Structures

struct  SpriteOutput
 A view of struct RenderOutput with its sprite cell (from offset 0x10) as the member attr. More...

Macros

#define SPRITE_CELL(output)
 A render output's sprite cell: the link and OAM attributes in its 12 bytes from offset 0x10.
#define TILEMAP_WIDTH   32
#define TILEMAP_ENTRIES   (TILEMAP_WIDTH * 20)

Typedefs

typedef s32(*) GlyphRoutine(struct UiWindow *, u32, u32, u32, const u8 *)

Enumerations

enum  {
  TILEMAP_ENTRY_PLAIN , TILEMAP_ENTRY_NONE , TILEMAP_ENTRY_PALETTE_14 , TILEMAP_ENTRY_PALETTE_15 ,
  TILEMAP_ENTRY_PALETTE_1
}

Functions

s32 UiText_DrawGlyph (struct UiWindow *window, s32 character, s32 x, s32 y, s32 mode)
 Draws a character of a window's text with its top-left corner at pixel (x, y) of the window's interior and returns how far the text advances.
 STATIC_ASSERT (offsetof(struct SpriteOutput, x)==offsetof(struct RenderOutput, x))
 STATIC_ASSERT (offsetof(struct SpriteOutput, y)==offsetof(struct RenderOutput, y))
 STATIC_ASSERT (offsetof(struct SpriteOutput, active)==offsetof(struct RenderOutput, active))
 STATIC_ASSERT (offsetof(struct SpriteOutput, animStep)==offsetof(struct RenderOutput, animStep))
 STATIC_ASSERT (offsetof(struct SpriteOutput, index)==offsetof(struct RenderOutput, index))
 STATIC_ASSERT (offsetof(struct SpriteOutput, attr)==offsetof(struct RenderOutput, unk10))
void UiWindow_PutGlyph (struct UiWindow *win, u32 tile, u32 x, u32 y, s32 mode)
 Puts a character into a window's tilemap as a tile at tile (x, y) of its interior.
void UiWindow_SetTilemapEntry (struct UiWindow *window, s32 value, s32 x, s32 y, u32 mode)
 Writes value into a window's tilemap at tile (x, y) of its interior, with the palette mode names (TILEMAP_ENTRY_), or as it is for TILEMAP_ENTRY_PLAIN; TILEMAP_ENTRY_NONE writes nothing.
void RenderOutput_UpdateScaleAnimation (struct RenderOutput *output)
 Steps a scaling sprite's animation (UI_SPRITE_SWELL to UI_SPRITE_SHRINK_HALF) and sets its affine scale for this frame.
void UiWork_AnimateSpriteSlots (void)
 The per-frame sprite update: moves each sprite that an open window carries by its animation mode (UI_SPRITE_) and queues it for drawing.

Detailed Description

Characters drawn into windows, and the per-frame sprite update.

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

Definition in file sprites.c.

Macro Definition Documentation

◆ SPRITE_CELL

#define SPRITE_CELL ( output)
Value:
((struct CursorSprite *)(output)->unk10)
A cursor or prompt sprite: a list link and its OAM attributes as fields.
Definition menu_list.h:50

A render output's sprite cell: the link and OAM attributes in its 12 bytes from offset 0x10.

Definition at line 11 of file sprites.c.

Referenced by RenderOutput_UpdateScaleAnimation(), and UiText_DrawGlyph().

◆ TILEMAP_WIDTH

#define TILEMAP_WIDTH   32

Definition at line 339 of file sprites.c.

Referenced by UiWindow_SetTilemapEntry().

◆ TILEMAP_ENTRIES

#define TILEMAP_ENTRIES   (TILEMAP_WIDTH * 20)

Definition at line 340 of file sprites.c.

Referenced by UiWindow_SetTilemapEntry().

Typedef Documentation

◆ GlyphRoutine

typedef s32(*) GlyphRoutine(struct UiWindow *, u32, u32, u32, const u8 *)

Definition at line 7 of file sprites.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
TILEMAP_ENTRY_PLAIN 
TILEMAP_ENTRY_NONE 
TILEMAP_ENTRY_PALETTE_14 
TILEMAP_ENTRY_PALETTE_15 
TILEMAP_ENTRY_PALETTE_1 

Definition at line 331 of file sprites.c.

Function Documentation

◆ UiText_DrawGlyph()

s32 UiText_DrawGlyph ( struct UiWindow * window,
s32 character,
s32 x,
s32 y,
s32 mode )

Draws a character of a window's text with its top-left corner at pixel (x, y) of the window's interior and returns how far the text advances.

A text canvas window draws it into the canvas; other windows show it as a sprite carried by the window. mode 1 shows the next-page arrow instead.

Definition at line 17 of file sprites.c.

Referenced by UiText_DrawGlyph(), UiText_GetResourceDimensionsAlt(), UiText_RenderWideStringAtOffset(), and UiWork_StepChannelScript().

◆ STATIC_ASSERT() [1/6]

STATIC_ASSERT ( offsetof(struct SpriteOutput, x) = =offsetof(struct RenderOutput, x))

◆ STATIC_ASSERT() [2/6]

STATIC_ASSERT ( offsetof(struct SpriteOutput, y) = =offsetof(struct RenderOutput, y))

◆ STATIC_ASSERT() [3/6]

STATIC_ASSERT ( offsetof(struct SpriteOutput, active) = =offsetof(struct RenderOutput, active))

◆ STATIC_ASSERT() [4/6]

STATIC_ASSERT ( offsetof(struct SpriteOutput, animStep) = =offsetof(struct RenderOutput, animStep))

◆ STATIC_ASSERT() [5/6]

STATIC_ASSERT ( offsetof(struct SpriteOutput, index) = =offsetof(struct RenderOutput, index))

◆ STATIC_ASSERT() [6/6]

STATIC_ASSERT ( offsetof(struct SpriteOutput, attr) = =offsetof(struct RenderOutput, unk10))

◆ UiWindow_PutGlyph()

void UiWindow_PutGlyph ( struct UiWindow * win,
u32 tile,
u32 x,
u32 y,
s32 mode )

Puts a character into a window's tilemap as a tile at tile (x, y) of its interior.

mode 1 shows the next-page arrow sprite in the window's corner instead.

Definition at line 187 of file sprites.c.

Referenced by Battle_CollectPartyCommands(), SummonMenu_SelectSummon(), UiText_RenderWideStringInWindow(), and UiWindow_PutGlyph().

◆ UiWindow_SetTilemapEntry()

void UiWindow_SetTilemapEntry ( struct UiWindow * window,
s32 value,
s32 x,
s32 y,
u32 mode )

Writes value into a window's tilemap at tile (x, y) of its interior, with the palette mode names (TILEMAP_ENTRY_), or as it is for TILEMAP_ENTRY_PLAIN; TILEMAP_ENTRY_NONE writes nothing.

Definition at line 345 of file sprites.c.

Referenced by Battle_CollectPartyCommands(), Battle_SelectAbility(), BattleMenu_RunActionSelection(), DjinnMenu_ShowChangePreview(), ItemList_SelectEntry(), PartyStatusDraw(), SaveMenu_Run(), SummonMenu_SelectSummon(), Ui_RunOwnerStatusScreen(), UiText_GetResourceDimensionsAlt(), UiWindow_DrawThreeTileColumn(), and UiWindow_SetTilemapEntry().

◆ RenderOutput_UpdateScaleAnimation()

void RenderOutput_UpdateScaleAnimation ( struct RenderOutput * output)

Steps a scaling sprite's animation (UI_SPRITE_SWELL to UI_SPRITE_SHRINK_HALF) and sets its affine scale for this frame.

Definition at line 396 of file sprites.c.

Referenced by RenderOutput_UpdateScaleAnimation(), UiText_GetResourceDimensionsAlt(), and UiWork_AnimateSpriteSlots().

◆ UiWork_AnimateSpriteSlots()

void UiWork_AnimateSpriteSlots ( void )

The per-frame sprite update: moves each sprite that an open window carries by its animation mode (UI_SPRITE_) and queues it for drawing.

Definition at line 443 of file sprites.c.

Referenced by UiText_GetResourceDimensionsAlt(), UiWork_AnimateSpriteSlots(), and UiWork_ProcessAll().