Alchemy
Loading...
Searching...
No Matches

shop.h File Reference

Go to the source code of this file.

Functions

s32 Shop_ListAvailableArtifacts (void)
 Lists the current shop's artifacts: every item of the shop's type whose shared stock counter is above zero.
void Shop_StepCursor (void)
 Advances the hand cursor one frame.
void Shop_InitializeCursorWork (void)
 Allocates and clears the work block in the menu's heap slot, lists the party, loads the six cursor icons into the VRAM cache and starts the cursor's task.
void Shop_ReleaseCursorWork (void)
 Stops the cursor task, frees the six cursor icons and the work block.
s32 Shop_Run (s32 stockRow, s32 keeperId)
 Runs a shop: the shopkeeper's welcome, then buy, sell, artifacts and repair until the player leaves.
s32 Battle_ApplyPresetItemsAndFlags (s32 unused)
 Opens the debug shop with 200000 coins, the ticket counter at its cap, broken equipment for repairs and poisoned or haunted members for the sanctum.
void AudioCommand_WaitForStateByteClear (void)
 Waits one frame at a time until the sound driver has finished the last command.
void UiMessage_ShowAndWait (s32 messageId)
 Shows a shopkeeper's line and waits for its window to finish, one more frame included.
void UiMessage_ShowAndRestoreState (s32 messageId)
 Shows a shopkeeper's line as UiMessage_ShowAndWait does, hiding the hand cursor while it shows and putting back its motion after.
s32 UiMessage_ShowChoice (s32 choice)
 Runs the Yes or No choice beside the shopkeeper's line and returns it, keeping the hand cursor's motion.
s32 UiMessage_ShowChoiceVariant (s32 choice)
 Runs the Yes or No choice at the sanctum's place on the screen and returns it, keeping the hand cursor's motion.
struct NodeChainNode * NodeChain_GetNodeAtIndex (struct NodeChainState *state)
 Unused original list walker: follows the requested number of next links.
void Shop_FillSelector (s32 itemCount, s32 paletteSelector, u8 *tileBuffer)
 Colours the first itemCount segments of the quantity bar with palette paletteSelector, writing six pixels a segment in tileBuffer.
void Shop_CopyGlyphs (s32 digit, u8 *tileBuffer, u32 digitPosition)
 Copies decimal glyph digit into its price-tile position, stopping at zero source bytes.
struct RenderOutput * Shop_CreatePriceSprite (s32 value, struct UiWindow *window, s32 x, s32 y)
 Builds a price of up to five digits in scratch tiles (heap slot 14), loads them into a free VRAM cache slot and attaches them to window as one sprite at (x, y).
void Shop_SaveAndTintFieldPalette (s32 layer)
 Saves the field colours in event work and fades to layer over 16 frames.
void Shop_RestoreFieldPalette (void)
 Fades back to the colours Shop_SaveAndTintFieldPalette saved, over 16 frames.
void ShopCursor_Advance (struct ShopCursor *cursor)
 Moves the cursor from its saved position toward its target, in a straight line over kind frames, one frame a call; active counts the frames and both go back to 0 on arrival.
void ShopCursor_MoveTowardTarget (struct ShopCursor *cursor)
 Moves each cursor axis one quarter of the remaining distance, with a minimum one-pixel step.
void Shop_SetCursor (struct ShopCursor *cursor, s32 targetX, s32 targetY, s32 kind)
 Starts a glide of the cursor from where it is to (targetX, targetY) over kind frames, for ShopCursor_Advance to run.
void ShopCursor_SetPositionImmediate (struct ShopCursor *cursor, s32 x, s32 y)
 Places the cursor and its sprite at (x, y) at once, with a one-frame glide that has already arrived.
void Shop_PlaceCursor (struct UiWindow *window, s32 x, s32 y)
 Starts the hand cursor's glide to (x, y) pixels inside window (the screen when it is NULL), over the frames shop->mode holds.
s32 Shop_SelectBuy (void)
 Runs the Buy and Artifacts counters: the player browses the stock seven items a page, picks one, chooses who gets it and how many, and pays.
void Shop_DrawStock (struct UiWindow *window, s32 selected)
 Draws a page of seven stock items with their prices, the page arrows, and the chosen item lifted and pulsing.
void Shop_DrawMoney (void)
 Draws the party's coins in the coins window, in the edition's layout.
void Shop_DrawItemPrice (struct UiWindow *window, s32 itemId, s32 price, s32 priceKind)
 Draws the item's name and below it its price.
void Shop_DrawMsg (struct UiWindow *window, s32 message)
 Shows message, an item's description, in the help window; a NULL window is ignored.
void Shop_DrawParty (struct UiWindow *window, s32 selected, s32 itemId)
 Shows the chosen member walking and the others standing, and draws at four fifths of their size the members who cannot equip itemId.
void Shop_DrawEquipComparison (struct UiWindow *window, s32 unitId, s32 itemId)
 Shows how Attack, Defense and Agility would change if the member wore the item: equips it in place of what it would replace, recomputes, puts the slot back and recomputes again, then draws both values with an arrow and the name of the item it would replace.
void Shop_DrawUnitItem (struct UiWindow *window, s32 unitId, s32 itemId)
 Shows the quantity already carried and the member's inventory icons.
