Files
Neutron/docs/checkpoint/loop-motion.md
T

114 lines
7.8 KiB
Markdown

# Main loop, input, motion and animation
Static recovery from supplied Neutron.exe (SHA256
`f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8`) and
OMT2.dll (`3ec41ead011adf56387a6dbd4580e5b5a9721b5f8020c8a56420f42824354943`).
Investigated independently, integrated and byte-checked by primary. No original
whole-game runtime comparison. `checkpoint_loop_motion.py` reports PE-mapped
file offsets and verifies decisive calls/vtable anchors. For the EXE anchors below,
file offset is VA minus400000; do not apply that shortcut to DLL addresses.
## Recovered loop and ownership
| Boundary / owner | Original evidence | Interaction |
|---|---|---|
| Application pump | EXE4802F2 CRT →4789B0 WinMain →46A4A0 bootstrap; DLL100218A0 application start →10060720 devote_time | Engine periodicals own dispatch; not an established60Hz game loop |
| Engine animation periodical | DLL100215C0 emits -604 logic and -605 animation/render; world100F9B10 →100F9C80, world+48 timer and pause/min/max periods | Engine logic and game render callback are separate timing paths; exact interleaving needs trace |
| Game frame entry | EXE47E374 (file7E374) assigns viewport vtable4D74C4; slot+B8 at4D757C points to47E4F0 | This is a viewport render override, not an ordinary world logic tick |
| Frame time | 47E4FC virtual+D4;47E502 stores float seconds696030; guards47E508..52A accept0<dt<1; QPC reset47E470/elapsed47E490 | No source fixed1/60 accumulator recovered; do not choose original cadence from port tests |
| Conditional first passes | 47E554 →479BC0 physics;47E560 →462A20 transient pass;47E56B →4693A0 frame-list pass | All three require475CA0 true, supervisor509980 nonnull and supervisor+8C clear |
| Remaining passes |47E57A →47D8F0 sound;47E582 →473740 objects;47E587 →473770 transform sync;47E6B1 →477DB0 | These calls are outside that first-pass gate but inside valid-dt branch |
| Draw and post-draw |47E6DF imports viewport render via IAT48D304;47E6E5 →468600;47E6EF increments696028 | Draw occurs after game update/sync; invalid dt skips game passes but still reaches base render |
The object registry is a circular doubly linked list at50999C. Node layout:
next+0, previous+4, game-interface payload+8; allocation12 bytes at46FF50.
Constructor46FF4A..46FF7F appends to tail. Thus473740 walks construction/insertion
order, not grouped actor types. It invokes payload.vtable+10 at473758, then
reads next at47375B: appends during a callback can be visited in that same pass.
Deletion/reentrancy safety is not fully recovered.
Common slot10 wrapper470280 stores dt at interface+294 and invokes slot3C4 in
normal mode (4702C5), slot3C8 when supervisor+8C is set (4702B5).
Jimmy's3C4 is424600; movement path437940 executes during that object update.
Physics479BC0 has already consumed the existing body state. This establishes
prior-velocity/prior-impulse integration before the current controller computes
new motion. It does not alone establish the complete input/engine interleaving.
473770 is a second whole-list traversal invoking interface3DC then3E0. Jimmy
3DC4624B0 gets logical position through slot310 and writes interface-7C/-78/-74
(complete object+44/+48/+4C). Slot3E04624F0 →473540 synchronizes Euler angles.
Many objects expose multiple inheritance interfaces: the usual game interface
is complete+0xC0. Label every field by its pointer base; never merge equal-looking
offsets from unrelated interfaces.
## Input, controller and physics boundaries
Input arrives through game update44DF80 →475A70;475A9C reads controlled pointer
5099E4, null skips dispatch;475AA9 invokes its slot3CC (Jimmy426030).
Follow-up [input-frame-bridge.md](input-frame-bridge.md) proves44DF80 itself is a
normal registry3C4 callback on the level game interface (complete+8C). Thus input
is inside473740 after physics, distinct from Jimmy's own424600 callback but not
an independent world-logic tick. The game's OMT3C callback4747A0 only forwards to
base element no-op. SDL sampling/fixed ticks remain implementation policy.
Previously recovered detailed arithmetic remains in `analysis/jetpack.md`,
`analysis/original-collision.md`, `analysis/dynamic-collision.md` and
`analysis/patrol.md`:
- Jimmy movement437940/437F90 and air fall-through439900 own speed/turn/jump state.
Mode1 does reach airborne steering; the old binary report's “no action” label is
superseded. Grounded/released clears interface+614 (complete+6D4).
-479BC0 visits bodies;479D20/479EBB..479EF2 consumes queued impulse once,
then acceleration/gravity and displacement479F8D. This is a per-body algorithm,
not proof of the port's surrounding controller order.
- Jetpack controller437F90 and effect421FB0 have distinct owners. Timers,
state0..5, radius100/60, impulse550, hold>.4,8s burst and.5/s energy drain
are narrowly recovered. Registry insertion order of Jimmy/effect must be traced
before deciding same-frame vs next-frame effect expiry and impulse application.
- Source support/ray/magnitude and dynamic box broadphase have byte/DLL evidence.
Static response47BD80, stairs, all body masks and contact side effects remain
incomplete. NC shape exclusion is a recovered registration gate, not a water fix.
## Animation
There is a separate OMT logic/morph path: EXE462260 forwards its argument through
IAT48D244 to OMT morph update10002DB0. Common logical/visual transforms are copied
by the later registry sync. Morph interpolation is recovered at DLL10002F9A;
original mode2 probes for tested standing/jump clips return zero dynamic-point
offsets. These probes do not establish full animation scheduling or collision pose.
Port `MorphAnimation` samples extracted ASE timing with linear interpolation,
loops the final sample to first unconditionally, and rejects irregular samples.
`PreviewAnimationLibrary` chooses from pose/action aliases; Program resets poseTime
on clip change and adds1/60 every port tick. Actor visuals likewise run after the
grouped gameplay passes. Playback-end callbacks, one-shot vs looping flags,
class-specific speed, state transitions and interrupt rules remain unresolved.
## Baseline comparison and verification
Baseline69d0187 runs `LabSimulation.Step` controller → physics → jetpack effect →
camera, then contacts/mechanisms → patrols → director → objective timer → animation.
This contradicts the recovered physics-before-object-update contract and replaces
construction-order callbacks with subsystem groups. A global reorder now would
invent ordering for spawned effects, scripts and NPCs. First build a lab registry
and phase trace and assert source contracts; only then split simulation phases.
The helper and Python regression verify exact original bytes/call order; managed
tests verify port arithmetic and deterministic route outcomes. Neither proves source
cadence, input latency or original end-to-end gameplay. Keep both traces separate.
## Explicit unresolved questions / next work
1. Input bridge is resolved: registry3C4→44DF80 after physics. Exact event-pump,
pause/focus/invalid-dt/multiple-viewport behavior remains open. Engine world
timer is milliseconds, default mode1/min1/max500, distinct from QPC game seconds;
see the follow-up before interpreting the40ms period or choosing a cadence.
2. Capture lab construction registry including Goddard, jetpack effect, transient
objects and deletions; identify462A20/4693A0/477DB0 dependencies precisely.
3. Recover47BD80 response, Jimmy body/root/capsule relationship and source contact
ordering before replacing provisional feet grounding/sweep-slide collision.
4. Trace morph flags/end events and class animation selection, including cutscene
exit, jump→fall→land and jetpack state/energy transitions.
5. Probe isolated source components where possible; full original timing remains
unverified until a usable original runtime exists. Do not use nominal60Hz as fact.