Alchemy
Loading...
Searching...
No Matches

icon_menu.c File Reference

The command icon menus of the field, title and transfer screens. More...

Go to the source code of this file.

Data Structures

struct  WindowLine
 One line's horizontal window edges: window 0's and window 1's, each (left << 8 | right). More...
struct  WindowBuffer
 A page of the display transition's window edges: WININ and WINOUT, then each of the 160 lines' edges. More...

Macros

#define TRANSFER_MODE_DRAW_HELP   UiText_DrawResource
#define TRANSFER_PASSWORD_HELP_X   PASSWORD_HELP_X
#define TRANSFER_PASSWORD_HELP_FIRST_Y   4
#define TRANSFER_PASSWORD_HELP_LAST_Y   16
#define TRANSFER_CABLE_HELP_FIRST_Y   4
#define TRANSFER_CABLE_HELP_LAST_Y   28
#define ANIMATE_ENTRIES_ROW   7
#define MODE_LABEL_X   18
#define MODE_LABEL_RIGHT   144
#define PASSWORD_HELP_X   16
#define PAIR_WIDTH   9

Functions

void AffineEffect_UpdateFrame (void)
 Draws the resource-menu icons, pulsing the selected icon with one affine matrix, and updates the horizontal window spans to reveal the active icon row.
void * AffineEffect_InitializeWork (void)
 Allocates and clears the resource-menu state, then schedules its icon pulse.
void Menu_EndResourceSelection (void)
 Stops the icon pulse, closes the label window and releases each loaded icon before freeing the resource-menu state.
s32 Menu_RunResourceSelectionLoop (s32 initial)
 Selects an icon position with wrapped directional input.
static s32 AbsoluteDifference (s32 diff, s32 lhs, s32 rhs)
 Returns the distance between lhs and rhs, reusing their supplied difference.
s32 Menu_SelectResource (s32 start, s32 goal)
 Animates a cursor from start to goal with table-driven delays.
void Menu_LoadResourceSlot (s32 slot, s32 index)
 Decodes one command-icon table entry into the requested VRAM cache slot.
void Menu_AppendResourceEntry (s32 icon)
 Appends a command icon if fewer than six are present.
void Menu_CenterResourceEntries (s32 row, s32 width, s32 resourceBase)
 Centers the icons and their label window together on the given tile row.
void Menu_LayoutResourceEntries (s32 x, s32 y, s32 width, s32 resourceBase)
 Places icons at three-tile intervals from (x, y), then creates their label window immediately to the right.
static __inline__ s32 ResourceMenu_ReadCommandPosition (s8 *table, s32 index)
 Reads the signed command-position mapping used by the top resource menu.
s32 Menu_SelectTopEntry (s32 selection)
 Builds the field command menu, omitting Djinn when none are owned.
s32 Menu_AnimateSelectionToEntry (s32 start, s32 command)
 Opens the field command menu and animates from start to the command's icon.
s32 Menu_SelectSaveSlotAction (void)
 Builds the title menu from the save summaries and optional send flags.
void Menu_DrawModeLabel (void)
 Redraws the password-level explanation when the selected level changes.
void Menu_DrawModeIndicator (void)
s32 Menu_SelectResourceLayout (s32 mode)
 Selects either the transfer method (mode 0) or password level.
s32 Menu_SelectShopCommand (s32 selection)
 Selects a shop command, icons 0x11-0x14 (Buy, Sell, Artifacts, Repair), centered on row 17.
s32 Menu_SelectSanctumService (s32 selection)
 Selects a sanctum service, icons 0x19-0x1c (Revive, Cure Poison, Repel Evil, Remove Curse), centered on row 17.
s32 Menu_RunConfirmSelection (s32 bottom, s32 message, s32 labelWidth, s32 selection)
 Selects Yes/No (icons 5/6); canceling returns 1 (No).
