24 if (work->
flags != 0) {
87 remaining = duration - frame;
92 x = (scratch.
result >> 16) + window->
x;
97 width = scratch.
result >> 15;
103 y = (scratch.
result >> 16) + window->
y;
108 height = scratch.
result >> 15;
111 if (savePosition != 0) {
136 if (width <= 1 || height <= 1 || width > 30 || height > 30)
140 if (canvas->
mode != 0)
146 if (canvas->
mode != 0)
150 cursor += 32 - width;
152 for (row = 1; row < height - 1; row++) {
158 cursor += 32 - width;
161 if (canvas->
mode != 0)
167 if (canvas->
mode != 0)
183 if (width <= 1 || height <= 1 || width > 30 || height > 30)
187 if (fullWidth == 0) {
188 for (row = 1; row < height - 1; row++) {
190 for (col = 1; col < width - 1; col++)
195 cursor += 32 - width;
198 for (row = 1; row < height - 1; row++) {
199 for (col = 0; col < width; col++)
202 cursor += 32 - width;
215 for (i = 0; i != 3; i++, ch++) {
270 if (loadGlyphTiles != 0)
287 if (window !=
NULL) {
313 if (state->
entries[entryIndex] != 0) {
314 previousWindow = control->
window;
315 if (previousWindow ==
NULL) {
318 control->
window = messageWindow;
322 messageWindow = previousWindow;
324 if (messageWindow !=
NULL) {
329 if (channel ==
NULL) {
419 if (width == 0 && height == 0)
450 s32 actorPosition[2] = {0, 0};
473 }
else if (
flags & 0x40) {
479 actorTileY = actorPosition[1] >> 3;
480 if (actorTileY > 9) {
489 if (window !=
NULL) {
508 state->speakerVoiceSound = zero;
509 state->speakerVoiceCountdown = zero;
struct BattleDisplayWork * gBattleDisplayWork
s32 UiText_BuildRenderEntries(s32 script, s32 clear)
Decodes message script into the ring of decoded text (UiRenderWork.entries) and returns where it star...
#define Dma_Fill16(value, destination, size)
Fills size bytes at destination with the halfword value by DMA3, from a volatile copy of it on the st...
s32 Object_GetScreenPositionFar(s32 objectId, s32 *position)
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
void UiText_ShowPositionedMessageAndWait(s32 message, s32 flags)
Shows a message in a window centred on the screen, waits until it is typed out and closes 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.
void UiWindow_DrawZoomFrame(void *windowArg, s32 savePosition)
Draws the frame of a zooming window at its size for this frame: the window grows from its centre as f...
void UiText_PrepareMessageWork(s32 argument)
Shows a message in the battle message window, opening the window (a full-width text canvas along the ...
void UiWork_FinalizeSharedSlot(void)
Closes the battle message window, if one is open.
void UiWork_ResetCounters(void)
Resets the text style glyphs are drawn with: colour 15, no outline, line spacing 10.
struct UiWindow * UiText_OpenMessageWindow(s32 message, s32 x, s32 y, u32 packed)
Opens a window sized to a message near tile (x, y) and starts typing the message into it.
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.
void UiWork_InitCountersWithResourceAndScheduleRefresh(void)
Loads the glyph tiles, resets the text style and starts the per-frame window update (UiWork_ProcessAl...
void UiWork_ProcessAll(void)
The window system's per-frame callback: windows, then message channels, then sprite animation.
u16 * Memory_FillHalfwordsDma(u16 *dst, s32 value, s32 count)
Fills count halfwords at dst with value by DMA, and returns the position after them.
void UiWindow_MapTextCanvasTiles(s32 x, s32 y, u32 width, u32 height, s32 fullWidth)
Maps the text canvas tiles into the interior of a window at tile (x, y).
void UiWork_InitCountersAndScheduleRefresh(s32 loadGlyphTiles)
Resets the text style and starts the per-frame window update (UiWork_ProcessAll), loading the glyph t...
void UiText_ShowMessageAndWaitCore(s32 argument)
Shows a message in the battle message window and waits until it has been typed out.
void UiWork_ProcessDirectWork(void)
The per-frame window update: steps each window's zoom while it opens or closes, draws it in full once...
s32 UiWork_IsComplete(void)
Returns 1 when every message channel has finished its text (or is idle), and 0 while one is still typ...
s32 UiText_OpenEntryMessage(struct UiWindow *window, s32 message)
Types a message into an open window from its top left.
void UiWork_SetBusyFlags(s32 flags)
Sets the effects the next message is decoded with (UiText_BuildRenderEntries): flags bit 0 (spacingBe...
struct GameState gGameState
static s32 Iwram_RatioMulQ14(s32 divisor, s32 value)
All calls go through this layer.
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.
s32 Scheduler_AddOrUpdateCallback(SchedulerCallback callback, s32 order)
Schedules callback with order, or gives a task already running it the new order, and re-sorts the tab...
The battle message's text channel, as far as its offset in the window.
The battle message display: its window, its text channel and whether the next message is marked.
s32 marked
set by BATTLE_EVENT_MARK; passed to the next message
struct UiWindow * window
the message window
struct BattleDisplayOffset * offset
its text channel
s32 selectedActor
the leader: its unit and its actor
struct RenderOutput ** tailLink
struct RenderOutput * head
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
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
u8 spacingBefore
1 for halting speech: a pause before each character, broken off with an ellipsis after the first word...
u16 tilemap[640]
the windows' BG tilemap, 32 by 20 tiles
u16 unknownAfterLineSpacing
set to 1 with the text style; not read
u8 dirty
The tilemap's 4-row bands to upload: bit 0 for all, bit n + 1 for band n.
u16 entries[RENDER_ENTRY_MASK+1]
decoded text, a ring of codes
u16 speakerVoiceSound
first of four voice blip sounds; 0 for none
u16 count
where the next code goes in entries
u16 colour
the current channel's, copied in to draw
u16 letterSpacing
pixels between sprite glyphs; 9
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 spacingAfter
1 puts code 222 after certain characters in English and Japanese (UiWork_SetBusyFlags bit 1).
u16 glyphTiles
first sprite tile of the glyph sheet (picture 95)
u16 lineSpacing
the current channel's, copied in to draw
Scratch values for a step of a window's zoom: the scaled part of a side, the scaled duration and thei...
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 unk10
1 once opened, 0 once freed; not read by name in TBS
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
void UiWindow_ClearTileAttributesInRect(s32 x, s32 y, u32 width, u32 height)
Marks the text tiles under a tilemap rectangle (x, y, width and height in tiles) as no longer shown,...
void UiWork_ProcessRenderChannels(void)
The per-frame message update: each message channel whose window is fully open runs its window effect ...
#define UI_CANVAS_FIRST_TILE
#define UI_TILE_PAIR(entry)
Two copies of a tilemap entry, for filling a run of entries a word at a time.
s32 UiText_GetResourceDimensions(s32 no, s32 *x, s32 *y, u32 *width, u32 *height)
#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_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
@ UI_TILE_FRAME_BOTTOM_LEFT
@ UI_TILE_FRAME_ROUND_CORNER
@ UI_TILE_FRAME_TOP_RIGHT
@ UI_TILE_FRAME_BOTTOM_RIGHT
#define TILE_HFLIP
The tilemap entry flip bits.
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_...
What every part of the window object shares: its includes, edition values, macros and the codes of de...
@ HEAP_SLOT_BATTLE_DISPLAY
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,...
struct UiChannelSlot * UiText_StartBattleMessage(struct UiWindow *window, s32 entry, s32 keepPosition)
Starts a channel typing the decoded text at entry into the battle message window.
void UiWindow_DrawOpened(struct UiWindow *window)
Draws a window at its full size: its frame, and for a text canvas window the canvas,...
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,...