At a glance

Where
Mostly the battle overlay, PROT 0898 at base 0x801CE818; a few in SCUS_942.54
Context
The battle context struct, pointer at 0x8007BD24: ctx[7] is the action state, ctx[+0x13] the acting slot
Actors
Pointer table 0x801C9370, eight slots: 0..2 party, 3.. monsters
Roster ids
DAT_8007BD10[slot], 1-based: Vahn, Noa, Gala, and 4 the AI companion
Slot B
The second overlay slot at 0x801F69D8 where cast modules page in
Port
engine-battle-vm::battle_action, battle_formulas, battle_cam_script; world glue in engine-core::world::battle

The helper families

Action SM FUN_801E295C owns the order of a turn Damage + status range FUN_8004E2F0 rolls 801DD4B0 / 6B4 DoT tick FUN_801E752C escape FUN_801E791C AI + turn budget queue FUN_801EED1C auto arts FUN_801F0450 monster FUN_801E9FD4 retarget FUN_801E7320 Effects + summons spawn FUN_801DFDF8 script FUN_801DEA50 flight FUN_801E09F8 loader B FUN_8003EC70 Camera + pose pose FUN_801D5854 tween FUN_801D829C framing 0x801F0348 bounds FUN_801EFE44 Audio + voice duck _DAT_8007B910 XA FUN_8003D53C arts FUN_8004C140 cast cue FUN_801F3990 actor[+0x16E] status word read by nearly every scan actor[+0x14C] live HP zero = dead; there is no KO bit
The state machine sequences a turn; the arithmetic lives in the helpers. Most are in the battle overlay (PROT 0898, base 0x801CE818); the range metric, stat aggregator, XA player and loader B are in the main executable. Every scan pairs the status halfword with the liveness halfword, because a dead actor is only one whose HP reads zero.

Range metric

FUN_8004E2F0 answers “is the attacker close enough” for the attack chain and for the animation tick’s root-motion gate. It returns a 16-bit distance, and zero means in range.

The two damage-roll wrappers

Every capture-class hit goes through one of two sibling wrappers. Each draws an attacker roll and a defender roll, applies the element-affinity scale FUN_801DD864, then the closed-form finisher FUN_801DDB30.

WrapperStat mixed into both rollsFifth finisher argumentParty resist ladder
FUN_801DD4B0INT-working +0x1680runs: jewels, elemental guards, All Guard
FUN_801DD6B4ATK-working +0x1581skipped

The fifth argument is the resist bypass: the finisher tests it once (bne a3,zero at 0x801DDBD4) and jumps past the whole party-defender block. That is the mechanism behind the boss casts that ignore elemental guards. The affinity scale still reads the caster’s element either way. Formulas: battle formulas.

The status word

One actor halfword, +0x16E, carries every condition. Its bits are pinned by the HUD icon selector’s priority ladder and by the appliers that set them.

BitsCondition
0x0001 / 0x0002Venom / Toxic
0x0004Stone
0x0008 / 0x0010 / 0x0020Rot, one rolled limb
0x0380AI delegation, always set as a group
0x0400 / 0x0800Numb / Sleep
0x1000Curse
0x2000 and upunused: no applier in the dumped corpus

Three masks are read as units: 0xF84 gates a slot out of the selectable scans, 0x0F80 is what taking damage clears, and 0x0404 is the whole-actor inert test. There is no KO bit: a dead actor is one whose HP halfword is zero, which is why every consumer pairs the two.

The port keeps the word in two halves, the raw bits a cast writes and a typed tracker a hit’s status arm fills, and composes them back into one halfword for every reader. Retail reads the halfword whole everywhere, so each reader does too: the pickers, the Counterattack roll, the Auto fill, the HUD’s gauge colour and status element, the limb dimming and the cast modules’ seats. A reader of one half missed a Confuse the tracker held or a Curse a cast wrote; the off-disc differentials hold each one to the whole word.

The escape roll

FUN_801E791C decides a flee. Both sides score from speed plus how hurt they are, and each rolls rand() % score:

party_score = sum over party   (SPD * 3) >> 1 + (maxHP - curHP) >> 4
enemy_score = sum over enemies  SPD           + (maxHP - curHP) >> 5
Escape Boost:  roll_p += roll_p >> 1
Great Escape, a pre-emptive strike, or the forced-flee flag:  roll_p = roll_e
FAIL iff  not forced  and  (roll_p < roll_e  or  ctx[+0x287] != 0)

AI picks and the turn budget

The queue itself is on the action queue page.

Effects, summons and the per-frame walkers

RoutineRole
FUN_801DFDF8Public spawn into the effect pool (sprite animations)
FUN_801D8DE8Raises a HUD text or chrome widget by element id
FUN_801DEA50Steps the acting actor’s effect script and installs the move-power record
FUN_801E09F8Counts outstanding effects; flies and lands projectiles. Its hit arm ORs +0x1DC and turns the victim toward the attacker
FUN_801E0080Per-frame walker of the effect master and child pools
FUN_801DF6B8The scaling damage-number popup
FUN_8003EC70Loader B: pages a summon or cast module into slot B (raw index arg + 0x381)
0x801F1ED4 / 0x801F2160Jump-table dispatch into the slot-B routine, by summon id or by effect class

The pool model is on the effect VM page; what a paged module does is on cast modules.

Camera and pose

FUN_801D5854 is the pose driver: one presentation program per pose id 0..9, called with the acting slot. Three of its arms read the per-action style byte ctx[+0xD] through the same compare ladder: values 1 and 3 add half a turn of yaw, 2 and 3 tilt the pitch by 0x80 and store TR.y = 0x400. FUN_801D829C arms the eased tween every framing change goes through. The framings themselves are on battle stage and camera.

Keeping the party apart

Nothing walks a combatant home after an action. Three helpers, plus the round start’s recentre, are what keep a formation in frame and its members out of each other’s way.

1. Seed recentre FUN_801EFE44, every action origin target the formation moves with it 2. Make-way step state 0x14 + the SM tail, melee target attacker heading h ± 0x400, about size × 8 units 3. Separation pass FUN_80050BB8, once a battle frame gap < (r1 + r2) / 6: nudge both r = 0x280 party, 0x400 Terra
Top-down stage, party at the bottom. Each sketch is one helper; the round start runs the first one’s whole-formation form as well.

Ports: battle_action::seed_formation_recentre, arm_make_way and make_way_step in engine-battle-vm, and battle_separation::push_apart driven by World::tick_battle_separation.

Audio and voice

The overlay also carries its own small PRNG (FUN_801D0290). It is a shape hash for the lightning ribbon emitter and feeds no gameplay roll - those draw the BIOS rand.

See also

Every helper with its full read / write set, the leaf scans, the audio cue tables and the dump-alias list for the 0x801Fxxxx band are in docs/subsystems/battle-action-helpers.md.

Reference Action state machine Action queue Battle formulas Stage and camera Cast modules Effect VM Actor rendering