Alchemy
Loading...
Searching...
No Matches

run.c File Reference

Running a shop, its cursor work, and the message helpers every counter uses. More...

Go to the source code of this file.

Data Structures

struct  SelectorRecord
 Byte view of the six colour writes in a quantity-bar segment. More...

Macros

#define SHOP_DEBUG_STOCK_ROW   1

Functions

s32 Shop_ListAvailableArtifacts (void)
 Lists the current shop's artifacts: every item of the shop's type whose shared stock counter is above zero.
void Shop_StepCursor (void)
 Advances the hand cursor one frame.
void Shop_InitializeCursorWork (void)
 Allocates and clears the work block in the menu's heap slot, lists the party, loads the six cursor icons into the VRAM cache and starts the cursor's task.
void Shop_ReleaseCursorWork (void)
 Stops the cursor task, frees the six cursor icons and the work block.
s32 Shop_Run (s32 stockRow, s32 keeperId)
 Runs a shop: the shopkeeper's welcome, then buy, sell, artifacts and repair until the player leaves.
s32 Battle_ApplyPresetItemsAndFlags (s32 unused)
 Opens the debug shop with 200000 coins, the ticket counter at its cap, broken equipment for repairs and poisoned or haunted members for the sanctum.
void AudioCommand_WaitForStateByteClear (void)
 Waits one frame at a time until the sound driver has finished the last command.
void UiMessage_ShowAndWait (s32 messageId)
 Shows a shopkeeper's line and waits for its window to finish, one more frame included.
void UiMessage_ShowAndRestoreState (s32 messageId)
 Shows a shopkeeper's line as UiMessage_ShowAndWait does, hiding the hand cursor while it shows and putting back its motion after.
s32 UiMessage_ShowChoice (s32 choice)
 Runs the Yes or No choice beside the shopkeeper's line and returns it, keeping the hand cursor's motion.
s32 UiMessage_ShowChoiceVariant (s32 choice)
 Runs the Yes or No choice at the sanctum's place on the screen and returns it, keeping the hand cursor's motion.
UNUSED struct NodeChainNode * NodeChain_GetNodeAtIndex (struct NodeChainState *state)
 Unused original list walker: follows the requested number of next links.

Detailed Description

Running a shop, its cursor work, and the message helpers every counter uses.

Part of shop.c, the shop object, compiled only through it.

Definition in file run.c.

Macro Definition Documentation

◆ SHOP_DEBUG_STOCK_ROW

#define SHOP_DEBUG_STOCK_ROW   1

Definition at line 171 of file run.c.

Referenced by Battle_ApplyPresetItemsAndFlags().

Function Documentation

◆ Shop_ListAvailableArtifacts()

s32 Shop_ListAvailableArtifacts ( void )

Lists the current shop's artifacts: every item of the shop's type whose shared stock counter is above zero.

Writes them to the work block's stock list and returns how many. Called by Shop_Run when the player picks Artifacts, and by Shop_SelectBuy to refresh the list after a purchase.

Definition at line 11 of file run.c.

Referenced by Shop_ListAvailableArtifacts(), Shop_Run(), and Shop_SelectBuy().

◆ Shop_StepCursor()

void Shop_StepCursor ( void )

Advances the hand cursor one frame.

Runs every frame as a scheduler task while a counter is open.

Definition at line 39 of file run.c.

Referenced by Shop_InitializeCursorWork(), Shop_ReleaseCursorWork(), and Shop_StepCursor().

◆ Shop_InitializeCursorWork()

void Shop_InitializeCursorWork ( void )

Allocates and clears the work block in the menu's heap slot, lists the party, loads the six cursor icons into the VRAM cache and starts the cursor's task.

Every counter opens with it: Shop_Run, the inn, the sanctum and the item picker.

Definition at line 47 of file run.c.

Referenced by Inn_CheckIn(), Shop_ConfirmAct(), Shop_InitializeCursorWork(), Shop_PickUnitItem(), and Shop_Run().

◆ Shop_ReleaseCursorWork()

void Shop_ReleaseCursorWork ( void )

Stops the cursor task, frees the six cursor icons and the work block.

Every counter closes with it.

