Alchemy
Loading...
Searching...
No Matches

sprites.c

Go to the documentation of this file.
1/// @file
2/// Characters drawn into windows, and the per-frame sprite update.
3/// Part of window.c, the window object, compiled only through it.
4
6
7typedef s32 (*GlyphRoutine)(struct UiWindow *, u32, u32, u32, const u8 *);
8
9/// A render output's sprite cell: the link and OAM attributes in its 12 bytes
10/// from offset 0x10.
11#define SPRITE_CELL(output) ((struct CursorSprite *)(output)->unk10)
12
13/// Draws a character of a window's text with its top-left corner at pixel
14/// (x, y) of the window's interior and returns how far the text advances. A
15/// text canvas window draws it into the canvas; other windows show it as a
16/// sprite carried by the window. mode 1 shows the next-page arrow instead.
17s32 UiText_DrawGlyph(struct UiWindow *window, s32 character, s32 x, s32 y,
18 s32 mode) {
19 struct UiRenderWork *work = UI_WORK;
20 u32 spacingX = work->letterSpacing;
21 s32 width;
22 u32 spacingY = work->lineSpacing;
23
24 // A text canvas window draws the glyph into its canvas.
25 if (mode != 1 && (window->flags & UI_WINDOW_TEXT_CANVAS) != 0) {
26 u8 *font;
27 GlyphRoutine draw;
28 s32 result;
29#if (LANGUAGE == LANGUAGE_JAPANESE)
30 s32 mark;
31
32 font = NULL;
33 if (((struct BattleDisplayWork *)
35 ->window == window) {
37 width = 3;
38 if (character == ' ')
39 goto done;
40 }
42 character &= (1 << TEXT_CODE_MARK_SHIFT) - 1;
43 width = 4;
44#else
45 if (((struct BattleDisplayWork *)
47 ->window == window) {
50 width = 3;
51 if (character == ' ')
52 goto done;
53 }
55 width = 4;
56#endif
57 if (character != ' ') {
59 result = draw(window, character, x, y, font);
60#if (LANGUAGE == LANGUAGE_JAPANESE)
61 if ((u16)mark != 0)
62 result += draw(window, (u16)mark, x + result, y, font);
63#endif
64 MemFree(draw);
65 return result;
66 }
67 } else if (character == ' ') {
69 } else {
70 // Other windows show each glyph as a 16x16 sprite, animated by the text
71 // style (UiRenderWork.outline 2 to 5) or, in mode 1, as the page arrow.
72 u32 tiles[32];
73 struct RenderOutput *output;
74 struct CursorSprite *sprite;
75 s32 index;
76
77 output = RenderOutput_AcquireFree();
78 if (output == NULL)
79 return 0;
80 index = (output - work->outputs) * 4;
81 output->active = UI_SPRITE_STILL;
82 output->kind = 0;
83 if (mode == 1) {
84 width = 1;
86 } else {
87 switch (work->outline) {
88 case 3:
89 output->active = UI_SPRITE_SHAKE;
90 break;
91 case 4:
92 output->active = UI_SPRITE_POP;
93 output->animStep = 8;
94 break;
95 case 5:
96 output->active = UI_SPRITE_SPIN;
97 output->animStep = 0;
98 break;
99 case 2:
100 output->active = UI_SPRITE_WOBBLE;
101 output->animStep = 0;
102 break;
103 }
104#if (LANGUAGE == LANGUAGE_JAPANESE)
105 width = UiText_RenderGlyphPair(character, tiles);
106#else
107 {
108 s32 drawn = UiText_RenderGlyphPair(character, tiles);
109
110 if (drawn == 0)
111 drawn = 1;
112 width = drawn;
113 }
114#endif
115 }
116
117 if ((u8)output->active == UI_SPRITE_PAGE_ARROW) {
118 // The page arrow sits in the window's bottom-right corner.
119 sprite = SPRITE_CELL(output);
120 if (work->glyphResource == NO_GLYPH_RESOURCE)
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;
125#else
126 sprite->y = (window->y << 3) + ((window->height - 2) << 3) - 1;
127#endif
128 } else {
129 // Copy the glyph's tiles to its sprite tiles (OBJ VRAM) and place it.
130 Dma_Set(tiles, (void *)(OBJ_VRAM0 + (work->glyphTiles + index) * 32),
131 DMA_COPY32(32), REG_DMA3);
132#if (LANGUAGE == LANGUAGE_JAPANESE)
133 ((u16 *)&output->oam)[0] = y + (spacingY >> 1) + window->y * 8;
134#else
135 ((u16 *)&output->oam)[0] = y + (spacingY >> 1) + window->y * 8 - 2;
136#endif
137 ((u16 *)&output->oam)[1] =
138 (x + (spacingX >> 1) + window->x * 8 + 2) | 0x4000;
139 ((u16 *)&output->oam)[2] = work->glyphTiles + index;
140 sprite = SPRITE_CELL(output);
141 }
142 output->sentinel = 254;
143 output->x = sprite->x;
144 output->y = sprite->y;
145 output->index = index;
146 output->next = NULL;
147 RenderOutput_AppendToList(&window->output, output);
148 }
149done:
150 return width;
151}
152
153/// A view of struct RenderOutput with its sprite cell (from offset 0x10) as the
154/// member attr. Read through a cast of RenderOutput.unk10 instead,
155/// UiWork_AnimateSpriteSlots does not match (578 instructions become 605).
167};
168
170 offsetof(struct RenderOutput, x));
172 offsetof(struct RenderOutput, y));
174 offsetof(struct RenderOutput, active));
176 offsetof(struct RenderOutput, animStep));
178 offsetof(struct RenderOutput, index));
180 offsetof(struct RenderOutput, unk10));
181
182#if (LANGUAGE != LANGUAGE_JAPANESE)
183
184/// Puts a character into a window's tilemap as a tile at tile (x, y) of its
185/// interior. mode 1 shows the next-page arrow sprite in the window's corner
186/// instead.
188 void *work = gWindowWork[0];
189 u8 *base = work;
190 struct SpriteOutput *out;
191 s32 idx;
192 u16 *slot;
193 struct CursorSprite *attr;
194 u32 pos;
195 u16 row;
196
197 if (y > (win->height - 2))
198 return;
199 if (x > (win->width - 2))
200 return;
201 if (mode == 1) {
202 s32 column;
204 if (work == NULL)
205 return;
206 out = work;
207 idx =
208 ((struct RenderOutput *)out - ((struct UiRenderWork *)base)->outputs) *
209 4;
211 attr = &out->attr;
212 slot = &((struct UiRenderWork *)base)->glyphResource;
213 if (*slot == NO_GLYPH_RESOURCE)
214 *slot = Resource_FindFreeEntry();
215 column = 0xfffe;
216 attr->x = (win->x + (column + *(u16 *)&win->width)) * 8 + 4;
217#ifdef UBFIX
218 // Sequence the two writes to row. Combining them in one expression has
219 // no intervening sequence point; plain stores reorder native EN code.
220 row = (u8)win->height + 254;
221 row = (u8)win->y + row;
222#else
223 row = (u8)win->y + (row = (u8)win->height + 254);
224#endif
225 attr->y = row * 8 - 1;
226 /* FAKEMATCH: needed to match: the embedded OAM view preserves
227 * packed/logical position store order changed by byte-span and scalar
228 * views. */
229 out->x = attr->x;
230 out->y = attr->y;
231 out->next = NULL;
232 out->index = idx;
233 if (out->active == 0)
234 out->active = mode;
235 RenderOutput_AppendToList(&win->output, (struct RenderOutput *)out);
236 } else if (tile <= 0xff) {
237 x++;
238 y++;
239 pos = (win->y + y) * 32 + (win->x + x);
240 if (pos < 32 * 20)
241 ((struct UiRenderWork *)work)->tilemap[pos] = UI_TILE(tile);
242 }
243}
244
245#else
246
247/// The Japanese UiWindow_PutGlyph, which also places the kana marks.
248void UiWindow_PutGlyph(struct UiWindow *win, u32 tile, u32 x, u32 y, s32 mode) {
249 u8 *work = gWindowWork[0];
250 /* FAKEMATCH: this XOR pair folds away but keeps work and base as separate
251 * lifetimes, with the native r8/r12 copy; as a direct copy, 17 instructions
252 * differ in tbs-en. */
253 u8 *base = (u8 *)((unsigned long)work ^ tile);
254 struct SpriteOutput *out;
255 s32 idx;
256 u16 *slot;
257 struct CursorSprite *attr;
258 u32 pos;
259 u16 row;
260
261 base = (u8 *)((unsigned long)base ^ tile);
262
263 if (y > (win->height - 2))
264 return;
265 if (x > (win->width - 2))
266 return;
267 if (mode == 1) {
268 s32 column;
269 u16 left;
270 out = (struct SpriteOutput *)RenderOutput_AcquireFree();
271 if (out == NULL)
272 return;
273 idx =
274 ((struct RenderOutput *)out - ((struct UiRenderWork *)base)->outputs) *
275 4;
277 attr = &out->attr;
278 slot = &((struct UiRenderWork *)base)->glyphResource;
279 if (*slot == NO_GLYPH_RESOURCE)
280 *slot = Resource_FindFreeEntry();
281 column = 0xfffe;
282 left = win->x;
283 attr->x = (left + (column + *(u16 *)&win->width)) * 8 + 4;
284#ifdef UBFIX
285 // As above, the original writes row twice without a sequence point.
286 row = (u8)win->height + 254;
287 row = (u8)win->y + row;
288#else
289 row = (u8)win->y + (row = (u8)win->height + 254);
290#endif
291 attr->y = row * 8 + 1;
292 /* FAKEMATCH: needed to match: the embedded OAM view preserves
293 * packed/logical position store order changed by byte-span and scalar
294 * views. */
295 out->x = attr->x;
296 out->y = attr->y;
297 out->next = NULL;
298 out->index = idx;
299 if (out->active == 0)
300 out->active = mode;
301 RenderOutput_AppendToList(&win->output, (struct RenderOutput *)out);
302 } else if (tile <= 0xff) {
303 if (tile - TEXT_VOICED_MARK <= 1) {
304 // A kana mark goes in the tile above the character before it. Over the
305 // frame's top edge or a divider line, it takes the mark tile drawn over
306 // that background.
307 u32 line;
308
309 line = (win->y + y) * 32;
310 switch (
311 *(((struct UiRenderWork *)base)->tilemap + (line + (win->x + x)))) {
313 tile -= 0xc0;
314 break;
316 tile -= 0xd0;
317 break;
318 }
319 } else {
320 x++;
321 y++;
322 }
323 pos = (win->y + y) * 32 + (win->x + x);
324 if (pos < 32 * 20)
325 ((struct UiRenderWork *)work)->tilemap[pos] = UI_TILE(tile);
326 }
327}
328
329#endif
330
331enum {
337};
338
339#define TILEMAP_WIDTH 32
340#define TILEMAP_ENTRIES (TILEMAP_WIDTH * 20)
341
342/// Writes value into a window's tilemap at tile (x, y) of its interior, with
343/// the palette mode names (TILEMAP_ENTRY_), or as it is for
344/// TILEMAP_ENTRY_PLAIN; TILEMAP_ENTRY_NONE writes nothing.
345void UiWindow_SetTilemapEntry(struct UiWindow *window, s32 value, s32 x, s32 y,
346 u32 mode) {
347 struct UiRenderWork *work = UI_WORK;
348 s32 palette;
349 s32 index;
350
351 y += 1;
352 x += 1;
353 if (y > (u32)(window->height - 1))
354 return;
355 if (x > (u32)(window->width - 1))
356 return;
357
358 switch (mode) {
360 palette = 0xf000;
361 break;
363 palette = 0xe000;
364 break;
366 palette = 0x1000;
367 break;
368 default:
369 palette = 0;
370 break;
371 }
372
373 switch (mode) {
375 return;
379 index = (window->y + y) * TILEMAP_WIDTH + (window->x + x);
380 if ((u32)index >= TILEMAP_ENTRIES)
381 return;
382 work->tilemap[index] = palette | value;
383 return;
385 default:
386 index = (window->y + y) * TILEMAP_WIDTH + (window->x + x);
387 if ((u32)index >= TILEMAP_ENTRIES)
388 return;
389 work->tilemap[index] = value;
390 return;
391 }
392}
393
394/// Steps a scaling sprite's animation (UI_SPRITE_SWELL to
395/// UI_SPRITE_SHRINK_HALF) and sets its affine scale for this frame.
397 s32 scale = 256;
398 struct CursorSprite *sprite = SPRITE_CELL(output);
399 struct AffineTransform effect;
400
401 switch ((u8)output->active) {
402 case UI_SPRITE_SWELL:
403 scale = gUi_BounceScales[output->animStep++ & 31];
404 break;
406 scale = gUi_BounceScales[output->animStep++ & 31] >> 1;
407 break;
408 case UI_SPRITE_SHRINK:
409 if (output->animStep <= 7)
410 scale = gUi_BounceScales[output->animStep++ * 2 + 16];
411 break;
413 if (output->animStep <= 7)
414 scale = gUi_BounceScales[output->animStep++ * 2 + 16] >> 1;
415 break;
416 }
417 if (scale == 256) {
418 sprite->affineIndex = 0;
419 sprite->affine = 0;
420 sprite->x = output->x;
421 sprite->y = output->y;
422 } else {
423 effect.scaleX = scale;
424 effect.scaleY = scale;
425 effect.angle = 0;
426 sprite->affineIndex = AffineMatrix_BuildForEffect(&effect);
427 if (scale > 256) {
428 sprite->affine = 3;
429 /* FAKEMATCH: needed to match: the unsigned halfword read of the x cell; a
430 * cast of the signed member swaps the x load and the -8 pool load. */
431 sprite->x = *(u16 *)&output->x - 8;
432 sprite->y = (u16)output->y - 8;
433 } else {
434 sprite->affine = 1;
435 sprite->x = output->x;
436 sprite->y = output->y;
437 }
438 }
439}
440
441/// The per-frame sprite update: moves each sprite that an open window carries
442/// by its animation mode (UI_SPRITE_) and queues it for drawing.
444 struct UiRenderWork *work = UI_WORK;
445 struct UiWindow *window = work->windows;
446 s32 no;
447 struct AffineTransform effect;
448
449 for (no = 0; no != WINDOW_COUNT; window++, no++) {
450 struct SpriteOutput *output;
451 u32 phase;
452
453 if (!(window->flags & UI_WINDOW_OPEN))
454 continue;
455 output = (struct SpriteOutput *)window->output.head;
456 phase = (gFrameTick >> 2) & 7;
457 while (output != NULL) {
458 struct CursorSprite *sprite = &output->attr;
459
460 if (window->effect == UI_WINDOW_EFFECT_SWELL) {
461 output->animStep = 2;
462 output->active = UI_SPRITE_PULSE;
463 }
464 switch (output->active) {
466 if (work->glyphResource != 0x60) {
467 const u8 *tiles = &gUiSprite_CursorFrameTiles[phase * 128];
468
469 sprite->tile = VramCache_Load(work->glyphResource, 128, tiles);
470 output->index = sprite->tile;
471 sprite->mode = 0;
472 sprite->mosaic = 0;
473 sprite->colors = 1;
474 sprite->size = 0;
475 sprite->shape = 2;
476 sprite->y =
477 output->y + gUiSprite_CursorBobOffsets[gFrameTick % 80] + 2;
478 sprite->affine = 0;
479 sprite->affineIndex = 0;
480 }
481 break;
482 case UI_SPRITE_SHAKE:
483 if (gFrameTick & 1) {
484 sprite->x =
485 output->x +
486 (s32)(((Random16() * 3 >> 16) + (Random16() * 3 >> 16)) >> 1) - 1;
487 sprite->y =
488 output->y +
489 (s32)(((Random16() * 3 >> 16) + (Random16() * 3 >> 16)) >> 1) - 1;
490 }
491 break;
492 case UI_SPRITE_POP:
493 if (output->animStep == 0) {
494 sprite->affineIndex = 0;
495 sprite->affine = 0;
496 sprite->x = output->x;
497 sprite->y = output->y;
498 break;
499 }
500 effect.scaleX = 512;
501 effect.scaleY = 512;
502 effect.angle = 0;
503 sprite->affineIndex = AffineMatrix_BuildForEffect(&effect);
504 sprite->affine = 3;
505 sprite->x = output->x - 5;
506 sprite->y = output->y - 5;
507 output->animStep--;
508 break;
509 case UI_SPRITE_SPIN:
510 effect.scaleX = 256;
511 effect.scaleY = 256;
512 output->animStep += 768;
513 effect.angle = output->animStep;
514 sprite->affineIndex = AffineMatrix_BuildForEffect(&effect);
515 sprite->affine = 1;
516 sprite->x = output->x - (Trig_Sin(effect.angle + 0xe800) >> 14) - 2;
517 sprite->y = output->y - (Trig_Cos(effect.angle + 0x6800) >> 14) - 2;
518 break;
519 case UI_SPRITE_WOBBLE:
520 if (gFrameTick & 1)
521 output->animStep++;
522 sprite->x =
523 output->x + gUiSprite_WobbleOffsets[output->animStep % 20][0];
524 sprite->y =
525 output->y + gUiSprite_WobbleOffsets[output->animStep % 20][1] - 2;
526 break;
527 case UI_SPRITE_HOP_UP:
528 output->animStep++;
529 sprite->y = output->y - gUiSprite_BounceOffsets[output->animStep & 15];
530 break;
532 case UI_SPRITE_HOP_DOWN + 1:
533 case UI_SPRITE_HOP_DOWN + 2:
534 output->animStep++;
535 sprite->y = output->y + gUiSprite_BounceOffsets[output->animStep & 15];
536 break;
538 output->animStep++;
539 sprite->x = output->x - gUiSprite_BounceOffsets[output->animStep & 15];
540 sprite->y = output->y + gUiSprite_BounceOffsets[output->animStep & 15];
541 break;
542 case UI_SPRITE_PULSE:
543 if (output->animStep != 0) {
544 effect.scaleX = 320;
545 effect.scaleY = 320;
546 effect.angle = 0;
547 sprite->affineIndex = AffineMatrix_BuildForEffect(&effect);
548 sprite->affine = 3;
549 sprite->x = output->x - 8;
550 sprite->y = output->y - 8;
551 output->animStep--;
552 break;
553 }
554 sprite->affineIndex = 0;
555 sprite->affine = 0;
556 sprite->x = output->x;
557 sprite->y = output->y;
558 break;
559 case UI_SPRITE_SWELL:
561 case UI_SPRITE_SHRINK:
564 break;
565 }
566 if (output->active == UI_SPRITE_PAGE_ARROW) {
567 if (work->glyphResource != 0x60)
568 Runtime_PushSlotEntry(sprite, output->sentinel);
569 } else if (output->active != UI_SPRITE_HIDDEN) {
570 Runtime_PushSlotEntry(sprite, output->sentinel);
571 }
572 output = output->next;
573 phase = (gFrameTick >> 2) & 7;
574 }
575 }
576}
const u8 gUiSprite_BounceOffsets[16]
A hop of up to 8 pixels over 16 frames.
Definition articles.c:199
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.
Definition articles.c:185
const u8 gUiSprite_CursorBobOffsets[80]
The pointing hand's bob: a smooth rise and fall of 8 pixels over 80 frames.
Definition articles.c:175
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...
Definition dma.h:62
s32 Trig_Cos(s32 angle)
s32 Trig_Sin(s32 angle)
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,...
Definition glyph_arm.c:49
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...
Definition glyphs.c:17
u8 UiText_DrawGlyphCodeSize[]
const u8 gUiSprite_CursorFrameTiles[]
@ HEAP_SLOT_WINDOW
Definition heap_state.h:39
#define OBJ_VRAM0
Sprite tile memory, as pret names it: the 32 KB from 0x06010000.
Definition io_reg.h:170
#define REG_DMA3
Definition io_reg.h:153
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
Definition math.c:10
void MemFree(void *buffer)
#define RamCode_Load(to, code, bytes)
Allocates a heap copy; release it with MemFree when finished.
Definition ramcode.h:15
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...
Definition render.c:27
void Runtime_PushSlotEntry(void *slotEntry, s32 slot)
Links a sprite entry into depth slot slot (clamped to 0..255) for this frame.
Definition render.c:79
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...
Definition scales.c:10
#define NULL
Definition bilibin.h:6
u8 gWindowWork[]
#define STATIC_ASSERT(condition)
C89 permits repeated extern declarations of the same array.
#define offsetof(type, member)
Definition stddef.h:19
A sprite's rotation and scale: scales in 8.8 fixed point (0x100 is full size), the angle in 1/65536 t...
Definition affine.h:13
u16 angle
1/65536 turns
Definition affine.h:16
u16 scaleY
8.8 fixed point, read signed
Definition affine.h:15
u16 scaleX
8.8 fixed point, read signed: negative mirrors the sprite
Definition affine.h:14
The battle message display: its window, its text channel and whether the next message is marked.
Definition battle_work.h:38
A cursor or prompt sprite: a list link and its OAM attributes as fields.
Definition menu_list.h:50
u16 affineIndex
Definition menu_list.h:59
struct RenderOutput * head
A render output: a sprite in a window's output list (a character, an icon or a portrait),...
struct RenderOam oam
u16 y
screen pixels
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
u16 x
screen pixels
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.
Definition sprites.c:156
struct CursorSprite attr
Definition sprites.c:166
struct SpriteOutput * next
Definition sprites.c:157
The window system's work: the windows' tilemap, the windows, the three text channels,...
Definition window.h:19
struct UiWindow windows[WINDOW_COUNT]
Definition window.h:21
u8 mode
Set while Mind Read shows thoughts: round frame corners, colour 8 text with no shadow,...
Definition window.h:35
struct RenderOutput outputs[UI_OUTPUT_COUNT]
Definition window.h:23
u16 tilemap[640]
the windows' BG tilemap, 32 by 20 tiles
Definition window.h:20
u16 glyphResource
VRAM cache slot of the page arrow; 99 when none.
Definition window.h:50
u16 letterSpacing
pixels between sprite glyphs; 9
Definition window.h:47
u16 outline
the current channel's, copied in to draw
Definition window.h:44
u16 glyphTiles
first sprite tile of the glyph sheet (picture 95)
Definition window.h:51
u16 lineSpacing
the current channel's, copied in to draw
Definition window.h:42
A window: a framed rectangle of the tilemap with its sprite outputs, its opening or closing animation...
Definition uiwindow.h:11
u16 y
tiles
Definition uiwindow.h:16
u16 effect
The effect a message's TEXT_WINDOW_STATE code sets.
Definition uiwindow.h:21
u16 flags
UI_WINDOW_ flags; 0 once closing or free.
Definition uiwindow.h:25
u16 x
tiles
Definition uiwindow.h:15
u16 height
tiles
Definition uiwindow.h:14
struct RenderOutputList output
the sprites the window carries
Definition uiwindow.h:12
u16 width
tiles
Definition uiwindow.h:13
void * Resource_GetTableEntry(s32 index)
Returns the ROM address of resource index from the resource directory.
Definition system.c:150
#define WINDOW_COUNT
Definition tbs_edition.h:69
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
signed short s16
Definition types.h:12
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11
#define UI_WORK
Definition window.h:267
@ UI_SPRITE_STILL
Definition window.h:119
@ UI_SPRITE_SHAKE
jitters by a pixel every other frame
Definition window.h:122
@ UI_SPRITE_HOP_UP
Definition window.h:132
@ UI_SPRITE_PAGE_ARROW
the animated next-page arrow, bobbing
Definition window.h:120
@ UI_SPRITE_POP
shown at double size, then normal size
Definition window.h:123
@ UI_SPRITE_HOP_DOWN_LEFT
Definition window.h:133
@ UI_SPRITE_WOBBLE
swings along a small arc
Definition window.h:121
@ UI_SPRITE_HIDDEN
not drawn
Definition window.h:130
@ UI_SPRITE_SHRINK_HALF
the same at half the scale
Definition window.h:129
@ UI_SPRITE_SHRINK
shrinks from 1.5 times to its size, once
Definition window.h:128
@ UI_SPRITE_HOP_DOWN
14 to 16: hops down and back
Definition window.h:131
@ UI_SPRITE_SWELL
pulses between 1 and 1.5 times its size
Definition window.h:126
@ UI_SPRITE_SWELL_HALF
the same at half the scale
Definition window.h:127
@ UI_SPRITE_PULSE
shown at 1.25 times, then normal size
Definition window.h:125
@ UI_SPRITE_SPIN
turns while circling its place
Definition window.h:124
#define UI_TILE(tile)
A tilemap entry of palette 15, the UI palette.
Definition window.h:54
@ UI_WINDOW_TEXT_CANVAS
text is drawn into a canvas of bitmap tiles (UiWindow_MapTextCanvasTiles)
Definition window.h:31
@ UI_WINDOW_OPEN
the window slot is in use
Definition window.h:28
#define DMA_COPY32(count)
The DMA control word that copies count words.
Definition window.h:112
@ UI_TILE_DIVIDER_HORIZONTAL
Definition window.h:91
@ UI_TILE_FRAME_TOP
Definition window.h:75
s32 Resource_FindFreeEntry(void)
Returns the number of the first free cache entry, or VRAM_CACHE_ENTRY_COUNT when all are taken.
Definition vram_cache.c:211
s32 VramCache_Load(u32 no, u32 size, const void *src)
Gives cache entry no size bytes of sprite VRAM and copies src there.
Definition vram_cache.c:143
void UiWork_AnimateSpriteSlots(void)
The per-frame sprite update: moves each sprite that an open window carries by its animation mode (UI_...
Definition sprites.c:443
#define TILEMAP_WIDTH
Definition sprites.c:339
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.
Definition sprites.c:187
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...
Definition sprites.c:396
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...
Definition sprites.c:17
@ TILEMAP_ENTRY_PALETTE_14
Definition sprites.c:334
@ TILEMAP_ENTRY_PALETTE_1
Definition sprites.c:336
@ TILEMAP_ENTRY_PALETTE_15
Definition sprites.c:335
@ TILEMAP_ENTRY_PLAIN
Definition sprites.c:332
@ TILEMAP_ENTRY_NONE
Definition sprites.c:333
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...
Definition sprites.c:345
#define TILEMAP_ENTRIES
Definition sprites.c:340
#define SPRITE_CELL(output)
A render output's sprite cell: the link and OAM attributes in its 12 bytes from offset 0x10.
Definition sprites.c:11
s32(*) GlyphRoutine(struct UiWindow *, u32, u32, u32, const u8 *)
Definition sprites.c:7
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.
Definition windows.c:478
struct RenderOutput * RenderOutput_AcquireFree(void)
Takes the first render output from the free list, or returns NULL when every output is in use.
Definition windows.c:9