Skip to Content
The Alchemy Project

src/window/screens_battle_djinn_preview.c

The preview of what setting or removing a Djinni changes. More…

Included by screens.c.

Macros

NameDescription
#defineNUMBER_TEXT_WIDE_LENGTH 14How many bytes of NumberBuffer are widened: the eleven characters syStringFormatDecimal writes, its terminator and the two bytes after.
#definePREVIEW_STAT_ARROW_X 80A changed stat's arrow, right of its value on window tile row row (HP on row 1 to Luck on row 6).
#definePREVIEW_STAT_ARROW_Y (row) ((row) * 8 + 6)
#defineDJINN_PREVIEW_ABILITY_GAINED 0x8000The marks mnBattleDjinnMenuListChangedAbilities gives an ability in its list, above its id: the preview draws a gained one in TEXT_COLOR_YELLOW and a lost one in TEXT_COLOR_RED.
#defineDJINN_PREVIEW_ABILITY_LOST 0x4000gone with the change
#defineDJINN_PREVIEW_ABILITY_CAPACITY
#defineDJINN_PREVIEW_ABILITIES_PER_PAGElost ones

Functions

NameDescription
UNREAD_RESULTmnStringFormatNumberToHalfwords (Sint16 *out, Sint32 value)Writes value into out as syStringFormatDecimal's eleven-character, right-aligned decimal text, widened to halfwords for mnTextDrawWideStringInWindow.
Sint32mnBattleDjinnMenuListChangedAbilities (const PSYNERGY_ENTRY *oldGrid, const PSYNERGY_ENTRY *newGrid, Uint16 *out, Sint32 *gained, Sint32 *lost)Lists into out the abilities usable in battle (ABILITY_USABLE_IN_BATTLE) of the action list newGrid, in its order, marking with DJINN_PREVIEW_ABILITY_GAINED those oldGrid lacks; then appends those of oldGrid that newGrid lacks, marked DJINN_PREVIEW_ABILITY_LOST.
UNREAD_RESULTmnWindowSpriteCreateAbilityIcon (WINDOW *window, Sint32 x, Sint32 y, Sint32 abilityId)Loads the icon of ability abilityId into the first free VRAM cache slot and shows it as a 16x16 sprite at pixel (x, y) inside window, whose sprite list then owns the slot.
WINDOW *mnBattleDjinnMenuShowChangePreview (WINDOW *window, Sint32 member, Sint32 encodedDjinn, Sint32 page, Sint32 *pageCount)Shows what setting or removing Djinni encodedDjinn (element << 8 | index) would change for member: closes the preview window window, opens a new one and returns it, or NULL when none could be opened.

Description

The preview of what setting or removing a Djinni changes. Part of screens.c.

Macros in detail

NUMBER_TEXT_WIDE_LENGTH

#define NUMBER_TEXT_WIDE_LENGTH 14

How many bytes of NumberBuffer are widened: the eleven characters syStringFormatDecimal writes, its terminator and the two bytes after.

Referenced by mnStringFormatNumberToHalfwords().

Definition at line 5 of file screens_battle_djinn_preview.c.

PREVIEW_STAT_ARROW_X

#define PREVIEW_STAT_ARROW_X 80

A changed stat's arrow, right of its value on window tile row row (HP on row 1 to Luck on row 6).

Referenced by mnBattleDjinnMenuShowChangePreview().

Definition at line 9 of file screens_battle_djinn_preview.c.

PREVIEW_STAT_ARROW_Y

#define PREVIEW_STAT_ARROW_Y(row) ((row) * 8 + 6)

Referenced by mnBattleDjinnMenuShowChangePreview().

Definition at line 10 of file screens_battle_djinn_preview.c.

DJINN_PREVIEW_ABILITY_GAINED

#define DJINN_PREVIEW_ABILITY_GAINED 0x8000

The marks mnBattleDjinnMenuListChangedAbilities gives an ability in its list, above its id: the preview draws a gained one in TEXT_COLOR_YELLOW and a lost one in TEXT_COLOR_RED.

new with the change

Referenced by mnBattleDjinnMenuListChangedAbilities() and mnBattleDjinnMenuShowChangePreview().

Definition at line 34 of file screens_battle_djinn_preview.c.

DJINN_PREVIEW_ABILITY_LOST

#define DJINN_PREVIEW_ABILITY_LOST 0x4000

gone with the change

Referenced by mnBattleDjinnMenuListChangedAbilities() and mnBattleDjinnMenuShowChangePreview().