s32 Menu_RunConfirmSelectionAt (s32 x, s32 y, s32 selection)
 Selects Yes/No at (x, y); canceling returns 1 (No).
s32 Menu_SelectCoinsOrMedals (s32 selection)
 Selects icons 0x20 and 0x21 (Coins, Lucky Medals) centered on row 17.

Detailed Description

The command icon menus of the field, title and transfer screens.

Part of battle_command.c, the menu object, compiled only through it.

Definition in file icon_menu.c.

Macro Definition Documentation

◆ TRANSFER_MODE_DRAW_HELP

#define TRANSFER_MODE_DRAW_HELP   UiText_DrawResource

Definition at line 15 of file icon_menu.c.

Referenced by Menu_DrawModeIndicator().

◆ TRANSFER_PASSWORD_HELP_X

#define TRANSFER_PASSWORD_HELP_X   PASSWORD_HELP_X

Definition at line 16 of file icon_menu.c.

Referenced by Menu_DrawModeIndicator().

◆ TRANSFER_PASSWORD_HELP_FIRST_Y

#define TRANSFER_PASSWORD_HELP_FIRST_Y   4

Definition at line 17 of file icon_menu.c.

Referenced by Menu_DrawModeIndicator().

◆ TRANSFER_PASSWORD_HELP_LAST_Y

#define TRANSFER_PASSWORD_HELP_LAST_Y   16

Definition at line 18 of file icon_menu.c.

Referenced by Menu_DrawModeIndicator().

◆ TRANSFER_CABLE_HELP_FIRST_Y

#define TRANSFER_CABLE_HELP_FIRST_Y   4

Definition at line 19 of file icon_menu.c.

Referenced by Menu_DrawModeIndicator().

◆ TRANSFER_CABLE_HELP_LAST_Y

#define TRANSFER_CABLE_HELP_LAST_Y   28

Definition at line 20 of file icon_menu.c.

Referenced by Menu_DrawModeIndicator().

◆ ANIMATE_ENTRIES_ROW

#define ANIMATE_ENTRIES_ROW   7

Definition at line 488 of file icon_menu.c.

Referenced by Menu_AnimateSelectionToEntry().

◆ MODE_LABEL_X

#define MODE_LABEL_X   18

Definition at line 562 of file icon_menu.c.

Referenced by Menu_DrawModeLabel().

◆ MODE_LABEL_RIGHT

#define MODE_LABEL_RIGHT   144

Definition at line 563 of file icon_menu.c.

Referenced by Menu_DrawModeLabel().

◆ PASSWORD_HELP_X

#define PASSWORD_HELP_X   16

Definition at line 617 of file icon_menu.c.

◆ PAIR_WIDTH

#define PAIR_WIDTH   9

Definition at line 844 of file icon_menu.c.

Referenced by Menu_SelectCoinsOrMedals().

Function Documentation

◆ AffineEffect_UpdateFrame()

void AffineEffect_UpdateFrame ( void )

Draws the resource-menu icons, pulsing the selected icon with one affine matrix, and updates the horizontal window spans to reveal the active icon row.

Definition at line 40 of file icon_menu.c.

Referenced by AffineEffect_InitializeWork(), AffineEffect_UpdateFrame(), Menu_EndResourceSelection(), and NameEntry_CountLetters().

◆ AffineEffect_InitializeWork()

◆ Menu_EndResourceSelection()

void Menu_EndResourceSelection ( void )

◆ Menu_RunResourceSelectionLoop()

s32 Menu_RunResourceSelectionLoop ( s32 initial)

Selects an icon position with wrapped directional input.

A returns the position; B or Start returns -1. Redraws the label only after a move.

Definition at line 260 of file icon_menu.c.

Referenced by Menu_RunConfirmSelection(), Menu_RunConfirmSelectionAt(), Menu_RunResourceSelectionLoop(), Menu_SelectCoinsOrMedals(), Menu_SelectResourceLayout(), Menu_SelectSanctumService(), Menu_SelectSaveSlotAction(), Menu_SelectShopCommand(), Menu_SelectTopEntry(), and NameEntry_CountLetters().