s32 Shop_SelectBuyNum (s32 unitId, s32 itemId)
 Asks how many to buy when the item stacks, limited by what the coins buy, the artifact's stock and a stack of 30 less what the member carries.
s32 Shop_SelectQuantity (s32 minimum, s32 maximum, s32 price)
 Chooses how many items to buy or sell, returning the quantity above minimum or -1 when cancelled.
void Shop_BuyDone (s32 unitId, s32 itemId, s32 quantity)
 Adds each item bought to the member, charging its price and adding it to the shop credit one at a time, then offers to equip it and, if equipped, to sell what it replaced.
s32 Shop_ConfirmEquip (s32 unitId, s32 slot)
 Offers to equip the item just bought, unless it is equipped already, the member cannot equip it, or what it would replace is cursed on.
s32 Shop_SellOld (s32 unitId, s32 slot)
 Offers to sell the item the new one replaced, unless there is none or it is a Psynergy item or indispensable.
s32 Shop_SalePrice (s32 inventoryEntry)
 Returns what the shops pay for an inventory entry: nothing for an indispensable item, half the price for a broken one, three quarters otherwise.
s32 Shop_PickUnit (void)
 Lets the player choose whose items to sell or repair, with the coins window and the member's item grid, and runs Shop_SelectSell or Shop_SelectRepair for each member chosen until B.
s32 Shop_SelectSell (s32 unitId)
 Lets the player choose items to sell from the member's grid, one at a time, with each one's price and description, until B or the inventory is empty.
void Shop_DrawUnitGrid (struct UiWindow *window, s32 unitId)
 Draws the member's items as icons in rows of five, or a line saying it has none.
s32 Shop_SelectSellNum (s32 unitId, s32 slot)
 Asks how many to sell when the item is a stack of more than one, and returns the count (1 otherwise, -1 when cancelled), putting the cursor back after.
void Shop_SellItem (s32 unitId, s32 slot, s32 count)
 Sells count of the item in slot: refuses an item the shop does not buy or one equipped and cursed on, asks with the offer that fits (an old item the player just replaced, a broken one, a stack, a rare one), then discards them, pays the coins and redraws.
s32 Shop_RepairPrice (s32 inventoryEntry)
 Returns what a repair costs: a quarter of the price for a broken item, nothing for one that is not broken.
s32 Shop_SelectUnit (void)
 Runs the repair counter's member choice; always returns 0.
s32 Shop_SelectRepair (s32 unitId)
 Lets the player choose items to repair from the member's grid, one at a time, with each one's repair price, until B or the inventory is empty.
void Shop_RepairItem (s32 unitId, s32 slot)
 Repairs the item in slot: refuses one that cannot break, is not broken or is equipped and cursed on, or that the coins do not cover; asks, then takes the item away for the smith's three hammer blows, gives it back mended, charges the price and offers to equip it.
void Shop_BuySpecialItem (struct UiWindow *window, struct UiWindow *itemWindow)
 Gives a Game Ticket once the party's shop credit (what it has spent in shops) reaches the next ticket's cost, and lets the player choose who takes it.
s32 EventTable_GetRowLimit (void)
 Returns how many stock rows there are; Shop_Run refuses a row past them.
void EventTable_ApplyRowAbilities (s32 stockRow)
 Adds a shop's artifacts to the shared stock counters once, on its first visit, and sets the shop's flag (FLAG_SHOP_ARTIFACTS_STOCKED + row) to remember it.
s32 EventTable_CopyRowHeader (s32 stockRow, s16 *output)
 Copies the shop's ordinary stock, up to 24 items, to output with a 0 after, and returns how many.
s32 EventTable_GetRowType (s32 stockRow)
 Returns the shop's type from the last column of its stock row: 0 items, 1 weapons, 2 armor, as Item_GetEquipmentGroup sorts items.
s32 Shop_ServicePrice (s32 unitId, s32 serviceKind)
 Calculates the existing fee for reviving, curing poison, exorcising or removing a curse.
s32 Shop_CanServe (s32 unitId, s32 serviceKind)
 Checks whether a member needs the selected sanctum service.
s32 Shop_CountUnits (void)
 Counts party members who need the currently selected sanctum service.
s32 Shop_MsgByMode (s32 messageId)
 Selects the matching poison, exorcism or curse-service message from a revive message base.
void UiMessage_ShowResolvedAndWait (s32 messageId)
 Resolves service dialogue and waits for completion, including the final frame.
void UiMessage_ShowResolvedAndRestoreState (s32 messageId)
 Resolves service dialogue, waits for it and restores the cursor's saved mode.
s32 Shop_ConfirmAct (s32 unitId)
 Runs the sanctum service menu using the shared shop cursor and window resources.
s32 Sanctum_RunPartyService (void)
 Selects an eligible member, confirms the donation and applies the chosen service.
void BattleUnit_ResetStateByMode (s32 unitId, s32 serviceKind)
 Revives, cures poison, removes a haunting or unequips cursed items for a sanctum service.
void Shop_HiliteUnit (struct UiWindow *window, s32 selected)
 Highlights the selected party icon and dims members who do not need the sanctum service.
void Shop_DrawSelectMsg (struct UiWindow *target, s32 unitId)
 Shows the selected member's service price or the message that no treatment is needed.
