Skip to Content
The Alchemy Project

include/shop/shop.h

The counters of a town, shops, sanctums and inns: SHOP_STATE, the state they share, the shop screen's tiles, and every function of the shop object.

Included by menu_item.c, shop_internal.h, script.h and import.h.

Structures

NameDescription
structSHOP_STATEA shop's state: its windows, the party members' icons, the stock, the cursor and its icons, and the field effect sprites.

Macros

NameDescription
#defineSHOP_CURSOR_ENTER_TICKS 12The ticks the hand cursor takes to glide into a newly opened list.
#defineSANCTUM_PARTICLE_COUNT 24The particles a sanctum service's sparkles use (SHOP_STATE.effects), and how many of them fly in at the party member's icon in its burst.
#defineSANCTUM_BURST_SPARKLES 18

Enumerations

NameDescription
enumQUANTITY_BAR_COL { QUANTITY_BAR_CHOOSABLE, QUANTITY_BAR_HELD, QUANTITY_BAR_CHOS … }The quantity bar's colours (mnQuantityBarFill), painted over each other longest first: past what can be chosen, what can be chosen, the number chosen and what is held already.
enumSHOP_PRICE_KIND { SHOP_PRICE_KIND_BUY, SHOP_PRICE_KIND_SELL, SHOP_PRICE_KIND_R … }What mnShopDrawItemPrice says below an item whose price is 0.

Functions

