From ea04210f524faae7dc1caff8afbc608fbb8144f4 Mon Sep 17 00:00:00 2001 From: Cristian Cerroni Date: Fri, 6 Nov 2026 17:08:59 -0500 Subject: [PATCH] Preserve retained Jimmy update order on initial story entry --- AGENTS.md | 26 +-- docs/checkpoint/coverage.md | 11 ++ docs/checkpoint/next-work-plan.md | 10 ++ docs/compatibility.md | 24 ++- docs/decisions.md | 11 ++ docs/gameplay/jimmy-body-transform-return.md | 125 ++++++++++++++ docs/gameplay/jimmy-cutscene-decompilation.md | 8 + docs/gameplay/jimmy-cutscene-lifecycle.md | 9 ++ docs/gameplay/jimmy-derived-frame.md | 51 ++++++ docs/gameplay/main-menu-player-lifetime.md | 93 +++++++++++ docs/gameplay/original-startup-diagnostic.md | 88 ++++++++++ docs/gameplay/original-state-observer.md | 10 ++ docs/progress.md | 31 +++- docs/tasks.md | 29 +++- src/GamePort/Application/CutsceneIdleSmoke.cs | 32 ++++ src/GamePort/Program.cs | 11 +- tests/GamePort.DirectorTests/Program.cs | 46 ++++++ tools/binary/jimmy_body_transform_return.py | 140 ++++++++++++++++ tools/binary/jimmy_derived_frame.py | 153 ++++++++++++++++++ tools/binary/jimmy_derived_frame_probe.c | 93 +++++++++++ tools/binary/main_menu_player_lifetime.py | 106 ++++++++++++ tools/recon/original_startup_probe.c | 116 +++++++++++++ tools/recon/original_state_observer.c | 4 +- tools/recon/reference_capture.py | 4 +- 24 files changed, 1209 insertions(+), 22 deletions(-) create mode 100644 docs/gameplay/jimmy-body-transform-return.md create mode 100644 docs/gameplay/jimmy-derived-frame.md create mode 100644 docs/gameplay/main-menu-player-lifetime.md create mode 100644 docs/gameplay/original-startup-diagnostic.md create mode 100644 src/GamePort/Application/CutsceneIdleSmoke.cs create mode 100644 tools/binary/jimmy_body_transform_return.py create mode 100644 tools/binary/jimmy_derived_frame.py create mode 100644 tools/binary/jimmy_derived_frame_probe.c create mode 100644 tools/binary/main_menu_player_lifetime.py create mode 100644 tools/recon/original_startup_probe.c diff --git a/AGENTS.md b/AGENTS.md index ce0e07a..bafbfd3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -38,22 +38,24 @@ other agents' active changes. Keep updates concise, save detailed evidence to di Use bounded endian-aware parsers, portable paths, clear C#, deterministic tests, and explicit unmanaged ownership. Build frequently. Update `docs/progress.md`, `docs/tasks.md`, `docs/decisions.md`, and compatibility evidence before transitions. -Current direction (2026-11-05): user requests decompilation before further -implementation. Keep runtime/package baseline a2e89c6/dae13ac unchanged while -recovering Carl's skip-to-idle lifecycle; current entry reset does not close the -post-skip tilt bug. Trace original state ownership/update order before another -movement reset or scheduler change. See docs/gameplay/jimmy-cutscene-decompilation.md. +Current direction: preserve exact original movement; keep gameplay expansion +paused. The menu/background→successful TSK-load lifetime now establishes retained +Jimmy-before-level-input order on first story entry. Correct that initialization +classification, preserving fresh direct-scene order and all movement/rotation +algorithms. See docs/gameplay/main-menu-player-lifetime.md. The strengthened +Vulkan Carl fixture reproduces the old first-neutral-tick bank and passes after +the correction; broader/native Windows comparison remains separate. The broader priority remains Jimmy movement stabilization, with gadgets paused. Preserve current movement as baseline; do not substitute JN-Engine native/Godot movement. Use its original decompiler index only as leads, verified with REA/authoritative originals. See docs/gameplay/jimmy-movement-stabilization.md. -2026-11-06 continuation: docs/gameplay/jimmy-cutscene-lifecycle.md records292 -new bounded original-code cases, mapped DEFAULT recovery and a read-only copied- -original launch/attach observer. No source-supported reset is established; actual -original Carl entry/return state remains the implementation gate. Wine32 observer -attach works but only MAIN/no Jimmy/black frames were observed locally. Preserve -runtime a2e89c6/packages dae13ac and normal landing bank. The user reiterates exact -original behavior; do not substitute a leveling reset or global scheduling change. +2026-11-06 continuation: the earlier292 original component cases plus50 derived- +caller cases and body/visual-sync audit supply no extra reset. Startup diagnostics +now observe backgroundLevel1D/Jimmy allocation after an explicit OS repaint +acknowledgement, with black frames/timing perturbation recorded. Source lifetime, +not those frames, proves the TSK ordering correction. Preserve normal landing +bank; never substitute a leveling reset. Historical runtime/package baseline is +a2e89c6/dae13ac. Read the current progress/compatibility results before packaging. The prior collision work is resumed where needed for movement; preserve the 35a2a66/0272f7b checkpoints and their source gates before broader body admission. Controller checkpoint integrates108 native ground/air/facing/jump comparisons; diff --git a/docs/checkpoint/coverage.md b/docs/checkpoint/coverage.md index ca68a48..0c43d73 100644 --- a/docs/checkpoint/coverage.md +++ b/docs/checkpoint/coverage.md @@ -1,5 +1,16 @@ # Core architecture coverage map +2026-11-06 TSK-entry correction: [menu/player lifetime](../gameplay/main-menu-player-lifetime.md) +establishes backgroundJimmy construction and reuse before the first playable +story scene. Input is now after Jimmy for that TSK path, while direct fresh-GAM +order remains. This replaces the named assumption that initial story equals fresh +registry insertion. First-neutral-tick/300-idle native Vulkan and eight managed +Carl trajectories pass; full-suite/platform results are tracked in progress.md. +50 more native derived-caller cases and body/transform ownership are documented. +Original startup diagnostics now reach background allocation after a recorded +repaint intervention, with black frames; no full-original visual/runtime parity +or native Windows execution is claimed. + 2026-11-06: [Carl lifecycle trace](../gameplay/jimmy-cutscene-lifecycle.md) adds 292 bounded original-code cases and closes local contact/task/animation/STOP and DEFAULT-provider questions. Actual first-resumed-frame state remains unobserved. diff --git a/docs/checkpoint/next-work-plan.md b/docs/checkpoint/next-work-plan.md index fbcfedf..92b9f71 100644 --- a/docs/checkpoint/next-work-plan.md +++ b/docs/checkpoint/next-work-plan.md @@ -11,6 +11,16 @@ read-only copied-original observer. Steps1–2 remain open at the actual origina Carl entry/resumed-frame observation. Step3 has not begun; source composition agrees with the port's stale writer under the same synthetic order/state. +Later execution update: [menu/player lifetime](../gameplay/main-menu-player-lifetime.md) +closes the successful TSK story path's source ordering gate. MAIN loads a background +Level1D/Jimmy; successful TSK load uses that controlled Jimmy and the ordinary +retained-object loader. Program's first-story classification is corrected without +another angle reset. Step3's first-neutral-tick/300-idle Vulkan and eight managed +trajectories pass; integrated/native SDL/package validation is underway. Original +Windows comparison remains a step5 obligation, not a completed claim. Step4's +derived-caller/body-transform investigation is also recorded, with broader +dynamic/special contacts and playback dependencies still open. + ## Objective Establish the original ownership and timing of player state across gameplay, diff --git a/docs/compatibility.md b/docs/compatibility.md index 8d4c6da..4ee4940 100644 --- a/docs/compatibility.md +++ b/docs/compatibility.md @@ -1,6 +1,28 @@ # Compatibility and validation -Post-skip tilt is still open (2026-11-05). User original comparison specifically +2026-11-06 TSK startup correction: the original menu creates backgroundLevel1D/ +Jimmy before successful TSK story entry, then retains that player ahead of the +new level-game input callback. Program now models this on first story entry as +well as retained transitions; direct fresh-scene order stays separate. The +baseline native Vulkan replay fails on first neutral tick0 with destination +roll−10.000001. Corrected first input and300 idle ticks stay upright, preserving +heading, held-input return and body/fire continuation with zero Vulkan errors. +Eight managed Carl trajectories coverLeft/Right, natural/skip and repeated scenes. +All336 Python+2 HUD, managed projects and36 GPU/render passes succeed. Native Linux +SDL/Vulkan1920×1080 control replay and VR04 powered keyboard/steering/resize pass +with zero validation errors. The returned-frame readback is inspected upright. +Final build has zero warnings/errors; Windows x64 cross-publish succeeds. Clean +package validation follows. Source details: +[menu/player lifetime](gameplay/main-menu-player-lifetime.md). Normal landing bank +and the actual movement/facing algorithms are preserved. Airborne control return, +whole-original timing/rendering and native Windows comparison remain separate. + +The50 new copied-original derived-caller cases and static body/visual-sync audit +are bounded source/component evidence. Matched Wine startup diagnostics progress +past MAIN only after an explicit OS repaint acknowledgement; they show background +allocation with black frames and perturbed timing, not a playable Carl reference. + +Earlier checkpoint (2026-11-05): post-skip tilt was still open. User original comparison specifically identifies skipping Carl; the previous validation covered entry and held movement on resume, not subsequent idle. A48-case managed port diagnostic isolates stale mode/turn republishing a bank target in fresh order. New original skip/control/ diff --git a/docs/decisions.md b/docs/decisions.md index 3bb5766..e73fe56 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -373,3 +373,14 @@ assets and generated packages stay excluded. registry membership. Its successful Wine32 attach is tool validation, while MAIN-only black frames are not gameplay evidence. Keep runtime/packages fixed until the source/differential gate closes. See gameplay/jimmy-cutscene-lifecycle.md. + +54. **Classify successful TSK story entry as retained-player order.** + Source application startup loads backgroundLevel1D/Jimmy; successful TSK + destination requests use an existing controlled C3DJIMMY and the ordinary + selective teardown/reuse path. The new level game follows that retained node, + including first playable New Game. Program's carriedSave-only test was too + narrow. Include TSK-backed story entry, keep fresh direct-scene simulations, + and preserve rotation/movement algorithms. Baseline first-neutral input + republishes−10° bank; corrected startup order stays upright through300 idle + ticks. Original runtime/native Windows comparison remains distinct. See + gameplay/main-menu-player-lifetime.md. diff --git a/docs/gameplay/jimmy-body-transform-return.md b/docs/gameplay/jimmy-body-transform-return.md new file mode 100644 index 0000000..4e84bfd --- /dev/null +++ b/docs/gameplay/jimmy-body-transform-return.md @@ -0,0 +1,125 @@ +# Jimmy body-context alignment and transform publication on return + +2026-11-06. Static follow-up to the null-body-context limitation in +[the base/STOP probe](jimmy-base-return.md). Original identity and cached REA +instructions are reused; no new native cases or gameplay changes are claimed. + +## Source identity and guard + +Canonical Neutron.exe SHA256: +`f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8`. +Complete EXE instruction Evidence: +`ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904`. +The read-only `tools/binary/jimmy_body_transform_return.py` verifies that subject, +12 source sites,16 virtual bindings and13 bounded source ranges. Its generated +report contains PE file offsets, hashes and the matching retained REA extracts: +`artifacts/jimmy-body-transform-return/source.json`. + +The prior OMT transform Evidence is +`ev_af082632c98b34ccfcedef01466cafa03365e7fbf482496d01a4cda6d2f8f787`. +It is a truncated DLL disassembly prefix, not complete DLL coverage. Existing +transform ranges are present and rechecked against the supplied DLL through +`jimmy_model_bridge.collect`; see [render transform](jimmy-render-transform.md) +for the earlier12 angle and14 hierarchy/final-matrix observations and limitations. +JN-Engine's original class notes supplied field/navigation leads only. + +## The live context bridge can write current Euler, behind a separate gate + +| Original VA / EXE file offset | Recovered receiver and state effect | +|---|---| +|462520..462649 /62520..62649|Runs before common458930→473240/facing. Requires475CA0, own game210→4719F0(byte13E), and nonnull own game338→472570(pointer234) for the context path.| +|46255D..46258F /6255D..6258F|Reads support polygon's+4 link and linked+80 payload; invokes current game complete130(actor game pointer,linked record,payload,dt). Lab4C3CD0,VR044CE910 and outside4C5A80 all bind130→44E030. The callback occurs **before** the alignment gate.| +|462595..4625A2 /62595..625A2|Own game1E8→471950 reads live byte138. False bypasses normal→Euler publication but still reaches common update/facing. This gate is independent of cached support218 and raw input owner.| +|4625A8..462632 /625A8..62632|For true138, obtains current Euler328→4723F0, copies support normal Vec4 from polygon+8..14, calls476FF0 and writes resulting XYZ through330→472420. This changes **current Euler only**: target274, dirtyA, mode704 and turn614 are not written by this suffix.| +|471080/471090 /71080/71090|Property getterC4 reads byte10. Property setterC8 writes byte10 and invokes live setter1EC.| +|471950/471960 /71950/71960|Live getter1E8/setter1EC read/write byte138. Property10 and live138 are separate fields.| +|47059C..4705A9 /7059C..705A9|Generic Init470540 restores live138 through1EC from propertyC4. It does not infer alignment from landing or input ownership.| + +Crucially, the ordinary Player constructor explicitly disables this path: +43729E clears EBX;437332 installs the active Player game table4AF6C4;437426 +pushes EBX=0 and437429 calls471090. The active constructor table's1EC resolves +471960, as does the eventual Jimmy table4A373C. Thus both property10 and live138 +are set false. The inspected constructor interval contains no intervening EBX +assignment; its callees follow the recovered x86 nonvolatile-register convention. +Subsequent generic Init restores the false property into live138. This is a +positive constructor/Init chain, not an assumption from the old null-context probe. + +This does **not** prove no uninspected runtime path ever changes the property. +The previously recovered Carl camera preparation/STOP/DEFAULT boundaries do not +supply such a write. Enabling this surface-alignment path for Jimmy, or using it +as a new cutscene-exit leveling rule, would therefore introduce unsupported state. +The generic normal-angle helper's existing Scooter observations remain separate +from whether Jimmy is eligible to invoke it. + +## The supplied static lab terrain takes the ordinary callback path + +The authoritative `omt/level1b.omt` SHA256 is +`5a33d11311fc222631eb8f7384d1863192cb1f55f7e67035caa0ae12fd9892ab`. +Using the existing bounded OMT parser and source shape/checkpoint exclusions, +the helper inventories2869 polygons,2851 eligible for static registration. +Among eligible polygons,2526 have texture references with IDs0..30 and325 have +no texture. The report retains counts, shape IDs/names, original payload offsets +and payload hashes. No texture ID is guessed from the port's material index. + +44E030 requires both linked record and payload. It reads polygon material+0C, +then the material's texture-definition ID+8; missing material/payload bypasses +the callback's state paths. All identified static-lab IDs0..30 fall below its +first special selector range50..55, so they select ordinary surface sound5 at +44E407. This excludes the callback's higher-numbered lava/ground-hazard branches +for **that supplied static geometry**. + +When desired surface sound changes,44E426 invokes Jimmy **complete**1E4→42AEC0. +That method stops/restarts an existing floor-loop handle at completeA44 only if +the prior handle is valid. It writes the new handle, without touching either +Euler vector, mode704 or turn614. This is distinct from game-interface1E4, which +is another field accessor. The ordinary path supplies no movement reset and +does not grant/remove raw control. + +This is not a complete runtime collision-world inventory. It does not prove the +provenance of a retained338 context, rule out additional runtime geometry or +dynamic interactions, or execute the full original body/derived Jimmy frame. +The old Bubble floor component investigation already covers this same callback +with explicit synthetic dependencies; another duplicated finite negative probe +would not establish the missing original Carl entry/resume state. + +## Transform publication does not conditionally hide the bank + +The later473770 pass calls each game interface3DC and3E0, **not3C8**. +Jimmy3C8→4235B0 is the separate supervisor/editor update selected by470280 when +app+8C is set. It must not be described as normal render synchronization. + +For Jimmy,3DC→4624B0 copies current logical/body XYZ into complete44/48/4C. +3E0→4624F0→473540 reads current Euler, converts each degree axis to masked +14-bit angle units, then3E4→462500 writes complete50/52/54. These routines do +not test raw control, movement mode, animation name or cutscene state, and do +not replace current or destination Euler. Previously verified OMT hierarchy +construction consumes those cached pitch/yaw/roll angles. The known publication +path therefore provides no scene-return branch that conceals a residual bank. +Whole-world parent transforms, full morph playback and final render flags remain +separate from the already-probed identity-parent/unit-scale contract. + +## Result, implementation and remaining observation + +The optional body-context bridge contains a real current-Euler writer, but the +ordinary Jimmy constructor/Init disables its alignment gate. The identified +static lab terrain path affects surface audio, not banking state. The normal +logical→visual synchronization publishes current pitch/roll rather than dropping +them. These facts close specific omissions in the composed return explanation; +they do not explain the user's upright whole-original return or justify a new +reset. Keep the existing playable port unchanged until actual original entry, +registry placement and resumed input state are measured. + +Integration follow-up: [the menu/player lifetime chain](main-menu-player-lifetime.md) +subsequently establishes retained player-before-input order for successful original +TSK story entry. The resulting correction changes that entry classification; it +does not enable this optional surface-alignment gate or alter visual publication. + +Verification is static: source hash/site/binding/range checks, revalidated prior +transform contracts and complete supplied-static-lab polygon inventory. No new +original execution, native Windows comparison, runtime edit or commit is made. + +```sh +python3 tools/binary/jimmy_body_transform_return.py ../Original \ + --rea artifacts/jimmy-movement-audit/rea-original-disassembly.json \ + --output artifacts/jimmy-body-transform-return +``` diff --git a/docs/gameplay/jimmy-cutscene-decompilation.md b/docs/gameplay/jimmy-cutscene-decompilation.md index d70f8e7..8596f36 100644 --- a/docs/gameplay/jimmy-cutscene-decompilation.md +++ b/docs/gameplay/jimmy-cutscene-decompilation.md @@ -1,5 +1,13 @@ # Focused decompilation checkpoint: cutscene lifecycle +Follow-up: the source gate for successful TSK story entry is now closed by +[menu/player lifetime](main-menu-player-lifetime.md). BackgroundJimmy is reused +before the first playable game, making input follow his update. Program's initial +story order is corrected; camera preparation/landing algorithms are unchanged. +First-neutral-tick/300-idle native Vulkan and eight managed trajectories pass. +The investigation below records the earlier open state; whole-original/native +Windows comparison and integrated package validation remain separate. + 2026-11-05. User redirects work toward understanding the original before further implementation. Preserve runtime baseline a2e89c6 and packaged runtime dae13ac. No src/, regression test, build script, original or packaged binary changes are diff --git a/docs/gameplay/jimmy-cutscene-lifecycle.md b/docs/gameplay/jimmy-cutscene-lifecycle.md index fcb960b..eb3536c 100644 --- a/docs/gameplay/jimmy-cutscene-lifecycle.md +++ b/docs/gameplay/jimmy-cutscene-lifecycle.md @@ -1,5 +1,14 @@ # Carl skip lifecycle: recovered boundaries and the remaining observation +Follow-up: [menu/player lifetime](main-menu-player-lifetime.md) resolves the +successful TSK story entry ordering omitted by this earlier checkpoint. The port +now includes first story entry in retained Jimmy-before-input order. Its baseline +native regression fails on neutral tick0 and passes first input plus300 idle ticks +with the correction. No additional movement/angle reset is introduced.50 derived- +caller source cases and the body/visual-sync audit close other local omissions; +the historical findings below remain scoped to their earlier evidence. Full +original/native Windows gameplay comparison is still unverified. + 2026-11-06. Execution of the accepted next-work plan, with the user's requirement to preserve original behavior exactly. Runtime a2e89c6 and packages dae13ac remain unchanged. This checkpoint adds evidence and observation tools, not a tilt fix. diff --git a/docs/gameplay/jimmy-derived-frame.md b/docs/gameplay/jimmy-derived-frame.md new file mode 100644 index 0000000..af254b5 --- /dev/null +++ b/docs/gameplay/jimmy-derived-frame.md @@ -0,0 +1,51 @@ +# Derived Jimmy frame around the controller + +2026-11-06. This closes a caller-level omission in the earlier component +composition; the lifecycle correction is separately established by +[menu/player lifetime](main-menu-player-lifetime.md). + +Canonical EXE SHA256f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8; +retained REA instruction Evidence +`ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904`. +The guard verifies14 source sites,21 virtual bindings,15 ranges and the actual +controller call. Text file offsets below equal preferred VA−400000; the helper +PE-maps them independently. + +| Source boundary | Recovered ownership | +|---|---| +|424600..424D10 /24600..24D10|Actual Jimmy game3C4 caller. Null raw control closes/hides helper UI and stops sound handles. It does not itself clear movement mode or stored turn.| +|424721..424751|If the menu exists and shared4F8181 is set, poll menu4A8→403A10. State2 calls menu460; both state2 and other states return before the controller. This lock is distinct from raw ownership.| +|424767 complete208→424D10|Objective/UI helper before the controller. The separate objective presentation does not set modal input gate4F8198; that explicit-modal opener is406F90. See objective-timing.md.| +|424BFC complete1A4→425170|Upward world query/velocity handling. Its falling callback425120 maintains mode1; it is not a grounded resume reset.| +|424C08 complete1A8→4252E0|Downward/shadow-distance query and own helper state.| +|424C2B complete194→42AAC0|Airborne sound cleanup.| +|424C34→437940|Actual ordinary player wrapper. The source ownership/support/input-order conclusions remain here.| +|424C3F complete1C8→424E80|Invisible upkeep, with its own mode gate and ordinary non-Invisible return.| +|424C88 complete1B4→4255C0|Impact/material helper; world-hit dependencies remain separate.| +|424C94 complete1B0→425490|History/position correction. Calls game314→472360 Vec4 **root** setter; this is not an Euler setter.| + +`jimmy_derived_frame_probe.c` executes the complete derived caller and ordinary +helpers on private copied source.437940 is a recording adapter, upward/downward +world queries return no hit, and menu/resource/visibility transports are explicit +adapters. Thus these cases test what the caller changes outside its controller, +not another execution of the controller/body/whole game. + +All50 cases pass:48 combinations of raw ownerNULL/Jimmy/other, menu lock0/1, +menu state1/2, supported0/1 and rising0/1, plus two180-tick unlocked intervals. +The caller dispatches the controller only while the menu lock is clear; raw +ownership is passed onward rather than becoming another caller-side gate. +Mode1, turn11.666668 and distinct current/destination Euler stay unchanged outside +the recorded controller. Queries and menu-close callbacks have checked counts. + +Artifacts: `artifacts/jimmy-derived-frame/native-observations.json` binds generated +source, executable, source contracts, original identity, capture metadata and log +hashes; capture wineExit0 and `JIMMY_DERIVED_FRAME_COMPLETE` are required. Primary +integration reran the parser/guards and verified all50 cases. No full body/world +hits, OMT playback, native Windows or actual original Carl frame is claimed. + +```sh +python3 tools/binary/jimmy_derived_frame.py ../Original \ + --output artifacts/jimmy-derived-frame/build \ + --rea artifacts/jimmy-movement-audit/rea-original-disassembly.json \ + --capture artifacts/jimmy-derived-frame/probe +``` diff --git a/docs/gameplay/main-menu-player-lifetime.md b/docs/gameplay/main-menu-player-lifetime.md new file mode 100644 index 0000000..f834f29 --- /dev/null +++ b/docs/gameplay/main-menu-player-lifetime.md @@ -0,0 +1,93 @@ +# First story entry inherits the menu's Jimmy registry position + +2026-11-06. This closes the missing source lifetime distinction behind the Carl +neutral-return failure. It does not establish a universal rotation reset or a +native Windows/full-original cutscene capture. + +## Source and supplied data + +Canonical Neutron.exe SHA256 +`f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8`; +retained REA instruction Evidence +`ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904`. +`tools/binary/main_menu_player_lifetime.py` verifies8 calls,15 sites,15 bindings, +12 instruction spans and both actual GAMs. Coordinates below are preferred VAs; +the helper PE-maps file offsets independently (these text offsets equal VA−400000). + +| Boundary | Source fact | +|---|---| +|46A641→46B160;46A660→46A310→44D0E0|Construct application and MAIN. This bounded prefix alone does not create Jimmy.| +|46BA12/46BA18|Application constructor seeds elapsed+804=0 and splash stage+808=0.| +|46BEC0..46C067|Application update increments elapsed. Strict elapsed>3s or an accepted Escape edge advances stages0→1→2→3; the3s float is48E5A0.| +|46BF2F..46C00A|Stage1 advances to2, clears elapsed and dispatches app114(`level1d.gam`) at46C004. This is the previously omitted positive background-load edge.| +|app114→46DFB0;46BEDF;app104→46DFF0|Queues filename+74D with signed callback countdown+7FA=2; underflow sets pending+74C; the application then invokes ordinary selective teardown/load.| +|Level1D GAM|LV1D,54 records, first3JIM/JIM1 at raw8. SHA256276133d750eaa82724b35c12a91fce41a9e074224e3ef12c3624564ae8ed4d9e. Loading the supplied background creates Jimmy before a user story load.| +|46E570..46E67D|After GAM records, the whole surviving registry receives Init28 then PostLoad40C, including retained MAIN; Init is not limited to newly parsed records.| +|MAIN/Level1D game28→44D4E0→4587F0→470540|Common Init restores stored+11 into live+139 through4705B3/4705BC. Both games' stored value is1. MAIN's constructor-default live0 therefore does not imply indefinite retention after background initialization. Their40C is44DF30, a noop call plus own game520=0 store, with no later lifetime reset.| +|404B4F→460E70→460EA0/460EF0→4603F0|The NewGame action queues NewGame.tsk; the reader consumes that request. The request itself does not initialize Jimmy.| +|460A50..460A6A;460BD1|The reader requests a destination GAM only through an existing non-null controlled receiver accepting **C3DJIMMY** at4ECB20. It dispatches Jimmy complete168→43B5A0 with the staged filename/start/root data. The no-Jimmy path does not supply that request.| +|43B5A0→app100/46DF70|Uses the ordinary player scene-transition request. The successful TSK-to-GAM path does not construct a new player before teardown.| +|Jimmy4226B5..BF;42275A|Stored/live teardown predicate0 via470F40(0), reusable game09=1. The initialized old games qualify for removal; Jimmy survives.| +|46E38B/46E45A→46E6A0,46E6E0|Matching reusable3JIM is found in the existing registry. Reuse does not invoke its constructor or re-append its node. The new game header is allocated/appended after that existing node.| + +Lab Level1B has129 records and first3JIM/JIM1 at raw8, SHA256 +316fff40db565c2add5b07cbccdef640ddb67c64d6625fea1429ce2a0542a234. +The prior [game-lifetime proof](../checkpoint/level-game-lifetime.md) supplies +the initialized-game predicate, destructor unlink and retained-character order. +The earlier fresh game→Jimmy proof remains correct **when no reusable Jimmy +exists**. It was incorrectly applied to the port's first TSK-backed story scene. + +## Causal consequence and implementation boundary + +A successful original TSK character/destination load requires an existing Jimmy; +the ordinary loader retains him and appends the new game afterward. Thus the +normal New Game story path has **Jimmy update before level-game input**, even +though it is the first playable lab. The background edge explains where that +player comes from; successful-request and retention guards establish the ordering +without treating a black screenshot as proof of the complete New Game sequence. + +At Carl completion, grounded/released Jimmy clears mode704/turn614 in437940 +before438A60 can select air input. The stale airborne destination is not republished. +This agrees with the already-executed original-component composition and the +user's upright-original observation. No Euler/turn reset is added to control grant, +DEFAULT, landing, task or animation callbacks. + +The port previously selected retained input order only when `carriedSave!=null`. +Its initial story also consumes NewGame.tsk, but incorrectly used fresh order. +Correct only that scene-entry classification: TSK-backed story and retained +transitions use player-before-input; direct scene inspection/fresh simulations +keep fresh order. Remaining scalar/helper/lifetime reconstruction stays bounded. + +## Runtime evidence and limits + +An isolated generated-copy diagnostic observed MAIN followed by Level1D allocation +and a Jimmy registry node. It required a recorded, one-time Win32 ValidateRect +acknowledgement after a pending full-window WM_PAINT. Thread snapshots suspend/ +resume owned threads briefly, so timing is perturbed. The supplied HDnoCD and +640×480 NoCD variants have separately authenticated identities; their only mutual +byte differences are the3 resolution-data bytes. Neither is silently equated with +the canonical EXE. These captures show allocation/lifetime progress, not usable +rendering, completed PostLoad, user New Game or Carl playback. + +Local artifacts: `artifacts/original-startup-diagnostic/{before-ack,with-ack,long-hd}/` +and `artifacts/main-menu-player-lifetime/source.json`. The baseline port's strengthened +native Vulkan control-phase regression fails on **first neutral tick0**: +inputAfterPlayer=false, current roll360, destination roll−10.000001, mode0/turn0. +This is the exact source-composed stale writer. After the correction, the native +Vulkan fixture stays upright on first resumed input and300 neutral ticks, then +resumes held movement. It preserves heading and locked body/fire/energy updates. +The existing standing/landing/air algorithms are unchanged; airborne return is +still governed by original air input, not an invented blanket leveling rule. + +Verification: all336 Python plus2 HUD checks, all managed projects and36 +GPU/render passes succeed. Eight new managed trajectories coverLeft/Right, +natural/skip and repeated Carl scenes. Native Linux SDL/Vulkan1920×1080 control +replay and VR04 powered steering/keyboard/800×600 resize pass, zero Vulkan errors. +The first post-return held-input readback is inspected upright. Final Debug build +has zero warnings/errors and Windows x64 cross-publish succeeds. No native Windows +execution or full-original Carl runtime is claimed. + +Logs, baseline failure, source contracts, capture hashes and verified-change.json +are in artifacts/main-menu-player-lifetime/. Clean package validation follows as +a separate checkpoint. Full original/native Windows comparison remains separate +from this source-supported initialization correction. diff --git a/docs/gameplay/original-startup-diagnostic.md b/docs/gameplay/original-startup-diagnostic.md new file mode 100644 index 0000000..deecfc9 --- /dev/null +++ b/docs/gameplay/original-startup-diagnostic.md @@ -0,0 +1,88 @@ +# Original startup: pending repaint and background Jimmy allocation + +2026-11-06. This is a local Wine diagnostic, not an untouched timing or visual +reference. Originals remain unmounted in the execution namespace and unchanged. + +`tools/recon/original_startup_probe.c` reuses the observer's exact-subject/live +instruction guards and runs only at the generated wrapper directory +`Z:\work\game`. It samples registry/actor state, loaded modules and owned thread +contexts. Each successful SuspendThread is paired with ResumeThread; all recorded +resumes succeed. Stack words are retained as raw candidates, not a full validated +unwind. Suspension perturbs timing. No game code or actor memory is written. + +## Repaint observation and controlled test + +Two initial main-thread snapshots contain the guarded OMT window-procedure return +100F1ADA and its consistent local message value0F (WM_PAINT), with internal event7. +Read-only GetUpdateRect later reports the entire1024×768 window pending. Original +DLL source100F1330 converts paint to event7 and calls100F7050; its validation of +engine-owned rectangles includes100F70BA→ValidateRect. The message pump +100F11D0..100F129C drains queued messages before returning to the periodical loop. +These bounded facts explain the diagnostic target; they do not prove all startup +time is spent in a single call or that native Windows has the same failure. + +`--acknowledge-repaint` makes one ordinary Win32 ValidateRect(window,NULL) call +after the second sample. The operation is explicit in output and changes only +the OS window update region. It is an intervention, so no result is presented as +an untouched original frame/timing trace. + +Matched24s tests use the same standard-resolution executable, generated prefix, +sampling tool and no synthetic keyboard input: + +| Condition | Observed result | +|---|---| +|No acknowledgement|16 samples through24.35s: MAIN only, no Jimmy.| +|One acknowledgement at3.10s|Pending full-window region acknowledged. By9.18s, current game table4C444C (Level1D), Jimmy table4A373C, with MAIN still in the registry.| + +The HD variant also progresses to the same allocation boundary after the recorded +acknowledgement. Both resolutions remain black with sampled gameplay-viewport +delta0 and raw ownerNULL. No usable Carl, completed New Game, completed PostLoad, +or playable-render reference is established. The source trace of +[menu/player lifetime](main-menu-player-lifetime.md) supplies the subsequent +successful-TSK retention proof; these captures establish the previously unseen +background allocation, not that complete later route. + +## Subject and code identity + +HDnoCD SHA2568cd5d21997835a40978b8b83e344c97c92217bf6cd6858f7458b76935d64dedb, +standard NoCD SHA2565e1d3bed2d649d16ec62ead02514119a16590380d4d5a6a73103db900a15c62e. +Their only mutual byte differences are resolution-data offsetsF655E,F655F,F6561: +standard640×480 versus HD1920×1080, both16-bit. The Xvfb desktop is1024×768. +This difference prompted the controlled standard-resolution check; switching +resolution alone is not claimed to repair rendering. Neither variant is assumed +equivalent to canonical Neutron.exe. + +Standard-subject REA file-header Evidence: +`ev_62814154b8ddc13d5db3c1150082b91f0f7bf1eaccf1bca208b36671a7a1bd81`. +HDnoCD complete instruction Evidence: +`ev_23555fac476985c913a80805a12b25c26c25347c6e8210ee188471dd815c276d`. +Relevant OMT instructions come from retained DLL Evidence +`ev_af082632c98b34ccfcedef01466cafa03365e7fbf482496d01a4cda6d2f8f787`; +that saved disassembly is a prefix, not complete DLL coverage. The relevant +window/message ranges are present. Original file identity is independently +checked by the project inventory and PE mapping. + +Artifacts under `artifacts/original-startup-diagnostic/` retain each probe binary, +capture identity, stdout, screenshots, module/stack/state samples and final +standard probe/dependency source. `standard/` is the acknowledged matched run; +`standard-no-ack/` is the control. All actual live anchors pass. Successful capture +requires process exit0 and `ORIGINAL_STARTUP_DIAGNOSTIC_COMPLETE`. + +## Reproduction + +Build against the source observer in the same tools directory. Reuse only the +existing generated game copy/prefix; never use an original directory as output. + +```sh +i686-w64-mingw32-gcc -std=c11 -O2 -Wall -Wextra -Werror \ + tools/recon/original_startup_probe.c -lbcrypt -o artifacts/startup-probe.exe +python3 tools/recon/reference_capture.py --asset-probe \ + --probe-executable artifacts/startup-probe.exe \ + --probe-model=--standard-resolution --probe-arg=--seconds=24 \ + --probe-arg=--acknowledge-repaint \ + --probe-success ORIGINAL_STARTUP_DIAGNOSTIC_COMPLETE --seconds 30 \ + --output artifacts/jimmy-skip-original-sw +``` + +Omit the acknowledgement argument for the control. Keep each capture in a +separate generated directory or preserve its logs/identity before another run. diff --git a/docs/gameplay/original-state-observer.md b/docs/gameplay/original-state-observer.md index 844df43..4b880d3 100644 --- a/docs/gameplay/original-state-observer.md +++ b/docs/gameplay/original-state-observer.md @@ -59,6 +59,16 @@ The supplied HD resolution variant preserves the observed operands. The HDnoCD profile is independently identified; its observation is not automatically a canonical-original behavior claim. Other supplied variants are rejected. +2026-11-06 follow-up: the supplied standard-resolution NoCD image is now a fourth +exact profile, SHA256 +`5e1d3bed2d649d16ec62ead02514119a16590380d4d5a6a73103db900a15c62e`. +Its eight live global operands match the HDnoCD profile; independent source checks +verify32 anchors across four subjects. The two NoCD images differ only at three +resolution bytes; canonical-equivalence is still not assumed. Source checks are +in artifacts/original-state-observer/profiles-4.json. Standard-subject REA Evidence +and perturbed startup observations are in +[the startup diagnostic](original-startup-diagnostic.md). + Each global address is independently guarded by its actual live instruction operand before sampling. Runtime inspection is refused if those anchors do not match within5s. This avoids assuming that the other variant has identical data diff --git a/docs/progress.md b/docs/progress.md index 1a3ba16..75a3b85 100644 --- a/docs/progress.md +++ b/docs/progress.md @@ -7,7 +7,36 @@ Next-work plan: [recover interactions, then implement verified changes](checkpoi It defines the Carl source/differential gate, the bounded implementation step, movement/contact/animation recovery and the end-to-end platform checkpoint. -## Carl lifecycle investigation and original-state observer +## Carl neutral return: TSK startup lifetime correction + +[Menu/player lifetime](gameplay/main-menu-player-lifetime.md) closes the missing +ordering distinction: the original initializes a backgroundLevel1D/Jimmy before +a successful TSK story load. The loader retains Jimmy and appends the new level +game later. First playable story entry therefore uses player-before-input, just +like subsequent retained transitions. Fresh direct-GAM order remains separate. + +Program previously used that order only when carriedSave was non-null. The +correction includes TSK-backed story entry and adds no movement/Euler reset. +The strengthened Vulkan control-phase replay fails on baseline neutral tick0 +(destination roll−10.000001), then passes first input plus300 idle ticks after +the correction, preserving heading and held-input/body/fire continuation. +Eight managed trajectories coverLeft/Right, natural/skip and repeated scenes. +All336 Python+2 HUD, managed projects and36 GPU/render passes succeed. Native Linux +SDL/Vulkan1920×1080 control replay and VR04 powered keyboard/steering/resize pass +with zero validation errors; the first returned-frame readback is inspected upright. +Final build has zero warnings/errors; Windows x64 cross-publish passes. Source/ +test provenance is in artifacts/main-menu-player-lifetime/verified-change.json. +Clean package validation follows; historical a2e89c6/dae13ac is not the identity of +an in-progress cross-build. Native Windows/original Carl execution stays unverified. + +The additional derived-frame caller50 native cases and static body/visual-sync +audit close their bounded omissions. A matched original-resolution Wine startup +diagnostic progresses to backgroundJimmy allocation only after the recorded +repaint acknowledgement; frames remain black. See +[startup observations](gameplay/original-startup-diagnostic.md). These are +perturbed allocation observations, not full original Carl or Windows fidelity. + +## Earlier Carl lifecycle investigation and original-state observer The accepted plan is underway; its gameplay correction gate remains open. [Integrated lifecycle trace](gameplay/jimmy-cutscene-lifecycle.md) records292 new diff --git a/docs/tasks.md b/docs/tasks.md index 1e4583a..41e51e8 100644 --- a/docs/tasks.md +++ b/docs/tasks.md @@ -48,6 +48,22 @@ compile, runtime and original-fidelity verification are separate. Execution order and acceptance criteria: [next work plan](checkpoint/next-work-plan.md). +- [x] Close the first-story ordering distinction through original menu background, + controlled-Jimmy TSK request, ordinary selective teardown and registry reuse. + See gameplay/main-menu-player-lifetime.md. Preserve conditional fresh-GAM order. +- [x] Correct TSK story-entry order; native Vulkan regression fails on baseline + tick0 and passes first neutral input plus300 idle ticks after the change. + Eight managed Left/Right/natural/skip/repeated-scene cases pass. +- [x] Verify50 additional derived Jimmy caller cases and audit body-context/ + surface-alignment/visual-sync ownership without inventing an angle reset. +- [x] Complete integrated suite:336 Python+2 HUD, all managed projects and36 + GPU/render passes; native Linux SDL control/VR04 input-steering-resize and + Windows x64 cross-publish pass. No native Windows execution is inferred. +- [ ] Build clean Linux/Windows packages and verify standalone runtime/resource + provenance for the TSK entry-order correction. +- [ ] Obtain native Windows/whole-original Carl feedback for that same scenario; + local Wine allocation diagnostics remain visually unusable. + - [x] Expand original lifecycle coverage:96 Carl contact,8 composed input/ controller/skip-prefix,48 task/objective and140 base/STOP cases; recover complete DEFAULT pseudocode through a mapped carrier. See gameplay/jimmy-cutscene-lifecycle.md. @@ -57,12 +73,15 @@ Execution order and acceptance criteria: [next work plan](checkpoint/next-work-p - [ ] Capture the actual original Carl banked-entry/skip/neutral-return interval. Local Wine reaches MAIN with black frames and no Jimmy; the composed original routines do not establish a reset. Use the observer on a working copied original - before changing gameplay. Preserve ordinary landing bank. + for the remaining full-runtime comparison. The separately recovered TSK lifetime + now supports the bounded startup-order correction. Preserve ordinary landing bank. -- [ ] Current user direction: decompile the complete Carl skip-to-idle state - lifecycle before further gameplay implementation. Preserve a2e89c6/dae13ac. - Close original support/mode/turn/input/skip ownership and same-frame ordering; - see gameplay/jimmy-cutscene-decompilation.md. +- [x] Current user direction: decompile the Carl skip-to-idle state + lifecycle before further gameplay implementation. Baseline a2e89c6/dae13ac was + preserved through that research checkpoint. + Establish the missing source ordering before implementation. The successful TSK + entry chain now closes that bounded gate; full original runtime comparison and + broader core reconstruction stay open. See gameplay/main-menu-player-lifetime.md. - [x] Reproduce the remaining post-skip bug with48 managed port traces: all24 fresh-order cases retilt, all24 retained-order cases stay upright. This is diagnostic evidence, not a source-justified scheduling or reset correction. diff --git a/src/GamePort/Application/CutsceneIdleSmoke.cs b/src/GamePort/Application/CutsceneIdleSmoke.cs new file mode 100644 index 0000000..ce7c10e --- /dev/null +++ b/src/GamePort/Application/CutsceneIdleSmoke.cs @@ -0,0 +1,32 @@ +using GamePort.Game; + +namespace GamePort.Application; + +/// Exercise grounded neutral input after skipping the real Carl chain. +/// Kept separate from the held-input check, which cannot detect stale bank. +internal static class CutsceneIdleSmoke +{ + public static void LandWhileLocked(PlayerSceneBinding binding, SceneDirector director, LabSimulation player) + { + for (var tick = 0; tick < 180; tick++) binding.Step(default); + if (director.Controlled || !player.Grounded || player.MovementMode != 1 || player.TurnRate == 0) + throw new InvalidOperationException("Carl idle fixture did not retain airborne mode/turn through an uncontrolled landing"); + } + + public static void VerifyReturn(PlayerSceneBinding binding, SceneDirector director, LabSimulation player) + { + var yaw = player.Yaw; + for (var tick = 0; tick < 300; tick++) + { + binding.Step(default); + if (!director.Controlled || player.MovementMode != 0 || player.TurnRate != 0 + || MathF.Abs(MathF.IEEERemainder(player.Pitch, 360)) > .001f + || MathF.Abs(MathF.IEEERemainder(player.Roll, 360)) > .001f + || MathF.Abs(MathF.IEEERemainder(player.Yaw - yaw, 360)) > .001f + || MathF.Abs(player.FacingTarget.X) > .001f || MathF.Abs(player.FacingTarget.Z) > .001f) + throw new InvalidOperationException($"Carl neutral return republished airborne bank on tick{tick}: " + + $"inputAfterPlayer={player.InputAfterPlayerUpdate}, Euler={player.Rotation}, target={player.FacingTarget}, mode={player.MovementMode}, turn={player.TurnRate}"); + } + Console.WriteLine("Carl neutral return: upright on first resumed input and300 idle ticks; heading preserved."); + } +} diff --git a/src/GamePort/Program.cs b/src/GamePort/Program.cs index 3a8a260..ed3bca1 100644 --- a/src/GamePort/Program.cs +++ b/src/GamePort/Program.cs @@ -362,7 +362,10 @@ internal static class Program cameraRay == null ? null : (look, eye) => cameraRay.Trace(look, eye), cameraRay == null ? null : (start, end) => cameraRay.TraceGeometry(start, end), level.Code is "VR01" or "VR02" or "VR04" or "VR07" or "VR08" ? OriginalStaticCollision.FromRouteScene(world,level.Code) : null, energy) - { LevelCode = level.Code, InputAfterPlayerUpdate = carriedSave != null }; + //Successful TSK entry reuses the menu-background Jimmy, whose + //node precedes the new level game. Direct scene inspection + //still has fresh game-before-player order. See main-menu-player-lifetime.md. + { LevelCode = level.Code, InputAfterPlayerUpdate = story || carriedSave != null }; if(level.Code=="VR08")simulation.EnableGrappler(world,grapplerMemory); if (carriedPlayer != null) { @@ -1502,6 +1505,8 @@ internal static class Program count++; if (controlPhaseSmoke && (count == 1 || count == 15) && Option(args, "--screenshot") is { } phaseCapture) renderer.SavePpm(Path.ChangeExtension(phaseCapture, count == 1 ? ".locked-start.ppm" : ".locked-fall.ppm")); + if (controlPhaseSmoke && count == 16 && Option(args, "--screenshot") is { } returnCapture) + renderer.SavePpm(Path.ChangeExtension(returnCapture, ".returned.ppm")); if (controlPhaseSmoke && count == 15) { phasesLocked = director is { Controlled: false, Playing: true } @@ -1511,7 +1516,11 @@ internal static class Program && simulation.Rotation == controlRotation && simulation.FacingTarget == controlRotation && !simulation.FacingDirty && simulation.ActorRoot.Y < controlEntry.Y && simulation.JetpackRemaining is > 0 and < 6.125f && simulation.Energy < 20 && Vector2.Distance(new(simulation.ActorRoot.X, simulation.ActorRoot.Z), new(controlEntry.X, controlEntry.Z)) < .001f; + CutsceneIdleSmoke.LandWhileLocked(playerBinding!, director!, simulation!); + sceneAudio?.StopSpeech(); director!.Skip(); + CutsceneIdleSmoke.VerifyReturn(playerBinding!, director, simulation!); + controlControllers = simulation!.ControllerSteps; } if (controlPhaseSmoke && count == 30) phasesResumed = director!.Controlled && simulation!.ControllerSteps == controlControllers + 15 && simulation.Travel > 1; diff --git a/tests/GamePort.DirectorTests/Program.cs b/tests/GamePort.DirectorTests/Program.cs index 43078f0..fff4d59 100644 --- a/tests/GamePort.DirectorTests/Program.cs +++ b/tests/GamePort.DirectorTests/Program.cs @@ -242,6 +242,52 @@ foreach (var kind in new[] { "3CAM", "3MCA" }) } Console.WriteLine("PASS CAM and original Carl MCA banked-jump preparation, destination yaw/dirty ownership and sustained control lock"); +foreach (var left in new[] { false, true }) +foreach (var skipPlayback in new[] { false, true }) +{ + var scene = new SceneDirector(level, new TaskStates(save.Tasks), (_, _) => 2); + var body = ControlBody(); + //Normal TSK story entry retains the background Jimmy before the new game. + //The application's control-phase smoke separately checks this entry wiring. + body.InputAfterPlayerUpdate = true; + using var binding = new PlayerSceneBinding(scene, body, new SceneInventory(new int[19]), "JIM1"); + for (var carlCycle = 0; carlCycle < 2; carlCycle++) + { + for (var tick = 0; tick < 8; tick++) binding.Step(new(true, false, left, !left, true)); + Check(!body.Grounded && body.MovementMode == 1 && body.TurnRate != 0, + "Neutral return starts with a banked jump on either turn direction"); + scene.SyncActor("JIM1", body.ActorRoot, body.Rotation); + scene.Trigger("neutron1a"); + for (var tick = 0; tick < 180; tick++) + { + binding.Step(default); + scene.Step(FixedStepClock.Step); + } + Check(body.Grounded && !scene.Controlled && body.MovementMode == 1 && body.TurnRate != 0, + "Uncontrolled landing retains mode and stored turn before Carl finishes"); + var yaw = body.Yaw; + if (skipPlayback) scene.Skip(); + else + { + for (var tick = 0; scene.Playing && tick < 1200; tick++) + { + binding.Step(default); + scene.Step(FixedStepClock.Step); + } + } + Check(scene.Controlled && !scene.Playing, "Carl completes naturally or through skip"); + for (var tick = 0; tick < 300; tick++) + { + binding.Step(default); + Near(body.Rotation, new(0, yaw, 0), "First and sustained neutral return stay upright with heading preserved"); + Near(body.FacingTarget, new(0, yaw, 0), "Neutral return never republishes airborne bank"); + Check(body.MovementMode == 0 && body.TurnRate == 0, + "Original grounded controller clears movement state before resumed input"); + } + } +} +Console.WriteLine("PASS eight Carl neutral-return trajectories: Left/Right, natural/skip, repeated scenes and first resumed input"); + using (var reference = JsonDocument.Parse(File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "original-camera-rotation-reference.json")))) { var cases = 0; diff --git a/tools/binary/jimmy_body_transform_return.py b/tools/binary/jimmy_body_transform_return.py new file mode 100644 index 0000000..938d0f5 --- /dev/null +++ b/tools/binary/jimmy_body_transform_return.py @@ -0,0 +1,140 @@ +#!/usr/bin/env python3 +"""Guard the original body-context/normal-alignment and visual-sync boundary. + +Reads authoritative files and existing REA Evidence. The generated report is +static evidence, not original gameplay or a new component execution. +""" +import argparse +from collections import Counter +import hashlib +import json +from pathlib import Path +import re +import struct + +from bubble_body import geometry +from checkpoint_script_state import EXE_SHA256, find_case, read_va, rel_call_target +from jimmy_model_bridge import collect as transform_contract +from pe_inspect import PE + +REA_ID = 'ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904' +DLL_REA_ID = 'ev_af082632c98b34ccfcedef01466cafa03365e7fbf482496d01a4cda6d2f8f787' +LAB_SHA = '5a33d11311fc222631eb8f7384d1863192cb1f55f7e67035caa0ae12fd9892ab' +SLOTS = ( + ('Player active constructor alignment setter', 0x4af6c4, 0x1ec, 0x471960), + ('Jimmy property getter', 0x4a373c, 0xc4, 0x471080), + ('Jimmy property setter', 0x4a373c, 0xc8, 0x471090), + ('Jimmy alignment getter', 0x4a373c, 0x1e8, 0x471950), + ('Jimmy alignment setter', 0x4a373c, 0x1ec, 0x471960), + ('Jimmy eligible getter', 0x4a373c, 0x210, 0x4719f0), + ('Jimmy context getter', 0x4a373c, 0x338, 0x472570), + ('Jimmy current Euler getter', 0x4a373c, 0x328, 0x4723f0), + ('Jimmy current Euler setter', 0x4a373c, 0x330, 0x472420), + ('Jimmy position publication', 0x4a373c, 0x3dc, 0x4624b0), + ('Jimmy Euler publication', 0x4a373c, 0x3e0, 0x4624f0), + ('Jimmy cached render angle setter', 0x4a373c, 0x3e4, 0x462500), + ('Lab terrain callback', 0x4c3cd0, 0x130, 0x44e030), + ('VR04 terrain callback', 0x4ce910, 0x130, 0x44e030), + ('Outside terrain callback', 0x4c5a80, 0x130, 0x44e030), + ('Jimmy floor-loop retarget', 0x4a3bdc, 0x1e4, 0x42aec0), +) +SITES = ( + ('Player constructor clears argument register', 0x43729e, '33db'), + ('Player installs constructor game table', 0x437332, 'c706c4f64a00'), + ('player disables alignment property', 0x437426, '538bcee8629c0300'), + ('property setter mirrors to live field', 0x471090, '8b4424048b1150884110ff92ec010000c20400'), + ('Init restores live alignment from property', 0x47059c, '8b3e8bceff97c4000000508bceff97ec010000'), + ('alignment live getter', 0x471950, '8a8138010000c3'), + ('alignment live setter', 0x471960, '8a442404888138010000c20400'), + ('body callback precedes alignment gate', 0x46258f, 'ff95300100008b168bceff92e8010000'), + ('alignment write current XYZ', 0x462630, '8bceff9230030000'), + ('visual position before angle', 0x473784, 'ff90dc0300008b168bceff92e0030000'), + ('default terrain sound selector', 0x44e407, 'c7824c05000005000000'), + ('floor-loop retarget call', 0x44e426, 'ff92e4010000'), +) +RANGES = ( + ('body-context bridge', 0x462520, 0x462649), + ('Player constructor alignment initialization', 0x43729e, 0x43743e), + ('generic property initialization', 0x470540, 0x470610), + ('property getter and setter', 0x471080, 0x4710a3), + ('live alignment getter and setter', 0x471950, 0x47196d), + ('context getter', 0x472570, 0x472577), + ('current Euler setter', 0x472420, 0x472450), + ('terrain callback', 0x44e030, 0x44e444), + ('floor-loop retarget', 0x42aec0, 0x42aef1), + ('position publication', 0x4624b0, 0x4624f0), + ('angle publication forwarding and setter', 0x4624f0, 0x46251e), + ('angle conversion', 0x473540, 0x4735da), + ('whole-registry transform publication', 0x473770, 0x4737a2), +) + + +def collect(original, rea): + original = Path(original) + pe = PE(find_case(original, 'Neutron.exe')) + if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256: + raise ValueError('Unexpected original EXE') + evidence = next(r for r in json.loads(Path(rea).read_text())['records'] + if r['evidence_id'] == REA_ID) + if evidence['subject']['digest']['sha256'] != EXE_SHA256: + raise ValueError('Wrong REA subject') + sites, slots = [], [] + for name, va, expected in SITES: + actual = read_va(pe, va, len(bytes.fromhex(expected))).hex() + if actual != expected: + raise ValueError(f'Changed {name} at {va:#x}: {actual}') + sites.append(dict(name=name, va=hex(va), file_offset=hex(pe.offset(va-pe.base)), bytes=actual)) + for name, table, slot, expected in SLOTS: + actual, = struct.unpack('1e-6: + raise ValueError('Movement state changed outside controller') + if row['current'] != '13,155,17' or row['target'] != '-40,154,-12': + raise ValueError('Euler changed outside controller') + paths = [output/'probe.exe', output/'jimmy_derived_frame_probe.c', output/'source.json', + capture/'wine.log', capture/'capture.json', capture/'game/Neutron.exe'] + if hashlib.sha256(paths[-1].read_bytes()).hexdigest() != EXE_SHA256: + raise ValueError('Executed mapped source copy identity') + result = dict(cases=cases, source_sha256=EXE_SHA256, rea_evidence_id=REA_ID, + provenance={str(p):hashlib.sha256(p.read_bytes()).hexdigest() for p in paths}, + scope='50 derived-caller cases; recorded controller, no-hit world queries and UI adapters.') + (output.parent/'native-observations.json').write_text(json.dumps(result, indent=2)+'\n') + return dict(cases=len(cases), wine_exit=0) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('original', type=Path) + parser.add_argument('--output', type=Path, required=True) + parser.add_argument('--rea', type=Path, required=True) + parser.add_argument('--capture', type=Path) + args = parser.parse_args() + result = generate(args.original, args.output, args.rea) + if args.capture: + result['observations'] = observe(args.output, args.capture) + print(json.dumps({k:v for k,v in result.items() if k != 'rea_extracts'}, indent=2)) diff --git a/tools/binary/jimmy_derived_frame_probe.c b/tools/binary/jimmy_derived_frame_probe.c new file mode 100644 index 0000000..8c86775 --- /dev/null +++ b/tools/binary/jimmy_derived_frame_probe.c @@ -0,0 +1,93 @@ +/* Actual derived424600 and its ordinary pre/post helpers. The controller437940 + is a recording adapter: this isolates caller-owned writes/gates, not physics. + World queries return no hit; UI visibility/menu transitions are adapters. */ +#define main unused_scalar_main +#include "grappler_scalar_probe.c" +#undef main + +static uintptr_t game_table[0x450/4], complete_table[0x220/4]; +static uintptr_t menu_table[0x500/4], helper_table[0x60/4]; +static unsigned char menu_object[0x600], helper[0x100], current_game[0x600]; +static int controllers, upward_queries, downward_queries, closed, hidden; +#define GF(o) (*(float*)(object+0xc0+(o))) +#define MODE (*(short*)(object+0x7c4)) + +static void fix(uint32_t a, uint32_t b) { + const uint32_t targets[]={/* RELOCATIONS */}; + for(;a+4<=b;a++) { + uint32_t v;memcpy(&v,AT(a),4); + for(unsigned i=0;iContextRecord->Eip-(uintptr_t)mapped+0x400000,e->ExceptionRecord->ExceptionCode,e->ExceptionRecord->ExceptionInformation[1]); + ExitProcess(2);return EXCEPTION_CONTINUE_SEARCH; +} +static void TC controller(void*self,float dt) { + require(self==object+0xc0&&dt==1.f/60,"controller owner/delta");controllers++; +} +static void TC close_menu(void*self) {require(self==menu_object,"menu owner");closed++;} +static void TC visibility(void*self,int value) {require(self==helper&&value==1,"helper visibility owner");hidden++;} +static int no_up_hit(void) {upward_queries++;return 0;} +static int no_down_hit(void) {downward_queries++;return 0;} +static void draw(void) {require(0,"unexpected HUD draw in ordinary fixture");} + +static void one(int owner,int lock,int state,int supported,int rising,int ticks) { + memset(object,0,sizeof(object));memset(menu_object,0,sizeof(menu_object)); + *(void**)object=complete_table;*(void**)(object+0xc0)=game_table; + *(void**)menu_object=menu_table;*(short*)(menu_object+0x4d4)=(short)state; + /* Menu layout0 makes actual406590 a no-op; resources are not synthesized. */ + *(void**)(object+0xa18)=menu_object; + *(void**)(object+0xc0+0x1d94)=helper+0xc0; + *(void**)helper=helper_table; + *(void**)AT(0x509948)=current_game;*(uint32_t*)(current_game+0x490)=0x4c563142; + *(void**)AT(0x5099e4)=owner==0?NULL:owner==1?object+0xc0:helper+0xc0; + *AT(0x4f8181)=(unsigned char)lock;*AT(0x509a12)=0;*AT(0x4f8210)=0; + *(short*)AT(0x4f0588)=-1;F(0x4eefc8)=F(0x4eefd0)=-1; + F(0x4f83d4)=100;F(0x4f83c8)=0;F(0x4f8408)=0; + *(void**)AT(0x4f7cb0)=*(void**)AT(0x4f8028)=NULL; + *(int*)(object+0xc0+0x974)=*(int*)(object+0xc0+0x97c)=-1; + *(int*)(object+0x1e08)=-1; + object[0xc0+0x13f]=(unsigned char)supported;object[0xc0+0x1d41]=1; + GF(0x214)=10;GF(0x218)=20;GF(0x21c)=30;GF(0x220)=1; + GF(0x224)=13;GF(0x228)=155;GF(0x22c)=17;GF(0x230)=1; + GF(0x274)=-40;GF(0x278)=154;GF(0x27c)=-12;GF(0x280)=1; + GF(0x1a8)=rising?100:0;MODE=1;GF(0x614)=11.666668f;object[0xca]=1; + unsigned char euler[32];memcpy(euler,object+0x2e4,16);memcpy(euler+16,object+0x334,16); + controllers=upward_queries=downward_queries=closed=hidden=0; + for(int i=0;i + +static void threads(HANDLE process, DWORD pid, unsigned elapsed) { + HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); + THREADENTRY32 entry = {0}; + entry.dwSize = sizeof(entry); + if (snapshot == INVALID_HANDLE_VALUE) return; + if (Thread32First(snapshot, &entry)) do { + if (entry.th32OwnerProcessID != pid) continue; + HANDLE thread = OpenThread(THREAD_SUSPEND_RESUME|THREAD_GET_CONTEXT|THREAD_QUERY_INFORMATION, + FALSE, entry.th32ThreadID); + CONTEXT context = {0}; + uint32_t stack[64] = {0}; + int context_ok = 0, stack_ok = 0; + if (!thread) continue; + DWORD prior = SuspendThread(thread); + if (prior != (DWORD)-1) { + context.ContextFlags = CONTEXT_CONTROL; + context_ok = GetThreadContext(thread, &context); + if (context_ok) stack_ok = read_memory(process, context.Esp, stack, sizeof(stack)); + /* Resume even when context/stack reads fail. Keep prior suspension count. */ + DWORD resumed = ResumeThread(thread); + printf("{\"kind\":\"thread\",\"elapsed_ms\":%u,\"tid\":%lu,\"prior_suspend\":%lu," + "\"resume_ok\":%s,\"context_ok\":%s,\"eip\":%lu,\"esp\":%lu,\"stack_ok\":%s,\"stack\":[", + elapsed, entry.th32ThreadID, prior, resumed!=(DWORD)-1?"true":"false", + context_ok?"true":"false", context.Eip, context.Esp, stack_ok?"true":"false"); + for (unsigned i=0; stack_ok && isha)) { CloseHandle(file); return 4; } + start.cb = sizeof(start); + if (!CreateProcessA(command,command,NULL,NULL,FALSE,0,NULL,cwd,&start,&child)) { CloseHandle(file); return 5; } + CloseHandle(file); CloseHandle(child.hThread); + printf("{\"kind\":\"diagnostic_subject\",\"sha256\":\"%s\",\"pid\":%lu,\"timing_perturbed\":true}\n",digest,child.dwProcessId); + DWORD began=GetTickCount(); int identified=0; + for (unsigned sample=0; GetTickCount()-began