Definition at line 35 of file screens_battle_djinn_preview.c.

DJINN_PREVIEW_ABILITY_CAPACITY

#define DJINN_PREVIEW_ABILITY_CAPACITY

Referenced by mnBattleDjinnMenuShowChangePreview().

Definition at line 36 of file screens_battle_djinn_preview.c.

DJINN_PREVIEW_ABILITIES_PER_PAGE

#define DJINN_PREVIEW_ABILITIES_PER_PAGE

lost ones

Referenced by mnBattleDjinnMenuShowChangePreview().

Definition at line 39 of file screens_battle_djinn_preview.c.

Functions in detail

mnStringFormatNumberToHalfwords

UNREAD_RESULT mnStringFormatNumberToHalfwords(Sint16 *out, Sint32 value)

Writes value into out as syStringFormatDecimal's eleven-character, right-aligned decimal text, widened to halfwords for mnTextDrawWideStringInWindow. out needs room for NUMBER_TEXT_WIDE_LENGTH halfwords.

References NumberBuffer, Sint32 and syStringFormatDecimal().

Referenced by mnBattleDjinnMenuShowChangePreview().

Definition at line 16 of file screens_battle_djinn_preview.c.

mnBattleDjinnMenuListChangedAbilities

Sint32 mnBattleDjinnMenuListChangedAbilities(const PSYNERGY_ENTRY *oldGrid, const PSYNERGY_ENTRY *newGrid, Uint16 *out, Sint32 *gained, Sint32 *lost)

Lists into out the abilities usable in battle (ABILITY_USABLE_IN_BATTLE) of the action list newGrid, in its order, marking with DJINN_PREVIEW_ABILITY_GAINED those oldGrid lacks; then appends those of oldGrid that newGrid lacks, marked DJINN_PREVIEW_ABILITY_LOST. Returns the entries written, and the gained and lost counts through gained and lost.

References gmAbilityGetDefinitionStub() and Sint32.

Referenced by mnBattleDjinnMenuShowChangePreview().

Definition at line 49 of file screens_battle_djinn_preview.c.

mnWindowSpriteCreateAbilityIcon

UNREAD_RESULT mnWindowSpriteCreateAbilityIcon(WINDOW *window, Sint32 x, Sint32 y, Sint32 abilityId)

Loads the icon of ability abilityId into the first free VRAM cache slot and shows it as a 16x16 sprite at pixel (x, y) inside window, whose sprite list then owns the slot. Does nothing when the cache is full.

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

Referenced by mnBattleDjinnMenuShowChangePreview().

Definition at line 114 of file screens_battle_djinn_preview.c.

mnBattleDjinnMenuShowChangePreview

WINDOW *mnBattleDjinnMenuShowChangePreview(WINDOW *window, Sint32 member, Sint32 encodedDjinn, Sint32 page, Sint32 *pageCount)

Shows what setting or removing Djinni encodedDjinn (element << 8 | index) would change for member: closes the preview window window, opens a new one and returns it, or NULL when none could be opened. Page 0 compares the class and stats, old against new, with an arrow by each stat that rises or falls; pages 1 on list the unit's battle abilities after the change and then those it would lose, and *pageCount is set to their number (at least 1). The Djinni is toggled and the unit recalculated only to measure: the unit is restored from a copy before it returns.

References DjinnMenuArrowDownTiles, DjinnMenuArrowUpTiles, gmAbilityGetDefinitionStub(), gmDjinnIsSetStub(), gmDjinnPutOnStandbyStub(), gmDjinnSetStub(), gmUnitCalculateStub(), gmUnitGetStub(), mnBattleDjinnMenuListChangedAbilities(), mnRangeIconDraw(), mnStringFormatNumberToHalfwords(), mnTextDrawMessageAsTiles(), mnTextDrawNumberInWindow(), mnTextDrawWideStringInWindow(), mnTextSetColor(), mnWindowClose(), mnWindowCreate(), mnWindowDrawDividerLine(), mnWindowSetTilemapEntry(), mnWindowSpriteAcquireFree(), mnWindowSpriteAppendToList(), mnWindowSpriteCreateAbilityIcon(), Sint32, syHeapAllocate(), syHeapAllocateEWRAM(), syHeapRelease(), syVRAMCacheAllocateEntry(), syVRAMCacheReload() and syWordsCopy().

Referenced by mnBattleDjinnMenuRun().

Definition at line 138 of file screens_battle_djinn_preview.c.