void BattleFx_UpdateRadialMotion (struct EffectSlot *effect)
 Picks random particle positions, moves toward the target and releases finished particles.
void Shop_ResetEffects (void)
 Updates all 24 service particles, then randomizes the active member's pose.
void Shop_RunPartyMemberIconBurst (s32 member)
 Animates the selected member and service particles, then restores the menu and cursor.
s32 Inn_RoomPrice (s32 innId)
 Returns the night's price: the inn's price per guest times the party members still standing.
s32 Inn_CheckIn (s32 innId, s32 objectId)
 Runs an inn's counter: the innkeeper names the price, and on Yes, with the coins, the party sleeps (Inn_PlaySleep) and the innkeeper speaks again.
void Inn_PlaySleep (s32 roomPrice)
 Charges roomPrice, restores the HP and PP of each member still standing, and plays the night: a fade to black, the inn's music and a fade back.
s32 Shop_PickUnitItem (s32 *selectedUnit, s32 *selectedSlot)
 Lets the player choose a party member, then one of its items that may be dropped.
s32 Shop_SelectUse (s32 unitId)
 Lets the player choose one of the member's items to drop, refusing an indispensable or cursed equipped one with a message.
void Shop_DrawUseItem (struct UiWindow *window, s32 unitId, s32 slot)
 Draws the slot's item name and, below it, why it cannot be dropped or what the whole stack would sell for.

Function Documentation

◆ Shop_ListAvailableArtifacts()

s32 Shop_ListAvailableArtifacts ( void )

Lists the current shop's artifacts: every item of the shop's type whose shared stock counter is above zero.

Writes them to the work block's stock list and returns how many. Called by Shop_Run when the player picks Artifacts, and by Shop_SelectBuy to refresh the list after a purchase.

Definition at line 11 of file run.c.

Referenced by Shop_ListAvailableArtifacts(), Shop_Run(), and Shop_SelectBuy().

◆ Shop_StepCursor()

void Shop_StepCursor ( void )

Advances the hand cursor one frame.

Runs every frame as a scheduler task while a counter is open.

Definition at line 39 of file run.c.

Referenced by Shop_InitializeCursorWork(), Shop_ReleaseCursorWork(), and Shop_StepCursor().

◆ Shop_InitializeCursorWork()

void Shop_InitializeCursorWork ( void )

Allocates and clears the work block in the menu's heap slot, lists the party, loads the six cursor icons into the VRAM cache and starts the cursor's task.

Every counter opens with it: Shop_Run, the inn, the sanctum and the item picker.

Definition at line 47 of file run.c.

Referenced by Inn_CheckIn(), Shop_ConfirmAct(), Shop_InitializeCursorWork(), Shop_PickUnitItem(), and Shop_Run().

◆ Shop_ReleaseCursorWork()

void Shop_ReleaseCursorWork ( void )

Stops the cursor task, frees the six cursor icons and the work block.

Every counter closes with it.

Definition at line 79 of file run.c.

Referenced by Inn_CheckIn(), Shop_ConfirmAct(), Shop_PickUnitItem(), Shop_ReleaseCursorWork(), and Shop_Run().

◆ Shop_Run()

s32 Shop_Run ( s32 stockRow,
s32 keeperId )

Runs a shop: the shopkeeper's welcome, then buy, sell, artifacts and repair until the player leaves.

stockRow picks the row of sStockTable (0 for a row out of range) and keeperId the object whose portrait the messages show. Seeds the row's artifacts on the first visit and holds the work block while it runs. Called by the town scenes' shopkeepers through SHOP.S, and by the debug shop.

Definition at line 100 of file run.c.

Referenced by Battle_ApplyPresetItemsAndFlags(), Shop_Run(), TalkToShopkeeper32(), TalkToShopkeeper33(), and TalkToShopkeeper34().

◆ Battle_ApplyPresetItemsAndFlags()

s32 Battle_ApplyPresetItemsAndFlags ( s32 unused)

Opens the debug shop with 200000 coins, the ticket counter at its cap, broken equipment for repairs and poisoned or haunted members for the sanctum.

Called by DebugMenu_RunPresetShop.

Definition at line 179 of file run.c.

Referenced by Battle_ApplyPresetItemsAndFlags(), and DebugMenu_RunPresetShop().

◆ AudioCommand_WaitForStateByteClear()

void AudioCommand_WaitForStateByteClear ( void )

Waits one frame at a time until the sound driver has finished the last command.

Called by the inn's sleep, the sanctum and two scenes that wait for a fanfare.

Definition at line 198 of file run.c.

Referenced by AudioCommand_WaitForStateByteClear(), Inn_PlaySleep(), RaiseTheShip(), Shop_RunPartyMemberIconBurst(), and TolbiSpring_Initialize().

◆ UiMessage_ShowAndWait()

void UiMessage_ShowAndWait ( s32 messageId)

Shows a shopkeeper's line and waits for its window to finish, one more frame included.

messageId is the weapon shop's line; the armor, item and warriors' shops say theirs, at the same distance from their own welcome. Called by every counter.

Definition at line 214 of file run.c.

Referenced by Inn_CheckIn(), Shop_BuySpecialItem(), Shop_ConfirmEquip(), Shop_Run(), Shop_SelectBuy(), Shop_SelectBuyNum(), Shop_SelectRepair(), Shop_SelectSell(), Shop_SelectSellNum(), and UiMessage_ShowAndWait().

