Skip to Content
The Alchemy Project

src/window/screens_menu_titles.c

The pictures the menus show: the headings and command icons, with their bob and pulse, the range icons of the battle lists, the page arrows, icons and portraits loaded into the VRAM cache, the link battle timer's window, and the battle command row's icons on BG1 with its priority. More…

Included by screens.c.

Macros

NameDescription
#defineCOMMAND_ICON_TILE_ROW_BYTES (4 * TILE_SIZE_8BPP)A row of a command icon's 8x8 tiles, four across, as a sprite holds them.
#defineRANGE_PATTERN_SET_COUNT 2The range icons' two sets of six, each a pair of tiles (16 words).
#defineRANGE_PATTERN_COUNT 6
#defineRANGE_PATTERN_PAIR_WORDS 16
#defineRANGE_ICON_FIRST_TILE 788The first of the range icons' BG tiles, which mnRangeIconDraw draws as tilemap entries.
#defineROW_LAST_PIXEL_SHIFT 28A 4bpp tile row's eighth pixel, in the top four bits of its word.
#defineLINK_COUNTDOWN_DRAW_HEADINGHow the link timer's heading is drawn: Spanish and French at a pixel offset (mnTextDrawStringAtOffset), the others one tile a character (mnTextDrawStringInWindow).
#defineCOMMAND_ICON_COLORS 64The command icons on BG1 share at most COMMAND_ICON_COLORS BG colours, given out in the order their pixels first use them; a colour met after that takes colour COMMAND_ICON_COLORS.
#defineCOMMAND_ICON_BG_TILES (COMMAND_ICON_BYTES / TILE_SIZE_8BPP)A command icon as BG1 tiles: 32 by 32 pixels, 16 tiles of 256 colours.

Functions