◆ AbsoluteDifference()

s32 AbsoluteDifference ( s32 diff,
s32 lhs,
s32 rhs )
inlinestatic

Returns the distance between lhs and rhs, reusing their supplied difference.

Definition at line 303 of file icon_menu.c.

Referenced by AbsoluteDifference(), and Menu_SelectResource().

◆ Menu_SelectResource()

s32 Menu_SelectResource ( s32 start,
s32 goal )

Animates a cursor from start to goal with table-driven delays.

Draws each intervening label, pauses at the destination, and returns its position.

Definition at line 311 of file icon_menu.c.

Referenced by Menu_AnimateSelectionToEntry(), Menu_SelectResource(), and NameEntry_CountLetters().

◆ Menu_LoadResourceSlot()

void Menu_LoadResourceSlot ( s32 slot,
s32 index )

Decodes one command-icon table entry into the requested VRAM cache slot.

Definition at line 362 of file icon_menu.c.

Referenced by Menu_AppendResourceEntry(), Menu_LoadResourceSlot(), and NameEntry_CountLetters().

◆ Menu_AppendResourceEntry()

void Menu_AppendResourceEntry ( s32 icon)

Appends a command icon if fewer than six are present.

Its initial position is on the bottom icon row; a layout routine places the final row.

Definition at line 375 of file icon_menu.c.

Referenced by Menu_AnimateSelectionToEntry(), Menu_AppendResourceEntry(), Menu_RunConfirmSelection(), Menu_RunConfirmSelectionAt(), Menu_SelectCoinsOrMedals(), Menu_SelectResourceLayout(), Menu_SelectSanctumService(), Menu_SelectSaveSlotAction(), Menu_SelectShopCommand(), Menu_SelectTopEntry(), and NameEntry_CountLetters().

◆ Menu_CenterResourceEntries()

void Menu_CenterResourceEntries ( s32 row,
s32 width,
s32 resourceBase )

Centers the icons and their label window together on the given tile row.

A nonzero resourceBase supplies labels; otherwise command-name IDs do.

Definition at line 399 of file icon_menu.c.

Referenced by Menu_AnimateSelectionToEntry(), Menu_CenterResourceEntries(), Menu_RunConfirmSelection(), Menu_SelectCoinsOrMedals(), Menu_SelectResourceLayout(), Menu_SelectSanctumService(), Menu_SelectSaveSlotAction(), Menu_SelectShopCommand(), Menu_SelectTopEntry(), and NameEntry_CountLetters().

◆ Menu_LayoutResourceEntries()

void Menu_LayoutResourceEntries ( s32 x,
s32 y,
s32 width,
s32 resourceBase )

Places icons at three-tile intervals from (x, y), then creates their label window immediately to the right.

Coordinates and label width are in tiles.

Definition at line 422 of file icon_menu.c.

Referenced by Menu_LayoutResourceEntries(), Menu_RunConfirmSelectionAt(), and NameEntry_CountLetters().

◆ ResourceMenu_ReadCommandPosition()

__inline__ s32 ResourceMenu_ReadCommandPosition ( s8 * table,
s32 index )
static

Reads the signed command-position mapping used by the top resource menu.

Definition at line 441 of file icon_menu.c.

Referenced by Menu_SelectTopEntry(), and ResourceMenu_ReadCommandPosition().

◆ Menu_SelectTopEntry()

s32 Menu_SelectTopEntry ( s32 selection)

Builds the field command menu, omitting Djinn when none are owned.

Translates between command IDs and visible icon positions using the two lookup rows.

Definition at line 448 of file icon_menu.c.

Referenced by Menu_RunTopSelection(), Menu_SelectTopEntry(), and NameEntry_CountLetters().

