Debug character viewer: the skill bench (executable, PC and Xbox)

Both retail builds ship a debug character viewer (scene 3 of the scene table at 0x1403e8450, class pdCharaSelClass; the debug menu’s first entry). It needs only the game’s own debug script set (MenuD/*.ssb used as Menu/) and a floor file Menu/charasel/yuka.alm whose first word isn’t the model tag 0x11 (256 zero bytes of our own do: the set-up skips a floor without the tag, and the draw crashes on a missing one). No executable change on either build (the Xbox BIOS refuses a changed xbe anyway). It draws one character on a cleared background with no stage, no light set (so the model comes out green on both builds: the viewer’s own look, not a port bug) and no HUD. We use it as the answer key for effects, motions and timing: the same skill, the same camera numbers, the same tick on PC, on Xbox (xemu) and in the rebuild. Tools: tools/bench/ (bench.sh, benchcam.py). Found by the playtester 11-14; the debug script set is what the community’s pd_loader_core “DebugMenus” mod serves (credit).

Modes

The scene object’s mode word (PC + 0x44) is stepped by Start:

Mode What PC draw / update
0 character list (5 characters, colour 1..4) 0x14018897a…
1 motion list: every motion slot by number, with the frame counter 0x14015d820 / 0x14015d6a0
2 skill list: skill numbers 1..374 (= our skill record numbers; records 375..386 are not listed) 0x14015e050 / 0x14015db1e…
3 background colour editor: three 0..255 values at object + 0xf8 / + 0xfc / + 0x100 (red, green, blue), the clear colour of the scene (0x14015d138) 0x14015e470

Skill mode runs the real cast code (H): “play” calls the character’s own skill-use entry 0x140258180 (character + 0x12f00, character + 0x388, skill number, 1), the routine a battle cast goes through, on the battle character object (object + 0x110). So the body motion, the effect slots, the release tick and the shot objects are the battle ones; there is no target, so nothing hits and no hit slot plays. A skill whose objects outlive the cast (mines, shields, auras, environments) stays until the scene is left: one skill per fresh viewer.

Buttons in skill mode (pressed word 0x14059b804; the bits are the pad word’s, FORMATS “Pad objects”): 0x10 play, 0x20 pause toggle (object + 0x6c), 0x80 one tick forward while paused, 0x100 play with the effect switched off, 0x200 put the character back at the origin, 0x40 movement on / off (object + 0x70), 0x400 next damage reaction (object + 0x64, 0..3), 0x2000 next landing reaction (object + 0x68, 0..5). The header line prints the skill record’s field 0x14 (“used” id), its three reaction ids (0x6e / 0x70 / 0x72, shown as −1 when field 0x52 isn’t 0) and its effect id (0x74): the scout’s sweep read these for all 374 list numbers and they match our skills.json (H). The frame number on the motion line is the character’s animation state (character + 0x13960 → + 0x18, a float, truncated) and the motion slot is character + 0x12fc4: the counter is the 30 Hz tick (skill 61 leaves the hand on frame 20 = its decoded release tick, H).

The scene object’s bench fields

Same order on both builds; the Xbox object is 0x18 bytes shorter up to here.

PC Xbox Type Meaning Reset (set-up 0x14015ca20 / Xbox 0x655f0)
+ 0x5c + 0x44 s32 selected list number (1-based) 1
+ 0x60 + 0x48 s32 loaded list number: when it differs from the selection the update loads the selected skill’s data and copies the number 1
+ 0x64 + 0x4c s32 damage reaction cycle 0..3 0
+ 0x68 + 0x50 s32 landing reaction cycle 0..5 0
+ 0x6c + 0x54 s32 1 = paused 0
+ 0x70 + 0x58 s32 1 = the character may move; 0 = its x and z are zeroed every tick 1
+ 0x74 + 0x5c f32 camera distance 40
+ 0x78 + 0x60 f32 camera height 10
+ 0x7c + 0x64 s32 camera yaw, angle units (32768 = one turn) 0
+ 0x80 + 0x68 s32 camera pitch, angle units 0
+ 0x110 + 0xf0 pointer the character object

In the character object: position PC + 0x12e40 / Xbox + 0x11290 (three f32), motion slot PC + 0x12fc4 / Xbox + 0x11400, animation state pointer PC + 0x13960 / Xbox + 0x11b40 whose frame float is at + 0x18 on PC and + 0xc on Xbox (the Xbox three were found on the running game and checked by single steps, not read in the xbe).

The set-up gets the object from its caller’s object (PC + 0x58, Xbox + 0x3c; callers 0x140188769 / Xbox 0x7af3f; no static pointer to it was found, so the bench finds the block by its reset values). Writing the selection, the pause flag, the movement flag or the camera fields into the running game takes effect on the next tick / draw: the bench does that (PC: the Wine process’s memory; xemu: the emulator’s gdb stub) instead of walking the list or holding sticks.

Camera

Rebuilt every draw (0x14015d0e0) from the four fields; nothing is smoothed and there is no collision:

M      = RotX(pitch) · RotY(yaw)                    (0x1402906e0, then 0x1402905c0; sine table)
eye    = distance · (cos pitch · sin yaw, −sin pitch, cos pitch · cos yaw) + (0, height, 0)
target = (0, height, 0)
view   = look-at(eye, target)   (0x1402912d0, written to the renderer's view 0x1405a5ca0)

in game units (10 units = 1 m in the rebuild), about the world origin, where the character stands; the camera does not follow a character that walks or dashes away. Negative pitch puts the eye above the target. The projection is the frame’s own on PC (FORMATS “Projection”: vertical FOV 46.7°). The Xbox viewer’s projection is wider: measured, the same camera draws the character 0.533 times as tall as on PC (about the same picture centre), a vertical FOV near 78° (M, measured on xemu; where the Xbox viewer sets it is not decoded).

Stick input (0x14015d540, Xbox 0x65f10; once per tick, raw axis beyond ±0x2000 of 32767, no analogue rate):

Axis Field Step per tick Limits
pad 1 left x yaw ∓364 units (4°) wraps
pad 2 left y pitch ∓182 units (2°) none
pad 1 left y distance ∓1 10..200
pad 1 right y height ±0.25 none

There is no reset button; the reset values come back only when the scene is set up again. The yaw at the skill list is not a fixed start value: the camera turns by itself while the character list is up, so a fresh viewer came up at 103.8° on PC and 91.8° on Xbox in our runs (H, read from memory). Two captures only share a camera when the numbers are written. Pitch is on the second controller on both builds (PC axis word 0x1405a5d34 = pad 2’s left y; Xbox pad index 0x317364 against 0x317360 for the rest), which is why one pad never tilts it.

Proof (run proof-both, list number 61, presets default / front34 / right / top, ticks 4..31 every third; private shots). Both builds were given the same four numbers per preset and read back the same eye point (for example front34: eye (−31.337, 17.812, 31.337), yaw 28672 and pitch 31858 units on both). The frame counter read from memory was the same on both for every shot, and so was the character’s position on every one of the 40 shots (root motion of the cast is identical on PC and Xbox, to the third decimal). Framing: the character’s bounding box, measured from the picture centre in picture heights, on 16 shot pairs (4 presets × ticks 4, 13, 22, 31): after dividing the xemu-based box by 0.533 all four edges agree with PC within 0.005 on 13 pairs and within 0.014 on 15; the one outlier (0.026, right, tick 22) is the shot passing in front of the body, where the colour mask differs. The height ratio alone is 0.522..0.537 on those 15. So the pose of the camera is the same and the Xbox projection is a constant 1 / 0.533 wider; the contact sheets zoom the xemu-based row by that factor and the two rows then line up tick by tick.

How the bench reaches the fields. PC: the game’s memory through the process’s memory file (Wine allows it). xemu: its debugger stub, switched on from xemu’s own monitor window after the viewer is up (nothing of the emulator’s set-up is edited; the stub listens on all interfaces while that xemu runs, so the bench stops xemu when a run ends). The block is found by its fresh-start values (list number 1 selected and loaded, not paused, movement on, distance 40, height 10); on xemu a physical memory dump is searched and the hit mapped back through the page tables, and the last address is tried first (it was the same on every boot so far). First reachable tick after “play”: 1 on PC, 3 on xemu (each debugger attach halts the guest; the pause write lands two ticks later). One step press is exactly one tick on both.

What the bench shows and what it can’t

Implementation notes for the rebuild

  1. A viewer mode in the rebuild must use the same four camera numbers and the formula above (units ÷ 10, z flipped as everywhere), the frame’s normal projection cropped to 4:3, the character at the origin with no stage, target or light set, the real cast path with the list number as the skill record, and one screenshot per 30 Hz tick.
  2. Compare by list number, camera preset and tick; PC is the look reference, xemu only a cross-check for what the PC port changed.
  3. Motion answers from the scout’s sweep: 354 of 374 list numbers play the motion slot we decode; 12 more are idle in both. Record 230 plays slot 37 (the jump start) where we decode none: it is a levitate, so this belongs to the open levitate row, not a new gap. Records 262 and 282 stay idle in the viewer while we decode slot 93 (L: the viewer may not stage these kinds; check them in a battle before changing anything).
  4. List number = the record’s own number (skills.json record, the record’s first field), not our id: list 61 plays motion slot 70 and releases on tick 20, which is record 61 (id 130); our id 61 is a blade with slot 64. (viewer)
  5. The rebuild’s viewer mode is godot/tests/render_viewer.gd (bench.sh --target afterlife, all = three rows). It runs with --fixed-fps 30 so every drawn frame is exactly one physics tick, casts after a drawn frame (frame 1 = the first tick after), draws extra presets of the same tick with the tree paused (effects step on the physics tick, so they hold), and writes the body position per tick as chara_pos in game units. Its camera is checked against the formula above to within 1 px by tools/bench/viewer_camtest.py (two cubes, no game data). Neither the viewer render nor the camera test is in run_autotests.sh (on purpose: they need the GPU host’s weston, the suite is headless). bench.sh restarts the shared pd-weston before each render only after tools/bench/weston_guard.sh finds no other godot on it (waits up to 240 s, then fails the job; tools/bench/test_weston_guard.sh checks it).