Skip to Content
The Alchemy Project

include/graphics/graphics.h

What the graphics module holds for the rest of the game: fonts, icons, cursors, the name entry keyboards, the transitions' tables and the ARM functions that decode and draw pictures. More…

Included by battle_internal.h, battle_effect_internal.h, field_engine_internal.h, field_internal.h, game_internal.h, credits.c, menu_internal.h, menu_pattern_masks.c, title_intro.c, alpine_crossing_lama_temple.c, altin.c, altin_peak.c, altmiller_cave.c, babi_lighthouse.c, babi_palace.c, battle_arena.c, bilibin.c, bilibin_cave.c, colosseum_azart_match.c, colosseum_entrance.c, colosseum_navampa_match.c, colosseum_satrage_match.c, cottage_rooms_b.c, cottage_rooms_c.c, crossbone_isle.c, crossbone_isle_keys.c, crossbone_isle_stepping_stones.c, file_screen.c, fuchin_temple.c, goma_cave_entrance.c, goma_cave_pillar.c, goma_cave_pond.c, goma_cave_stream.c, gondowan_cave.c, hammet_palace.c, imil.c, imil_fuchin_falls.c, kalay.c, kalay_tolbi_docks.c, kolima.c, kolima_forest_cliff.c, kolima_forest_entrance.c, kolima_forest_floodgate.c, kolima_forest_glade.c, kolima_forest_tree.c, lacquer_rooms_b.c, lalivero.c, lamakan_desert.c, lemurian_ship.c, log_rooms_a.c and 53 more.

Structures

NameDescription
structTILE_MASKOne row's masks for a pair of bar-pattern tiles: a word XORed into each tile's row.

Macros

NameDescription
#defineOFFSCREEN_TILE 511The map entry a screen-wide picture gives each row's two columns past the screen's edge, which never show.
#defineLOGO_PALETTE_COLORS 224The colours a screen-wide 256-colour picture resource opens with, before its packed tiles: the publisher's, Camelot's and Golden Sun's logos' and the To Be Continued pictures'.
#definePartyStatusState (*(Uint8 (*)[]) & HeapSlots[HEAP_SLOT_PARTY_STATUS])HEAP_SLOT_PARTY_STATUS: the party status window's layout (struct PARTY_STAT_WINDOW), right after WindowStateWork in IWRAM.
#defineSelectionStateWorkHEAP_SLOT_SELECTION_STATE: SELECTION_STATE, which only two unused functions touch.
#definePaletteCycleStateWorkHEAP_SLOT_PALETTE_CYCLES: the queue of palette cycles, which no code in the game ever starts.
#defineSpritesWork (*(struct SPR **)&HeapSlots[HEAP_SLOT_SPRITES])HEAP_SLOT_SPRITES: the actor system's sprite pool, which the field animation and the sprite viewer walk.

Functions

NameDescription
static __inline__ Uint32mnXorWord (Uint32 word, Uint32 mask)One row of a tile XORed with a row's mask: how mnBuildPatternTiles and mnRangeIconBuildTiles mark each tile of a pair, at all four of their XORs, as The Lost Age's twins do (window/screens.h).
Sint32btStubsBattleEffect (Sint32 slot, Sint32 widthShift, Sint32 heightShift, Sint32 flags, Uint32 mode)The battle effect module's stub table, declared as a function so that a call reaches its first stub, btEffectBuildBlitterStub; nothing in this game calls it by this name.

Variables

