11#define SPRITE_CELL(output) ((struct CursorSprite *)(output)->unk10)
29#if (LANGUAGE == LANGUAGE_JAPANESE)
57 if (character !=
' ') {
59 result = draw(window, character, x, y, font);
60#if (LANGUAGE == LANGUAGE_JAPANESE)
62 result += draw(window, (
u16)mark, x + result, y, font);
67 }
else if (character ==
' ') {
80 index = (output - work->
outputs) * 4;
104#if (LANGUAGE == LANGUAGE_JAPANESE)
122 sprite->
x = (window->
x << 3) + ((window->
width - 2) << 3) + 4;
123#if (LANGUAGE == LANGUAGE_JAPANESE)
124 sprite->
y = (window->
y << 3) + ((window->
height - 2) << 3) + 1;
126 sprite->
y = (window->
y << 3) + ((window->
height - 2) << 3) - 1;
132#if (LANGUAGE == LANGUAGE_JAPANESE)
133 ((
u16 *)&output->
oam)[0] =
y + (spacingY >> 1) + window->
y * 8;
135 ((
u16 *)&output->
oam)[0] =
y + (spacingY >> 1) + window->
y * 8 - 2;
137 ((
u16 *)&output->
oam)[1] =
138 (
x + (spacingX >> 1) + window->
x * 8 + 2) | 0x4000;
143 output->
x = sprite->
x;
144 output->
y = sprite->
y;
145 output->
index = index;
182#if (LANGUAGE != LANGUAGE_JAPANESE)
216 attr->
x = (win->
x + (column + *(
u16 *)&win->
width)) * 8 + 4;
221 row = (
u8)win->
y + row;
225 attr->
y = row * 8 - 1;
236 }
else if (tile <= 0xff) {
239 pos = (win->
y + y) * 32 + (win->
x + x);
253 u8 *base = (
u8 *)((
unsigned long)work ^ tile);
261 base = (
u8 *)((
unsigned long)base ^
tile);
283 attr->
x = (left + (column + *(
u16 *)&win->
width)) * 8 + 4;
287 row = (
u8)win->
y + row;
291 attr->
y = row * 8 + 1;
302 }
else if (tile <= 0xff) {
309 line = (win->
y + y) * 32;
323 pos = (win->
y + y) * 32 + (win->
x + x);
339#define TILEMAP_WIDTH 32
340#define TILEMAP_ENTRIES (TILEMAP_WIDTH * 20)
382 work->
tilemap[index] = palette | value;
420 sprite->
x = output->
x;
421 sprite->
y = output->
y;
431 sprite->
x = *(
u16 *)&output->
x - 8;
432 sprite->
y = (
u16)output->
y - 8;
435 sprite->
x = output->
x;
436 sprite->
y = output->
y;
457 while (output !=
NULL) {
496 sprite->
x = output->
x;
497 sprite->
y = output->
y;
505 sprite->
x = output->
x - 5;
506 sprite->
y = output->
y - 5;
549 sprite->
x = output->
x - 8;
550 sprite->
y = output->
y - 8;
556 sprite->
x = output->
x;
557 sprite->
y = output->
y;
572 output = output->
next;
const u8 gUiSprite_BounceOffsets[16]
A hop of up to 8 pixels over 16 frames.
const s8 gUiSprite_WobbleOffsets[40]
A swing along an arc of radius 4, as {x, y} pairs: x runs 0, 4, 0, -4, 0 while y rises at each side.
const u8 gUiSprite_CursorBobOffsets[80]
The pointing hand's bob: a smooth rise and fall of 8 pixels over 80 frames.
const u16 gUiText_MarkGlyphCodes[]
static __inline__ void Dma_Set(const volatile void *source, volatile void *destination, u32 control, volatile u32 *channel)
Starts a DMA transfer: stores the source, destination and control words into channel's registers with...
u32 gFrameTick
Counted up by every VBlank.
s32 UiText_DrawGlyphArm(struct UiWindow *window, u32 character, u32 x, u32 y, const u8 *font)
Draws one character into a window's text canvas with its top-left corner at pixel (x,...
s32 UiText_RenderGlyphPair(s32 code, u32 *out)
Draws a character, and a second one when the code carries it in bits 8 to 15, into a 16x16-pixel cell...
u8 UiText_DrawGlyphCodeSize[]
const u8 gUiSprite_CursorFrameTiles[]
#define OBJ_VRAM0
Sprite tile memory, as pret names it: the 32 KB from 0x06010000.
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
void MemFree(void *buffer)
#define RamCode_Load(to, code, bytes)
Allocates a heap copy; release it with MemFree when finished.
s32 AffineMatrix_BuildForEffect(struct AffineTransform *source)
Hands out the next OAM affine matrix for a sprite drawn with source's scale and rotation and fills it...
void Runtime_PushSlotEntry(void *slotEntry, s32 slot)
Links a sprite entry into depth slot slot (clamped to 0..255) for this frame.
char ResourceId_SmallFont
char ResourceId_WindowTiles
const u16 gUi_BounceScales[32]
A sprite's pulse, as a scale where 256 is its normal size: it swells to 1.5 times and back over 32 st...
#define STATIC_ASSERT(condition)
C89 permits repeated extern declarations of the same array.
#define offsetof(type, member)
The battle message display: its window, its text channel and whether the next message is marked.
A cursor or prompt sprite: a list link and its OAM attributes as fields.
struct RenderOutput * head
A render output: a sprite in a window's output list (a character, an icon or a portrait),...
u8 sentinel
depth slot it is drawn at (254 for glyphs)
s8 active
its UI_SPRITE_ motion; 0 while free
struct RenderOutput * next
the next output in its list
u16 animStep
step of its motion's animation
s8 kind
0 for a glyph; otherwise it owns VRAM cache slot index, freed with it, and 2 (a portrait) also its pa...
s8 index
VRAM cache slot, or a glyph's tile after glyphTiles.
A view of struct RenderOutput with its sprite cell (from offset 0x10) as the member attr.
struct SpriteOutput * next
The window system's work: the windows' tilemap, the windows, the three text channels,...
struct UiWindow windows[WINDOW_COUNT]
u8 mode
Set while Mind Read shows thoughts: round frame corners, colour 8 text with no shadow,...
struct RenderOutput outputs[UI_OUTPUT_COUNT]
u16 tilemap[640]
the windows' BG tilemap, 32 by 20 tiles
u16 glyphResource
VRAM cache slot of the page arrow; 99 when none.
u16 letterSpacing
pixels between sprite glyphs; 9
u16 outline
the current channel's, copied in to draw
u16 glyphTiles
first sprite tile of the glyph sheet (picture 95)
u16 lineSpacing
the current channel's, copied in to draw
A window: a framed rectangle of the tilemap with its sprite outputs, its opening or closing animation...
u16 effect
The effect a message's TEXT_WINDOW_STATE code sets.
u16 flags
UI_WINDOW_ flags; 0 once closing or free.
struct RenderOutputList output
the sprites the window carries
void * Resource_GetTableEntry(s32 index)
Returns the ROM address of resource index from the resource directory.
@ UI_SPRITE_SHAKE
jitters by a pixel every other frame
@ UI_SPRITE_PAGE_ARROW
the animated next-page arrow, bobbing
@ UI_SPRITE_POP
shown at double size, then normal size
@ UI_SPRITE_HOP_DOWN_LEFT
@ UI_SPRITE_WOBBLE
swings along a small arc
@ UI_SPRITE_HIDDEN
not drawn
@ UI_SPRITE_SHRINK_HALF
the same at half the scale
@ UI_SPRITE_SHRINK
shrinks from 1.5 times to its size, once
@ UI_SPRITE_HOP_DOWN
14 to 16: hops down and back
@ UI_SPRITE_SWELL
pulses between 1 and 1.5 times its size
@ UI_SPRITE_SWELL_HALF
the same at half the scale
@ UI_SPRITE_PULSE
shown at 1.25 times, then normal size
@ UI_SPRITE_SPIN
turns while circling its place
#define UI_TILE(tile)
A tilemap entry of palette 15, the UI palette.
@ UI_WINDOW_TEXT_CANVAS
text is drawn into a canvas of bitmap tiles (UiWindow_MapTextCanvasTiles)
@ UI_WINDOW_OPEN
the window slot is in use
#define DMA_COPY32(count)
The DMA control word that copies count words.
@ UI_TILE_DIVIDER_HORIZONTAL
s32 Resource_FindFreeEntry(void)
Returns the number of the first free cache entry, or VRAM_CACHE_ENTRY_COUNT when all are taken.
s32 VramCache_Load(u32 no, u32 size, const void *src)
Gives cache entry no size bytes of sprite VRAM and copies src there.
void UiWork_AnimateSpriteSlots(void)
The per-frame sprite update: moves each sprite that an open window carries by its animation mode (UI_...
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 RenderOutput_UpdateScaleAnimation(struct RenderOutput *output)
Steps a scaling sprite's animation (UI_SPRITE_SWELL to UI_SPRITE_SHRINK_HALF) and sets its affine sca...
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 interio...
@ TILEMAP_ENTRY_PALETTE_14
@ TILEMAP_ENTRY_PALETTE_1
@ TILEMAP_ENTRY_PALETTE_15
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 (TIL...
#define SPRITE_CELL(output)
A render output's sprite cell: the link and OAM attributes in its 12 bytes from offset 0x10.
s32(*) GlyphRoutine(struct UiWindow *, u32, u32, u32, const u8 *)
What every part of the window object shares: its includes, edition values, macros and the codes of de...
@ TEXT_VOICED_MARK
dakuten
#define TEXT_CODE_MARK_SHIFT
#define NO_GLYPH_RESOURCE
A glyph resource id meaning no glyph resource is loaded.
@ HEAP_SLOT_BATTLE_DISPLAY
#define UI_WINDOW_EFFECT_SWELL
The window effect a message can start (TEXT_WINDOW_STATE): the window's frame grows by a tile and its...
#define UI_SPRITE_SPACE_WIDTH
void RenderOutput_AppendToList(struct RenderOutputList *list, struct RenderOutput *node)
Adds a render output to the end of a list; NULL lists are ignored.
struct RenderOutput * RenderOutput_AcquireFree(void)
Takes the first render output from the free list, or returns NULL when every output is in use.