26 for (index = 0; index != 4; index++)
28 for (index = 0; index < partyCount; index++) {
29 s32 unitId = unitIds[index];
32 entry = &entries[index];
44 entry = &entries[partyCount];
46 for (index = 0; index < enemyCount; index++) {
47 s32 unitId = unitIds[index];
64 for (index = count - 2; index > 0; index--) {
68 for (pos = count - 1; pos > 0; pos--) {
69 if ((
s16)entries[pos].priority > (
s16)entries[pos - 1].priority) {
96 actorId = action->unitId;
104 if (action->unitId > 4)
112 switch (action->command) {
129 transition->
flag = 0;
131 transition->
flag = 0;
159 s16 partyMembers[14];
166 if (((
Random16() << 4) >> 16) != 0) {
169 if (partySize != 0) {
176 }
while (animated != partySize);
217 u16 visibleUnits[14];
232 targetId = action->
target;
249 if (targetId >= 0 && targetId <= 7) {
257 for (index = 0; index != sideCount; index++) {
258 if (index + sideStart == actorId) {
266 for (index = 0; index != sideCount; index++) {
269 for (index = 0; index != 16; index++) {
280 for (index = 0; livingCount != count; index++) {
283 visibleUnits[livingCount++] = unit;
288 for (index = 0; livingCount != count; index++) {
290 visibleUnits[livingCount++] = index;
299 for (index = 0; index != livingCount; index++) {
303 if (targetId >= 0 && targetId <= 7) {
314 for (index = 0; index != sideCount; index++) {
317 for (index = 0; index != 16; index++) {
321 for (index = 0; index != sideCount; index++) {
394 if (transition->
targetYaw == targetYaw) {
431 for (targetIndex = 0; targetIndex != work.
effect.
count; targetIndex++) {
436 for (entryIndex = 0; entryIndex != animation->
count - 1; entryIndex++)
457 for (targetIndex = 0; targetIndex != work.
effect.
count; targetIndex++)
476 context = localContext;
494 if (showMessage != 0)
500 if (showMessage != 0)
514 }
else if (unit->
hp <= 0) {
533 actorData =
object->entries[0];
534 actorData->
param = 6;
535 actorData->
frame = 0xFF;
543#define TARGET_SIDE_DEFEATED 0x100
553 targetId = action->
target;
564 if (livingCount == 0) {
568 return (
s16)livingUnits[(
Random16() * livingCount) >> 0x10];
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.
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...
#define TARGET_SIDE_DEFEATED
BattleTarget_ReplaceDefeated's result when the target's side is all down.
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.
s32 BattlePres_RunAction(struct BattleActionRecord *action)
Auto battle: plays one action.
s32 BattlePresentation_RunPairedUnitTransition(struct BattleActionRecord *action)
Auto battle: casts Psynergy.
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,...
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 ...
s32 BattleParty_ListLivingUnits(s32 sideMask, u16 *unitIds)
Lists the units still standing (HP above 0) on the sides in sideMask (BATTLE_SIDE_PARTY,...
void BattleActor_SpawnObjectsForList(s16 *unitIds, s32 refreshPoses)
Readies the sprites of the units in list: releases those of every place list lacks,...
struct BattleObj * BattleObjGet(s32 unitId)
Returns unitId's battle object, through its place, or null for a unit with no place.
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...
void BattleObjPut(void)
Readies the sprite of every unit in the battle (releasing those of units that left) and sets each one...
struct BattlePresentationTransition * gTransitionWork
What every part of the battle object shares: its includes, in their original order,...
#define BLEND_SPRITES_OVER_ALL
REG_BLDCNT: blend the semi-transparent sprites (OBJ mode 1) over every layer, to fade them.
#define FIRST_ENEMY_UNIT
Unit ids from 128 are the enemies'; in a link battle the opponent's party takes the first three.
#define YAW_PARTY_TURN
The camera's yaw while a party member acts, and while an enemy does.
#define ENEMY_BATTLE_SIZE
@ BATTLE_UNIT_LIST_END
ends the list
struct BattleWork * gBattleWork
static __inline__ void Dma_Set(const volatile void *source, volatile void *destination, u32 control, volatile u32 *channel)
Starts a DMA transfer: stores the source, destination and control words into channel's registers with...
void BattleFx_RunTableEffectFar(struct BattleEffectArgument *effect)
void BattleFx_RunSceneEffectFar(struct BattleEffectArgument *effect)
void BattleFx_RunElementPillarFar(struct BattleEffectArgument *effect)
void BattleFx_DispatchByIdRangeFar(struct BattleEffectArgument *effect)
s32 AnimationObjects_SelectAnimationFar(struct AnimationObject *state, s32 flags)
void ObjectDispatch_SelectAnimationFar(void *raw, s32 no)
void ObjectDispatch_SetAnimationSpeedFar(struct DispatchObject *obj, s32 val)
void Map_RenderAnimatedTileFramesForObjectFar(u8 *obj)
struct BattleUnit * UnitGetFar(u32 owner)
void PartyStatusDrawFar(s32 flags)
void UiWork_PushValueSlotFar(u32 value, u32 kind)
void UiText_ShowMessageAndWaitCoreFar(s32 argument)
void UiWork_ResetFreeChannelFar(void)
void UiWork_ClearValueNameTablesFar(void)
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
#define BLEND_ALPHA(top, bottom)
A REG_BLDALPHA value: top and bottom are the two targets' weights, out of 16.
#define DMA_COPY_WORDS(n)
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
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,...
void ObjMotRst(s32 unitId)
Sends unitId back to its spot, landing there, and turns it to face the centre.
void BattleMotion_SetupEscapeObject(s32 unitId)
Sends unitId running off its side of the battlefield, three times as far out as its spot,...
One animation layer of a sprite: its animation id, frames, running script and timer.
u8 param
SpriteColorMode its pixels are drawn with; 0 when taken.
u8 frame
frame shown, frameBase plus the facing offset; 255 none
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
struct AnimationEntry * entries[4]
its layers; empty ones null
u8 count
layers in use, up to the last one present
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
s32 range
forwarded action range, otherwise initialized to 1
s32 actor
the user's unit id
s32 side
1 when the targets are the party, 0 for enemies
s32 kind
handler table index; 200 more for a critical hit
s16 actors[8]
the targets' unit ids, count of them
s32 variant
the ability's size, from 0 (Quake, then Earthquake)
s32 count
targets in actors, at least 1
s32 prelude
1 plays a prelude: in some effects a Djinni appears
s32 firstTarget
the action's first target, standing or not
A unit's place on the battlefield: its sprite object, resources and animations, its anchor spot and s...
struct MotionObject * object
NULL once released.
The battle background's work slot as the camera reads it: the yaw the camera eases toward and the fra...
s32 frames
frames left to ease the yaw, a sixteenth a frame
s32 flag
0 lets the camera update set the background's range each frame; 1 for a critical hit's zoom and once ...
s32 targetYaw
1/65536 turns
The effect updates its command while the presentation keeps animation state.
struct BattleEffectArgument effect
u8 savedAnimationParameters[8][4]
Each target's animation entries' param, saved before the effect.
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
s16 hp
current HP, 0 when downed
u16 agi
Agility, 0 to 999: the order of the round's actions.
u8 partyStatus
PARTY_STATUS_SUMMONS or PARTY_STATUS_NO_SUMMONS.
A field object as the object dispatcher's far calls take it.
An effect object that moves and draws one sprite: its position, scale, velocity and target,...
void * records
one sprite, or a table of up to four (recordStorageKind)
#define DEFINE_ADJUST_CAMERA(name)
Moves camera yaw by 512 while L/R is held; two identical functions exist.