Skip to Content
The Alchemy Project

src/shop/shop_cursor.c

The shop's quantity bar and price sprites, the field's colours tinted and restored (the Sanctum's healing, a Djinni joining the party), and the hand cursor's glides. More…

Included by shop.c.

Macros

NameDescription
#defineSHOP_TINT_TICKS 16The ticks the field's colours take to fade to a shop's tint and back.

Functions

NameDescription
voidmnQuantityBarFill (Sint32 itemCount, Sint32 color, Uint8 *tileBuf)Colours the first itemCount segments of the quantity bar in color (enum QUANTITY_BAR_COL).
voidmnShopDrawPriceDigit (Sint32 digit, Uint8 *tileBuf, Uint32 digitPos)Draws one digit of a price at its place (0 for the ones) over the blank price's tiles.
WINDOW_SPR *mnShopCreatePriceSprite (Sint32 value, WINDOW *window, Sint32 x, Sint32 y)Builds a price of up to five digits as a sprite on window at (x, y).
voidmnShopSaveAndTintFieldPalette (Sint32 tint)Saves the field's background colours in the field state and fades them to tint (PALETTE_TINT_CUSTOM with a colour) over SHOP_TINT_TICKS ticks.
voidmnShopRestoreFieldPalette (void)Fades back to the colours mnShopSaveAndTintFieldPalette saved, over SHOP_TINT_TICKS ticks.
voidmnCursorAdvance (MENU_CURSOR *cursor)Moves the cursor a tick along its straight line toward its target.
voidmnCursorMoveTowardTarget (MENU_CURSOR *cursor)Eases a cursor toward its target, a quarter of the way on each axis a tick and at least a pixel; the settings and name-entry screens move their markers with it.
voidmnCursorSet (MENU_CURSOR *cursor, Sint32 targetX, Sint32 targetY, Sint32 ticks)Starts a glide of the cursor from where it is to (targetX, targetY) over ticks ticks, for mnCursorAdvance to run.
voidmnCursorSetPosImmediate (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.
voidmnCursorPlace (WINDOW *window, Sint32 x, Sint32 y)Starts the hand cursor's glide to (x, y) pixels inside window (the screen when it is NULL), over the ticks shop->cursorMoveTicks holds.

Description

The shop's quantity bar and price sprites, the field's colours tinted and restored (the Sanctum's healing, a Djinni joining the party), and the hand cursor's glides. Part of shop.c.

Macros in detail

SHOP_TINT_TICKS

#define SHOP_TINT_TICKS 16

The ticks the field's colours take to fade to a shop's tint and back.

Referenced by mnShopRestoreFieldPalette() and mnShopSaveAndTintFieldPalette().

Definition at line 8 of file shop_cursor.c.

Functions in detail

mnQuantityBarFill

void mnQuantityBarFill(Sint32 itemCount, Sint32 color, Uint8 *tileBuf)

Colours the first itemCount segments of the quantity bar in color (enum QUANTITY_BAR_COL).

References ShopQuantityBarSegmentOffsets and Sint32.

Referenced by mnShopSelectQuantity().

Definition at line 12 of file shop_cursor.c.

mnShopDrawPriceDigit

void mnShopDrawPriceDigit(Sint32 digit, Uint8 *tileBuf, Uint32 digitPos)

Draws one digit of a price at its place (0 for the ones) over the blank price's tiles. A digit is up to four rows of eight pixels, the right half of one tile and the left half of the next; its glyph's bytes end at the first 0.

References ShopGlyphBytes, ShopPriceDigitTileOffsets and Sint32.

Referenced by mnShopCreatePriceSprite().

Definition at line 36 of file shop_cursor.c.

mnShopCreatePriceSprite

WINDOW_SPR * mnShopCreatePriceSprite(Sint32 value, WINDOW *window, Sint32 x, Sint32 y)

Builds a price of up to five digits as a sprite on window at (x, y). Returns the sprite, or NULL with no free slot.

References mnShopDrawPriceDigit(), mnWindowSpriteCreateStub(), ShopPriceTiles, Sint32, syDMAXCopy(), syHeapSlotAllocateEWRAM(), syHeapSlotRelease(), syVRAMCacheFindFreeEntry() and syVRAMCacheLoad().

Referenced by mnShopDrawStock().

Definition at line 64 of file shop_cursor.c.

mnShopSaveAndTintFieldPalette

void mnShopSaveAndTintFieldPalette(Sint32 tint)

Saves the field's background colours in the field state and fades them to tint (PALETTE_TINT_CUSTOM with a colour) over SHOP_TINT_TICKS ticks.

References fdPaletteFadeSetTargetStub(), fdPaletteFadeStartInterpolationStub(), Sint32 and syDMAXCopy().

Referenced by mnSanctumRunMemberIconBurst() and scAltmillerCaveReleaseWallBurst().

Definition at line 112 of file shop_cursor.c.

mnShopRestoreFieldPalette

void mnShopRestoreFieldPalette(void)

Fades back to the colours mnShopSaveAndTintFieldPalette saved, over SHOP_TINT_TICKS ticks.

References fdPaletteFadeSetTargetStub(), fdPaletteFadeStartInterpolationStub() and Sint32.

Referenced by mnSanctumRunMemberIconBurst() and scAltmillerCaveReleaseWallBurst().

Definition at line 140 of file shop_cursor.c.

mnCursorAdvance

void mnCursorAdvance(MENU_CURSOR *cursor)

Moves the cursor a tick along its straight line toward its target.

References Sint32.

Referenced by mnCursorStep().

Definition at line 148 of file shop_cursor.c.

mnCursorMoveTowardTarget

void mnCursorMoveTowardTarget(MENU_CURSOR *cursor)

Eases a cursor toward its target, a quarter of the way on each axis a tick and at least a pixel; the settings and name-entry screens move their markers with it.

References Sint32.

Definition at line 181 of file shop_cursor.c.

mnCursorSet

void mnCursorSet(MENU_CURSOR *cursor, Sint32 targetX, Sint32 targetY, Sint32 ticks)

Starts a glide of the cursor from where it is to (targetX, targetY) over ticks ticks, for mnCursorAdvance to run.

References Sint32.

Referenced by mnCursorPlace().

Definition at line 236 of file shop_cursor.c.

mnCursorSetPosImmediate

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

References Sint32.

Referenced by mnItemPickerRun(), mnSanctumRun() and mnShopRun().

Definition at line 253 of file shop_cursor.c.

mnCursorPlace

void mnCursorPlace(WINDOW *window, Sint32 x, Sint32 y)

Starts the hand cursor's glide to (x, y) pixels inside window (the screen when it is NULL), over the ticks shop->cursorMoveTicks holds.

References mnCursorSet() and Sint32.

Referenced by mnItemPickerRun(), mnItemPickerSelectItem(), mnSanctumRunPartyService(), mnShopChooseMember(), mnShopGiveGameTicket(), mnShopSelectBuy(), mnShopSelectBuyCount(), mnShopSelectRepair(), mnShopSelectSell() and mnShopSelectSellCount().

Definition at line 267 of file shop_cursor.c.