NameDescription
Sint32mnShopOpenDebugShop (Sint32 unused)The shop module's functions in the order of its stub table (src/shop/stubs.s).
Sint32mnShopRun (Sint32 stockRow, Sint32 keeperId)Runs a shop: the shopkeeper's welcome, then buy, sell, artifacts and repair until the player leaves. keeperId is the actor whose portrait the lines show.
Sint32mnSanctumRun (Sint32 keeperId)Runs a Sanctum: the healer's welcome, the service menu until B, and the farewell; keeperId is the healer's actor, whose portrait the lines show.
Sint32mnInnCheckIn (Sint32 innId, Sint32 actorId)Runs an inn's counter: the innkeeper names the price, and on Yes the party sleeps. actorId is the innkeeper, whose portrait the lines show.
voidmnCursorAdvance (MENU_CURSOR *cursor)Moves the cursor a tick along its straight line toward its target.
voidmnCursorMoveTowardTarget (MENU_CURSOR *cursor)Eases a cursor toward its target, a quarter of the way on each axis a tick and at least a pixel; the settings and name-entry screens move their markers with it.
voidmnCursorSet (MENU_CURSOR *cursor, Sint32 targetX, Sint32 targetY, Sint32 ticks)Starts a glide of the cursor from where it is to (targetX, targetY) over ticks ticks, for mnCursorAdvance to run.
voidmnCursorSetPosImmediate (MENU_CURSOR *cursor, Sint32 x, Sint32 y)Places the cursor and its sprite at (x, y) at once, with a one-tick glide that has already arrived.
voidmnQuantityBarFill (Sint32 itemCount, Sint32 color, Uint8 *tileBuf)Colours the first itemCount segments of the quantity bar in color (enum QUANTITY_BAR_COL).
voidmnShopSaveAndTintFieldPalette (Sint32 tint)Saves the field's background colours in the field state and fades them to tint (PALETTE_TINT_CUSTOM with a colour) over SHOP_TINT_TICKS ticks.
voidmnShopRestoreFieldPalette (void)Fades back to the colours mnShopSaveAndTintFieldPalette saved, over SHOP_TINT_TICKS ticks.
Sint32mnItemPickerRun (Sint32 *selectedUnit, Sint32 *selectedSlot)Lets the player choose a party member, then one of their items that may be dropped, in the selling screen without its shopkeeper.
voidmnSoundWaitForJingle (void)Waits a tick at a time while a jingle holds back the music, as the inn's does through the night.
voidmnInnPlaySleep (Sint32 roomPrice)Charges the room and restores the HP and PP of each party member still standing over a night: a fade to black, the inn's music and a fade back.
Sint32mnShopListAvailableArtifacts (void)A counter's state and the shop's visit, and what every counter shares: the keeper's lines, the Yes or No choice and waiting out a jingle (shop_run.c).
voidmnCursorStep (void)Advances the hand cursor one tick.
voidmnShopInitState (void)Opens a counter's state: the party list, the cursor icons and the cursor's event, which last until mnShopReleaseState.
voidmnShopReleaseState (void)Stops the cursor event, frees the six cursor icons and the state block.
voidmnShopShowKeeperMessage (Sint32 msgId)Shows a shopkeeper's line and waits until it is typed out.
voidmnShopShowKeeperMessageHidingCursor (Sint32 msgId)Shows a shopkeeper's line as mnShopShowKeeperMessage does, hiding the hand cursor while it shows and putting back its motion after.
Sint32mnShopAskYesNo (Sint32 choice)Runs the Yes or No choice beside the shopkeeper's line: 0 for Yes, 1 for No or B.
Sint32mnSanctumAskYesNo (Sint32 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 SELECTION_NODE *mnNodeChainGetNodeAtIndex (struct SELECTION_MENU_STATE *state)Returns the node state->count next links on from state->node.
voidmnShopDrawPriceDigit (Sint32 digit, Uint8 *tileBuf, Uint32 digitPos)The quantity bar and price sprites, the field's tint behind a counter and the hand cursor's moves (shop_cursor.c).
WINDOW_SPR *mnShopCreatePriceSprite (Sint32 value, struct WINDOW *window, Sint32 x, Sint32 y)Builds a price of up to five digits as a sprite on window at (x, y).
voidmnCursorPlace (struct WINDOW *window, Sint32 x, Sint32 y)Starts the hand cursor's glide to (x, y) pixels inside window (the screen when it is NULL), over the ticks shop->cursorMoveTicks holds.
Sint32mnShopSelectBuy (void)Buying, and the windows the other counters share: the coins, an item's price and description, the party and the quantity bar (shop_buy.c).
voidmnShopDrawStock (struct WINDOW *window, Sint32 selected)Draws a page of seven stock items with their prices, the page arrows, and the chosen item lifted and pulsing.
voidmnShopDrawMoney (void)Draws the party's coins in the coins window, in the edition's layout.
voidmnShopDrawItemPrice (struct WINDOW *window, Sint32 itemId, Sint32 price, Sint32 priceKind)Draws the item's name and below it its price.
voidmnShopDrawMessage (struct WINDOW *window, Sint32 msg)Shows msg, an item's description, in the help window; a NULL window is ignored.
voidmnShopDrawParty (struct WINDOW *window, Sint32 selected, Sint32 itemId)Shows the chosen party member running in place and the others standing, and draws at four fifths of their size the party members who cannot equip itemId.
voidmnShopDrawEquipComparison (struct WINDOW *window, Sint32 unitId, Sint32 itemId)Shows how Attack, Defense and Agility would change if the party member wore the item, with an arrow up or down beside each that changes and the name of the item it would replace.
voidmnShopDrawCarriedItem (struct WINDOW *window, Sint32 unitId, Sint32 itemId)Shows how many of the item the party member carries ("You have", or "None in stock" when none) and their inventory's icons.
Sint32mnShopSelectBuyCount (Sint32 unitId, Sint32 itemId)Asks how many to buy when the item stacks, limited by what the coins buy, the artifact's stock and a full stack less what the party member carries.
Sint32mnShopSelectQuantity (Sint32 minimum, Sint32 maximum, Sint32 price)Lets the player choose how many to buy or sell on the quantity bar, from 1 to limit less the carried already held, with the coins they come to.
voidmnShopBuyDone (Sint32 unitId, Sint32 itemId, Sint32 quantity)Gives the party member each item bought and takes its price, then offers to equip it and to sell what it replaced.
BoolmnShopConfirmEquip (Sint32 unitId, Sint32 slot)Offers to equip the item just bought, and warns of a curse.
BoolmnShopSellOld (Sint32 unitId, Sint32 slot)Offers to sell the item the new one replaced, unless there is none or it is a Psynergy item or indispensable.
Sint32mnShopSalePrice (Sint32 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.
Sint32mnShopChooseMember (void)Selling, and the party member's item grid (shop_sell.c).
Sint32mnShopSelectSell (Sint32 unitId)Lets the player choose items to sell from the party member's grid, one at a time, with each one's price and description, until B or the inventory is empty.
voidmnShopDrawMemberItems (struct WINDOW *window, Sint32 unitId)Draws the party member's items as icons in rows of five, or a line saying it has none.
Sint32mnShopSelectSellCount (Sint32 unitId, Sint32 slot)Asks how many to sell of a stack, and returns the count, -1 when cancelled.
voidmnShopSellItem (Sint32 unitId, Sint32 slot, Sint32 count)Sells count of the item in slot, after the shopkeeper's offer that fits it and a Yes; whatever the shops keep a stock of goes back on sale.
Sint32mnShopRepairPrice (Sint32 inventoryEntry)Repairing (shop_repair.c).
Sint32mnShopRunRepairMemberChoice (void)Runs the repair counter's party member choice; always returns 0.
Sint32mnShopSelectRepair (Sint32 unitId)Lets the player choose items to repair from the party member's grid, one at a time, with each one's repair price, until B or the inventory is empty.
voidmnShopRepairItem (Sint32 unitId, Sint32 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 while three clangs sound, gives it back mended, charges the price and offers to equip it.
voidmnShopGiveGameTicket (struct WINDOW *window, struct WINDOW *itemWindow)The Game Ticket and every shop's stock (shop_stock.c).
Sint32mnShopStockGetRowCount (void)Returns how many stock rows there are; mnShopRun refuses a row past them.
voidmnShopStockAddArtifacts (Sint32 stockRow)Adds a shop's artifacts to the shared stock on its first visit, so an item two shops list can be bought twice.
Sint32mnShopStockCopyItems (Sint32 stockRow, Sint16 *output)Copies the shop's ordinary stock, up to 24 items, to output with a 0 after, and returns how many.
Sint32mnShopStockGetType (Sint32 stockRow)Returns the shop's type from the last column of its stock row (enum SHOP_TYPE).
Sint32mnSanctumServicePrice (Sint32 unitId, Sint32 serviceKind)The sanctum (shop_sanctum.c).
Sint32mnSanctumNeedsService (Sint32 unitId, Sint32 serviceKind)Returns 1 when a party member needs the service: down for Revive, poisoned for Cure Poison, haunted for Repel Evil, cursed for Remove Curse.
Sint32mnSanctumCountMembersInNeed (void)Counts party members who need the service in shop->action.
Sint32mnSanctumGetServiceMessage (Sint32 msgId)Returns the current service's line that stands where msgId stands among the revive service's lines.
voidmnSanctumShowKeeperMessage (Sint32 msgId)Shows the healer's line and waits until it is typed out.
voidmnSanctumShowKeeperMessageHidingCursor (Sint32 msgId)As mnSanctumShowKeeperMessage, hiding the hand cursor while the line shows.
Sint32mnSanctumRunPartyService (void)Lets the player pick a party member for the service, asks for the donation, then applies it with its burst; offers another while any still need it.
voidmnSanctumApplyService (Sint32 unitId, Sint32 serviceKind)Applies a Sanctum service to a party member: full HP for a revive, poison or the haunting cleared, or every cursed item taken off.
voidmnSanctumHighlightMembers (struct WINDOW *window, Sint32 selected)Shows the chosen party member running in place, and those who do not need the service drawn smaller.
voidmnSanctumDrawFee (struct WINDOW *target, Sint32 unitId)Draws the party member's fee for the current service, or that they need no treatment.
voidmnSanctumUpdateBurstSparkle (FIELD_PARTICLE *effect)Steps one sparkle of the Sanctum's burst, which flies in from a ring around the icon, again and again until the burst ends.
voidmnSanctumUpdateBurst (void)Steps the burst's sparkles, and while the tune plays flickers the party member's icon through random colours, a new one each tick.
voidmnSanctumRunMemberIconBurst (Sint32 member)Plays the service's burst on a party member's icon: its tune, the field greyed, and SANCTUM_BURST_SPARKLES sparkles flying in at the icon as it flickers through colours, then the recovery sound.
Sint32mnInnRoomPrice (Sint32 innId)The inn (shop_inn.c).
Sint32mnItemPickerSelectItem (Sint32 unitId)The item picker (shop_item_picker.c).
voidmnItemPickerDrawItem (struct WINDOW *window, Sint32 unitId, Sint32 slot)Draws the slot's item name and, below it, why it cannot be dropped or what the whole stack would sell for.

Variables

NameDescription
extern const Uint8MenuCursorHandTiles []The shop's 16-by-16 sprites (graphics/ui/menu_sprites): the hand cursor, the gem and the list arrows.
extern const Uint8ShopGemTiles []
extern const Uint8ShopSmallDownArrowTiles []
extern const Uint8ShopSmallUpArrowTiles []
extern const Uint8ShopUpArrowTiles []
extern const Uint8ShopDownArrowTiles []
extern const Uint8ShopPriceTiles []The eight blank tiles of a price, which the shop writes its digits over, and of the quantity bar, which it fills in colours.
extern const Uint8ShopQuantityTiles []

Description

The counters of a town, shops, sanctums and inns: SHOP_STATE, the state they share, the shop screen's tiles, and every function of the shop object.

Macros in detail

SHOP_CURSOR_ENTER_TICKS

#define SHOP_CURSOR_ENTER_TICKS 12

The ticks the hand cursor takes to glide into a newly opened list.

Referenced by mnItemPickerRun(), mnItemPickerSelectItem(), mnShopChooseMember(), mnShopInitState(), mnShopSelectBuy(), mnShopSelectBuyCount(), mnShopSelectRepair(), mnShopSelectSell() and mnShopSelectSellCount().

Definition at line 18 of file shop.h.

SANCTUM_PARTICLE_COUNT

#define SANCTUM_PARTICLE_COUNT 24

The particles a sanctum service's sparkles use (SHOP_STATE.effects), and how many of them fly in at the party member's icon in its burst.

Referenced by mnSanctumRunMemberIconBurst() and mnSanctumUpdateBurst().

Definition at line 22 of file shop.h.

SANCTUM_BURST_SPARKLES

#define SANCTUM_BURST_SPARKLES 18

Referenced by mnSanctumRunMemberIconBurst().

Definition at line 23 of file shop.h.

Enumerations in detail

QUANTITY_BAR_COL

enum QUANTITY_BAR_COL

The quantity bar's colours (mnQuantityBarFill), painted over each other longest first: past what can be chosen, what can be chosen, the number chosen and what is held already. Each segment is a black pixel and a pixel of its colour, in the window sprites' palette.

EnumeratorValueDescription
QUANTITY_BAR_CHOOSABLE0clear, the window showing through
QUANTITY_BAR_HELD2red
QUANTITY_BAR_CHOSEN10orange
QUANTITY_BAR_OUT_OF_REACH14grey

Definition at line 179 of file shop.h.

SHOP_PRICE_KIND

enum SHOP_PRICE_KIND

What mnShopDrawItemPrice says below an item whose price is 0.

EnumeratorValueDescription
SHOP_PRICE_KIND_BUY0buying: the price, even when it is 0
SHOP_PRICE_KIND_SELL1selling: the shop does not buy it
SHOP_PRICE_KIND_REPAIR2repairing: it is not broken

Definition at line 197 of file shop.h.

Variables in detail

extern const Uint8 MenuCursorHandTiles[]

The shop's 16-by-16 sprites (graphics/ui/menu_sprites): the hand cursor, the gem and the list arrows.

Referenced by mnShopInitState().

Definition at line 123 of file shop.h.

ShopGemTiles

extern const Uint8 ShopGemTiles[]

Referenced by mnShopInitState().

Definition at line 124 of file shop.h.

ShopSmallDownArrowTiles

extern const Uint8 ShopSmallDownArrowTiles[]

Referenced by mnShopInitState().

Definition at line 125 of file shop.h.

ShopSmallUpArrowTiles

extern const Uint8 ShopSmallUpArrowTiles[]

Referenced by mnShopInitState().

Definition at line 126 of file shop.h.

ShopUpArrowTiles

extern const Uint8 ShopUpArrowTiles[]

Referenced by mnShopInitState().

Definition at line 127 of file shop.h.

ShopDownArrowTiles

extern const Uint8 ShopDownArrowTiles[]

Referenced by mnShopInitState().

Definition at line 128 of file shop.h.

ShopPriceTiles

extern const Uint8 ShopPriceTiles[]

The eight blank tiles of a price, which the shop writes its digits over, and of the quantity bar, which it fills in colours.

Referenced by mnShopCreatePriceSprite().

Definition at line 132 of file shop.h.

ShopQuantityTiles

extern const Uint8 ShopQuantityTiles[]

Referenced by mnShopSelectQuantity().

Definition at line 133 of file shop.h.