NameDescription
voidmnTitleLoad (Sint32 picture, Sint32 slot)Decompresses picture picture of MenuTitlePictures, a 64x16 heading (Save, Continue, Copy, Erase, Battle, Link, Pause, Setup) of 512 bytes, into VRAM slot slot, through a 1 KB staging block in HEAP_SLOT_TILE_SCRATCH.
WINDOW_SPR *mnTitleCreate (Sint32 picture, WINDOW *window, Sint32 x, Sint32 y)Shows heading picture of MenuTitlePictures as two 32x16 sprites side by side at (x, y) in window, on draw layer 253, and returns the left one (the right one follows it in the window's list).
voidmnTitleBob (WINDOW_SPR *sprite)Bobs the two sprites of a pair (see mnTitleCreate) up and down by MenuTitleBobOffsets, one step every four ticks.
voidmnCommandIconLoad (Sint32 icon, Sint32 slot, Sint32 remap)Decompresses command icon icon (a 32x32 picture of 256 colours, 1 KB) into VRAM slot slot, remapping the colours of its top three rows of tiles by table when remap is nonzero.
WINDOW_SPR *mnCommandIconCreate ( Sint32 icon, Sint32 remap, WINDOW *window, Sint32 x, Sint32 y)Shows command icon icon (see mnCommandIconLoad) as a 32x32 256-colour sprite at (x, y) in window, on draw layer 251.
voidmnWindowSpritePulse (WINDOW_SPR *sprite)Makes sprite pulse: scales it about its centre by WindowSpritePulseScales (in 1/65536, used in 1/256), one step every two ticks, and puts it on draw layer 252.
UNREAD_RESULTmnRangeIconBuildTiles (void)Builds the twelve range icons the battle lists draw beside an ability (mnRangeIconDraw), each a row of bars, as the 24 BG tiles from RANGE_ICON_FIRST_TILE: icon n is a centre tile and an end tile, filled with WINDOW_BACKGROUND_COLOR, then marked row by row by XOR with MenuBarPatternRows (its colour 5 turns the fill to colour 1).
UNREAD_RESULTmnRangeIconDraw ( WINDOW *window, Sint32 x, Sint32 y, Sint32 pattern, Sint32 unused)Draws range icon pattern, how many targets an ability reaches, across tiles (x, y) to (x + 2, y) of window's interior: its end tile mirrored, its centre tile and its end tile, in the UI palette.
voidmnGraphicsMergeShiftedTileRows (Uint32 *first, Uint32 *second, Uint32 *output, Sint32 shift)Merges two 8x8 4bpp tiles row by row into output: second moved shift pixels (right when positive, left when negative), drawn over first, which shows wherever the moved pixel is colour 0.
voidmnPageArrowsDraw (Sint32 offset)Draws the two page arrows (PageArrowTiles) into the two tiles at VRAM address offset, sliding outward: the left arrow 2 or 3 pixels to the left, the right one as far to the right, eight ticks each.
voidmnGraphicsExpandVRAMTilesByColorTable (Uint16 *dest)Copies the UI's ten digit tiles ('0' to '9', tiles 48 to 57) twice into dest, each pixel mapped through GraphicsExpandNibbleTable: first with colour 1 drawn as colour 10, then unchanged.
Sint32mnStatusIconLoadIntoSlot (Sint32 resource, Sint32 index)Builds icon resource (0 to 31) of IconMiscellaneousIconPointers, the table the status icons come from (mnIconDrawMiscellaneous), in a transfer block taken from HEAP_SLOT_ICON_TRANSFER, reloads VRAM cache entry index with it and returns the entry's first tile.
Sint32mnItemIconLoadIntoSlot (Sint32 resource, Sint32 index)Builds the icon of inventory item resource (the count above one and both marks) in a transfer block taken from HEAP_SLOT_ICON_TRANSFER, reloads VRAM cache entry index with it and returns the entry's first tile.
Sint32mnAbilityIconLoadIntoSlot (Sint32 resource, Sint32 index)Builds the icon of ability resource in a transfer block taken from HEAP_SLOT_ICON_TRANSFER, reloads VRAM cache entry index with it and returns the entry's first tile.
Sint32mnPortraitLoad (Uint32 member, Sint32 cacheSlot)Loads the portrait of character member (ISAAC to PIERS, 0 to 7; any higher value shows Isaac's) into VRAM cache entry cacheSlot, in PORTRAIT_PALETTE, and returns its first tile.
Sint32mnWindowSpriteGetPointerTiles (Sint32 index)Returns WindowSpritePointerTiles[0], whatever index is.
voidmnIconDecompress (ICON_TRANSFER *state)Copies the 4bpp decoder into RAM, calls it with the transfer's encoded source and byte buffer, then releases the copied code.
WINDOW *mnLinkCreateCountdownLabelWindow (void)Opens the link battle timer's window, 6 by 4 tiles at the top left, with its heading (LinkTimeLabelString), and returns it; the seconds go under the heading (mnBattleMenuUpdate), which keeps the window in BATTLE_MENU_STATE.timerWindow until the commands are chosen.
Sint32mnCommandIconReloadSlot (Sint32 slotIndex, Sint32 icon)Decodes command icon icon (ResourceIdCommandIcons, 1 KB of 256-colour pixels) in a block taken from HEAP_SLOT_ICON_TRANSFER, reloads VRAM cache entry slotIndex with it and returns the entry's first tile.
voidmnBattleCommandRowLoadIconTiles (ICON_PALETTE *palette, Sint32 icon, Sint32 tile)Loads command icon icon for the battle command row on BG1: COMMAND_ICON_BG_TILES 8bpp tiles in character block 1 from tile tile, its colours given out from the BG colours the row's icons share (palette, COMMAND_ICON_COLORS).
voidmnBattleCommandRowLoadIcon (BATTLE_COMMAND_ROW_STATE *state, Sint32 index, Uint32 icon)Loads the command row's icon index as command icon icon: as BG1 tiles from tile index * COMMAND_ICON_BG_TILES (mnBattleCommandRowLoadIconTiles), and into the row's shared VRAM cache entry for its 32x32 sprite, which mnBattleCommandRowRun shows only for the selected icon.
voidmnCommandRowPutBg1Behind (void)Puts BG1 behind the other layers (priority 3).
voidmnCommandRowPutBg1InFront (void)Brings BG1 to the front (priority 0): the command row's VCount handler, run at line COMMAND_ROW_TOP * 8, the top of its icon strip.
voidmnGraphicsInstallBg1VCountHandler (void)Clears BG0's vertical scroll (REG_BG0VOFS) and installs mnCommandRowPutBg1InFront as the VCount handler at line COMMAND_ROW_TOP * 8, as the command row does.

Description

The pictures the menus show: the headings and command icons, with their bob and pulse, the range icons of the battle lists, the page arrows, icons and portraits loaded into the VRAM cache, the link battle timer's window, and the battle command row's icons on BG1 with its priority. Part of screens.c.

Macros in detail

COMMAND_ICON_TILE_ROW_BYTES

#define COMMAND_ICON_TILE_ROW_BYTES (4 * TILE_SIZE_8BPP)

A row of a command icon's 8x8 tiles, four across, as a sprite holds them.

Referenced by mnCommandIconLoad().

Definition at line 7 of file screens_menu_titles.c.

RANGE_PATTERN_SET_COUNT

#define RANGE_PATTERN_SET_COUNT 2

The range icons' two sets of six, each a pair of tiles (16 words).

Referenced by mnRangeIconBuildTiles().

Definition at line 132 of file screens_menu_titles.c.

RANGE_PATTERN_COUNT

#define RANGE_PATTERN_COUNT 6

Referenced by mnRangeIconBuildTiles().

Definition at line 133 of file screens_menu_titles.c.

RANGE_PATTERN_PAIR_WORDS

#define RANGE_PATTERN_PAIR_WORDS 16

Referenced by mnRangeIconBuildTiles().

Definition at line 134 of file screens_menu_titles.c.

RANGE_ICON_FIRST_TILE

#define RANGE_ICON_FIRST_TILE 788

The first of the range icons' BG tiles, which mnRangeIconDraw draws as tilemap entries.

Referenced by mnRangeIconBuildTiles() and mnRangeIconDraw().

Definition at line 137 of file screens_menu_titles.c.

ROW_LAST_PIXEL_SHIFT

#define ROW_LAST_PIXEL_SHIFT 28

A 4bpp tile row's eighth pixel, in the top four bits of its word.

Referenced by mnGraphicsMergeShiftedTileRows().

Definition at line 210 of file screens_menu_titles.c.

#define LINK_COUNTDOWN_DRAW_HEADING

How the link timer's heading is drawn: Spanish and French at a pixel offset (mnTextDrawStringAtOffset), the others one tile a character (mnTextDrawStringInWindow).

Referenced by mnLinkCreateCountdownLabelWindow().

Definition at line 446 of file screens_menu_titles.c.

COMMAND_ICON_COLORS

#define COMMAND_ICON_COLORS 64

The command icons on BG1 share at most COMMAND_ICON_COLORS BG colours, given out in the order their pixels first use them; a colour met after that takes colour COMMAND_ICON_COLORS. A ICON_PALETTE slot holds ICON_PALETTE_SLOT_UNSET until its colour is given out.

Referenced by mnBattleCommandRowLoadIconTiles().

Definition at line 489 of file screens_menu_titles.c.

COMMAND_ICON_BG_TILES

#define COMMAND_ICON_BG_TILES (COMMAND_ICON_BYTES / TILE_SIZE_8BPP)

A command icon as BG1 tiles: 32 by 32 pixels, 16 tiles of 256 colours.

Referenced by mnBattleCommandRowLoadIcon().

Definition at line 491 of file screens_menu_titles.c.

Functions in detail

mnTitleLoad

void mnTitleLoad(Sint32 picture, Sint32 slot)

Decompresses picture picture of MenuTitlePictures, a 64x16 heading (Save, Continue, Copy, Erase, Battle, Link, Pause, Setup) of 512 bytes, into VRAM slot slot, through a 1 KB staging block in HEAP_SLOT_TILE_SCRATCH.

References MenuTitlePictures, Sint32, syDecompressByteLZ(), syHeapSlotAllocateEWRAM(), syHeapSlotRelease() and syVRAMCacheLoad().

Referenced by mnTitleCreate().

Definition at line 12 of file screens_menu_titles.c.

mnTitleCreate

WINDOW_SPR *mnTitleCreate(Sint32 picture, WINDOW *window, Sint32 x, Sint32 y)

Shows heading picture of MenuTitlePictures as two 32x16 sprites side by side at (x, y) in window, on draw layer 253, and returns the left one (the right one follows it in the window's list).

References mnTitleLoad(), mnWindowSpriteCreate(), Sint32 and syVRAMCacheFindFreeEntry().

Referenced by mnFileListSelectFile(), mnPauseMenuChoose() and mnSettingsMenuRun().

Definition at line 28 of file screens_menu_titles.c.

mnTitleBob

void mnTitleBob(WINDOW_SPR *sprite)

Bobs the two sprites of a pair (see mnTitleCreate) up and down by MenuTitleBobOffsets, one step every four ticks.

References FrameCount, MenuTitleBobOffsets and Sint32.

Referenced by mnFileListSelectFile(), mnPauseMenuChoose() and mnSettingsMenuRun().

Definition at line 52 of file screens_menu_titles.c.

mnCommandIconLoad

void mnCommandIconLoad(Sint32 icon, Sint32 slot, Sint32 remap)

Decompresses command icon icon (a 32x32 picture of 256 colours, 1 KB) into VRAM slot slot, remapping the colours of its top three rows of tiles by table when remap is nonzero.

References fdSpriteColorRemapPixelsStub(), Sint32, syDecompressByteLZ(), syHeapSlotAllocateEWRAM(), syHeapSlotRelease(), syResourceGetTableEntry() and syVRAMCacheLoad().

Referenced by mnCommandIconCreate(), mnPauseMenuChoose() and mnSettingsMenuRun().

Definition at line 69 of file screens_menu_titles.c.

mnCommandIconCreate

WINDOW_SPR *mnCommandIconCreate( Sint32 icon, Sint32 remap, WINDOW *window, Sint32 x, Sint32 y)

Shows command icon icon (see mnCommandIconLoad) as a 32x32 256-colour sprite at (x, y) in window, on draw layer 251.

References mnCommandIconLoad(), mnWindowSpriteCreate(), Sint32 and syVRAMCacheFindFreeEntry().

Referenced by mnPauseMenuOpen() and mnSettingsMenuOpen().

Definition at line 88 of file screens_menu_titles.c.

mnWindowSpritePulse

void mnWindowSpritePulse(WINDOW_SPR *sprite)

Makes sprite pulse: scales it about its centre by WindowSpritePulseScales (in 1/65536, used in 1/256), one step every two ticks, and puts it on draw layer 252.

References FrameCount, Sint32, syOAMMatrixAllocateFromTransform() and WindowSpritePulseScales.

Referenced by mnPauseMenuAnimateCursor() and mnSettingsMenuAnimateCursors().

Definition at line 110 of file screens_menu_titles.c.

mnRangeIconBuildTiles

UNREAD_RESULT mnRangeIconBuildTiles(void)

Builds the twelve range icons the battle lists draw beside an ability (mnRangeIconDraw), each a row of bars, as the 24 BG tiles from RANGE_ICON_FIRST_TILE: icon n is a centre tile and an end tile, filled with WINDOW_BACKGROUND_COLOR, then marked row by row by XOR with MenuBarPatternRows (its colour 5 turns the fill to colour 1). Pattern p of either set has 2p + 1 bars; the first set steps them down from the tallest at the centre, the second draws them all one height, a row shorter than that centre bar.

References MenuBarPatternRows, mnXorWord(), Sint32 and syWordsFill().

Referenced by mnBattleCollectPartyCommands().

Definition at line 147 of file screens_menu_titles.c.

mnRangeIconDraw

UNREAD_RESULT mnRangeIconDraw( WINDOW *window, Sint32 x, Sint32 y, Sint32 pattern, Sint32 unused)

Draws range icon pattern, how many targets an ability reaches, across tiles (x, y) to (x + 2, y) of window's interior: its end tile mirrored, its centre tile and its end tile, in the UI palette.

References mnWindowSetTilemapEntry() and Sint32.

Referenced by mnBattleDjinnMenuShowChangePreview() and mnBattlePsynergyMenuRun().

Definition at line 194 of file screens_menu_titles.c.

mnGraphicsMergeShiftedTileRows

void mnGraphicsMergeShiftedTileRows(Uint32 *first, Uint32 *second, Uint32 *output, Sint32 shift)

Merges two 8x8 4bpp tiles row by row into output: second moved shift pixels (right when positive, left when negative), drawn over first, which shows wherever the moved pixel is colour 0.

References pixel and Sint32.

Referenced by mnPageArrowsDraw().

Definition at line 215 of file screens_menu_titles.c.

mnPageArrowsDraw

void mnPageArrowsDraw(Sint32 offset)

Draws the two page arrows (PageArrowTiles) into the two tiles at VRAM address offset, sliding outward: the left arrow 2 or 3 pixels to the left, the right one as far to the right, eight ticks each.

References mnGraphicsMergeShiftedTileRows(), PageArrowTiles, Sint32 and TickCount.

Referenced by mnBattleCollectPartyCommands(), mnBattleMenuUpdate() and scInit().

Definition at line 263 of file screens_menu_titles.c.

mnGraphicsExpandVRAMTilesByColorTable

void mnGraphicsExpandVRAMTilesByColorTable(Uint16 *dest)

Copies the UI's ten digit tiles ('0' to '9', tiles 48 to 57) twice into dest, each pixel mapped through GraphicsExpandNibbleTable: first with colour 1 drawn as colour 10, then unchanged.

References GraphicsExpandNibbleTable and Sint32.

Referenced by mnBattleCollectPartyCommands() and scInit().

Definition at line 296 of file screens_menu_titles.c.

mnStatusIconLoadIntoSlot

Sint32 mnStatusIconLoadIntoSlot(Sint32 resource, Sint32 index)

Builds icon resource (0 to 31) of IconMiscellaneousIconPointers, the table the status icons come from (mnIconDrawMiscellaneous), in a transfer block taken from HEAP_SLOT_ICON_TRANSFER, reloads VRAM cache entry index with it and returns the entry's first tile.

References mnIconDrawMiscellaneous(), Sint32, state, syHeapSlotAllocateEWRAM(), syHeapSlotRelease() and syVRAMCacheReload().

Referenced by mnBattleStatusScreenRun().

Definition at line 349 of file screens_menu_titles.c.

mnItemIconLoadIntoSlot

Sint32 mnItemIconLoadIntoSlot(Sint32 resource, Sint32 index)

Builds the icon of inventory item resource (the count above one and both marks) in a transfer block taken from HEAP_SLOT_ICON_TRANSFER, reloads VRAM cache entry index with it and returns the entry's first tile.

References mnItemIconCompose(), Sint32, state, syHeapSlotAllocateEWRAM(), syHeapSlotRelease() and syVRAMCacheReload().

Referenced by mnBattleCollectPartyCommands() and mnBattleItemMenuRun().

Definition at line 364 of file screens_menu_titles.c.

mnAbilityIconLoadIntoSlot

Sint32 mnAbilityIconLoadIntoSlot(Sint32 resource, Sint32 index)

Builds the icon of ability resource in a transfer block taken from HEAP_SLOT_ICON_TRANSFER, reloads VRAM cache entry index with it and returns the entry's first tile.

References mnAbilityBuildIconTiles(), Sint32, state, syHeapSlotAllocateEWRAM(), syHeapSlotRelease() and syVRAMCacheReload().

Referenced by mnBattleCollectPartyCommands() and mnWindowSpriteCreateAbilityIcon().

Definition at line 380 of file screens_menu_titles.c.

mnPortraitLoad

Sint32 mnPortraitLoad(Uint32 member, Sint32 cacheSlot)

Loads the portrait of character member (ISAAC to PIERS, 0 to 7; any higher value shows Isaac's) into VRAM cache entry cacheSlot, in PORTRAIT_PALETTE, and returns its first tile.

References gmFlagGetStub(), mnIconLoadWithPalette() and Sint32.

Referenced by mnBattleCollectPartyCommands() and mnBattleStatusScreenRun().

Definition at line 398 of file screens_menu_titles.c.

mnWindowSpriteGetPointerTiles

Sint32 mnWindowSpriteGetPointerTiles(Sint32 index)

Returns WindowSpritePointerTiles[0], whatever index is. The battle engine's prompt reads it by stub call (btMessageWaitForAdvanceAt).

References Sint32 and WindowSpritePointerTiles.

Definition at line 424 of file screens_menu_titles.c.

mnIconDecompress

void mnIconDecompress(ICON_TRANSFER *state)

Copies the 4bpp decoder into RAM, calls it with the transfer's encoded source and byte buffer, then releases the copied code.

References HeapSlots, mnTileDecompress4bpp, state, syHeapSlotRelease() and TileDecompress4bppCodeSize.

Definition at line 433 of file screens_menu_titles.c.

mnLinkCreateCountdownLabelWindow

WINDOW *mnLinkCreateCountdownLabelWindow(void)

Opens the link battle timer's window, 6 by 4 tiles at the top left, with its heading (LinkTimeLabelString), and returns it; the seconds go under the heading (mnBattleMenuUpdate), which keeps the window in BATTLE_MENU_STATE.timerWindow until the commands are chosen.

References LinkTimeLabelString and mnWindowCreate().

Referenced by mnBattleMenuUpdate().

Definition at line 458 of file screens_menu_titles.c.

mnCommandIconReloadSlot

Sint32 mnCommandIconReloadSlot(Sint32 slotIndex, Sint32 icon)

Decodes command icon icon (ResourceIdCommandIcons, 1 KB of 256-colour pixels) in a block taken from HEAP_SLOT_ICON_TRANSFER, reloads VRAM cache entry slotIndex with it and returns the entry's first tile.

References Sint32, syDecompressByteLZ(), syHeapSlotAllocate(), syHeapSlotRelease(), syResourceGetTableEntry() and syVRAMCacheReload().

Referenced by mnBattleCollectPartyCommands() and mnBattleCommandRowLoadIcon().

Definition at line 469 of file screens_menu_titles.c.

mnBattleCommandRowLoadIconTiles

void mnBattleCommandRowLoadIconTiles(ICON_PALETTE *palette, Sint32 icon, Sint32 tile)

Loads command icon icon for the battle command row on BG1: COMMAND_ICON_BG_TILES 8bpp tiles in character block 1 from tile tile, its colours given out from the BG colours the row's icons share (palette, COMMAND_ICON_COLORS).

References Sint32, syDecompressByteLZ(), syDMAXCopy(), syHeapAllocate(), syHeapRelease(), syHeapSlotAllocate(), syHeapSlotRelease() and syResourceGetTableEntry().

Referenced by mnBattleCommandRowLoadIcon().

Definition at line 497 of file screens_menu_titles.c.

mnBattleCommandRowLoadIcon

void mnBattleCommandRowLoadIcon(BATTLE_COMMAND_ROW_STATE *state, Sint32 index, Uint32 icon)

Loads the command row's icon index as command icon icon: as BG1 tiles from tile index * COMMAND_ICON_BG_TILES (mnBattleCommandRowLoadIconTiles), and into the row's shared VRAM cache entry for its 32x32 sprite, which mnBattleCommandRowRun shows only for the selected icon.

References mnBattleCommandRowLoadIconTiles(), mnCommandIconReloadSlot(), Sint32 and state.

Referenced by mnBattleCommandRowRun().

Definition at line 543 of file screens_menu_titles.c.

mnCommandRowPutBg1Behind

void mnCommandRowPutBg1Behind(void)

Puts BG1 behind the other layers (priority 3).

Referenced by mnBattleCommandRowRun().

Definition at line 558 of file screens_menu_titles.c.

mnCommandRowPutBg1InFront

void mnCommandRowPutBg1InFront(void)

Brings BG1 to the front (priority 0): the command row's VCount handler, run at line COMMAND_ROW_TOP * 8, the top of its icon strip.

Referenced by mnBattleCommandRowRun() and mnGraphicsInstallBg1VCountHandler().

Definition at line 569 of file screens_menu_titles.c.

mnGraphicsInstallBg1VCountHandler

void mnGraphicsInstallBg1VCountHandler(void)

Clears BG0's vertical scroll (REG_BG0VOFS) and installs mnCommandRowPutBg1InFront as the VCount handler at line COMMAND_ROW_TOP * 8, as the command row does. Nothing calls it.

References mnCommandRowPutBg1InFront() and syIntFunction().

Definition at line 580 of file screens_menu_titles.c.