9#define NUMBER_TEXT_WIDE_LENGTH 14
27 *destination++ = *source++;
32#define DJINN_PREVIEW_ABILITY_GAINED 0x8000
33#define DJINN_PREVIEW_ABILITY_LOST 0x4000
34#define DJINN_PREVIEW_ABILITY_CAPACITY 48
52 if (
BattleActGet(newGrid[i].encodedAction)->flags & 0x80) {
55 for (j = 0; j < 32; j++) {
56 if (((newGrid[i].encodedAction ^ oldGrid[j].encodedAction) &
67 if (
BattleActGet(oldGrid[i].encodedAction)->flags & 0x80) {
68 for (j = 0; j < 32; j++) {
69 if (((oldGrid[i].encodedAction ^ newGrid[j].encodedAction) &
81 *gained = gainedCount;
110 s32 encodedDjinn,
s32 page,
121 u16 *changedAbilities;
136 void DjinnMenu_DrawStatArrow(
s32 x,
s32 y,
s32 rising) {
165 *(
void **)&entry->
tile = (
void *)zero;
197 numberText =
MemAlloc(64 *
sizeof(*numberText));
198 savedUnit =
MemAlloc(
sizeof(*savedUnit));
203 element = (encodedDjinn >> 8) & 15;
204 djinnIndex = encodedDjinn & 255;
213 changedAbilities, &gained, &lost);
214 pages = ((abilityCount - 1) / 5) + 1;
216 if (page * 5 - 5 >= abilityCount)
221 s32 label = MsgPreviewStatLabel;
230 oldHp = savedUnit->
hp;
234 oldPp = savedUnit->
pp;
238 oldAtk = savedUnit->
atk;
243 oldDef = savedUnit->
def;
248 oldAgi = savedUnit->
agi;
257 if (gained != 0 || lost != 0)
266 visibleRows = abilityCount;
267 if (abilityCount > 4)
270 for (visibleRow = 0; visibleRow < visibleRows && i < abilityCount;
277 rangePattern = ability->
range;
295 win, 16, visibleRow * 16);
300 win, 104, visibleRow * 16);
311 summaryRows * 8 + 80);
314 if (summaryRows == 0)
332 if (unit->
hp != oldHp) {
334 if (unit->
hp > oldHp)
336 DjinnMenu_DrawStatArrow(80, 14, rising);
341 if (unit->
pp != oldPp) {
343 if (unit->
pp > oldPp)
345 DjinnMenu_DrawStatArrow(80, 22, rising);
350 if (unit->
atk != oldAtk) {
352 if (unit->
atk > oldAtk)
354 DjinnMenu_DrawStatArrow(80, 30, rising);
359 if (unit->
def != oldDef) {
361 if (unit->
def > oldDef)
363 DjinnMenu_DrawStatArrow(80, 38, rising);
368 if (unit->
agi != oldAgi) {
370 if (unit->
agi > oldAgi)
372 DjinnMenu_DrawStatArrow(80, 46, rising);
377 if (unit->
luck != savedUnit->
luck) {
381 DjinnMenu_DrawStatArrow(80, 54, rising);
What every part of the menu object shares: its includes, edition values, macros and the link round st...
#define DJINN_PREVIEW_HELP_X
#define PSYNERGY_COST_SECOND_TILE
#define DJINN_PREVIEW_VITALS_X
#define DJINN_PREVIEW_STAT_DIGIT_OFFSET
#define OUTPUT_SIZE_16X16
OAM attribute bits a sprite output is created with: the size field of attribute 1 (bits 30-31 of the ...
#define DJINN_PREVIEW_STAT_X
#define ABILITY_RANGE_ALL
BattleAct.range of an ability that reaches every unit on the side, each as if aimed at.
u8 gDjinnMenu_ArrowDownTiles[]
u8 gDjinnMenu_ArrowUpTiles[]
struct BattleUnit * UnitGetFar(u32 owner)
struct BattleAct * BattleActGet(s32 actionId)
Far call to BattleAction_GetDirect.
u32 Djinn_IsActiveFar(s32 owner, s32 index, s32 bit)
u32 Djinn_DeactivateFar(s32 owner, s32 index, s32 bit)
s32 Djinn_ActivateFar(s32 owner, s32 index, s32 bit)
void UnitCalcFar(s32 owner)
void UiText_RenderWideStringInWindow(s16 *text, struct UiWindow *window, s32 x, s32 y)
Draws a zero-terminated string of 16-bit character codes into a window's tilemap at tile (x,...
void * Runtime_BumpAllocateAlternatePool(s32 size)
As MemAlloc, but tries EWRAM first.
void * MemAlloc(s32 size)
Allocates size bytes (rounded up to words) with no slot, from IWRAM when they fit and EWRAM otherwise...
static s32 Iwram_CopyWords(volatile void *destination, const volatile void *source, s32 size)
void MemFree(void *buffer)
struct RenderOutput * RenderOutput_Create(s32 slot, s32 oamFlags, struct UiWindow *window, s32 offsetX, s32 offsetY)
Creates a sprite output for the VRAM cache slot slot and attaches it to window, placed at (offsetX,...
s32 Resource_LoadIndexedEntryToBuffer(s32 resource, s32 index)
Builds the ability glyph in temporary transfer work, reloads the requested cache slot and returns its...
int UiWindow_DrawThreeTileColumn(struct UiWindow *window, s32 x, s32 y, s32 pattern, s32 unused)
An ability's definition, a row of gBattleAction_DefinitionTable: its targeting, kind,...
u8 range
the aimed unit and range - 1 either side, or ABILITY_RANGE_ALL
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
u8 luck
0 to 99 (UnitCalc)
s16 hp
current HP, 0 when downed
struct OwnerActionSlot actionSlots[32]
The action list: Psynergy taught for good, then the class's and the equipment's (Unit_RefreshPsynergy...
u8 classIndex
The character's class, worked out from its Djinn (Unit_UpdateClass); 0 marks an enemy,...
u16 atk
Attack, 0 to 999 (UnitCalc).
u16 agi
Agility, 0 to 999: the order of the round's actions.
u16 def
Defense, 0 to 999 (UnitCalc).
An entry in a unit's action list: the action's id (OWNER_ACTION_ID_MASK) and marks for an action its ...
u16 encodedAction
bits: 15 from the class | 14 from an equipped item | 13..0 action id.
The OAM entry of a render output, as the Djinn preview places its stat arrows.
union PreviewSprite::@277316304171272134171205205340246056300000270302 attributes
union RenderTableValue tile
A list of render outputs: its first output and the link to append after.
A render output: a sprite in a window's output list (a character, an icon or a portrait),...
u8 sentinel
depth slot it is drawn at (254 for glyphs)
s8 active
its UI_SPRITE_ motion; 0 while free
s8 kind
0 for a glyph; otherwise it owns VRAM cache slot index, freed with it, and 2 (a portrait) also its pa...
s8 index
VRAM cache slot, or a glyph's tile after glyphTiles.
A window: a framed rectangle of the tilemap with its sprite outputs, its opening or closing animation...
struct RenderOutputList output
the sprites the window carries
void NumberText_FormatDecimal(s32 number)
Writes number to the number buffer as eleven characters: spaces, a sign (a space or '-') and its deci...
void UiWindow_DrawDividerLine(struct UiWindow *win, u32 x1, u32 y1, u32 x2, u32 y2)
Draws a straight divider line inside a window from tile (x1, y1) to (x2, y2), horizontal or vertical:...
void UiText_DrawNumberInWindow(s32 value, s32 width, struct UiWindow *window, s32 x, s32 y)
Draws a number (width as UiText_FormatNumber) into a window's tilemap at pixel (x,...
void UiWork_SetParamNibble(s32 param)
Sets the text colour (0 to 15) of drawn text.
void UiText_DrawCharacterAtOffset(s32 message, const struct UiWindow *window, u32 offsetX, u32 offsetY)
Decodes a message and draws it as tiles in a window at pixel (offsetX, offsetY) of its interior.
struct RenderTableValue::@007120236370026233101065137137050014126142057215 bits
s32 VramCache_AllocEntry(s32 size)
Takes a free cache entry, gives it size bytes of sprite VRAM and returns its number.
s32 VramCache_Reload(s32 no, s32 src)
Copies src again into entry no's VRAM, keeping its size.
s32 Resource_FindFreeEntry(void)
Returns the number of the first free cache entry, or VRAM_CACHE_ENTRY_COUNT when all are taken.
s32 DjinnMenu_ListChangedDjinn(const struct OwnerActionSlot *oldGrid, const struct OwnerActionSlot *newGrid, u16 *out, s32 *gained, s32 *lost)
List Psynergy in the new grid, marking newly gained entries with bit 15, then append lost entries wit...
#define NUMBER_TEXT_WIDE_LENGTH
The decimal formatter writes eleven characters plus a terminator.
#define DJINN_PREVIEW_ABILITY_LOST
#define DJINN_PREVIEW_ABILITY_CAPACITY
s32 Ui_CreateOutputFromResourceSlot(struct UiWindow *window, s32 x, s32 y, s32 abilityId)
s32 UiText_FormatNumberToHalfwords(s16 *out, s32 value)
#define DJINN_PREVIEW_ABILITY_GAINED
struct UiWindow * DjinnMenu_ShowChangePreview(struct UiWindow *win, s32 owner, s32 encodedDjinn, s32 page, s32 *pageCount)
Temporarily toggle a Djinni and recalculate its owner's stats to show the change.
void UiWindow_SetTilemapEntry(struct UiWindow *window, s32 value, s32 x, s32 y, u32 mode)
Writes value into a window's tilemap at tile (x, y) of its interior, with the palette mode names (TIL...
void RenderOutput_AppendToList(struct RenderOutputList *list, struct RenderOutput *node)
Adds a render output to the end of a list; NULL lists are ignored.
void UiWork_Finalize(struct UiWindow *window, s32 instant)
Closes a window: clears its contents and remembers its last rectangle.
struct RenderOutput * RenderOutput_AcquireFree(void)
Takes the first render output from the free list, or returns NULL when every output is in use.
struct UiWindow * UiWindow_Create(s32 x, s32 y, s32 width, s32 height, s32 attrs)
Opens a window at tile (x, y) of width by height tiles in the first free window slot,...