54 }
while (remainingLinks >= 0);
108 s32 UiWork_CopyTileTail(
u32 sourceTile,
u32 destinationTile) {
110 destinationTile &= 0x3ff;
149 for (tileIndex = 2; tileIndex >= 0; tileIndex--)
218 if (*inBattle != 0) {
225 if (column < width) {
229 }
while (column < width);
232 cursor += 32 - width;
233 }
while (row < height);
252 flags = window->
flags;
258 width = window->
width;
361 window->
flags = zero;
369 window->
width = zero;
373 window->
unk10 = zero;
375 window->
state = zero;
376 window->
flags = zero;
377 window->
frame = zero;
385 window->
frame = instant;
417 while (node !=
NULL) {
454 tiles = work->
tilemap + top * 32 + left;
455 for (row = 0; row < height; row++) {
456 for (left = 0; left < width; left++)
470 while (node !=
NULL) {
498 if ((
u8)entry->
kind != 0) {
500 if ((
u8)entry->
kind == 2) {
530 found->
work = window;
577 if (selected->
work == 0) {
578 selected->
y = 10 << 8;
579 selected->
work = window;
580 selected->
x = 3 << 8;
581 }
else if (keepPosition == 0) {
582 if (selected->
y == 0) {
583 selected->
y = 10 << 8;
584 }
else if (selected->
y < 13 << 8) {
585 selected->
y += 13 << 8;
589 selected->
x = 3 << 8;
593 selected->
startX = 3 << 8;
601 selected->
line = zero;
602 selected->
ended = zero;
637 if (selection != 0) {
638 if (selection->
work != 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 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.
void UiWork_ResetCounters(void)
Resets the text style glyphs are drawn with: colour 15, no outline, line spacing 10.
void UiWork_InitCountersWithResourceAndScheduleRefresh(void)
Loads the glyph tiles, resets the text style and starts the per-frame window update (UiWork_ProcessAl...
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 * Runtime_AllocateBlock(s32 kind, s32 size)
As Runtime_AllocateHeapBlock, but tries EWRAM first, for blocks that need room more than speed: the b...
static s32 Iwram_FillWords(void *destination, s32 size, u32 value)
static s32 Iwram_ClearWords(void *destination, s32 size)
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...
A list of render outputs: its first output and the link to append after.
struct RenderOutput ** tailLink
struct RenderOutput * head
A render output: a sprite in a window's output list (a character, an icon or a portrait),...
s8 active
its UI_SPRITE_ motion; 0 while free
struct RenderOutput * next
the next output in its list
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 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 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,...
struct RenderOutput outputs[UI_OUTPUT_COUNT]
u16 tilemap[640]
the windows' BG tilemap, 32 by 20 tiles
u8 dirty
The tilemap's 4-row bands to upload: bit 0 for all, bit n + 1 for band n.
u8 level
text tiles' palette; 15 by default, 14 or 5 for low HP
u16 glyphResource
VRAM cache slot of the page arrow; 99 when none.
u16 colour
the current channel's, copied in to draw
u16 outline
the current channel's, copied in to draw
u8 tileAttributes[256]
Per text tile (tiles 0x80 to 0xFF, then 0x200 to 0x27F): bit 0 once allocated, bit 1 while the tilema...
u8 menuState
1 from the work's setup; 2 while a battle message is decoded.
u8 menuBusy
while set, the tilemap is not uploaded
struct RenderOutputList freeOutputs
the outputs not in any window
u16 lineSpacing
the current channel's, copied in to draw
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
#define RENDER_PALETTE_TABLE_OFFSET
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,...
#define UI_TILE_PAIR(entry)
Two copies of a tilemap entry, for filling a run of entries a word at a time.
#define UI_TILEMAP_VRAM
The UI tilemap in VRAM (BG screen block 4), which UiWork_UploadDirtyBlocks copies the work block's ti...
#define UI_TILE(tile)
A tilemap entry of palette 15, the UI palette.
#define DMA_FILL32(count)
The DMA control word that fills count words from one fixed source word.
#define DMA_COPY16(count)
The DMA control word that copies count halfwords.
@ 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_FRAMED_CANVAS
the canvas has a frame and a filled background; without it the canvas is transparent and frameless
@ UI_WINDOW_ANCHOR_BOTTOM
when a new page resizes the window, its bottom edge stays put
@ UI_WINDOW_OUTLINED_TEXT
the canvas text gets an outline
@ UI_WINDOW_OPEN
the window slot is in use
@ UI_WINDOW_INSTANT
opens and closes at once, with no zoom
#define DMA_COPY32(count)
The DMA control word that copies count words.
@ UI_TILE_FRAME_BOTTOM_LEFT
@ UI_TILE_FRAME_BOTTOM_RIGHT
s32 Resource_ResetEntry(u32 no)
Frees cache entry no: its blocks go back and the entry is marked free (offset 0xffff).
void UiWork_ClearPortraitSlots(void)
Marks both portrait slots free (999).
What every part of the window object shares: its includes, edition values, macros and the codes of de...
#define UI_MESSAGE_LINE_COUNT
#define UI_MESSAGE_CHANNEL_COUNT
#define UI_TEXT_DEFAULT_LINE_SPACING
#define NO_GLYPH_RESOURCE
A glyph resource id meaning no glyph resource is loaded.
#define UI_TILEMAP_PALETTE
#define UI_WINDOW_CLOSE_FRAMES
#define UI_TEXT_DEFAULT_COLOUR
#define UI_WINDOW_OPEN_FRAMES
#define UI_PALETTE_SLOT_FREE
#define UI_CANVAS_BACKGROUND_WORD
void RenderOutput_AppendToList(struct RenderOutputList *list, struct RenderOutput *node)
Adds a render output to the end of a list; NULL lists are ignored.
void RenderOutput_InitFreeList(void)
Links all 64 render outputs of the pool into the free list.
void RenderOutput_PrepareForRedraw(struct UiWindow *window)
Clears a window's contents: redraws its empty frame and releases the render outputs it carries.
void RenderOutput_Release(struct RenderOutput *entry)
Frees a render output: returns it to the free list, releases its resource, and for a kind-2 output fr...
void UiWork_ResetFreeChannel(void)
Resets the pen and text style of the first idle message channel, clearing the canvas when the channel...
s32 Ui_ClearVramBlock(void)
Clears the text canvas to transparent.
s32 Ui_FillVramBlockPattern(void)
Fills the text canvas with the window background colour (4).
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.
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 UiWindow_WaitZoom(struct UiWindow *window)
Waits until a zooming window has finished opening or closing.
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 UiWork_UploadDirtyBlocks(void)
The per-frame tilemap upload: copies each 256-byte band of the tilemap (four tile rows) marked in the...
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_Initialize(s32 loadGlyphTiles)
Sets up the window system for battle, as UiWork_InitializeWithResourceCounters does for the field,...
void UiWork_Finalize(struct UiWindow *window, s32 instant)
Closes a window: clears its contents and remembers its last rectangle.
void RenderOutput_ReleaseFree(struct RenderOutput *out)
Returns a render output to the end of the free list.
void UiText_StartCanvasScroll(struct UiChannelSlot *channel)
Starts a channel scrolling its canvas up a line, over two frames.
UNUSED void RenderOutputList_UpdateTail(struct RenderOutputList *list)
Points a list's tail link back at its last output, after the list has been edited by hand.
void RenderOutput_ClearList(void *outputs)
Releases every render output in a list and empties it.
struct RenderOutput * RenderOutput_AcquireFree(void)
Takes the first render output from the free list, or returns NULL when every output is in use.
void UiWork_InitializeWithResourceCounters(void)
Sets up the window system for the field (and the other screens outside battle): allocates and clears ...
void UiWindow_ClearInteriorTiles(const struct UiWindow *window, u32 left, u32 top, u32 right, u32 bottom)
Clears an area of a window's interior to the window fill.
void RenderOutput_RedrawSavedRect(struct UiWindow *window)
Redraws a window's empty frame at its current 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,...