9#define CANVAS_COLUMNS 30
10#define CANVAS_COLUMN_WORDS 32
11#define CANVAS_KEPT_ROWS 8
71 channel->
entry = pending;
85 }
while (channelNo != 3);
121 glyphsLeft = lag * 5 + 3;
139 if (channel->
ended == 0)
149 if (channel->
y >= 13 << 8) {
153 channel->
y += 13 << 8;
156 channel->
y += 15 << 8;
157 if (channel->
line <= 2)
185 window = channel->
work;
188 oldWidth = window->
width;
189 oldHeight = window->
height;
190 entryIndex = channel->
entry;
197 if (work->
entries[entryIndex] != 0 &&
199 if (channel->
flags != 0) {
206 if (oldHeight != newHeight)
207 y -= newHeight - oldHeight;
213 x += (
s32)(oldWidth - newWidth) / 4;
219 window->
width = newWidth;
220 window->
height = newHeight;
308 pixelX = (channel->
x + 128) / 256;
309 pixelY = (channel->
y + 128) / 256;
311 nextEntryIndex = channel->
entry;
312#if (LANGUAGE == LANGUAGE_JAPANESE) || (LANGUAGE == LANGUAGE_ENGLISH)
317 nextCode = work->
entries[nextEntryIndex];
318#if (LANGUAGE == LANGUAGE_JAPANESE) || (LANGUAGE == LANGUAGE_ENGLISH)
328#if (LANGUAGE != LANGUAGE_JAPANESE)
331#if (LANGUAGE == LANGUAGE_SPANISH)
338 if ((
u16)pair <= 14) {
339 code |= nextCode << 8;
342 }
else if ((
u16)pair <= 15) {
343 code |= nextCode << 8;
352 code |= nextCode << 8;
359 if (glyphWidth != 0) {
373 glyphAdvance = glyphWidth << 8;
374#if (LANGUAGE != LANGUAGE_JAPANESE)
380 channel->
x += glyphAdvance;
382#if (LANGUAGE == LANGUAGE_JAPANESE)
397 }
while (--glyphsLeft != 0);
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...
void AudioCommand_PlayFar(s32 id)
volatile u16 gLagFramesShown
gLagFrameCount as the last frame left it; the text typing paces itself by it.
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.
struct GameState gGameState
const struct FontGlyph gUiText_Glyphs[]
static s32 Iwram_FillWords(void *destination, s32 size, u32 value)
volatile u32 gKeysHeld
Keys down now.
u32 gKeysPressedLatch
Presses since a reader last cleared it.
#define CLAMP(v, low, high)
Keeps v within low to high, the low bound tested first.
void UiWindow_FitOnScreen(s32 entryIndex, s32 *windowX, s32 *windowY, u32 *windowWidth, u32 *windowHeight, u16 *spacing, u32 flags)
Sizes a window for decoded text no and moves (*px, *py) so the window fits on the screen.
u8 messageSpeed
0 to 2; 1 on a new game
A text channel, one of three, which types decoded text into a window a few characters a frame and run...
u16 outline
outline colour; 0 for none
u16 colour
text colour; 15 by default
u16 y
pen, 8.8 fixed-point pixels
u16 flags
nonzero keeps the window's size from page to page
u16 glyphDelay
frames to wait after a glyph while no button is held
u16 x
pen, 8.8 fixed-point pixels
u16 spacing[4]
Extra advance per line, in 1/256 pixels: after every character in Japanese, after a space in the othe...
u16 ended
1 once a TEXT_END code is reached
u16 transition
frames left of the canvas scrolling up a line
u16 lineSpacing
10 by default
u16 line
line of the page, indexes spacing; at most 3
u16 startX
pen x each new line returns to, 8.8 fixed-point pixels
struct UiWindow * work
the window typed into; NULL when free
u16 entry
next code in UiRenderWork.entries
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,...
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
u16 entries[RENDER_ENTRY_MASK+1]
decoded text, a ring of codes
u16 speakerVoiceSound
first of four voice blip sounds; 0 for none
u16 glyphResource
VRAM cache slot of the page arrow; 99 when none.
u16 outline
the current channel's, copied in to draw
u8 menuState
1 from the work's setup; 2 while a battle message is decoded.
u8 pageArrowShown
1 while the next-page arrow is shown
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,...
s16 duration
frames of the zoom under way; 0 when none
#define RENDER_ENTRY_MASK
const u8 gUiText_SpeedDelays[3]
Frames to wait after each glyph while no button is held.
const u8 gUiText_SpeedCueGaps[3]
Glyphs between two of the speaker's voice blips.
const u8 gUiText_SpeedSteps[3]
Glyphs a message channel draws each frame.
void UiWork_ProcessRenderChannels(void)
The per-frame message update: each message channel whose window is fully open runs its window effect ...
#define CANVAS_COLUMN_WORDS
s32 UiWork_StepChannelScript(struct UiChannelSlot *channel)
Types one frame's share of a channel's text: runs control codes (new line, new page,...
void UiText_ScrollCanvasUp(s32 step)
Scrolls the battle message canvas up by 6 pixel rows per step, below its top 8 rows,...
#define CANVAS_KEPT_ROWS
the top 8 pixel rows stay put
@ CHANNEL_STEP_ENDED
the text has ended; the window stays open
@ CHANNEL_STEP_RUNNING
the text goes on next frame
@ CHANNEL_STEP_CLOSE
the text is dismissed: close the window
@ UI_WINDOW_TEXT_CANVAS
text is drawn into a canvas of bitmap tiles (UiWindow_MapTextCanvasTiles)
@ UI_WINDOW_FIXED_X
when a new page resizes the window, its left edge stays put
@ UI_WINDOW_ANCHOR_BOTTOM
when a new page resizes the window, its bottom edge stays put
@ UI_WINDOW_INSTANT
opens and closes at once, with no zoom
#define DMA_COPY32(count)
The DMA control word that copies count words.
s32 Resource_ResetEntry(u32 no)
Frees cache entry no: its blocks go back and the entry is marked free (offset 0xffff).
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....
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 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...
What every part of the window object shares: its includes, edition values, macros and the codes of de...
@ TEXT_PAUSE_SHORT
a 20-frame pause a button can cut short
@ TEXT_WINDOW_STATE
the next entry is the window effect to run
@ TEXT_PAUSE_LONGEST
a 120-frame pause a button can cut short
@ TEXT_OUTLINE
the next entry is the outline colour
@ TEXT_WAIT_KEY
wait for a button, then close the window
@ TEXT_VOICED_MARK
dakuten
@ TEXT_PAGE
wait for a button, then clear the window for a new page
@ TEXT_SEMIVOICED_MARK
handakuten
@ TEXT_COLOUR
the next entry is the text colour
@ TEXT_LINE_SPACING
the next entry is the line spacing
@ TEXT_PAUSE_LONG
a 60-frame pause
#define TEXT_CODE_SEMIVOICED
#define NO_GLYPH_RESOURCE
A glyph resource id meaning no glyph resource is loaded.
void RenderOutput_PrepareForRedraw(struct UiWindow *window)
Clears a window's contents: redraws its empty frame and releases the render outputs it carries.
void UiText_ApplyChannelStyle(struct UiChannelSlot *channel)
Copies the channel's text colour, outline and line spacing into the shared glyph renderer before that...
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.
void UiWork_Finalize(struct UiWindow *window, s32 instant)
Closes a window: clears its contents and remembers its last rectangle.
void UiText_StartCanvasScroll(struct UiChannelSlot *channel)
Starts a channel scrolling its canvas up a line, over two frames.