Alchemy
Loading...
Searching...
No Matches

djinn.c File Reference

The Djinn menu: its screen, the Djinn list, help, and choosing the Djinn to set, put on standby, give or trade. More...

Go to the source code of this file.

Macros

#define DJINN_CURSOR_WIDTH   6
#define DJINN_SWAP_PREVIEW_MODE   2
#define DJINN_PREVIEW_DIGITS   3
#define DJINN_PREVIEW_CURRENT_X   48
#define DJINN_PREVIEW_MAX_X   80
#define DJINN_PREVIEW_SLASH_X   72
#define DJINN_PREVIEW_LUCK_X   56
#define DJINN_PREVIEW_ARROW_X(x, iconX)
#define DJINN_PREVIEW_PP_X   88
#define DJINN_RESELECT_PAIR_ENTRY(menu, i)
 Finds the moved Djinni in the list and selects its new position.
#define DJINN_BACKDROP_FRAME_TILE   150
#define DJINN_PREVIEW_GAINED   0x8000
#define DJINN_PREVIEW_LOST   0x4000
#define DJINN_ELEMENT_TILE   0x5001
 The window map entry of the first element icon, in palette 5; the four elements follow it in order.
#define DJINN_ENTRY_SET   (-0x8000)
#define DJINN_OWNER(v)
#define DJINN_ELEMENT(v)
#define DJINN_NUMBER(v)

Enumerations

enum  DjinnMenuStep {
  DJINN_STEP_HANDLE_RESULT = 0 , DJINN_STEP_RESERVED = 1 , DJINN_STEP_SELECT_DJINN = 2 , DJINN_STEP_SELECT_ACTION = 3 ,
  DJINN_STEP_HANDLE_PAIR_RESULT = 4 , DJINN_STEP_CONFIRM_SET = 5 , DJINN_STEP_CONFIRM_STANDBY = 6 , DJINN_STEP_CONFIRM_GIVE = 7 ,
  DJINN_STEP_SELECT_SECOND = 8 , DJINN_STEP_CONFIRM_TRADE = 9 , DJINN_STEP_SHOW_STATUS = 10 , DJINN_STEP_APPLY_SET = 11 ,
  DJINN_STEP_APPLY_STANDBY = 12 , DJINN_STEP_APPLY_GIVE = 13 , DJINN_STEP_APPLY_TRADE = 14 , DJINN_STEP_SHOW_HELP = 15
}
 The screen chooses an operation, optionally previews it, then commits it. More...

Functions

s32 Menu_WrapIndex (s32 value, s32 modulus)
 Wraps a cursor index that has stepped one past either end of modulus entries: -1 becomes modulus - 1 and modulus becomes 0.
s32 Menu_SetFirstObjectRowCoordinates (s32 yOffset)
 Places the Djinn menu's first row at its normal height plus yOffset.
s32 DjinnMenu_Run (void)
 Runs the Djinn menu, preserving field tiles and the message speed.
s32 DjinnMenu_RunScreen (void)
 Chooses a Djinni, previews changes, then sets, stands by, gives or trades it.
void Graphics_AdjustPaletteBank (s32 brightnessDelta)
 Writes copies of background palettes 15, 5 and 7, each brightnessDelta lighter in every channel (clamped to 0-31), into palettes 14, 4 and 6.
MenuBackdropResult Menu_OpenBackdropScreen (void)
 Draws the backdrop behind the Djinn menu's list: its window, tiles and palettes.
s32 OwnerAction_DiffSlots (struct OwnerActionSlot *before, struct OwnerActionSlot *after, u16 *actionsOut, s32 *gainedCountOut, s32 *lostCountOut)
 Lists the actions after a preview, marking gains, then appends the losses.
s32 DjinnMenu_BuildLists (void *table)
 Rebuilds the Djinn lists in table: each owner's packed Djinn entries and their count.
void DjinnMenu_DrawElementList (struct DjinnListTable *table)
 Draws each owner's Djinn column, including set and recovering entries.
s32 UiWindow_SetInteriorPaletteBitRect (const struct UiWindow *window, s32 x, s32 y, s32 width, s32 height, s32 palette)
 Sets the palette of a rectangle of window's interior, (x, y) and its size in tiles from the interior's corner, through UiWindow_SetPaletteBitRectFar.
void UiWindow_SetRectPalette (s32 x, s32 y, s32 width, s32 height, s32 palette)
 Moves each tile of a screen rectangle (in tiles, clipped to the screen) that shows palette 15 to palette.
void UiWindow_SetInteriorRectPalette (void *window, s32 x, s32 y, s32 width, s32 height, s32 palette)
 UiWindow_SetRectPalette on a rectangle of window's interior, (x, y) and its size in tiles from the interior's corner.
s32 DjinnMenu_ShowHelp (void)
 Runs the Djinn help choices and restores the list when the player leaves.
