Alchemy
Loading...
Searching...
No Matches

cursor.c File Reference

The selection frame and price digit tiles, and the hand cursor. More...

Go to the source code of this file.

Functions

void Shop_FillSelector (s32 itemCount, s32 paletteSelector, u8 *tileBuffer)
 Colours the first itemCount segments of the quantity bar with palette paletteSelector, writing six pixels a segment in tileBuffer.
void Shop_CopyGlyphs (s32 digit, u8 *tileBuffer, u32 digitPosition)
 Copies decimal glyph digit into its price-tile position, stopping at zero source bytes.
struct RenderOutput * Shop_CreatePriceSprite (s32 value, struct UiWindow *window, s32 x, s32 y)
 Builds a price of up to five digits in scratch tiles (heap slot 14), loads them into a free VRAM cache slot and attaches them to window as one sprite at (x, y).
void Shop_SaveAndTintFieldPalette (s32 layer)
 Saves the field colours in event work and fades to layer over 16 frames.
void Shop_RestoreFieldPalette (void)
 Fades back to the colours Shop_SaveAndTintFieldPalette saved, over 16 frames.
void ShopCursor_Advance (struct ShopCursor *cursor)
 Moves the cursor from its saved position toward its target, in a straight line over kind frames, one frame a call; active counts the frames and both go back to 0 on arrival.
void ShopCursor_MoveTowardTarget (struct ShopCursor *cursor)
 Moves each cursor axis one quarter of the remaining distance, with a minimum one-pixel step.
void Shop_SetCursor (struct ShopCursor *cursor, s32 targetX, s32 targetY, s32 kind)
 Starts a glide of the cursor from where it is to (targetX, targetY) over kind frames, for ShopCursor_Advance to run.
void ShopCursor_SetPositionImmediate (struct ShopCursor *cursor, s32 x, s32 y)
 Places the cursor and its sprite at (x, y) at once, with a one-frame glide that has already arrived.
void Shop_PlaceCursor (struct UiWindow *window, s32 x, s32 y)
 Starts the hand cursor's glide to (x, y) pixels inside window (the screen when it is NULL), over the frames shop->mode holds.

Variables

static const u16 sSelectorTileOffsets [30]
 Where each of the quantity bar's 30 segments starts in its tile buffer.
static const u16 sPriceDigitTileOffsets [5]
 Where each of a price's five digits starts in its tile buffer, ones first.

Detailed Description

The selection frame and price digit tiles, and the hand cursor.

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

Definition in file cursor.c.

Function Documentation

◆ Shop_FillSelector()

void Shop_FillSelector ( s32 itemCount,
s32 paletteSelector,
u8 * tileBuffer )

Colours the first itemCount segments of the quantity bar with palette paletteSelector, writing six pixels a segment in tileBuffer.

Called by the shop's quantity choice and, through SHOP.S, by the item menu's quantity bar, which draws its bar in four colours this way.

Definition at line 25 of file cursor.c.

Referenced by Shop_FillSelector(), and Shop_SelectQuantity().

◆ Shop_CopyGlyphs()

void Shop_CopyGlyphs ( s32 digit,
u8 * tileBuffer,
u32 digitPosition )

Copies decimal glyph digit into its price-tile position, stopping at zero source bytes.

Called by Shop_CreatePriceSprite.

Definition at line 55 of file cursor.c.

Referenced by Shop_CopyGlyphs(), and Shop_CreatePriceSprite().

◆ Shop_CreatePriceSprite()

struct RenderOutput * Shop_CreatePriceSprite ( s32 value,
struct UiWindow * window,
s32 x,
s32 y )

Builds a price of up to five digits in scratch tiles (heap slot 14), loads them into a free VRAM cache slot and attaches them to window as one sprite at (x, y).

Returns the sprite, or NULL with no free slot. Called by Shop_DrawStock for each item on sale.

Definition at line 81 of file cursor.c.

Referenced by Shop_CreatePriceSprite(), and Shop_DrawStock().

◆ Shop_SaveAndTintFieldPalette()

void Shop_SaveAndTintFieldPalette ( s32 layer)

