26 destination[
count] = 0;
30#if (LANGUAGE == LANGUAGE_GERMAN) || (LANGUAGE == LANGUAGE_SPANISH) || \
31 (LANGUAGE == LANGUAGE_FRENCH) || (LANGUAGE == LANGUAGE_ITALIAN)
32#define DECODE_EUROPEAN
44#if !defined(DECODE_EUROPEAN)
54#if !defined(DECODE_EUROPEAN)
57 while ((value = decode(&reader)) != 0) {
64#if defined(DECODE_EUROPEAN)
65 value = decode(&reader) + 0xffff;
67 value = decode(&reader) + 0xffff;
69 *text++ = decode(&reader) + delta;
70 value = decode(&reader) + delta;
79#if defined(DECODE_EUROPEAN)
86 value = decode(&reader) + 0xffff;
130 if (work != 0 && work->
flags != 0)
143 poll_work = ch->
work;
144 if (poll_work != 0) {
146 flag = poll_work->
flags;
222 if (work->
names[no] == 0) {
224 work->
names[no] = kind;
228 }
while (no != limit);
241 if (work->
names[i] == kind) {
267 if (cancelKeys != zero) {
289 if (work->
mode != zero)
293 if (cancelKeys != 0) {
339 messageWindow =
NULL;
341 if (render->
entries[entryIndex] != 0) {
345 y = ((15 -
height) >> 1) + yOffset;
350 messageWindow->
width = mode;
351 messageWindow->
height = mode;
383 routine(reader, message);
410 text = (
const u8 *)reader->
words;
411 textBits = reader->
bits;
413 contextBank = code >> 8;
423 if (bit != 0 && treeBits == 0) {
426 treeBits = (treeBits >> 1) | 0x80;
432 if (bit != 0 && textBits == 0) {
435 textBits = (textBits >> 1) | 0x80;
443 if (bit != 0 && treeBits == 0) {
446 treeBits = (treeBits >> 1) | 0x80;
454 }
while (depth >= 0);
457 if (((index * 4) & 7) == 0) {
458 bit = leaves[-(index >> 1)];
460 bit = leaves[-(index >> 1) - 1];
461 code |= (
u32)bit >> 4;
463 leafNibble = leaves[-(index >> 1)];
465 code = leaves[-(index >> 1) - 1] | (leafNibble << 8);
467 reader->
bits = textBits;
481 }
while (index != 2);
488 s32 portraitIndex = 0;
496 if (speakerId == value) {
509 if (speakerId == value) {
537 offset = negativeFour;
545 CreateSideObject(speaker, portraitOption, -1, window, offset, negativeFour);
564 if (resourceId == -1)
575 resourceId = state->
outputIds[portraitSlot];
577 for (windowIndex = 0; windowIndex !=
WINDOW_COUNT; windowIndex++, window++) {
583 if (portraitOutput ==
NULL)
586 if ((
u8)portraitOutput->
kind == 2 &&
587 (
u8)portraitOutput->
index == resourceId) {
s32 UiText_BuildRenderEntries(s32 script, s32 clear)
Decodes message script into the ring of decoded text (UiRenderWork.entries) and returns where it star...
s32 AudioCommand_GetStateByteFar(void)
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
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.
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.
s32 UiWork_IsComplete(void)
Returns 1 when every message channel has finished its text (or is idle), and 0 while one is still typ...
const u8 Text_DecodeSymbol[]
u8 UiText_LookupMessageCodeSize[]
u8 Text_DecodeSymbolCodeSize[]
const u8 UiText_LookupMessageArm[]
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,...
#define RamCode_LoadSlot(slot, code, bytes)
Allocates a work-slot copy; release it with Runtime_ReleaseHeapBlock.
#define RamCode_Load(to, code, bytes)
Allocates a heap copy; release it with MemFree when finished.
const s16 gPortrait_SpriteMap[100]
{sprite, portrait} pairs of the other speakers, ending in -1: portrait n of this list is portrait 128...
const s16 gPortrait_CharacterMap[20]
{character, portrait} pairs of the playable characters, ending in -1.
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,...
A text channel, one of three, which types decoded text into a window a few characters a frame and run...
struct UiWindow * work
the window typed into; NULL when free
u16 countdown
frames left of a pause, a page wait or a swell
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,...
u16 speakerVoiceCountdown
characters until the next voice blip
u32 values[8]
Message argument values (UiWork_PushValueSlot).
u16 entries[RENDER_ENTRY_MASK+1]
decoded text, a ring of codes
u16 speakerVoiceSound
first of four voice blip sounds; 0 for none
struct UiChannelSlot channels[3]
u16 count
where the next code goes in entries
u16 outputIds[2]
VRAM cache slot of each portrait slot's picture.
u16 resourceIds[2]
picture shown in each portrait slot; 999 when free
u16 names[8]
the MSG_ARG_ kind of each value; 0 for a free slot
u8 busy
Set while a message waits on its sound: the text ends its pauses and pages once the sound is over.
A window: a framed rectangle of the tilemap with its sprite outputs, its opening or closing animation...
u16 frame
The zoom's step: counts down from 7 to 0 while opening, and up from 0 to duration while closing.
u16 effect
The effect a message's TEXT_WINDOW_STATE code sets.
u16 flags
UI_WINDOW_ flags; 0 once closing or free.
u16 state
0 while a message channel is typing into the window; 1 once its text has ended or closed the window,...
struct RenderOutputList output
the sprites the window carries
s16 duration
frames of the zoom under way; 0 when none
The heap's 64 work slots, the first two holding the next free EWRAM and IWRAM addresses.
void * slots[64]
Each slot's block once allocated, else null; slots 0 and 1 are the pool pointers.
s32 UiText_GetResourceDimensions(s32 no, s32 *x, s32 *y, u32 *width, u32 *height)
@ UI_WINDOW_INSTANT
opens and closes at once, with no zoom
s32 Localization_LookupEntryId(u32 value)
Returns the portrait of a character (ids below 20) or another speaker's sprite (128 and up for those)...
UNUSED s32 UiText_DecodeSymbol(struct TextReader *reader)
Decodes the next symbol of a message.
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; ...
s32 UiText_CopyMessageString(s32 message, u16 *destination, u32 capacity)
Decodes message into destination as a zero-terminated string of at most capacity entries,...
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...
s32 UiText_CheckPauseSkipped(struct UiChannelSlot *channel)
Ends a channel's pause early: when the message waits on a sound that has finished (busy),...
s32 UiText_CheckTextDismissed(struct UiChannelSlot *channel)
As UiText_CheckPauseSkipped, but on a newly pressed button: the latched presses while UiRenderWork....
s32 UiText_BuildRenderEntriesMode1(s32 message)
Decodes message and empties the argument table; returns where its decoded text starts.
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.
void UiWork_FinalizePendingCore(void)
Closes each message channel's window whose text has ended, then waits ten frames.
void UiWork_DrainPending(s32 unused)
Closes every window: first the message channels' windows, waiting until they have closed,...
void Ui_AdjustValueWithoutLimit(s32 message, u16 *text)
Decodes message into text (a u16 string) with no length limit.
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,...
void UiWork_ClearPortraitSlots(void)
Marks both portrait slots free (999).
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,...
void UiWork_FinalizeEntityMatchingLocalizedId(u32 speaker)
Closes the portrait window showing speaker entry, if one is open.
void UiWork_ClearValueNameTables(void)
Empties the table of message arguments.
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.
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...
s32 * Runtime_ClearWordIfSet(s32 *p)
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.
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,...
void UiWork_Finalize(struct UiWindow *window, s32 instant)
Closes a window: clears its contents and remembers its last rectangle.
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,...