include/shop/shop.h
What the shop object defines for the code outside it.
Included by psynergy_test.c, shop_test.c, menu_item.c, alhafra.c, alhafra_rooms.c, apojii_islands.c, champa_rooms.c, champa_sanctum.c, clear.c, contigo.c, daila.c, daila_rooms.c, garoh_rooms.c, islets.c, izumo_rooms.c, jupiter_lighthouse_terraces.c, kibombo.c, lobby.c, madra.c, naribwe.c, naribwe_rooms.c, prox.c, shaman_village.c, yallam_rooms.c and shop_internal.h.
Macros
| Name | Description | |
|---|---|---|
#define | SHOP_COIN_WINDOW_WIDTH JAPANESE_OR(11, 12) | Width in tiles of the coins window that shops, inns and sanctums open beside the keeper (mnShopDrawMoney draws it); one tile narrower in Japanese. |
#define | QUANTITY_BAR_OUT_OF_REACH 14 | The colours of a quantity bar's segments. |
#define | QUANTITY_BAR_OPEN 0 | |
#define | QUANTITY_BAR_CHOSEN 10 | |
#define | QUANTITY_BAR_HELD 2 | |
#define | SHOP_MESSAGES (MsgArmorShopWelcome - MsgWeaponShopWelcome) | The lines of one shop, as many as the weapon shop's, and of a sanctum, as the debug rooms' message browsers count them (text/msg_ids.h). |
#define | SANCTUM_MESSAGES (MsgRightWhenI - MsgWelcomeWearyWanderers) | |
#define | SHOP_CURSOR_ENTER_TICKS 12 | The ticks the hand cursor takes to glide into a newly opened list. |
Enumerations
| Name | Description | |
|---|---|---|
enum | anonymous enum { SHOP_DAILA_WEAPONS, SHOP_DAILA_ARMOR, SHOP_DAILA_ITEMS, SHOP … } | Rows of the shop stock table, as a script passes them to mnShopRun: Daila's weapon, armor and item shops, and Izumo's general store, which the debug rooms' shopkeepers also open. |
enum | anonymous enum { INN_ID_DAILA } | Daila's inn, as mnInnCheckIn numbers the inns, which the debug rooms' innkeepers also open. |
Functions
| Name | Description | |
|---|---|---|
void | mnShopDrawMoney (void) | Draws the party's coins in the coins window, in the edition's layout. |
void | mnShopInitState (void) | Allocates and clears the shop's state in the menu's heap slot, lists the party, loads the six cursor icons into the VRAM cache, starts the cursor's event and readies the item icon grid. |
void | mnShopReleaseState (void) | Releases the item icon grid, stops the cursor event, frees the six cursor icons and the shop's state. |
Sint32 | mnShopSelectBuy (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 | mnShopDrawStock (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. |
void | mnShopDrawItemPrice (struct WINDOW *window, Sint32 itemId, Sint32 price, Sint32 priceKind) | Draws the item's name and below it its price. |
void | mnShopDrawMessage (struct WINDOW *window, Sint32 msg) | Shows msg, an item's description, in the help window; a NULL window is ignored. |
void | mnShopDrawParty (struct WINDOW *window, Sint32 selected, Sint32 itemId) | Shows the chosen party member running in place and the others standing, four a page with its arrows, and draws at four fifths of their size the party members who cannot equip itemId. |
void | mnShopDrawEquipComparison (struct WINDOW *window, Sint32 unitId, Sint32 itemId) | Shows how Attack, Defense and Agility would change if the party 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 | mnShopDrawCarriedItem (struct WINDOW *window, Sint32 unitId, Sint32 itemId) | Shows how many of the item the party member already carries and the party member's inventory icons. |
Sint32 | mnShopSelectBuyCount (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 stack of 30 less what the party member carries. |
Sint32 | mnShopSelectQuantity (Sint32 minimum, Sint32 maximum, Sint32 price) | Lets the player pick a quantity with left and right in a small window that shows it and its price in coins: a bar of 30 segments, the ones already carried in one colour and the ones chosen in another. |
void | mnShopBuyDone (Sint32 unitId, Sint32 itemId, Sint32 quantity) | Gives the party member each item bought, one at a time, taking its price and counting it toward the next Game Ticket; then offers to equip it and to sell what it replaced. |
Bool | mnShopConfirmEquip (Sint32 unitId, Sint32 slot) | Offers to equip the item just bought, and warns of a curse. |
Bool | mnShopSellOld (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. |
void | mnShopGiveGameTicket (struct WINDOW *window, struct WINDOW *itemWindow) | Gives a Game Ticket once the party's spending in shops reaches the next ticket's cost, and lets the player choose who takes it. |
Sint32 | mnShopChooseMember (void) | Lets the player choose whose items to sell, repair or forge, by shop->action, until B or, at the forge, an item is taken. |
Sint32 | mnShopSelectSell (Sint32 unitId) | Lets the player choose items to sell, repair or forge from the party member's grid, one at a time, with each one's price and description, until B or the inventory is empty. |
void | mnShopDrawMemberItems (struct WINDOW *window, Sint32 unitId) | Draws the party member's items as icons in rows of five, or a line saying it has none. |
Sint32 | mnShopSelectSellCount (Sint32 unitId, Sint32 slot) | Asks how many of a stack to sell, when the party member holds more than one, and returns the count, -1 when cancelled; 1 otherwise. |
void | mnShopSellItem (Sint32 unitId, Sint32 slot, Sint32 count) | Sells count of the item in slot once the player accepts the shopkeeper's offer, worded for a broken item, for several or for a rare one. |
Sint32 | mnShopRepairPrice (Sint32 inventoryEntry) | Returns what a repair costs: a quarter of the price for a broken item, nothing for one that is not broken. |
Sint32 | mnShopRunRepairMemberChoice (void) | Runs the repair counter's party member choice. |
Sint32 | mnShopSelectRepair (Sint32 unitId) | Lets the player choose items to repair on the sell counter's grid, which serves repairs too by shop->action. |
void | mnShopRepairItem (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 for the smith's three hammer blows, gives it back mended, charges the price and offers to equip it. |
void | mnShopShowKeeperMessage (Sint32 msgId) | Shows the shopkeeper's line msgId, given as the weapon shop's (SHOP_KEEPER_LINE), and waits until it is typed out. |
struct 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). |
Sint32 | mnShopStockGetRowCount (void) | Returns how many stock rows there are; mnShopRun refuses a row past them. |
Sint32 | mnShopStockGetType (Sint32 stockRow) | Returns the shop's type from the last column of its stock row (enum SHOP_TYPE). |
void | mnShopStockAddArtifacts (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. |
Sint32 | mnShopStockCopyItems (Sint32 stockRow, Sint16 *output) | Copies the shop's ordinary stock, up to 24 items, to output with a 0 after, and returns how many. |
Sint32 | mnInnRoomPrice (Sint32 innId) | Returns the night's price: the inn's price per guest times the party members still standing. |
Sint32 | mnForgeChooseMember (void) | Runs the forge's party member choice, the sell counter's. |
Sint32 | mnForgeSelectItem (Sint32 unitId) | Lets the player choose the party member's item to forge, on the sell counter's grid. |
Sint32 | mnForgeGetItemCondition (Sint32 itemId) | Returns what the forge makes of an item, counted from MsgItemCondition: 0 for an item it has no recipe for, then FORGE_CONDITION plus one. |
Sint32 | mnForgeOfferItem (Sint32 unitId, Sint32 slot) | The forge's offer for one inventory item: refuses an item it has no recipe for, otherwise asks (a rusted weapon takes its own lines), and on yes takes the item, redraws the grid and stores the rolled result. |
Sint32 | mnSanctumRunPartyService (void) | Runs one service: the player chooses the party member, sees the donation, confirms, pays and watches the burst. |
void | mnSanctumHighlightMembers (struct WINDOW *window, Sint32 selected) | Shows the chosen party member running in place and the others standing, four a page with its arrows, and draws at seven tenths of their size the party members who do not need the service. |
void | mnSanctumDrawFee (struct WINDOW *window, Sint32 unitId) | Shows the chosen party member's donation for the service, or that none is needed. |
void | mnSanctumApplyService (Sint32 unitId, Sint32 serviceKind) | Gives the party member the service: full HP for a revive, the poison or the haunting lifted, or every cursed item it wears taken off. |
void | mnSanctumRunMemberIconBurst (Sint32 member) | Plays the service's burst on a party member's icon: its tune, the colours tinted, and SANCTUM_BURST_SPARKLES sparkles flying in around the icon as it changes colour. |
Sint32 | mnItemPickerRun (Sint32 *selectedUnit, Sint32 *selectedSlot, Sint32 itemMode) | Lets the player choose a party member, then one of its items, four party members a page, returning the unit and slot through the pointers (both -1 when cancelled). |
Sint32 | mnItemPickerSelectItem (Sint32 unitId) | Lets the player choose one of the party member's items, refusing with a message one that cannot be dropped or removed (gmInventoryCheckDiscard or gmInventoryCheckUnequip, by the picker's mode). |
void | mnItemPickerDrawItem (struct WINDOW *window, Sint32 unitId, Sint32 slot) | Draws the slot's item name and, below it, why it cannot be dropped or removed, or, for an item to drop, what the whole stack would sell for. |
void | mnItemIconGridInit (void) | Empties the grid, hides it and starts its drawing event. |
void | mnItemIconGridRelease (void) | Stops the drawing event and frees the icons' VRAM cache entries. |
void | mnItemIconGridDraw (void) | Queues each loaded icon's sprite while the grid is visible. |
void | mnItemIconGridSetPos (Sint32 index, Sint32 x, Sint32 y) | Places icon index at (x, y) screen pixels. |
void | mnItemIconGridSetVisible (Sint32 active) | Shows the grid (1) or hides it (0). |
void | mnItemIconGridLoadItems (Uint16 *items, Sint32 count, Sint32 mode) | Releases the item icons' VRAM entries, then loads the icons of up to count items with the ICON_ layers in mode (an empty item keeps its old entry) and gives each its sprite attributes and tile. |
void | mnItemIconGridShowInventory (struct WINDOW *window, Sint32 x, Sint32 y, Sint32 unitId) | Shows a party member's INVENTORY_SLOTS inventory icons at (x, y) pixels inside window, SHOP_INVENTORY_COLUMNS to a row, 16 pixels apart. |
Sint32 | mnSanctumNeedsService (Sint32 unitId, Sint32 serviceKind) | Returns 1 when a party member needs the service: down for a revive, poisoned for a cure, haunted for an exorcism, cursed for removing a curse. |
Sint32 | mnShopOpenDebugShop (void) | The shop module's functions in the order of its stub table. |
Sint32 | mnShopRun (Sint32 stockRow, Sint32 keeperId) | The shops, inns, sanctums and forges as scripts open them. |
Sint32 | mnSanctumRun (Sint32 actorId) | Runs a sanctum: the keeper's welcome, the service menu until B, and the farewell; actorId is the keeper, whose portrait the lines show. |
Sint32 | mnInnCheckIn (Sint32 innId, Sint32 actorId) | Runs an inn's counter: the innkeeper names the price, and on Yes the party sleeps. |
Sint32 | mnForgeRun (Sint32 actorId) | Runs the forge: the smith's line, then a party member's materials to forge, until the player leaves. |
Sint32 | mnInnQuoteRoomPrice (Sint32 innId) | Returns the night's price at inn innId with the shop's state opened for it, for a script to quote before checking in. |
void | mnCursorAdvance (struct MENU_CURSOR *cursor) | Moves the cursor a tick along its straight line toward its target. |
void | mnCursorMoveTowardTarget (struct MENU_CURSOR *cursor) | Moves each cursor axis one quarter of the remaining distance, with a minimum one-pixel step. |
void | mnCursorSet (struct MENU_CURSOR *cursor, Sint32 targetX, Sint32 targetY, Sint8 ticks) | Starts a glide of the cursor from where it is to (targetX, targetY) over ticks ticks, for mnCursorAdvance to run. |
void | mnCursorSetPosImmediate (struct 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. |
void | mnQuantityBarFill (Sint32 segments, Sint32 color, Uint8 *tileBuf) | Paints the first segments segments of the quantity bar in color (a QUANTITY_BAR_ colour), over what was painted before. |
void | mnShopSaveAndTintFieldPalette (Sint32 tint) | Saves the field's colours and fades them to tint (a PALETTE_TINT_ mode) over SHOP_TINT_TICKS ticks: the grey of the sanctum's healing, and the element's colour as a Djinni joins the party. |
void | mnShopRestoreFieldPalette (void) | Fades back to the colours mnShopSaveAndTintFieldPalette saved, over SHOP_TINT_TICKS ticks. |
Sint32 | mnItemPickerRunToDrop (Sint32 *selectedUnit, Sint32 *selectedSlot) | Runs the item picker for an item to drop, showing each item's sale price. |
Sint32 | mnItemPickerRunToShow (Sint32 *selectedUnit, Sint32 *selectedSlot) | Runs the item picker for an item to show, refusing one that cannot be unequipped: Naribwe's fortune teller reads the party's fortune from it. |
void | mnSoundWaitForJingle (void) | Waits until the jingle playing has ended and the music it interrupted is back: the inn's night, the sanctum's healing and scripts that wait for a jingle. |
void | mnInnPlaySleep (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. |
void | mnVRAMBlockLoadResource (Sint32 entryId, Sint32 size, Sint32 resourceId) | Decompresses resource resourceId and loads its first size bytes into VRAM cache entry entryId; does nothing for an entry past the cache. |
Bool | mnForgePartyHasMaterial (void) | Returns 1 when anyone in the party carries anything the forge takes. |
void | mnForgeSetItem (Sint32 itemId) | Records the item the forge is making, for the smith to hand over later. |
Sint32 | mnForgeGetItem (void) | Returns the item the forge is making. |
Variables
| Name | Description | |
|---|---|---|
extern Uint8 | ShopGlyphBytes [] | The price digits 0 to 9, 32 bytes each (digits.4bpp), copied into a price sprite's tiles (mnShopDrawPriceDigit). |
Description
What the shop object defines for the code outside it.
Macros in detail
SHOP_COIN_WINDOW_WIDTH
#define SHOP_COIN_WINDOW_WIDTH JAPANESE_OR(11, 12)
Width in tiles of the coins window that shops, inns and sanctums open beside
the keeper (mnShopDrawMoney draws it); one tile narrower in Japanese.
Referenced by mnInnCheckIn(), mnSanctumRun(), mnShopChooseMember() and mnShopSelectBuy().
Definition at line 15 of file shop.h.
QUANTITY_BAR_OUT_OF_REACH
#define QUANTITY_BAR_OUT_OF_REACH 14
The colours of a quantity bar's segments. mnQuantityBarFill paints the first
so many segments in one, and the bar is built by painting shorter runs over
longer: the whole bar out of reach, then what could be chosen, then what is
chosen, then what the party member already carries.
Referenced by mnItemMenuSelectGiveQuantity() and mnShopSelectQuantity().
Definition at line 22 of file shop.h.
QUANTITY_BAR_OPEN
#define QUANTITY_BAR_OPEN 0
Referenced by mnItemMenuSelectGiveQuantity() and mnShopSelectQuantity().
Definition at line 23 of file shop.h.
QUANTITY_BAR_CHOSEN
#define QUANTITY_BAR_CHOSEN 10
Referenced by mnItemMenuSelectGiveQuantity() and mnShopSelectQuantity().
Definition at line 24 of file shop.h.
QUANTITY_BAR_HELD
#define QUANTITY_BAR_HELD 2
Referenced by mnItemMenuSelectGiveQuantity() and mnShopSelectQuantity().
Definition at line 25 of file shop.h.
SHOP_MESSAGES
#define SHOP_MESSAGES (MsgArmorShopWelcome - MsgWeaponShopWelcome)
The lines of one shop, as many as the weapon shop's, and of a sanctum, as the
debug rooms' message browsers count them (text/msg_ids.h).
Referenced by dbPsynergyTestBrowseArmorShopMessages(), dbPsynergyTestBrowseItemShopMessages(), dbPsynergyTestBrowseWeaponShopMessages(), dbShopTestBrowseArmorShopMessages(), dbShopTestBrowseItemShopMessages() and dbShopTestBrowseWeaponShopMessages().
Definition at line 41 of file shop.h.
SANCTUM_MESSAGES
#define SANCTUM_MESSAGES (MsgRightWhenI - MsgWelcomeWearyWanderers)
Referenced by dbPsynergyTestBrowseSanctumMessages() and dbShopTestBrowseSanctumMessages().
Definition at line 42 of file shop.h.
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(), mnShopSelectSell() and mnShopSelectSellCount().
Definition at line 121 of file shop.h.
Enumerations in detail
anonymous enum
enum { SHOP_DAILA_WEAPONS, SHOP_DAILA_ARMOR, SHOP_DAILA_ITEMS, SHOP_IZUMO }
Rows of the shop stock table, as a script passes them to mnShopRun: Daila's
weapon, armor and item shops, and Izumo's general store, which the debug
rooms' shopkeepers also open. A town no other room opens a shop of names its
rows itself.
| Enumerator | Value | Description |
|---|---|---|
SHOP_DAILA_WEAPONS | 1 | |
SHOP_DAILA_ARMOR | 2 | |
SHOP_DAILA_ITEMS | 3 | |
SHOP_IZUMO | 24 |
Definition at line 31 of file shop.h.
anonymous enum
enum { INN_ID_DAILA }
Daila's inn, as mnInnCheckIn numbers the inns, which the debug rooms'
innkeepers also open. A town no other room opens an inn of names its inn
itself.
| Enumerator | Value | Description |
|---|---|---|
INN_ID_DAILA | 0 |
Definition at line 47 of file shop.h.
Variables in detail
ShopGlyphBytes
extern Uint8 ShopGlyphBytes[]
The price digits 0 to 9, 32 bytes each (digits.4bpp), copied into a price
sprite's tiles (mnShopDrawPriceDigit).
Referenced by mnShopDrawPriceDigit().
Definition at line 125 of file shop.h.