s32 DjinnMenu_SelectDjinn (s32 mode)
 Chooses an owner and Djinni, or a set, standby, give or trade action.
s32 Djinn_ListOwnerEntries (u16 *entriesOut, s32 ownerId, s32 element)
 Lists owned Djinn by element and index, marking those that are set.
s32 DjinnMenu_DrawPairPreview (s32 mode, s32 pageIndex)
 Draws both sides of the give or trade preview for the selected page.
static __inline__ void Unit_Copy (struct BattleUnit *destination, struct BattleUnit *source)
 Copies a full unit for a temporary Djinn-stat preview.
s32 DjinnMenu_DrawStatPreview (struct UiWindow *window, s32 x, s32 y, s32 ownerId, s32 removePairSlot, s32 addPairSlot, s32 previewMode, s32 page, s32 side)
 Saves the unit, applies a hypothetical Djinn change, draws its differences and restores the original unit before returning.

Detailed Description

The Djinn menu: its screen, the Djinn list, help, and choosing the Djinn to set, put on standby, give or trade.

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

Definition in file djinn.c.

Macro Definition Documentation

◆ DJINN_CURSOR_WIDTH

#define DJINN_CURSOR_WIDTH   6

Definition at line 14 of file djinn.c.

Referenced by DjinnMenu_SelectDjinn().

◆ DJINN_SWAP_PREVIEW_MODE

#define DJINN_SWAP_PREVIEW_MODE   2

Definition at line 20 of file djinn.c.

Referenced by DjinnMenu_DrawPairPreview().

◆ DJINN_PREVIEW_DIGITS

#define DJINN_PREVIEW_DIGITS   3

Definition at line 28 of file djinn.c.

Referenced by DjinnMenu_DrawStatPreview().

◆ DJINN_PREVIEW_CURRENT_X

#define DJINN_PREVIEW_CURRENT_X   48

Definition at line 29 of file djinn.c.

Referenced by DjinnMenu_DrawStatPreview().

◆ DJINN_PREVIEW_MAX_X

#define DJINN_PREVIEW_MAX_X   80

Definition at line 30 of file djinn.c.

Referenced by DjinnMenu_DrawStatPreview().

◆ DJINN_PREVIEW_SLASH_X

#define DJINN_PREVIEW_SLASH_X   72

Definition at line 31 of file djinn.c.

Referenced by DjinnMenu_DrawStatPreview().

◆ DJINN_PREVIEW_LUCK_X

#define DJINN_PREVIEW_LUCK_X   56

Definition at line 32 of file djinn.c.

Referenced by DjinnMenu_DrawStatPreview().

◆ DJINN_PREVIEW_ARROW_X

#define DJINN_PREVIEW_ARROW_X ( x,
iconX )
Value:
(iconX)

Definition at line 33 of file djinn.c.

Referenced by DjinnMenu_DrawStatPreview().

◆ DJINN_PREVIEW_PP_X

#define DJINN_PREVIEW_PP_X   88

Definition at line 34 of file djinn.c.

Referenced by DjinnMenu_DrawStatPreview().

◆ DJINN_RESELECT_PAIR_ENTRY

#define DJINN_RESELECT_PAIR_ENTRY ( menu,
i )
Value:
do { \
s32 column; \
s32 found; \
u8 entry; \
\
column = (u16)((u32)(menu)->selection[1] % DJINN_LIST_ROWS); \
found = 0; \
entry = (menu)->pairEntries[0]; \
for ((i) = 0; (i) < (menu)->backdrop->list.counts[column]; (i)++) { \
if (entry == (u8)(menu)->backdrop->list.ids[column][(i)]) { \
found = (i); \
break; \
} \
} \
(menu)->selection[0] = column + found * DJINN_LIST_ROWS; \
} while (0)
#define DJINN_LIST_ROWS
Definition djinn_menu.h:20
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11

Finds the moved Djinni in the list and selects its new position.

Definition at line 140 of file djinn.c.

Referenced by DjinnMenu_RunScreen().

◆ DJINN_BACKDROP_FRAME_TILE

#define DJINN_BACKDROP_FRAME_TILE   150

Definition at line 455 of file djinn.c.

Referenced by Menu_OpenBackdropScreen().

◆ DJINN_PREVIEW_GAINED

#define DJINN_PREVIEW_GAINED   0x8000

Definition at line 457 of file djinn.c.

Referenced by OwnerAction_DiffSlots().

◆ DJINN_PREVIEW_LOST

#define DJINN_PREVIEW_LOST   0x4000

Definition at line 458 of file djinn.c.

Referenced by OwnerAction_DiffSlots().

◆ DJINN_ELEMENT_TILE

#define DJINN_ELEMENT_TILE   0x5001

