Skip to Content
The Alchemy Project

src/shop/shop_cursor.c

The quantity bar, the price digits and their sprites, the field's tint behind the sanctum and the Djinn, the hand cursor's glides, and loading a picture into VRAM. More…

Included by shop.c.

Macros

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

Functions

NameDescription
voidmnQuantityBarFill (Sint32 segments, Sint32 color, Uint8 *tileBuf)Paints the first segments segments of the quantity bar in color (a QUANTITY_BAR_ colour), over what was painted before.
voidmnShopDrawPriceDigit (Sint32 digit, Uint8 *tileBuf, Uint32 digitPos)Copies decimal glyph digit into its price-tile position, stopping at zero source bytes: two bytes of each of its four rows in the digit's tile, and two more in the same row of the next.
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 colours and fades them to tint (a PALETTE_TINT_ mode) over SHOP_TINT_TICKS ticks: the grey of the sanctum's healing, and the element's colour as a Djinni joins the party.
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)Moves each cursor axis one quarter of the remaining distance, with a minimum one-pixel step.
voidmnCursorSet (MENU_CURSOR *cursor, Sint32 targetX, Sint32 targetY, Sint8 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->cursorFrame holds.
voidmnVRAMBlockLoadResource (Sint32 entryId, Sint32 size, Sint32 resourceId)Decompresses resource resourceId and loads its first size bytes into VRAM cache entry entryId; does nothing for an entry past the cache.

Description

The quantity bar, the price digits and their sprites, the field's tint behind the sanctum and the Djinn, the hand cursor's glides, and loading a picture into VRAM. 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 tint and back.

Referenced by mnShopRestoreFieldPalette() and mnShopSaveAndTintFieldPalette().

Definition at line 8 of file shop_cursor.c.

Functions in detail

mnQuantityBarFill

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

Paints the first segments segments of the quantity bar in color (a QUANTITY_BAR_ colour), over what was painted before.

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)

Copies decimal glyph digit into its price-tile position, stopping at zero source bytes: two bytes of each of its four rows in the digit's tile, and two more in the same row of the next.

References ShopGlyphBytes, ShopPriceDigitTileOffsets and Sint32.

Referenced by mnShopCreatePriceSprite().

Definition at line 43 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 71 of file shop_cursor.c.

mnShopSaveAndTintFieldPalette

void mnShopSaveAndTintFieldPalette(Sint32 tint)

Saves the field's colours and fades them to tint (a PALETTE_TINT_ mode) over SHOP_TINT_TICKS ticks: the grey of the sanctum's healing, and the element's colour as a Djinni joins the party.

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

Referenced by mnSanctumRunMemberIconBurst().

Definition at line 120 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().

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() and scCursorShow().

Definition at line 147 of file shop_cursor.c.

mnCursorMoveTowardTarget

void mnCursorMoveTowardTarget(MENU_CURSOR *cursor)

Moves each cursor axis one quarter of the remaining distance, with a minimum one-pixel step.

References Sint32.

Definition at line 179 of file shop_cursor.c.

mnCursorSet

void mnCursorSet(MENU_CURSOR *cursor, Sint32 targetX, Sint32 targetY, Sint8 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() and scCursorShow().

Definition at line 234 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 mnForgeRun(), mnItemPickerRun(), mnSanctumRun(), mnShopRun() and scCursorPlace().

Definition at line 251 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->cursorFrame holds.

References mnCursorSet() and Sint32.

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

Definition at line 274 of file shop_cursor.c.

mnVRAMBlockLoadResource

void mnVRAMBlockLoadResource(Sint32 entryId, Sint32 size, Sint32 resourceId)

Decompresses resource resourceId and loads its first size bytes into VRAM cache entry entryId; does nothing for an entry past the cache.

References Sint32, syDecompressByteLZ(), syHeapAllocate(), syHeapRelease(), syResourceGetTableEntry() and syVRAMCacheLoad().

Referenced by mnShopInitState().

Definition at line 290 of file shop_cursor.c.