Saves the field colours in event work and fades to layer over 16 frames.

Called before sanctum and Djinn capture effects and Altmiller's wall burst; Shop_RestoreFieldPalette restores the saved colours afterward.

Definition at line 122 of file cursor.c.

Referenced by AltmillerCave_ReleaseWallBurst(), Shop_RunPartyMemberIconBurst(), and Shop_SaveAndTintFieldPalette().

◆ Shop_RestoreFieldPalette()

void Shop_RestoreFieldPalette ( void )

Fades back to the colours Shop_SaveAndTintFieldPalette saved, over 16 frames.

Called when the sanctum, Djinn capture or Altmiller wall effect ends.

Definition at line 147 of file cursor.c.

Referenced by AltmillerCave_ReleaseWallBurst(), Shop_RestoreFieldPalette(), and Shop_RunPartyMemberIconBurst().

◆ ShopCursor_Advance()

void ShopCursor_Advance ( struct ShopCursor * cursor)

Moves the cursor from its saved position toward its target, in a straight line over kind frames, one frame a call; active counts the frames and both go back to 0 on arrival.

Runs every frame from Shop_StepCursor, and from the option, name entry and save menus' cursor tasks.

Definition at line 156 of file cursor.c.

Referenced by Shop_StepCursor(), and ShopCursor_Advance().

◆ ShopCursor_MoveTowardTarget()

void ShopCursor_MoveTowardTarget ( struct ShopCursor * cursor)

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

Called each frame by the option menu and name entry.

Definition at line 186 of file cursor.c.

Referenced by ShopCursor_MoveTowardTarget().

◆ Shop_SetCursor()

void Shop_SetCursor ( struct ShopCursor * cursor,
s32 targetX,
s32 targetY,
s32 kind )

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

Called by Shop_PlaceCursor and, through SHOP.S, by name entry and the Colosso choice.

Definition at line 234 of file cursor.c.

Referenced by Shop_PlaceCursor(), and Shop_SetCursor().

◆ ShopCursor_SetPositionImmediate()

void ShopCursor_SetPositionImmediate ( struct ShopCursor * cursor,
s32 x,
s32 y )

Places the cursor and its sprite at (x, y) at once, with a one-frame glide that has already arrived.

Called when a counter, the option and system menus or name entry opens.

Definition at line 249 of file cursor.c.

Referenced by Shop_ConfirmAct(), Shop_PickUnitItem(), Shop_Run(), and ShopCursor_SetPositionImmediate().

◆ Shop_PlaceCursor()

void Shop_PlaceCursor ( struct UiWindow * window,
s32 x,
s32 y )

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

Called by every counter's lists.

Definition at line 273 of file cursor.c.

Referenced by Sanctum_RunPartyService(), Shop_BuySpecialItem(), Shop_PickUnit(), Shop_PickUnitItem(), Shop_PlaceCursor(), Shop_SelectBuy(), Shop_SelectBuyNum(), Shop_SelectRepair(), Shop_SelectSell(), Shop_SelectSellNum(), and Shop_SelectUse().

Variable Documentation

◆ sSelectorTileOffsets

const u16 sSelectorTileOffsets[30]
static
Initial value:
= {
0x00, 0x01, 0x02, 0x03,
0x20, 0x21, 0x22, 0x23,
0x40, 0x41, 0x42, 0x43,
0x60, 0x61, 0x62, 0x63,
0x80, 0x81, 0x82, 0x83,
0xa0, 0xa1, 0xa2, 0xa3,
0xc0, 0xc1, 0xc2, 0xc3,
0xe0, 0xe1,
}

Where each of the quantity bar's 30 segments starts in its tile buffer.

Definition at line 9 of file cursor.c.

Referenced by Shop_FillSelector().

◆ sPriceDigitTileOffsets

const u16 sPriceDigitTileOffsets[5]
static
Initial value:
= {
0xc0, 0x90, 0x80, 0x50, 0x40,
}

Where each of a price's five digits starts in its tile buffer, ones first.

Definition at line 48 of file cursor.c.

Referenced by Shop_CopyGlyphs().