The window map entry of the first element icon, in palette 5; the four elements follow it in order.

Definition at line 580 of file djinn.c.

Referenced by DjinnMenu_DrawElementList(), DjinnMenu_DrawStatPreview(), and DjinnMenu_SelectDjinn().

◆ DJINN_ENTRY_SET

#define DJINN_ENTRY_SET   (-0x8000)

Definition at line 822 of file djinn.c.

Referenced by Djinn_ListOwnerEntries().

◆ DJINN_OWNER

#define DJINN_OWNER ( v)
Value:
(((v) & 0xf00) >> 8)

Definition at line 824 of file djinn.c.

Referenced by DjinnMenu_SelectDjinn().

◆ DJINN_ELEMENT

#define DJINN_ELEMENT ( v)
Value:
(((v) & 0xe0) >> 5)

Definition at line 825 of file djinn.c.

◆ DJINN_NUMBER

#define DJINN_NUMBER ( v)
Value:
((v) & 0x1f)

Definition at line 826 of file djinn.c.

Referenced by DjinnMenu_SelectDjinn().

Enumeration Type Documentation

◆ DjinnMenuStep

The screen chooses an operation, optionally previews it, then commits it.

Enumerator
DJINN_STEP_HANDLE_RESULT 
DJINN_STEP_RESERVED 
DJINN_STEP_SELECT_DJINN 
DJINN_STEP_SELECT_ACTION 
DJINN_STEP_HANDLE_PAIR_RESULT 
DJINN_STEP_CONFIRM_SET 
DJINN_STEP_CONFIRM_STANDBY 
DJINN_STEP_CONFIRM_GIVE 
DJINN_STEP_SELECT_SECOND 
DJINN_STEP_CONFIRM_TRADE 
DJINN_STEP_SHOW_STATUS 
DJINN_STEP_APPLY_SET 
DJINN_STEP_APPLY_STANDBY 
DJINN_STEP_APPLY_GIVE 
DJINN_STEP_APPLY_TRADE 
DJINN_STEP_SHOW_HELP 

Definition at line 159 of file djinn.c.

Function Documentation

◆ Menu_WrapIndex()

s32 Menu_WrapIndex ( s32 value,
s32 modulus )

Wraps a cursor index that has stepped one past either end of modulus entries: -1 becomes modulus - 1 and modulus becomes 0.

Definition at line 47 of file djinn.c.

Referenced by DjinnMenu_SelectDjinn(), DjinnMenu_ShowHelp(), DjinnMenu_ShowOwnerStatus(), Menu_WrapIndex(), and OwnerAction_RunCompareLoop().

◆ Menu_SetFirstObjectRowCoordinates()

s32 Menu_SetFirstObjectRowCoordinates ( s32 yOffset)

Places the Djinn menu's first row at its normal height plus yOffset.

Definition at line 52 of file djinn.c.

Referenced by DjinnMenu_Run(), DjinnMenu_RunScreen(), and Menu_SetFirstObjectRowCoordinates().

◆ DjinnMenu_Run()

s32 DjinnMenu_Run ( void )

Runs the Djinn menu, preserving field tiles and the message speed.

Definition at line 68 of file djinn.c.

Referenced by DjinnMenu_Run().

◆ DjinnMenu_RunScreen()

s32 DjinnMenu_RunScreen ( void )

Chooses a Djinni, previews changes, then sets, stands by, gives or trades it.

Confirmation states fall through to their matching commit states on success.

Definition at line 181 of file djinn.c.

Referenced by DjinnMenu_Run(), and DjinnMenu_RunScreen().

◆ Graphics_AdjustPaletteBank()

void Graphics_AdjustPaletteBank ( s32 brightnessDelta)

Writes copies of background palettes 15, 5 and 7, each brightnessDelta lighter in every channel (clamped to 0-31), into palettes 14, 4 and 6.

Palette 7's copy is 12 darker instead.

Definition at line 401 of file djinn.c.

Referenced by Graphics_AdjustPaletteBank(), and Menu_OpenBackdropScreen().

◆ Menu_OpenBackdropScreen()

MenuBackdropResult Menu_OpenBackdropScreen ( void )

Draws the backdrop behind the Djinn menu's list: its window, tiles and palettes.

Definition at line 462 of file djinn.c.

Referenced by DjinnMenu_RunScreen(), and Menu_OpenBackdropScreen().

◆ OwnerAction_DiffSlots()

s32 OwnerAction_DiffSlots ( struct OwnerActionSlot * before,
struct OwnerActionSlot * after,
u16 * actionsOut,
s32 * gainedCountOut,
s32 * lostCountOut )

Lists the actions after a preview, marking gains, then appends the losses.

The two output counts distinguish gained and lost actions.

Definition at line 495 of file djinn.c.

