11#define PSYNERGY_PROMPT_TILES BG_CHAR_BLOCK(1)
12#define PSYNERGY_PROMPT_TILES_SIZE 0x2000
17#define PSYNERGY_DETAIL_ROW_X 0
18#define PSYNERGY_DETAIL_ROW_WIDTH 15
20#define PSYNERGY_DETAIL_ROW_X 1
21#define PSYNERGY_DETAIL_ROW_WIDTH 14
26#define PSYNERGY_PAGE_ICONS_X 112
27#define PSYNERGY_PP_LABEL_X 96
28#define PSYNERGY_NAME_X 16
29#define PSYNERGY_LIST_CURSOR_X 88
31#define PSYNERGY_PAGE_ICONS_X 120
32#define PSYNERGY_PP_LABEL_X 72
33#define PSYNERGY_NAME_X 32
34#define PSYNERGY_LIST_CURSOR_X 98
64 Iwram_CopyWords(saved, PSYNERGY_PROMPT_TILES, PSYNERGY_PROMPT_TILES_SIZE);
77 request = psynergy | (owner << 10);
90 Iwram_CopyWords(PSYNERGY_PROMPT_TILES, saved, PSYNERGY_PROMPT_TILES_SIZE);
150 if (((
u32)chosen ^ (
u32)cancelled) == 0) {
152 useResult = cancelled;
177 switch (menu->
mode) {
193 if (chosenAction != -1) {
195 if (menu->
mode != 0) {
196 if (menu->
mode == 1) {
222 if (chosenTarget == -1) {
232 if (targetMode == 1) {
236 if (targetMode == 2) {
308 s32 targetModeDifference;
317 if (action->
range != 0xff) {
320 targetModeDifference = kind ^ 2;
321 classification = (0 - targetModeDifference) | targetModeDifference;
322 classification = (
u32)classification >> 0x1f;
323 classification = 1 - classification;
325 return classification;
337 s32 iconOffset = partySlot *
sizeof(menu->
paneIcon[0]) +
358 ownerIndex = *(
s8 *)((
u8 *)menu + tabOffset);
360 counts[tabOffset] = ownerCount;
362 if (ownerIndex == -1) {
363 *((
u8 *)menu + tabOffset) = 0;
366 ownerOffset = ownerIndex *
sizeof(menu->
ownerTable[0]);
370 tableOffset = ownerOffset + ((
u8 *)menu->
ownerTable - (
u8 *)menu);
371 ownerId = *(
u16 *)((
u8 *)menu + tableOffset);
378 iconOffset2 = partySlot *
sizeof(menu->
paneIcon[0]) +
424 selection = (ownerCount + selection) % ownerCount;
432 for (i = 3; i >= 0; i--)
452 result = ownerIds[selection];
459 result = ownerIds[selection];
468 shortcutCount = fieldCount;
469 if (shortcutCount == 0) {
470 menu->
mode = shortcutCount;
495 menu->
ownerIds[0] = ownerIds[selection];
548 selection = (selection + count) % count;
551 marker->
oam.
x = marker->
x =
553 if (targetMode == 0) {
562 MsgAbilityDescription,
605#define PSYNERGY_SHORTCUT_OWNER_SHIFT 10
606#define PSYNERGY_SHORTCUT_ID_MASK 0x3ff
614 if (shortcutIndex == 0) {
626#if LANGUAGE != LANGUAGE_JAPANESE
642 &left, &top, &width, &height);
643 if (width < 0 || width > 10)
662 &left, &top, &width, &height);
663 if (width < 0 || width > 10)
698 &left, &top, &width, &height);
699 if (width < 0 || width > 11)
729 &left, &top, &width, &height);
730 if (width < 0 || width > 11)
799 }
while (
index <= 7);
809 }
while (
index <= 15);
836 if (psynergyId != 0) {
841 }
while (remaining >= 0);
860 passCount = (
mode != 2) ? 4 : 3;
861 for (clearOffset = 62; clearOffset >= 0; clearOffset -= 2) {
862 u16 *q = (
u16 *)((
u8 *)actions + clearOffset);
870 for (slotIndex = 0; slotIndex < 32; slotIndex++) {
881 for (passIndex = 0; passIndex < passCount; passIndex++) {
882 for (slotIndex = 0; slotIndex < 32; slotIndex++) {
888 if (passIndex == 0 &&
893 }
else if (passIndex == 1) {
894 }
else if (passIndex == 2) {
895 }
else if (passIndex == 3 && ability->
type0c == 0 &&
925 if ((selectedIndex + 1) > entryCount) {
926 selectedIndex = entryCount - 1;
945#define PSYNERGY_MENU_SHORTCUT_HELP 2
958 actionIndex += state->
row;
968 (menu->
psynergies[actionIndex] & 0x1ff) + MsgAbilityDescription;
983 if (rowIndex == state->
row) {
1029 visibleCount = (
u8)(pageState->
entryCount - firstEntry);
1037 pageState->
page, 15);
1042 if (visibleCount > row) {
1043 cursor = firstEntry;
1066 }
while (visibleCount > row);
1110 if (menu->
mode != 0) {
1173 if (menu->
mode == 0) {
1177 if (ability->
type0c == 0) {
1199 if (menu->
mode != 0) {
1234 listMode = menu->
mode != 0 ? 1 : 2;
1238 member = menu->
tabIndex[paneIndex];
1251 menu->
tabIndex[paneIndex] = member;
1252 for (i = 0; i < 4; i++) {
1266 if (ability->
type0c == 0) {
1284 if (ability->
type0c == 0) {
1320 if (action->
type0c != 0 ||
1327#undef PSYNERGY_PROMPT_TILES
1328#undef PSYNERGY_PROMPT_TILES_SIZE
1329#undef PSYNERGY_DETAIL_ROW_X
1330#undef PSYNERGY_DETAIL_ROW_WIDTH
1331#undef PSYNERGY_PAGE_ICONS_X
1332#undef PSYNERGY_PP_LABEL_X
1333#undef PSYNERGY_NAME_X
1334#undef PSYNERGY_LIST_CURSOR_X
1335#undef PSYNERGY_SHORTCUT_OWNER_SHIFT
1336#undef PSYNERGY_SHORTCUT_ID_MASK
1337#undef PSYNERGY_MENU_SHORTCUT_HELP
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_ReleaseEntryObjects(void)
Releases the party figures PsynergyMenu_InitializeEntryObjects created and stops their placement call...
struct UiWindow * UiMenu_CreateCursor(void *source)
Opens the menu's top-left window (13 by 5 tiles) and puts the hand cursor in it, hidden for now.
void UiIcon_PrepareObject(struct RenderOutput *object)
Shows a menu icon at its stored position, without rotation or scaling.
void UiText_DrawWorkValueWithLabel(struct UiWindow *window)
Writes the party's coins and the "Coins" label into window.
void Palette_LightenBankHighlight(s32 bank)
Copies the last background palette (15) into background palette bank and lightens its colour 4 by 9 s...
void PsynergyMenu_CallIconRoutineWithValue(const void *unused, s32 unit)
Loads the graphics of character unit into menu entry slot 0.
void Render_SetTilemapFlagRect(const struct UiWindow *window, s32 x, s32 y, s32 width, s32 height, u32 palette)
Switches a rectangle of a window's text between palette 15 (normal) and 14 (the highlight made by Pal...
void PsynergyMenu_RefreshOwnerEntries(s32 originX, s32 originY, s32 columns)
Lays the menu's entry icons (up to 32) out in a grid of 16x16 cells, columns wide,...
s32 UiIcon_CreateWithResourceVariant(struct UiWindow *window, s32 x, s32 y)
Creates the menu's hand cursor sprite in window at (x, y), loading the hand's tiles into a free VRAM ...
void Menu_DrawPageIndicator(struct UiWindow *window, s32 itemCount, s32 pageSize, s32 selectedPage, s32 rightEdge)
Draws a paged list's page numbers on the top border of window, ending at tile rightEdge: one digit pe...
void UiMenu_PositionCursor(s32 xOffset, s32 yOffset)
Places the hand cursor at (xOffset, yOffset) inside the menu's top-left window, bobbing.
void Menu_CancelSoundReset(void)
Starts watching for Start: clears FLAG_MENU_START_PRESSED and adds Menu_CancelSoundTick.
s32 Menu_SuspendFieldTasks(void)
Suspends the overlay tasks and tile animations while a menu is open, and sets flags 0x152 and 0x166.
void UiWindow_InitializeWork(s32 unused)
Clears the whole menu work and sets its defaults: no pane selected, one entry in each pane,...
void PsynergyMenu_InitializeEntryObjects(void *source, s32 originX, s32 originY, s32 spacing, s32 unused)
Creates a walking figure for each active party member, side by side under the window source: origin (...
void Menu_EnsureCancelSound(void)
Stops watching for Start, if Start has not removed the watch already.
s32 Menu_ResumeFieldTasks(void)
Resumes the overlay tasks and tile animations when a menu closes, and clears game flags 0x166 and 0x1...
void Menu_DrawOwnerStatusPanel(struct UiWindow *unused, s32 owner, s32 slot, s32 mode)
Draws the item menu's status panel for the party member owner (window at tile 0,5,...
void InventoryMenu_ShowModalMessage(s32 message, s32 x, s32 y)
Shows message in the item menu, with the hand cursor hidden meanwhile.
s32 Menu_HandlePageInput(s32 horizontal, s32 count, s32 pageSize, s32 *cursor, s32 *page)
Moves a paged list's cursor and page with the d-pad's repeating keys.
void Menu_SetPageIcons(s32 pageSize, s32 first, struct UiWindow *window, s32 x, s32 y)
Shows the item icons of one page of the item list: entries first to first + pageSize - 1,...
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.
s32 AnimationObjects_SelectAnimationFar(struct AnimationObject *state, s32 flags)
struct BattleUnit * UnitGetFar(u32 owner)
s32 Party_ListActiveOwnersFar(s16 *owners)
s16 Unit_AddPpFar(s32 owner, s32 delta)
s32 GameFlag_TestFar(s32 flag)
struct BattleAct * BattleActGet(s32 actionId)
Far call to BattleAction_GetDirect.
void GameFlag_ClearBitFar(s32 flag)
void UnitCalcFar(s32 owner)
void Event_ClearInvalidPackedValuesFar(void)
s32 BattleFx_HasMatchingEvent5Far(s32 group)
void AudioCommand_PlayFar(s32 id)
struct UiWindow * UiWindow_CreateFar(s32 x, s32 y, s32 width, s32 height, s32 attrs)
void UiWindow_DrawFrameFar(s32 x, s32 y, u32 width, u32 height)
void UiWindow_MarkVisibleTileAttributesFar(void)
void RenderOutput_ClearListFar(void *work)
void UiWindow_EraseBorderRectFar(s32 x, s32 y, u32 width, u32 height)
void UiWork_SetParamNibbleFar(s32 param)
s32 UiText_GetResourceDimensionsFar(s32 no, s32 *x, s32 *y, u32 *width, u32 *height)
s32 Resource_LoadByModeIntoSlotFar(s32 mode, s32 value, s32 result, s32 option)
void Link_DrawShiftedTilePairFar(s32 offset)
struct RenderOutput * SideObject_CreateFar(s32 object_kind, s32 position, s32 side, struct UiWindow *arg3, s32 arg4, s32 arg5)
Far call to CreateSideObject.
void UiText_DrawNumberAtOffsetFar(s32 arg0, s32 arg1, const struct UiWindow *arg2, s32 arg3, s32 arg4)
void UiWindow_ClearInteriorTilesFar(const struct UiWindow *window, u32 left, u32 top, u32 right, u32 bottom)
void UiWindow_DrawDividerLineFar(struct UiWindow *win, u32 x1, u32 y1, u32 x2, u32 y2)
void UiText_DrawCharacterAtOffsetFar(s32 character, const struct UiWindow *position, u32 offsetX, u32 offsetY)
void UiWork_FinalizeFar(struct UiWindow *work, s32 release)
void UiText_DrawStringAtOffsetFar(const u8 *text, const struct UiWindow *work, s32 offsetX, s32 offsetY)
struct RenderOutput * RenderOutput_CreateFromResourceFar(s32 mode, s32 resource, struct UiWindow *input, s32 x, s32 y)
void UiWork_PushValueSlotFar(u32 value, u32 kind)
void UiWork_SetAltFlagAndClearTableFar(s32 flag)
void RenderOutput_RedrawSavedRectFar(struct UiWindow *window)
void UiText_DrawStringInWindowFar(const u8 *text, struct UiWindow *arg1, u32 x, u32 y)
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.
void * MemAlloc(s32 size)
Allocates size bytes (rounded up to words) with no slot, from IWRAM when they fit and EWRAM otherwise...
void * Runtime_AllocateHeapBlock(s32 kind, s32 size)
Returns heap slot kind's block, first allocating size bytes for it (rounded up to words),...
#define WORK_SLOT(n)
Reads slots through their own addresses; adjacent slots are reached by offsets.
void ItemMenu_Close(void)
Closes the item menu: releases the party figures, hides the icons and the cursor, and closes every wi...
void ItemMenu_DrawMessage(s32 unused, s32 message)
Clears the message window and writes message into it.
void ItemMenu_Initialize(s32 x, s32 y, s32 mode, s32 columns)
Sets up the item menu's first screen: the cursor window with the party's figures, the info window alo...
void Menu_SpawnIconEntries(struct InventoryMenuState *state, struct UiWindow *window)
Creates the 32 item icon sprites in window, off screen until placed: slots 0 to 7 at x 248,...
void Menu_HideEmptyEntryIcons(const u16 *items)
Hides the icon of each of the 32 list entries whose item is 0.
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 Runtime_ReleaseHeapBlock(s32 slot)
void MemFree(void *buffer)
#define SE_MENU_CURSOR_MOVE
An ability's definition, a row of gBattleAction_DefinitionTable: its targeting, kind,...
u8 type0c
The field Psynergy the ability works as, 1 (Move) to 16 (Avoid); 0 for none.
u8 ppCost
PP the ability costs.
u8 range
the aimed unit and range - 1 either side, or ABILITY_RANGE_ALL
u8 targetMode
TARGET_MODE_NONE, _FOES, _ALLIES or _SELF.
u8 flags
bits: 7 usable in battle | 6 usable in the field | 5..4 clear in every row | 3..0 kind (ABILITY_KIND_...
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
u8 name[0x0f]
The name, one byte a character, ending in 0.
struct OwnerActionSlot actionSlots[32]
The action list: Psynergy taught for good, then the class's and the equipment's (Unit_RefreshPsynergy...
The running scene's event work: its placement and event tables, its actors, the triggers and exit it ...
s16 psynergyRequest
a field Psynergy to use, as owner << 10 | Psynergy
u16 firstShortcut
The shortcuts' assignments.
The object system's work: the flag that suspends sprite projection, the outline's edge and fill colou...
s16 suspended
nonzero while a menu has suspended sprite projection
u16 encodedAction
bits: 15 from the class | 14 from an equipped item | 13..0 action id.
A render output: a sprite in a window's output list (a character, an icon or a portrait),...
u8 sentinel
depth slot it is drawn at (254 for glyphs)
s8 active
its UI_SPRITE_ motion; 0 while free
u16 animStep
step of its motion's animation
s8 index
VRAM cache slot, or a glyph's tile after glyphTiles.
The window system's work: the windows' tilemap, the windows, the three text channels,...
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...
#define UI_PAGE_ARROW_VRAM
void Ability_PlayUseAnimation(s32 action)
Starts the action's menu animation and waits for its completion.
s32 BattleEffect_ApplyToTargets(s32 effectId, s32 sourceId, s32 targetId, s32 fixedScale)
Applies healing or permanent-stat effects to one member or the whole party.