NameDescription
extern Uint8PageArrowTiles []The two page arrow tiles, 4bpp, that mnPageArrowsDraw slides outward over the border's top edge.
extern Sint32WindowSpritePointerTiles []A one-entry table of sprite tiles: the pointing hand cursor (PointingHandTiles), returned by mnWindowSpriteGetPointerTiles.
extern Uint8 *ItemIcons []The compressed item icons, indexed by an item's icon field.
extern Uint8 *ItemIconsEnd []The end of ItemIcons, so mnIconCountItemIcons can count them.
extern Uint8 *IconMiscellaneousIconPointers []The other compressed icons, among them the Status screen's status icons.
extern Uint8 *PsynergyIcons []The compressed Psynergy icons, drawn over the shared icon base.
extern Uint8 *PsynergyIconsEnd []The end of PsynergyIcons, for mnIconCountPsynergyIcons.
extern const TILE_MASKMenuBarPatternRows []The six row patterns that mark the battle menus' range icons, colour 5 over a colour-4 fill, read by mnRangeIconBuildTiles.
extern const TILE_MASKMenuPatternRowMasks []The row masks mnBuildPatternTiles XORs into the range icons' tile pairs (menu_pattern_masks.c).
extern const Uint8CreditsFont []The credits' 8x8 one-bit font, ASCII 32 to 127.
extern const Uint16GraphicsExpandNibbleTable []Two 16-entry colour maps for 4bpp pixels: the first draws colour 1 as colour 10, the second leaves every colour as it is.
extern const Uint8MenuCursorActorTiles []The right-pointing arrow cursor, an 8x16 sprite of 256 colours, beside its left-pointing twin.
extern const Uint8fdRenderDecodePictureEnd []224 zeroed bytes right after fdRenderDecodePicture's code and tables; its address ends the stretch the field sprites' draw copies to RAM.
extern Uint8PointingHandTiles []The pointing hand cursor, a 16x16 sprite, shared by the battle menus, the name entry screen and the talk choices.
extern const Uint8mnCreditsDecodeBackground []Decodes a credits slide's packed picture into 8bpp tiles, adding a palette offset to each pixel; it relocates its own command table wherever it's copied.
extern Uint8CreditsDecodeBackgroundCodeSize []mnCreditsDecodeBackground with its command table, copied into HEAP_SLOT_RAM_CODE_TEMP for each slide.
extern const Uint8TextDecodeSymbol []Decodes one Huffman-coded symbol of a message for a MESSAGE_READER.
extern Uint8TextDecodeSymbolCodeSize []TextDecodeSymbol, which the message decoders copy into HEAP_SLOT_MESSAGE_DECODER.
extern Uint8mnScanlineWindowBuildEdgesCodeSize []mnScanlineWindowBuildEdges, copied to the heap by mnScanlineWindowFillSpans for each tick of a window transition.
extern const Uint8fdTileConvertMapGrid []Interleaves a layout's three decoded cell planes into cell words, for fdTileMapConvertBuffer.
extern Uint8fdTileConvertMapGridCodeSize []fdTileConvertMapGrid, which fdTileMapConvertBuffer runs from a heap copy.
extern const Uint8mnTileDecompress4bpp []Unpacks a compressed icon into a glyph transfer's input buffer.
extern Uint8TileDecompress4bppCodeSize []mnTileDecompress4bpp, which mnIconDecode copies into HEAP_SLOT_RAM_CODE_TEMP.
extern const Uint8mnTileExpandMasked []Packs an unpacked icon into 4bpp tiles over the layers already drawn there.
extern Uint8TileExpandMaskedCodeSize []mnTileExpandMasked, which mnIconDecode loads for an icon's upper layers.
extern const Uint8mnTileExpandOpaque []Packs an unpacked icon into 4bpp tiles, overwriting every pixel.
extern Uint8TileExpandOpaqueCodeSize []mnTileExpandOpaque, which mnIconDecode loads for an icon's first layer.
extern const Uint8TitlePromptTiles []The title screen's "Press Start" prompt, byte-LZ compressed, in each language.
extern const Sint32WindowSpritePulseScales []The eight scales, in 1/65536, that mnWindowSpritePulse pulses the settings menu's selected icon through.
extern const Uint8MenuTitleBobOffsets []The pixel offsets mnTitleBob moves a sprite pair up and down by.
extern Uint8 *IconDigitPointers []The icon count's digits: 0 to 9, then the tens 1 to 3.
extern Uint8 *IconBasePointerTable []The three icon bases; base 2 is the one item and Psynergy icons share.
extern Uint8 *IconMarkPointers []The three marks mnItemIconCompose draws over an item icon: 0 on a broken item, 1 on an equipped one and 2 on a cursed one.
extern Uint8 *IconOverlayPointerTable []The command icons' overlays, all 43 entries the same picture.
extern Uint8IconResourceTiles []The menus' hand cursor and gem, 16x16 4bpp sprites; the hand is loaded by mnIconCreateHandCursor.
extern const Sint8WindowSpriteBounceOffsets []Pixels: the hop a window's sprite makes, one step a tick.
extern const Uint8WindowSpritePageArrowTiles []The animated page arrow's pictures, 8x16 sprites of 256 colours, 128 bytes each.
extern const Sint8WindowSpriteWobbleOffsets [][2]Pixels: the x and y a window's wobbling sprite is moved by, one step every other tick.
extern const Uint8FontColorPens []For each of the 16 text colours, the pen the font's light shade takes in the UI palette.
extern Uint8mnGlyphDrawCodeSize []mnGlyphDrawArm, copied to the heap for each character drawn.
extern const Uint8FontGlyphWidths []Each main font glyph's width in pixels, from the space (32) on.
extern const Uint8mnMessageFindArm []Points a MESSAGE_READER at a message's compressed bits and first context.
extern Uint8mnMessageFindCodeSize []mnMessageFindArm; mnMessageFind frees its copy on return.
extern const Sint8WindowPartyColumnOffsets []The party status window's column lines, ended by -1: the Djinn column's first, then one between members.