◆ UiMessage_ShowAndRestoreState()

void UiMessage_ShowAndRestoreState ( s32 messageId)

Shows a shopkeeper's line as UiMessage_ShowAndWait does, hiding the hand cursor while it shows and putting back its motion after.

Definition at line 239 of file run.c.

Referenced by Shop_BuyDone(), Shop_BuySpecialItem(), Shop_ConfirmEquip(), Shop_RepairItem(), Shop_SelectBuy(), Shop_SellItem(), and UiMessage_ShowAndRestoreState().

◆ UiMessage_ShowChoice()

s32 UiMessage_ShowChoice ( s32 choice)

Runs the Yes or No choice beside the shopkeeper's line and returns it, keeping the hand cursor's motion.

Called by the counters before they buy, sell, equip or repair, and by the inn.

Definition at line 278 of file run.c.

Referenced by Inn_CheckIn(), Shop_ConfirmEquip(), Shop_RepairItem(), Shop_SelectBuy(), Shop_SellItem(), and UiMessage_ShowChoice().

◆ UiMessage_ShowChoiceVariant()

s32 UiMessage_ShowChoiceVariant ( s32 choice)

Runs the Yes or No choice at the sanctum's place on the screen and returns it, keeping the hand cursor's motion.

Called by Sanctum_RunPartyService.

Definition at line 291 of file run.c.

Referenced by Sanctum_RunPartyService(), and UiMessage_ShowChoiceVariant().

◆ NodeChain_GetNodeAtIndex()

struct NodeChainNode * NodeChain_GetNodeAtIndex ( struct NodeChainState * state)

Unused original list walker: follows the requested number of next links.

Definition at line 303 of file run.c.

Referenced by NodeChain_GetNodeAtIndex().

◆ Shop_FillSelector()

void Shop_FillSelector ( s32 itemCount,
s32 paletteSelector,
u8 * tileBuffer )

Colours the first itemCount segments of the quantity bar with palette paletteSelector, writing six pixels a segment in tileBuffer.

Called by the shop's quantity choice and, through SHOP.S, by the item menu's quantity bar, which draws its bar in four colours this way.

Definition at line 25 of file cursor.c.

Referenced by Shop_FillSelector(), and Shop_SelectQuantity().

◆ Shop_CopyGlyphs()

void Shop_CopyGlyphs ( s32 digit,
u8 * tileBuffer,
u32 digitPosition )

Copies decimal glyph digit into its price-tile position, stopping at zero source bytes.

Called by Shop_CreatePriceSprite.

Definition at line 55 of file cursor.c.

Referenced by Shop_CopyGlyphs(), and Shop_CreatePriceSprite().

◆ Shop_CreatePriceSprite()

struct RenderOutput * Shop_CreatePriceSprite ( s32 value,
struct UiWindow * window,
s32 x,
s32 y )

Builds a price of up to five digits in scratch tiles (heap slot 14), loads them into a free VRAM cache slot and attaches them to window as one sprite at (x, y).

Returns the sprite, or NULL with no free slot. Called by Shop_DrawStock for each item on sale.

Definition at line 81 of file cursor.c.

Referenced by Shop_CreatePriceSprite(), and Shop_DrawStock().

◆ Shop_SaveAndTintFieldPalette()

void Shop_SaveAndTintFieldPalette ( s32 layer)

Saves the field colours in event work and fades to layer over 16 frames.

Called before sanctum and Djinn capture effects and Altmiller's wall burst; Shop_RestoreFieldPalette restores the saved colours afterward.

Definition at line 122 of file cursor.c.

Referenced by AltmillerCave_ReleaseWallBurst(), Shop_RunPartyMemberIconBurst(), and Shop_SaveAndTintFieldPalette().

◆ Shop_RestoreFieldPalette()

void Shop_RestoreFieldPalette ( void )

Fades back to the colours Shop_SaveAndTintFieldPalette saved, over 16 frames.

Called when the sanctum, Djinn capture or Altmiller wall effect ends.

Definition at line 147 of file cursor.c.

Referenced by AltmillerCave_ReleaseWallBurst(), Shop_RestoreFieldPalette(), and Shop_RunPartyMemberIconBurst().

◆ ShopCursor_Advance()

void ShopCursor_Advance ( struct ShopCursor * cursor)

Moves the cursor from its saved position toward its target, in a straight line over kind frames, one frame a call; active counts the frames and both go back to 0 on arrival.

Runs every frame from Shop_StepCursor, and from the option, name entry and save menus' cursor tasks.

Definition at line 156 of file cursor.c.

Referenced by Shop_StepCursor(), and ShopCursor_Advance().

◆ ShopCursor_MoveTowardTarget()

void ShopCursor_MoveTowardTarget ( struct ShopCursor * cursor)

Moves each cursor axis one quarter of the remaining distance, with a minimum one-pixel step.

Called each frame by the option menu and name entry.

Definition at line 186 of file cursor.c.

Referenced by ShopCursor_MoveTowardTarget().

◆ Shop_SetCursor()

void Shop_SetCursor ( struct ShopCursor * cursor,
s32 targetX,
s32 targetY,
s32 kind )

Starts a glide of the cursor from where it is to (targetX, targetY) over kind frames, for ShopCursor_Advance to run.

