Skip to Content
The Alchemy Project

src/menu/menu_psynergy.c

The Psynergy menu: the field menu's Psynergy screen, the party member and Psynergy lists, targets, and the L and R shortcuts. More…

Included by menu.c.

Macros

NameDescription
#definePSYNERGY_SHORTCUT_MEMBER_SHIFT 10A Psynergy shortcut, and the field's Psynergy request packed the same way: its party member above bit 10, the Psynergy's id below.
#definePSYNERGY_SHORTCUT_ID_MASK 0x3ff
#defineABILITY_DESCRIPTION_MASK 0x1ffThe bits of a listed Psynergy the info window's description is found by: nine, where the list's other reads take PSYNERGY_ABILITY_MASK's fourteen.
#definePSYNERGY_MENU_BACK_TO_LIST 1PSYNERGY_MENU_STATE.flags: set on going back to the list after a use or a cancelled target, which nothing reads; and while Select shows the shortcut help in the list.
#definePSYNERGY_MENU_SHORTCUT_HELP 2
#definePSYNERGY_PROMPT_TILES BG_CHAR_BLOCK(1)
#definePSYNERGY_PROMPT_TILES_SIZE 8192
#definePSYNERGY_DETAIL_ROW_X JAPANESE_OR(1, 0)The highlight over the Psynergy list's rows.
#definePSYNERGY_DETAIL_ROW_WIDTH JAPANESE_OR(14, 15)
#definePSYNERGY_PAGE_ICONS_X JAPANESE_OR(120, 112)The Psynergy list's page icons, "PP" label, names and hand cursor.
#definePSYNERGY_PP_LABEL_X JAPANESE_OR(72, 96)
#definePSYNERGY_NAME_X JAPANESE_OR(32, 16)
#definePSYNERGY_LIST_CURSOR_X JAPANESE_OR(98, 88)
#definePSYNERGY_ABILITY_OF (entry) (((Uint32)(entry) << 18) >> 18)A Psynergy entry's action id, its PSYNERGY_ABILITY_MASK bits, taken out by shifts.

Enumerations

NameDescription
enumPSYNERGY_MENU_STEP { PSYNERGY_STEP_MEMBER, PSYNERGY_STEP_LIST, PSYNERGY_STEP_CLAS … }The steps of the Psynergy menu (mnPsynergyMenuRunSteps).

Functions