Referenced by DjinnMenu_DrawStatPreview(), DjinnMenu_ShowOwnerStatus(), OwnerAction_DiffSlots(), and OwnerAction_RunCompareLoop().

◆ DjinnMenu_BuildLists()

s32 DjinnMenu_BuildLists ( void * table)

Rebuilds the Djinn lists in table: each owner's packed Djinn entries and their count.

Definition at line 548 of file djinn.c.

Referenced by DjinnMenu_BuildLists(), and DjinnMenu_RunScreen().

◆ DjinnMenu_DrawElementList()

void DjinnMenu_DrawElementList ( struct DjinnListTable * table)

Draws each owner's Djinn column, including set and recovering entries.

Definition at line 583 of file djinn.c.

Referenced by DjinnMenu_DrawElementList(), DjinnMenu_RunScreen(), DjinnMenu_SelectDjinn(), and Menu_OpenBackdropScreen().

◆ UiWindow_SetInteriorPaletteBitRect()

s32 UiWindow_SetInteriorPaletteBitRect ( const struct UiWindow * window,
s32 x,
s32 y,
s32 width,
s32 height,
s32 palette )

Sets the palette of a rectangle of window's interior, (x, y) and its size in tiles from the interior's corner, through UiWindow_SetPaletteBitRectFar.

Definition at line 648 of file djinn.c.

Referenced by DjinnMenu_SelectDjinn(), DjinnMenu_ShowHelp(), and UiWindow_SetInteriorPaletteBitRect().

◆ UiWindow_SetRectPalette()

void UiWindow_SetRectPalette ( s32 x,
s32 y,
s32 width,
s32 height,
s32 palette )

Moves each tile of a screen rectangle (in tiles, clipped to the screen) that shows palette 15 to palette.

Definition at line 660 of file djinn.c.

Referenced by DjinnMenu_ShowHelp(), UiWindow_SetInteriorRectPalette(), and UiWindow_SetRectPalette().

◆ UiWindow_SetInteriorRectPalette()

void UiWindow_SetInteriorRectPalette ( void * window,
s32 x,
s32 y,
s32 width,
s32 height,
s32 palette )

UiWindow_SetRectPalette on a rectangle of window's interior, (x, y) and its size in tiles from the interior's corner.

Definition at line 702 of file djinn.c.

Referenced by DjinnMenu_SelectDjinn(), DjinnMenu_ShowHelp(), and UiWindow_SetInteriorRectPalette().

◆ DjinnMenu_ShowHelp()

s32 DjinnMenu_ShowHelp ( void )

Runs the Djinn help choices and restores the list when the player leaves.

Definition at line 710 of file djinn.c.

Referenced by DjinnMenu_RunScreen(), and DjinnMenu_ShowHelp().

◆ DjinnMenu_SelectDjinn()

s32 DjinnMenu_SelectDjinn ( s32 mode)

Chooses an owner and Djinni, or a set, standby, give or trade action.

The tutorial can replace the sampled input without changing the input order.

Definition at line 830 of file djinn.c.

Referenced by DjinnMenu_RunScreen(), and DjinnMenu_SelectDjinn().

◆ Djinn_ListOwnerEntries()

s32 Djinn_ListOwnerEntries ( u16 * entriesOut,
s32 ownerId,
s32 element )

Lists owned Djinn by element and index, marking those that are set.

For element -1, entries also encode their owner.

Definition at line 1506 of file djinn.c.

Referenced by Djinn_ListOwnerEntries(), DjinnMenu_BuildLists(), and DjinnMenu_DrawElementList().

◆ DjinnMenu_DrawPairPreview()

s32 DjinnMenu_DrawPairPreview ( s32 mode,
s32 pageIndex )

Draws both sides of the give or trade preview for the selected page.

Definition at line 1538 of file djinn.c.

Referenced by DjinnMenu_DrawPairPreview(), and OwnerAction_RunCompareLoop().

◆ Unit_Copy()

__inline__ void Unit_Copy ( struct BattleUnit * destination,
struct BattleUnit * source )
static

Copies a full unit for a temporary Djinn-stat preview.

Definition at line 1557 of file djinn.c.

Referenced by DjinnMenu_DrawStatPreview(), and Unit_Copy().

◆ DjinnMenu_DrawStatPreview()

s32 DjinnMenu_DrawStatPreview ( struct UiWindow * window,
s32 x,
s32 y,
s32 ownerId,
s32 removePairSlot,
s32 addPairSlot,
s32 previewMode,
s32 page,
s32 side )

Saves the unit, applies a hypothetical Djinn change, draws its differences and restores the original unit before returning.

Definition at line 1564 of file djinn.c.

Referenced by DjinnMenu_DrawPairPreview(), DjinnMenu_DrawStatPreview(), DjinnMenu_ShowOwnerStatus(), and OwnerAction_RunCompareLoop().