Called by Shop_PlaceCursor and, through SHOP.S, by name entry and the Colosso choice.

Definition at line 234 of file cursor.c.

Referenced by Shop_PlaceCursor(), and Shop_SetCursor().

◆ ShopCursor_SetPositionImmediate()

void ShopCursor_SetPositionImmediate ( struct ShopCursor * cursor,
s32 x,
s32 y )

Places the cursor and its sprite at (x, y) at once, with a one-frame glide that has already arrived.

Called when a counter, the option and system menus or name entry opens.

Definition at line 249 of file cursor.c.

Referenced by Shop_ConfirmAct(), Shop_PickUnitItem(), Shop_Run(), and ShopCursor_SetPositionImmediate().

◆ Shop_PlaceCursor()

void Shop_PlaceCursor ( struct UiWindow * window,
s32 x,
s32 y )

Starts the hand cursor's glide to (x, y) pixels inside window (the screen when it is NULL), over the frames shop->mode holds.

Called by every counter's lists.

Definition at line 273 of file cursor.c.

Referenced by Sanctum_RunPartyService(), Shop_BuySpecialItem(), Shop_PickUnit(), Shop_PickUnitItem(), Shop_PlaceCursor(), Shop_SelectBuy(), Shop_SelectBuyNum(), Shop_SelectRepair(), Shop_SelectSell(), Shop_SelectSellNum(), and Shop_SelectUse().

◆ Shop_SelectBuy()

s32 Shop_SelectBuy ( void )

Runs the Buy and Artifacts counters: the player browses the stock seven items a page, picks one, chooses who gets it and how many, and pays.

Checks room in the bag and coins first, and warns when the member cannot equip it. An artifact bought takes its stock counter down, and the list is rebuilt. Repeats until B. Called by Shop_Run.

Definition at line 19 of file buy.c.

Referenced by Shop_Run(), and Shop_SelectBuy().

◆ Shop_DrawStock()

void Shop_DrawStock ( struct UiWindow * window,
s32 selected )

Draws a page of seven stock items with their prices, the page arrows, and the chosen item lifted and pulsing.

Called by Shop_SelectBuy each time the cursor moves.

Definition at line 241 of file buy.c.

Referenced by Shop_DrawStock(), and Shop_SelectBuy().

◆ Shop_DrawMoney()

void Shop_DrawMoney ( void )

Draws the party's coins in the coins window, in the edition's layout.

Called when a counter opens and after each purchase, sale or repair.

Definition at line 305 of file buy.c.

Referenced by Inn_CheckIn(), Sanctum_RunPartyService(), Shop_BuyDone(), Shop_ConfirmAct(), Shop_DrawMoney(), Shop_PickUnit(), Shop_RepairItem(), Shop_SelectBuy(), and Shop_SellItem().

◆ Shop_DrawItemPrice()

void Shop_DrawItemPrice ( struct UiWindow * window,
s32 itemId,
s32 price,
s32 priceKind )

Draws the item's name and below it its price.

With a price of 0 it says instead that the shop does not buy it (priceKind 1) or that it is not broken (2). Called by the buy, sell and repair lists.

Definition at line 328 of file buy.c.

Referenced by Shop_DrawItemPrice(), Shop_SelectBuy(), Shop_SelectRepair(), and Shop_SelectSell().

◆ Shop_DrawMsg()

void Shop_DrawMsg ( struct UiWindow * window,
s32 message )

Shows message, an item's description, in the help window; a NULL window is ignored.

Called by the counters' lists each time the cursor moves.

Definition at line 367 of file buy.c.

Referenced by Shop_DrawMsg(), Shop_SelectBuy(), Shop_SelectRepair(), Shop_SelectSell(), and Shop_SelectUse().

◆ Shop_DrawParty()

void Shop_DrawParty ( struct UiWindow * window,
s32 selected,
s32 itemId )

Shows the chosen member walking and the others standing, and draws at four fifths of their size the members who cannot equip itemId.

Called by every counter's member choice.

Definition at line 382 of file buy.c.

Referenced by Shop_BuySpecialItem(), Shop_DrawParty(), Shop_PickUnit(), Shop_PickUnitItem(), and Shop_SelectBuy().

◆ Shop_DrawEquipComparison()

void Shop_DrawEquipComparison ( struct UiWindow * window,
s32 unitId,
s32 itemId )

Shows how Attack, Defense and Agility would change if the member wore the item: equips it in place of what it would replace, recomputes, puts the slot back and recomputes again, then draws both values with an arrow and the name of the item it would replace.

Called by Shop_SelectBuy for weapons and armor.

Definition at line 407 of file buy.c.

Referenced by Shop_DrawEquipComparison(), and Shop_SelectBuy().

◆ Shop_DrawUnitItem()

void Shop_DrawUnitItem ( struct UiWindow * window,
s32 unitId,
s32 itemId )

Shows the quantity already carried and the member's inventory icons.

Called by Shop_SelectBuy for items that are not equipment.

Definition at line 484 of file buy.c.

Referenced by Shop_BuySpecialItem(), Shop_DrawUnitItem(), and Shop_SelectBuy().

◆ Shop_SelectBuyNum()

s32 Shop_SelectBuyNum ( s32 unitId,
s32 itemId )