NameDescription
Sint32mnPsynergyMenuRun (void)The field menu's Psynergy screen (mnFieldMenuRun, FIELD_MENU_PSYNERGY), over the field, which stops meanwhile.
Sint32mnPsynergyMenuRunSteps (Sint32 *outMember, Sint32 *unused, Sint32 *outAction)Runs the Psynergy menu: choose a party member and one of their Psynergy, then use it on a party member (or the whole party), or, in the shortcut modes, set it as the L or R shortcut.
Sint32mnPsynergyMenuClassifySelectedPsynergy (void)Says how the selected Psynergy is used from the menu, as an item is (enum ITEM_USE_MODE): ITEM_USE_MODE_FROM_FIELD once the menu closes when the scene has a script for its field Psynergy (fieldPsynergy) where the leader faces, ITEM_USE_MODE_WHOLE_PARTY for ABILITY_RANGE_ALL, ITEM_USE_MODE_CHOOSE_MEMBER when it targets ABILITY_TARGET_ALLIES, and ITEM_USE_MODE_FROM_FIELD otherwise.
Sint32mnPsynergyMenuSelectPartySlot (Sint32 partySlot)Lets the player choose a party member in side partySlot (0 or 1), starting from the one chosen last, with each party member's Psynergy shown as the cursor passes.
Sint32mnPsynergyMenuSelectMember (Uint16 *memberIds, Uint16 *unused)The party member row of the Psynergy menu.
voidmnPsynergyMenuRefreshMemberPsynergy (Sint32 memberId)Shows party member memberId's Psynergy icons in the Psynergy window, eight to a row, or "no Psynergy" when they have none.
Sint32mnPsynergyMenuReturnTrue (void)
voidmnPsynergyMenuNoOperation (void)
Sint32mnPsynergyMenuSelectTarget (Sint32 targetMode)Chooses the party member to use the selected Psynergy on.
Sint32mnPsynergyMenuSetShortcut (Sint32 memberId, Sint32 abilityId, Sint32 shortcutIndex)Sets the L or R Psynergy shortcut (PSYNERGY_SHORTCUT) to abilityId as memberId uses it, packed as the field's Psynergy request is.
Sint32mnPsynergyMenuDrawShortcuts (WINDOW *window, Sint32 memberId)
voidmnPsynergyMenuCreateEntryGrid (void)Sets up a Psynergy grid screen: the cursor window with the party's figures, a 30 by 15 window below with a hidden grid cursor and a portrait, and 16 Psynergy icon sprites in two rows of eight from (96, 8), on an 8 by 2 grid.
voidmnPsynergyMenuCloseWindows (void)Releases the party figures and closes the Psynergy grid screen's windows.
voidmnPsynergyMenuDrawPsynergyIcons (Uint16 *psynergies)Loads each listed Psynergy's icon into its icon sprite (32 entries) and hides the icons of empty entries.
Sint32mnPsynergyMenuCollectActions (UNIT *unit, Uint16 *actions, Sint32 mode)Lists unit's Psynergy into actions (PSYNERGY_SLOTS entries, cleared first) and returns how many there are, as mode (PSYNERGY_LIST_MODE) chooses; any mode other than PSYNERGY_LIST_SHORTCUTS and PSYNERGY_LIST_FIELD lists as PSYNERGY_LIST_ALL.
Sint32mnPsynergyMenuBuildPagedList (PAGED_LIST *result, Sint32 index)Fills result with the Psynergy list of the party member in side index: their unit, how many Psynergy are listed, and the page and row of the one chosen last for them (kept within the list), five to a page.
Sint32mnPsynergyMenuShowSelectedRow (WINDOW *window, Sint32 *memberState, PAGED_LIST *state)Updates the Psynergy list for the row under the cursor: puts the Psynergy's description in the info window, unless a kept message is there, and highlights its row of the five. window and memberState are not used.
Sint32mnPsynergyMenuDrawPage (WINDOW *window, Sint32 unused, const PAGED_LIST *pageState)Draws one page of the Psynergy list into window: up to five names with their icons and PP costs, Psynergy the party member cannot afford in the no-HP colour and one restricted here in the low-HP colour, the page numbers, and the help line (how to set a shortcut while Select is held, else how to change party member).
Sint32mnPsynergyMenuRunList (Sint32 sideIndex)The Psynergy list of the party member in sideIndex, five a page.
BoolmnPsynergyMenuIsActionRestricted (Sint32 actionEntry)Returns 1 when actionEntry cannot be used from the menu: it has no field effect and is not usable both in the field and in battle.

Description

The Psynergy menu: the field menu's Psynergy screen, the party member and Psynergy lists, targets, and the L and R shortcuts. Part of menu.c.

Macros in detail

PSYNERGY_SHORTCUT_MEMBER_SHIFT

#define PSYNERGY_SHORTCUT_MEMBER_SHIFT 10

A Psynergy shortcut, and the field's Psynergy request packed the same way: its party member above bit 10, the Psynergy's id below.

Referenced by mnPsynergyMenuDrawShortcuts(), mnPsynergyMenuRun() and mnPsynergyMenuSetShortcut().

Definition at line 8 of file menu_psynergy.c.

PSYNERGY_SHORTCUT_ID_MASK

#define PSYNERGY_SHORTCUT_ID_MASK 0x3ff

Referenced by mnPsynergyMenuDrawShortcuts().

Definition at line 9 of file menu_psynergy.c.

ABILITY_DESCRIPTION_MASK

#define ABILITY_DESCRIPTION_MASK 0x1ff

The bits of a listed Psynergy the info window's description is found by: nine, where the list's other reads take PSYNERGY_ABILITY_MASK's fourteen.

Referenced by mnPsynergyMenuShowSelectedRow().

Definition at line 13 of file menu_psynergy.c.

PSYNERGY_MENU_BACK_TO_LIST

#define PSYNERGY_MENU_BACK_TO_LIST 1

PSYNERGY_MENU_STATE.flags: set on going back to the list after a use or a cancelled target, which nothing reads; and while Select shows the shortcut help in the list.

Referenced by mnPsynergyMenuRunSteps().

Definition at line 18 of file menu_psynergy.c.