◆ Menu_AnimateSelectionToEntry()

s32 Menu_AnimateSelectionToEntry ( s32 start,
s32 command )

Opens the field command menu and animates from start to the command's icon.

Returns the final icon position after closing the menu.

Definition at line 495 of file icon_menu.c.

Referenced by Event_MeetFlint(), Menu_AnimateSelectionToEntry(), NameEntry_CountLetters(), and WorldMap_ShowDjinnTutorial().

◆ Menu_SelectSaveSlotAction()

s32 Menu_SelectSaveSlotAction ( void )

Builds the title menu from the save summaries and optional send flags.

Translates the chosen visible position back to its save-action code.

Definition at line 511 of file icon_menu.c.

Referenced by Menu_SelectSaveSlotAction(), NameEntry_CountLetters(), and SaveMenu_Run().

◆ Menu_DrawModeLabel()

void Menu_DrawModeLabel ( void )

Redraws the password-level explanation when the selected level changes.

Definition at line 570 of file icon_menu.c.

Referenced by Menu_DrawModeLabel(), Menu_SelectResourceLayout(), and NameEntry_CountLetters().

◆ Menu_DrawModeIndicator()

void Menu_DrawModeIndicator ( void )

◆ Menu_SelectResourceLayout()

s32 Menu_SelectResourceLayout ( s32 mode)

Selects either the transfer method (mode 0) or password level.

Schedules the appropriate help redraw while the icon menu is active, then closes both help windows and the icon menu.

Definition at line 675 of file icon_menu.c.

Referenced by Menu_SelectResourceLayout(), NameEntry_CountLetters(), and SaveMenu_Run().

◆ Menu_SelectShopCommand()

s32 Menu_SelectShopCommand ( s32 selection)

Selects a shop command, icons 0x11-0x14 (Buy, Sell, Artifacts, Repair), centered on row 17.

selection: initial position; returns the selected position.

Definition at line 760 of file icon_menu.c.

Referenced by Menu_SelectShopCommand(), and NameEntry_CountLetters().

◆ Menu_SelectSanctumService()

s32 Menu_SelectSanctumService ( s32 selection)

Selects a sanctum service, icons 0x19-0x1c (Revive, Cure Poison, Repel Evil, Remove Curse), centered on row 17.

Definition at line 776 of file icon_menu.c.

Referenced by Menu_SelectSanctumService(), and NameEntry_CountLetters().

◆ Menu_RunConfirmSelection()

s32 Menu_RunConfirmSelection ( s32 bottom,
s32 message,
s32 labelWidth,
s32 selection )

Selects Yes/No (icons 5/6); canceling returns 1 (No).

bottom: 0 places the menu on row 0; otherwise row 17. message: first name message, or 0 for command names. labelWidth: name window width, or 0 for width 3. selection: initial position

Definition at line 795 of file icon_menu.c.

Referenced by Menu_RunConfirmSelection(), NameEntry_CountLetters(), Save_WriteSelectedSlot(), SaveMenu_Run(), SaveState_ConfirmAndProcessSelectedSlot(), and SaveState_DeleteSelectedSlot().

◆ Menu_RunConfirmSelectionAt()

s32 Menu_RunConfirmSelectionAt ( s32 x,
s32 y,
s32 selection )

Selects Yes/No at (x, y); canceling returns 1 (No).

Definition at line 823 of file icon_menu.c.

Referenced by Menu_RunConfirmSelectionAt(), and NameEntry_CountLetters().

◆ Menu_SelectCoinsOrMedals()

s32 Menu_SelectCoinsOrMedals ( s32 selection)

Selects icons 0x20 and 0x21 (Coins, Lucky Medals) centered on row 17.

selection: initial position; returns the selected position.

Definition at line 849 of file icon_menu.c.

Referenced by Menu_SelectCoinsOrMedals(), NameEntry_CountLetters(), and TolbiSpring_RunSpringGame().