Asks how many to buy when the item stacks, limited by what the coins buy, the artifact's stock and a stack of 30 less what the member carries.

Returns the count (1 for other items), or -1 when cancelled. Called by Shop_SelectBuy.

Definition at line 547 of file buy.c.

Referenced by Shop_SelectBuy(), and Shop_SelectBuyNum().

◆ Shop_SelectQuantity()

s32 Shop_SelectQuantity ( s32 minimum,
s32 maximum,
s32 price )

Chooses how many items to buy or sell, returning the quantity above minimum or -1 when cancelled.

The bar's fixed prefix is minimum (items already carried when buying); maximum must exceed it so at least one can be chosen. Holds heap slot 14 for the bar's tiles. Called by the buy and sell quantity pickers.

Definition at line 611 of file buy.c.

Referenced by Shop_SelectBuyNum(), Shop_SelectQuantity(), and Shop_SelectSellNum().

◆ Shop_BuyDone()

void Shop_BuyDone ( s32 unitId,
s32 itemId,
s32 quantity )

Adds each item bought to the member, charging its price and adding it to the shop credit one at a time, then offers to equip it and, if equipped, to sell what it replaced.

Called by Shop_SelectBuy.

Definition at line 700 of file buy.c.

Referenced by Shop_BuyDone(), and Shop_SelectBuy().

◆ Shop_ConfirmEquip()

s32 Shop_ConfirmEquip ( s32 unitId,
s32 slot )

Offers to equip the item just bought, unless it is equipped already, the member cannot equip it, or what it would replace is cursed on.

Equips it on Yes, redraws the grid and warns of a curse. Returns 1 when it was equipped. Called by Shop_BuyDone.

Definition at line 732 of file buy.c.

Referenced by Shop_BuyDone(), Shop_ConfirmEquip(), and Shop_RepairItem().

◆ Shop_SellOld()

s32 Shop_SellOld ( s32 unitId,
s32 slot )

Offers to sell the item the new one replaced, unless there is none or it is a Psynergy item or indispensable.

Returns 1 when it offered. Called by Shop_BuyDone.

Definition at line 781 of file buy.c.

Referenced by Shop_BuyDone(), Shop_RepairItem(), and Shop_SellOld().

◆ Shop_SalePrice()

s32 Shop_SalePrice ( s32 inventoryEntry)

Returns what the shops pay for an inventory entry: nothing for an indispensable item, half the price for a broken one, three quarters otherwise.

Definition at line 803 of file buy.c.

Referenced by Shop_DrawUseItem(), Shop_SalePrice(), Shop_SelectSell(), Shop_SelectSellNum(), and Shop_SellItem().

◆ Shop_PickUnit()

s32 Shop_PickUnit ( void )

Lets the player choose whose items to sell or repair, with the coins window and the member's item grid, and runs Shop_SelectSell or Shop_SelectRepair for each member chosen until B.

Called by Shop_Run for Sell and Repair.

Definition at line 11 of file sell.c.

Referenced by Shop_PickUnit(), Shop_Run(), and Shop_SelectUnit().

◆ Shop_SelectSell()

s32 Shop_SelectSell ( s32 unitId)

Lets the player choose items to sell from the member's grid, one at a time, with each one's price and description, until B or the inventory is empty.

Returns -1 when cancelled, 0 when the inventory ran out. Called by Shop_PickUnit.

Definition at line 83 of file sell.c.

Referenced by Shop_PickUnit(), and Shop_SelectSell().

◆ Shop_DrawUnitGrid()

void Shop_DrawUnitGrid ( struct UiWindow * window,
s32 unitId )

Draws the member's items as icons in rows of five, or a line saying it has none.

Called by the sell, repair and drop screens each time the member changes, and after a sale.

Definition at line 190 of file sell.c.

Referenced by Shop_ConfirmEquip(), Shop_DrawUnitGrid(), Shop_PickUnit(), Shop_PickUnitItem(), Shop_RepairItem(), and Shop_SellItem().

◆ Shop_SelectSellNum()

s32 Shop_SelectSellNum ( s32 unitId,
s32 slot )

Asks how many to sell when the item is a stack of more than one, and returns the count (1 otherwise, -1 when cancelled), putting the cursor back after.

Called by Shop_SelectSell.

Definition at line 231 of file sell.c.

Referenced by Shop_SelectSell(), and Shop_SelectSellNum().

◆ Shop_SellItem()

void Shop_SellItem ( s32 unitId,
s32 slot,
s32 count )

Sells count of the item in slot: refuses an item the shop does not buy or one equipped and cursed on, asks with the offer that fits (an old item the player just replaced, a broken one, a stack, a rare one), then discards them, pays the coins and redraws.

count -1 is the old equipment the equip prompt offers to sell (Shop_SellOld).

Definition at line 269 of file sell.c.

Referenced by Shop_SelectSell(), Shop_SellItem(), and Shop_SellOld().

◆ Shop_RepairPrice()

s32 Shop_RepairPrice ( s32 inventoryEntry)

Returns what a repair costs: a quarter of the price for a broken item, nothing for one that is not broken.

Called by the repair list and Shop_RepairItem.

Definition at line 10 of file repair.c.

Referenced by Shop_RepairItem(), Shop_RepairPrice(), and Shop_SelectRepair().

