Play camera (executable + setup/configdata.dat, com/stNN/camdata.cam)
Decoded from the Store build 1.3.25854.2
executable (our reading of the machine code) and
the two data files. The Godot side is
godot/scripts/pd_camera.gd
(PdCamera). Units 0.1 m, ticks 1/30 s, angles
15-bit (0x8000 = 360°; one degree = 91.0222
units, constant 0x1402f8058; every
degrees-to-units product is truncated toward
zero). converter/camdata.py dumps
the three camera files through structs (test:
converter/tests/test_camdata.py).
“C” is the character object, “cam” = C + 0x13f10
its camera object, “rec” the player’s preset
record. Confidence is M (read
in the code) unless a bullet says otherwise; the
docs run of 11-10 re-read the whole tick and
corrected three earlier statements (marked
“corrected”).
Everything below runs once per 30 Hz logic tick (the camera tick is part of the character tick, 0x14024f120 → 0x140252a20). The frame only copies the finished view matrix (cam + 0x40) and the drawn eye into the renderer’s globals (0x14012bfc0, view 0x1405a5ca0, eye 0x14058bdf0); nothing is interpolated between ticks.
Projection
Builder at 0x140291570 (wrapper 0x140292d40): a D3D left-handed matrix with m00 = cot(f/2), m11 = (w/h)·cot(f/2), so f is the horizontal FOV. For any viewport wider than tall the builder ignores the caller’s FOV (the frame passes 1.0472 rad, the old 4:3 value of 60°) and uses f = 1.309 rad (75°) with w:h = 853:480, so the frame is a fixed 16:9 whatever the window. Vertical FOV = 2·atan(tan 37.5° · 480/853) = 46.70° (the vertical extent of 60° at 4:3 is 46.83°: the remaster widened the view and kept the height; Godot uses KEEP_HEIGHT). Near 2, far 16000 units (set at 0x1401c8153). H (checked against footage framing).
setup/configdata.dat:
the presets
6 records of 13 f32 (0x34 bytes), loaded by 0x14017d970 and copied per player to 0x140534660 (record of player p at + p·0x34). H for the layout and the readers; every field has a reader in the camera code.
| Offset | Field | Unit | Used by |
|---|---|---|---|
| 0x00 | yaw speed at full stick | °/tick | manual turn 0x140253a1b |
| 0x04 | pitch speed at full stick | °/tick | manual turn 0x140253a78 |
| 0x08 | largest yaw step of the re-center and the lock-on turn | °/tick | 0x1402538c9, 0x1402535d4 |
| 0x0C | largest pitch step of the same two | °/tick | 0x140253930, 0x140253562 |
| 0x10 | look-at height above the anchor, free | units | ideal points 0x1402537d8 |
| 0x14 | eye distance behind the look-at point, free | units | same |
| 0x18 | look-at height while the lock tracks | units | 0x140253817 |
| 0x1C | eye distance while the lock tracks | units | same |
| 0x20 | pitch limit upward, stored negated (70 → −70°) | ° | manual, lock-on, aim pitch clamps |
| 0x24 | pitch limit downward, stored negated (−70 → +70°) | ° | same |
| 0x28 | rest pitch, stored negated (−9 → 9° down) | ° | re-center, lock release, aim pitch |
| 0x2C | pitch offset of the lock-on aim, stored negated | ° | lock-on turn 0x14025350a |
| 0x30 | yaw-follow rate at full sideways stick | °/tick | follow 0x140252d36 |
Values by record (kinds, the numbers are the file’s): 0 = default (6 / 3 °/tick, steps 20 / 10, height 13, distance 55, limits ±70, rest 9, follow 1); 1 = the near setting (distance 45.5, rest 12); 2 and 3 = records 0 and 1 with faster sticks (8 / 5); 4 = record 1 with follow 3; 5 = the out-of-match camera (4.06 / 5, distance 40, lock distance 55, limits 25 up / 32.5 down, follow 3.56). In records 0–4 the lock pair equals the free pair, so locked play frames exactly like free play; only record 5 differs.
Which record (0x14012dca0, game mode 0x1404bc9d4, record pointers 0x1404c0190): record = option 0xb · 2 + option 0xa (option bytes from 0x14052dfb0, all 0 on a fresh save, so record 0 is the default; 5 or more falls back to 0). Mode 0 (not a match) gives slot 0 record 5; in mode 6 (split screen) slot 1 reads the second player’s options. Nothing else picks a record: lock grades and team modes do not change the preset.
The camera object
cam = C + 0x13f10 (init 0x1402529a0, at character setup 0x1402510a0):
| Offset | Field |
|---|---|
| 0x00 | spectating (see “Spectator camera”) |
| 0x04 | lock button state; 0x08 “just switched on”; 0x0C lock grade (0 = not tracking, 1/2/3); 0x10 target index (−1 none); 0x14 tracked this tick; 0x18 tracked before (lock style 2 only) |
| 0x1C | drawn eye (f32[3]); 0x28 drawn look-at point |
| 0x40 | view matrix (4×4) |
| 0x80 | 32 × 0x14 bytes, one per target table entry: on-screen flag, screen x, screen y, 0, distance |
| 0x300 | back pointer to C |
| 0x308 | re-center ticks left; 0x30C re-center yaw target |
| 0x310 | ticks out of play; 0x314 spectator spot timer; 0x318 watched slot; 0x31C spot index; 0x320 spot blend in percent (starts 50) |
The yaw and pitch are not in it: they are C + 0x12e5c / + 0x12e60 (pitch positive = looking down), and the basis built from them is at C + 0x12d80 (Rx(pitch) · Ry(yaw); row 2, C + 0x12da0, is the forward vector). The init zeroes the object, sets index −1 and puts the drawn points straight on the ideal ones.
The tick, in order (0x140252a20)
For a character without a view (C + 0x30 = 0: not a local player) the tick only sets the yaw to 0 and runs step 8. Otherwise:
- Spectator check (below). When spectating, steps 2–7 are skipped.
- Lock button and target pick: FORMATS “Lock-on and targeting”.
- Lock-on turn (0x1402531d0,
only in match phase 6 with the lock on and a
valid target):
- grade = 1 / 2 / 3 by the 3-D distance between the two body records (≤ 80, ≤ 300, more);
- yaw target = atan2(dx, dz) from the player’s body record (C + 0xe0) to the target record (corrected: not from the drawn eye), masked to 15 bits;
- pitch target = atan2(eye.y − target.y, horizontal distance from the drawn eye to the target) + rec 0x2C (9° in record 0), clamped to the limits 0x20 / 0x24;
- yaw and pitch each move toward their target by at most rec 0x08 / 0x0C per tick: the signed difference is wrapped to ±180°; when its size is at most the step the angle is set to the target, else the step is added or subtracted (yaw masked to 15 bits);
- it clears the re-center counter (cam + 0x308 = 0). So the target sits 9° above the view axis, and a far-off or high target is reached in at most 9 ticks of yaw. A switch to another target has no transition of its own: the same capped turn runs toward the new target. A lost target (not valid any more) clears the grade and leaves yaw and pitch where they are; the lock stays on, tracking nothing, until a press. When the lock goes off (or the phase leaves 6) while a grade was set, the grade is cleared and, in phase 6, the pitch is set to the rest pitch at once.
- Ideal points (0x1402536f0): anchor = the position behind the pointer at C + 0x13de0 when that pointer is set and the point’s squared length is under 1e8, else the body position C + 0x12e40 (feet). The pointer is one of the character’s model point pointers (model + 0x260; docs 11-12: the node with packed id 0x511D082B, a child of the model root with zero rest offset in every playable model, so the anchor is the model origin = the body position unless a motion moves that node: “Body point, sight point and aim point”). look-at = anchor + (0, rec 0x10, 0); eye = look-at − forward · rec 0x14. With a lock grade set, rec 0x18 / 0x1C are used instead.
- Walls (0x140253f20), on the
ideal points:
- a segment query from the look-at point to the eye against the stage collision world (query 0x1401d5860 with the camera’s segment probe 0x1404bec70; probes made at 0x140163333);
- of the contacts with a sphere or a mesh (contact byte 0 = 1 or 3) whose byte 2 is not 0x12 or 0x14, the one nearest to the look-at point is taken (0x140164020), and the eye becomes contact point + 0.5 · contact normal;
- then a sphere of radius 1 at the eye (probe 0x1404bec88, 0x1401644b0) is pushed out of every mesh triangle it touches (same byte 2 rule; resolve 0x140195f30);
- the look-at point becomes new eye + (old look-at − old eye): the view direction and the eye-to-look-at distance stay the same, the whole camera moves forward. Bodies (characters) are not in this test.
- Smoothing: drawn = 0.625 · drawn + 0.375 · ideal, for the eye and the look-at point separately (constants 0x1402f7d4c / 0x1402f7d2c). H (matches footage lag).
- Manual control, skipped
while a lock grade is set (default lock style),
0x140253880. It changes yaw and pitch for the
next tick’s ideal points:
- re-center running (cam + 0x308 > 0): yaw steps toward the stored facing (cam + 0x30C) by at most rec 0x08, pitch toward the rest pitch by at most rec 0x0C, counter − 1; the sticks are ignored;
- else, unless the player’s camera input is switched off (per-player flag 0x1404bbd84 + p · 0x24), yaw += trunc(rec 0x00 · right stick x · 91.02) and pitch += trunc(rec 0x04 · right stick y · 91.02), pitch clamped to the limits; a product that truncates to 0 changes nothing;
- then the re-center press (pad pressed bit 0x2000000): the facing (C + 0x12e68) is stored as the yaw target and the counter becomes max(|Δyaw| / yaw step, |Δpitch| / pitch step) + 1 (integer divisions, differences wrapped to ±180°). Corrected: the re-center is not in equal steps, it is the capped step above for that many ticks;
- yaw-follow, only when none of the above changed anything this tick and the character is in action state 1 (C + 0x12f04, the run): the yaw moves toward the facing by at most trunc(|left stick x| · rec 0x30 · 91.02) units, with the same wrap-and-snap step. In record 0 that is up to 1° per tick (30°/s) at full sideways stick and nothing when running straight up or down the screen.
- Aim pitch (C + 0x12e64, what casts read), not updated in action states 10 and 11 (handler 0x14025bd40, the cast states that turn the body toward the cast point): with a lock grade and a table entry, atan2((C.y + C + 0x12e98) − target.y, horizontal distance from the body to the target), clamped to the limits; else camera pitch − rest pitch.
- View matrix with shake (0x14021b030, below), then the target projection (0x140253c00): every target table entry not owned by this player is projected with the view and the frame’s projection (0x14058bdb0) to x = 426 · X / (W · sx), y = −240 · Y / (W · sy) (sx, sy = the projection’s two scale globals 0x14057f418 / 0x14057f3b8); it is on screen when |x| < 426, |y| < 240 and W > 0. Stored per entry at cam + 0x80 with the distance from the player’s body record to the entry. That distance is the sort key of the sorted switch style (cam + 0x90 + i · 0x14, the lead left open in “Lock-on and targeting”): option 0x14052dfb8 ≠ 0 orders the valid targets by distance from the player.
Sticks
The local input fill (0x140256580, into C + 0x14248): raw pad axes (pad records at 0x1405a5ce0 + pad · 0x30, + 0x20 left x, + 0x24 left y, + 0x28 right x, + 0x2c right y) get a dead zone of 13000 (a value inside ±13000 is 0, else 13000 is taken off its size) and are divided by 19767, so each axis is linear from 0 at the dead zone’s edge to 1 at full deflection (C + 0x1424c left x, + 0x14250 left y, + 0x14254 right x, + 0x14258 right y). No response curve and no acceleration. Then (0x140256710) the right stick is flipped by two option nibbles: x is negated when option 0 (0x14052dfb0) is 1; y is negated unless option 1 (0x14052dfb1) is 1. The low nibble is player 1’s; the second local player (split screen) uses the high nibble. With the default options pushing the stick up looks up and right turns right. The left stick’s magnitude and angle are stored next to them (+ 0x20 /
- 0x28 of the input block).
Resets and special states
- Pit return (0x140251d80) and respawn (0x140251f80): the ideal points are computed from the body position (the anchor pointer is not used) and written straight into the drawn eye and look-at point: a snap, no smoothing and no wall test that tick. The respawn also ends spectating.
- Hit reactions, knockdown, lying, the dead state: no camera code looks at them. The camera keeps following the anchor with the same smoothing and the sticks keep turning it; only the yaw-follow stops (it needs the run state) and the lock-on turn keeps running while the target is valid.
- Match start: the view
switches from the intro path
(
stNNcam.alr) to the player camera when the intro sets flag 0x1404bbec0 (0x14012abd0 / 0x14012ae01). The camera object was put on its ideal points at character setup, so there is no fly-in in the camera itself; the first ticks only smooth what the body does. - Match end and results: no separate camera was found. The frame keeps using the player camera in every phase after the intro; the lock-on turn stops outside phase 6 (the grade is cleared, the pitch is left alone) and the sticks still work.
- The override camera (flag 0x140534798, eye 0x14059e150, look-at 0x14059e130, FOV argument 60°) belongs to the arsenal preview scene (module 0x140274d20–0x140276080), not to matches.
Spectator
camera (com/stNN/camdata.cam)
A player who is out watches the others. The file is per stage (st02–st08, st12–st17, st22–st26 have one): i32 count, 64 × f32[3] points, u32 0 (776 bytes; unused points are 0). st03 has 28 points 80–140 units up around the arena. It is loaded with the CPU data of the stage (name at 0x1402f2c20, loader 0x140176420) and kept at 0x1404c0178.
- When: the character is out (C + 0x20 or C + 0x24 is 0; which of the two a KO clears was not traced), the file is loaded, the game mode is 4 or 5, the match mode is not 10 and the phase is 6. After more than 150 such ticks in a row (counter cam + 0x310) the camera goes to spectating; any tick without the conditions resets the counter. It ends when the phase leaves 6, at the respawn, or when no slot is left to watch.
- Watched body: table entry cam + 0x318 (starts as the own slot). When that entry is empty, or pad 0’s bit 0x400 is set in the pad word at 0x14059b804 (the switch-target button), it moves to the next of the first four entries that exists, and a new spot is picked.
- Each tick: yaw = the direction from the eye to the look-at point (so the HUD has one); look-at = the watched record’s position (no height added, no smoothing); eye = look-at · (1 − t) + spot · t with t = cam + 0x320 / 100; when the eye is closer than 25 units to the look-at point it is put 25 units away along the same line. No wall test.
- Spot pick (0x140254320):
start at index (rand15 · count) >> 15,
then try the next indices in turn (count tries)
for one with a clear line from the look-at point
(0x1401641b0: a segment query, clear when every
contact has byte 2 = 0x10); the last one tried
is used either way. The spot timer restarts and
t becomes 20 + ((rand15 · 80) >> 15)
percent. rand15 =
rand() & 0x7fff. - Re-pick: every 30 ticks of the spot timer, when the timer is over 240 or the line from the look-at point to the eye is blocked.
Shake
The shake manager (global 0x1405330d8) keeps two amplitudes per player slot (+ 0x50 + 4·p sideways, + 0x60 + 4·p vertical). Adding (0x14021afc0, slot −1 = the local viewed player, phase 6 only for that form) keeps the larger of the stored and the new value. The view build (0x14021b030), each tick for each viewed player:
- builds the view matrix from the drawn eye and look-at point (look-at builder 0x1402912d0);
- jx = (r1 · 2a − a) · 0.5 with a = the sideways amplitude and r1 = rand() / 32767 (constant 0x1402f7c14), jy the same with the vertical amplitude and a second rand(): each is uniform in ±a/2;
- look-at’ = look-at + right · jx + up · jy (right and up = the first two columns of the matrix from step 1), and the view matrix is built again from the eye and look-at’;
- both amplitudes of that slot are set to 0.
So the shake turns the view about a fixed eye, it is re-rolled every tick, it lasts only while something keeps adding, and the stored drawn points are not changed (the smoothing never sees it). At the default distance of 55 an amplitude of 10 swings the view by up to ±5.2°.
Sources. A positional source object (tick 0x14022bf80): age + 1 per tick, removed after its lifetime (+ 0x74); fade f = 1 until the fade start (+ 0x78), then 1 − (age − start) / (lifetime − start); d = distance from the frame’s camera position to the source (+ 0x64); nothing beyond the radius (+ 0x70); g = 1 − (d / radius)²; k = the source’s pattern table (+ 0x80: count, values in pairs) at index 2 · (age mod count); amplitudes = g · f · k · (+ 0x58 sideways, + 0x5C vertical), added for slot + 0x60. The same tick sends two integers g · f · (+ 0x50, + 0x54) · the pattern pair to 0x14022c660 with the slot: the controller vibration (confirmed, “Controller rumble”). Stage effects add shake too (0x14022106f, 0x14022124e). Who creates the sources and with which amplitudes, radius and pattern was not followed.
preview/prevcam.dat
16 records of 8 f32 (0x20 bytes) for the arsenal preview scene only: one unused float, an eye triple and a target triple (each turned into a point by 0x1402759b0, not followed), and a blend factor (0, 0.3 or 0.5). Read at 0x1402757e0. L beyond the layout.
Against footage
Xbox original,
original-st13-yellow-palace.mp4 at
65 s, body standing, camera behind: the
character spans 0.43 of the picture height, feet
at 0.86. The near preset predicts 0.42 / 0.81,
the default 0.36 / 0.76, so that capture
probably used the near setting. Record 5
(distance 40) is not a match camera, so it
doesn’t explain the fit. The yaw-follow, the
spectator camera and the shake formula are read
from the code only (not checked on footage).
Implementation notes for the rebuild
- Step the camera in the 30 Hz tick, in the order above; draw the tick’s result as it is (no extra smoothing; frame interpolation, if wanted, is ours).
- Keep yaw and pitch as 15-bit integers and truncate every degrees product (6° = 546, 3° = 273, 20° = 1820, 10° = 910, 9° = 819, 70° = 6371 units), so small stick values give no turn exactly as in the game.
- Stick: dead zone 13000 / 32767 of the raw axis, linear to 1, x option and y option as above; no curve.
- Add the yaw-follow: run state only, no camera input that tick, rate = |left stick x| · rec 0x30 per tick toward the facing.
- Re-center: N + 1 ticks of capped steps (20° yaw / 10° pitch), sticks ignored meanwhile; a lock-on turn cancels it.
- Lock-on: yaw from the body
to the target, pitch from the drawn
eye to the target
- 9°, capped steps; no change per grade; pitch snaps to rest when the lock goes off; no manual control or yaw-follow while a grade is set; a lost target frees the camera at once.
- Walls: nearest contact to the look-at point, eye = point + 0.5 · normal, radius-1 push-out, then move the look-at point by the same offset; skip collision attributes 18 and 20 (taking contact byte 2 as the mesh attribute, as the collision section does) and bodies.
- Snap (no smoothing) on pit return and respawn.
- Shake: per-player sideways / vertical amplitudes, max-combined per tick, applied to the look-at point only as ±a/2 uniform jitter per tick, cleared after use; sources with radius falloff 1 − (d/r)² and linear fade. The sources’ numbers still need a decode.
- Spectator camera for 2v2: convert
camdata.camper stage (camdata.py), start after 150 ticks out, spot logic as above with the game’s rand(). - Aim pitch for casts: from the body (at the cast height) to the target while tracking, else camera pitch − rest pitch; frozen in the cast states.
- The reticle position per target is the projection in step 9 of the tick, in a 852 × 480 space centred on the screen (the point is the body record position, no added height: “Lock-on marker”).
In the rebuild
(camtick):
camdata.py <dump>/Assets/Data/setup/configdata.dat > <pd-data>/camera.json
gives the six records (field names as in the
table above); PdCamera reads record b · 2 + a
from it (launch options
--cam-option-a/-b) and falls back
to the built-in record 0. Notes 1–8 are
implemented (pd_camera.gd,
player.gd
_update_camera,
_camera_walls); the attribute skip
of note 7 waits for the collision masks
(PLACEHOLDERS.md).