8#define SUMMON_COST_X 13
10#define SUMMON_COST_X 10
21 u8 learnedSummons[33];
22 u8 orderedSummons[33];
30 s32 drawnRow, drawnFirstEntry, selectedRow, firstEntry;
32 struct UiWindow *description, *counts;
33 s32 mask, preferredRow;
41 s32 pressed, repeated, result;
57 for (index = 0; index < 4; index++) {
60 sprite = &sprites[index];
62 sprite->
oam.f.x = window->
x * 8 + 8;
63 sprite->
oam.f.y = (
y + window->
y) * 8 + 4;
65 for (index = 0; index < 4; index++) {
67 iconSlots[index] = slot;
81 for (i = count - 1; i >= 0; i--) {
85 k = learnedSummons[i];
87 for (n = 0; n <= 3; n++) {
92 orderedSummons[orderedCount++] = k;
100 for (i = 0; i < count; i++) {
101 k = learnedSummons[i];
103 orderedSummons[orderedCount++] = k;
114 if (firstEntry != drawnFirstEntry || selectedRow != drawnRow) {
117 window->
width - 2, 1, 15);
128 MsgAbilityDescription,
132 drawnRow = selectedRow;
134 for (element = 0; element <= 3; element++) {
136 mask |= 1 << element;
141 if (firstEntry != drawnFirstEntry) {
146 for (element = 0; element <= 3; element++) {
157 if ((
id = orderedSummons[firstEntry + index]) !=
SUMMON_END) {
161 for (element = 0; element <= 3; element++) {
165 affordable = element == 4;
167 &iconSlots[index], &glyph, 1);
169 sprites[index].
oam.f.tile = glyph;
175 window, 16, index * 16);
176 for (element = 0; element <= 3; element++) {
186 visibleSummons[index++] = 1;
188 (
id = orderedSummons[firstEntry + index]) !=
SUMMON_END)
192 visibleSummons[index++] = 0;
194 drawnFirstEntry = firstEntry;
199 for (index = 0; index < (count + 3) / 4; index++) {
201 if (index == firstEntry / 4)
204 window, tile, window->
width - (count + 3) / 4 + index - 2, -1, 0);
208 window->
width - 2, 1, 14);
216 for (index = 0; index <= 3; index++) {
217 if (visibleSummons[index] != 0)
222 cursorPosition.
x = window->
x * 8 - 2;
223 cursorPosition.
y = (selectedRow * 2 + window->
y) * 8 + 20;
238 s32 element, tile, blink;
241 for (element = 0; element <= 3; element++) {
242 tile = 15 - (blink != 0);
243 if ((1 << element & mask) == 0)
252 for (index = 0; index < (count + 3) / 4; index++) {
254 if ((
gFrameCount & 15) <= 11 && index == firstEntry / 4)
257 window, tile, window->
width - (count + 3) / 4 + index - 2, -1, 0);
260 window->
width - (count + 3) / 4 - 3, -1, 0);
286 if (pressed &
KEY_A) {
287 result = orderedSummons[firstEntry + selectedRow];
298 if (selectedRow == 4 || firstEntry + selectedRow == count)
300 preferredRow = selectedRow;
301 }
else if (repeated &
KEY_UP) {
304 if (selectedRow < 0) {
306 if (firstEntry == ((count - 1) / 4) * 4)
307 selectedRow = count - firstEntry - 1;
311 preferredRow = selectedRow;
316 if (firstEntry + 4 >= count) {
317 if (firstEntry != 0) {
319 selectedRow = preferredRow;
323 selectedRow = preferredRow;
324 if (firstEntry == ((count - 1) / 4) * 4) {
325 selectedRow = count - firstEntry - 1;
326 if (selectedRow > preferredRow)
327 selectedRow = preferredRow;
334 if (firstEntry != 0) {
336 selectedRow = preferredRow;
338 firstEntry = ((count - 1) / 4) * 4;
339 selectedRow = preferredRow;
340 if (firstEntry != 0) {
341 selectedRow = count - firstEntry - 1;
342 if (selectedRow > preferredRow)
343 selectedRow = preferredRow;
352 for (index = 0; index < 4; index++)
What every part of the menu object shares: its includes, edition values, macros and the link round st...
#define BATTLE_MENU_MESSAGE_COPY
#define SUMMON_MENU_WINDOW_X
@ LIST_TILE_PAGES_RIGHT
Right arrow.
@ SUMMON_ELEMENT_TILE
Element icon.
@ LIST_TILE_PAGE_NUMBER
Page number.
@ LIST_TILE_PAGES_LEFT
Left arrow.
@ LIST_TILE_PAGE_NUMBER_LIT
Current page number.
#define SUMMON_MENU_WINDOW_WIDTH
#define BATTLE_MENU_MESSAGE_CAPACITY
void Ui_SetRectHighlight(s32 x, s32 y, s32 width, s32 height, s32 paletteBit)
Sets bit 12 of each tile in a screen-space rectangle, preserving the other tile attributes.
s32 Summon_ListLearnedFar(u8 *output)
const struct SummonDefinition * SummonDefinition_Get(u32 summon_id)
Far call to SummonDefinition_GetNear.
void AudioCommand_PlayFar(s32 id)
void Input_ResetKeyRepeat(void)
Restarts the key repeat delay, so held keys wait the full delay again.
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
volatile u32 gFrameCount
Frames WaitFrames has finished.
void UiText_RenderWideStringAtOffset(u16 *text, struct UiWindow *window, s32 x, s32 y)
Draws a zero-terminated string of 16-bit character codes into a text canvas window at pixel (x,...
u8 gResource_FixedBlockBTiles[]
volatile u32 gKeysPressed
Keys that went down this frame.
volatile u32 gKeysRepeat
Pressed keys, repeating while held: after 19 frames, then every 6.
void Runtime_PushSlotEntry(void *slotEntry, s32 slot)
Links a sprite entry into depth slot slot (clamped to 0..255) for this frame.
#define SE_MENU_CURSOR_MOVE
A cursor or prompt sprite: a list link and its OAM attributes as fields.
A summon: its name's message and the Djinn of each element it needs.
u16 nameMessageId
The summon's ability id: its name is message MsgAbilityName plus it, and its low 14 bits pick the ico...
u8 djinnRequired[4]
standby Djinn needed, by element
The window system's work: the windows' tilemap, the windows, the three text channels,...
u8 dirty
The tilemap's 4-row bands to upload: bit 0 for all, bit n + 1 for band n.
u8 menuBusy
while set, the tilemap is not uploaded
A window: a framed rectangle of the tilemap with its sprite outputs, its opening or closing animation...
void UiWork_SetParamNibble(s32 param)
Sets the text colour (0 to 15) of drawn text.
void UiText_DrawCharacterAtOffset(s32 message, const struct UiWindow *window, u32 offsetX, u32 offsetY)
Decodes a message and draws it as tiles in a window at pixel (offsetX, offsetY) of its interior.
#define UiRender_MarkRow(render, y)
Requests transfer of the four-row tilemap band containing window row y.
s32 VramCache_AllocEntry(s32 size)
Takes a free cache entry, gives it size bytes of sprite VRAM and returns its number.
s32 VramCache_Reload(s32 no, s32 src)
Copies src again into entry no's VRAM, keeping its size.
s32 Resource_ResetEntry(u32 no)
Frees cache entry no: its blocks go back and the entry is marked free (offset 0xffff).
void Ability_LoadGlyph(s32 action, s32 withBase, s32 *slot, s32 *tile, s32 reuse)
Builds the Psynergy icon of a battle action, as UiIcon_BuildAbilityIconTiles.
void UiWindow_PutGlyph(struct UiWindow *win, u32 tile, u32 x, u32 y, s32 mode)
Puts a character into a window's tilemap as a tile at tile (x, y) of its interior.
void UiWindow_SetTilemapEntry(struct UiWindow *window, s32 value, s32 x, s32 y, u32 mode)
Writes value into a window's tilemap at tile (x, y) of its interior, with the palette mode names (TIL...
s32 Ui_FillVramBlockPattern(void)
Fills the text canvas with the window background colour (4).
void UiWork_Finalize(struct UiWindow *window, s32 instant)
Closes a window: clears its contents and remembers its last rectangle.
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,...