14#define ITEM_MODAL_SHORT_X 14
15#define ITEM_MODAL_REMOVED_X 14
17#define ITEM_MODAL_SHORT_X 15
18#define ITEM_MODAL_REMOVED_X 17
21#if LANGUAGE == LANGUAGE_FRENCH
22#define ITEM_CANNOT_TRADE_X 11
24#define ITEM_CANNOT_TRADE_X 15
27#if LANGUAGE == LANGUAGE_ITALIAN
28#define ITEM_TRADED_X 13
30#define ITEM_TRADED_X 15
34#define ITEM_TRADE_PROMPT_X 0
36#define ITEM_TRADE_PROMPT_X 16
41#define ITEM_COMMAND_TEXT_X 32
43#define ITEM_COMMAND_TEXT_X 40
47#define ITEM_QUANTITY_WINDOW_WIDTH 30
49#define ITEM_QUANTITY_WINDOW_WIDTH 13
54#define ITEM_GIVE_CURSOR_X 128
55#define ITEM_GIVE_ASK_X 32
56#define ITEM_GIVE_ASK_Y 0
58#define ITEM_GIVE_CURSOR_X 88
59#define ITEM_GIVE_ASK_X 0
60#define ITEM_GIVE_ASK_Y 32
64#define ITEM_DROP_QUESTION_X 0
66#define ITEM_DROP_QUESTION_X 8
71#define ITEM_LIST_PAGE_ICONS_X 116
72#define ITEM_LIST_NAME_X 24
74#define ITEM_LIST_PAGE_ICONS_X 120
75#define ITEM_LIST_NAME_X 32
168#define ITEM_STACK_MAX 30
173#define ITEM_IWRAM_COPY_WORDS \
174 ((ItemWordCopyFn)(IwramIrqMain + Iwram_CopyWordsOffset))
177 const void *src,
s32 size) {
181 return copy(dst, src, size);
258 selection = command = 0;
266 chosen = selection = owner = 0;
289 if (selection == -1) {
311 *targetOut = command;
316 *itemOut = selection;
340 if (result == -1 || result == 0) {
418 if (giveTarget == -1) {
461 for (removedCount = 0; removedCount < result + 1; removedCount++) {
469 for (removedCount = 0; removedCount < result + 1; removedCount++) {
509 if (transferFailed == 0) {
524 for (command = 0; command < result + 1; command++) {
528 if (heldCount != -1) {
556 if (transferFailed == 0) {
573 if (transferFailed == 1) {
609 if (selection == -1) {
625 while (sourceQuantity <= 29) {
639 while (targetQuantity <= 29) {
658 while (sourceQuantity != 0) {
669 while (targetQuantity != 0) {
681 if (transferFailed == 1) {
688#if TBS_PATCH_LEVEL == 3
865 for (ownerIndex = 3; ownerIndex >= 0; ownerIndex--)
866 menu->
ownerY[ownerIndex] = 30;
905 }
while (firstSlot <= 7);
914 }
while (secondSlot <= 15);
921 2, remainingSlot, window, 0x100, remainingY);
923 }
while (remainingSlot <= 31);
933 for (slot = 31; slot >= 0; slot--) {
936 icon->
active = hiddenState;
953 icon->
active = hiddenState;
956 }
while (slot <= 31);
997 if (ownerIndex == -1) {
1044#if LANGUAGE != LANGUAGE_JAPANESE
1059 selection = (selection + ownerCount) % ownerCount;
1066 if (showEquipment) {
1078 for (ownerIndex = 3; ownerIndex >= 0; ownerIndex--)
1079 menu->
ownerY[ownerIndex] = 30;
1080 menu->
ownerY[selection] = 26;
1086 sortMode = (sortMode + 4) % 4;
1093 result = ownerIds[selection];
1125 menu->
paneOwner[0] = ownerIds[selection];
1153 s32 descriptionShown;
1163 descriptionShown = 0;
1172 ownerIndex = (ownerIndex + ownerCount) % ownerCount;
1177 targetMarker->
oam.
x = targetMarker->
x =
1178 ((menu->
mainWindow->
x + ownerIndex * 3) << 3) - 2;
1188#if LANGUAGE == LANGUAGE_SPANISH || LANGUAGE == LANGUAGE_FRENCH || \
1189 LANGUAGE == LANGUAGE_ITALIAN
1194 else if (heldCount != 0) {
1202 if (heldCount != 0) {
1234 descriptionShown = 1;
1243 if (mode == 1 && ownerIndex == menu->
paneIndex[0]) {
1248 result = menu->
ownerIds[ownerIndex];
1299 }
while (memberIndex < menu->partyCount);
1316 }
while (memberIndex < menu->partyCount);
1348 for (slot = 0; slot < 32; slot++) {
1349 if (
items[slot] == 0) {
1369 if (maskedItemId != 0) {
1372 remainingSlots -= 1;
1373 }
while (remainingSlots >= 0);
1413 for (slotIndex = 0; slotIndex < 32; slotIndex++) {
1414 items[slotIndex] = 0;
1418 items[slotIndex] = 0;
1420 items[itemCount] = unit->
inventory[slotIndex];
1438 entries = inventoryEntries;
1441 itemId = *entries++;
1443 if (iconStyle == 0) {
1451 }
while (remaining >= 0);
1464 items = menu->
items;
1506 if (owner == target) {
1517 if (previewSlot != 0) {
1520 if (previewSlot != -1) {
1536 if (target == owner) {
1546 buffer = (
void *)owner;
1549 if (previewSlot != 0) {
1551 if (previewSlot != -1) {
1563 buffer = (
void *)owner;
1585 s32 count = quantity + 1;
1590 for (removedCount = 0; removedCount < count; removedCount++)
1606 if (column > 2 || row > 2 || column < 0 || row < 0)
1624#define ITEM_COMMAND_STATE_DISABLED (-1)
1625#define ITEM_COMMAND_STATE_AVAILABLE 1
1636 s8 commandStorage[6];
1654 commandStates = commandStorage;
1656 redrawFlag = &menu->
flags;
1658 if (*redrawFlag != 1) {
1678 if (lastCommand == -1) {
1700 column = (
s8)(lastCommand % 3);
1701 row = (
s8)(lastCommand / 3);
1702 commandIndex = row * 3 + column;
1717 column = (column + 3) % 3;
1718 row = (row + 2) % 2;
1719 commandIndex = row * 3 + column;
1722 if (commandIndex > 2) {
1730 }
else if (commandIndex != 0) {
1752 switch (commandIndex) {
1803 return commandIndex;
1818 if (item->
type == 0) {
1868#define TEXT_COLOR_DISABLED 14
1874 u32 firstCommandMessage;
1879 if (useState == disabled)
1882 firstCommandMessage = MsgItemCommandUse;
1924 s32 itemId = inventoryEntry;
1939 if (itemDefinition->
actionId != 0) {
1940 if (itemDefinition->
type != 0) {
1941 if (itemDefinition->
useType != 3) {
1956 result = (
range == 0xff) ? 2 : 1;
1958 result = (
flags & mask) ? -1 : 0;
2035 counter = (counter + 5) % 5;
2064 s32 priority = 0xc80;
2099 s32 bestowsPsynergy;
2103 bestowsPsynergy = 0;
2106 if (def->
type != 0) {
2109 for (i = 0; i < 4; i++) {
2118 if (hasEffects == 1) {
2136 for (i = 0; i < 4; i++) {
2151 window, 0, row * 8);
2165 window, (
u8)((def->
effects[i].
kind - 15) % 4) + 1, 0, row, 2);
2167 window, 8, row * 8);
2180 window, 0, row * 8);
2181#if LANGUAGE != LANGUAGE_JAPANESE
2209 window, 0, row * 8);
2221 bestowsPsynergy = 1;
2225 if (!bestowsPsynergy) {
2240 m = MsgBrokenNotice;
2262 i = MsgNumberHeading;
2267#if LANGUAGE != LANGUAGE_JAPANESE
2279 if (def->
flags & 4) {
2304 magnitude = statChange;
2305 if (statChange < 0) {
2306 magnitude = -statChange;
2308 if (magnitude > 9) {
2311 magnitude = statChange;
2312 if (statChange < 0) {
2313 magnitude = -statChange;
2315 if (magnitude > 99) {
2318 if (statChange > 0) {
2320 x - digits * 8 + 16, y);
2323 x - digits * 8 + 16, y);
2374 s32 quantity = baseQuantity;
2406 quantity = (quantityRange + quantity) % quantityRange;
2423#if LANGUAGE != LANGUAGE_JAPANESE
2429 if (dropMode == 0) {
2507 question = MsgConfirmDrop;
2521 selection = (selection + rows) % rows;
2596 selection = (selection + rows) % rows;
2679 result->
page = page;
2697 page = pageState->
page;
2700 index += pageState->
row;
2707 if (menu->
items[index] != 0) {
2714 if (row == pageState->
row) {
2744 page = pageState->
page;
2746 visibleCount = (
u8)(pageState->
entryCount - firstEntry);
2754 pageState->
page, 15);
2757 if (visibleCount > row) {
2758 entry = &menu->
items[firstEntry];
2765 }
while (visibleCount > row);
2830 if (paneIndex == 0) {
2894 if (paneIndex == 1) {
2915 for (i = 0; i <= 3; i++) {
2918 menu->
ownerY[member] = 26;
2937#undef ITEM_MODAL_SHORT_X
2938#undef ITEM_MODAL_REMOVED_X
2939#undef ITEM_CANNOT_TRADE_X
2941#undef ITEM_TRADE_PROMPT_X
2942#undef ITEM_COMMAND_TEXT_X
2943#undef ITEM_QUANTITY_WINDOW_WIDTH
2944#undef ITEM_GIVE_CURSOR_X
2945#undef ITEM_GIVE_ASK_X
2946#undef ITEM_GIVE_ASK_Y
2947#undef ITEM_DROP_QUESTION_X
2948#undef ITEM_LIST_PAGE_ICONS_X
2949#undef ITEM_LIST_NAME_X
2950#undef ITEM_STACK_MAX
2951#undef ITEM_IWRAM_COPY_WORDS
2952#undef ITEM_COMMAND_STATE_DISABLED
2953#undef ITEM_COMMAND_STATE_AVAILABLE
2954#undef TEXT_COLOR_DISABLED
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.
s32 InventoryMenu_SortByListOrder(u16 *inventory, s32 mode)
Sorts a party member's 15 inventory slots by the list order of mode (see Menu_CopyListOrder): items a...
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 Menu_UpdateEntryObjectTransforms(void)
Scheduler callback: each frame, places every party member sprite created by PsynergyMenu_InitializeEn...
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 Palette_CopyObjectBankToBackground14(void)
Copies the first sprite palette into background palette 14, then colour 4 of background palette 15 ov...
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 ItemMenu_RefreshEntry(s32 layout)
Lays the inventory's 15 item icons out five to a row from (116, y): y is 56 for layout 1 and 40 other...
void Menu_CancelSoundReset(void)
Starts watching for Start: clears FLAG_MENU_START_PRESSED and adds Menu_CancelSoundTick.
void UiWindow_SetBounds(struct UiWindow *window, s32 x, s32 y, s32 width, s32 height)
Moves and resizes a window, in tiles.
s32 Menu_SuspendFieldTasks(void)
Suspends the overlay tasks and tile animations while a menu is open, and sets flags 0x152 and 0x166.
void UiWindow_CloseIfOpen(struct UiWindow **handle, s32 style)
Closes the window kept in *handle, if any, and clears the handle.
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.
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...
s32 AnimationObjects_SelectAnimationFar(struct AnimationObject *state, s32 flags)
struct BattleUnit * UnitGetFar(u32 owner)
struct ItemDefinition * Item_GetDirectFar(s32 item)
s32 Party_ListActiveOwnersFar(s16 *owners)
s32 Item_AdjustCounterFar(s32 item_id, s32 delta)
s32 GameFlag_TestFar(s32 flag)
s32 Inventory_AddItemFar(s32 owner_id, s32 item_id)
s32 Unit_RefreshPsynergyFar(s32 owner)
struct BattleAct * BattleActGet(s32 actionId)
Far call to BattleAction_GetDirect.
s32 Inventory_RemoveFar(s32 owner, s32 slot)
s32 Inventory_BreakFar(s32 owner, s32 slot)
s32 Inventory_EquipFar(s32 owner, s32 slot)
s32 Item_CanOwnerEquip(s32 unit, s32 item)
Far call to Item_CanOwnerEquipDirect.
void GameFlag_ClearBitFar(s32 flag)
void UnitCalcFar(s32 owner)
void Event_ClearInvalidPackedValuesFar(void)
u32 BattleFx_HasTriggerFar(u16 item)
void Shop_FillSelectorFar(s32 count, s32 selector, u8 *base)
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 UiText_DrawNumberInWindowFar(s32 arg0, s32 arg1, struct UiWindow *arg2, s32 arg3, s32 arg4)
void UiWork_SetParamNibbleFar(s32 param)
s32 Resource_LoadByModeIntoSlotFar(s32 mode, s32 value, s32 result, s32 option)
void Link_DrawShiftedTilePairFar(s32 offset)
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)
struct RenderOutput * RenderOutput_CreateFar(s32 slot, s32 flags, struct UiWindow *input, s32 offsetX, s32 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 UiWindow_SetTilemapEntryFar(struct UiWindow *window, s32 value, s32 x, s32 y, u32 mode)
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.
volatile u32 gFrameCount
Frames WaitFrames has finished.
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_AllocateBlock(s32 kind, s32 size)
As Runtime_AllocateHeapBlock, but tries EWRAM first, for blocks that need room more than speed: the b...
void * Runtime_AllocateHeapBlock(s32 kind, s32 size)
Returns heap slot kind's block, first allocating size bytes for it (rounded up to words),...
s32 ItemMenu_RunOwnerSelection(u16 *ownerIds, u16 *items)
The party member row of the item menu.
#define ITEM_STACK_MAX
The most items of one kind a stack holds.
s32(*) ItemWordCopyFn(void *dst, const void *src, s32 size)
The resident IWRAM word copy, called through its address.
#define ITEM_COMMAND_TEXT_X
s32 ItemMenu_Run(void)
The item picker an event script opens (window command 3): the item menu, in which the player chooses ...
UNUSED s32 InventoryMenu_ItemNamePageReturnTrue(void)
Nothing calls it.
#define ITEM_TRADE_PROMPT_X
s32 ItemMenu_DrawNamePage(struct UiWindow *window, s32 unused, const struct MenuResult *pageState)
Draws one page of the item list into window: up to five item names with their icons,...
void ItemMenu_SetItemWindowRow3(void)
Moves the item window to row 3 of the right-hand side.
s32 ItemMenu_DrawItemDetailPage(struct UiWindow *window, void *ownerWork, struct MenuResult *pageState)
Updates the item list for the row under the cursor: puts the selected item's plain name in the info w...
ItemMenuStep
The steps of the item menu's command loop (ItemMenu_RunCommands).
@ ITEM_STEP_QUANTITY
nothing sets it
@ ITEM_STEP_IDLE
nothing sets it
#define ITEM_COMMAND_STATE_DISABLED
Each item command's state in the grid.
s32 ItemMenu_ChooseCommand(void)
The item command grid: Use, Equip and Details on the top row, Give, Remove and Drop below (grid index...
s32 Inventory_RemoveFirstUnflagged(s32 ownerId)
Makes room in ownerId's inventory: if no slot is free, removes the whole stack in the first slot that...
s32 ItemMenu_ConfirmDrop(s32 item)
Asks whether to drop item (an inventory entry): its name, the question, and Yes or No,...
static __inline__ s32 Item_CopyWords(ItemWordCopyFn copy, void *dst, const void *src, s32 size)
#define ITEM_GIVE_CURSOR_X
void ItemMenu_Close(void)
Closes the item menu: releases the party figures, hides the icons and the cursor, and closes every wi...
s32 ItemMenu_SelectTarget(s32 mode)
Chooses the party member to use (mode 0) or give (mode 1) the selected item to.
void ItemMenu_DrawItemDetails(struct UiWindow *window, s32 inventoryEntry)
Writes the description of the inventoryEntry into window, one line a row: for equipment its Attack an...
s32 ItemMenu_RunCommands(s32 *ownerOut, s32 *targetOut, s32 *itemOut)
Runs the item menu: choose a party member, one of their items and a command (Use, Equip,...
s32 Menu_SelectQuantity(s32 value)
The item menu's Details screen: describes the item entry value in a large window (the whole top half ...
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...
#define ITEM_QUANTITY_WINDOW_WIDTH
void ItemMenu_DrawCommands(const s8 *commandStates, struct UiWindow *window)
Writes the six command names into window, the disabled ones in grey.
void EquipmentMenu_UpdateCompatibilityIndicators(void)
Scheduler callback while choosing a member to give an item to: every 32 frames, sets each party figur...
#define ITEM_MODAL_REMOVED_X
void EquipmentMenu_StartCompatibilityIndicators(void)
Ends EquipmentMenu_UpdateCompatibilityIndicators: puts every party figure back to animation 1 and rem...
s32 InventoryMenu_GetItemQuantity(s32 ownerId, s32 itemId)
Returns how many of itemId the unit ownerId holds: the quantity of its first stack,...
#define ITEM_DROP_QUESTION_X
UNUSED void InventoryMenu_NoOp(void)
Nothing calls it.
void ItemMenu_HidePageIcons(void)
Hides the item icons in the first column of the five-wide item grid.
s32 ItemMenu_RunList(s32 paneIndex)
The item list of the member in paneIndex (0: the owner, 1: the receiver of a trade),...
#define ITEM_MODAL_SHORT_X
s32 ItemMenu_Use(void)
Uses the selected item from the owner in pane 0 on the member in pane 1.
void ItemMenu_TryBreak(void)
After the selected item is used: an item of use type 2 breaks one time in eight, with the break sound...
s32 ItemMenu_IsSpecial(s32 itemId)
Returns 1 for the items that raise a stat for good (Apple, Hard Nut, Mint and Lucky Pepper),...
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,...
s32 ItemMenu_SelectMember(s32 pane)
Lets the player choose a party member in pane (0 or 1), starting from the member chosen last.
s32 ItemMenu_SelectGiveQuantity(s32 baseQuantity, s32 quantityRange, s32 dropMode)
Asks how many of the selected item stack to give or drop: Left and Right choose a number from 1 to qu...
UNUSED void InventoryMenu_ItemNamePageNoOp(void)
Nothing calls it.
void ItemMenu_DrawItemHead(void)
Shows the selected item at the top of the message window: its icon, its owner's name and its name.
void ItemMenu_SetMessageWindowHeight3(void)
#define ITEM_LIST_PAGE_ICONS_X
void ItemMenu_OpenCategory(s32 ownerId)
Shows the equipment view of member ownerId's items in the item window.
void ItemMenu_DrawIcons(u16 *inventoryEntries, s32 iconStyle)
Loads each listed item's icon into its item icon sprite, the first 15 entries of inventoryEntries,...
void Menu_HideEmptyEntryIcons(const u16 *items)
Hides the icon of each of the 32 list entries whose item is 0.
void ItemMenu_HideAllIcons(void)
Hides all 32 item icons.
void ItemMenu_SetMessageWindowHeight5(void)
Makes the message window, along the top right, 5 rows tall.
#define TEXT_COLOR_DISABLED
void Resource_LoadPairedBlocks(void)
Loads the stat arrows (up and down) into two free VRAM blocks, kept in the menu work's resource slots...
void ItemMenu_DrawEquipPreview(s32 owner, s32 slot, s32 mode, s32 target)
Shows in the status panel what the item in owner's inventory slot would mean to member target: for a ...
s32 ItemMenu_OpenDetail(s32 itemIndex)
Opens the details window (top left, 13 by 10 tiles) and describes the item in pane itemIndex there.
#define ITEM_CANNOT_TRADE_X
void ItemMenu_RefreshOwner(s32 ownerId, s32 mode)
Shows member ownerId's items in the item window, laid out for layout mode (see ItemMenu_RefreshEntry)...
s32 Item_ClassifyUseMode(s32 ownerId, s32 inventoryEntry)
Says how ownerId can use inventoryEntry from the item menu: 0 the item works on the field (BattleFx_H...
s32 ItemMenu_CountItems(s32 ownerId)
Returns how many of member ownerId's 15 inventory slots hold an item.
s32 ItemMenu_ConfirmEquip(s32 unused)
After giving or trading the selected item to the member in pane 1, offers to equip it there,...
#define ITEM_IWRAM_COPY_WORDS
s32 ItemMenu_CommandCursorX(s32 column, s32 row)
The x and y of the item command cursor on column and row of the command grid (three commands to a row...
#define ITEM_COMMAND_STATE_AVAILABLE
s32 ItemMenu_CommandCursorY(s32 column, s32 row)
void ItemMenu_SetMessageWindowHeight7(void)
s32 ItemMenu_CollectItems(struct BattleUnit *unit, u16 *items, s32 mode)
Copies the unit's items into the list items (32 entries), skipping empty slots and clearing the rest.
void ItemMenu_SetMessageWindowHeight6(void)
void ItemMenu_BuildCommands(s8 *commandStates)
Fills commandStates (indexed by ItemMenuCommand) for the selected item: Use for usable items the owne...
void ItemMenu_SetItemWindowRow5(void)
Moves the item window to row 5 of the right-hand side.
s32 ItemMenu_PageResult(struct MenuResult *result, s32 index)
Fills result with the item list of the member in pane index: their unit, how many items they hold,...
void ItemMenu_DrawStat(s32 statChange, s32 unused, struct UiWindow *window, s32 x, s32 y)
Writes a signed stat change at (x, y) of window: the number, with a plus or minus sign just before it...
@ ITEM_EFFECT_SCALE_HP_REGEN
@ ITEM_EFFECT_SCALE_DEFENSE
@ ITEM_EFFECT_SCALE_AGILITY
@ ITEM_EFFECT_SCALE_ATTACK
@ ITEM_EFFECT_ADD_AGILITY
@ ITEM_EFFECT_ADD_HP_REGEN
@ ITEM_EFFECT_ADD_PP_REGEN
@ ITEM_EFFECT_SCALE_PP_REGEN
@ INVENTORY_QUANTITY_STEP
@ INVENTORY_QUANTITY_MASK
@ INVENTORY_QUANTITY_SHIFT
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.
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
void Runtime_ReleaseHeapBlock(s32 slot)
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...
s32 Scheduler_RemoveCallback(SchedulerCallback callback)
Unschedules the task running callback: clears its routine and gives it order 0x7fff,...
#define SE_MENU_CURSOR_MOVE
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
An ability's definition, a row of gBattleAction_DefinitionTable: its targeting, kind,...
u8 range
the aimed unit and range - 1 either side, or ABILITY_RANGE_ALL
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.
u16 inventory[15]
Items held, one entry each: bits 15..11 quantity | 10 broken | 9 equipped | 8..0 item id (INVENTORY_*...
An item's definition: its price, type, who can equip it, its bonuses and unleash, its effects and the...
u8 useType
what using it costs (ITEM_USE_), or 0 for nothing
s8 secondaryBonus
Defense added while equipped.
u8 type
enum ItemType; 0 for an item that is not equipment
s16 primaryBonus
Attack added while equipped.
u16 actionId
the ability used, or taught as Psynergy
struct ItemEffect effects[4]
what it does while equipped
u8 kind
enum ItemEffectKind; 0 for none
s8 amount
what the kind adds or scales by
The event work as the item picker sees it: what the player chose, for the event script.
u16 chosenItem
owner << 10 | item id
u16 chosenSlot
the owner's inventory slot
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
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...
The heap's 64 work slots, the first two holding the next free EWRAM and IWRAM addresses.
void * slots[64]
Each slot's block once allocated, else null; slots 0 and 1 are the pool pointers.
#define UI_PAGE_ARROW_VRAM
void Item_PlayUseAnimation(u32 item)
Runs the animation selected by the item's action definition.
s32 Item_Use(s32 slot, s32 ownerId, s32 targetId)
Applies the slot's action, then consumes or transforms the item on success.
s32 Resource_FindFreeEntry(void)
Returns the number of the first free cache entry, or VRAM_CACHE_ENTRY_COUNT when all are taken.
s32 VramCache_Load(u32 no, u32 size, const void *src)
Gives cache entry no size bytes of sprite VRAM and copies src there.