Skip to Content
The Alchemy Project

src/shop/shop_buy.c

Buying: the stock list, the money and party windows, quantities and prices. More…

Included by shop.c.

Macros

NameDescription
#defineSHOP_MIN (a, b) ((a) > (b) ? (b) : (a))The smaller of a and b.
#defineSHOP_QUANTITY_NUMBER_X BY_LANGUAGE(72, 72, 64, 72, 64, 72)The quantity window's count and the coins word after its total, in pixels: German and French move both 8 left, Spanish the coins word 8 right.
#defineSHOP_QUANTITY_COIN_LABEL_X BY_LANGUAGE(136, 136, 128, 144, 128, 136)

Functions

NameDescription
Sint32mnShopSelectBuy (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.
voidmnShopDrawStock (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 (WINDOW *window, Sint32 itemId, Sint32 price, Sint32 priceKind)Draws the item's name and below it its price.
voidmnShopDrawMessage (WINDOW *window, Sint32 msg)Shows msg, an item's description, in the help window; a NULL window is ignored.
voidmnShopDrawParty (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 (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 (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 carried, Sint32 limit, 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.

Description

Buying: the stock list, the money and party windows, quantities and prices. Part of shop.c.

Macros in detail

SHOP_MIN

#define SHOP_MIN(a, b) ((a) > (b) ? (b) : (a))

The smaller of a and b. It reads b again when that is the smaller, so a call passed as b is made a second time.

Referenced by mnShopSelectBuyCount().

Definition at line 609 of file shop_buy.c.

SHOP_QUANTITY_NUMBER_X

#define SHOP_QUANTITY_NUMBER_X BY_LANGUAGE(72, 72, 64, 72, 64, 72)

The quantity window's count and the coins word after its total, in pixels: German and French move both 8 left, Spanish the coins word 8 right.

Referenced by mnShopSelectQuantity().

Definition at line 667 of file shop_buy.c.

SHOP_QUANTITY_COIN_LABEL_X

#define SHOP_QUANTITY_COIN_LABEL_X BY_LANGUAGE(136, 136, 128, 144, 128, 136)

Referenced by mnShopSelectQuantity().

Definition at line 668 of file shop_buy.c.

Functions in detail

mnShopSelectBuy

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. Checks room in the pack and coins first, and warns when the party member cannot equip it. An artifact bought takes its stock counter down, and the list is rebuilt. Repeats until B.

References gmInventoryAddItemStub(), gmInventoryCountStub(), gmInventoryRemoveStub(), gmItemAdjustRareItemStockStub(), gmItemGetDefinitionStub(), gmItemGetEquipmentGroupStub(), gmItemIsCompatibleWithUnitStub(), MainRoutineStateWork, mnCreatePartyFiguresStub(), mnCursorPlace(), mnMessageArgumentPushStub(), mnReleasePartyFiguresStub(), mnShopAskYesNo(), mnShopBuyDone(), mnShopDrawCarriedItem(), mnShopDrawEquipComparison(), mnShopDrawItemPrice(), mnShopDrawMessage(), mnShopDrawMoney(), mnShopDrawParty(), mnShopDrawStock(), mnShopGiveGameTicket(), mnShopListAvailableArtifacts(), mnShopSelectBuyCount(), mnShopShowKeeperMessage(), mnShopShowKeeperMessageHidingCursor(), mnWindowCloseStub(), mnWindowCreateStub(), mnWindowSpriteRedrawSavedRectStub(), PerPush, PerRepeat, Sint32, sySoundPlayStub() and sySynch().

Referenced by mnShopRun().

Definition at line 11 of file shop_buy.c.

mnShopDrawStock

void mnShopDrawStock(WINDOW *window, Sint32 selected)

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

References gmItemGetDefinitionStub(), mnShopCreatePriceSprite(), mnWindowSpriteCreateLoadedStub(), mnWindowSpriteCreateStub(), mnWindowSpritePrepareForRedrawStub() and Sint32.

Referenced by mnShopSelectBuy().

Definition at line 278 of file shop_buy.c.

mnShopDrawMoney

void mnShopDrawMoney(void)

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

References MainRoutineStateWork, mnTextDrawMessageAsTilesStub() and mnTextDrawNumberInWindowStub().

Referenced by mnInnCheckIn(), mnSanctumRun(), mnSanctumRunPartyService(), mnShopBuyDone(), mnShopChooseMember(), mnShopRepairItem(), mnShopSelectBuy() and mnShopSellItem().

Definition at line 342 of file shop_buy.c.

mnShopDrawItemPrice

void mnShopDrawItemPrice(WINDOW *window, Sint32 itemId, Sint32 price, Sint32 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 (SHOP_PRICE_KIND_SELL) or that it is not broken (SHOP_PRICE_KIND_REPAIR).

References mnTextDrawMessageAsTilesStub(), mnTextDrawNumberInWindowStub(), mnWindowSpriteRedrawSavedRectStub() and Sint32.

Referenced by mnShopSelectBuy(), mnShopSelectRepair() and mnShopSelectSell().

Definition at line 369 of file shop_buy.c.

mnShopDrawMessage

void mnShopDrawMessage(WINDOW *window, Sint32 msg)

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

References mnWindowSpriteRedrawSavedRectStub() and Sint32.

Referenced by mnItemPickerSelectItem(), mnShopSelectBuy(), mnShopSelectRepair() and mnShopSelectSell().

Definition at line 407 of file shop_buy.c.

mnShopDrawParty

void mnShopDrawParty(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.

References fdSpriteStartAnimationStub(), gmItemIsCompatibleWithUnitStub() and Sint32.

Referenced by mnItemPickerRun(), mnShopChooseMember(), mnShopGiveGameTicket() and mnShopSelectBuy().

Definition at line 424 of file shop_buy.c.

mnShopDrawEquipComparison

void mnShopDrawEquipComparison(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. The item is tried on in that item's slot and the slot put back.

References gmInventoryFindEquippedStub(), gmItemCanUnitEquipStub(), gmItemGetDefinitionStub(), gmUnitCalculateStub(), gmUnitGetStub(), mnTextDrawMessageAsTilesStub(), mnTextDrawMessageStub(), mnTextDrawNumberInWindowStub(), mnWindowDrawDividerLineStub(), mnWindowSpriteCreateStub(), mnWindowSpritePrepareForRedrawStub() and Sint32.

Referenced by mnShopSelectBuy().

Definition at line 452 of file shop_buy.c.

mnShopDrawCarriedItem

void mnShopDrawCarriedItem(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.

References gmInventoryFindStub(), gmUnitGetStub(), mnMessageArgumentPushStub(), mnTextDrawMessageAsTilesStub(), mnWindowSpriteCreateLoadedStub(), mnWindowSpritePrepareForRedrawStub() and Sint32.

Referenced by mnShopGiveGameTicket() and mnShopSelectBuy().

Definition at line 547 of file shop_buy.c.

mnShopSelectBuyCount

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 full stack less what the party member carries. Returns the count (1 for other items), or -1 when cancelled.

References gmInventoryFindStub(), gmItemAdjustRareItemStockStub(), gmItemGetDefinitionStub(), gmUnitGetStub(), MainRoutineStateWork, mnCursorPlace(), mnShopSelectQuantity(), mnShopShowKeeperMessage() and Sint32.

Referenced by mnShopSelectBuy().

Definition at line 614 of file shop_buy.c.

mnShopSelectQuantity

Sint32 mnShopSelectQuantity(Sint32 carried, Sint32 limit, 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. Returns the number, or -1 for B.

References mnQuantityBarFill(), mnTextDrawMessageAsTilesStub(), mnTextDrawNumberInWindowStub(), mnWindowCloseStub(), mnWindowCreateStub(), mnWindowSpriteCreateStub(), PerPush, PerRepeat, ShopQuantityTiles, Sint32, syDMAXCopy(), syHeapSlotAllocateEWRAM(), syHeapSlotRelease(), sySoundPlayStub(), sySynch(), syVRAMCacheFindFreeEntry() and syVRAMCacheLoad().

Referenced by mnShopSelectBuyCount() and mnShopSelectSellCount().

Definition at line 673 of file shop_buy.c.

mnShopBuyDone

void mnShopBuyDone(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.

References gmInventoryAddItemStub(), gmInventoryFindEquippedStub(), gmItemGetDefinitionStub(), gmPartyAdjustCoinsStub(), gmPartyAdjustShopCreditStub(), mnShopConfirmEquip(), mnShopDrawMoney(), mnShopSellOld(), mnShopShowKeeperMessageHidingCursor(), Sint32 and sySoundPlayStub().

Referenced by mnShopSelectBuy().

Definition at line 784 of file shop_buy.c.

mnShopConfirmEquip

Bool mnShopConfirmEquip(Sint32 unitId, Sint32 slot)

Offers to equip the item just bought, and warns of a curse. Returns TRUE when it was equipped.

References gmInventoryEquipStub(), gmInventoryFindEquippedStub(), gmItemCanUnitEquipStub(), gmItemGetDefinitionStub(), gmUnitGetStub(), mnMessageAllTypedStub(), mnMessageArgumentPushStub(), mnMessageCloseFinishedWindowsStub(), mnMessageOpenWindowStub(), mnShopAskYesNo(), mnShopDrawMemberItems(), mnShopShowKeeperMessage(), mnShopShowKeeperMessageHidingCursor(), Sint32, sySoundPlayStub() and sySynch().

Referenced by mnShopBuyDone() and mnShopRepairItem().

Definition at line 814 of file shop_buy.c.

mnShopSellOld

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. Returns TRUE when it offered.

References gmItemGetDefinitionStub(), gmUnitGetStub(), mnShopSellItem() and Sint32.

Referenced by mnShopBuyDone() and mnShopRepairItem().

Definition at line 869 of file shop_buy.c.

mnShopSalePrice

Sint32 mnShopSalePrice(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.

References gmItemGetDefinitionStub() and Sint32.

Referenced by mnItemPickerDrawItem(), mnShopSelectSell(), mnShopSelectSellCount() and mnShopSellItem().

Definition at line 895 of file shop_buy.c.