PSYNERGY_MENU_SHORTCUT_HELP

#define PSYNERGY_MENU_SHORTCUT_HELP 2

Referenced by mnPsynergyMenuDrawPage() and mnPsynergyMenuRunList().

Definition at line 19 of file menu_psynergy.c.

PSYNERGY_PROMPT_TILES

#define PSYNERGY_PROMPT_TILES BG_CHAR_BLOCK(1)

Referenced by mnPsynergyMenuRun().

Definition at line 24 of file menu_psynergy.c.

PSYNERGY_PROMPT_TILES_SIZE

#define PSYNERGY_PROMPT_TILES_SIZE 8192

Referenced by mnPsynergyMenuRun().

Definition at line 25 of file menu_psynergy.c.

PSYNERGY_DETAIL_ROW_X

#define PSYNERGY_DETAIL_ROW_X JAPANESE_OR(1, 0)

The highlight over the Psynergy list's rows.

Referenced by mnPsynergyMenuShowSelectedRow().

Definition at line 29 of file menu_psynergy.c.

PSYNERGY_DETAIL_ROW_WIDTH

#define PSYNERGY_DETAIL_ROW_WIDTH JAPANESE_OR(14, 15)

Referenced by mnPsynergyMenuShowSelectedRow().

Definition at line 30 of file menu_psynergy.c.

PSYNERGY_PAGE_ICONS_X

#define PSYNERGY_PAGE_ICONS_X JAPANESE_OR(120, 112)

The Psynergy list's page icons, "PP" label, names and hand cursor.

Referenced by mnPsynergyMenuDrawPage().

Definition at line 33 of file menu_psynergy.c.

PSYNERGY_PP_LABEL_X

#define PSYNERGY_PP_LABEL_X JAPANESE_OR(72, 96)

Referenced by mnPsynergyMenuDrawPage().

Definition at line 34 of file menu_psynergy.c.

PSYNERGY_NAME_X

#define PSYNERGY_NAME_X JAPANESE_OR(32, 16)

Referenced by mnPsynergyMenuDrawPage().

Definition at line 35 of file menu_psynergy.c.

PSYNERGY_LIST_CURSOR_X

#define PSYNERGY_LIST_CURSOR_X JAPANESE_OR(98, 88)

Referenced by mnPsynergyMenuRunList().

Definition at line 36 of file menu_psynergy.c.

PSYNERGY_ABILITY_OF

#define PSYNERGY_ABILITY_OF(entry) (((Uint32)(entry) << 18) >> 18)

A Psynergy entry's action id, its PSYNERGY_ABILITY_MASK bits, taken out by shifts.

Referenced by mnPsynergyMenuIsActionRestricted().

Definition at line 1562 of file menu_psynergy.c.

Enumerations in detail

PSYNERGY_MENU_STEP

enum PSYNERGY_MENU_STEP

The steps of the Psynergy menu (mnPsynergyMenuRunSteps).

EnumeratorValueDescription
PSYNERGY_STEP_MEMBER
PSYNERGY_STEP_LIST
PSYNERGY_STEP_CLASSIFYhow the Psynergy is used (mnPsynergyMenuClassifySelectedPsynergy)
PSYNERGY_STEP_TARGET
PSYNERGY_STEP_APPLY

Definition at line 105 of file menu_psynergy.c.

Functions in detail

mnPsynergyMenuRun

Sint32 mnPsynergyMenuRun(void)

The field menu's Psynergy screen (mnFieldMenuRun, FIELD_MENU_PSYNERGY), over the field, which stops meanwhile.

References fdPartyClearUnusableShortcutsStub(), gmAbilityGetDefinitionStub(), gmPartyListMembersStub(), mnInitState(), mnItemMenuClose(), mnItemMenuInit(), mnPageArrowsDrawStub(), mnPaletteLightenHighlight(), mnPsynergyMenuRunSteps(), mnResumeFieldEvents(), mnStartWatchingStart(), mnStopWatchingStart(), mnSuspendFieldEvents(), mnTextUseExtraTilesStub(), mnWindowCreateStub(), mnWindowDrawBorderStub(), mnWindowEraseBorderRectStub(), mnWindowMarkVisibleTextTilesStub(), mnWindowSpriteClearListStub(), Sint32, syHeapAllocateEWRAM(), syHeapRelease(), syHeapSlotAllocate(), syHeapSlotRelease(), sySynch(), syWordsCopy() and syWordsFill().