◆ Shop_SelectUnit()

s32 Shop_SelectUnit ( void )

Runs the repair counter's member choice; always returns 0.

Called by Shop_Run for Repair.

Definition at line 21 of file repair.c.

Referenced by Shop_Run(), and Shop_SelectUnit().

◆ Shop_SelectRepair()

s32 Shop_SelectRepair ( s32 unitId)

Lets the player choose items to repair from the member's grid, one at a time, with each one's repair price, until B or the inventory is empty.

Returns -1 when cancelled, 0 when the inventory ran out. Called by Shop_PickUnit.

Definition at line 30 of file repair.c.

Referenced by Shop_PickUnit(), and Shop_SelectRepair().

◆ Shop_RepairItem()

void Shop_RepairItem ( s32 unitId,
s32 slot )

Repairs the item in slot: refuses one that cannot break, is not broken or is equipped and cursed on, or that the coins do not cover; asks, then takes the item away for the smith's three hammer blows, gives it back mended, charges the price and offers to equip it.

Called by Shop_SelectRepair.

Definition at line 136 of file repair.c.

Referenced by Shop_RepairItem(), and Shop_SelectRepair().

◆ Shop_BuySpecialItem()

void Shop_BuySpecialItem ( struct UiWindow * window,
struct UiWindow * itemWindow )

Gives a Game Ticket once the party's shop credit (what it has spent in shops) reaches the next ticket's cost, and lets the player choose who takes it.

Spends the credit and counts the gift, not coins. Called by Shop_SelectBuy after each purchase.

Definition at line 32 of file artifacts.c.

Referenced by Shop_BuySpecialItem(), and Shop_SelectBuy().

◆ EventTable_GetRowLimit()

s32 EventTable_GetRowLimit ( void )

Returns how many stock rows there are; Shop_Run refuses a row past them.

Definition at line 304 of file artifacts.c.

Referenced by EventTable_GetRowLimit(), and Shop_Run().

◆ EventTable_ApplyRowAbilities()

void EventTable_ApplyRowAbilities ( s32 stockRow)

Adds a shop's artifacts to the shared stock counters once, on its first visit, and sets the shop's flag (FLAG_SHOP_ARTIFACTS_STOCKED + row) to remember it.

Called by Shop_Run as a shop opens.

Definition at line 309 of file artifacts.c.

Referenced by EventTable_ApplyRowAbilities(), and Shop_Run().

◆ EventTable_CopyRowHeader()

s32 EventTable_CopyRowHeader ( s32 stockRow,
s16 * output )

Copies the shop's ordinary stock, up to 24 items, to output with a 0 after, and returns how many.

Called by Shop_Run for Buy.

Definition at line 338 of file artifacts.c.

Referenced by EventTable_CopyRowHeader(), and Shop_Run().

◆ EventTable_GetRowType()

s32 EventTable_GetRowType ( s32 stockRow)

Returns the shop's type from the last column of its stock row: 0 items, 1 weapons, 2 armor, as Item_GetEquipmentGroup sorts items.

Called by Shop_Run.

Definition at line 366 of file artifacts.c.

Referenced by EventTable_GetRowType(), and Shop_Run().

◆ Shop_ServicePrice()

s32 Shop_ServicePrice ( s32 unitId,
s32 serviceKind )

Calculates the existing fee for reviving, curing poison, exorcising or removing a curse.

Definition at line 9 of file sanctum.c.

Referenced by Sanctum_RunPartyService(), Shop_DrawSelectMsg(), and Shop_ServicePrice().

◆ Shop_CanServe()

s32 Shop_CanServe ( s32 unitId,
s32 serviceKind )

Checks whether a member needs the selected sanctum service.

Definition at line 26 of file sanctum.c.

Referenced by Sanctum_RunPartyService(), Shop_CanServe(), Shop_CountUnits(), Shop_DrawSelectMsg(), and Shop_HiliteUnit().

◆ Shop_CountUnits()

s32 Shop_CountUnits ( void )

Counts party members who need the currently selected sanctum service.

Definition at line 40 of file sanctum.c.

Referenced by Sanctum_RunPartyService(), Shop_ConfirmAct(), and Shop_CountUnits().

◆ Shop_MsgByMode()

s32 Shop_MsgByMode ( s32 messageId)

Selects the matching poison, exorcism or curse-service message from a revive message base.

Definition at line 55 of file sanctum.c.

Referenced by Shop_DrawSelectMsg(), Shop_MsgByMode(), UiMessage_ShowResolvedAndRestoreState(), and UiMessage_ShowResolvedAndWait().

◆ UiMessage_ShowResolvedAndWait()

void UiMessage_ShowResolvedAndWait ( s32 messageId)

Resolves service dialogue and waits for completion, including the final frame.

Definition at line 72 of file sanctum.c.

Referenced by Sanctum_RunPartyService(), Shop_ConfirmAct(), and UiMessage_ShowResolvedAndWait().

◆ UiMessage_ShowResolvedAndRestoreState()

void UiMessage_ShowResolvedAndRestoreState ( s32 messageId)

Resolves service dialogue, waits for it and restores the cursor's saved mode.

Definition at line 89 of file sanctum.c.

Referenced by Sanctum_RunPartyService(), and UiMessage_ShowResolvedAndRestoreState().

