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
#defineHELD_WINDOW_X 10
#defineHELD_WINDOW_WIDTH 20
#defineBUY_PRICE_WINDOW_WIDTH 16
#defineSHOP_ITEM_NOTE_X JAPANESE_OR(8, 0)The price line reads "Price", the price, then "Coins".
#defineSHOP_PRICE_NUMBER_X FRENCH_OR(24, 32)
#defineSHOP_PRICE_LABEL_X BY_LANGUAGE(72, 72, 72, 80, 72, 80)
#defineQUANTITY_WINDOW_X 7
#defineQUANTITY_WINDOW_WIDTH 23
#defineQUANTITY_COUNT_X 72
#defineQUANTITY_PRICE_X 88
#defineQUANTITY_COINS_X 136
#defineQUANTITY_PIECE_X 80

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, four a page with its arrows, 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: 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.
voidmnShopDrawCarriedItem (WINDOW *window, Sint32 unitId, Sint32 itemId)Shows how many of the item the party member already carries and the party member's inventory 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 stack of 30 less what the party member carries.
Sint32mnShopSelectQuantity (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.
voidmnShopBuyDone (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.
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

HELD_WINDOW_X

#define HELD_WINDOW_X 10

#define HELD_WINDOW_X 14

#define HELD_WINDOW_X 13

Referenced by mnShopSelectBuy().

Definition at lines 10, 13 and 16 of file shop_buy.c.

HELD_WINDOW_WIDTH

#define HELD_WINDOW_WIDTH 20

#define HELD_WINDOW_WIDTH 13

#define HELD_WINDOW_WIDTH 17

Referenced by mnShopSelectBuy().

Definition at lines 11, 14 and 17 of file shop_buy.c.

BUY_PRICE_WINDOW_WIDTH

#define BUY_PRICE_WINDOW_WIDTH 16

#define BUY_PRICE_WINDOW_WIDTH 14

#define BUY_PRICE_WINDOW_WIDTH 15

Referenced by mnShopSelectBuy().

Definition at lines 21, 23 and 25 of file shop_buy.c.

SHOP_ITEM_NOTE_X

#define SHOP_ITEM_NOTE_X JAPANESE_OR(8, 0)

The price line reads "Price", the price, then "Coins". Japanese indents the line and its notes by 8 pixels, French draws the price 8 pixels nearer its label, Spanish and Italian the coins label 8 pixels further right.

Referenced by mnShopDrawItemPrice().

Definition at line 389 of file shop_buy.c.

SHOP_PRICE_NUMBER_X

#define SHOP_PRICE_NUMBER_X FRENCH_OR(24, 32)

Referenced by mnShopDrawItemPrice().

Definition at line 390 of file shop_buy.c.

SHOP_PRICE_LABEL_X

#define SHOP_PRICE_LABEL_X BY_LANGUAGE(72, 72, 72, 80, 72, 80)

Referenced by mnShopDrawItemPrice().

Definition at line 391 of file shop_buy.c.

QUANTITY_WINDOW_X

#define QUANTITY_WINDOW_X 7

#define QUANTITY_WINDOW_X 5

Referenced by mnShopSelectQuantity().

Definition at lines 702, 708, 715, 721 and 727 of file shop_buy.c.

QUANTITY_WINDOW_WIDTH

#define QUANTITY_WINDOW_WIDTH 23

#define QUANTITY_WINDOW_WIDTH 25

Referenced by mnShopSelectQuantity().

Definition at lines 703, 709, 716, 722 and 728 of file shop_buy.c.

QUANTITY_COUNT_X

#define QUANTITY_COUNT_X 72

#define QUANTITY_COUNT_X 64

Referenced by mnShopSelectQuantity().

Definition at lines 704, 710, 717, 723 and 729 of file shop_buy.c.

QUANTITY_PRICE_X

#define QUANTITY_PRICE_X 88

#define QUANTITY_PRICE_X 96

#define QUANTITY_PRICE_X 80

#define QUANTITY_PRICE_X 104

Referenced by mnShopSelectQuantity().

Definition at lines 705, 712, 718, 724 and 730 of file shop_buy.c.

QUANTITY_COINS_X

#define QUANTITY_COINS_X 136

#define QUANTITY_COINS_X 144

#define QUANTITY_COINS_X 128

#define QUANTITY_COINS_X 160

Referenced by mnShopSelectQuantity().

Definition at lines 706, 713, 719, 725 and 731 of file shop_buy.c.

QUANTITY_PIECE_X

#define QUANTITY_PIECE_X 80

Referenced by mnShopSelectQuantity().

Definition at line 711 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 bag 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. Holding Select shows the item's details. Repeats until B.

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

Referenced by mnShopRun().

Definition at line 33 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 298 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(), mnTextDrawNumberInWindowStub(), mnWindowSpritePrepareForRedrawStub() and Sint32.

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

Definition at line 360 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); at the forge (SHOP_PRICE_KIND_FORGE) price is the item's condition, drawn as its word.

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

Referenced by mnShopSelectBuy() and mnShopSelectSell().

Definition at line 397 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. The Japanese release clears the window and waits a tick; the others redraw the window's saved rectangle.

References mnTextDrawMessageAsTilesStub(), mnWindowSpriteRedrawSavedRectStub() and Sint32.

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

Definition at line 450 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, four a page with its arrows, and draws at four fifths of their size the party members who cannot equip itemId.

References fdSpriteStartAnimationStub(), gmItemIsCompatibleWithUnitStub(), mnWindowSpriteCreateStub(), mnWindowSpritePrepareForRedrawStub() and Sint32.

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

Definition at line 471 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: 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 mnShopSelectBuy for weapons and armor.

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

Referenced by mnShopSelectBuy().

Definition at line 523 of file shop_buy.c.

mnShopDrawCarriedItem

void mnShopDrawCarriedItem(WINDOW *window, Sint32 unitId, Sint32 itemId)

Shows how many of the item the party member already carries and the party member's inventory icons.

References gmInventoryFindStub(), gmUnitGet(), mnItemIconGridShowInventory(), mnMessageArgumentPushStub(), mnTextDrawMessageAsTilesStub(), mnWindowSpritePrepareForRedrawStub() and Sint32.

Referenced by mnShopGiveGameTicket() and mnShopSelectBuy().

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

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

Referenced by mnShopSelectBuy().

Definition at line 647 of file shop_buy.c.

mnShopSelectQuantity

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. Returns the count above minimum, the items already carried, or -1 when B cancels.

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

Referenced by mnShopSelectBuyCount() and mnShopSelectSellCount().

Definition at line 738 of file shop_buy.c.

mnShopBuyDone

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.

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

Referenced by mnShopSelectBuy().

Definition at line 848 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 1 when it was equipped.

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

Referenced by mnShopBuyDone() and mnShopRepairItem().

Definition at line 875 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 1 when it offered.

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

Referenced by mnShopBuyDone() and mnShopRepairItem().

Definition at line 927 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 953 of file shop_buy.c.