Definition at line 40 of file menu_psynergy.c.

mnPsynergyMenuRunSteps

Sint32 mnPsynergyMenuRunSteps(Sint32 *outMember, Sint32 *unused, Sint32 *outAction)

Runs the Psynergy menu: choose a party member and one of their Psynergy, then use it on a party member (or the whole party), or, in the shortcut modes, set it as the L or R shortcut.

References gmAbilityGetDefinitionStub(), gmFlagGetStub(), gmUnitAddPpStub(), gmUnitCalculateStub(), gmUnitGetStub(), mnAbilityApplyToTargets(), mnAbilityPlayUseSound(), mnHideEntryIcons(), mnItemMenuDrawMessage(), mnItemMenuShowMessage(), mnPsynergyMenuClassifySelectedPsynergy(), mnPsynergyMenuRunList(), mnPsynergyMenuSelectPartySlot(), mnPsynergyMenuSelectTarget(), mnPsynergyMenuSetShortcut(), mnStatusPanelDraw(), mnWindowSpriteClearListStub(), mnWindowSpriteRedrawSavedRectStub(), Sint32, sySoundPlayStub() and sySynch().

Referenced by mnPsynergyMenuRun().

Definition at line 118 of file menu_psynergy.c.

mnPsynergyMenuClassifySelectedPsynergy

Sint32 mnPsynergyMenuClassifySelectedPsynergy(void)

Says how the selected Psynergy is used from the menu, as an item is (enum ITEM_USE_MODE): ITEM_USE_MODE_FROM_FIELD once the menu closes when the scene has a script for its field Psynergy (fieldPsynergy) where the leader faces, ITEM_USE_MODE_WHOLE_PARTY for ABILITY_RANGE_ALL, ITEM_USE_MODE_CHOOSE_MEMBER when it targets ABILITY_TARGET_ALLIES, and ITEM_USE_MODE_FROM_FIELD otherwise.

References fdHasPsynergyCueStub(), gmAbilityGetDefinitionStub() and Sint32.

Referenced by mnPsynergyMenuRunSteps().

Definition at line 343 of file menu_psynergy.c.

mnPsynergyMenuSelectPartySlot

Sint32 mnPsynergyMenuSelectPartySlot(Sint32 partySlot)

Lets the player choose a party member in side partySlot (0 or 1), starting from the one chosen last, with each party member's Psynergy shown as the cursor passes.

References gmUnitGetStub(), mnCursorSlide(), mnIconShow(), mnPsynergyMenuCollectActions(), mnPsynergyMenuSelectMember(), Sint32 and sySynch().

Referenced by mnPsynergyMenuRunSteps().

Definition at line 373 of file menu_psynergy.c.

mnPsynergyMenuSelectMember

Sint32 mnPsynergyMenuSelectMember(Uint16 *memberIds, Uint16 *unused)

The party member row of the Psynergy menu.

References gmFlagClearStub(), gmFlagGetStub(), gmUnitGetStub(), mnCursorPos(), mnDrawCoins(), mnPsynergyMenuCollectActions(), mnPsynergyMenuDrawShortcuts(), mnPsynergyMenuRefreshMemberPsynergy(), mnReloadMemberPortrait(), mnSpawnIconEntries(), mnStatusPanelDraw(), mnWindowSpriteClearListStub(), mnWindowSpriteCreateFromResourceStub(), mnWindowSpriteRedrawSavedRectStub(), mnWindowUpdateOrCreate(), PerPush, PerRepeat, Sint32, syHeapAllocate(), syHeapRelease(), sySoundPlayStub() and sySynch().

Referenced by mnPsynergyMenuSelectPartySlot().

Definition at line 411 of file menu_psynergy.c.

mnPsynergyMenuRefreshMemberPsynergy

void mnPsynergyMenuRefreshMemberPsynergy(Sint32 memberId)

Shows party member memberId's Psynergy icons in the Psynergy window, eight to a row, or "no Psynergy" when they have none.

References gmUnitGetStub(), mnPsynergyMenuCollectActions(), mnPsynergyMenuDrawPsynergyIcons(), mnPsynergyMenuPlaceEntryIcons(), mnTextDrawMessageAsTilesStub(), mnWindowSpriteRedrawSavedRectStub() and Sint32.

