Alchemy
Loading...
Searching...
No Matches

battle.h

Go to the documentation of this file.
1#ifndef ALCHEMY_UNIT_BATTLE_BATTLE_H
2#define ALCHEMY_UNIT_BATTLE_BATTLE_H
3
4#include "types.h"
5
11struct BattleAct;
12struct BattleObj;
13struct BattlePlan;
15struct MotionObject;
16
19void DebugBattle_RunMenu(void);
21void BattleIntro_AnnounceEncounter(s32 enemyCount);
25void Party_ReservedNoOp5B14(s32 unused);
26#ifdef UBFIX
28#else
30#endif
31#ifdef UBFIX
33#else
35#endif
39#ifdef UBFIX
40void LinkBattle_SendParty(void);
41#else
43#endif
44u8 *Text_CopyFiveCharsPaddingUnderscore(u32 unused0, u32 unused1, u16 *source);
47#ifdef UBFIX
49#else
51#endif
53s32 Battle_RunEncounter(s32 enemyGroup);
62
63/// Pushes a message to show, waiting for the player to read it.
64#define PUSH_MESSAGE(message) BattleEvPush(BATTLE_EVENT_MESSAGE, (message))
65
66/// Moves camera yaw by 512 while L/R is held; two identical functions exist.
67#define DEFINE_ADJUST_CAMERA(name) \
68 void name(void) { \
69 struct BattleCamera *cam = WORK_SLOT(HEAP_SLOT_CAMERA); \
70 struct BattlePresentationTransition *trans = \
71 WORK_SLOT(HEAP_SLOT_BATTLE_BACKGROUND); \
72 \
73 if ((gKeysHeld & KEY_L) != 0) { \
74 cam->yaw += 512; \
75 } \
76 if ((gKeysHeld & KEY_R) != 0) { \
77 cam->yaw -= 512; \
78 } \
79 if (trans->flag == 0) { \
80 BattleCamera_SetRange(0x780000, 0x780000, 0, 0, 0x10000); \
81 } \
82 }
83
85s32 BattleEnemyList(s16 *unitIds);
86s32 BattleParty_ListLivingUnits(s32 sideMask, u16 *unitIds);
87s32 BattleParty_ListActorIds(s32 sideMask, u16 *unitIds);
88void BattleObjPut(void);
91s32 EnemyCheck(s32 classId);
93#ifdef UBFIX
95#else
97#endif
100void BattleObjMake(struct BattleObj *actor, s32 unitId, s32 x, s32 y);
101void BattlePlacement_GetStepPair(s32 partyPlace, s32 *x, s32 *y);
102void Summon_LayoutPositions(u16 *actorIds, s32 count, s32 *xPositions,
103 s32 *zPositions);
104s32 EnemySlotGet(void);
105#ifdef UBFIX
106void EnemyUpdate(void);
107#else
108s32 EnemyUpdate(void);
109#endif
113#ifdef UBFIX
114void BattleUnit_BuildStatusFlags(s32 unitId, struct BattleObj *battleObject);
115#else
116s32 BattleUnit_BuildStatusFlags(s32 unitId, struct BattleObj *battleObject);
117#endif
118#ifdef UBFIX
119void BattleStatusIcon_Cycle(struct BattleObj *battleObject);
120#else
121s32 BattleStatusIcon_Cycle(struct BattleObj *battleObject);
122#endif
123#ifdef UBFIX
125#else
127#endif
129void BattleActor_SpawnObjectsForList(s16 *unitIds, s32 refreshPoses);
130struct BattleObj *BattleObjGet(s32 unitId);
131void ResetMotionRecordGroup(void *recordGroup);
134#ifdef UBFIX
136#else
138#endif
139s32 Battle_GetWorkEntryPair(s32 place, struct FixedPointPosition *position);
140#ifdef UBFIX
142#else
144#endif
145s32 BattleMotion_ProjectPosition(s32 unitId, s32 *projected);
146void *GetMotionRecord(struct MotionObject *object, s32 recordIndex);
148void ObjMotRst(s32 unitId);
150void BattleMotion_InterpolatePosition(struct BattleObj *startSlot,
151 struct BattleObj *endSlot, s32 progress);
152void BattleMotion_SetObjectPosition(struct BattleObj *battleObject);
155void BattleMotion_ApplyVariantMotion(s32 unitId, s32 variant);
156void BattleMotion_ApproachTarget(s32 actorId, s32 targetId, s32 travelDivisor,
157 s32 initialVelocityY);
160void BattleMotion_ApplyPairMidpoint(s32 firstId, s32 secondId);
165
167 struct BattleActionRecord *entries);
173 struct BattleActionRecord *action);
176void BattlePresentation_ApplyUnitDamage(u32 unitId, s32 damage, s32 showMessage,
177 u8 *context);
180
182void Camera_ConfigureScene(s32 verticalOffset);
187void BattleQueue_SortByPriority(struct BattleActionRecord *entries, s32 count);
189 s32 count);
194void Battle_ReservedNoOp9B2C(void);
195
197 s32 delay);
198#ifdef UBFIX
199void BattlePres_BuildTargetList(struct BattlePlan *plan,
201#else
204#endif
207#ifdef UBFIX
208void BattlePres_RunActorEntries(struct BattlePlan *plan, s32 unused);
209#else
210s32 BattlePres_RunActorEntries(struct BattlePlan *plan, s32 unused);
211#endif
212s32 BattlePres_RunAttack(struct BattlePlan *plan, s32 mode);
213s32 BattlePres_RunPlainAttack(struct BattlePlan *input, s32 flags);
214s32 BattlePres_RunItem(struct BattlePlan *plan, s32 unused,
215 struct BattleActionRecord *selection);
216#ifdef UBFIX
218 s32 palette);
219#else
221#endif
222s32 BattlePres_RunPsynergyCast(struct BattlePlan *plan, s32 mode);
223
224void BattleMotion_FlashHit(s32 unitId, s32 unused0, s32 unused1);
226void BattleMotion_ShowDowned(s32 unitId);
227s32 BattleTarget_SelectRandomPosition(s32 requireLivingUnit);
228s32 BattleTarget_SelectForAction(s32 actorId, struct BattleAct *action);
229#ifdef UBFIX
231#else
233#endif
234#ifdef UBFIX
236#else
238#endif
239#ifdef UBFIX
241#else
243#endif
244void BattleEv_MarkDisplay(void);
245#ifdef UBFIX
247#else
249#endif
250void BattleEv_GrantDjinnBonus(struct BattleEventState *runtime, u32 operand);
251#ifdef UBFIX
252void BattleEv_DispatchQueued(void);
253#else
255#endif
256u32 BattleEvPush(u32 opcode, u32 operand);
258#ifdef UBFIX
259void BattleTargetExec(struct BattlePlan *plan, s32 slot);
260#else
261s32 BattleTargetExec(struct BattlePlan *plan, s32 slot);
262#endif
263u32 Ability_IsPsynergy(s32 abilityId);
264#ifdef UBFIX
266 s32 retry);
267#else
269 s32 retry);
270#endif
271void Dma_StopAllThenRunHook(void);
274void BattleEvent_Playback(void);
275void BattleEventRuntime_Reset(void);
276#ifdef UBFIX
278#else
280#endif
282s32 BattleParty_CountStandbyDjinn(u32 unitId, u8 *counts);
284 struct BattlePlan *plan);
285
286s32 BattleUnit_RollCounterEarlyEnd(s32 unitId, s32 turns, s32 bias);
295void Battle_ReservedNoOpF674(void);
296#ifdef UBFIX
297void Battle_ProcessRoundEnd(void);
298#else
300#endif
301#ifdef UBFIX
302void BattleUnit_ProcessTurnEnd(struct BattlePlan *plan);
303#else
305#endif
306
308void Graphics_BuildSequentialTileTable(void *tilemap);
309void BattlePresentation_BuildTilemap(void *tilemap);
314void Graphics_ClearBg0Vofs(void);
315void BattlePres_RunEntryTransition(s32 enemyCount, s32 encounterId);
316void BattlePresentation_SetPaletteLevel(s32 unused, s32 level);
317void BattlePresentation_ConfigurePaletteFade(s32 mode, s32 unusedResource,
318 s32 fade);
321void BattleBackground_Load(s32 mode, s32 resourceId, s32 level);
322void BattleCamera_SetRange(s32 centerX, s32 centerY, s32 offsetX, s32 offsetY,
323 s32 scale);
324#ifdef UBFIX
326#else
328#endif
329void BattlePres_SetupTransitionScene(s32 x, s32 depth, s32 y, s32 zoom);
330void BattlePres_SetupTransitionAtPairMidpoint(s32 firstUnitId, s32 secondUnitId,
331 s32 zoom);
332void Graphics_FadeAlphaOut(void);
333void Graphics_FadeAlphaIn(void);
334void Graphics_SetBlendControl(void);
336 struct BattleTransitionEntry *entries);
339void BattlePres_SetActorRecordMode(s32 actorId, s32 mode);
340void BattlePres_SetOtherActorRecordModes(s32 selectedUnitId);
343void BattlePres_SetActorModes(u16 *selectedUnits, s32 mode);
344
345#ifdef UBFIX
346void BattleFx_UpdateStarField(void);
347#else
349#endif
350#ifdef UBFIX
351void BattleFx_UploadStarField(void);
352#else
354#endif
357s32 Graphics_ScaleRgb555Clamped(u16 *source, u16 *destination, s32 scale,
358 s32 count);
359// The native implicit-int declaration disagrees with the later void definition.
360// A plain prototype keeps EN size but changes its first caller at .text+0x4c62.
361#ifdef UBFIX
362void BattleFx_PlayUnitElementEffect(s32 unitId, s32 element, s32 mode,
363 s32 variant);
364#endif
367
370#ifdef UBFIX
371void BattleEnemy_AdjustLevel(s32 owner, s32 levels);
372#else
373s32 BattleEnemy_AdjustLevel(s32 owner, s32 levels);
374#endif
375s32 BattleEnemy_ClaimNameLetter(s32 classId, s32 unused);
376#ifdef UBFIX
378#else
380#endif
381#ifdef UBFIX
383#else
385#endif
386s32 BattleGroupRandom(s32 recordId);
388
397
398u32 BattleSpoils_RankItem(u32 inventoryEntry);
399void BattleSpoils_Clear(void);
400s32 BattleEnemy_RecordDefeat(s32 unitId, s32 djinnBonus);
401void Battle_AwardSpoils(void);
402void Battle_ReservedNoOp2A08(void);
403
404#endif
s32 BattlePres_RunUnitAction(struct BattleActionRecord *action)
Auto battle: an attack or an item.
void BattlePres_AdjustCameraByShoulderKeys(void)
Turns the camera while L or R is held. Nothing in the source calls it.
Definition auto_battle.c:83
void BattleMotion_SetMode5AndActivateSlot(s32 unitId)
For a unit whose HP has run out: plays its falling animation to the last frame and marks its object f...
s32 BattleObject_IsValidId(u32 unitId)
Returns 0 for a party member's or an enemy's unit id, -1 for any other.
s32 BattlePres_RunApproachAction(struct BattleActionRecord *input)
Auto battle: an attack.
s32 BattleTarget_ReplaceDefeated(const struct BattleActionRecord *action)
Returns the action's target, or a random living unit of its side when the target is down; TARGET_SIDE...
s32 BattleEscape_PlayRun(struct BattleActionRecord *action)
Auto battle: the party tries to run, and gets away 15 times in 16, each living member running off in ...
void BattlePresentation_ApplyUnitDamage(u32 unitId, s32 damage, s32 showMessage, u8 *context)
Auto battle: deals damage HP to unit unitId and shows it.
s32 BattlePres_ShowDefendMessage(const struct BattleActionRecord *action)
Auto battle: shows that a standing unit is defending.
s32 BattlePresentation_BuildSortedUnitEntries(struct BattleActionRecord *entries)
Auto battle: gives every living unit a plain attack and sorts them into turn order.
Definition auto_battle.c:12
s32 BattlePres_RunAction(struct BattleActionRecord *action)
Auto battle: plays one action.
Definition auto_battle.c:90
s32 BattlePresentation_RunPairedUnitTransition(struct BattleActionRecord *action)
Auto battle: casts Psynergy.
void BattlePresentation_InitializeWorkAndResetState(void)
Allocates the perspective plane's scanline work (heap slot 10) cleared, and sets the background's mod...
Definition background.c:145
void BattlePres_SetOtherActorRecordModes(s32 selectedUnitId)
Makes every unit's sprites semi-transparent but selectedUnitId's, which are left as they are; nothing...
Definition background.c:552
void Runtime_ReleaseHeapBlock10(void)
Frees the perspective plane's scanline work (heap slot 10); called by Battle_RunEncounter as the batt...
Definition background.c:156
void BattlePres_ClearAllActorRecordModes(void)
Returns every unit's sprites to OBJ mode 0; called by BattlePres_SetActorModes when the highlight sto...
Definition background.c:565
void BattlePres_SetActorRecordMode(s32 actorId, s32 mode)
Sets the OBJ mode (1 semi-transparent, 0 normal) of every sprite of a unit's battle object,...
Definition background.c:515
void Graphics_SetBlendControl(void)
Sets REG_BLDCNT to lighten every layer by REG_BLDY; nothing calls it.
Definition background.c:458
void BattlePresentation_InitializeTransitionEntries(struct BattleTransitionEntry *entries)
Sets entries to the identity transform, then stores the first word's old value plus its new one in th...
Definition background.c:465
s32 BattlePres_DivideBy16(s32 value)
Nothing calls it.
Definition background.c:475
void Graphics_FadeAlphaIn(void)
Fades BG2 in over the backdrop in eight frames, its blend weight rising by 2 a frame from 1,...
Definition background.c:438
void Graphics_AdvancePaletteCycle(void)
Lightens the opaque sprites, the highlighted units, by the next step of gBattleFx_HighlightBlendRamp.
Definition background.c:580
void BattlePres_SetupTransitionAtPairMidpoint(s32 firstUnitId, s32 secondUnitId, s32 zoom)
Points the battle camera, through BattlePres_SetupTransitionScene, at the ground between two units' b...
Definition background.c:406
void Graphics_FadeAlphaOut(void)
Fades BG2 out over the backdrop in eight frames, its blend weight falling by 2 a frame from 15,...
Definition background.c:424
void BattleBackground_Load(s32 mode, s32 resourceId, s32 level)
Loads a battle background: its picture into character blocks 2 and 3, its palette into BattleWork....
Definition background.c:170
s32 Runtime_AdjustDebugValueWithButtons(s32 selectedValue)
A debug aid: while Start is held, edits BattleWork.debugValue with the d-pad (1 left and right,...
Definition background.c:481
void BattlePres_SetupTransitionScene(s32 x, s32 depth, s32 y, s32 zoom)
Points the battle camera at (x, depth, y) with a zoom in percent, and lines the perspective plane up ...
Definition background.c:359
void BattlePresentation_ConfigurePaletteFade(s32 mode, s32 unusedResource, s32 fade)
Switches the background's display mode, optionally sets its palette, and rebuilds both its maps.
Definition background.c:85
void BattlePres_SetActorModes(u16 *selectedUnits, s32 mode)
Highlights the units in selectedUnits, a list ended by BATTLE_UNIT_LIST_END, or with mode 0 stops the...
Definition background.c:609
void BattleCamera_SetRange(s32 centerX, s32 centerY, s32 offsetX, s32 offsetY, s32 scale)
Builds the perspective plane's next page for a zoom of scale about centerX and centerY (all 16....
Definition background.c:224
void BattlePresentation_SetPaletteLevel(s32 unused, s32 level)
Copies the background's saved palette to BG palettes 6 to 13, darkened by level (0 for none).
Definition background.c:42
UNUSED void BattlePres_SetupTransitionSceneAtDepth(s32 x, s32 depth, s32 y)
Sets the camera's eye at its stored distance without taking a zoom; nothing in the source calls it.
Definition background.c:301
u32 BattleClass_GetAttackEffect(u32 index)
Returns the effect a class's plain attack shows, 1 for none or out of range.
Definition classes.c:60
s32 BattleClass_GetPalette(s32 index)
Returns the class's sprite palette.
Definition classes.c:35
u32 BattleClass_GetAttackHop(u32 index)
Returns how high a class hops as it runs up to attack, in pixels; 0 out of range.
Definition classes.c:73
s32 BattleClass_IsSmall(s32 index)
Returns 1 for a small class, which takes one enemy sprite slot instead of two and stands closer to it...
Definition classes.c:45
s32 BattleClass_GetEffectHeight(s32 index)
Returns the height an effect is drawn at over a class, in pixels, or 0 for its size's default; 0 out ...
Definition classes.c:95
s32 BattleClass_GetSprite(s32 index)
Returns the class's battle sprite, row 0's for a class out of range.
Definition classes.c:24
s32 Summon_IsEntrySecondaryFlagged(s32 index)
Returns 1 for a class whose blow lands with SE_HEAVY_IMPACT instead of SE_133; 0 out of range.
Definition classes.c:85
u32 BattleClass_GetDefeatSoundKind(s32 index)
Returns the class's defeat-sound kind, 0 to 4, or -1 for none; a fallen enemy's sound is SE_146 plus ...
Definition classes.c:11
void DebugBattle_ViewMessages(void)
Debug: a message viewer that never returns.
Definition debug.c:153
s32 DebugParty_LoadPreset(s32 preset)
Debug: replaces the party with the members of preset number preset.
Definition debug.c:53
void DebugBattle_RunMenu(void)
Debug: the battle test menu, which never returns.
Definition debug.c:253
s32 BattleParty_ListLivingUnits(s32 sideMask, u16 *unitIds)
Lists the units still standing (HP above 0) on the sides in sideMask (BATTLE_SIDE_PARTY,...
Definition encounter.c:437
s32 BattleEnemyList(s16 *unitIds)
Lists the enemy units present, ended by BATTLE_UNIT_LIST_END, and returns how many there are (0 when ...
Definition encounter.c:401
s32 Battle_RunEncounter(s32 enemyGroup)
Fights the battle against the enemy formation enemyGroup, from the opening transition to the end,...
Definition encounter.c:44
s32 BattleParty_ListActorIds(s32 sideMask, u16 *unitIds)
Lists the units in the battle's unit lists on the sides in sideMask, party first, skipping those remo...
Definition encounter.c:510
s32 BattleParty_PrepareActiveOwners(u16 *owners)
Lists the party members who fight (the first four of the party, three in a link battle) and marks eac...
Definition encounter.c:371
s32 BattleActor_ResetRuntimeFields(s32 unitId)
Clears every ailment and stat change of a unit that goes down, recalculates its stats and rebuilds it...
Definition events.c:19
void BattleEv_MarkDisplay(void)
Sets gBattleDisplayWork->marked, which the next message reads, as BATTLE_EVENT_MARK does.
Definition events.c:189
u32 BattleEvPush(u32 opcode, u32 operand)
Queues one battle event (enum BattleEventOpcode) with its operand, and returns the opcode.
Definition events.c:321
u32 BattleEv_DispatchQueued(void)
Plays the queued battle events at once, in order (BattleEvent_Playback plays them over frames instead...
Definition events.c:241
s32 BattleActor_DestroyTemporaryObject(s32 unitId)
Takes an enemy out of the battle at once (one that leaves rather than falls): its HP to 0,...
Definition events.c:200
void BattleEv_GrantDjinnBonus(struct BattleEventState *runtime, u32 operand)
The BATTLE_EVENT_DJINN_BONUS event: grants the Djinn bonus for the rest of the action.
Definition events.c:226
s32 BattlePresentation_WaitForPromptAt(s32 x, s32 y)
Shows the cursor bobbing at (x, y) and waits for one of KEY_ADVANCE.
Definition events.c:152
s32 BattlePresentation_WaitForAdvance(void)
Shows the bobbing arrow at the message window and waits for the player to go on (B,...
Definition events.c:90
s32 BattleMotion_ProjectPosition(s32 unitId, s32 *projected)
Projects unit id's position onto the screen, into projected.
Definition objects.c:611
void Camera_InitDefaultTransform(void)
Puts the battle camera at its default view of the battlefield's centre.
Definition objects.c:644
void BattleActor_UpdateSpritePriorities(void)
Runs each frame of a battle: advances every unit's status icon, lifts an airborne unit's effect sprit...
Definition objects.c:16
void ResetMotionRecordGroup(void *recordGroup)
Detaches the scripts from the four sprite entries of one sprite.
Definition objects.c:497
void BattleActor_SpawnObjectsForList(s16 *unitIds, s32 refreshPoses)
Readies the sprites of the units in list: releases those of every place list lacks,...
Definition objects.c:356
s32 BattlePres_SetActorModeAndAction(s32 unitId)
Sets unit id's pose to match its state: held (asleep, stunned or unable to move) or down,...
Definition objects.c:294
s32 Battle_GetWorkEntryPair(s32 place, struct FixedPointPosition *position)
Writes the battlefield spot of place (its anchor, on the ground) to position.
Definition objects.c:581
struct BattleObj * BattleObjGet(s32 unitId)
Returns unitId's battle object, through its place, or null for a unit with no place.
Definition objects.c:480
s32 BattleStatusIcon_Cycle(struct BattleObj *battleObject)
Shows a unit's status icons one after another, each for ICON_CYCLE_FRAMES frames, switching at once w...
Definition objects.c:204
void ResetBattleObjectRecordGroups(struct MotionObject *object)
Detaches the scripts from every sprite of a battle object.
Definition objects.c:511
s32 Camera_ApplyTransformByFlag(void)
Sets up the camera's view for projecting points; under FLAG_CHOOSING_COMMANDS, through the extra tran...
Definition objects.c:597
s32 BattleUnit_BuildStatusFlags(s32 unitId, struct BattleObj *battleObject)
Builds the status icon bits of unit id's ailments into its battle object's activeConditions,...
Definition objects.c:155
s32 BattleObj_MarkForRelease(s32 unitId)
Frees the enemy sprite slots unitId holds and marks its object for release at the end of the round (B...
Definition objects.c:543
void * BattleMotion_DestroyAllSlotObjects(void)
Releases the object of every unit marked by BattleObj_MarkForRelease, leaving its battle object with ...
Definition objects.c:557
void * GetMotionRecord(struct MotionObject *object, s32 recordIndex)
Returns sprite recordIndex of an object (0 only, for a single sprite), or null when it has no such sp...
Definition objects.c:628
void ReleaseBattleObjectRecords(s32 unitId)
Releases every sprite unitId's object holds and leaves it with none, clearing the battle object's ani...
Definition objects.c:321
void BattleParty_CollectUnitList(void)
Fills the battle's two unit lists, each ended by BATTLE_UNIT_LIST_END: the party members in their ord...
Definition setup.c:135
void BattleIntro_AnnounceEncounter(s32 enemyCount)
Announces the enemies at the start of a battle, then whether the party strikes first or is caught by ...
Definition setup.c:90
s32 BattlePresentation_InitializeTilePattern(void)
Moves the 16 bytes at VRAM 0x06000290 down to 0x06000280 and clears the 20 bytes from 0x0600028c.
Definition setup.c:173
void BattlePresentation_UpdateCamera(void)
Runs each frame of a battle.
Definition setup.c:18
struct BattleSummonState * BattleSummon_UpdateAvailability(void)
Works out which summons the party can call: one whose Djinn requirement of every element is met by th...
Definition setup.c:337
void Party_ReservedNoOp5B14(s32 unused)
Does nothing; Battle_RunEncounter calls it with 1 as the battle is set up.
Definition setup.c:188
s32 BattleParty_ReconcileDjinnRecovery(void)
Brings the Djinn recovery list up to date as a battle starts: every Djinni a party member has on stan...
Definition setup.c:260
s32 BattleParty_ResetActiveRuntimeFields(void)
Clears every battle-only state of the party members (stat stages and their turns, statuses,...
Definition setup.c:197
void BattlePresentation_ClearBg0VerticalOffset(void)
Nothing in the source calls it.
Definition setup.c:180
void BattleSummon_ReservedNoOp(void)
Does nothing; nothing in the source calls it.
Definition setup.c:401
void BattleObjPut(void)
Readies the sprite of every unit in the battle (releasing those of units that left) and sets each one...
Definition sprites.c:13
void BattleParty_ListAllUnitsAndSubmit(void)
Readies the sprite of every unit in the battle (releasing those of units that left),...
Definition sprites.c:22
s32 SummonSlot_RegisterActorSprites(s32 unitId)
Loads an enemy unit's battle sprite into the first free enemy sprite slots (one for a small enemy,...
Definition sprites.c:67
s32 BattleUnit_LookupWeaponValueByClass(s32 unitId)
Returns the weapon sprite a party member's attack shows for the kind of weapon they have equipped (gB...
Definition sprites.c:197
s32 BattleUnit_GetWeaponKind(s32 itemId)
Returns the kind of the weapon whose item id is itemId (0 to 5), which picks a party member's attack ...
Definition sprites.c:163
s32 BattleMotion_ReleaseObjectSlotByValue(s32 unitId)
Frees every enemy sprite slot unit unitId holds, unloading its sprite.
Definition sprites.c:141
s32 EnemyCheck(s32 classId)
Returns 1 if an enemy of class classId would find room among the enemy sprite slots: one free slot fo...
Definition sprites.c:41
s32 BattleMotion_GetSlotPalette(s32 id)
Returns the palette of unit id's battle object.
Definition sprites.c:32
void BattlePresentation_BuildTilemap(void *tilemap)
Builds BG1's flat map of the same picture: rows 0 to 3 0xffff, rows 4 and 5 tile 0x3ff,...
Definition transition.c:106
void BattlePres_AdvanceTransitionTimer(void)
Advances the curtain opening by a frame: scrolls BG0 from 32 pixels to 0 over frames 20 to 52,...
Definition transition.c:167
void BattlePresentation_UploadTileVariant(void)
Copies one of eight curtain tiles from gBattlePres_TileVariants into CURTAIN_TILE(0),...
Definition transition.c:153
void BattlePres_UpdateHBlankScroll(void)
Shows the perspective plane's finished page each frame while the background is in mode 2: its first l...
Definition transition.c:132
void Graphics_ClearBg0Vofs(void)
Clears REG_BG0VOFS, so that BG0's scroll applies only above the line the interrupt fires on.
Definition transition.c:252
void BattlePres_RunEntryTransition(s32 enemyCount, s32 encounterId)
Opens a battle: the curtain opening, or for the Fusion Dragon the storm on the Venus Lighthouse aerie...
Definition transition.c:272
void BattlePres_DrawTransitionRows(void)
Draws a frame of the curtain opening on BG1: over 80 frames a row moves up from row 13 to row 4 and i...
Definition transition.c:202
void Graphics_BuildSequentialTileTable(void *tilemap)
Builds the perspective plane's 32 by 32 affine map: tiles 0 to 255 in its first eight rows,...
Definition transition.c:75
s32 BattlePres_RunMosaicFadeOut(void)
Fades the screen to black over sixteen frames as every background's mosaic grows, then shows no layer...
Definition transition.c:22
s32 BattleCommand_SelectAutomatic(struct BattleActionRecord *request, s32 retry)
Chooses an enemy's action (a party member's is chosen in the menu): one of the eight in its definitio...
Definition enemy_ai.c:33
s32 BattleEnemy_LetterFirstOfClass(s32 classId)
Gives the first enemy of the class on the field the first letter (0), appended to its name,...
Definition formation.c:362
s32 BattleFormation_BuildEnemyList(s32 recordId)
Builds the battle's enemies from formation recordId and returns how many there are.
Definition formation.c:451
s32 BattleGroupRandom(s32 recordId)
Returns the class id of a random member of the formation, among those that may appear (maximum count ...
Definition formation.c:407
s32 BattleFormation_SelectLevelMatchedCandidate(s32 *outMargin)
Chooses a monster battle's formation for the party's level, and returns it with the levels its enemie...
Definition formation.c:102
s32 BattleFormation_AverageLevel(s32 recordId)
Returns a formation's average enemy level, for the monster battles to choose by.
Definition formation.c:24
s32 BattleEnemy_AdjustLevel(s32 owner, s32 levels)
Raises an enemy by levels, or lowers it for a negative count: each base stat changes by a fixed amoun...
Definition formation.c:202
s32 BattleEnemy_ClaimNameLetter(s32 classId, s32 unused)
Gives an enemy of the class its name letter, which tells it from others of its kind,...
Definition formation.c:269
s32 BattleEnemy_ReleaseNameLetter(s32 actorId)
Frees a departing enemy's name letter for the next of its class, reading the letter back from the end...
Definition formation.c:320
void BattleMotion_SpawnSlotEffectAndWait(s32 unitId)
Plays the hit flash on unit id's sprite and waits ten frames.
Definition motion.c:286
s32 BattleMotion_ProjectConditionalPosition(s32 unitId, s32 *projected)
Projects the point above unit id onto the screen, into projected: 24 pixels up for a small enemy,...
Definition motion.c:331
void BattleMotion_InterpolatePosition(struct BattleObj *startSlot, struct BattleObj *endSlot, s32 progress)
Sends the unit of startSlot leaping progress percent of the way toward the unit of endSlot,...
Definition motion.c:67
void BattleMotion_ApplyPairMidpoint(s32 firstId, s32 secondId)
Works out the point halfway between two units, at their move targets where they have one,...
Definition motion.c:244
void BattleMotion_SetObjectPosition(struct BattleObj *battleObject)
Sends a unit's object back to its spot. Nothing in the source calls it.
Definition motion.c:96
void BattleMotion_ApproachTarget(s32 actorId, s32 targetId, s32 travelDivisor, s32 initialVelocityY)
Sends unit actorId three quarters of the way to unit targetId, arriving in travelDivisor steps,...
Definition motion.c:191
void BattleMotion_ResetObjectAtScaledAnchor(s32 unitId)
Sends unitId hopping out to one and a half times its spot's distance from the centre.
Definition motion.c:111
s32 BattleUnit_GetEffectHeight(s32 unitId)
Returns the height above unit id where its effects play, 16.16: its class's own (BattleClass_GetEffec...
Definition motion.c:352
void BattleMotion_InitializeObject(s32 unitId)
Sends unit id leaping back to 1.3 times its spot's distance from the centre, in pose 5.
Definition motion.c:135
s32 BattleMotion_ProjectScaledPosition(s32 unitId, s32 *projected)
Projects the point above unit id where its effects play (its class's height, BattleUnit_GetEffectHeig...
Definition motion.c:310
void BattleMotion_ResetSlotObjectMode2(s32 unitId)
Restarts unit id's motion in pose 2. Nothing in the source calls it.
Definition motion.c:229
void BattleMotion_ReservedNoOp83B0()
Does nothing; BattleMotion_ApplyPairMidpoint, its only caller, passes it a position and a distance.
Definition motion.c:239
void BattleMotion_ApplyVariantMotion(s32 unitId, s32 variant)
Knocks unit id back, by the speed, hop and distance of motion variant (gBattleMotion_Variant*),...
Definition motion.c:160
void ObjMotRst(s32 unitId)
Sends unitId back to its spot, landing there, and turns it to face the centre.
Definition motion.c:17
void BattleMotion_SetupEscapeObject(s32 unitId)
Sends unitId running off its side of the battlefield, three times as far out as its spot,...
Definition motion.c:46
void BattleUnit_RefreshPlacement(void)
Places every unit at the start of a battle: numbers the places (party members 0 up in their order,...
Definition placement.c:379
s32 BattlePlacement_ContainsId(s16 *list, s32 place)
Returns 1 if the unit at place is in list.
Definition placement.c:436
s32 EnemySlotGet(void)
Returns the id of the first free enemy unit, or -1 when all six are taken.
Definition placement.c:328
void BattleObjMake(struct BattleObj *actor, s32 unitId, s32 x, s32 y)
Creates the battle object of unit at (x, y) on the battlefield, in pixels: its sprite (an enemy's fro...
Definition placement.c:24
s32 EnemyUpdate(void)
Lays the enemies out again and moves each one's object anchor to its new place.
Definition placement.c:348
void Summon_LayoutPositions(u16 *actorIds, s32 count, s32 *xPositions, s32 *zPositions)
Lays out count enemies in a column 80 pixels left of the centre, spaced by their size (38 pixels arou...
Definition placement.c:290
void BattlePlacement_GetStepPair(s32 partyPlace, s32 *x, s32 *y)
Reads the battlefield position of party place index from gBattlePlacement_StepPairs,...
Definition placement.c:274
s32 BattleCommand_BuildPlan(struct BattleActionRecord *request, struct BattlePlan *plan)
Announces the action and plans its targets and effects.
Definition plan.c:108
s32 BattleParty_CountStandbyDjinn(u32 unitId, u8 *counts)
Counts the standby Djinn whose owners fight on unitId's side, from that side's Djinn recovery list.
Definition plan.c:37
u32 BattleParty_IsUnitListed(u32 unitId)
Returns one when the unit is in its side's formation.
Definition plan.c:11
s32 BattleEventRuntime_SchedulePhase(s32 frames)
Empties the event queue and schedules playback of the events queued next, with no targets to resolve.
Definition playback.c:49
s32 BattleEventRuntime_WaitForReady(void)
Waits, a frame at a time, until BattleEvent_Playback has played every target, then removes the callba...
Definition playback.c:458
void BattleEventRuntime_Reset(void)
Stops playback and empties the event queue.
Definition playback.c:437
void BattleEventRuntime_BeginPhase(s32 cue)
Starts playback of the plan's targets when the effect's blow lands.
Definition playback.c:27
void BattleEvent_Playback(void)
Plays the plan's targets one at a time: resolves the next target with BattleTargetExec,...
Definition playback.c:87
void Dma_StopAllThenRunHook(void)
Sets DMA3 three times over, stopping it, then calls the IRQ return instruction's word as a routine.
Definition playback.c:14
s32 BattlePresentation_BuildActions(struct BattleActionRecord *actions)
Builds the turn's actions and sorts them into turn order: the party's commands, then the link opponen...
Definition round.c:620
void Palette_UpdatePulseBrightness(void)
Pulses BG palette 14's colours: each takes the matching colour of palette 15 brightened by up to twel...
Definition round.c:14
void Palette_CopyBanksWithBrightnessOffset(s32 offset)
Copies BG palette 15 to 14 and 5 to 4, brightened or darkened.
Definition round.c:562
void BattleQueue_SortByPriority(struct BattleActionRecord *entries, s32 count)
Sorts the round's actions into turn order, fastest first, after moving the guarding and grounding Dji...
Definition round.c:323
s32 Battle_GetTaggedSlotValue(s32 taggedPlace)
Returns the unit id at a list place.
Definition round.c:711
s32 BattleEscape_CheckSuccess(void)
Rolls whether the party gets away.
Definition round.c:145
s32 BattlePres_BuildUnitEntries(struct BattleActionRecord *entries)
The party's actions for the round, from the command menu: a member who is asleep, confused,...
Definition round.c:191
void Battle_ReservedNoOp9B2C(void)
Does nothing; Battle_RunEncounter calls it at the start of each round.
Definition round.c:752
void BattleUnit_ResetGuardLevels(void)
Ends every unit's guard (Defend and the like) and recalculates its stats.
Definition round.c:119
void Camera_ConfigureScene(s32 verticalOffset)
Sets the camera up for the fixed view the battle shows while commands are chosen, raised by verticalO...
Definition round.c:65
s32 BattlePresentation_AppendLinkedActions(struct BattleActionRecord *actions, s32 count)
Link battle: exchanges the round's actions with the other console and appends the opponent's after th...
Definition round.c:397
void BattlePres_AdjustCameraByShoulderKeysAlt(void)
Turns the camera while L or R is held (a second copy).
Definition round.c:749
s32 Battle_FindTaggedSlotByValue(u32 unitId)
Returns the list place of unit id, or -1 if it is in neither list: the party's as 0x100 | place,...
Definition round.c:724
s32 BattlePres_BuildOpponentEntries(struct BattleActionRecord *entries)
The enemies' actions for the round, in a shuffled order, each chosen by BattleCommand_SelectAutomatic...
Definition round.c:244
u32 BattleSpoils_RankItem(u32 inventoryEntry)
Ranks an item among the spoils, 0 for none: an indispensable item first, then a rare item,...
Definition spoils.c:12
void BattleSpoils_Clear(void)
Empties the battle's spoils (BattleWork.spoils) and gGameState.pendingItem.
Definition spoils.c:33
void Battle_AwardSpoils(void)
Hands out the spoils after a victory: the experience to each party member still standing,...
Definition spoils.c:194
s32 BattleEnemy_RecordDefeat(s32 unitId, s32 djinnBonus)
Counts a fallen enemy and adds its coins, experience and perhaps its item to the spoils.
Definition spoils.c:99
void Battle_ReservedNoOp2A08(void)
Does nothing; the debug battle menu (DebugBattle_RunMenu) calls it.
Definition spoils.c:326
s32 BattlePresentation_DispatchAction(struct BattleActionRecord *request, s32 delay)
Plays one action of the round, after delay frames facing the party: an enemy picks its ability now; t...
Definition staging.c:18
s32 BattlePres_RunActorEntries(struct BattlePlan *plan, s32 unused)
Clears the highlights, then applies the action to each target in turn and plays its events; with no t...
Definition staging.c:428
s32 BattlePres_RunItem(struct BattlePlan *plan, s32 unused, struct BattleActionRecord *selection)
Plays an item's use: the camera turns to the user's side, the user raises the item and,...
Definition staging.c:700
UNUSED s32 BattlePres_RunPlainAttack(struct BattlePlan *input, s32 flags)
Unused.
Definition staging.c:617
s32 BattlePres_RunEscape(struct BattlePlan *plan)
Plays a unit's attempt to run.
Definition staging.c:175
void BattleMotion_FlashHit(s32 unitId, s32 unused0, s32 unused1)
Flashes unit id as it is hit: puts it in its damage pose and switches its sprites between white and t...
Definition staging.c:978
s32 BattlePres_RunPsynergyCast(struct BattlePlan *plan, s32 mode)
Plays Psynergy, a Djinni or an enemy's cast.
Definition staging.c:871
s32 BattlePres_BuildTargetList(struct BattlePlan *plan, struct BattleEffectArgument *effect)
Fills an effect command from a plan: its kind and strength, the actor and the targets still standing ...
Definition staging.c:129
s32 BattleMotion_SetRecordChildValues(struct MotionObject *object, s32 colorMode)
Draws every sprite of an object in a colour mode (enum SpriteColorMode): colorMode on each sprite's f...
Definition staging.c:830
s32 BattlePres_RunAttack(struct BattlePlan *plan, s32 mode)
Plays an attack: the camera turns halfway to the attacker's view, the attacker runs up to its first t...
Definition staging.c:454
void BattleActor_RemoveFromLists(s32 unitId)
Takes unit id out of the party's or the enemies' list and out of this round's actions,...
Definition staging.c:1019
s32 BattlePresentation_RunUnitTransition(struct BattlePlan *plan, s32 mode)
Plays a summon or a full-screen Psynergy.
Definition staging.c:252
void BattleMotion_ShowDowned(s32 unitId)
Shows a downed unit: a party member lies down, an enemy keeps its damage pose, turns grey,...
Definition staging.c:1072
s32 Graphics_ResetVramBlockAndReleaseHeapBlocks(s32 unused)
Ends a star field: clears BG2's tiles in character block 1, frees its blitters, canvas and work,...
Definition star_field.c:297
s32 BattleFx_InitializeStarField(s32 mode)
Starts a star field of the element mode (0 to 3, enum Element order): sixteen sparks on random rings ...
Definition star_field.c:198
void BattlePres_RestorePalette(void)
Copies the background's saved palette back undarkened, as the star field of BattleFx_PlayUnitElementE...
Definition star_field.c:469
void BattleFx_PlayUnitElementEffect(s32 unitId, s32 element, s32 mode, s32 variant)
Plays a glow of the element about a unit, and returns when it is over.
Definition star_field.c:363
s32 Graphics_ScaleRgb555Clamped(u16 *source, u16 *destination, s32 scale, s32 count)
Copies count colours from source to destination, each channel scaled by scale (16....
Definition star_field.c:315
u32 BattleFx_UploadStarField(void)
Definition star_field.c:168
void Runtime_RemoveIrqHandlerSlot2(void)
Removes the VCount interrupt's handler, as BattlePres_RunEntryTransition installs one; nothing calls ...
Definition star_field.c:475
s32 BattleFx_UpdateStarField(void)
Definition star_field.c:48
An ability's definition, a row of gBattleAction_DefinitionTable: its targeting, kind,...
A unit's chosen action for the turn: its command, the command's parameter, its target and range,...
The command shared by an effect's caller, dispatcher and handlers.
The battle event queue and the state of its playback: the phase, the event playing and the advance ar...
Definition battle_work.h:51
A unit's place on the battlefield: its sprite object, resources and animations, its anchor spot and s...
s32 palette
the unit sprite's palette
s32 scale
16.16 fixed point, 0x10000 full size
u16 effect
an effect sprite drawn with the unit
One action, as BattleCommand_BuildPlan lays it out for BattleTargetExec to apply target by target.
Definition battle_type.h:26
The party's Djinn recovery table as summons read it: the mask of summons the party can call,...
What BattlePresentation_InitializeTransitionEntries treats as an array of these; Transform_SetIdentit...
Definition background.c:450
A position in three coordinates, each in 16.16 fixed point.
An effect object that moves and draws one sprite: its position, scale, velocity and target,...
Definition motobj.h:20
s32 BattleEffectDeadCheck(s32 effect)
Returns 1 for an effect that still applies when the ability's damage has just knocked its target out:...
Definition target_exec.c:13
s32 BattleTargetExec(struct BattlePlan *plan, s32 slot)
Applies the planned ability to one of its targets: first its damage or healing, then its added effect...
u32 Ability_IsPsynergy(s32 abilityId)
Returns 1 for an ability that costs PP, and for Psy Drain, which costs none.
s32 BattleTarget_SelectForAction(s32 actorId, struct BattleAct *action)
Picks the target of an enemy's ability (or a confused unit's), as a place code: among the units of th...
Definition targeting.c:317
s32 BattleTarget_SelectRandomPosition(s32 requireLivingUnit)
Picks a random place: with requireLivingUnit, a party member still standing; otherwise any enemy plac...
Definition targeting.c:26
s32 BattleUnit_TickStun(s32 unitId)
Counts down stun, which may end early at bias 40; Battle_ProcessRoundEnd shows MsgCureStun when it re...
Definition turn_end.c:128
s32 Battle_ProcessRoundEnd(void)
Ends a round: sets recovered Djinn, then gives each unit its regeneration and counts down its stat ch...
Definition turn_end.c:298
s32 BattleUnit_ProcessTurnEnd(struct BattlePlan *plan)
Ends one unit's turn: its Djinn on standby are taken off its set, the Djinn a summon used begin to re...
Definition turn_end.c:528
s32 BattleUnit_RollCounterEarlyEnd(s32 unitId, s32 turns, s32 bias)
Rolls whether a stat change or status with five turns or fewer left ends early.
Definition turn_end.c:13
s32 BattleUnit_TickReflect(s32 unitId)
Counts down Reflect and returns 1 when it runs out; it never ends early.
Definition turn_end.c:187
s32 BattleUnit_TickResistanceModifier(s32 unitId)
Counts down a Resistance change; Battle_ProcessRoundEnd shows MsgResNormal when it returns 1.
Definition turn_end.c:81
s32 BattleUnit_TickSleep(s32 unitId)
Counts down sleep, which may end early at bias 50; Battle_ProcessRoundEnd shows MsgWakes when it retu...
Definition turn_end.c:131
s32 BattleUnit_TickDelusion(s32 unitId)
Counts down delusion, which may end early at bias 30; Battle_ProcessRoundEnd shows MsgCureDelusion wh...
Definition turn_end.c:102
s32 BattleUnit_TickRefrain(s32 unitId)
Counts down BattleUnit.refrain and returns 1 when it runs out; it never ends early.
Definition turn_end.c:174
s32 BattleUnit_TickDefenseModifier(s32 unitId)
Counts down a Defense change; Battle_ProcessRoundEnd shows MsgDefNormal when it returns 1.
Definition turn_end.c:77
s32 DjinnRecovery_Tick(void)
Brings the party's recovering Djinn one turn nearer, setting each whose turns reach 0,...
Definition turn_end.c:221
s32 Battle_AdvanceCounterAndCheckChance(s32 unitId)
Counts down both seals packed in BattleUnit.psySeal and returns 1 when the last ends.
Definition turn_end.c:139
s32 DjinnRecovery_TickTwenty(void)
Runs DjinnRecovery_Tick twenty times, which sets every recovering Djinni of a party member with HP.
Definition turn_end.c:269
s32 BattleUnit_TickAgilityModifier(s32 unitId)
Counts down an Agility change, clearing agilityStage and returning 1 when it runs out; unlike the oth...
Definition turn_end.c:201
s32 BattleUnit_TickCharm(s32 unitId)
Counts down charm, which may end early at bias 70; Battle_ProcessRoundEnd shows MsgConscious2 when it...
Definition turn_end.c:125
s32 BattleUnit_TickAttackModifier(s32 unitId)
Counts down an Attack change and returns 1 when it ends.
Definition turn_end.c:30
s32 BattleUnit_TickConfusion(s32 unitId)
Counts down confusion, which may end early at bias 60; Battle_ProcessRoundEnd shows MsgConscious when...
Definition turn_end.c:106
void Battle_ReservedNoOpF674(void)
Does nothing; Battle_RunEncounter calls it at the end of each round and of the battle.
Definition turn_end.c:282
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
signed short s16
Definition types.h:12
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11