17#define CURSOR_OWNER (*(struct PartyStatusWindow **)gPartyStatusWork)
20#define DJINN_ENTRY_STANDBY 0x10000
21#define DJINN_ENTRY_RECOVERY_MASK 0x3e0000
22#define DJINN_ENTRY_RECOVERY_SHIFT 17
23#define DJINN_ENTRY_END 0x80000000
89 for (element = 0; element <= 3; element++) {
91 entryCursor = (
u32 *)((djinnCount << 2) + (
u32)djinnEntries);
92 djinnIndex <= 19; djinnIndex++) {
94 *entryCursor = (
u32)((element << 8) | djinnIndex);
101 (
u32)owner > 7 ? 1 : 0))
103 for (k = 0; k < recovery->
count; k++) {
127 cursorSprite = &cursor;
130 if (firstEntry != drawnFirstEntry || selectedRow != drawnRow ||
132 selectedDjinn = djinnEntries[firstEntry + selectedRow];
136 listWindow->
width - 2, 1, 15);
137 if (previewPage != 0) {
143 if (djinnCount != 0) {
152 for (k = redraw; k == redraw;) {
156 if (selected == selectedDjinn) {
163 k += 1 - alreadySelected;
172 if (alreadySelected != 0) {
175 if (previewWindow != 0) {
187 (selectedDjinn & 0xff)) +
190 if (previewWindow != 0) {
197 previewWindow, owner, (
s32)selectedDjinn, previewPage,
201 standbyElements = 1 << ((selectedDjinn & 0xf00) >> 8);
205 previewWindow, owner, (
s32)selectedDjinn, previewPage,
208 (selectedDjinn & 0xff)) +
217 if (previewPage == 0) {
224 drawnRow = selectedRow;
225 if (firstEntry != drawnFirstEntry) {
228 while ((encodedDjinn = djinnEntries[firstEntry + j]) !=
231 (
s32)((encodedDjinn & 0xf00) >> 8) + 0x5001,
239 (
s32)(((encodedDjinn & 0xf00) >> 8) * 20 +
240 (encodedDjinn & 0xff)) +
242 listWindow, 8, j * 16);
255 drawnFirstEntry = firstEntry;
260 s32 tile = j + 0xf301;
265 listWindow, tile, listWindow->
width - listPages + j - 2, -1, 0);
269 listWindow->
y + selectedRow * 2 + 1,
270 listWindow->
width - 2, 1, 14);
277 s32 tile = j + 0xf301;
299 listWindow->
width - 2, -1, 0);
322 if (navigation->
timer == 0 || (pressed &
KEY_B)) {
327 if (pressed &
KEY_A) {
330 if (djinnCount != 0) {
331 selection = djinnEntries[firstEntry + selectedRow];
334 if (alreadySelected == 0) {
335 navigation->
page = firstEntry;
336 navigation->
row = selectedRow;
338 encodedDjinn = selection;
341 }
else if (alreadySelected == 0) {
358 if (djinnCount != 0) {
363 firstEntry + selectedRow == djinnCount) {
366 preferredRow = selectedRow;
367 }
else if (repeated &
KEY_UP) {
370 if (selectedRow < 0) {
373 selectedRow = djinnCount - firstEntry - 1;
378 preferredRow = selectedRow;
379 }
else if (held &
KEY_R) {
380 if (previewWindow != 0) {
381 for (i = 0; i < previewPages; i++) {
382 s32 tile = i + 0xf301;
383 if ((
gFrameCount & 15) <= 11 && i == previewPage - 1) {
384 tile = previewPage - 1 + 0xf30b;
388 previewWindow->
width - previewPages + i - 2, -1, 0);
391 previewWindow->
width - previewPages - 3, -1,
394 previewWindow->
width - 2, -1, 0);
397 if (previewPage == 0 && previewPages != 0) {
398 if (previewWindow != 0) {
404 if (previewPage > previewPages) {
405 previewPage = previewPages;
407 if (previewPage != 0) {
411 if (previewPage > previewPages) {
418 if (previewPage <= 0) {
419 previewPage = previewPages;
425 }
else if (previewPage != 0) {
426 if (previewWindow != 0) {
435 if (firstEntry != 0) {
437 selectedRow = preferredRow;
441 selectedRow = preferredRow;
444 selectedRow = djinnCount - firstEntry - 1;
445 if (selectedRow > preferredRow) {
446 selectedRow = preferredRow;
453 if (firstEntry != 0) {
455 selectedRow = preferredRow;
458 selectedRow = preferredRow;
459 if (firstEntry != 0) {
460 selectedRow = djinnCount - firstEntry - 1;
461 if (selectedRow > preferredRow) {
462 selectedRow = preferredRow;
476 cx = listWindow->
x * 8;
481 asm(
"" : :
"l"(selectedRow));
482 cursorPos.
x = cx - 2;
484 cursorPos.
y = (selectedRow * 2 + listWindow->
y) * 8 + 20;
488 cursorSprite = &cursor;
490 ((
u32 *)cursorSprite)[2] = 0;
493 cursorSprite->
x = cursorPos.
x + ((
gFrameCount & 4) >> 1) - 6;
494 cursorSprite->
y = cursorPos.
y - ((
gFrameCount & 4) >> 2) - 8;
495 if (djinnCount != 0) {
500 iconWindow = partyStatus->
window;
501 if (partyStatus->
flags & 2) {
502 for (i = 0; i <= 3; i++) {
503 palette = 15 - (blinkPhase != 0);
504 if (((1 << i) & standbyElements) == 0) {
535 return (
s32)encodedDjinn;
What every part of the menu object shares: its includes, edition values, macros and the link round st...
const u8 gDjinnMenu_BlinkTile[32]
#define BATTLE_MENU_MESSAGE_COPY
const u8 gDjinnMenu_ElementYOffsets[4]
#define BATTLE_MENU_MESSAGE_CAPACITY
const u8 gDjinnMenu_ElementXOffsets[4]
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.
struct BattleUnit * UnitGetFar(u32 owner)
void * Djinn_GetRecoveryTableFar(s32 arg0)
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[]
void * Runtime_BumpAllocateAlternatePool(s32 size)
As MemAlloc, but tries EWRAM first.
static s32 Iwram_CopyWords(volatile void *destination, const volatile void *source, s32 size)
static s32 Iwram_FillWords(void *destination, s32 size, u32 value)
volatile u32 gKeysHeld
Keys down now.
volatile u32 gKeysPressed
Keys that went down this frame.
volatile u32 gKeysRepeat
Pressed keys, repeating while held: after 19 frames, then every 6.
void MemFree(void *buffer)
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 unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
u32 djinnActive[4]
The Djinn set, one bit per Djinni; only these add their stat bonuses.
u32 djinnAvailable[4]
The Djinn held, one bit per Djinni (by its index) in each element's word.
A cursor or prompt sprite: a list link and its OAM attributes as fields.
s8 turns
Turns until it is set again; -1 on standby (DJINN_RECOVERY_AFTER_BATTLE), -2 while a summon uses it.
u8 index
the Djinni within its element, 0 to 19
One side's Djinn recovery list: up to 64 entries and their count.
struct DjinnRecoveryEntry entries[64]
One side's Djinn recovery table, as Djinn_GetRecoveryTable returns it.
struct DjinnRecoveryList list
The party status window's layout: its window, its place and size, and what it shows (PARTY_STATUS_ fl...
u16 flags
PARTY_STATUS_ flags.
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_SetAltFlagAndClearTable(s32 allowAlternateTiles)
Frees every text tile, and with flag set lets text tiles take the second tile range (0x200 to 0x27f) ...
void UiText_DrawNumberAtOffset(s32 value, s32 width, const struct UiWindow *window, s32 x, s32 y)
Draws a number (width as UiText_FormatNumber) as tiles in a window at pixel (x, y) of its interior.
void UiWindow_MarkVisibleTileAttributes(void)
Marks the text tiles the tilemap shows, and frees those it no longer shows.
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.
@ UI_TILE_FRAME_TOP_RIGHT
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).
struct UiWindow * DjinnMenu_ShowChangePreview(struct UiWindow *win, s32 owner, s32 encodedDjinn, s32 page, s32 *pageCount)
Temporarily toggle a Djinni and recalculate its owner's stats to show the change.
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 UiWork_ClearValueNameTables(void)
Empties the table of message arguments.
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_ClearList(void *outputs)
Releases every render output in a list and empties it.
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,...