Referenced by mnPsynergyMenuSelectMember().

Definition at line 540 of file menu_psynergy.c.

mnPsynergyMenuReturnTrue

Sint32 mnPsynergyMenuReturnTrue(void)

References Sint32.

Definition at line 561 of file menu_psynergy.c.

mnPsynergyMenuNoOperation

void mnPsynergyMenuNoOperation(void)

Definition at line 566 of file menu_psynergy.c.

mnPsynergyMenuSelectTarget

Sint32 mnPsynergyMenuSelectTarget(Sint32 targetMode)

Chooses the party member to use the selected Psynergy on.

References gmFlagClearStub(), gmFlagGetStub(), gmUnitGetStub(), mnCursorPos(), mnCursorSlide(), mnIconShow(), mnReloadMemberPortrait(), mnStatusPanelDraw(), PerPush, PerRepeat, Sint32, sySoundPlayStub() and sySynch().

Referenced by mnPsynergyMenuRunSteps().

Definition at line 571 of file menu_psynergy.c.

mnPsynergyMenuSetShortcut

Sint32 mnPsynergyMenuSetShortcut(Sint32 memberId, Sint32 abilityId, Sint32 shortcutIndex)

Sets the L or R Psynergy shortcut (PSYNERGY_SHORTCUT) to abilityId as memberId uses it, packed as the field's Psynergy request is. Returns 1.

References MainRoutineStateWork and Sint32.

Referenced by mnPsynergyMenuRunList() and mnPsynergyMenuRunSteps().

Definition at line 667 of file menu_psynergy.c.

mnPsynergyMenuDrawShortcuts

Sint32 mnPsynergyMenuDrawShortcuts(WINDOW *window, Sint32 memberId)

Sint32 mnPsynergyMenuDrawShortcuts(WINDOW *window, Sint32 member)

References gmUnitGetStub(), MainRoutineStateWork, MenuShortcutLColonString, MenuShortcutLString, MenuShortcutRColonString, MenuShortcutRString, mnMessageArgumentPushStub(), mnTextDrawMessageAsTilesStub(), mnTextDrawStringAtOffsetStub(), mnTextDrawStringInWindowStub(), mnTextGetMessageSizeStub(), mnTextSetColorStub(), Sint32 and width.

Referenced by mnPsynergyMenuSelectMember().

Definition at lines 692 and 772 of file menu_psynergy.c.

mnPsynergyMenuCreateEntryGrid

void mnPsynergyMenuCreateEntryGrid(void)

Sets up a Psynergy grid screen: the cursor window with the party's figures, a 30 by 15 window below with a hidden grid cursor and a portrait, and 16 Psynergy icon sprites in two rows of eight from (96, 8), on an 8 by 2 grid. Nothing calls it.

References mnCreatePartyFigures(), mnCursorCreate(), mnIconCreateHandCursor(), mnPortraitCreateStub(), mnWindowCreateStub(), mnWindowSpriteCreateFromResourceStub() and Sint32.

Definition at line 886 of file menu_psynergy.c.

mnPsynergyMenuCloseWindows

void mnPsynergyMenuCloseWindows(void)

Releases the party figures and closes the Psynergy grid screen's windows. Nothing calls it.

References mnReleasePartyFigures() and mnWindowCloseStub().

Definition at line 939 of file menu_psynergy.c.

mnPsynergyMenuDrawPsynergyIcons

void mnPsynergyMenuDrawPsynergyIcons(Uint16 *psynergies)

Loads each listed Psynergy's icon into its icon sprite (32 entries) and hides the icons of empty entries.

References mnHideEmptyEntryIcons(), mnSelectionIconLoadIntoSlotStub() and Sint32.

Referenced by mnPartyMemberChooserChooseMember(), mnPsynergyMenuDrawPreparedPsynergyIcons(), mnPsynergyMenuRefreshMemberPsynergy() and mnPsynergyMenuRunList().

Definition at line 952 of file menu_psynergy.c.

mnPsynergyMenuCollectActions

Sint32 mnPsynergyMenuCollectActions(UNIT *unit, Uint16 *actions, Sint32 mode)

