Alchemy
Loading...
Searching...
No Matches

messages.c

Go to the documentation of this file.
1/// @file
2/// Message strings and arguments, symbol decoding and portrait windows.
3/// Part of window.c, the window object, compiled only through it.
4
6
7/// Decodes message into text (a u16 string) with no length limit.
8void Ui_AdjustValueWithoutLimit(s32 message, u16 *text) {
9 UiText_DecodeMessage(message, text, 0x7fffffff);
10}
11
12/// Decodes message into destination as a zero-terminated string of at most
13/// capacity entries, and returns its length.
14/// capacity counts halfwords including the terminator and must be at least 1.
15s32 UiText_CopyMessageString(s32 message, u16 *destination, u32 capacity) {
16 struct UiRenderWork *work;
17 u32 count;
18
19 work = UI_WORK;
20 work->count = 0;
21 UiText_BuildRenderEntries(message, 1);
22 for (count = 0;
23 count < capacity - 1 && (destination[count] = work->entries[count]) != 0;
24 count++) {
25 }
26 destination[count] = 0;
27 return count;
28}
29
30#if (LANGUAGE == LANGUAGE_GERMAN) || (LANGUAGE == LANGUAGE_SPANISH) || \
31 (LANGUAGE == LANGUAGE_FRENCH) || (LANGUAGE == LANGUAGE_ITALIAN)
32#define DECODE_EUROPEAN
33#endif
34
35/// Decodes message into text as a zero-terminated string of 16-bit codes, with
36/// at most capacity entries, keeping style codes with their operands.
37/// capacity includes the terminating halfword; the unbounded wrapper supplies
38/// -1.
39void UiText_DecodeMessage(s32 message, u16 *text, s32 capacity) {
40 struct TextReader reader;
41 void *original;
42 s32 (*decode)(struct TextReader *);
43 u32 value;
44#if !defined(DECODE_EUROPEAN)
45 u16 delta;
46#endif
47
48 original = ((union HeapState *)&gWorkSlot)->slots[50];
49 if (original == NULL)
51 decode =
52 (s32 (*)(struct TextReader *))((union HeapState *)&gWorkSlot)->slots[50];
53 UiText_LookupMessage(&reader, message);
54#if !defined(DECODE_EUROPEAN)
55 delta = 0xffff;
56#endif
57 while ((value = decode(&reader)) != 0) {
58 switch (value) {
59 case 14:
60 capacity -= 3;
61 if (capacity <= 0)
62 goto done;
63 *text++ = value;
64#if defined(DECODE_EUROPEAN)
65 value = decode(&reader) + 0xffff;
66 *text++ = value;
67 value = decode(&reader) + 0xffff;
68#else
69 *text++ = decode(&reader) + delta;
70 value = decode(&reader) + delta;
71#endif
72 break;
73 case 8:
74 case 9:
75 case 10:
76 case 11:
77 case 12:
78 case 15:
79#if defined(DECODE_EUROPEAN)
80 case 29:
81#endif
82 capacity--;
83 if (capacity <= 0)
84 goto done;
85 *text++ = value;
86 value = decode(&reader) + 0xffff;
87 break;
88 default:
89 capacity--;
90 if (capacity <= 0)
91 goto done;
92 break;
93 }
94 *text++ = value;
95 }
96done:
97 if (original == NULL)
99 *text = 0;
100}
101
103 if (*p != 0) {
104 *p = 0;
105 }
106 return p;
107}
108
109// Closing the message channels' windows, and the message argument table.
110
111/// Closes every window: first the message channels' windows, waiting until
112/// they have closed, then the windows opened directly.
113/// Channel references are cleared only after their windows finish closing.
115 struct UiRenderWork *uw;
116 struct UiChannelSlot *ch;
117 struct UiWindow *win;
118 u32 done;
119 struct UiWindow *work;
120 struct UiWindow *poll_work;
121 s32 i;
122 u16 flag;
123
124 uw = UI_WORK;
125 ch = uw->channels;
126 win = uw->windows;
127 i = 0;
128 do {
129 work = ch->work;
130 if (work != 0 && work->flags != 0)
131 UiWork_Finalize(work, 0);
132 i++;
133 ch++;
134 } while (i != 3);
135
136 // Free each channel whose window has closed; while one is still closing,
137 // wait a frame.
138 for (;;) {
139 done = 1;
140 ch = uw->channels;
141 i = 0;
142 do {
143 poll_work = ch->work;
144 if (poll_work != 0) {
145 if (poll_work->frame == 0 && poll_work->duration == 0) {
146 flag = poll_work->flags;
147 if (flag == 0)
148 ch->work = (struct UiWindow *)(u32)flag;
149 else
150 done = 0;
151 } else {
152 done = 0;
153 }
154 }
155 i++;
156 ch++;
157 } while (i != 3);
158 i = 0;
159 if (done)
160 break;
161 WaitFrames(1);
162 }
163
164 // Then the windows opened directly.
165 for (;;) {
166 if (i == WINDOW_COUNT)
167 break;
168 if (win->flags != 0)
169 UiWork_Finalize(win, 0);
170 win++;
171 i++;
172 }
173}
174
175/// Steps a channel's window effect (UI_WINDOW_EFFECT_SWELL): the frame is drawn
176/// a tile bigger on every side until the countdown ends, then back to normal.
178 struct UiWindow *window = channel->work;
179 s32 effect = window->effect;
180 s32 x = window->x;
181 s32 y = window->y;
182 s32 width = window->width;
183 s32 height = window->height;
184
186 return;
187
188 UiWindow_DrawFrame(x - 1, y - 1, width + 2, height + 2);
189 channel->countdown--;
190 if (channel->countdown != 0)
191 return;
192
193 channel->work->effect = 0;
194 UiWindow_EraseBorderRect(x - 1, y - 1, width + 2, height + 2);
196}
197
198/// Empties the table of message arguments.
200 s32 no;
201 struct UiRenderWork *work;
202
203 work = UI_WORK;
204 no = 0;
205
206 do {
207 work->values[no] = 0;
208 work->names[no] = 0;
209 no++;
210 } while (no != UI_ARGUMENT_SLOT_COUNT);
211}
212
213/// Adds a message argument of kind (MSG_ARG_) with value to the first free
214/// place of the argument table; when all eight are in use it is dropped.
215/// Kind 0 denotes an empty slot.
216void UiWork_PushValueSlot(u32 value, u32 kind) {
217 struct UiRenderWork *work = UI_WORK;
218 u32 no = 0;
220
221 do {
222 if (work->names[no] == 0) {
223 work->values[no] = value;
224 work->names[no] = kind;
225 break;
226 }
227 no++;
228 } while (no != limit);
229}
230
231/// Returns the value of the first message argument of kind (MSG_ARG_), or 0
232/// when there is none. With clear set the argument is removed from the table.
233/// Repeated kinds are allowed: only the first matching slot is read or
234/// consumed.
236 struct UiRenderWork *work = UI_WORK;
237 u32 i;
238 u32 value = 0;
239
240 for (i = 0; i < UI_ARGUMENT_SLOT_COUNT; i++) {
241 if (work->names[i] == kind) {
242 value = work->values[i];
243 if (clear != 0) {
244 work->values[i] = 0;
245 work->names[i] = 0;
246 }
247 break;
248 }
249 }
250 return value;
251}
252
253/// Ends a channel's pause early: when the message waits on a sound that has
254/// finished (busy), or while A, B, L or R is held. Clears the countdown and
255/// returns 1 if it ended.
256/// This path uses held keys; dismissal below uses newly pressed keys instead.
258 struct UiRenderWork *work = UI_WORK;
259 s32 cancelKeys = 0;
260 s32 zero;
261
262 if (work->busy != 0 && AudioCommand_GetStateByteFar() == 0)
263 cancelKeys = 1;
264 zero = 0;
266 cancelKeys = 1;
267 if (cancelKeys != zero) {
268 channel->countdown = zero;
269 return 1;
270 }
271 return zero;
272}
273
274/// As UiText_CheckPauseSkipped, but on a newly pressed button: the latched
275/// presses while UiRenderWork.mode is set. Returns 1 when the player has
276/// dismissed the text.
277/// Mode chooses latched presses rather than changing which buttons dismiss
278/// text.
280 struct UiRenderWork *work = UI_WORK;
281 s32 pressedKeys;
282 s32 cancelKeys = 0;
283 u8 zero;
284
285 if (work->busy != 0 && AudioCommand_GetStateByteFar() == 0)
286 cancelKeys = 1;
287 pressedKeys = gKeysPressed;
288 zero = 0;
289 if (work->mode != zero)
290 pressedKeys = gKeysPressedLatch;
291 if (pressedKeys & (KEY_A | KEY_B | KEYS_SHOULDERS))
292 cancelKeys = 1;
293 if (cancelKeys != 0) {
294 channel->countdown = zero;
295 return 1;
296 }
297 return 0;
298}
299
300/// Closes each message channel's window whose text has ended, then waits ten
301/// frames.
303 s32 i;
304 struct UiChannelSlot *ch;
305 struct UiWindow *work;
306
307 ch = UI_WORK->channels;
308 i = 0;
309 do {
310 work = ch->work;
311 if (work != NULL && work->frame == 0 && work->duration == 0 &&
312 work->flags != 0 && work->state != 0) {
314 }
315 i++;
316 ch++;
317 } while (i != 3);
318 WaitFrames(10);
319}
320
321/// Shows a message centred on the screen (yOffset tiles lower) and waits until
322/// it is typed out, then closes it. With mode 0 the window has no frame or
323/// size and opens and closes at once; otherwise it is a zooming window sized
324/// to the message.
325void UiText_ShowCenteredMessage(s32 message, s32 mode, s32 yOffset) {
326 struct UiRenderWork *render;
327 struct UiWindow *messageWindow;
328 s32 x;
329 s32 y;
330 s32 width;
331 s32 height;
332 s32 entryIndex;
333
334 render = UI_WORK;
335 x = 8;
336 y = 8;
337 // the window starts as NULL, though every path that reads it assigns it
338 // first; the same zero is the style argument below
339 messageWindow = NULL;
340 entryIndex = UiText_BuildRenderEntries(message, 1);
341 if (render->entries[entryIndex] != 0) {
342 UiText_GetResourceDimensions(message, &x, &y, (u32 *)&width,
343 (u32 *)&height);
344 x = (30 - width) >> 1;
345 y = ((15 - height) >> 1) + yOffset;
346 if (mode != 0)
347 messageWindow = UiWindow_Create(x, y, width, height, 0);
348 else {
349 messageWindow = UiWindow_Create(x, y, 0, 0, 2);
350 messageWindow->width = mode;
351 messageWindow->height = mode;
352 }
353 if (UiText_QueueRenderEntries(messageWindow, entryIndex, 0, 0, 0, 0) == 0)
354 UiWork_Finalize(messageWindow, 1);
355 else {
356 while (UiWork_IsComplete() == 0)
357 WaitFrames(1);
358 if (mode != 0) {
359 UiWork_Finalize(messageWindow, 0);
360 while (UiWork_IsIdle(messageWindow) == 0)
361 WaitFrames(1);
362 } else
363 UiWork_Finalize(messageWindow, 1);
364 render->speakerVoiceSound = 0;
365 render->speakerVoiceCountdown = 0;
366 }
367 }
368}
369
370/// Decodes message and empties the argument table; returns where its
371/// decoded text starts.
373 return UiText_BuildRenderEntries(message, 1);
374}
375
376/// Points reader at the start of message (its compressed bits and first
377/// context), running the ARM lookup routine from a RAM copy.
378/// The RAM routine initializes reader state; symbols are decoded separately.
379void UiText_LookupMessage(struct TextReader *reader, s32 message) {
380 void (*routine)(struct TextReader *, s32);
381
383 routine(reader, message);
384 MemFree(routine);
385}
386
387/// Decodes the next symbol of a message. Messages are Huffman coded with one
388/// tree per previous symbol: the previous code picks the tree, the message's
389/// bits walk it to a leaf, and the leaf's 12-bit symbol is returned and
390/// becomes the next context.
391/// Tree traversal consumes bytes; reader->words retains that byte position
392/// between calls.
393/// Nothing calls it.
395 u32 code;
396 u32 contextBank;
397 const u8 *base;
398 const u8 *tree;
399 const u8 *leaves;
400 const u8 *text;
401 s32 textBits;
402 s32 treeBits;
403 s32 rank;
404 s32 depth;
405 s32 bit;
406 u32 index;
407 u32 leafNibble;
408
409 code = reader->previousCode;
410 text = (const u8 *)reader->words;
411 textBits = reader->bits;
412 treeBits = 1;
413 contextBank = code >> 8;
414 code &= 0xff;
415 base = Text_MessageContexts[contextBank][0];
416 base += ((const u16 *)Text_MessageContexts[contextBank][1])[code];
417 tree = base;
418 leaves = base - 1;
419 rank = 0;
420 for (;;) {
421 bit = treeBits & 1;
422 treeBits >>= 1;
423 if (bit != 0 && treeBits == 0) {
424 treeBits = *tree++;
425 bit = treeBits & 1;
426 treeBits = (treeBits >> 1) | 0x80;
427 }
428 if (bit != 0)
429 break;
430 bit = textBits & 1;
431 textBits >>= 1;
432 if (bit != 0 && textBits == 0) {
433 textBits = *text++;
434 bit = textBits & 1;
435 textBits = (textBits >> 1) | 0x80;
436 }
437 if (bit == 0)
438 continue;
439 depth = 0;
440 do {
441 bit = treeBits & 1;
442 treeBits >>= 1;
443 if (bit != 0 && treeBits == 0) {
444 treeBits = *tree++;
445 bit = treeBits & 1;
446 treeBits = (treeBits >> 1) | 0x80;
447 }
448 if (bit == 0)
449 depth++;
450 else {
451 rank++;
452 depth--;
453 }
454 } while (depth >= 0);
455 }
456 index = rank * 3;
457 if (((index * 4) & 7) == 0) {
458 bit = leaves[-(index >> 1)];
459 code = bit << 4;
460 bit = leaves[-(index >> 1) - 1];
461 code |= (u32)bit >> 4;
462 } else {
463 leafNibble = leaves[-(index >> 1)];
464 leafNibble &= 0xf;
465 code = leaves[-(index >> 1) - 1] | (leafNibble << 8);
466 }
467 reader->bits = textBits;
468 reader->previousCode = code;
469 reader->words = (const u32 *)text;
470 return code;
471}
472
473/// Marks both portrait slots free (999).
475 struct UiRenderWork *work = UI_WORK;
476 s32 index = 0;
477
478 do {
479 work->resourceIds[index] = 999;
480 index++;
481 } while (index != 2);
482}
483
484/// Returns the portrait of a character (ids below 20) or another speaker's
485/// sprite (128 and up for those), or -1 when it has none.
487 s32 result = -1;
488 s32 portraitIndex = 0;
489
490 if (value < 20) {
491 for (;;) {
492 s32 speakerId = gPortrait_CharacterMap[portraitIndex];
493
494 if (speakerId == -1)
495 break;
496 if (speakerId == value) {
497 portraitIndex++;
498 result = gPortrait_CharacterMap[portraitIndex];
499 break;
500 }
501 portraitIndex += 2;
502 }
503 } else {
504 for (;;) {
505 s32 speakerId = gPortrait_SpriteMap[portraitIndex];
506
507 if (speakerId == -1)
508 break;
509 if (speakerId == value) {
510 portraitIndex++;
511 result = gPortrait_SpriteMap[portraitIndex];
512 result += 128;
513 break;
514 }
515 portraitIndex += 2;
516 }
517 }
518 return result;
519}
520
521/// Opens a portrait window at tile (x, y) showing the speaker's portrait.
522/// portraitOption is passed on to the portrait object. Returns the window,
523/// or 0 when the speaker has no portrait.
524/// Portrait offsets are in pixels; the enclosing window bounds are in tiles.
525struct UiWindow *UiWindow_CreateWithSideObject(s32 speaker, s32 portraitOption,
526 s32 x, s32 y) {
527 struct UiWindow *window;
528 s32 negativeFour;
529 s32 offset;
530 void *work;
531
532 work = gWindowWork[0];
533 if (Localization_LookupEntryId(speaker) == -1) {
534 return 0;
535 }
536 negativeFour = -4;
537 offset = negativeFour;
538 if (((struct UiRenderWork *)work)->mode != 0) {
539 window = UiWindow_Create(x, y, 6, 5, 2);
540 offset = 0;
541 } else {
542 window = UiWindow_Create(x, y, 5, 5, 2);
543 }
544 if (window != 0) {
545 CreateSideObject(speaker, portraitOption, -1, window, offset, negativeFour);
546 }
547 return window;
548}
549
550/// Closes the portrait window showing speaker entry, if one is open.
551/// resourceIds selects the portrait slot, then outputIds identifies its render
552/// output.
554 struct UiRenderWork *state;
555 struct UiWindow *window;
556 s32 resourceId;
557 s32 portraitSlot;
558 s32 windowIndex;
559 struct RenderOutput *portraitOutput;
560
561 state = UI_WORK;
562 window = state->windows;
563 resourceId = Localization_LookupEntryId(speaker);
564 if (resourceId == -1)
565 return;
566
567 if (state->resourceIds[1] == resourceId) {
568 portraitSlot = 1;
569 } else if (state->resourceIds[0] == resourceId) {
570 portraitSlot = 0;
571 } else {
572 return;
573 }
574
575 resourceId = state->outputIds[portraitSlot];
576
577 for (windowIndex = 0; windowIndex != WINDOW_COUNT; windowIndex++, window++) {
578 portraitOutput = window->output.head;
579#ifdef UBFIX
580 // UiWindow_Create and the closing update leave empty heads NULL. Skip
581 // them before reading kind: dereferencing that NULL pointer is undefined.
582 // The plain guard adds four bytes to the native English object.
583 if (portraitOutput == NULL)
584 continue;
585#endif
586 if ((u8)portraitOutput->kind == 2 &&
587 (u8)portraitOutput->index == resourceId) {
588 UiWork_Finalize(window, 2);
589 return;
590 }
591 }
592}
s32 UiText_BuildRenderEntries(s32 script, s32 clear)
Decodes message script into the ring of decoded text (UiRenderWork.entries) and returns where it star...
Definition decode.c:276
s32 AudioCommand_GetStateByteFar(void)
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
Definition frame.c:97
void UiWindow_DrawFrame(s32 x, s32 y, u32 width, u32 height)
Draws an empty window: a frame around a filled interior, at tile (x, y) of width by height tiles.
Definition frames.c:131
s32 UiWork_IsIdle(struct UiWindow *window)
Returns 1 when a window is fully closed (its slot free), and 0 while it is open or closing.
Definition frames.c:224
s32 UiWork_IsComplete(void)
Returns 1 when every message channel has finished its text (or is idle), and 0 while one is still typ...
Definition frames.c:210
const u8 Text_DecodeSymbol[]
u8 UiText_LookupMessageCodeSize[]
u8 Text_DecodeSymbolCodeSize[]
const u8 UiText_LookupMessageArm[]
@ KEY_B
Definition io_reg.h:244
@ KEY_A
Definition io_reg.h:243
@ KEYS_SHOULDERS
Definition io_reg.h:256
volatile u32 gKeysHeld
Keys down now.
volatile u32 gKeysPressed
Keys that went down this frame.
u32 gKeysPressedLatch
Presses since a reader last cleared it.
void Runtime_ReleaseHeapBlock(s32 slot)
void MemFree(void *buffer)
struct RenderOutput * CreateSideObject(s32 character, s32 unused, s32 side, struct UiWindow *window, s32 x, s32 y)
Shows the 32x32 portrait of character at (x, y) in window, in portrait slot side (0 or 1,...
Definition outputs.c:138
#define RamCode_LoadSlot(slot, code, bytes)
Allocates a work-slot copy; release it with Runtime_ReleaseHeapBlock.
Definition ramcode.h:26
#define RamCode_Load(to, code, bytes)
Allocates a heap copy; release it with MemFree when finished.
Definition ramcode.h:15
const s16 gPortrait_SpriteMap[100]
{sprite, portrait} pairs of the other speakers, ending in -1: portrait n of this list is portrait 128...
Definition scales.c:87
const s16 gPortrait_CharacterMap[20]
{character, portrait} pairs of the playable characters, ending in -1.
Definition scales.c:72
#define NULL
Definition bilibin.h:6
void * gWorkSlot[]
u8 gWindowWork[]
struct RenderOutput * head
A render output: a sprite in a window's output list (a character, an icon or a portrait),...
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 position in a Huffman-coded message: the previous code, which picks the next symbol's tree,...
Definition text_reader.h:13
u32 previousCode
Definition text_reader.h:14
const u32 * words
Definition text_reader.h:15
A text channel, one of three, which types decoded text into a window a few characters a frame and run...
Definition uiwindow.h:43
struct UiWindow * work
the window typed into; NULL when free
Definition uiwindow.h:44
u16 countdown
frames left of a pause, a page wait or a swell
Definition uiwindow.h:52
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
u16 speakerVoiceCountdown
characters until the next voice blip
Definition window.h:61
u32 values[8]
Message argument values (UiWork_PushValueSlot).
Definition window.h:56
u16 entries[RENDER_ENTRY_MASK+1]
decoded text, a ring of codes
Definition window.h:46
u16 speakerVoiceSound
first of four voice blip sounds; 0 for none
Definition window.h:60
struct UiChannelSlot channels[3]
Definition window.h:22
u16 count
where the next code goes in entries
Definition window.h:48
u16 outputIds[2]
VRAM cache slot of each portrait slot's picture.
Definition window.h:59
u16 resourceIds[2]
picture shown in each portrait slot; 999 when free
Definition window.h:58
u16 names[8]
the MSG_ARG_ kind of each value; 0 for a free slot
Definition window.h:57
u8 busy
Set while a message waits on its sound: the text ends its pauses and pages once the sound is over.
Definition window.h:65
A window: a framed rectangle of the tilemap with its sprite outputs, its opening or closing animation...
Definition uiwindow.h:11
u16 frame
The zoom's step: counts down from 7 to 0 while opening, and up from 0 to duration while closing.
Definition uiwindow.h:28
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 state
0 while a message channel is typing into the window; 1 once its text has ended or closed the window,...
Definition uiwindow.h:24
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
s16 duration
frames of the zoom under way; 0 when none
Definition uiwindow.h:29
#define WINDOW_COUNT
Definition tbs_edition.h:69
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
unsigned short u16
Definition types.h:13
#define UNUSED
Definition types.h:22
unsigned char u8
Definition types.h:11
The heap's 64 work slots, the first two holding the next free EWRAM and IWRAM addresses.
Definition heap_state.h:18
void * slots[64]
Each slot's block once allocated, else null; slots 0 and 1 are the pool pointers.
Definition heap_state.h:26
s32 UiText_GetResourceDimensions(s32 no, s32 *x, s32 *y, u32 *width, u32 *height)
#define UI_WORK
Definition window.h:267
@ UI_WINDOW_INSTANT
opens and closes at once, with no zoom
Definition window.h:29
s32 Localization_LookupEntryId(u32 value)
Returns the portrait of a character (ids below 20) or another speaker's sprite (128 and up for those)...
Definition messages.c:486
UNUSED s32 UiText_DecodeSymbol(struct TextReader *reader)
Decodes the next symbol of a message.
Definition messages.c:394
void UiWork_PushValueSlot(u32 value, u32 kind)
Adds a message argument of kind (MSG_ARG_) with value to the first free place of the argument table; ...
Definition messages.c:216
s32 UiText_CopyMessageString(s32 message, u16 *destination, u32 capacity)
Decodes message into destination as a zero-terminated string of at most capacity entries,...
Definition messages.c:15
void UiText_LookupMessage(struct TextReader *reader, s32 message)
Points reader at the start of message (its compressed bits and first context), running the ARM lookup...
Definition messages.c:379
s32 UiText_CheckPauseSkipped(struct UiChannelSlot *channel)
Ends a channel's pause early: when the message waits on a sound that has finished (busy),...
Definition messages.c:257
s32 UiText_CheckTextDismissed(struct UiChannelSlot *channel)
As UiText_CheckPauseSkipped, but on a newly pressed button: the latched presses while UiRenderWork....
Definition messages.c:279
s32 UiText_BuildRenderEntriesMode1(s32 message)
Decodes message and empties the argument table; returns where its decoded text starts.
Definition messages.c:372
u32 UiText_LookupArgument(u32 kind, u32 clear)
Returns the value of the first message argument of kind (MSG_ARG_), or 0 when there is none.
Definition messages.c:235
void UiWork_FinalizePendingCore(void)
Closes each message channel's window whose text has ended, then waits ten frames.
Definition messages.c:302
void UiWork_DrainPending(s32 unused)
Closes every window: first the message channels' windows, waiting until they have closed,...
Definition messages.c:114
void Ui_AdjustValueWithoutLimit(s32 message, u16 *text)
Decodes message into text (a u16 string) with no length limit.
Definition messages.c:8
void UiText_ShowCenteredMessage(s32 message, s32 mode, s32 yOffset)
Shows a message centred on the screen (yOffset tiles lower) and waits until it is typed out,...
Definition messages.c:325
void UiWork_ClearPortraitSlots(void)
Marks both portrait slots free (999).
Definition messages.c:474
void UiText_DecodeMessage(s32 message, u16 *text, s32 capacity)
Decodes message into text as a zero-terminated string of 16-bit codes, with at most capacity entries,...
Definition messages.c:39
void UiWork_FinalizeEntityMatchingLocalizedId(u32 speaker)
Closes the portrait window showing speaker entry, if one is open.
Definition messages.c:553
void UiWork_ClearValueNameTables(void)
Empties the table of message arguments.
Definition messages.c:199
struct UiWindow * UiWindow_CreateWithSideObject(s32 speaker, s32 portraitOption, s32 x, s32 y)
Opens a portrait window at tile (x, y) showing the speaker's portrait.
Definition messages.c:525
void UiWindow_StepSwellEffect(struct UiChannelSlot *channel)
Steps a channel's window effect (UI_WINDOW_EFFECT_SWELL): the frame is drawn a tile bigger on every s...
Definition messages.c:177
s32 * Runtime_ClearWordIfSet(s32 *p)
Definition messages.c:102
What every part of the window object shares: its includes, edition values, macros and the codes of de...
#define UI_ARGUMENT_SLOT_COUNT
const void *const Text_MessageContexts[][2]
Each message context bank's Huffman models and their offsets, which the message catalog built from ga...
#define TEXT_WORK_BLOCK
The heap block the message decoder routine is copied into to run.
#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...
void UiWindow_EraseBorderRect(s32 x, s32 y, u32 width, u32 height)
Erases a window's rectangle of the tilemap (x, y, width and height in tiles), clamped to the screen.
Definition windows.c:187
struct UiChannelSlot * UiText_QueueRenderEntries(struct UiWindow *window, s32 entry, s32 x, s32 y, u16 *spacing, s32 flags)
Starts a free message channel typing the decoded text that begins at entry into window,...
Definition windows.c:515
void UiWork_Finalize(struct UiWindow *window, s32 instant)
Closes a window: clears its contents and remembers its last rectangle.
Definition windows.c:349
struct UiWindow * UiWindow_Create(s32 x, s32 y, s32 width, s32 height, s32 attrs)
Opens a window at tile (x, y) of width by height tiles in the first free window slot,...
Definition windows.c:279