At a glance

Ground
Procedural grid emitter func_0x801d02c0 (battle overlay), the sole draw call of the battle-mode render; no geometry file
Backdrop
The scene's own backdrop mesh stream, selected by scene data into _DAT_8007B864; registered once, drawn by two actors
Stage colour
Depth-cue pass FUN_80050120 (ambient 0x8007B7B0, far colour 0x8007BB48)
Camera pose
Rotation trio 0x8007B790 (pitch / yaw / roll, 4096 = one turn), translation trio 0x800840B8, projection distance H = 256
Framing
Dispatcher FUN_801D5854(actor, case), ten-entry jump table at 0x801CEA00 (PROT 0898)
Tween
Builder FUN_801D829C, walker FUN_8002149C
Intro
Transition overlay PROT 0979, tick FUN_801CF5BC, five visual styles
Port
scene-formats::battle_backdrop, engine-battle-vm::battle_cam_script / battle_camera / battle_attack_camera; both hosts only read the pose

The stage

authored halfbackdrop mesh, copy A second copysame mesh, mirrored or rotated, copy B ground grid: 28 × 28 cells, pitch 0x200 party seats monster seats CameraTR (0, 1280, 7680) idle orbit: yaw is a clock Field scenerystays resident behind
Not to scale. The grid is a full plane centred on the actors, so it fills the ground at every orbit angle; the shell is half a bowl whose second draw closes the circle.

Ground grid

The floor is not geometry from a file. A GTE rasteriser emits a flat tiled grid each frame in two passes: the first transforms each grid point and writes a per-cell visibility byte, the second emits four gouraud-textured quads per visible cell. One 64×64 texel window is stretched over each cell. The routine contains no RNG and mirrors no corner - the tiling is deterministic. The grid has one extra cell of bias on the depth axis, so it is not quite centred.

Every grid quad is linked into one ordering-table entry at the far end of the table, so the floor is painted before anything else and hides nothing drawn after it - not even geometry reaching below the floor plane. The port depth-tests the grid like any other mesh, which is why Zeto's Call Wave rays only fan upward in the port where retail's fan all the way round him over the floor.

Which backdrop a fight uses

A scene bundle carries one backdrop mesh stream per sub-area, and the battle uses whichever one the chunk walker last recorded. The choice is scene data, not a code table, and it is not uniformly the block's first stream: Rim Elm carries four sub-area backdrops and the sparring match is fought in the second. The block is the one the map id word names, which a fight start can point elsewhere: a Muscle Dome leg is fought on the arena data file’s backdrop (extraction 1225) while the field under it stays koin1.

Two copies of one mesh

The shell is authored as half a bowl - across every stage entry the mesh barely crosses its own centre plane, and that is the real shape, not a truncated parse. The mesh is registered once and drawn by two actors; a per-stage mirror table and an outdoor table decide how the second copy is placed. One orbit-angle capture separates the models: with one copy, 90 screen columns are empty where the retail framebuffer has a mountain band in all 90.

Which side of the ribbon draws. The backdrop arm hands the primitive dispatcher the node’s colour word with a flag that, for the mirrored copy only, lowers the winding mask so the quad leaf’s back-face test (NCLIP) can no longer fail. The mirrored copy therefore draws both sides of every face and the unmirrored copy only its front faces. The ribbon faces the arena’s centre and the camera stands outside its ring, so the near quads of the unmirrored copy - the ones between the camera and the fighters - face away and drop out. Both play hosts pass the same per-draw NCLIP word.

How the floor is lit

The grid has no light source. Each lattice vertex is depth-cued by the GTE from a colour register the emitter never writes itself: a once-a-frame pass rewrites it from the stage’s ambient word, which is the stage base colour plus 0x404040. Settled, the base is 0x808080, so the floor’s near colour is 0xC0 per channel and the texel is lifted by half before the cue blends it toward the far colour.

The camera

