91 state->
kinds[entryCount] = kind;
92 state->
bases[entryCount] = base;
104 u32 entryIndex = screen->
top;
109 while (entryIndex < count) {
117 if (screen->
head == 0) {
121 previous->
next = node;
122 node->
prev = previous;
127 if (rowPosition == 5)
132 screen->
baseX = 100 - rowPosition * 8;
136 for (previous = screen->
head, rowPosition = 0; previous != 0;
137 previous = previous->
next) {
146 if (previous->
kind == 6 && screen->
locked == 0) {
166 for (i = 0; i != 5; i++) {
171 for (i = 0; i != 7; i++) {
216 }
else if (node->
x != node->
targetX) {
233 if (cursor->
kind != 0) {
238 if (cursor->
scale == 0) {
246 if (node->
scale != 0) {
253 if (node->
kind == 1) {
263 if (transfer->
kind != 0) {
265 commandSprite = &transfer->
sprite;
266 commandSprite->
mode = 0;
267 commandSprite->
affine = 0;
268 commandSprite->
param = 0;
269 commandSprite->
mosaic = 0;
270 commandSprite->
colors = 1;
271 commandSprite->
size = 2;
272 commandSprite->
shape = 0;
274 commandSprite->
tile = transfer->
tile;
275 commandSprite->
x = node->
x - 4;
283 commandSprite->
affine = 3;
284 commandSprite->
x += 0xfff0;
285 commandSprite->
y += 0xf0;
289 commandSprite->
mode = 1;
326 if (node->
kind == 1) {
334 if (cursor->
kind != 0) {
337 void *src = (
void *)(entryIndex + (((
gFrameTick >> 2) & 15) << 8));
342 axisStep = (cursor->
targetX - cursor->
x) >> 1;
344 cursor->
x += axisStep;
350 if ((axisStep = (cursor->
targetY - cursor->
y) >> 1) != 0) {
351 cursor->
y += axisStep;
358 cursorEntry->
x = cursor->
x - 4;
361 cursorEntry->
mode = 1;
363 cursorEntry->
mode = 0;
376 const u8 *arrowTiles;
393 tmp = arrowTiles + animationStep * 128;
422 if (screen->
locked != 0) {
434 if (count != 0 && window->
width != count + 2) {
440 if (screen->
count != 0) {
464 if (node->
kind != 0) {
472 if (node->
kind != 0) {
520 const u8 *arrowTiles = 0;
530 count = state->
count;
574#define SELECTION_FIXED 999
576#define NODE_STATUS_SCROLLING 33
577#define NODE_STATUS_SHOWN 1
579#define NODE_KIND_YES_NO 6
581#define SELECTION_ROWS 4
582#define ARROW_SCROLL_FRAMES 8
658 if (nextEntry == screen->
count) {
699 if (screen->
top == 0) {
725 if (state->
count > 5) {
727 if (end == state->
count) {
746 state->
bases[entryIndex], node, 1);
749 }
while (node !=
NULL);
756 while (node !=
NULL) {
791 if (state->
count > 5) {
810 register s32 z
asm(
"r0") = 0;
825 while (i != state->
count - 5)
830 while (node !=
NULL) {
863 while (rowIndex != 0) {
867 if (node->
kind == 1 || node->
kind == 6) {
882 while (rowIndex != 0) {
886 if (node->
kind == 1 || node->
kind == 6) {
887 u32 resource = node->
message - MsgCommandName;
931 rowX = screen->
baseX;
933 rowY = screen->
baseY;
958 }
while (node->
scale != 0);
965 entryIndex = screen->
top;
972 node->
x = screen->
baseX - 16;
985 screen->
head = first;
999 }
while (node->
scale != 256);
1044 s32 original = result;
1090 cacheSlot = node->
slot;
1092 node->
message = base + MsgCommandName;
1096 cacheSlot = node->
slot;
1098 node->
message = base + MsgItemName;
1102 cacheSlot = node->
slot;
1104 node->
message = base + MsgAbilityName;
1109 node->
slot = cacheSlot;
1112 node->
scale = 0x100;
1149 node = screen->
head;
1156 for (other = screen->
head; other !=
NULL; other = other->
next) {
1157 if (other != node) {
1159 other->
dx = (node->
x - other->
x) >> 1;
1163 for (other = screen->
head; other !=
NULL; other = other->
next) {
1164 if (other != node) {
1169 screen->
head = node;
1173 for (other = screen->
path, nodeIndex = 0; other !=
NULL;
1174 other = other->
next) {
1198 other->
scale = 0x100;
1211 node = screen->
path;
1218 screen->
path = other;
1243 sprite->
oam.f.mode = 0;
1244 sprite->
oam.f.mosaic = 0;
1245 sprite->
oam.f.colors = 1;
1246 sprite->
oam.f.affine = 0;
1247 sprite->
oam.f.affineIndex = 0;
1248 sprite->
oam.f.size = 0;
1249 sprite->
oam.f.shape = 2;
1250 sprite->
oam.f.priority = 0;
1255 sprite->
oam.f.x =
x;
1256 sprite->
oam.f.y =
y;
1273 if (selected->
kind != 1 && selected->
kind != 6)
1277 transfer = &state->
records[15];
1278 resourceId = selected->
base;
1282 resource = table + *(
u16 *)(table + selected->
base * 2);
1287 if (transfer->
kind == 0)
1291 transfer->
base = resourceId;
1292 transfer->
scale = 40;
1303 if (largeIcon->
kind != 0) {
1305 largeIcon->
kind = 0;
1311#define HAS_LOCALIZED_MENU_GUARD 1
1327#if defined(HAS_LOCALIZED_MENU_GUARD)
1329 if (*(
s16 *)(state + 0xcb8) != 0) {
1330 BattleFx_ClearRandomParticlesFar();
1343 switch (selection) {
1376#if defined(HAS_LOCALIZED_MENU_GUARD)
static s32 * EffectPosition_Coordinates(struct EffectPosition *position)
Returns the position's three coordinates as an array.
void BattlePres_SetActorModesFar(u16 *actors, s32 mode)
s32 BattleMotion_ProjectScaledPositionFar(s32 id, s32 *projected)
s32 GameFlag_TestFar(s32 flag)
s32 Object_GetTriggerTileAheadOfCurrentFar(void)
void AudioCommand_PlayFar(s32 id)
#define FLAG_IN_BATTLE
Set as a battle starts, cleared as a field scene starts.
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
u32 gFrameTick
Counted up by every VBlank.
const u8 gMenu_CursorObjectTiles[]
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),...
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 UiWindow_CreateWithLayoutBounds(s32 flags)
Opens the party status window with flags (see PARTY_STATUS_*) in a new heap block and draws it.
void PartyStatus_Close(void)
Closes the party status window and frees its heap block.
s32 AffineMatrix_BuildForEffect(struct AffineTransform *source)
Hands out the next OAM affine matrix for a sprite drawn with source's scale and rotation and fills it...
void Runtime_PushSlotEntry(void *slotEntry, s32 slot)
Links a sprite entry into depth slot slot (clamped to 0..255) for this frame.
char ResourceId_CommandIcons
s32 Resource_DecodeByteLz(const void *source, void *destination)
Decodes a byte-oriented LZ resource and returns its unpacked byte count.
const s8 gMenu_CursorBobOffsets[16]
The selection cursor's bob: a 16-step wave of up to 3 pixels each way.
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,...
UNUSED void Menu_MoveSelectionBackward(struct SelectionScreen *screen)
Moves the cursor one entry left, scrolling the row at its second place.
void Menu_SetupSelectionBothSides(void)
Sets up both end arrows of the selection row.
void Menu_OpenSelectionWindow(s32 mode, u32 count)
Opens or refits the name window above the selection row and writes the name of the icon under the cur...
void UiGlyph_ResetWorkState(void)
Allocates and resets the selection screen: the row of icons the player picks from,...
static __inline__ void ResetCursor(struct GlyphCursor *cursor)
void Resource_ScheduleOwnerReset(void)
Stops drawing the selection screen.
void Resource_ClearOwnerListAndCounters(void)
Empties the selection screen's list of entries.
s32 Resource_LoadByMode(s32 mode, s32 value)
Loads the icon of an entry of kind mode (1 and 6 commands, 2 items, 4 Psynergy, 9 fixed images) into ...
void SelectionScreen_LoadLargeIcon(void)
Loads the large icon of the command under the cursor, zooming in.
void Resource_PushPendingPair(u32 kind, u32 base)
Adds an entry (kind and id) to the selection screen's list, up to 16.
UNUSED void Menu_MoveSelectionForward(struct SelectionScreen *screen)
Moves the cursor one entry right, scrolling the row at its fourth place.
UNUSED void UiTextResource_NoOpCallback2(void)
s32 Resource_LoadByModeIntoSlot(s32 mode, s32 value, s32 result, s32 option)
Loads the icon of an entry of kind mode into sprite tile slot result (a free slot when -1) and return...
void Menu_SetNodeCoordinates(u32 x, u32 y)
Moves the row of icons to start at pixel (x, y), 16 pixels apart.
void Menu_StepRight(struct SelectionScreen *state)
Moves the cursor one entry right, scrolling the row at its edge and wrapping from the last entry to t...
#define NODE_STATUS_SCROLLING
u32 Menu_RunSelectionForValue(u32 initialIndex)
Runs a selection row with the cursor on entry initialIndex, cancellable, and returns the entry chosen...
void Resource_ResetPendingTransfer(void)
Frees the large command icon, if it is shown.
void UiTextResource_Initialize(struct MenuSprite *sprite, s32 *slot)
Sets up a sprite as the right-pointing arrow, in a free tile slot (returned in *slot).
void SelectionScreen_DrawArrow(struct SelectionScreen *state, s32 side)
Draws the selection screen's left (index 0) or right (1) arrow, nudged outwards while it flashes afte...
u32 Menu_ConfirmSelection(struct SelectionScreen *screen)
Chooses the entry under the cursor: the other icons gather into it and vanish, and it joins the chose...
void SelectionScreen_RedrawIcon(struct SelectionScreen *state, u32 rowIndex)
Redraws the command icon at row place rowIndex in its plain state.
#define ARROW_SCROLL_FRAMES
void UiTextResource_Release(s32 value)
Frees an arrow sprite's tile slot.
void UiTextResource_SetPosition(struct MenuSprite *sprite, s32 x, s32 y)
Places an arrow sprite at (x, y) and queues it for drawing.
void MenuSelection_BuildEntries(u32 unused)
Creates icons for the first five listed entries in a row along the bottom of the screen.
struct SelectionNode * SelectionScreen_FindFreeIcon(s32 kind)
Returns a free selection icon record: one of the seven row icons (kind 0) or of the five chosen icons...
void UiTextResource_NoOpCallback4(void)
struct SelectionNode * Selection_GetCursorNode(struct SelectionScreen *screen)
Returns the node at the selection screen's cursor index.
void Menu_ScrollSelectionList(struct SelectionScreen *screen, s32 forward)
Scrolls the row one entry: forward brings an icon in from the right as the leftmost shrinks away,...
void SelectionScreen_SetupArrow(struct SelectionScreen *state, s32 side)
Sets up the left (index 0) or right (1) arrow of the selection row, shown when there are entries beyo...
void SelectionScreen_SetupIcon(u32 kind, s32 base, struct SelectionNode *node, s32 reuse)
Sets up a selection icon for an entry: its icon tiles (in its old slot when reuse is set),...
void UiWork_CloseAndRelease(void)
Closes the window kept in heap block 16 and frees the block.
UNUSED void SelectionScreen_CreateEmpty(void)
Sets up an empty selection screen and waits a frame.
void Resource_ScheduleOwnerResetDelayed(void)
Starts drawing the selection screen each frame.
UNUSED void UiTextResource_NoOpCallback3(void)
s32 Menu_SelectionLoop(s32 mode)
Runs the selection row until the player chooses (the chosen entry's index) or, when mode allows it,...
void UiTextResource_NoOpCallbackBank(void)
void Resource_ResetOwnerEntries(void)
Closes the selection screen and frees its icons, tiles and work block.
void UiWindow_OpenMode1AndWaitFrame(void)
Opens the field menu's window and waits a frame.
#define NODE_STATUS_SHOWN
void SelectionScreen_Draw(void)
The selection screen's per-frame callback: slides and draws the row of icons, the large icon over the...
u32 Menu_WaitForSelectionInput(u32 mode)
As Menu_SelectionLoop, with the menu sounds.
void UiWork_ReservedNoOp(void)
s32 Menu_RunTopSelection(void)
Runs the field menu until the player picks something that leaves it, and returns that choice's result...
void Menu_SendNodeCountList(struct SelectionScreen *screen)
Tells the battle presentation how many icons the row shows.
void UiTextResource_NoOpCallback1(void)
UNUSED void UiTextResource_NoOpCallback(void)
Six empty functions; nothing calls the first, the fourth or the fifth.
void SelectionScreen_HighlightIcon(struct SelectionScreen *state, u32 rowIndex)
Redraws the command icon at row place rowIndex and loads its large icon.
void Menu_StepLeft(struct SelectionScreen *state)
Moves the cursor one entry left, scrolling the row at its edge and wrapping from the first entry to t...
#define SE_MENU_CURSOR_MOVE
struct EventWork * gEventWork
A point projected onto the screen, with its depth.
The running scene's event work: its placement and event tables, its actors, the triggers and exit it ...
s16 facingTrigger
the collision code ahead, which a search answers
Two halfwords of a selection record, the second cleared as its cursor.
An icon of the selection screen: its list links, the entry it shows, its place and its slide toward a...
u16 tile
first sprite tile of its picture
s16 scaleEnd
8.8 fixed point, 0x100 full size
s16 scale
8.8 fixed point, 0x100 full size
struct SelectionNode * next
the icon after it in its row
s16 scaleStep
8.8 fixed point a frame
u16 message
its name, shown in the screen's window
struct SelectionNode * prev
the icon before it in its row
s16 homeX
screen pixels, where it stood when chosen
u16 kind
the entry's kind, as listed in SelectionScreen.kinds; 0 free
u16 base
the entry's id, as listed in SelectionScreen.bases
struct SelectionSprite sprite
s16 homeY
screen pixels, where it stood when chosen
u16 slot
VRAM cache slot of its picture.
The selection screen (heap block 18): the row of icons the player picks from, with arrows at each end...
u16 pathTop[5]
top, kept for each icon chosen on the path
struct UiWindow * window
the window naming the chosen entry
u16 verticalScroll
pixels added to the icons' y; 32 at setup
struct AffineTransform transform
a zooming icon's scale
u16 status
1 shown, 33 while scrolling; counts up each frame drawn
u16 top
the first listed entry shown
u16 pathCursor[5]
cursorIndex, kept for each icon chosen on the path
u16 locked
999 from setup on.
struct SelectionNode * path
the icons chosen so far
u16 cursorIndex
The entry under the hand, from top; bit 7 asks the next list to start again from its first entry.
u16 kinds[16]
The listed entries, up to 16 (Resource_PushPendingPair).
struct SelectionNode records[16]
The icons; 14 is the pointing hand, whose picture is loaded at setup.
struct SelectionNode * head
the first icon of the row
u16 unk39a
cleared with the list; not read by name in TBS
A selection screen sprite: a list link and its OAM attributes.
A window: a framed rectangle of the tilemap with its sprite outputs, its opening or closing animation...
void * Resource_GetTableEntry(s32 index)
Returns the ROM address of resource index from the resource directory.
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.
s32 Resource_ResetEntry(u32 no)
Frees cache entry no: its blocks go back and the entry is marked free (offset 0xffff).
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.
s32 Ui_BuildPatternToSlot(s32 icon, s32 unused, s32 cacheSlot)
Builds one of the other icons and loads it into sprite tile slot cacheSlot.
s32 UiIcon_CopyResourceToSlot(s32 inventoryCode, s32 layers, s32 cacheSlot)
Composes an inventory icon with the requested layers and loads it into cacheSlot.
s32 RenderResource_LoadTableEntry(u32 value, s32 unused, u32 slot)
Loads one of four small fixed images into the sprite tile slot named by slot.
void Ui_BuildPairedPatternsToSlot(s32 overlayIcon, s32 frameIcon, s32 *slot, s32 *tileOut, s32 reuse)
Builds a command icon (overlay overlayIcon over frame frameIcon) and loads it into a sprite tile slot...
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 UiIcon_BuildItemIconTiles(u32 glyph, s32 withBase, s32 *cacheSlot, s32 *tileOut, s32 reuse)
Builds the item icon glyph, over the icon frame when withBase is set, and loads it into *cacheSlot (a...
What every part of the window object shares: its includes, edition values, macros and the codes of de...
#define UI_SELECTION_ENTRY_LIMIT
void RenderOutput_PrepareForRedraw(struct UiWindow *window)
Clears a window's contents: redraws its empty frame and releases the render outputs it carries.
void UiWork_Finalize(struct UiWindow *window, s32 instant)
Closes a window: clears its contents and remembers its last 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,...