24 effect = signedEffect;
40 u16 *actors,
s32 commandCount) {
50 u16 signatureHeader[2];
64 void BattleMenu_ClearPartyHighlights(
void) {
83 for (k = 0; k < 8; k++) {
86 for (k = 0; k < 3; k++) {
101 transferWords[4] =
'V';
102 transferWords[5] =
'S';
103 transferWords[6] =
'S';
104 transferWords[7] =
'T';
105 missedLinkFrames = 0;
114 if (++missedLinkFrames > 24) {
120 missedLinkFrames = 0;
121 if (peerSignature[4] ==
'V' && peerSignature[5] ==
'S' &&
122 peerSignature[6] ==
'S' && peerSignature[7] ==
'T') {
125 if (peerSignature[4] ==
'E' && peerSignature[5] ==
'D' &&
126 peerSignature[6] ==
'V' && peerSignature[7] ==
'S') {
129 if (!(peerSignature[0] ==
'E' && peerSignature[1] ==
'X' &&
130 peerSignature[2] ==
'E' && peerSignature[3] ==
'C')) {
142 BattleMenu_ClearPartyHighlights();
150 if (commandCount > 0) {
178 command->
unitId = actors[0];
190 if (commandIndex >= commandCount) {
195 if (commandIndex == 0) {
200 for (k = 0; k < 4; k++) {
206 command = &commands[commandIndex];
207 actorId = actors[commandIndex];
220 iconSprite->
oam.word.attr01 = 0x80000400;
221 iconSprite->
oam.word.attr23 = 0;
222 iconSprite->
oam.f.tile =
225 iconSprite->
oam.f.y = 0x80;
226 iconSprite->
oam.f.palette = 14;
236 signatureHeader[0] = 0;
237 signatureHeader[0] = 0;
238 signatureHeader[0] = 0;
239 signatureHeader[0] = 0;
240 signatureHeader[0] = 0;
241 signatureHeader[0] = 0;
242 signatureHeader[0] = 0;
243 signatureHeader[0] = 0;
244 signatureHeader[0] = 0;
245 signatureHeader[0] = 0;
246 signatureHeader[0] = 0;
247 signatureHeader[0] = 0;
248 signatureHeader[0] = (
u16)actorId;
249 signatureHeader[1] = 255;
270 if (commandIndex == 0) {
281 iconSprite->
oam.word.attr23 = 0;
282 iconSprite->
oam.word.attr01 = 0x80002400;
283 iconSprite->
oam.f.tile =
286 iconSprite->
oam.f.x = 128;
288 iconSprite->
oam.f.x = 96;
290 iconSprite->
oam.f.y = 136;
331 if (entryValue != 0) {
335 list[cnt] = entryValue;
343 }
while (entryValue != 0);
354 cost = ability->
range;
355 iconSprite = &state->
icons[1];
360 iconSprite->
oam.word.attr01 = 0x40000400;
361 iconSprite->
oam.word.attr23 = 0;
362 iconSprite->
oam.f.x = commandWindow->
x * 8 + 8;
363 iconSprite->
oam.f.y = commandWindow->
y * 8 + 4;
367 __asm__
volatile(
"");
368 iconSprite->
oam.f.tile =
374 }
else if (unit->
psySeal != 0) {
389 command->
range = cost;
427 iconSprite = &state->
icons[1];
434 for (j = 0; j <= 3; j++) {
441 iconSprite->
oam.word.attr01 = 0x40000400;
442 iconSprite->
oam.word.attr23 = 0;
446 __asm__
volatile(
"");
447 iconSprite->
oam.f.x = commandWindow->
x * 8 + 8;
448 iconSprite->
oam.f.y = commandWindow->
y * 8 + 4;
457 commandWindow, 16, 0);
458 for (j = 0; j <= 3; j++) {
483 for (j = 0; j <= 3; j++) {
504 state->icons[0].oam.f.x = 144;
514 element = (parameter >> 8) & 15;
515 index = parameter & 255;
518 cost = ability->
range;
520 state->icons[0].oam.f.x = 64;
523 commandWindow, 16, 0);
524 command->
range = cost;
530 if (
state->tutorialStep != 0) {
537 state->tutorialStep++;
538 state->tutorialDelay = 45;
548 state->icons[0].oam.f.x = 64;
552 commandWindow, 16, 0);
588 if (entryValue != 0) {
592 list[cnt] = entryValue;
600 }
while (entryValue != 0);
604 if (entryValue != 0) {
608 list[cnt] = entryValue;
616 }
while (entryValue != 0);
623 selection = pick[mode];
624 parameter = selection;
627 cost = ability->
range;
628 iconSprite = &state->
icons[1];
632 iconSprite->
oam.word.attr01 = 0x40000400;
633 iconSprite->
oam.word.attr23 = 0;
637 __asm__
volatile(
"");
638 iconSprite->
oam.f.x = commandWindow->
x * 8 + 8;
639 iconSprite->
oam.f.y = commandWindow->
y * 8 + 4;
640 iconSprite->
oam.f.tile =
645 commandWindow, 24, 0);
646 command->
range = cost;
670 priority = unit->
agi;
675 if (commandIndex != 0 &&
676 actors[commandIndex] == actors[commandIndex - 1]) {
682 command->
command = commandKind;
686 if (commandIndex < commandCount) {
692 if (commandIndex < commandCount) {
701 transferWords[4] =
'E';
702 transferWords[5] =
'D';
703 transferWords[6] =
'V';
704 transferWords[7] =
'S';
714 s32 Link_DrawWaitingForOpponent(
void) {
730 Link_DrawWaitingForOpponent();
748 if (peerSignature[4] ==
'E' && peerSignature[5] ==
'D' &&
749 peerSignature[6] ==
'V' && peerSignature[7] ==
'S') {
752 if (!(peerSignature[4] ==
'V' && peerSignature[5] ==
'S' &&
753 peerSignature[6] ==
'S' && peerSignature[7] ==
'T')) {
What every part of the menu object shares: its includes, edition values, macros and the link round st...
#define BATTLE_CLASS_ICON_X
#define BATTLE_MENU_MESSAGE_COPY
#define PSYNERGY_COST_SECOND_TILE
#define BATTLE_SUMMON_COST_COLUMN
#define BATTLE_SUMMON_ICON_X
#define BATTLE_ITEM_WINDOW_WIDTH
#define BATTLE_COMMAND_NAME_X
#define BATTLE_SUMMON_WINDOW_WIDTH
#define BATTLE_SUMMON_ELEMENT_COLUMN
#define BATTLE_MENU_MESSAGE_CAPACITY
@ ABILITY_KIND_HEAL_PP
Ember, Psy Crystal, Adept Ring.
@ ABILITY_KIND_HEAL_HP
Cure, Fizz, healing items.
@ ABILITY_EFFECT_CURE_ALL
Tonic.
@ ABILITY_EFFECT_RESTORE
Restore, Elixir.
@ ABILITY_EFFECT_CURE_POISON
Cure Poison, Antidote.
#define ABILITY_KIND_MASK
The low four bits of BattleAct.flags: how BattleTargetExec applies the ability's power.
struct BattleWork * gBattleWork
s32 Menu_RunCommandRow(s32 mode)
Selects a command icon, returning its kind, -1 for cancel or -2 for a shoulder-button switch.
struct UiWindow * UiText_ShowMessageAndWaitComplete(s32 message, s32 x, s32 y)
Opens a message at (x, y), waits for its text to finish, and returns its window so the caller can hol...
s32 BattleLayout_HighlightPartyPanels(u16 *ids)
Dims the party strip, then highlight the actor IDs up to the 0xff terminator.
s32 BattleParty_ListActorIdsFar(s32 groups, u16 *dst)
void BattlePres_SetActorModesFar(u16 *actors, s32 mode)
s32 BattleParty_CountStandbyDjinnFar(u32 unitId, u8 *counts)
void Camera_ConfigureSceneFar(s32 pos)
struct BattleUnit * UnitGetFar(u32 owner)
struct ItemDefinition * Item_GetDirectFar(s32 item)
s32 GameFlag_TestFar(s32 flag)
struct BattleAct * BattleActGet(s32 actionId)
Far call to BattleAction_GetDirect.
u32 Djinn_IsActiveFar(s32 owner, s32 index, s32 bit)
const struct SummonDefinition * SummonDefinition_Get(u32 summon_id)
Far call to SummonDefinition_GetNear.
s32 Djinn_GetAbilityIdFar(u32 group, u32 index)
s32 Battle_IsReviveEffectFar(s32 effect_id)
void AudioCommand_PlayFar(s32 id)
#define FLAG_DJINN_TUTORIAL
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
u8 gDebugMode
Debug builds: Start+Select pauses the frame loop.
s32 UiWork_IsComplete(void)
Returns 1 when every message channel has finished its text (or is idle), and 0 while one is still typ...
u16 gLinkPeerSignatures[][12]
24 bytes per peer
void UiText_RenderWideStringAtOffset(u16 *text, struct UiWindow *window, s32 x, s32 y)
Draws a zero-terminated string of 16-bit character codes into a text canvas window at pixel (x,...
void * MemAlloc(s32 size)
Allocates size bytes (rounded up to words) with no slot, from IWRAM when they fit and EWRAM otherwise...
void * Runtime_AllocateBlock(s32 kind, s32 size)
As Runtime_AllocateHeapBlock, but tries EWRAM first, for blocks that need room more than speed: the b...
volatile u32 gKeysHeld
Keys down now.
void UpdateLinkSessionCountdown(void)
Advances the link command-entry timer, slides the battle panels, and redraws the remaining seconds.
s32 UiText_ShowLocalizedMessageAndWait(void)
Tests whether this battle forbids escape.
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
void Runtime_ReleaseHeapBlock(s32 slot)
void MemFree(void *buffer)
s32 Battle_ClassifyEntryKind(const struct BattleAct *act)
Returns the target selection category for an ability's effect.
s32 Battle_CollectPartyCommands(struct BattleActionRecord *commands, u16 *actors, s32 commandCount)
Collects commands in party order, including target, cost and randomized priority.
s32 Resource_LoadIndexedIntoBuffer(s32 slotIndex, s32 icon)
Decodes a command-icon table entry in temporary transfer work and reload the requested cache slot.
s32 Resource_LoadIndexedEntryToBuffer(s32 resource, s32 index)
Builds the ability glyph in temporary transfer work, reloads the requested cache slot and returns its...
void Link_DrawShiftedTilePair(s32 offset)
Animates the two link indicator tiles with opposing two/three-pixel shifts.
s32 ItemIcon_LoadIntoSlot(s32 resource, s32 index)
Composes the item icon with style 0x1a in temporary transfer work and reload the requested cache slot...
s32 UiGlyph_LoadPortrait(u32 member, s32 cacheSlot)
Loads a party portrait into the supplied cache slot and returns its tile.
void Graphics_ExpandVramTilesByColorTable(u16 *dst)
Expands two palette variants of the ten source tile rows at 0x06000600, mapping each packed nibble th...
s32 Menu_BuildLocalizedPatternTiles(void)
s32 Scheduler_AddOrUpdateCallback(SchedulerCallback callback, s32 order)
Schedules callback with order, or gives a task already running it the new order, and re-sorts the tab...
s32 Scheduler_RemoveCallback(SchedulerCallback callback)
Unschedules the task running callback: clears its routine and gives it order 0x7fff,...
volatile u16 gLinkStatus
Link status, updated by the VBlank exchange handler.
struct SerialTransferState gSerialTransfer
An ability's definition, a row of gBattleAction_DefinitionTable: its targeting, kind,...
u8 ppCost
PP the ability costs.
u8 effect
enum AbilityEffect
u8 range
the aimed unit and range - 1 either side, or ABILITY_RANGE_ALL
u8 targetMode
TARGET_MODE_NONE, _FOES, _ALLIES or _SELF.
u8 flags
bits: 7 usable in battle | 6 usable in the field | 5..4 clear in every row | 3..0 kind (ABILITY_KIND_...
A unit's chosen action for the turn: its command, the command's parameter, its target and range,...
s16 target
the aimed unit's id
s16 parameter
an ability id, or CMD_ITEM's inventory index (-1 gone)
s16 command
enum BattleCommand
s16 range
the action's range
u16 priority
from the unit's Agility; higher acts first
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
u8 psySeal
bits: 7..3 Luff (16 when cast, minus 8 a turn) | 2..0 Bind's turns (7 when cast).
struct OwnerActionSlot actionSlots[32]
The action list: Psynergy taught for good, then the class's and the equipment's (Unit_RefreshPsynergy...
u8 classId
Who the unit is: a character's id (ISAAC to JENNA, below 8) or an enemy's id (BattleUnitSet).
u16 agi
Agility, 0 to 999: the order of the round's actions.
u16 inventory[15]
Items held, one entry each: bits 15..11 quantity | 10 broken | 9 equipped | 8..0 item id (INVENTORY_*...
The battle's own work: its enemies, units and their objects, the turn's actions, the spoils,...
u8 twoSided
1 in a link battle
u8 linkPaused
set when the link drops or the console's id changes
u8 linkSide
this console's multiplayer id
u16 actionId
the ability used, or taught as Psynergy
u16 encodedAction
bits: 15 from the class | 14 from an equipped item | 13..0 action id.
u8 payload[20]
one block of the data sent
A summon: its name's message and the Djinn of each element it needs.
u16 nameMessageId
The summon's ability id: its name is message MsgAbilityName plus it, and its low 14 bits pick the ico...
u8 djinnRequired[4]
standby Djinn needed, by element
The window system's work: the windows' tilemap, the windows, the three text channels,...
u8 mode
Set while Mind Read shows thoughts: round frame corners, colour 8 text with no shadow,...
u8 level
text tiles' palette; 15 by default, 14 or 5 for low HP
A window: a framed rectangle of the tilemap with its sprite outputs, its opening or closing animation...
u16 state
0 while a message channel is typing into the window; 1 once its text has ended or closed the window,...
void UiText_DrawNumberAtOffset(s32 value, s32 width, const struct UiWindow *window, s32 x, s32 y)
Draws a number (width as UiText_FormatNumber) as tiles in a window at pixel (x, y) of its interior.
void UiWindow_MarkVisibleTileAttributes(void)
Marks the text tiles the tilemap shows, and frees those it no longer shows.
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.
s32 VramCache_AllocEntry(s32 size)
Takes a free cache entry, gives it size bytes of sprite VRAM and returns its number.
s32 Resource_ResetEntry(u32 no)
Frees cache entry no: its blocks go back and the entry is marked free (offset 0xffff).
s32 Ui_RunOwnerStatusScreen(u16 *list, s32 listCount, s32 owner)
Shows a party member's stats and condition help until B or the link session ends.
s32 BattleTarget_RunSelection(s32 selection, s32 mode, u32 spread, u32 kind)
Chooses a party/enemy target and animates its selection markers.
void UiWindow_PutGlyph(struct UiWindow *win, u32 tile, u32 x, u32 y, s32 mode)
Puts a character into a window's tilemap as a tile at tile (x, y) of its interior.
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...
s32 Ui_FillVramBlockPattern(void)
Fills the text canvas with the window background colour (4).
void UiWork_Finalize(struct UiWindow *window, s32 instant)
Closes a window: clears its contents and remembers its last rectangle.
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,...