The view is a plain Euler pose: screen = H × (R·v + TR) / depth with R = Rx(pitch) × Ry(yaw). The projection distance and base matrix hold through every phase; only the pose moves. The reference pose is the far framing of the round prompt - pitch 32 (about 2.8° of down-tilt), no roll, TR = (0, 1280, 7680), looking at the world origin, with yaw the free orbit azimuth.

Who owns the camera this frame

Three owners hand it on in order, each calling the same dispatcher:

  1. Entry sweepthe SCUS frame driver: the camera rises and pulls in from battle init's pose, then closes with case 2
  2. Menu driverthe command flow: far framing on the prompt, a member close-up in the ring, a target shot on the cursor
  3. Action SMthe action state machine: per-action framing, a post-strike two-shot, then the target

The entry fade

Every fight comes up through a full-screen fade of its own. Battle init holds the screen on one colour until the stage loads, four counter units into the entry sweep; the stage loader then fades the fight in over 0x14 frames. The colour is the one the transition left: the spin-up and swirl styles (and the scatter style's third form) white the screen out, and their fights fade in from white; every other fight fades in from black. The same loader pass hides the evolved Cort until his arrival module drops him in, and that module itself waits for the sweep to end.

The ten framings

CaseShotPitchTranslationLooks at
0member close-up (ring, arts input, pickers)32(-512, height[char], 2457)the member
1target cursor on one enemy0x100(0, 0x600, …)the commanding member
2the entry sweep's close-in0(0, 0x600, 0x700)acting actor, or the origin
3target cursor on one ally32(0, height, 2457)the ally
4 / 5none - whole-side cursors go straight to the shared tail---
6per-action framing0(0, 0x500, ctx[+0x6D0])acting actor, live position
7post-strike two-shot0as case 6attacker-target midpoint
8end of actionby target stateby target statethe target
9far framing (round prompt)32(0, 1280, max(span × 3, 0x800))formation centre

Between two actors the camera stays on the last shot

The end-of-action gate 0x5A arms the finished actor’s framing once more: case 8 for an Attack, nothing for a Run, case 6 otherwise. The setup states 0x00, 0x0A and 0x0B arm nothing, so the tween walks on and the yaw orbits, and the next actor’s seed 0x0C tweens from that shot to its own case 6. A round’s first actor is the only one that stands on the far framing in those states, the one the prompt’s case 9 left. Over the library’s states parked in 0x0A behind an earlier actor, every tween table holds that actor’s endpoints with the walker landed.

StateLast actorShot
kor_ghost_knight_pre_v_windhashNoa, Spiritcase 6: pitch 128, TR (0, 1024, 3276), focus her seat
noaru_barra_v2_pre_multi_cuttera monster’s spellcase 6: pitch 0, TR (0, 1280, 4915), focus its seat
chitei2_kemaro_v2_pre_lava_breatha monster’s strike on Noacase 8: pitch 128, TR (0, 768, 2457), focus her body pair
taiku_topaz_pre_hyper_healnone this roundcase 9: pitch 32, TR (0, 1280, 8712)

The gate frames the seat it ran on. The port’s battle loop can arm the next actor in the same tick the Done or gate pass ran, before the camera steps on that pass, so the camera keeps the seat of the pass it is framing rather than reading the incoming one. Framed on the incoming seat, the Done band’s case 6 tweened onto the next actor three passes early, and Bloody Horns’ walk-in turned the camera down through yaw 0 where retail’s turns up onto the same endpoint. Retail films of an injected Bloody Horns and of a Spirit member’s turn read the same hold: through 0x5A, 0x0A and 0x0C’s first vsyncs the tween table is the finished actor’s, and the next endpoint appears with state 0x28.

An Attack’s Done band also opens with one step nobody re-arms: the pass on which state 0x20 lets go stores 0x50 and leaves before its framing fork, so the walker steps the increments the last held pass armed, and case 8 is armed by the Done arm a pass later.

That is also the pass on which whatever ended the return happened: the target’s get-up finished, or its defeat fade reached black. The port’s camera reads the target after the pass’s anim and tint ticks, so a re-arm there would frame the new state a pass early; it holds the framing for the exit pass instead (BattleCamInputs::return_exit_pass). On Gala’s Flying Knee that kills the Killer Bee, retail’s film holds pitch 84 through the exit pass and moves on the Done arm’s; the port now does the same, and the film’s first Done-band pair rises from .668 to .980.

Gate arm 0x801E6428..0x801E6470; orbit stores 0x801E2A3C..0x801E2A6C and 0x801E5BE4..0x801E5C04; seed tween 0x801E2D50. Port: battle_cam_script::end_of_action_phase, BattleCamera::set_phase_on_state.

The tween is an ease-out

Every framing is re-armed each pass: the target vectors are rebuilt from the live actor record every display frame and the step table re-emitted. The target is never frozen at the state change. Each rebuild divides the remaining gap by the duration again, so a pass covers about a sixth of what remains, and the camera is still closing in long after its nominal twelve frames. Captured step tables match that law exactly.

The cast driver’s shots follow the same law. A six-frame shot covers two thirds of its gap on a slow four-vsync pass, not all of it: when Caruban’s Fire Breath on a full party hands its caster shot on to the group shot at the first hit, retail’s camera walks in over four passes. The port once stepped those shots as a glide over the duration’s passes, which on a four-vsync pass is a single step, and cut straight to the group framing; it now chases them, and the film of the cast tracks retail’s camera to a unit.

Idle orbit

Battle init zeroes the yaw; from there it is a clock. Two writers decrement it by twice the frame step - the battle tick while the flow byte sits on a prompt, and the action SM in its setup states. This sweep never consults the state machines, which is why a parked battle shows as an endless orbit.

At yaw 0 the camera looks straight down the seat axis and the two rows overlap on screen, so the port opens a fight on the field camera's azimuth instead, moved out of that window. That is a port judgement and a toggle: the retail-faithful mode opens every fight on retail's zero.

The per-art attack camera

FUN_801D71B8 is an override, called from the dispatcher's shared tail after whichever case has armed its tween. It therefore overrides cases 7 and 8 as well as 6 - which matters, because the strike loop where most art swings are filmed is case 7. It seeds a fresh, tighter pose from the actor, runs a per-character, per-art arm, and re-arms a much shorter tween. An art with no arm returns without arming anything and the case's framing stands. Its first test is the target's live HP, so a death re-frame is never overridden. The arm offsets come from the attack-camera table.

The Battle Camera option is not a distance

The options row (Close / Normal / Far) is read in four places, each making the action shots calmer as it rises: Far skips the yaw drift, the setup-band orbit and the per-art override; Normal and Far skip case 8's dead-target and live-target arms.

The prompt and the target cursor

The menu driver re-arms the dispatcher on every cursor step, against the cursor’s scope. The Attack command’s cursor (the prompt’s Auto, and the ring’s Attack arm under the Automatic option) takes case 1 on the commanding member. The Auto | Command prompt itself is case 0: opening it leaves the ring’s close-up standing, and cancelling the cursor back to it re-arms case 0 on the member. Item and magic cursors switch on scope - one enemy is case 1, one ally case 3, a whole side cases 4 / 5, which leave the framing as it stands.

The 4× world scale

Battle meshes are small - a party member stands a couple of hundred units tall - yet they read at full size on screen. The reason is the battle mode’s base matrix, DAT_8007BF10, which holds a uniform 4.0 scale in every catalogued battle state. Every actor, the backdrop included (it is registered as an ordinary background actor), draws under that matrix, so the camera’s translations are authored in the scaled space: the far framing’s eye distance of 7680 is measured to a formation whose seats sit ±800 before the scale.

The scale belongs to the mode, not to the stage, so a fight whose stage stream does not resolve still draws its actors and effects at 4×. Both play hosts take it from one decision (legaia_engine_session::battle_fx::battle_world_scale). A draw class left at 1× would orbit at four times the intended radius - a fault invisible on a centred formation at the far framing, which is why a guard projects every retail seat through both the ground and the actors at every framing and requires the same pixel. The floor’s depth-cue window is not scaled: it is keyed on view depth, under a camera already in view units.

The frame step

Retail’s battle runs once per battle frame, not once per vsync. The frame driver measures what each frame cost and turns it into a step of one to four vsyncs (usually two, three or four in heavy summon close-ups); the action state machine, the camera walker, effect waits and root motion all scale by it.

The port runs retail’s own cadence by default: the whole battle pass once a frame of the default step two, with every counter tested once per pass and drained by the step. The Retail battle cadence toggle (WorldToggles::battle_sm_frame_cadence, see engine) turns it off, and the battle then steps every vsync with its timers draining by one. Measured against retail’s battle captures, the cadence matches retail’s frame on as many states or more than the per-vsync pass does, the summon close-ups most of all.

A pass runs on the step the frames before it left. The frame driver waits a frame out on the step that frame ran at and hands the step its cost raised to the next pass, so the first frame of an expensive draw still runs on the cheaper step. Caruban’s Fire Breath on a full party shows it: its first breath frame runs at step two, costs about 550 hblanks where the frames before cost 450, and the frames after it run at three.

Inside a summon band each module arm runs on the step a retail recording of the cast reads for it (legaia_engine_cast::cast_module_frame_step): a band opens at 1 and its whole-screen arms read 4, on every summon module. The reading is a property of the arm because the arm draws the same screen each time.

The table names what an arm’s frames cost, and the cost goes through the same sixteen-frame ring as any other frame. A cheaper arm after a whole-screen one therefore keeps the dearer step until the dear frames have left the ring: Kiss of Death’s last arm, the victim alone, runs step three for fifteen passes before it settles on two, as retail’s recording does, and Gimard’s arm 6 gains the same step-three band. A cost that falls inside one arm - Kiss of Death’s lips shrinking through its fourth arm - is not something an arm table can say.

The summon close-up and its white flash, just ahead of the band, are cheap frames too: on every recording of a lone caster the step falls from two to one a few frames into the close-up, and the flash-in then rises a vsync at a time. Left on the ordinary step, the port's flash rose two vsyncs at a time and read a step ahead of retail's through the whole rise.

Held out against retail’s monster strike films, which log the step every vsync, the ring over the measured table reads retail’s step on about nine vsyncs in ten, close to the best a single step per fight could do. What is left moves inside one action state: a full party’s strike that drops to step two as the HP bars settle, and the heaviest formations’ frames that run past step three one at a time. Weighting the cost by the monsters’ polygon count does not survive a held-out test, so the table carries no such term.

What the port under-prices there is the fight, not a per-frame load. Across the full-party strike recordings each film's strike frames sit a steady offset over the table, differing from film to film, and that offset follows neither the live effect parts nor the alive monsters' triangle count. Within a film the cost follows what the frame links: on a Fire Breath recording the frame whose linked polygons jump is the one that crosses into the next step. A per-fight term would need the stage and framing's linked polygons, which only the hosts hold.

A frame's span

The step says how many vsyncs a frame is meant to take; a frame whose work runs past its step's last vertical blank runs on to the first blank after its work. VSync(n) waits for the count to reach its target, then for the next blank, and only then stores the frame's base, so a frame's span is max(step, (cost + 20) / 263 + 1) vsyncs. The 20 hblanks are the work past the cost word (the vblank handler, VSync's return, the ring update); the law comes from the disassembly, the constant from emulator recordings.

