src/shop/shop_run.c
Running a shop: the artifacts it lists, opening its state, the counter's loop and the message helpers every counter uses. More…
Included by shop.c.
Macros
| Name | Description | |
|---|---|---|
#define | SHOP_ICON_BYTES (4 * TILE_SIZE_4BPP) | The bytes of a shop icon: a 16x16 sprite, four tiles of 4 bits a pixel. |
#define | DEBUG_SHOP_COINS 200000 | The coins the debug shop gives. |
#define | DEBUG_SHOP_KEEPER 30 | The actor whose sprite picks the debug shop keeper's portrait, in whatever room it opens. |
#define | SHOP_KEEPER_LINE (message, shopType) | Turns the weapon shop's line message into the one the shop of shopType says: the armor shop, the item shop and the general store each have their own version, as many messages on. |
#define | SHOP_CONFIRM_MENU_X 6 |
Functions
| Name | Description | |
|---|---|---|
Sint32 | mnShopListAvailableArtifacts (void) | Lists the current shop's artifacts: every item of the shop's type whose shared stock counter is above zero, or of any type at a general store. |
void | mnCursorStep (void) | Advances the hand cursor one tick. |
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 | mnShopRun (Sint32 stockRow, Sint32 keeperId) | Runs a shop: the shopkeeper's welcome, then buy, sell, artifacts and repair until the player leaves. |
Sint32 | mnShopOpenDebugShop (void) | Unused: opens the debug shop with DEBUG_SHOP_COINS, the ticket counter at its cap, broken equipment for repairs and poisoned or haunted party members for the sanctum, on the empty stock row. |
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 | 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. |
void | mnShopShowKeeperMessageHidingCursor (Sint32 msgId) | Shows a shopkeeper's line as mnShopShowKeeperMessage does, hiding the hand cursor while it shows and putting back its motion after. |
Sint32 | mnShopAskYesNo (Sint32 choice) | Runs the Yes or No choice beside the shopkeeper's line and returns it: 0 for Yes, 1 for No or B. |
Sint32 | mnSanctumAskYesNo (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. |
Sint32 | mnGridMoveCursor (Sint32 *cursor, Sint32 count, Sint32 columns) | Moves a cursor over count entries laid out columns to a row by the d-pad: left and right wrap round, up and down stop at the ends. |
Description
Running a shop: the artifacts it lists, opening its state, the counter's loop
and the message helpers every counter uses. Part of shop.c.
Macros in detail
SHOP_ICON_BYTES
#define SHOP_ICON_BYTES (4 * TILE_SIZE_4BPP)
The bytes of a shop icon: a 16x16 sprite, four tiles of 4 bits a pixel.
Referenced by mnShopInitState().
Definition at line 48 of file shop_run.c.
DEBUG_SHOP_COINS
#define DEBUG_SHOP_COINS 200000
The coins the debug shop gives.
Referenced by mnShopOpenDebugShop().
Definition at line 200 of file shop_run.c.
DEBUG_SHOP_KEEPER
#define DEBUG_SHOP_KEEPER 30
The actor whose sprite picks the debug shop keeper's portrait, in whatever room it opens.
Referenced by mnShopOpenDebugShop().
Definition at line 203 of file shop_run.c.
SHOP_KEEPER_LINE
#define SHOP_KEEPER_LINE(message, shopType)
Turns the weapon shop's line message into the one the shop of shopType
says: the armor shop, the item shop and the general store each have their own
version, as many messages on.
Referenced by mnShopShowKeeperMessage() and mnShopShowKeeperMessageHidingCursor().
Definition at line 240 of file shop_run.c.
SHOP_CONFIRM_MENU_X
#define SHOP_CONFIRM_MENU_X 6
#define SHOP_CONFIRM_MENU_X 7
Referenced by mnShopAskYesNo().
Definition at lines 307 and 309 of file shop_run.c.
Functions in detail
mnShopListAvailableArtifacts
Sint32 mnShopListAvailableArtifacts(void)
Lists the current shop's artifacts: every item of the shop's type whose
shared stock counter is above zero, or of any type at a general store. Writes
them to the shop state's stock list and returns how many. Called by mnShopRun
when the player picks Artifacts, and by mnShopSelectBuy to refresh the list
after a purchase.
References gmItemAdjustRareItemStockStub(), gmItemGetEquipmentGroupStub() and Sint32.
Referenced by mnShopRun() and mnShopSelectBuy().
Definition at line 13 of file shop_run.c.
mnCursorStep
void mnCursorStep(void)
Advances the hand cursor one tick. Runs every tick as an event while a counter is open.
References mnCursorAdvance().
Referenced by mnShopInitState() and mnShopReleaseState().
Definition at line 42 of file shop_run.c.
mnShopInitState
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. Every counter opens with it: mnShopRun,
the inn, the sanctum, the forge and the item picker. The block, the icons'
cache entries and the event last until mnShopReleaseState.
References fdScriptEndAllLastingPsynergyStub(), gmPartyListMembersStub(), mnCursorStep(), mnItemIconGridInit(), mnPaletteLoadIconsIntoHighlightStub(), mnVRAMBlockLoadResource(), Sint32, syHeapSlotAllocate(), sySetEvent() and syVRAMCacheFindFreeEntry().
Referenced by mnForgeRun(), mnInnCheckIn(), mnInnQuoteRoomPrice(), mnItemPickerRun(), mnSanctumRun() and mnShopRun().
Definition at line 55 of file shop_run.c.
mnShopReleaseState
void mnShopReleaseState(void)
Releases the item icon grid, stops the cursor event, frees the six cursor icons and the shop's state. Every counter closes with it.
References mnCursorStep(), mnItemIconGridRelease(), mnMessageCloseFinishedWindowsStub(), syCloseEvent(), syHeapSlotRelease() and syVRAMCacheFreeEntry().
Referenced by mnForgeRun(), mnInnCheckIn(), mnInnQuoteRoomPrice(), mnItemPickerRun(), mnSanctumRun() and mnShopRun().
Definition at line 100 of file shop_run.c.
mnShopRun
Sint32 mnShopRun(Sint32 stockRow, Sint32 keeperId)
Runs a shop: the shopkeeper's welcome, then buy, sell, artifacts and repair
until the player leaves. stockRow picks the row of the stock table (the
empty row 0 for one out of range) and keeperId the actor whose portrait the
messages show. Seeds the row's artifacts on the first visit and holds the
shop's state while it runs. Called by the town scenes' shopkeepers through
the stub table, and by the debug shop. Returns 0.
References fdActorGetByIdStub(), mnCursorSetPosImmediate(), mnPortraitOpenWindowStub(), mnSelectShopCommandStub(), mnShopChooseMember(), mnShopInitState(), mnShopListAvailableArtifacts(), mnShopReleaseState(), mnShopRunRepairMemberChoice(), mnShopSelectBuy(), mnShopShowKeeperMessage(), mnShopStockAddArtifacts(), mnShopStockCopyItems(), mnShopStockGetRowCount(), mnShopStockGetType(), mnWindowCloseStub(), mnWindowCreateStub(), mnWindowSpriteCreateStub(), Sint32 and sySynch().
Referenced by dbPsynergyTestOpenArmorShop(), dbPsynergyTestOpenGeneralStore(), dbPsynergyTestOpenItemShop(), dbPsynergyTestOpenWeaponShop(), dbShopTestOpenArmorShop(), dbShopTestOpenGeneralStore(), dbShopTestOpenItemShop(), dbShopTestOpenWeaponShop(), mnShopOpenDebugShop(), scAlhafraOpenArmorShop(), scAlhafraOpenWeaponShop(), scAlhafraRoomsTalkToItemMerchant(), scApojiiIslandsTalkToGeneralStorekeeper(), scChampaRoomsTalkToArtifactMerchant(), scContigoTalkToArmorMerchant(), scContigoTalkToItemMerchant(), scContigoTalkToWeaponMerchant(), scDailaAskAfterTaviAndRiki(), scDailaRoomsTalkToArmorMerchant(), scDailaRoomsTalkToArmorMerchantOnceTaviIsRescued(), scDailaRoomsTalkToWeaponMerchant(), scDailaRoomsTalkToWeaponMerchantOnceTaviIsRescued(), scDailaTaviAndRikiAreHome(), scGarohRoomsTalkToArmorVendor(), scGarohRoomsTalkToItemShopkeeper(), scGarohRoomsTalkToWeaponsVendor(), scIzumoRoomsTalkToMerchant(), scKibomboOpenArmorShop(), scKibomboOpenItemShop(), scKibomboOpenWeaponShop(), scLohoTalkAboutCommerce(), scMadraTalkToArmorMerchant(), scMadraTalkToItemMerchant(), scMadraTalkToWeaponMerchant(), scMikasallaRoomsTalkToGeneralStorekeeper(), scNaribwePraiseFortuneTeller(), scNaribwePraiseFortuneTellerOnReturn(), scNaribweRoomsTalkToArmorMerchant(), scNaribweRoomsTalkToArmorMerchantOnReturn(), scNaribweRoomsTalkToWeaponMerchant(), scNaribweRoomsTalkToWeaponMerchantOnReturn(), scProxTalkToShopkeeper(), scShamanVillageTalkToGeneralStorekeeper(), scYallamRoomsTalkToArmorMerchant(), scYallamRoomsTalkToItemMerchant() and scYallamRoomsTalkToWeaponMerchant().
Definition at line 123 of file shop_run.c.
mnShopOpenDebugShop
Sint32 mnShopOpenDebugShop(void)
Unused: opens the debug shop with DEBUG_SHOP_COINS, the ticket counter at its
cap, broken equipment for repairs and poisoned or haunted party members for
the sanctum, on the empty stock row. Nothing calls it or its stub call
export; The Broken Seal's debug menu opened its own.
References gmInventoryAddItemStub(), gmInventoryEquipStub(), gmUnitGet(), MainRoutineStateWork, mnShopRun() and Sint32.
Definition at line 209 of file shop_run.c.
mnSoundWaitForJingle
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.
References sySoundGetBGMRestoreDelayStub() and sySynch().
Referenced by mnInnPlaySleep(), mnSanctumRunMemberIconBurst(), scContigoReportCoinChange(), scJupiterLighthouseActivateTheLighthouse(), scJupiterLighthouseFinishMovingBlock() and scJupiterLighthouseRaiseAngels().
Definition at line 229 of file shop_run.c.
mnShopShowKeeperMessage
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.
References fdSpeakerGetVoiceStub(), mnMessageAllTypedStub(), mnMessageCloseFinishedWindowsStub(), mnMessageOpenWindowStub(), Sint32 and sySynch().
Referenced by mnForgeRun(), mnInnCheckIn(), mnShopConfirmEquip(), mnShopGiveGameTicket(), mnShopRun(), mnShopSelectBuy(), mnShopSelectBuyCount(), mnShopSelectSell() and mnShopSelectSellCount().
Definition at line 250 of file shop_run.c.
mnShopShowKeeperMessageHidingCursor
void mnShopShowKeeperMessageHidingCursor(Sint32 msgId)
Shows a shopkeeper's line as mnShopShowKeeperMessage does, hiding the hand
cursor while it shows and putting back its motion after.
References fdSpeakerGetVoiceStub(), mnMessageAllTypedStub(), mnMessageCloseFinishedWindowsStub(), mnMessageOpenWindowStub(), Sint32 and sySynch().
Referenced by mnForgeOfferItem(), mnShopBuyDone(), mnShopConfirmEquip(), mnShopGiveGameTicket(), mnShopRepairItem(), mnShopSelectBuy() and mnShopSellItem().
Definition at line 274 of file shop_run.c.
mnShopAskYesNo
Sint32 mnShopAskYesNo(Sint32 choice)
Runs the Yes or No choice beside the shopkeeper's line and returns it: 0 for
Yes, 1 for No or B. choice is where the cursor starts. Keeps the hand
cursor's motion. Called by the counters before they buy, sell, equip or
repair, and by the inn.
References mnIconShowStub(), mnYesNoMenuRunAtStub() and Sint32.
Referenced by mnForgeOfferItem(), mnInnCheckIn(), mnShopConfirmEquip(), mnShopRepairItem(), mnShopSelectBuy() and mnShopSellItem().
Definition at line 316 of file shop_run.c.
mnSanctumAskYesNo
Sint32 mnSanctumAskYesNo(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. Called by mnSanctumRunPartyService.
References mnIconShowStub(), mnYesNoMenuRunAtStub() and Sint32.
Referenced by mnSanctumRunPartyService().
Definition at line 331 of file shop_run.c.
mnGridMoveCursor
Sint32 mnGridMoveCursor(Sint32 *cursor, Sint32 count, Sint32 columns)
Moves a cursor over count entries laid out columns to a row by the d-pad:
left and right wrap round, up and down stop at the ends. Plays the cursor
sound when it moves. Returns how it moved (MENU_GRID_MOVE), a page being one
row of columns. Called by every counter's lists.
References PerWork, Sint32 and sySoundPlayStub().
Referenced by mnItemPickerRun(), mnSanctumRunPartyService(), mnShopChooseMember(), mnShopGiveGameTicket() and mnShopSelectBuy().
Definition at line 346 of file shop_run.c.