Lists unit's Psynergy into actions (PSYNERGY_SLOTS entries, cleared first) and returns how many there are, as mode (PSYNERGY_LIST_MODE) chooses; any mode other than PSYNERGY_LIST_SHORTCUTS and PSYNERGY_LIST_FIELD lists as PSYNERGY_LIST_ALL.

References gmAbilityGetDefinitionStub() and Sint32.

Referenced by mnPartyMemberChooserChooseMember(), mnPsynergyMenuRefreshMemberPsynergy(), mnPsynergyMenuRunList(), mnPsynergyMenuSelectMember(), mnPsynergyMenuSelectPartySlot() and mnStatusScreenRunPsynergyPage().

Definition at line 978 of file menu_psynergy.c.

mnPsynergyMenuBuildPagedList

Sint32 mnPsynergyMenuBuildPagedList(PAGED_LIST *result, Sint32 index)

Fills result with the Psynergy list of the party member in side index: their unit, how many Psynergy are listed, and the page and row of the one chosen last for them (kept within the list), five to a page. Returns 1.

References gmUnitGetStub() and Sint32.

Referenced by mnPsynergyMenuRunList().

Definition at line 1055 of file menu_psynergy.c.

mnPsynergyMenuShowSelectedRow

Sint32 mnPsynergyMenuShowSelectedRow(WINDOW *window, Sint32 *memberState, PAGED_LIST *state)

Updates the Psynergy list for the row under the cursor: puts the Psynergy's description in the info window, unless a kept message is there, and highlights its row of the five. window and memberState are not used.

References gmFlagClearStub(), gmFlagGetStub(), mnWindowSetHighlightRect(), Sint32, state and sySynch().

Referenced by mnPsynergyMenuRunList().

Definition at line 1093 of file menu_psynergy.c.

mnPsynergyMenuDrawPage

Sint32 mnPsynergyMenuDrawPage(WINDOW *window, Sint32 unused, const PAGED_LIST *pageState)

Draws one page of the Psynergy list into window: up to five names with their icons and PP costs, Psynergy the party member cannot afford in the no-HP colour and one restricted here in the low-HP colour, the page numbers, and the help line (how to set a shortcut while Select is held, else how to change party member).

References gmAbilityGetDefinitionStub(), gmUnitGetStub(), mnPagedListDrawPageNumbers(), mnPsynergyMenuIsActionRestricted(), mnSetPageIcons(), mnTextDrawMessageAsTilesStub(), mnTextDrawNumberAtOffsetStub(), mnTextSetColorStub(), mnWindowDrawDividerLineStub(), mnWindowSpriteRedrawSavedRectStub() and Sint32.

Referenced by mnPsynergyMenuRunList().

Definition at line 1163 of file menu_psynergy.c.

mnPsynergyMenuRunList

Sint32 mnPsynergyMenuRunList(Sint32 sideIndex)

The Psynergy list of the party member in sideIndex, five a page.

References fdSpriteStartAnimationStub(), gmAbilityGetDefinitionStub(), gmFlagGetStub(), gmUnitGetStub(), mnCursorPos(), mnIconShow(), mnPagedListHandleInput(), mnPsynergyMenuBuildPagedList(), mnPsynergyMenuCollectActions(), mnPsynergyMenuDrawPage(), mnPsynergyMenuDrawPsynergyIcons(), mnPsynergyMenuIsActionRestricted(), mnPsynergyMenuSetShortcut(), mnPsynergyMenuShowSelectedRow(), mnReloadMemberPortrait(), mnStatusPanelDraw(), mnTextDrawMessageAsTilesStub(), mnWindowClearInteriorTilesStub(), mnWindowUpdateOrCreate(), PerData, PerPush, PerRepeat, Sint32, state, sySoundPlayStub() and sySynch().

Referenced by mnPsynergyMenuRunSteps().

Definition at line 1250 of file menu_psynergy.c.

mnPsynergyMenuIsActionRestricted

Bool mnPsynergyMenuIsActionRestricted(Sint32 actionEntry)

Returns 1 when actionEntry cannot be used from the menu: it has no field effect and is not usable both in the field and in battle.

References gmAbilityGetDefinitionStub() and Sint32.

Referenced by mnPsynergyMenuDrawPage() and mnPsynergyMenuRunList().

Definition at line 1566 of file menu_psynergy.c.