While an XA clip loads, the CD polls take a share of the CPU, so the same work costs about three and a half times as much, and the clip's read window runs some vsyncs past its nominal span.

The port carries the law (frame_clock::frame_span with a loaded-frame cost and read tail) as an opt-in, WorldToggles::battle_frame_span_law (LEGAIA_BATTLE_FRAME_SPAN=1). Off, an ordinary frame runs its step and a loaded one a single vsync past it. On, the recorded casts' wall clock comes to retail's and their game clock holds, but cue timing shifts on films where something vsync-timed sits on the longer frames: some arts gain, others (Super Ironhead, Element Change, the Thunder Storms) lose ground, and a shout fallback that plays while the XA drive word holds ends a few passes early, so that word is not the span alone. Frames whose cost the engine does not hold (the capture band's and the summons' heavy arms) keep their table's step either way.

An enemy cast’s module arms run on a second table read the same way, fitted on the enemy cast films: one row per recorded cast. Over the enemy cast films that reads retail’s step right about three times in four. A cast no film has recorded keeps the ordinary step: most of its arms likely run at four, but a still captured on a counted pass lands on another pass there, so each waits for its own recording. Death Game stays on the ordinary step until its port bodies count by the vsync as retail’s do.

The cast driver's clip clock

The cast driver's case 0xA aims its yaw at node[+0x68] * 2 + 0x700 - facing on every pass of the magic band, so the endpoint climbs with the clip: 24 units a pass at the usual cursor step of 12. It reads the animation cursor in retail's own sixteenths, sub-keyframe bits included. Rounding the cursor down to a keyframe aims up to 30 units short. A capture cast's finishing arm also clears the style byte ctx+0xD, so the Done band frames from the default side; the bodies without that store keep the half turn.