Description

What the graphics module holds for the rest of the game: fonts, icons, cursors, the name entry keyboards, the transitions' tables and the ARM functions that decode and draw pictures. The screen fade's state and the system library's own decoders belong to the system library (system/globals.h).

Many of the functions declared here are handwritten ARM code that the game never runs where it lies: each loader copies it to RAM first, with RAM_CODE_LOAD or RAM_CODE_LOAD_SLOT (system.h) or a DMA into a stack array, and calls the copy. Such a function is declared as an array of bytes. A symbol ending in CodeSize is the length in bytes of the code the loader copies: it is not an object, but an address the linker sets equal to the length (in the function's assembly file, or ld_script.ld where the end is the next function), so the loader reads it by casting it to a number.

Macros in detail

OFFSCREEN_TILE

#define OFFSCREEN_TILE 511

The map entry a screen-wide picture gives each row's two columns past the screen's edge, which never show.

Referenced by mnTitleLoadIntroBackgrounds(), mnTitleShowPublisherLogo(), mnTitleShowTitleScreen(), scFileScreenLoadBackground() and scTitleLoadBackground().

Definition at line 25 of file graphics.h.

LOGO_PALETTE_COLORS

#define LOGO_PALETTE_COLORS 224

The colours a screen-wide 256-colour picture resource opens with, before its packed tiles: the publisher's, Camelot's and Golden Sun's logos' and the To Be Continued pictures'.

Referenced by scFileScreenLoadBackground(), scTitleLoadBackground() and scTitleLoadSprites().

Definition at line 29 of file graphics.h.

PartyStatusState

#define PartyStatusState (*(Uint8 (*)[]) & HeapSlots[HEAP_SLOT_PARTY_STATUS])

HEAP_SLOT_PARTY_STATUS: the party status window's layout (struct PARTY_STAT_WINDOW), right after WindowStateWork in IWRAM.

Definition at line 55 of file graphics.h.

SelectionStateWork

#define SelectionStateWork

HEAP_SLOT_SELECTION_STATE: SELECTION_STATE, which only two unused functions touch.

Referenced by mnReleaseSelectionState().

Definition at line 58 of file graphics.h.

PaletteCycleStateWork

#define PaletteCycleStateWork

HEAP_SLOT_PALETTE_CYCLES: the queue of palette cycles, which no code in the game ever starts.

Referenced by fdPaletteCycleAdd() and fdPaletteCycleStep().

Definition at line 88 of file graphics.h.

SpritesWork

#define SpritesWork (*(struct SPR **)&HeapSlots[HEAP_SLOT_SPRITES])

HEAP_SLOT_SPRITES: the actor system's sprite pool, which the field animation and the sprite viewer walk.

Referenced by fdSpriteCreate(), fdSpriteViewerLayOutRing(), fdSpriteViewerPlaceRing(), fdSpriteViewerRun(), fdSpriteViewerSetLayerSprite() and fdSpriteViewerStartStaggeredAnimations().

Definition at line 95 of file graphics.h.

Functions in detail

mnXorWord

static __inline__ Uint32 mnXorWord(Uint32 word, Uint32 mask)

One row of a tile XORed with a row's mask: how mnBuildPatternTiles and mnRangeIconBuildTiles mark each tile of a pair, at all four of their XORs, as The Lost Age's twins do (window/screens.h).

Referenced by mnBuildPatternTiles() and mnRangeIconBuildTiles().

Definition at line 79 of file graphics.h.

btStubsBattleEffect

Sint32 btStubsBattleEffect(Sint32 slot, Sint32 widthShift, Sint32 heightShift, Sint32 flags, Uint32 mode)

The battle effect module's stub table, declared as a function so that a call reaches its first stub, btEffectBuildBlitterStub; nothing in this game calls it by this name.

Definition at line 182 of file graphics.h.

Variables in detail

PageArrowTiles

extern Uint8 PageArrowTiles[]

The two page arrow tiles, 4bpp, that mnPageArrowsDraw slides outward over the border's top edge.

Referenced by mnPageArrowsDraw().

Definition at line 33 of file graphics.h.

ItemIcons

extern Uint8 *ItemIcons[]

The compressed item icons, indexed by an item's icon field.

Referenced by mnIconBuildItemIconTiles(), mnIconCountItemIcons(), mnIconDrawItem() and mnItemIconCompose().

Definition at line 38 of file graphics.h.

ItemIconsEnd

extern Uint8 *ItemIconsEnd[]

The end of ItemIcons, so mnIconCountItemIcons can count them.

Referenced by mnIconCountItemIcons().

Definition at line 40 of file graphics.h.

IconMiscellaneousIconPointers

extern Uint8 *IconMiscellaneousIconPointers[]

The other compressed icons, among them the Status screen's status icons.

Referenced by mnIconDrawMiscellaneous().

Definition at line 42 of file graphics.h.

PsynergyIcons

extern Uint8 *PsynergyIcons[]

The compressed Psynergy icons, drawn over the shared icon base.

Referenced by mnIconBuildAbilityIconTiles() and mnIconCountPsynergyIcons().

Definition at line 44 of file graphics.h.

PsynergyIconsEnd

extern Uint8 *PsynergyIconsEnd[]

The end of PsynergyIcons, for mnIconCountPsynergyIcons.

Referenced by mnIconCountPsynergyIcons().

Definition at line 46 of file graphics.h.

CreditsFont

extern const Uint8 CreditsFont[]

The credits' 8x8 one-bit font, ASCII 32 to 127.

Referenced by mnCreditsDrawLine().

Definition at line 85 of file graphics.h.

extern const Uint8 MenuCursorActorTiles[]

The right-pointing arrow cursor, an 8x16 sprite of 256 colours, beside its left-pointing twin.

Referenced by mnArrowCreate(), mnSelectionMenuDrawArrow() and mnSelectionMenuSetupArrow().

Definition at line 98 of file graphics.h.

fdRenderDecodePictureEnd

extern const Uint8 fdRenderDecodePictureEnd[]

224 zeroed bytes right after fdRenderDecodePicture's code and tables; its address ends the stretch the field sprites' draw copies to RAM.

Referenced by fdSpriteComposePicture().

Definition at line 101 of file graphics.h.

PointingHandTiles

extern Uint8 PointingHandTiles[]

The pointing hand cursor, a 16x16 sprite, shared by the battle menus, the name entry screen and the talk choices.

Referenced by mnBattleDjinnMenuRun(), mnBattleItemMenuRun(), mnBattlePsynergyMenuRun(), mnBattleStatusScreenRun(), mnBattleSummonMenuRun(), mnColossoMenuChoose(), mnDebugSelectShortcuts(), mnNameEntryEditMemberName(), mnNameEntryLoadPointingHandTiles(), mnPauseMenuOpen(), mnPointingHandLoadIntoFreeSlot(), mnSettingsMenuOpen() and WindowSpritePointerTiles.

Definition at line 104 of file graphics.h.

mnCreditsDecodeBackground

extern const Uint8 mnCreditsDecodeBackground[]

Decodes a credits slide's packed picture into 8bpp tiles, adding a palette offset to each pixel; it relocates its own command table wherever it's copied.

Referenced by mnCreditsLoadBackground().

Definition at line 108 of file graphics.h.

CreditsDecodeBackgroundCodeSize

extern Uint8 CreditsDecodeBackgroundCodeSize[]

mnCreditsDecodeBackground with its command table, copied into HEAP_SLOT_RAM_CODE_TEMP for each slide.

Referenced by mnCreditsLoadBackground().

Definition at line 111 of file graphics.h.

TextDecodeSymbol

extern const Uint8 TextDecodeSymbol[]

Decodes one Huffman-coded symbol of a message for a MESSAGE_READER.

Referenced by mnMessageDecode() and mnMessageDecodeRaw().

Definition at line 113 of file graphics.h.

TextDecodeSymbolCodeSize

extern Uint8 TextDecodeSymbolCodeSize[]

TextDecodeSymbol, which the message decoders copy into HEAP_SLOT_MESSAGE_DECODER.

Referenced by mnMessageDecode() and mnMessageDecodeRaw().

Definition at line 116 of file graphics.h.

mnScanlineWindowBuildEdgesCodeSize

extern Uint8 mnScanlineWindowBuildEdgesCodeSize[]

mnScanlineWindowBuildEdges, copied to the heap by mnScanlineWindowFillSpans for each tick of a window transition.

Referenced by mnScanlineWindowFillSpans().

Definition at line 119 of file graphics.h.

fdTileConvertMapGrid

extern const Uint8 fdTileConvertMapGrid[]

Interleaves a layout's three decoded cell planes into cell words, for fdTileMapConvertBuffer.

Referenced by fdTileMapConvertBuffer().

Definition at line 122 of file graphics.h.

fdTileConvertMapGridCodeSize

extern Uint8 fdTileConvertMapGridCodeSize[]

fdTileConvertMapGrid, which fdTileMapConvertBuffer runs from a heap copy.

Referenced by fdTileMapConvertBuffer().

Definition at line 124 of file graphics.h.

mnTileDecompress4bpp

extern const Uint8 mnTileDecompress4bpp[]

Unpacks a compressed icon into a glyph transfer's input buffer.

Referenced by mnIconDecode() and mnIconDecompress().

Definition at line 126 of file graphics.h.

TileDecompress4bppCodeSize

extern Uint8 TileDecompress4bppCodeSize[]

mnTileDecompress4bpp, which mnIconDecode copies into HEAP_SLOT_RAM_CODE_TEMP.

Referenced by mnIconDecode() and mnIconDecompress().

Definition at line 128 of file graphics.h.

mnTileExpandMasked

extern const Uint8 mnTileExpandMasked[]

Packs an unpacked icon into 4bpp tiles over the layers already drawn there.

Referenced by mnIconDecode().

Definition at line 130 of file graphics.h.

TileExpandMaskedCodeSize

extern Uint8 TileExpandMaskedCodeSize[]

mnTileExpandMasked, which mnIconDecode loads for an icon's upper layers.

Referenced by mnIconDecode().

Definition at line 132 of file graphics.h.

mnTileExpandOpaque

extern const Uint8 mnTileExpandOpaque[]

Packs an unpacked icon into 4bpp tiles, overwriting every pixel.

Referenced by mnIconDecode().

Definition at line 134 of file graphics.h.

TileExpandOpaqueCodeSize

extern Uint8 TileExpandOpaqueCodeSize[]

mnTileExpandOpaque, which mnIconDecode loads for an icon's first layer.

Referenced by mnIconDecode().

Definition at line 136 of file graphics.h.

TitlePromptTiles

extern const Uint8 TitlePromptTiles[]

The title screen's "Press Start" prompt, byte-LZ compressed, in each language.

Referenced by mnTitleShowTitleScreen().

Definition at line 139 of file graphics.h.

IconDigitPointers

extern Uint8 *IconDigitPointers[]

The icon count's digits: 0 to 9, then the tens 1 to 3.

Referenced by mnItemIconCompose().

Definition at line 146 of file graphics.h.

IconBasePointerTable

extern Uint8 *IconBasePointerTable[]

The three icon bases; base 2 is the one item and Psynergy icons share.

Referenced by mnIconBuildAbilityIconTiles(), mnIconBuildCommandIconTiles(), mnIconBuildItemIconTiles() and mnItemIconCompose().

Definition at line 148 of file graphics.h.

IconMarkPointers

extern Uint8 *IconMarkPointers[]

The three marks mnItemIconCompose draws over an item icon: 0 on a broken item, 1 on an equipped one and 2 on a cursed one.

Referenced by mnItemIconCompose().

Definition at line 151 of file graphics.h.

IconOverlayPointerTable

extern Uint8 *IconOverlayPointerTable[]

The command icons' overlays, all 43 entries the same picture.

Referenced by mnIconBuildCommandIconTiles().

Definition at line 153 of file graphics.h.

IconResourceTiles

extern Uint8 IconResourceTiles[]

The menus' hand cursor and gem, 16x16 4bpp sprites; the hand is loaded by mnIconCreateHandCursor.

Referenced by mnIconCreateHandCursor() and mnIconCreateHandCursorUnusedArgument().

Definition at line 156 of file graphics.h.

WindowSpritePageArrowTiles

extern const Uint8 WindowSpritePageArrowTiles[]

The animated page arrow's pictures, 8x16 sprites of 256 colours, 128 bytes each.

Referenced by mnWindowSpriteUpdateAll().

Definition at line 161 of file graphics.h.

mnGlyphDrawCodeSize

extern Uint8 mnGlyphDrawCodeSize[]

mnGlyphDrawArm, copied to the heap for each character drawn.

Referenced by mnGlyphDraw().

Definition at line 169 of file graphics.h.

mnMessageFindArm

extern const Uint8 mnMessageFindArm[]

Points a MESSAGE_READER at a message's compressed bits and first context.

Referenced by mnMessageFind().

Definition at line 173 of file graphics.h.

mnMessageFindCodeSize

extern Uint8 mnMessageFindCodeSize[]

mnMessageFindArm; mnMessageFind frees its copy on return.

Referenced by mnMessageFind().

Definition at line 175 of file graphics.h.