Definition at line 79 of file run.c.

Referenced by Inn_CheckIn(), Shop_ConfirmAct(), Shop_PickUnitItem(), Shop_ReleaseCursorWork(), and Shop_Run().

◆ Shop_Run()

s32 Shop_Run ( s32 stockRow,
s32 keeperId )

Runs a shop: the shopkeeper's welcome, then buy, sell, artifacts and repair until the player leaves.

stockRow picks the row of sStockTable (0 for a row out of range) and keeperId the object whose portrait the messages show. Seeds the row's artifacts on the first visit and holds the work block while it runs. Called by the town scenes' shopkeepers through SHOP.S, and by the debug shop.

Definition at line 100 of file run.c.

Referenced by Battle_ApplyPresetItemsAndFlags(), Shop_Run(), TalkToShopkeeper32(), TalkToShopkeeper33(), and TalkToShopkeeper34().

◆ Battle_ApplyPresetItemsAndFlags()

s32 Battle_ApplyPresetItemsAndFlags ( s32 unused)

Opens the debug shop with 200000 coins, the ticket counter at its cap, broken equipment for repairs and poisoned or haunted members for the sanctum.

Called by DebugMenu_RunPresetShop.

Definition at line 179 of file run.c.

Referenced by Battle_ApplyPresetItemsAndFlags(), and DebugMenu_RunPresetShop().

◆ AudioCommand_WaitForStateByteClear()

void AudioCommand_WaitForStateByteClear ( void )

Waits one frame at a time until the sound driver has finished the last command.

Called by the inn's sleep, the sanctum and two scenes that wait for a fanfare.

Definition at line 198 of file run.c.

Referenced by AudioCommand_WaitForStateByteClear(), Inn_PlaySleep(), RaiseTheShip(), Shop_RunPartyMemberIconBurst(), and TolbiSpring_Initialize().

◆ UiMessage_ShowAndWait()

void UiMessage_ShowAndWait ( s32 messageId)

Shows a shopkeeper's line and waits for its window to finish, one more frame included.

messageId is the weapon shop's line; the armor, item and warriors' shops say theirs, at the same distance from their own welcome. Called by every counter.

Definition at line 214 of file run.c.

Referenced by Inn_CheckIn(), Shop_BuySpecialItem(), Shop_ConfirmEquip(), Shop_Run(), Shop_SelectBuy(), Shop_SelectBuyNum(), Shop_SelectRepair(), Shop_SelectSell(), Shop_SelectSellNum(), and UiMessage_ShowAndWait().

◆ UiMessage_ShowAndRestoreState()

void UiMessage_ShowAndRestoreState ( s32 messageId)

Shows a shopkeeper's line as UiMessage_ShowAndWait does, hiding the hand cursor while it shows and putting back its motion after.

Definition at line 239 of file run.c.

Referenced by Shop_BuyDone(), Shop_BuySpecialItem(), Shop_ConfirmEquip(), Shop_RepairItem(), Shop_SelectBuy(), Shop_SellItem(), and UiMessage_ShowAndRestoreState().

◆ UiMessage_ShowChoice()

s32 UiMessage_ShowChoice ( s32 choice)

Runs the Yes or No choice beside the shopkeeper's line and returns it, keeping the hand cursor's motion.

Called by the counters before they buy, sell, equip or repair, and by the inn.

Definition at line 278 of file run.c.

Referenced by Inn_CheckIn(), Shop_ConfirmEquip(), Shop_RepairItem(), Shop_SelectBuy(), Shop_SellItem(), and UiMessage_ShowChoice().

◆ UiMessage_ShowChoiceVariant()

s32 UiMessage_ShowChoiceVariant ( s32 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 Sanctum_RunPartyService.

Definition at line 291 of file run.c.

Referenced by Sanctum_RunPartyService(), and UiMessage_ShowChoiceVariant().

◆ NodeChain_GetNodeAtIndex()

UNUSED struct NodeChainNode * NodeChain_GetNodeAtIndex ( struct NodeChainState * state)

Unused original list walker: follows the requested number of next links.

Definition at line 303 of file run.c.

Referenced by NodeChain_GetNodeAtIndex().