The field-to-battle transition

The transition between leaving the field and the battle coming up is its own overlay. It sequences the handoff and drives one of five visual styles over a one-shot capture of the field frame:

StyleRetail tick
Scatter particlesFUN_801CFDA0
Scatter with spin-up (boss entry)FUN_801D0370
Tile shatterFUN_801D0D24
Swirl fanFUN_801D1888 / FUN_801D1A20
Screen-strip curtainFUN_801D11D0

The transition runs 132 display frames, 252 for the swirl. Every battle entry rides it: the field step roll, a scripted fight, and a world-map contact. The scripted-fight bit of the per-battle flags selects the spin-up style. The curtain is a render-to-texture whose row pass is the only part that reaches the screen.

The styles’ randomness is the game’s one rand() stream. The transition’s setup seeds the tile shatter’s spawn delays and corner jitter, and the spin-up’s particle delays, from the same seed every other random roll in the game steps; a walked encounter on the console takes 706 draws there and none for the rest of the transition. The port takes the same draws from the same place in its one stream, so the intro looks as it would on the console from the same seed, and the rolls after it (the fight’s own) are dealt from where the console’s are.

The capture is the frame the player was looking at, as retail’s copy of the displayed framebuffer is. Both hosts read back their finished frame on the tick the transition arms: the 3D pass with every enhancement on it (the lighting and its time of day, the ground fog, the see-through walls, the glow) plus the screen layers over it (retail’s fog-pool particles, the drop shadows, the light pools, the fades). Only the transition’s own layer is left out, since it is drawn from the capture. With the enhancements off, the capture is the faithful frame.

The frame lands where the console puts it: retail draws a 224-row area from VRAM row 4 and copies the display from row 0, so every style’s texture coordinates expect drawn row d at v = d + 4, with the rows around the frame cleared to transparent. Landing the port’s frame at v = 0 started the shatter four rows high and left a band of garbage across the bottom rows, where the tile grid’s wrapped last row showed through below retail’s 224 rows.

See also

The full write-up - grid emitter constants, the two culls, the depth-cue colours, the mirror and outdoor tables, each framing case arm by arm, the frame step, screen shake and the transition's per-style packets - is in docs/subsystems/battle-stage-camera.md.

Reference Battle Action state machine Command flow Battle HUD Cutscene and transitions Renderer Attack-camera table Scene bundles