◆ Shop_ConfirmAct()

s32 Shop_ConfirmAct ( s32 unitId)

Runs the sanctum service menu using the shared shop cursor and window resources.

Definition at line 111 of file sanctum.c.

Referenced by DebugMenu_ConfirmShopAction(), Shop_ConfirmAct(), and TalkToPriest().

◆ Sanctum_RunPartyService()

s32 Sanctum_RunPartyService ( void )

Selects an eligible member, confirms the donation and applies the chosen service.

Definition at line 183 of file sanctum.c.

Referenced by Sanctum_RunPartyService(), and Shop_ConfirmAct().

◆ BattleUnit_ResetStateByMode()

void BattleUnit_ResetStateByMode ( s32 unitId,
s32 serviceKind )

Revives, cures poison, removes a haunting or unequips cursed items for a sanctum service.

Definition at line 308 of file sanctum.c.

Referenced by BattleUnit_ResetStateByMode(), and Sanctum_RunPartyService().

◆ Shop_HiliteUnit()

void Shop_HiliteUnit ( struct UiWindow * window,
s32 selected )

Highlights the selected party icon and dims members who do not need the sanctum service.

Definition at line 336 of file sanctum.c.

Referenced by Sanctum_RunPartyService(), and Shop_HiliteUnit().

◆ Shop_DrawSelectMsg()

void Shop_DrawSelectMsg ( struct UiWindow * target,
s32 unitId )

Shows the selected member's service price or the message that no treatment is needed.

Definition at line 358 of file sanctum.c.

Referenced by Sanctum_RunPartyService(), and Shop_DrawSelectMsg().

◆ BattleFx_UpdateRadialMotion()

void BattleFx_UpdateRadialMotion ( struct EffectSlot * effect)

Picks random particle positions, moves toward the target and releases finished particles.

Definition at line 379 of file sanctum.c.

Referenced by BattleFx_UpdateRadialMotion(), and Shop_RunPartyMemberIconBurst().

◆ Shop_ResetEffects()

void Shop_ResetEffects ( void )

Updates all 24 service particles, then randomizes the active member's pose.

Definition at line 412 of file sanctum.c.

Referenced by Shop_ResetEffects(), and Shop_RunPartyMemberIconBurst().

◆ Shop_RunPartyMemberIconBurst()

void Shop_RunPartyMemberIconBurst ( s32 member)

Animates the selected member and service particles, then restores the menu and cursor.

Definition at line 439 of file sanctum.c.

Referenced by Sanctum_RunPartyService(), and Shop_RunPartyMemberIconBurst().

◆ Inn_RoomPrice()

s32 Inn_RoomPrice ( s32 innId)

Returns the night's price: the inn's price per guest times the party members still standing.

Called by Inn_CheckIn.

Definition at line 26 of file inn.c.

Referenced by Inn_CheckIn(), and Inn_RoomPrice().

◆ Inn_CheckIn()

s32 Inn_CheckIn ( s32 innId,
s32 objectId )

Runs an inn's counter: the innkeeper names the price, and on Yes, with the coins, the party sleeps (Inn_PlaySleep) and the innkeeper speaks again.

Holds the shop's work block while it runs. Called by the town scenes' innkeepers through SHOP.S (Engine_InnOpen).

Definition at line 43 of file inn.c.

Referenced by Inn_CheckIn(), and TalkToInnkeeper().

◆ Inn_PlaySleep()

void Inn_PlaySleep ( s32 roomPrice)

Charges roomPrice, restores the HP and PP of each member still standing, and plays the night: a fade to black, the inn's music and a fade back.

Called by Inn_CheckIn.

Definition at line 103 of file inn.c.

Referenced by BabiPalace_RestInPalaceBeds(), Inn_CheckIn(), and Inn_PlaySleep().

◆ Shop_PickUnitItem()

s32 Shop_PickUnitItem ( s32 * selectedUnit,
s32 * selectedSlot )

Lets the player choose a party member, then one of its items that may be dropped.

Writes the member and inventory slot to selectedUnit and selectedSlot and returns 0, or writes -1 to both and returns -1 when cancelled. Holds the shop's work block while it runs. Reached through SHOP.S when an item is found with every bag full ("What will you drop?", PartyInventory_GiveItem), by the Elemental Star room's Mythril Bags and by the debug menu.

Definition at line 14 of file item_picker.c.

Referenced by DebugMenu_TestItemSelection(), Shop_PickUnitItem(), and SolSanctumElementalStarRoom_GiveMythrilBags().

◆ Shop_SelectUse()

s32 Shop_SelectUse ( s32 unitId)

Lets the player choose one of the member's items to drop, refusing an indispensable or cursed equipped one with a message.

Returns the slot, or -1 when cancelled. Called by Shop_PickUnitItem.

Definition at line 130 of file item_picker.c.

Referenced by Shop_PickUnitItem(), and Shop_SelectUse().

◆ Shop_DrawUseItem()

void Shop_DrawUseItem ( struct UiWindow * window,
s32 unitId,
s32 slot )

Draws the slot's item name and, below it, why it cannot be dropped or what the whole stack would sell for.

Called by Shop_SelectUse each time the cursor moves.

Definition at line 244 of file item_picker.c.

Referenced by Shop_DrawUseItem(), and Shop_SelectUse().