17 s32 confirmationChoice;
31 confirmationChoice = 0;
40 for (ownerIndex = 3; ownerIndex >= 0; ownerIndex--) {
41 menu->
ownerY[ownerIndex] = 0xc8;
73 size =
sizeof(*originalUnit);
90 if (secondWasSet != 0) {
97 diffWork, &gainedCount, &lostCount);
107 if (firstWasSet != 0) {
113 diffWork, &gainedCount, &lostCount);
117 }
else if (mode - 2 <= 1) {
138 if (applySecond != 0) {
144 diffWork, &gainedCount, &lostCount);
146 pageCounts[1] = pageCounts[0];
152 pageCounts[0] = ((pageCounts[0] - 1) / 5) + 1;
153 if (pageCounts[0] == 0) {
156 pageCounts[1] = ((pageCounts[1] - 1) / 5) + 1;
157 if (pageCounts[1] == 0) {
213 }
else if (mode - 2 <= 1) {
347 if ((redraw >> 1) != 0) {
370 0, previewMode, 0, 0);
372 page, 0, previewMode, selectedPages[1] + 1,
381 addPairSlot, previewMode, page, 1);
383 page, addPairSlot, previewMode,
384 selectedPages[0] + 1, 1);
392 if (pageCounts[page] > 1) {
395 for (index = 0; index < pageCounts[page]; index++) {
398 tile = 0xf031 + index;
402 if (index == selectedPages[page]) {
406 list, tile, list->
width - pageCounts[page] + index - 2, -1, 0);
410 list->
width - pageCounts[page] - 3, top, 0);
418 step = (
frame % 60) - 5;
439 slide = (step % 35) * 2;
454 if ((
frame & 3) == 0) {
458 tile = (
void *)0x060052c0;
460 if ((
frame & 4) != 0) {
467 if ((pressedKeys &
KEY_A) != 0) {
468 if (confirmationChoice == 0) {
480 }
else if ((pressedKeys &
KEY_B) != 0) {
484 }
else if ((pressedKeys &
KEY_R) != 0) {
486 page = ((page + 1) % 3);
490 }
else if ((repeatedKeys &
KEY_LEFT) != 0) {
492 selectedPages[page]--;
493 selectedPages[page] =
499 }
else if ((repeatedKeys &
KEY_RIGHT) != 0) {
503 selectedPages[page]++;
505 selectedPages[page] =
533 s32 selectedPages[2];
563 selectedPages[1] = selectedPages[0] = result;
564 for (side = 3; side >= 0; side--)
569 counts[1] = counts[0] = 1;
577 counts[0] = (counts[0] - 1) / 6 + 1;
580 counts[1] = (counts[1] - 1) / 6 + 1;
604 0, 3, selectedPages[0] + 1, 1);
607 if (counts[side] > 1) {
609 for (pageIndex = 0; pageIndex < counts[side]; pageIndex++) {
610 tile = 0xf031 + pageIndex;
613 if (pageIndex == selectedPages[side])
616 window, tile, window->
width - counts[side] + pageIndex - 2, -1, 0);
619 window->
width - counts[side] - 3, -1, 0);
621 window->
width - 2, -1, 0);
625 blink = frame % 60 - 5;
632 if ((frame & 3) == 0) {
649 selectedPages[side]--;
650 selectedPages[side] =
Menu_WrapIndex(selectedPages[side], counts[side]);
655 selectedPages[side]++;
659 selectedPages[side] =
Menu_WrapIndex(selectedPages[side], counts[side]);
690 entry = requiresTrade;
693 if (ownerColumn != sourceOwnerColumn) {
718 ownedCounts[sourceOwnerColumn] -= 1;
719 ownedCounts[targetOwnerColumn] += 1;
721 for (firstOwner = 0; firstOwner < menu->
ownerCount; firstOwner++) {
722 secondOwner = firstOwner;
728 difference = ownedCounts[firstOwner] - ownedCounts[secondOwner];
729 if (difference < -1 || difference > 1) {
749 for (ownerIndex = 0; ownerIndex < menu->
ownerCount; ownerIndex++) {
753 for (djinnIndex = 0; djinnIndex <= 19; djinnIndex++) {
760 ownedCounts[ownerIndex] = ownedCount;
void UiMenu_SlideCursor(s32 x, s32 y)
Slides the hand cursor from where it is to (x, y) inside the menu's top-left window over two frames,...
void Menu_UpdateEntryObjectTransforms(void)
Scheduler callback: each frame, places every party member sprite created by PsynergyMenu_InitializeEn...
void UiMenu_PositionCursor(s32 xOffset, s32 yOffset)
Places the hand cursor at (xOffset, yOffset) inside the menu's top-left window, bobbing.
void UiWindow_CloseIfOpen(struct UiWindow **handle, s32 style)
Closes the window kept in *handle, if any, and clears the handle.
s32 UiWindow_UpdateOrCreate(struct UiWindow **handle, s32 x, s32 y, s32 w, s32 h, s32 flags)
Opens the window kept in *handle, or redraws it if it is already open.
struct BattleUnit * UnitGetFar(u32 owner)
u32 Djinn_DeactivateFar(s32 owner, s32 index, s32 bit)
s32 Djinn_AddToOwnerFar(s32 owner, s32 index, s32 bit)
s32 Djinn_ActivateFar(s32 owner, s32 index, s32 bit)
void UnitCalcFar(s32 owner)
void AudioCommand_PlayFar(s32 id)
void RenderOutput_PrepareForRedrawFar(struct UiWindow *window)
void UiWindow_MarkVisibleTileAttributesFar(void)
void RenderOutput_ClearListFar(void *work)
void UiWork_SetParamNibbleFar(s32 param)
void UiWindow_ClearInteriorTilesFar(const struct UiWindow *window, u32 left, u32 top, u32 right, u32 bottom)
void UiText_DrawCharacterAtOffsetFar(s32 character, const struct UiWindow *position, u32 offsetX, u32 offsetY)
void UiWork_FinalizeFar(struct UiWindow *work, s32 release)
void UiWork_PushValueSlotFar(u32 value, u32 kind)
s32 UiWork_IsCompleteFar(void)
void UiWindow_SetTilemapEntryFar(struct UiWindow *window, s32 value, s32 x, s32 y, u32 mode)
void RenderOutput_RedrawSavedRectFar(struct UiWindow *window)
struct UiWindow * UiText_OpenMessageWindowFar(s32 message, s32 x, s32 y, u32 packed)
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.
struct GameState gGameState
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)
#define Iwram_MulQ16(left, right)
volatile u32 gKeysPressed
Keys that went down this frame.
volatile u32 gKeysRepeat
Pressed keys, repeating while held: after 19 frames, then every 6.
#define CLAMP(v, low, high)
Keeps v within low to high, the low bound tested first.
void MemFree(void *buffer)
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...
#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.
struct BattleElementStats element[4]
Power and resistance in each element, 0 to 200, after equipment, element levels and Resistance stages...
struct OwnerActionSlot actionSlots[32]
The action list: Psynergy taught for good, then the class's and the equipment's (Unit_RefreshPsynergy...
u32 djinnAvailable[4]
The Djinn held, one bit per Djinni (by its index) in each element's word.
u8 messageSpeed
0 to 2; 1 on a new game
s8 active
its UI_SPRITE_ motion; 0 while free
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...
u16 frame
The zoom's step: counts down from 7 to 0 while opening, and up from 0 to duration while closing.
#define UiRender_MarkRow(render, y)
Requests transfer of the four-row tilemap band containing window row y.
#define UI_PAGE_ARROW_RIGHT
#define UI_PAGE_ARROW_LEFT