From 27be8ed63079ae2e3bf7e965ee205c4a57a96559 Mon Sep 17 00:00:00 2001 From: Cristian Cerroni Date: Thu, 5 Nov 2026 10:19:12 -0500 Subject: [PATCH] Integrate source airborne tilt and logical-root rendering --- AGENTS.md | 10 +- README.md | 4 +- docs/architecture.md | 11 +- docs/checkpoint/coverage.md | 6 + docs/compatibility.md | 9 + docs/decisions.md | 10 + docs/gameplay/jimmy-air-bridge.md | 89 ++ docs/gameplay/jimmy-air-target-state.md | 155 +++ docs/gameplay/jimmy-movement-stabilization.md | 9 +- docs/gameplay/jimmy-render-transform.md | 114 +++ docs/progress.md | 26 + docs/reverse-engineering.md | 6 + docs/tasks.md | 8 +- scripts/test.sh | 1 + src/GamePort/Game/BubbleMotion.cs | 7 +- src/GamePort/Game/JimmyAirMotion.cs | 13 + src/GamePort/Game/JimmyRenderTransform.cs | 46 + src/GamePort/Game/LabSimulation.cs | 82 +- src/GamePort/Game/PlayerLevelState.cs | 3 +- src/GamePort/Game/PlayerSceneBinding.cs | 9 +- src/GamePort/Program.cs | 19 +- tests/GamePort.DirectorTests/Program.cs | 4 + .../GamePort.InteractionTests.csproj | 1 + .../GamePort.JimmyAirTests.csproj | 1 + tests/GamePort.JimmyAirTests/Program.cs | 13 + .../GamePort.JimmyRenderTests.csproj | 9 + tests/GamePort.JimmyRenderTests/Program.cs | 54 + .../original-render-reference.json | 925 ++++++++++++++++++ tests/GamePort.MovementTests/Program.cs | 72 +- .../GamePort.PatrolTests.csproj | 1 + tests/test_jimmy_air_target_state.py | 44 + tests/test_jimmy_model_bridge.py | 33 + tools/binary/jimmy_air_target_state.py | 120 +++ tools/binary/jimmy_model_bridge.py | 24 + .../binary/jimmy_model_bridge_angles_probe.c | 32 + tools/binary/jimmy_model_bridge_probe.c | 45 + 36 files changed, 1953 insertions(+), 62 deletions(-) create mode 100644 docs/gameplay/jimmy-air-bridge.md create mode 100644 docs/gameplay/jimmy-air-target-state.md create mode 100644 docs/gameplay/jimmy-render-transform.md create mode 100644 src/GamePort/Game/JimmyRenderTransform.cs create mode 100644 tests/GamePort.JimmyRenderTests/GamePort.JimmyRenderTests.csproj create mode 100644 tests/GamePort.JimmyRenderTests/Program.cs create mode 100644 tests/GamePort.JimmyRenderTests/original-render-reference.json create mode 100644 tests/test_jimmy_air_target_state.py create mode 100644 tests/test_jimmy_model_bridge.py create mode 100644 tools/binary/jimmy_air_target_state.py create mode 100644 tools/binary/jimmy_model_bridge.py create mode 100644 tools/binary/jimmy_model_bridge_angles_probe.c create mode 100644 tools/binary/jimmy_model_bridge_probe.c diff --git a/AGENTS.md b/AGENTS.md index 68e75ab..3402b28 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -44,9 +44,13 @@ The prior collision work is resumed where needed for movement; preserve the Controller checkpoint integrates108 native ground/air/facing/jump comparisons; 13 Jimmy source guards,26 movement/20 body groups and all five native SDL jump aliases pass. Source pressure requires a real support polygon; lab/outside keep -capsule compatibility. Next: ordinary air destination Euler plus the actor-root -render bridge, then special/root-changing/dynamic contracts.27 contact-dispatch -and12 air-target observations are evidence, not live implementation claims. +capsule compatibility. The next bounded air-target/root-render bridge is now +implemented (docs/gameplay/jimmy-air-bridge.md):146 saved source observations +compare, including12 air targets and12 degree/14 hierarchical transforms. Target +dirty/Init and retained apply-owned pitch seeds stay separate from current Euler. +Modern local sole correction and final OMT render-decomposition precision remain +explicit; broader special/root-changing/dynamic contacts are next.27 contact +dispatch observations still do not establish live special callbacks. No Remote/new-gadget implementation until this movement priority is handled. The initial architecture checkpoint is documented in docs/checkpoint/review.md; use the playable 69d0187 baseline as a comparison tool. Read diff --git a/README.md b/README.md index 7e6135c..e4a639b 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,9 @@ services are used. playable movement baseline; JN-Engine's original decompiler index supplies leads, verified with REA and authoritative component probes. The [movement checkpoint](docs/gameplay/jimmy-movement-stabilization.md) records -controller/facing/jump corrections and remaining render/body gates. The +controller/facing/jump corrections. The [air bridge](docs/gameplay/jimmy-air-bridge.md) +adds source airborne tilt, target-state ownership and full Euler rendering, with +explicit remaining render precision/body gates. The [checkpoint review](docs/checkpoint/review.md), [coverage map](docs/checkpoint/coverage.md) and [implementation plan](docs/checkpoint/implementation-plan.md) compare source owners, update order and lifecycles with the port. Clean69d0187 and its packages diff --git a/docs/architecture.md b/docs/architecture.md index 4f1936c..6d3a718 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -116,10 +116,13 @@ and pause simulation, while C pauses for inspection and R resets the start area. The Jimmy movement checkpoint uses `JimmyGroundMotion`/`JimmyAirMotion` for source input and velocity publication, `JimmyOrientation` in the base phase before control gating, and `JetpackBurst` for the controller/effect state tables. -Keyboard-turn latch and destination Euler are retained independently of current -Euler. Ground pressure requires a real source-body support polygon; the capsule -does not manufacture one. Ordinary air destination pitch and the complete -actor-root render bridge remain a paired implementation gate. See +Keyboard-turn latch and destination Euler/dirty are retained independently of +current Euler. Init clears the target/dirty while apply-owned air pitch seeds +survive bounded route loads. Ground pressure requires a real source-body support +polygon; the capsule does not manufacture one. JimmyRenderTransform now supplies +the full Euler hierarchical basis, source degree quantization and a modern local +sole correction around the logical root. Final OMT model decomposition remains +a separate precision gate. See [movement stabilization](gameplay/jimmy-movement-stabilization.md). `SceneCollision` sweeps/slides a vertical capsule against retained original scene diff --git a/docs/checkpoint/coverage.md b/docs/checkpoint/coverage.md index 2508ab2..2f1a20d 100644 --- a/docs/checkpoint/coverage.md +++ b/docs/checkpoint/coverage.md @@ -18,6 +18,12 @@ the source body, while lab/outside retain capsule compatibility.27 special contact dispatch and12 air-target observations expose remaining gates; they do not certify special callbacks or the ordinary air-pitch visual bridge. +The following [air-target/render continuation](../gameplay/jimmy-air-bridge.md) +implements ordinary pitch/roll targets, dirty/Init and retained seed ownership, +full current Euler publication and source hierarchical model rotation.146 native +observations now compare with managed components. The model-local sole correction +is modern; exact final OMT render decomposition and broad collision remain open. + | ID / system | Recovered contract / anchors | Port implementation | Evidence / remaining gap | Next bounded action | |---|---|---|---|---| | LOOP | Viewport47E4F0 physics before registry473740, including input44DF80; second sync473770; construction order and selective retained-character/new-game ordering. Separate engine morph clock. | Player now integrates prior body state, then fresh input/player/fire or retained player/fire/input. Uncontrolled body/fire now continue while movement/input are gated. Other systems remain grouped; fixed60Hz policy. | S/M/R. Controlled player partial order implemented; bounded raw-owner preparation implemented; full wrapper/registry/cadence open. | C3 continue other callbacks and morph/control phases; C4 support/response remains separate. | diff --git a/docs/compatibility.md b/docs/compatibility.md index 1752d9c..decbcff 100644 --- a/docs/compatibility.md +++ b/docs/compatibility.md @@ -1,5 +1,14 @@ # Compatibility and validation +Jimmy airborne bridge (2026-11-05): ordinary forward/back pitch and turn lean, +source target/dirty/Init/retained-seed ownership, full authored Euler and logical +root hierarchical rendering are integrated.146 native component outputs match; +final OMT model decomposition remains an explicit precision gate, and sole +alignment remains a modern local adapter. Native Linux all-five-jump walking/ +jetpack replays pass with25 identical cross-binding captures; Carl/control phases +pass, zero validation errors. Collision admission is unchanged. Detailed current +validation and limits: [air bridge](gameplay/jimmy-air-bridge.md). + Jimmy movement (2026-11-05):108 copied-original ground/air/facing/jump observations match managed components.26 integrated movement/20 body groups pass; lab and two-way underground routes retain the user's baseline. Native Linux walking and diff --git a/docs/decisions.md b/docs/decisions.md index 34551cc..37aff37 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -319,3 +319,13 @@ Keep ordinary air pitch/actor-root visual bridge together as the next chunk, and special/root-changing/dynamic body behavior behind independent gates. See gameplay/jimmy-movement-stabilization.md. + +49. **Keep air input, facing and the logical-root visual bridge together.** + Pitch seeds are retained apply-owned fields, not per-input mode constants. + Init clears destination Euler/dirty independently of current full STRT Euler. + Publish full authored/current XYZ and enable ordinary pitch/turn lean with + source hierarchical rotation/degree caching. Retain upright foot alignment + as an explicit local model correction around the logical root; do not call it + an original pivot offset or mutate source geometry/body support. Defer OMT's + final approximate-angle model decomposition with its measured seam mismatch. + Broader special/dynamic collision retains separate gates. See jimmy-air-bridge.md. diff --git a/docs/gameplay/jimmy-air-bridge.md b/docs/gameplay/jimmy-air-bridge.md new file mode 100644 index 0000000..1cf0182 --- /dev/null +++ b/docs/gameplay/jimmy-air-bridge.md @@ -0,0 +1,89 @@ +# Jimmy airborne targets and rendering bridge + +2026-11-05. Continuation of [movement stabilization](jimmy-movement-stabilization.md). +Preserve the playable controller baseline and original550 impulse/−800 gravity; +JN-Engine is used only for original-code navigation, verified with REA/source. + +## Recovered contracts and integration + +[Target state](jimmy-air-target-state.md) records source addresses/offsets, Init, +accepted input, pitch seeds, destination/dirty ownership and route retention. +[Render transform](jimmy-render-transform.md) records source-degree/OMT matrix +recovery and copied-original observations. These distinguish instruction/data +recovery, native component execution, implementation and port verification. + +- `JimmyAirMotion.Destination` matches all12 previously recovered ordinary-air + writes: Up reads retained forward pitch, Down reads backward pitch, Up wins, + neutral pitch0, yaw=current and roll=−turn. These are now live. +- `LabSimulation` retains forward/back pitch seeds. Constructor/debug reset seeds + −40/+10; ordinary air apply reasserts−40/+10, Bubble apply−10/+10. Input reads + whatever the preceding apply left. Bubble equip/cleanup does not reseed. +- `PlayerLevelState` carries these two process scalars only through its already + bounded lab/VR04/outside ordinary/jetpack route. Init resets targetEuler0 and + dirty=false independently. Original TSK files gain no fields. Debug reset R + remains a modern constructor-style reset. +- Current Euler, destination Euler and dirty state are separate. Accepted active + ground input writes upright destination; neutral leaves it. Air writes each + pass. Facing runs before raw control gating, only when dirty, then retains dirty + according to the before-step equality check. Authored fullXYZ writes current + Euler without replacing destination. Default route STRTs are upright; arbitrary + selected STRT Euler is now passed in full instead of dropping X/Z. +- `PlayerSceneBinding` and application sync publish full current Euler. The old + Bubble-only orientation switch/seeding bridge is removed. Vehicle passengers + continue to copy their full authored Euler; Scooter's existing copied-destination + adapter is retained as its separate compatibility boundary. +- The character model now uses `JimmyRenderTransform`: source-degree quantization, + proven local rotation order and the unrotated logical root. The former sole + correction becomes a fixed model-local translation before rotation. Upright + placement is preserved; tilt pivots around the logical root. This correction + remains modern, not an original recovered offset or complete pivot parity. + +Debug noclip/Stop Motion explicitly freezes the pending facing request along +with body motion, so enabling/debug-stopping flight cannot retain an unseen tilt +request. This is modern tool policy, separate from original script preparation. +Script STOP still preserves destination and queued body/effect work. + +## Verification in progress + +12 destination observations compare against the managed target helper. New +integrated cases cover Init/dirty/current writes, control locks, ordinary tilt, +scalar versus horizontal velocity, fresh/retained first Bubble input, cleanup, +route carry/reseed and noclip.28 movement groups,20 body groups and13 Grappler +integration groups pass in targeted runs. Lab and underground input-only routes +pass. Renderer component/whole-regression/native/package results follow below. + +The old powered-path regression required50 units of lateral displacement under +flat air. Source pitch attenuation produces about38 units on both paths in its +same60-step fixture; the test now requires30 measurable lateral units and retained +lift. No gameplay tuning was changed to recover the old flat-air distance. +Artifacts: artifacts/jimmy-air-bridge/{movement-diagnostic,movement-targets, +movement-bridge,body-targets,grappler-targets,lab-route,underground-route}.log. + +## Remaining gates + +The source hierarchical transform is recovered; OMT's later final render-matrix +decomposition/re-quantization is still approximated, with measured seam deviation +recorded in the transform report. The model-local sole alignment and original +animation-root/completion behavior remain distinct. No radius, support, dynamic +or special-contact admission changes are made here. Root-changing callback Vec4 +publication, world-response versus integration, hazards/climbs and dynamic pair +eligibility remain the next Jimmy body checkpoint. Whole-original trajectories, +original cadence and native Windows gameplay still require comparison. + +### Native movement integration + +Native Linux GTX1070/private Xvfb1920×1080 passes300-step VR04 powered steering +and240-step lab walking for shift/right-shift/insert/keypad0/right-mouse, including +actual SDL event receipt and resize. New smoke captures at powered step75/110 and +ordinary jump step90 record current/target Euler and the rendered frame. All25 +final/airborne readbacks match across bindings, with zero Vulkan validation errors. +The first forward/brake/ordinary airborne captures were visually inspected. + +Powered step75 has currentEuler≈(323.858,293.333,349.214), target(−40,292.917,−25); +step110 has≈(5.430,307.417,342.110), target(10,307.333,−5). Current Euler continues +through its own interpolation/turn phase rather than snapping to the target. +The300-step fixture travels359.19 versus the prior flat-air403.88; maximum rise +418.93, one burst/two landings and VR energy20 are preserved. This is port replay +measurement, not original whole-game trajectory evidence. Native Carl input lock +and control-independent body/fire/resumption also pass. Logs, images and all25 +hashes: artifacts/jimmy-air-bridge/window/. diff --git a/docs/gameplay/jimmy-air-target-state.md b/docs/gameplay/jimmy-air-target-state.md new file mode 100644 index 0000000..7c96ef5 --- /dev/null +++ b/docs/gameplay/jimmy-air-target-state.md @@ -0,0 +1,155 @@ +# Jimmy air targets: owners, initialization and mode transitions + +2026-11-05. Original EXE SHA256 +`f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8`. +This closes the state boundary needed to integrate the +[twelve original air destination writes](jimmy-air-motion.md). It adds static +source/data verification, not another original runtime capture. JN-Engine's +saved original index was a navigation aid; its tuned movement is not used. + +REA's retained complete instruction Evidence is +`ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904`, +artifacts/jimmy-movement-audit/rea-original-disassembly.json. No unchanged failed +Ghidra selector was repeated. Focused extracts and the source report are under +artifacts/jimmy-air-target-state/. Preferred EXE VA maps to file offset VA−400000; +the helper independently uses PE sections and guards every listed anchor. + +## Distinct state owners + +Jimmy's game interface is complete object+C0. These are **data offsets**, not +same-numbered virtual slots: + +| State | Game-interface data / complete data | Owner | +|---|---|---| +|Current Euler|224/228/22C /2E4/2E8/2EC|330→472420 sets XYZ;334→458F90→472480 adds Euler.| +|Destination Euler|274/278/27C /334/338/33C|36C→472660 writes all three axes and sets dirty byte+A.| +|Facing enabled/dirty|5/A /C5/CA|Init enables5, clearsA; source facing reads both; input destination writes setA.| +|Air forward/back pitch seeds|72C/730 /7EC/7F0|Constructor and movement apply callbacks, not input or current support.| +|Other yaw scalar|61C /6DC|Constructor0; Jimmy Init captures current yaw. No other direct access appears in the bounded437290..43B820 controller search.| + +The last scalar is **not** the destination yaw captured by the ground probe. +`jimmy_ground_motion_probe.c` explicitly captures game+278 after its synthetic36C +writer. `JimmyGroundState.TargetYaw` therefore models retained destinationEuler.Y; +ordinary air input replacing that destination Y is expected. There is no evidence +for adding an independently consumed ground-yaw accumulator merely because Init +writes61C. The bounded direct-access search is not a whole-program proof that +61C is globally unused. + +### Input publication + +- Ground43915D..4395CF calls36C only when an accepted active heading path reaches + 43957C,439599 or4395C9 (offset3957C/39599/395C9). It writes `(0,heading,0)`; + accepted Up/Down without a turn uses current yaw. Neutral leaves destination + Euler and dirty state alone. Backward acceptance is resolved before this suffix. +- Ground apply437C40..437F7F has no36C call or direct61C/6DC read. It does not + copy a saved ground yaw into the destination each pass. Its independent334 + yaw addition does not become a destination write. +- Air input439A7A/439A80 clears accepted throttle6E4 and brake6E5, then sets them + in the accepted branches439AF2/439C29. In the bounded zero-mouse/analog case, + Up accepts throttle; Down accepts brake; mode2 additionally accepts primary fire + as throttle. Target publication reads these accepted flags, not speed>0. +- Ordinary target branch439DB7..439E33 (offset39DB7..39E33) chooses forward pitch + seed first, backward seed second, otherwise0; yaw=currentEuler.Y; + roll=−storedTurn. Both arrows select forward pitch even though both affect the + speed arithmetic. Mode2's preceding439CFx..439D7C branch uses roll=−.25*turn + (constant4AFD2C, fileAFD2C), with the same seed selection. +- Shared36C dispatch439E2D→472660 writes targets even when neutral or equal to + current Euler. Its setter stores274/278/27C at472668/472672/472678 and sets + dirty+A=1 at47267E. The existing12 native observations cover ordinary targets; + mode2 roll/first-tick sequencing here is statically recovered. + +## Lifecycle and phase order + +| Event / original VA (file offset) | Result | +|---|---| +|Constructor437445/43744F (37445/3744F)|Complete7EC=−40,7F0=+10.| +|Ordinary apply437FBC/437FC6 (37FBC/37FC6)|Reassert complete7EC=−40,7F0=+10 before composing ordinary air velocity.| +|Bubble apply43880A/438814 (3880A/38814)|Reassert complete7EC=−10,7F0=+10 before Bubble velocity/bounce.| +|Bubble cleanup428037..4280CC (28037..280CC)|If owned effect exists, mode7C4=0, maximum650, radius60/factor1.265 and effect/sound cleanup. No pitch-seed or destination-Euler reset appears in this resolved branch.| +|Generic Init4709CA/9D0/9D6 (709CA/709D0/709D6)|Clear destination XYZ.4709E2 enables facing5;4709E6 clears dirtyA. This is not a current-Euler zeroing policy.| +|Jimmy Init437890..4378CC (37890..378CC)|Calls4587F0→470540, clears speed/turn/published scalar, copies current yaw to61C. It does not re-seed7EC/7F0.| +|PostLoad4239E6 (239E6)|Copy the selected STRT's full authored rotation through174→4716D0. That setter copies authoredFC/100/104 and calls330→472420 to publish currentXYZ. Target Euler/dirty are not modified by this leaf chain.| +|Control preparation42AFC0→43A750|Clears speed/body XYZ velocity and stops sound, then requests STOP. It is not a destination/facing reset or evidence that all current Euler axes become0.| + +Route property extraction does not reconstruct the object or re-run its +constructor: see [retained property stream](../checkpoint/retained-streamer.md). +Its verified20 descriptors do not point at game72C/730. The closed generic Init, +PostLoad and no-selected-gadget/jetpack cleanup route therefore retain these +pitch seeds while resetting destination Euler/dirty independently. This is the +bounded LV1B→VR04→LV1B→LEV1 contract, not arbitrary selected gadget/level cleanup. +Original save files do not gain these process fields; current R reset remains +an explicit modern debug policy and can restore constructor seeds. + +The existing original registry/partial-order findings imply these concrete +transition cases; the joint sequence has not been newly executed here: + +1. First Bubble activation on a fresh input-before-player tick may read the prior + −40 seed. Its later Bubble apply publishes−10, so subsequent Bubble input reads + −10. Retained player-before-input order seeds−10 before that first input. +2. Bubble cleanup leaves−10. Ground mode itself does not re-seed it. A subsequent + input already dispatched in ordinary air mode may read−10 until ordinary air + apply reasserts−40. Do not choose pitch solely from the current mode at input. +3. During a retained ordinary scene load, preserve the seed fields but initialize + targetEuler=(0,0,0), enabled=true, dirty=false. Reapply authored/current Euler + and subsequent destination writes through their own owners. + +## Facing and control + +43796A calls40E050→462520→473240 before the raw controlled-pointer check at +437A1B.47328D dispatches3D8→43A420. Facing itself checks global475CA0, game byte5 +enabled and byteA dirty at43A426/43A433/43A43E; it does not query raw control. +475CA0's global pause/gameplay policy is not the controlled-player identity. + +After accepting the gates,43A44F clearsA, then each unequal **before-step** +current/target component setsA again. Its comparisons are direct float equality, +before shortest-arc conversion/interpolation. It then calls334 even if all axes +were equal. A caller reproducing state needs to set `dirty = oldEuler != target` +when the facing callback actually runs; testing equality only after interpolation +can change that final pass. If a gate rejects the callback, dirty survives. +Canonical360 vs0 may remain unequal even when their angular delta is0. Direct +330 current-Euler writes do not synthesize dirty state or replace destinations. + +## Initial current Euler is data, not target defaults + +The source PostLoad copies full STRT XYZ. Default route GAM data nevertheless +supports keeping the present upright baseline: + +| Original GAM / selected default STRT | Authored/current rotation after the resolved setter | +|---|---| +|level1b.gam /STARTEXP|(0,155,0)| +|VR04.gam /PHONEBOOTH|(0,290,0)| +|level1.gam /PHONEBOOTH|(0,220,0)| + +The read-only helper records each GAM SHA256 and JIM1/STRT record offsets. +Arbitrary `--start` selections or authored script rotation with nonzero X/Z need +fullXYZ current publication; no source flattening is inferred from targetInit0. +RETURN restores a separate saved root, not a saved rotation; the selected STRT +rotation and its callback chain still apply. Other body/model animation offsets +belong to the render-transform investigation, not this Euler state report. + +## Implementation contract and verification + +Parent owns live implementation. Retain forward/back pitch seeds as fields, +seed them in apply callbacks, and read them at input time. Store current Euler, +destination Euler and facing enabled/dirty independently. Ground helpers' existing +destinationY state can remain a view of destinationEuler.Y; no extra6DC owner is +needed by proven ground math. Preserve source phase order, support/input gates, +and the explicit modern reset boundary. Full actor-root/model placement must be +handled by the sibling render bridge before enabling ordinary pitch visually. + +`tools/binary/jimmy_air_target_state.py` guards32 source anchors,9 virtual targets, +11 bounded instruction ranges, the registered route descriptor boundary and +selected STRT data. Optional `--rea-disassembly` validates retained REA identity +and emits the bounded61C/6DC access and ground-apply call lists. Three Python +groups pass with exact source/offset/binding, separate target/current/default +route data and apply-owned seed checks. Run: + +``` +python3 -m unittest discover -s tests -p test_jimmy_air_target_state.py -v +python3 tools/binary/jimmy_air_target_state.py ../Original --rea-disassembly artifacts/jimmy-movement-audit/rea-original-disassembly.json +``` + +Confidence is high for the guarded local contracts and route data. Full original +frame execution, unsupported modes/gadgets, other selected starts/levels, original +cadence, complete animation-root rendering and native Windows comparison remain +separate. No shared runtime or existing evidence fixture was changed here. diff --git a/docs/gameplay/jimmy-movement-stabilization.md b/docs/gameplay/jimmy-movement-stabilization.md index a29a377..f56cf4b 100644 --- a/docs/gameplay/jimmy-movement-stabilization.md +++ b/docs/gameplay/jimmy-movement-stabilization.md @@ -68,10 +68,11 @@ not an original-body result or a replacement friction/step tuning fix. ### Next coherent implementation chunks -1. Implement source destination-Euler pitch/roll with retained7EC/7F0, the full - actor-root visual bridge and mode/registration order together. Verify ordinary - jump, powered turning, Bubble cleanup, landing and RETURN. Baseline ordinary - air currently stays visually upright; the recovered−40/+10 targets are not live. +1. **Implemented bounded bridge:** source destination-Euler pitch/roll, retained + apply-owned7EC/7F0, Init/dirty, full authored XYZ and logical-root render basis. + [Air bridge](jimmy-air-bridge.md) records integration and subsequent validation. + The modern local sole correction and final OMT decomposition precision remain + explicit limitations; this does not close full original visual parity. 2. Finish Vec4 previous/live-root publication after callbacks; separate body integration210 from world-response1D0. Verify successful fence/ladder entry, animation-end/fallback completion and4255C0 hazard/impulse ownership before diff --git a/docs/gameplay/jimmy-render-transform.md b/docs/gameplay/jimmy-render-transform.md new file mode 100644 index 0000000..e4e5fb3 --- /dev/null +++ b/docs/gameplay/jimmy-render-transform.md @@ -0,0 +1,114 @@ +# Jimmy logical/render Euler and compatible pivot bridge + +2026-11-05. This investigates the original transform before enabling ordinary +up/down airborne tilt. The existing playable movement and upright placement are +the baseline. JN-Engine original class/decompiler notes supplied navigation leads; +its tuned movement and renderer are not copied as behavior references. + +## Original facts and state ownership + +Authoritative identities are EXE +`f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8` +and OMT2.dll +`3ec41ead011adf56387a6dbd4580e5b5a9721b5f8020c8a56420f42824354943`. +`tools/binary/jimmy_model_bridge.py` guards their ranges, five Jimmy bindings and +both double angle constants. File offsets below are independently PE-mapped. + +| VA / file offset | Recovered contract | +|---|---| +|EXE4624B0 /624B0|Jimmy game-interface3DC asks310→472300 for the current logical/body Vec4; copies XYZ to complete44/48/4C without scale or floor/sole subtraction.| +|EXE4624F0 /624F0|Angle publication hook3E0 jumps to473540.| +|EXE473540 /73540|Reads current degree Euler through328→4723F0; each axis is remainder360, multiplied by **double**45.51111111111111 at4D6408 and truncated through47F940, then masked16383. Double360 is4D6410.| +|EXE462500 /62500|Game3E4 stores the three resulting shorts at interface−70/−6E/−6C = complete50/52/54. Position and cached render angles are distinct records.| +|DLL1003FA60 /3FA60|OMediaElement::compute_hxform copies the parent hierarchy; obtains current animation dynamic offset from virtual7C and adds complete44/48/4C. With identity parent, resulting translation is exactly root+dynamic offset. Rotation does not rotate that root.| +|DLL1003FB26..1003FBE3 /3FB26..3FBE3|Reads cached angle shorts52/50/54 with negative signs and rotates the hierarchical basis. Row-vector form is Rz(−roll)·Rx(−pitch)·Ry(−yaw), with unit scale in the probed path.| +|DLL1003FC00 /3FC00|compute_model_matrix consumes the hierarchy and decomposes/re-quantizes its rotation through original angle lookup before publishing the final4×4. This additional precision behavior is distinct from the hierarchical basis.| + +473540 does **not** duplicate Y into X: the0C stack load at473586 reads Y, then +pushZ at473595 shifts the stack. The0C load at4735A6 consequently reads original +X. Native asymmetric(-40,45,-15)→(14564,2048,15702) confirms independent axes. +The double render conversion is kept separate from physics472B10's float +45.5111122 factor. Render caching is not permission to mutate current degree +Euler or its destination state. Their phase/state owners remain in LabSimulation. + +The position bridge has no hardcoded radius75.9, standing-minimum offset or scale. +Prior mode2 DLL import probes establish original jimstop geometry and zero dynamic +frame offsets for the tested clips; see [original collision](../analysis/original-collision.md). +That does not certify every clip, shape mutation, hierarchy or transform flag. +There is no newly recovered original correction for the port's sole alignment. + +## REA and native evidence + +The retained EXE instruction Evidence is +`ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904` +in artifacts/jimmy-movement-audit/rea-original-disassembly.json. The DLL REA +inspect-with-objdump Evidence is +`ev_af082632c98b34ccfcedef01466cafa03365e7fbf482496d01a4cda6d2f8f787`, +retained in artifacts/jimmy-model-bridge/rea-dll-disassembly.json. Its16MiB output +cap was reached, so it is a **bounded prefix**, completion unknown, not complete +DLL analysis. All transform ranges used here are present and separately guarded +against original bytes. An initial REA target-path error was corrected by making +a separate generated DLL copy; no missing-target result is cited as analysis. + +The OMT probe calls exported compute_hxform and compute_model_matrix against a +synthetic element, identity parent and zero dynamic-offset callback. Fourteen +cases include upright, individual90° axes, full combined axes, ordinary forward/ +backward air tilts, negative units,16383/16384 seams, halfturn, tiny angles and +two roots with the same rotation. No game/renderer entrypoint, GPU, body, +animation or audio runs. The original DLL is loaded only from an isolated copy. + +The angle probe executes copied473540, original4723F0 getter and462500 setter +with synthetic actor fields. It bypasses CRT exception dispatch at4802CA into +its original finite x87 remainder primitive4802D4;47F940 truncation is original. +Twelve finite cases cover independent axes, negative/fractional degrees, multiple +revolutions, exact angle units, canonical360 and tiny seams. This does not verify +CRT exceptions, nonfinite inputs or the whole object scheduler. + +Both isolated Wine32 runs exit0 with their success markers. First-time Wine prefix +creation exceeded the initial capture window; reuse of an already completed local +analysis prefix resolved setup. Successful model and angle logs/capture metadata +are retained separately under artifacts/jimmy-model-bridge. Fixture +`tests/GamePort.JimmyRenderTests/original-render-reference.json` commits all40 +observations (14 hierarchy +14 final render matrices +12 angle writes), source +ranges/constants/bindings and generator/probe-EXE/output hashes. + +## Implemented helper and explicit modern policy + +`JimmyRenderTransform.AngleUnits` follows the recovered finite degree conversion. +`Source(root,euler)` uses those units and the original hierarchical axis order; +its translation is the unrotated root. `Aligned(root,euler,localYCorrection)` +pre-translates local vertices before that source rotation/root transform. +The helpers are pure and reject nonfinite inputs; no broader renderer or asset +rewriting is introduced. + +For baseline upright placement, the caller may retain the fixed modern correction +`c = -modelMinimumY - rootHeight`, then use +`Translate(0,c,0) * Source(ActorRoot,Euler)`. For the standing mesh, minimumY is +approximately−64.6165 and the existing logical clearance is75.9, givingc≈−11.2835. +This preserves the upright sole location while combined pitch/roll rotate around +the logical root. The local point(0,−c,0) stays at ActorRoot under every rotation. +It is a **modern compatibility adapter**, not a recovered original pivot offset, +scale or new body clearance. It must not change collision/body support geometry. +The old world-space sole correction is not evidence for the source transform. + +## Tests and remaining gates + +The managed suite compares all12 original degree writes and14 hierarchical +transforms (basis tolerance1e−6), unit-scale determinant, unrotated translation, +modern upright/combined-tilt pivot invariants and nonfinite rejection. Two Python +groups verify source ranges/constants/bindings and complete native fixture/ +provenance. Commands from GamePort: + +``` +dotnet run --project tests/GamePort.JimmyRenderTests +python3 -m unittest discover -s tests -p test_jimmy_model_bridge.py +``` + +Both pass. Final OMT model-matrix parity is deliberately **not** claimed. Its +approximate angle decomposition produces up to0.007286333 matrix-coefficient +deviation in the14 saved cases, largest at the16383-unit near-zero seam; ordinary +combined air tilt differs by roughly0.0002..0.0003. The test records that mismatch +instead of treating the final matrices as conforming. Exact decomposition/lookup, +all render flags/parents/dynamic offsets, complete source pivot/clip ownership and +whole-original/native Windows visual comparison remain separate gates. Runtime +integration/route/native checks are owned by the parent movement continuation. diff --git a/docs/progress.md b/docs/progress.md index 4a6ec88..bf35842 100644 --- a/docs/progress.md +++ b/docs/progress.md @@ -1,5 +1,31 @@ # Progress — 2026-11-05 +## Jimmy airborne target and render bridge + +Ordinary jump/jetpack now reads source forward/backward pitch and turn lean, with +apply-owned seeds preserved through Bubble transitions and bounded route loads. +Destination Euler/dirty, current full STRT/authored Euler and Init are separate. +Full Euler is published to the director and character model; the old Bubble-only +orientation path is removed. Source degree caching/hierarchical rotation now +pivots around the logical root. The upright sole alignment is retained as an +explicit modern local correction; final OMT decomposition precision remains open. + +146 original observations compare with managed components: prior108,12 ordinary +air targets,12 render angle writes and14 hierarchical matrices.14 additional final +render matrices document a precision mismatch rather than conformance.28 movement, +20 body and13 Grappler groups pass; lab/two-way underground routes pass. Native +Linux1920×1080 walking/jetpack replays pass all five jump bindings;25 final/airborne +readbacks match across bindings. Carl/control phases pass, zero validation errors. +The existing powered replay now travels359.19 instead of403.88 with source pitch +attenuation; rise418.93 and source impulse/gravity remain unchanged. First forward, +brake and ordinary jump captures were visually inspected. + +Evidence/integration: [air bridge](gameplay/jimmy-air-bridge.md), +[target state](gameplay/jimmy-air-target-state.md), +[render transform](gameplay/jimmy-render-transform.md). Both investigators returned +ownership. Remaining priority is root-changing/special/dynamic contact state +before replacing the lab/outside capsule; no gadget expansion. + ## Jimmy controller conformance checkpoint User pauses gadget expansion and prioritizes Jimmy movement, preserving our diff --git a/docs/reverse-engineering.md b/docs/reverse-engineering.md index 801c664..8ec025b 100644 --- a/docs/reverse-engineering.md +++ b/docs/reverse-engineering.md @@ -5,6 +5,12 @@ offsets, virtual addresses, API symbols or observed behavior. Decompiled output evidence, not original source. Original gameplay has not yet been observed successfully; isolated original DLL probes and modern runtime checks are recorded separately. +- [Jimmy air target state](gameplay/jimmy-air-target-state.md) and + [render transform](gameplay/jimmy-render-transform.md): apply-owned pitch seeds, + full STRT/current Euler, destination/dirty Init, degree-to-short caching and + original hierarchical basis.26 additional native comparisons plus14 final render + matrices (documented precision mismatch). [Integration](gameplay/jimmy-air-bridge.md) + keeps the local sole correction modern and broader body admission separate. - [Jimmy movement stabilization](gameplay/jimmy-movement-stabilization.md): current priority, preserving our playable controller over JN's tuned replacement. Ground/air/facing/jump reports record108 native component observations matched diff --git a/docs/tasks.md b/docs/tasks.md index 83d099e..0f65e2b 100644 --- a/docs/tasks.md +++ b/docs/tasks.md @@ -55,9 +55,11 @@ compile, runtime and original-fidelity verification are separate. shared keyboard latch, control-independent full-axis facing, exact jump hold and gravity intermediates.108 saved original component observations match managed checks. Capsule compatibility remains explicit; broad collision is not complete. -- [ ] Next Jimmy chunk: source ordinary-air destination pitch/roll and retained - mode fields together with the actor-root visual bridge.12 original target writes - are recorded; do not silently enable physics tilt without matching presentation. +- [x] Jimmy ordinary-air destination pitch/roll, retained apply-owned pitch seeds, + destination/dirty Init, full authored Euler and logical-root rendering bridge. + 12 target writes plus12 degree/14 hierarchical transforms compare against + managed components. Sole alignment remains modern; final OMT decomposition + precision is separate. See gameplay/jimmy-air-bridge.md. - [ ] Then verify root-changing contact publication, world-response/integration flags, successful fence/ladder completion, hazard/impulse and dynamic eligibility before replacing the lab/outside capsule.27 dispatch cases establish eligibility diff --git a/scripts/test.sh b/scripts/test.sh index d296b49..d447bf3 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -9,6 +9,7 @@ dotnet run --project tests/GamePort.MovementTests -- ../Original dotnet run --project tests/GamePort.JimmyGroundTests dotnet run --project tests/GamePort.JimmyAirTests dotnet run --project tests/GamePort.JimmyOrientationTests +dotnet run --project tests/GamePort.JimmyRenderTests dotnet run --project tests/GamePort.JimmyJumpTests dotnet run --project tests/GamePort.DirectorTests -- ../Original dotnet run --project tests/GamePort.PatrolTests -- ../Original diff --git a/src/GamePort/Game/BubbleMotion.cs b/src/GamePort/Game/BubbleMotion.cs index 6cc8e5c..cc9eea8 100644 --- a/src/GamePort/Game/BubbleMotion.cs +++ b/src/GamePort/Game/BubbleMotion.cs @@ -18,10 +18,11 @@ public static class BubbleMotion public const float HeldBounceSpeed = 900; public static BubbleSteering StepInput(float speed, float turn, PlayerInput input, - bool supported, float seconds, float maximumSpeed = MaximumSpeed) + bool supported, float seconds, float maximumSpeed = MaximumSpeed, + float forwardPitch=-10,float backwardPitch=10) { Validate(speed, turn, seconds); - if (!float.IsFinite(maximumSpeed) || maximumSpeed <= 0) + if (!float.IsFinite(maximumSpeed) || maximumSpeed <= 0||!float.IsFinite(forwardPitch)||!float.IsFinite(backwardPitch)) throw new ArgumentOutOfRangeException(nameof(maximumSpeed)); var turnStep = AirSteering.TurnAcceleration * seconds; @@ -48,7 +49,7 @@ public static class BubbleMotion } turn = Math.Clamp(turn, -TurnLimit, TurnLimit); - return new(speed, turn, forward ? -10 : input.Backward ? 10 : 0, -.25f * turn); + return new(speed, turn, forward ? forwardPitch : input.Backward ? backwardPitch : 0, -.25f * turn); } public static BubbleApply StepApply(float speed, float turn, float yaw, float pitch, diff --git a/src/GamePort/Game/JimmyAirMotion.cs b/src/GamePort/Game/JimmyAirMotion.cs index 69bd2a5..b40695f 100644 --- a/src/GamePort/Game/JimmyAirMotion.cs +++ b/src/GamePort/Game/JimmyAirMotion.cs @@ -9,6 +9,19 @@ public readonly record struct JimmyAirApply(Vector3 Velocity,Vector3 Rotation,fl /// caller phases. Source constraints and observations: jimmy-air-motion.md. public static class JimmyAirMotion { + public const float ForwardPitch = -40; + public const float BackwardPitch = 10; + + /// 439DB7..439E33 target write. Pitch seeds belong to the preceding + /// apply/constructor phase, not the currently dispatched input mode. + public static Vector3 Destination(PlayerInput input,float yaw,float turn, + float forwardPitch=ForwardPitch,float backwardPitch=BackwardPitch) + { + if(!float.IsFinite(yaw)||!float.IsFinite(turn)||!float.IsFinite(forwardPitch)||!float.IsFinite(backwardPitch)) + throw new ArgumentOutOfRangeException(nameof(yaw)); + return new(input.Forward?forwardPitch:input.Backward?backwardPitch:0,yaw,-turn); + } + public static JimmyAirInputState Input(JimmyAirInputState state,PlayerInput input,bool supported, float seconds,float maximumSpeed=600) { diff --git a/src/GamePort/Game/JimmyRenderTransform.cs b/src/GamePort/Game/JimmyRenderTransform.cs new file mode 100644 index 0000000..30f79b6 --- /dev/null +++ b/src/GamePort/Game/JimmyRenderTransform.cs @@ -0,0 +1,46 @@ +using System.Numerics; + +namespace GamePort.Game; + +/// 473540 degree-to-OMT cache and1003FA60 unit-scale local transform. +/// Source root is unrotated. OMT1003FC00 subsequently decomposes/re-quantizes its +/// render matrix; this helper uses its directly recovered hierarchical basis. +/// See docs/gameplay/jimmy-render-transform.md for native evidence/limits. +public static class JimmyRenderTransform +{ + public static int AngleUnits(float degrees) + { + if (!float.IsFinite(degrees)) throw new ArgumentOutOfRangeException(nameof(degrees)); + return (int)Math.Truncate(((double)degrees % 360) * 45.51111111111111) & 16383; + } + + public static Matrix4x4 Source(Vector3 root, Vector3 euler) + { + Finite(root); + var (sx,cx) = RocketOrientation.Units(AngleUnits(euler.X)); + var (sy,cy) = RocketOrientation.Units(AngleUnits(euler.Y)); + var (sz,cz) = RocketOrientation.Units(AngleUnits(euler.Z)); + //Row-vector convention: Rz(-roll), then Rx(-pitch), then Ry(-yaw). + //The translation is the unchanged actor root, independent of all axes. + return new( + (float)((double)cz*cy-(double)sz*sx*sy), -sz*cx, (float)((double)cz*sy+(double)sz*sx*cy), 0, + (float)((double)sz*cy+(double)cz*sx*sy), cz*cx, (float)((double)sz*sy-(double)cz*sx*cy), 0, + -cx*sy, sx, cx*cy, 0, + root.X, root.Y, root.Z, 1); + } + + /// Modern compatibility adapter, not an original recovered offset. + /// A fixed sole-derived correction is local to the model, so full-axis tilt + /// remains around the source logical root and upright placement is preserved. + public static Matrix4x4 Aligned(Vector3 root, Vector3 euler, float localYCorrection) + { + if (!float.IsFinite(localYCorrection)) throw new ArgumentOutOfRangeException(nameof(localYCorrection)); + return Matrix4x4.CreateTranslation(0,localYCorrection,0) * Source(root,euler); + } + + private static void Finite(Vector3 value) + { + if (!float.IsFinite(value.X) || !float.IsFinite(value.Y) || !float.IsFinite(value.Z)) + throw new ArgumentOutOfRangeException(nameof(value)); + } +} diff --git a/src/GamePort/Game/LabSimulation.cs b/src/GamePort/Game/LabSimulation.cs index 116bc4b..e9ddd60 100644 --- a/src/GamePort/Game/LabSimulation.cs +++ b/src/GamePort/Game/LabSimulation.cs @@ -21,10 +21,12 @@ public sealed class LabSimulation private readonly Func? ceilingRay; private readonly OriginalBodyPhysics? originalBody; private readonly PlayerEnergy energy; - private readonly Vector3 sourceStart; - private readonly float startYaw, modelMinimumY, rootHeight, startFloor; + private readonly Vector3 sourceStart, sourceRotation; + private readonly float modelMinimumY, rootHeight, startFloor; private float targetYaw, extraAirAcceleration, shadowDistance, lateralContribution; private float targetPitch, targetRoll; + private float forwardAirPitch, backwardAirPitch; + private bool facingDirty; private int? retainedSupportMaterial; private bool bubbleLoop; private PlayerPose bubblePose; @@ -53,7 +55,11 @@ public sealed class LabSimulation public float MaximumSpeed { get; private set; } = RecoveredMotion.MaximumSpeed; public float Pitch { get; private set; } public float Roll { get; private set; } - public bool TracksBubbleOrientation { get; private set; } + public Vector3 Rotation => new(Pitch,Yaw,Roll); + public Vector3 FacingTarget => new(targetPitch,targetYaw,targetRoll); + public bool FacingDirty => facingDirty; + public float ForwardAirPitch => forwardAirPitch; + public float BackwardAirPitch => backwardAirPitch; public int BubbleBounces { get; private set; } public int GadgetMode { @@ -71,7 +77,6 @@ public sealed class LabSimulation if (Energy <= 0 && !IgnoresGadgetEnergy || Bubble.Active || Bubble.Expanding || Bubble.Collapsing) return; InteractionRadius=160; BodyFactor=.415f; movementMode=2; MaximumSpeed=1350; bubblePose=previousPose; - TracksBubbleOrientation=true; gadgetMode=0; Bubble.Start(); if (!bubbleLoop) { GadgetSound?.Invoke(2,true); bubbleLoop=true; } return; @@ -139,15 +144,23 @@ public sealed class LabSimulation public Vector3 ActorRoot => Position + Vector3.UnitY * rootHeight; public Vector3 CameraEye { get; private set; } public Vector3 CameraTarget => grapplerCameraTarget??ActorRoot + new Vector3(0, 80 + 1.9f * Baseball.CameraPitch, 0); - public Matrix4x4 Model => Matrix4x4.CreateRotationZ(-(TracksBubbleOrientation?Roll:0) * MathF.PI / 180) - * Matrix4x4.CreateRotationX(-(TracksBubbleOrientation?Pitch:0) * MathF.PI / 180) * Matrix4x4.CreateRotationY(-Yaw * MathF.PI / 180) - * Matrix4x4.CreateTranslation(Position - new Vector3(0, modelMinimumY, 0)); + //Preserve upright sole placement as a modern local correction, while the + //recovered full-axis rotation and unrotated translation use the actor root. + public Matrix4x4 Model => JimmyRenderTransform.Aligned(ActorRoot,Rotation,-modelMinimumY-rootHeight); public LabSimulation(SceneCollision collision, Mesh standingPose, Vector3 start, float yaw, Func? cameraRay = null, Func? ceilingRay = null, OriginalStaticCollision? originalCollision = null, PlayerEnergy? energy = null) + : this(collision,standingPose,start,new Vector3(0,yaw,0),cameraRay,ceilingRay,originalCollision,energy) { } + + public LabSimulation(SceneCollision collision, Mesh standingPose, Vector3 start, Vector3 rotation, + Func? cameraRay = null, + Func? ceilingRay = null, + OriginalStaticCollision? originalCollision = null, PlayerEnergy? energy = null) { + if(!float.IsFinite(rotation.X)||!float.IsFinite(rotation.Y)||!float.IsFinite(rotation.Z)) + throw new ArgumentOutOfRangeException(nameof(rotation)); this.collision = collision; this.cameraRay = cameraRay; this.ceilingRay = ceilingRay; @@ -157,7 +170,7 @@ public sealed class LabSimulation Invisible.BlendRequested += Appearance.SetBlend; Baseball.Thrown += () => GadgetSound?.Invoke(10,false); sourceStart = start; - startYaw = yaw; + sourceRotation = rotation; var bounds = standingPose.Bounds(); modelMinimumY = bounds.Min.Y; BodyHeight = bounds.Max.Y - bounds.Min.Y; @@ -181,13 +194,14 @@ public sealed class LabSimulation Baseball.Reset(); if (gadgetMode == 6) gadgetMode = -1; Bubble.Reset(); FloorState.Reset(); Appearance.Reset(); retainedSupportMaterial=null; - Pitch=Roll=targetPitch=targetRoll=0; BubbleBounces=0; - TracksBubbleOrientation=false; + Pitch=sourceRotation.X;Roll=sourceRotation.Z; + targetPitch=targetYaw=targetRoll=0;facingDirty=false;BubbleBounces=0; + forwardAirPitch=JimmyAirMotion.ForwardPitch;backwardAirPitch=JimmyAirMotion.BackwardPitch; MaximumSpeed=RecoveredMotion.MaximumSpeed; BodyFactor=OriginalBodySupport.JimmyFactor; var floor = collision.GroundHeight(sourceStart, 2500)!.Value; Position = new(sourceStart.X, floor + (UsesOriginalBody ? 0 : SceneCollision.Skin), sourceStart.Z); Velocity = Vector3.Zero; - Yaw = targetYaw = startYaw; + Yaw = sourceRotation.Y; Speed = PublishedSpeed = TurnRate = extraAirAcceleration = shadowDistance = 0; lateralContribution = 0; pendingImpulse = Vector3.Zero; movementMode = 0; keyboardTurn=false;hasSupportPolygon=false; @@ -214,7 +228,8 @@ public sealed class LabSimulation } public PlayerLevelState? CaptureLevelState(int selectedGadget) => Noclip ? null - : new(LevelCode, selectedGadget, movementMode, jumpState.HoldSeconds, jumpState.EffectRemaining); + : new(LevelCode, selectedGadget, movementMode, jumpState.HoldSeconds, jumpState.EffectRemaining, + forwardAirPitch,backwardAirPitch); /// Apply after destination construction. Init re-applies authored /// body vectors and clears speed/turn; PostLoad resets jump, not these scalars. @@ -224,10 +239,12 @@ public sealed class LabSimulation ArgumentNullException.ThrowIfNull(state); if (!state.SupportsDestination(LevelCode)) return false; if (state.MovementMode is < 0 or > 1 || !float.IsFinite(state.HoldSeconds) - || state.HoldSeconds < 0 || !float.IsFinite(state.EffectRemaining)) + || state.HoldSeconds < 0 || !float.IsFinite(state.EffectRemaining) + || !float.IsFinite(state.ForwardPitch)||!float.IsFinite(state.BackwardPitch)) throw new ArgumentOutOfRangeException(nameof(state)); movementMode = state.MovementMode; jumpState = new(0, state.HoldSeconds, state.EffectRemaining); + forwardAirPitch=state.ForwardPitch;backwardAirPitch=state.BackwardPitch; return true; } @@ -295,10 +312,9 @@ public sealed class LabSimulation public void EnterScooter() { CancelPoweredFlight(); //425120 only cancels mode1 jump/effect. - TracksBubbleOrientation=true; } public void ApplyScooterTransform(Vector3 root,Vector3 rotation) - {ApplyAuthoredTransform(root,rotation.Y);Pitch=rotation.X;Roll=rotation.Z;targetPitch=Pitch;targetRoll=Roll;targetYaw=Yaw;} + {ApplyAuthoredTransform(root,rotation);SetFacingDestination(rotation);} public void LeaveScooter(Vector3 root,Vector3 rotation,Vector3 eye) { ApplyScooterTransform(root+Vector3.UnitY*40,rotation); @@ -342,11 +358,6 @@ public sealed class LabSimulation } public void FlattenOrientation() { Pitch=Roll=0; } - public void SeedBubbleTilt(Vector3 euler) - { - if (TracksBubbleOrientation) return; - Pitch=targetPitch=euler.X; Roll=targetRoll=euler.Z; - } private void StepFloorPolicy() { @@ -384,6 +395,13 @@ public sealed class LabSimulation Position = root - Vector3.UnitY * rootHeight; Yaw = yaw; } + public void ApplyAuthoredTransform(Vector3 root,Vector3 rotation) + { + if(!float.IsFinite(rotation.X)||!float.IsFinite(rotation.Y)||!float.IsFinite(rotation.Z)) + throw new ArgumentOutOfRangeException(nameof(rotation)); + ApplyAuthoredTransform(root,rotation.Y);Pitch=rotation.X;Roll=rotation.Z; + } + /// Modern debug movement; never serialized into original save state. public bool SetNoclip(bool enabled) { @@ -410,7 +428,9 @@ public sealed class LabSimulation Velocity = pendingImpulse = Vector3.Zero; Speed = PublishedSpeed = TurnRate = extraAirAcceleration = lateralContribution = 0; jumpState = default; movementMode = 0; forceFall = JetpackEffectVisible = false; - targetYaw = Yaw; + //Modern debug stop freezes the retained facing request as well as body + //motion. Otherwise entering noclip can leave a queued airborne lean. + targetPitch=Pitch;targetYaw=Yaw;targetRoll=Roll;facingDirty=false; } public bool ReturnToNoclipEntry() @@ -451,26 +471,25 @@ public sealed class LabSimulation //does not invent a hold timer or admit its seeded auto-turn branch. var ground=JimmyGroundMotion.Input(new(Speed,targetYaw),Yaw,input,MaximumSpeed, blockBackward:(GadgetMode is -1 or 3)&&input.Fire); - Speed=ground.State.Speed;targetYaw=ground.State.TargetYaw;lateralContribution=ground.Lateral; + Speed=ground.State.Speed;lateralContribution=ground.Lateral; if(input.Left||input.Right)keyboardTurn=true; - if(ground.HeadingUpdated)targetPitch=targetRoll=0; + if(ground.HeadingUpdated)SetFacingDestination(new(0,ground.State.TargetYaw,0)); } else if (movementMode==2) { - var steering=BubbleMotion.StepInput(Speed,TurnRate,input,Grounded,dt,MaximumSpeed); + var steering=BubbleMotion.StepInput(Speed,TurnRate,input,Grounded,dt,MaximumSpeed,forwardAirPitch,backwardAirPitch); Speed=steering.Speed; TurnRate=steering.TurnRate; if(input.Left||input.Right)keyboardTurn=true; - targetPitch=steering.TargetPitch; targetRoll=steering.TargetRoll; targetYaw=Yaw; + SetFacingDestination(new(steering.TargetPitch,Yaw,steering.TargetRoll)); } else { var steering = JimmyAirMotion.Input(new(Speed,TurnRate,keyboardTurn),input,Grounded,dt,MaximumSpeed); Speed = steering.Speed; TurnRate = steering.TurnRate; keyboardTurn=steering.KeyboardTurn; - if (TracksBubbleOrientation) { targetPitch=0; targetRoll=-TurnRate; } //439E2B preserves current yaw as the destination; air apply then //438011..43802B adds the independent turn rate directly to yaw. - targetYaw = Yaw; + SetFacingDestination(JimmyAirMotion.Destination(input,Yaw,TurnRate,forwardAirPitch,backwardAirPitch)); } Baseball.StepCameraInput(input); StepCamera(); //438BC0/439900 input path owns follow; still provisional geometry/state. @@ -497,16 +516,22 @@ public sealed class LabSimulation private void StepFacing() { - var rotation=JimmyOrientation.Step(new(Pitch,Yaw,Roll),new(targetPitch,targetYaw,targetRoll),FixedStepClock.Step); + var before=Rotation; + var rotation=JimmyOrientation.Step(before,FacingTarget,FixedStepClock.Step,dirty:facingDirty); + if(facingDirty)facingDirty=before!=FacingTarget; Pitch=rotation.X;Yaw=rotation.Y;Roll=rotation.Z; } + private void SetFacingDestination(Vector3 target) + {targetPitch=target.X;targetYaw=target.Y;targetRoll=target.Z;facingDirty=true;} + private void StepPlayer(PlayerInput input) { ControllerSteps++; const float dt = FixedStepClock.Step; if (movementMode==2) { + forwardAirPitch=-10;backwardAirPitch=10; //43880A/438814, after input when fresh. var bubble=BubbleMotion.StepApply(Speed,TurnRate,Yaw,Pitch,Velocity,Grounded,input.Jump,dt); Velocity=bubble.Velocity; Yaw=bubble.Yaw; Speed=bubble.Speed; PublishedSpeed=Speed; if (Grounded) { BubbleBounces++; if (bubble.Boing) GadgetSound?.Invoke(106,false); } @@ -528,6 +553,7 @@ public sealed class LabSimulation } else { + forwardAirPitch=JimmyAirMotion.ForwardPitch;backwardAirPitch=JimmyAirMotion.BackwardPitch; var airMotion=JimmyAirMotion.Apply(Speed,TurnRate,new(Pitch,Yaw,Roll),Velocity,dt); velocity=airMotion.Velocity;Pitch=airMotion.Rotation.X;Yaw=airMotion.Rotation.Y;Roll=airMotion.Rotation.Z; } diff --git a/src/GamePort/Game/PlayerLevelState.cs b/src/GamePort/Game/PlayerLevelState.cs index 8a8532e..1986105 100644 --- a/src/GamePort/Game/PlayerLevelState.cs +++ b/src/GamePort/Game/PlayerLevelState.cs @@ -6,7 +6,8 @@ namespace GamePort.Game; /// Other gadget cleanup branches/levels need their own lifecycle proof. /// public sealed record PlayerLevelState(string SourceLevel, int SelectedGadget, - int MovementMode, float HoldSeconds, float EffectRemaining) + int MovementMode, float HoldSeconds, float EffectRemaining, + float ForwardPitch=JimmyAirMotion.ForwardPitch,float BackwardPitch=JimmyAirMotion.BackwardPitch) { public bool SupportsDestination(string level) => IsRoute(SourceLevel) && IsRoute(level) && SelectedGadget is -1 or 3; diff --git a/src/GamePort/Game/PlayerSceneBinding.cs b/src/GamePort/Game/PlayerSceneBinding.cs index 3592281..12c7925 100644 --- a/src/GamePort/Game/PlayerSceneBinding.cs +++ b/src/GamePort/Game/PlayerSceneBinding.cs @@ -65,14 +65,12 @@ public sealed class PlayerSceneBinding : IDisposable if(Rocketship is{Mounted:true} rocket) { //43DF70 copies passenger transforms and reasserts ship ownership. - player.ApplyAuthoredTransform(rocket.Root,rocket.Rotation.Y); + player.ApplyAuthoredTransform(rocket.Root,rocket.Rotation); director.TransferControl(rocket.Actor); if(player.InputAfterPlayerUpdate&&VehicleControl())rocket.StepInput(input,FixedStepClock.Step); } if (player.GadgetMode==0 && player.Grounded && director.FindActor(tag) is{} actor) actor.Animation="STOP"; - var rotation=director.FindActor(tag)?.Rotation ?? Vector3.Zero; - director.SyncActor(tag,player.ActorRoot,Rocketship is{Mounted:true} vehicle?vehicle.Rotation:player.TracksBubbleOrientation - ? new(player.Pitch,player.Yaw,player.Roll) : rotation with{Y=player.Yaw}); + director.SyncActor(tag,player.ActorRoot,player.Rotation); return acceptsInput; } @@ -115,7 +113,6 @@ public sealed class PlayerSceneBinding : IDisposable player.LeaveRocketship(Rocketship.CameraEye); if(director.FindActor(tag) is{} rider){rider.Animation="FALL";director.TransferControl(rider);} } - if (item==0 && director.FindActor(tag) is{} actor) player.SeedBubbleTilt(actor.Rotation); //The display tile remains available for Practice outside the bounded //live scene; unsupported selection must not invent a Jimmy flight mode. player.GadgetMode=item==1&&Rocketship==null||item==4&&Scooter==null?-1:GadgetScreen.EquippedMode(item); @@ -164,7 +161,7 @@ public sealed class PlayerSceneBinding : IDisposable private void Transform(DirectorActor actor) { if (string.Equals(actor.Tag, tag, StringComparison.OrdinalIgnoreCase)) - player.ApplyAuthoredTransform(actor.Position, actor.Rotation.Y); + player.ApplyAuthoredTransform(actor.Position, actor.Rotation); } public void Dispose() diff --git a/src/GamePort/Program.cs b/src/GamePort/Program.cs index d2bed8f..60217af 100644 --- a/src/GamePort/Program.cs +++ b/src/GamePort/Program.cs @@ -358,7 +358,7 @@ internal static class Program var cameraRay = level!.Code is "LV1B" or "VR01" or "VR02" or "VR04" or "VR05" or "VR07" or "VR08" or "LEV1" ? OriginalCameraRay.FromRouteScene(world, level.Code) : null; debugCameraRay = cameraRay; - simulation = new LabSimulation(new SceneCollision(world), standingPose, originalStart.Position, originalStart.Rotation.Y, + simulation = new LabSimulation(new SceneCollision(world), standingPose, originalStart.Position, originalStart.Rotation, 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) @@ -664,7 +664,7 @@ internal static class Program baseballs?.Reset(); interactions!.Reset(); mechanisms!.Reset(); - director.SyncActor(level!.Player!.Tag!, simulation!.ActorRoot, new Vector3(0, simulation.Yaw, 0)); + director.SyncActor(level!.Player!.Tag!, simulation!.ActorRoot, simulation.Rotation); if (returning && director.FindActor("C3DGODDARD") is { } companion) director.SyncActor(companion.Tag, returnRoot, companion.Rotation); //423AE3..423B1E, no offset. if (practiceReturnSmoke && returning) @@ -684,7 +684,7 @@ internal static class Program interactions.Inventory.SetState(0, 3, 1); interactions.Inventory.SelectGadget(3); simulation.ApplyRetainedLevelState(new("LV1B", 3, 1, .625f, 6.125f)); simulation.RestoreReturnRoot(simulation.ActorRoot + Vector3.UnitY * 200); - director.SyncActor(level.Player!.Tag!, simulation.ActorRoot, new(0, simulation.Yaw, 0)); + director.SyncActor(level.Player!.Tag!, simulation.ActorRoot, simulation.Rotation); director.Trigger("neutron1a"); } if (practiceReturnSmoke && level.Code == "VR04") @@ -726,7 +726,7 @@ internal static class Program // Move the real player away from STRT so an accidental // restart at the authored spawn cannot pass this check. for (var tick = 0; tick < 45; tick++) simulation.Step(new(true, false, false, false, false)); - director.SyncActor(level.Player!.Tag!, simulation.ActorRoot, new(0, simulation.Yaw, 0)); + director.SyncActor(level.Player!.Tag!, simulation.ActorRoot, simulation.Rotation); } director.Touch(level!.Player!.Tag!, level.Entities.Single(e => e.Tag == "teleportexplanation").Position); director.Skip(); @@ -862,7 +862,7 @@ internal static class Program director!.EnsureCompanion(ray.TraceGeometry(simulation.ActorRoot,behind)==null?behind:originalStart!.Position,Vector3.Zero); } interactions?.Reset(); mechanisms?.Reset(); gadgets?.Reset(); baseballs?.Reset(); mouseFire = false; - director?.SyncActor(level!.Player!.Tag!, simulation.ActorRoot, new Vector3(0, simulation.Yaw, 0)); + director?.SyncActor(level!.Player!.Tag!, simulation.ActorRoot, simulation.Rotation); } void ToggleCamera() { @@ -1026,7 +1026,7 @@ internal static class Program if (simulation == null) return; characterModel = simulation.Model; if (level?.Player?.Tag is { } tag) - director?.SyncActor(tag, simulation.ActorRoot, new Vector3(0, simulation.Yaw, 0)); + director?.SyncActor(tag, simulation.ActorRoot, simulation.Rotation); } Vector2 Pointer() { @@ -1436,6 +1436,13 @@ internal static class Program } renderer.UpdateVertices(mesh.Vertices); renderer.Render(view * projection); + if(simulation!=null&&((jetpackSmoke&&count is 74 or 109)||(walkSmoke&&count==89))) + { + var stage=jetpackSmoke?(count==74?"air-forward":"air-brake"):"air"; + Console.WriteLine($"Movement {stage}: step={simulation.Steps}, Euler={simulation.Rotation}, target={simulation.FacingTarget}, speed={simulation.Speed:F3}, velocity={simulation.Velocity}."); + if(Option(args,"--screenshot") is{} capture) + renderer.SavePpm(Path.ChangeExtension(capture,$".{stage}.ppm")); + } if(scooterFixture!=null) { scooterFixture.AfterFrame(count); diff --git a/tests/GamePort.DirectorTests/Program.cs b/tests/GamePort.DirectorTests/Program.cs index fe88886..5acc5cf 100644 --- a/tests/GamePort.DirectorTests/Program.cs +++ b/tests/GamePort.DirectorTests/Program.cs @@ -151,6 +151,10 @@ foreach (var kind in new[] { "3CAM", "3MCA", "3AIT" }) var bag = new SceneInventory(new int[19]); bag.SetState(0, 3, 1); bag.SelectGadget(3); using var binding = new PlayerSceneBinding(scene, body, bag, "JIM1"); for (var tick = 0; tick < 5; tick++) binding.Step(new(true, false, false, false, false)); + //Full Euler sync now reflects the ground input's leveling. Seed the authored + //tilt immediately before the command to isolate preparation ownership. + body.ApplyAuthoredTransform(body.ActorRoot,new Vector3(12,body.Yaw,0)); + scene.SyncActor("JIM1",body.ActorRoot,body.Rotation); var callbacks = new List(); scene.ActorPreparing += (actor, action) => { diff --git a/tests/GamePort.InteractionTests/GamePort.InteractionTests.csproj b/tests/GamePort.InteractionTests/GamePort.InteractionTests.csproj index 6d6645d..cf92326 100644 --- a/tests/GamePort.InteractionTests/GamePort.InteractionTests.csproj +++ b/tests/GamePort.InteractionTests/GamePort.InteractionTests.csproj @@ -37,5 +37,6 @@ + diff --git a/tests/GamePort.JimmyAirTests/GamePort.JimmyAirTests.csproj b/tests/GamePort.JimmyAirTests/GamePort.JimmyAirTests.csproj index ab70e8a..bca400a 100644 --- a/tests/GamePort.JimmyAirTests/GamePort.JimmyAirTests.csproj +++ b/tests/GamePort.JimmyAirTests/GamePort.JimmyAirTests.csproj @@ -2,5 +2,6 @@ Exenet10.0enableenablefalse + diff --git a/tests/GamePort.JimmyAirTests/Program.cs b/tests/GamePort.JimmyAirTests/Program.cs index dcf4ab6..4d50f57 100644 --- a/tests/GamePort.JimmyAirTests/Program.cs +++ b/tests/GamePort.JimmyAirTests/Program.cs @@ -21,6 +21,19 @@ foreach(var c in doc.RootElement.GetProperty("cases").EnumerateArray()) Check(inputs==22&&applies==13,"complete original observations"); Console.WriteLine("PASS22 copied-original airborne keyboard-input observations, including supported mode1, coast boundary and latch"); Console.WriteLine("PASS13 copied-original air velocity/Euler observations, including zero velocity, pitch, seam and original vertical preservation"); +using var targets=JsonDocument.Parse(File.ReadAllText(Path.Combine(AppContext.BaseDirectory,"original-air-targets-reference.json"))); +int writes=0; +foreach(var c in targets.RootElement.GetProperty("cases").EnumerateArray()) +{ + var p=c.GetProperty("input").EnumerateArray().Select(x=>x.GetSingle()).ToArray(); + var o=c.GetProperty("observed").EnumerateArray().Select(x=>x.GetSingle()).ToArray(); + var input=new PlayerInput(p[0]!=0,p[1]!=0,p[2]!=0,p[3]!=0,false); + var steering=JimmyAirMotion.Input(new(p[4],0,false),input,p[5]!=0,1f/60); + NearV(JimmyAirMotion.Destination(input,45,steering.TurnRate,p[6],p[7]),new(o[0],o[1],o[2]),"original destination write"); + Check(o[3]==1,"source wrote exactly once");writes++; +} +Check(writes==12,"complete destination observations"); +Console.WriteLine("PASS12 copied-original air destination-Euler observations, including retained pitch seeds and Up precedence"); static void Check(bool ok,string name){if(!ok)throw new Exception(name);} static void Near(float a,float b,string name)=>Check(float.IsFinite(a)&&Math.Abs(a-b)<.005f,$"{name}: {a} != {b}"); static void NearV(Vector3 a,Vector3 b,string name)=>Check(float.IsFinite(a.X+a.Y+a.Z)&&Vector3.Distance(a,b)<.04f,$"{name}: {a} != {b}"); diff --git a/tests/GamePort.JimmyRenderTests/GamePort.JimmyRenderTests.csproj b/tests/GamePort.JimmyRenderTests/GamePort.JimmyRenderTests.csproj new file mode 100644 index 0000000..b960068 --- /dev/null +++ b/tests/GamePort.JimmyRenderTests/GamePort.JimmyRenderTests.csproj @@ -0,0 +1,9 @@ + + Exenet10.0enableenablefalse + + + + + + + diff --git a/tests/GamePort.JimmyRenderTests/Program.cs b/tests/GamePort.JimmyRenderTests/Program.cs new file mode 100644 index 0000000..14e79ff --- /dev/null +++ b/tests/GamePort.JimmyRenderTests/Program.cs @@ -0,0 +1,54 @@ +using System.Numerics; +using System.Text.Json; +using GamePort.Game; + +using var doc=JsonDocument.Parse(File.ReadAllText(Path.Combine(AppContext.BaseDirectory,"original-render-reference.json"))); +int angles=0,transforms=0;float largestRenderDeviation=0; +foreach(var c in doc.RootElement.GetProperty("angles").EnumerateArray()) +{ + var p=c.GetProperty("input").EnumerateArray().Select(x=>x.GetSingle()).ToArray(); + var o=c.GetProperty("observed").EnumerateArray().Select(x=>x.GetInt32()).ToArray(); + for(int i=0;i<3;i++)Check(JimmyRenderTransform.AngleUnits(p[i])==o[i],$"degree cache {c.GetProperty("name")}, axis{i}"); + angles++; +} +foreach(var c in doc.RootElement.GetProperty("models").EnumerateArray()) +{ + var p=c.GetProperty("input").EnumerateArray().Select(x=>x.GetSingle()).ToArray(); + var o=c.GetProperty("observed").EnumerateArray().Select(x=>x.GetSingle()).ToArray(); + var render=c.GetProperty("render").EnumerateArray().Select(x=>x.GetSingle()).ToArray(); + var root=new Vector3(p[3],p[4],p[5]);var euler=new Vector3(p[0],p[1],p[2])*(360f/16384); + var m=JimmyRenderTransform.Source(root,euler);var a=Values(m); + for(int i=0;i<15;i++)Near(a[i],o[i],.000001f,$"original hxform {c.GetProperty("name")}, value{i}"); + //The source's render consumer decomposes and re-quantizes the basis. The + //hierarchical model bridge intentionally defers that final precision step. + for(int i=0;i<16;i++)largestRenderDeviation=Math.Max(largestRenderDeviation,Math.Abs(a[i]-render[i])); + Check(new Vector3(m.M41,m.M42,m.M43)==root,"Euler must not rotate root translation"); + Near(m.GetDeterminant(),1,.000001f,"unit-scale proper rotation");transforms++; +} +Check(angles==12&&transforms==14,"complete original transform fixture"); +Console.WriteLine("PASS12 copied-original degree/short cache and14 OMT hierarchical transform observations"); +Near(largestRenderDeviation,.007286334f,.000002f,"recorded final render consumer deviation remains an explicit precision gate"); +Console.WriteLine($"RECOVERED14 final render matrices: hierarchical bridge max deviation={largestRenderDeviation:G9}; final decomposition remains separate"); +const float minimum=-64.6165f,height=75.9f;float correction=-minimum-height; +var actorRoot=new Vector3(123,height,456); +var upright=JimmyRenderTransform.Aligned(actorRoot,Vector3.Zero,correction); +Near(Vector3.Transform(new(0,minimum,0),upright).Y,0,.00002f,"upright baseline sole placement"); +foreach(var euler in new[]{new Vector3(-40,45,-15),new Vector3(10,220,15),new Vector3(0,0,90)}) +{ + var model=JimmyRenderTransform.Aligned(actorRoot,euler,correction); + Check(Vector3.Distance(Vector3.Transform(new(0,-correction,0),model),actorRoot)<.00004f, + "compatibility correction is local: the logical pivot remains fixed under combined tilt"); +} +Console.WriteLine("PASS modern local sole correction preserves upright placement and the logical tilt pivot"); +foreach(var bad in new[]{float.NaN,float.PositiveInfinity,float.NegativeInfinity}) +{ + Throws(()=>JimmyRenderTransform.AngleUnits(bad)); + Throws(()=>JimmyRenderTransform.Source(new(bad,0,0),Vector3.Zero)); + Throws(()=>JimmyRenderTransform.Source(Vector3.Zero,new(0,bad,0))); + Throws(()=>JimmyRenderTransform.Aligned(Vector3.Zero,Vector3.Zero,bad)); +} +Console.WriteLine("PASS nonfinite transform inputs rejected"); +static float[] Values(Matrix4x4 m)=>[m.M11,m.M12,m.M13,m.M14,m.M21,m.M22,m.M23,m.M24,m.M31,m.M32,m.M33,m.M34,m.M41,m.M42,m.M43,m.M44]; +static void Check(bool value,string message){if(!value)throw new Exception(message);} +static void Near(float value,float expected,float tolerance,string message)=>Check(float.IsFinite(value)&&Math.Abs(value-expected)<=tolerance,$"{message}: {value} != {expected}"); +static void Throws(Action action){try{action();}catch(ArgumentOutOfRangeException){return;}throw new Exception("nonfinite input accepted");} diff --git a/tests/GamePort.JimmyRenderTests/original-render-reference.json b/tests/GamePort.JimmyRenderTests/original-render-reference.json new file mode 100644 index 0000000..48b8090 --- /dev/null +++ b/tests/GamePort.JimmyRenderTests/original-render-reference.json @@ -0,0 +1,925 @@ +{ + "exe": { + "sha256": "f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8", + "ranges": [ + { + "va": "0x4624b0", + "file_offset": "0x624b0", + "length": 64, + "sha256": "be80b2bde09dde5d668389d64d330c3b996e8a3cbd50cda5eb1394bb9be99515" + }, + { + "va": "0x462500", + "file_offset": "0x62500", + "length": 30, + "sha256": "71f83f2a073bd2458d3c7b31e6398fb9af5f92a6139ee6364b4339c68d60458d" + }, + { + "va": "0x473540", + "file_offset": "0x73540", + "length": 154, + "sha256": "145007991bf3514edba29d8df8c94eae069cf2d0d21034dea24d69eb611e9ab0" + }, + { + "va": "0x4723f0", + "file_offset": "0x723f0", + "length": 48, + "sha256": "ae10074b5ae2ff3d2d2ce8c16358476acdba2f2a166be8ad5c9f05e3f55ffc23" + }, + { + "va": "0x47f940", + "file_offset": "0x7f940", + "length": 39, + "sha256": "d0a2aca68648a0ae9d5cbfae1b276d4a64d4f797fc0c60f28b64096cdfa3148c" + }, + { + "va": "0x4802ca", + "file_offset": "0x802ca", + "length": 40, + "sha256": "a0dc90a444c3cd46550d18d44ab2a72c8569644044248528c9979457e88ffd3e" + } + ] + }, + "dll": { + "sha256": "3ec41ead011adf56387a6dbd4580e5b5a9721b5f8020c8a56420f42824354943", + "ranges": [ + { + "va": "0x1003fa60", + "file_offset": "0x3fa60", + "length": 400, + "sha256": "3032a99d8c5781eca782d91ea4aa06c2e30531aca01f869f6986d01eeb972e6d" + }, + { + "va": "0x1003fc00", + "file_offset": "0x3fc00", + "length": 868, + "sha256": "cbec74de9d7e4fc064a3100d450e28147e29cceddab5c9a5d5d01caf7897a624" + }, + { + "va": "0x10041d50", + "file_offset": "0x41d50", + "length": 512, + "sha256": "127a0e34d2ca6d9769fa9609b7ac22a58b743a0b2ac0564164f68240796f4696" + } + ] + }, + "bindings": [ + { + "table": "0x4a373c", + "slot": "0x310", + "target": "0x472300" + }, + { + "table": "0x4a373c", + "slot": "0x328", + "target": "0x4723f0" + }, + { + "table": "0x4a373c", + "slot": "0x3dc", + "target": "0x4624b0" + }, + { + "table": "0x4a373c", + "slot": "0x3e0", + "target": "0x4624f0" + }, + { + "table": "0x4a373c", + "slot": "0x3e4", + "target": "0x462500" + } + ], + "degree_constants": { + "0x4d6408": 45.51111111111111, + "0x4d6410": 360.0 + }, + "models": [ + { + "name": "upright", + "input": [ + 0.0, + 0.0, + 0.0, + 100.0, + 75.9000015, + -200.0 + ], + "observed": [ + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 100.0, + 75.9000015, + -200.0 + ], + "render": [ + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 100.0, + 75.9000015, + -200.0, + 1.0, + 6.0 + ] + }, + { + "name": "pitch90", + "input": [ + 4096.0, + 0.0, + 0.0, + 100.0, + 75.9000015, + -200.0 + ], + "observed": [ + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + -1.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 100.0, + 75.9000015, + -200.0 + ], + "render": [ + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + -1.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 100.0, + 75.9000015, + -200.0, + 1.0, + 6.0 + ] + }, + { + "name": "yaw90", + "input": [ + 0.0, + 4096.0, + 0.0, + 100.0, + 75.9000015, + -200.0 + ], + "observed": [ + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + -1.0, + 0.0, + 0.0, + 0.0, + 100.0, + 75.9000015, + -200.0 + ], + "render": [ + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + -1.0, + 0.0, + 0.0, + 0.0, + 100.0, + 75.9000015, + -200.0, + 1.0, + 6.0 + ] + }, + { + "name": "roll90", + "input": [ + 0.0, + 0.0, + 4096.0, + 100.0, + 75.9000015, + -200.0 + ], + "observed": [ + 0.0, + -1.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 100.0, + 75.9000015, + -200.0 + ], + "render": [ + 0.0, + -1.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 100.0, + 75.9000015, + -200.0, + 1.0, + 6.0 + ] + }, + { + "name": "air_forward", + "input": [ + 14564.0, + 2048.0, + 15702.0, + 100.0, + 500.0, + -200.0 + ], + "observed": [ + 0.565557301, + 0.198106021, + 0.800561607, + 0.0, + -0.621811032, + 0.740098596, + 0.256134927, + 0.0, + -0.541752696, + -0.642657042, + 0.541752696, + 0.0, + 100.0, + 500.0, + -200.0 + ], + "render": [ + 0.565611005, + 0.198169738, + 0.800507903, + 0.0, + -0.621610343, + 0.740336657, + 0.255934209, + 0.0, + -0.54192692, + -0.642363191, + 0.54192692, + 0.0, + 100.0, + 500.0, + -200.0, + 1.0, + 6.0 + ] + }, + { + "name": "air_brake", + "input": [ + 455.0, + 2048.0, + 682.0, + 100.0, + 500.0, + -200.0 + ], + "observed": [ + 0.651317656, + -0.254645705, + 0.714801311, + 0.0, + 0.301421434, + 0.951323569, + 0.0642546937, + 0.0, + -0.696369469, + 0.173606217, + 0.696369469, + 0.0, + 100.0, + 500.0, + -200.0 + ], + "render": [ + 0.651386678, + -0.254662871, + 0.71473223, + 0.0, + 0.301163465, + 0.951387763, + 0.06451267, + 0.0, + -0.696416497, + 0.173228532, + 0.696416497, + 0.0, + 100.0, + 500.0, + -200.0, + 1.0, + 6.0 + ] + }, + { + "name": "full_axes", + "input": [ + 1365.0, + 2503.0, + 910.0, + -123.5, + 811.25, + 70.125 + ], + "observed": [ + 0.399019778, + -0.296150625, + 0.867800713, + 0.0, + 0.580931485, + 0.813882947, + 0.0106347203, + 0.0, + -0.709437668, + 0.499889284, + 0.496798605, + 0.0, + -123.5, + 811.25, + 70.125 + ], + "render": [ + 0.399112821, + -0.29621619, + 0.867735505, + 0.0, + 0.580675781, + 0.814063072, + 0.0108137615, + 0.0, + -0.709594667, + 0.499557108, + 0.496908575, + 0.0, + -123.5, + 811.25, + 70.125, + 1.0, + 6.0 + ] + }, + { + "name": "negative_units", + "input": [ + -1820.0, + -2048.0, + -682.0, + -123.5, + 811.25, + 70.125 + ], + "observed": [ + 0.800561607, + 0.198106021, + -0.565557301, + 0.0, + 0.256134927, + 0.740098596, + 0.621811032, + 0.0, + 0.541752696, + -0.642657042, + 0.541752696, + 0.0, + -123.5, + 811.25, + 70.125 + ], + "render": [ + 0.800507903, + 0.198169738, + -0.565611005, + 0.0, + 0.255934209, + 0.740336657, + 0.621610343, + 0.0, + 0.54192692, + -0.642363191, + 0.54192692, + 0.0, + -123.5, + 811.25, + 70.125, + 1.0, + 6.0 + ] + }, + { + "name": "seam", + "input": [ + 16383.0, + 16383.0, + 16383.0, + 0.0, + 0.0, + 0.0 + ], + "observed": [ + 0.999999881, + 0.000383495149, + -0.000383348088, + 0.0, + -0.000383348088, + 0.999999881, + 0.000383642182, + 0.0, + 0.000383495149, + -0.000383495179, + 0.999999881, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "render": [ + 0.99994123, + 0.00766982883, + -0.00766960345, + 0.0, + -0.00766960345, + 0.999970615, + 5.88262737e-05, + 0.0, + 0.00766982883, + 0.0, + 0.999970615, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 6.0 + ] + }, + { + "name": "canonical360", + "input": [ + 16384.0, + 16384.0, + 16384.0, + 0.0, + 0.0, + 0.0 + ], + "observed": [ + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "render": [ + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 6.0 + ] + }, + { + "name": "halfturn", + "input": [ + 8192.0, + 8192.0, + 8192.0, + 0.0, + 0.0, + 0.0 + ], + "observed": [ + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + -0.0, + -0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "render": [ + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 6.0 + ] + }, + { + "name": "tiny", + "input": [ + 1.0, + 2.0, + 3.0, + 0.0, + 0.0, + 0.0 + ], + "observed": [ + 0.999999046, + -0.00115048536, + 0.000767431164, + 0.0, + 0.00115077931, + 0.999999285, + -0.000382612576, + 0.0, + -0.000766990415, + 0.000383495353, + 0.999999642, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "render": [ + 0.99994123, + -0.00766982883, + 0.00766960345, + 0.0, + 0.00766960345, + 0.999970615, + 5.88262737e-05, + 0.0, + -0.00766982883, + 0.0, + 0.999970615, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 6.0 + ] + }, + { + "name": "zero_root", + "input": [ + 14564.0, + 2048.0, + 15702.0, + 0.0, + 0.0, + 0.0 + ], + "observed": [ + 0.565557301, + 0.198106021, + 0.800561607, + 0.0, + -0.621811032, + 0.740098596, + 0.256134927, + 0.0, + -0.541752696, + -0.642657042, + 0.541752696, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "render": [ + 0.565611005, + 0.198169738, + 0.800507903, + 0.0, + -0.621610343, + 0.740336657, + 0.255934209, + 0.0, + -0.54192692, + -0.642363191, + 0.54192692, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 6.0 + ] + }, + { + "name": "other_root", + "input": [ + 14564.0, + 2048.0, + 15702.0, + 1000.0, + 1011.25, + -2500.0 + ], + "observed": [ + 0.565557301, + 0.198106021, + 0.800561607, + 0.0, + -0.621811032, + 0.740098596, + 0.256134927, + 0.0, + -0.541752696, + -0.642657042, + 0.541752696, + 0.0, + 1000.0, + 1011.25, + -2500.0 + ], + "render": [ + 0.565611005, + 0.198169738, + 0.800507903, + 0.0, + -0.621610343, + 0.740336657, + 0.255934209, + 0.0, + -0.54192692, + -0.642363191, + 0.54192692, + 0.0, + 1000.0, + 1011.25, + -2500.0, + 1.0, + 6.0 + ] + } + ], + "angles": [ + { + "name": "zero", + "input": [ + 0.0, + 0.0, + 0.0 + ], + "observed": [ + 0, + 0, + 0 + ] + }, + { + "name": "forward", + "input": [ + -40.0, + 45.0, + -15.0 + ], + "observed": [ + 14564, + 2048, + 15702 + ] + }, + { + "name": "backward", + "input": [ + 10.0, + 45.0, + 15.0 + ], + "observed": [ + 455, + 2048, + 682 + ] + }, + { + "name": "quarter", + "input": [ + 90.0, + 180.0, + 270.0 + ], + "observed": [ + 4096, + 8192, + 12288 + ] + }, + { + "name": "revolutions", + "input": [ + 360.0, + 720.0, + -360.0 + ], + "observed": [ + 0, + 0, + 0 + ] + }, + { + "name": "negative", + "input": [ + -0.5, + -40.0, + -359.998993 + ], + "observed": [ + 16362, + 14564, + 1 + ] + }, + { + "name": "fractional", + "input": [ + 0.00100000005, + 359.998993, + -0.00100000005 + ], + "observed": [ + 0, + 16383, + 0 + ] + }, + { + "name": "arbitrary", + "input": [ + 0.0166666675, + 30.0, + 7.30000019 + ], + "observed": [ + 0, + 1365, + 332 + ] + }, + { + "name": "large", + "input": [ + 1440.75, + -725.25, + 9999.99023 + ], + "observed": [ + 34, + 16146, + 12742 + ] + }, + { + "name": "exact_units", + "input": [ + 0.0219726562, + 0.0439453125, + 0.0659179688 + ], + "observed": [ + 1, + 2, + 3 + ] + }, + { + "name": "canonical", + "input": [ + 360.0, + 360.0, + 360.0 + ], + "observed": [ + 0, + 0, + 0 + ] + }, + { + "name": "seam", + "input": [ + 359.98999, + -0.00999999978, + -720.01001 + ], + "observed": [ + 16383, + 0, + 0 + ] + } + ], + "scope": "Original OMT compute_hxform and compute_model_matrix with synthetic zero-offset element/identity parent; original EXE473540\u2192462500 with synthetic Euler getter and original finite remainder primitive; CRT exception dispatch bypassed. No game/render entrypoint or whole-game trajectory.", + "files": { + "tools/binary/jimmy_model_bridge.py": "c2270f046fc35ecd6e52af94df075ecce99d7309a5d66bcae2e46094665dab35", + "tools/binary/jimmy_model_bridge_probe.c": "71a186c9132d9378216b7291f0eea494dad7aa060bec410c7e0bc2f48abd2539", + "tools/binary/jimmy_model_bridge_angles_probe.c": "4bbb8de48806e33c9aeb4402f369e7d2212ea4a0710fb111dec41c3d8eaa910d", + "artifacts/jimmy-model-bridge/jimmy_model_bridge_probe.exe": "897ba58d9c6231587a20638b197304fa421880d46f7eb2516188caeed2a82a4d", + "artifacts/jimmy-model-bridge/jimmy_model_bridge_angles_probe.exe": "574323679fbea46a8bc072eba4c485158ede3371e152e359d9c00f33baf1cc4d", + "artifacts/jimmy-model-bridge/probe/wine.log": "fd0d486c2e416ae08623d583fbf7e856b2170918ebb57c984ca91cb9d5fe0060", + "artifacts/jimmy-model-bridge/angles.log": "9d34919b022183db096b6555c2e54c5c51dbab012ba53b45607c21b9a8777fb3" + } +} diff --git a/tests/GamePort.MovementTests/Program.cs b/tests/GamePort.MovementTests/Program.cs index 485732b..5b66f79 100644 --- a/tests/GamePort.MovementTests/Program.cs +++ b/tests/GamePort.MovementTests/Program.cs @@ -19,6 +19,8 @@ var tests = new (string Name, Action Check)[] ("backpedal cap and release", Backpedal), ("yaw sign, forward half-turn and left precedence", Turning), ("active heading clears stale turn while control lock retains facing", FacingOwnership), + ("Init and authored Euler keep destination and dirty ownership separate", FacingState), + ("air target and pitch seed phases survive mode and route transitions", AirPitchPhases), ("fixed-step input replay independent of presentation rate", ReplayRates), ("jump rises, falls and returns to support", JumpLanding), ("held zero-burn jump repeats and release stops repetition", HeldJump), @@ -398,7 +400,7 @@ static void FacingOwnership() "base facing advances its retained target during control lock while input and jump remain gated"); var tilted = FlatSimulation(); - tilted.SeedBubbleTilt(new(350, 0, 10)); + tilted.ApplyAuthoredTransform(tilted.ActorRoot,new Vector3(350, 0, 10)); tilted.Step(new(true, false, false, false, false)); Check(tilted.Pitch > 350 && tilted.Pitch < 351 && tilted.Roll < 10 && tilted.Roll > 9, "ground heading levels all axes by the shortest arc through the zero seam"); @@ -408,6 +410,68 @@ static void FacingOwnership() "pitch and roll settling belong to the same control-independent facing phase"); } +static void FacingState() +{ + var simulation=FlatSimulation(155); + Check(simulation.FacingTarget==Vector3.Zero&&!simulation.FacingDirty, + "Init clears destination axes and dirty while STRT supplies current yaw"); + simulation.ApplyAuthoredTransform(simulation.ActorRoot,new Vector3(15,275,20)); + simulation.Step(default,controlled:false); + NearVector(simulation.Rotation,new(15,275,20),0,"authored current Euler survives without an active destination"); + Check(simulation.FacingTarget==Vector3.Zero&&!simulation.FacingDirty,"authored write does not invent a destination write"); + simulation.Step(new(true,false,false,false,false)); + Check(simulation.FacingTarget==new Vector3(0,275,0)&&simulation.FacingDirty, + "accepted ground heading writes upright destination; before-step difference keeps dirty"); + Check(simulation.Pitch<15&&simulation.Roll<20,"base facing consumes the new full-axis destination"); + simulation.Reset(); + simulation.Step(default,controlled:false); + Near(simulation.Yaw,155,0,"reset's zero destination cannot pull authored yaw toward zero"); + Check(!simulation.FacingDirty,"inactive reset destination stays clean"); + simulation.Step(new(true,false,false,false,false)); + Check(!simulation.FacingDirty&&simulation.FacingTarget==simulation.Rotation, + "source clears dirty when all current axes already equal the written target"); +} + +static void AirPitchPhases() +{ + var forward=new PlayerInput(true,false,false,false,true); + var simulation=FlatSimulation(); + simulation.Step(forward); //Ground input, then ordinary air apply seeds−40/+10. + simulation.Step(forward); + Check(simulation.FacingTarget.X==-40&&simulation.FacingTarget.Z==0, + "ordinary airborne throttle publishes source forward pitch"); + Check(MathF.IEEERemainder(simulation.Pitch,360)<0&&simulation.Velocity.Y>0, + "current pitch follows target while incoming vertical motion remains physical"); + simulation.Step(new(false,true,false,true,true)); + Check(simulation.FacingTarget.X==10&&simulation.FacingTarget.Z>0, + "backward target and turn lean use the updated air turn scalar"); + var tilted=FlatSimulation(); + for(var tick=0;tick<40;tick++)tilted.Step(forward); + Check(!tilted.Grounded&&tilted.Speed==600&&new Vector2(tilted.Velocity.X,tilted.Velocity.Z).Length()<550, + "source air pitch attenuates horizontal forward while retaining the controller speed scalar"); + tilted.SetNoclip(true); + Check(!tilted.FacingDirty&&tilted.FacingTarget==tilted.Rotation,"modern noclip entry freezes the pending airborne facing request"); + + foreach(var retained in new[]{false,true}) + { + var bubble=FlatSimulation();bubble.InputAfterPlayerUpdate=retained;bubble.GadgetMode=0; + bubble.Step(new(false,false,false,false,false,Fire:true)); + Near(bubble.FacingTarget.X,retained?-10:-40,0,"first Bubble input reads pitch from its preceding apply phase"); + Near(bubble.ForwardAirPitch,-10,0,"Bubble apply seeds the next input's pitch"); + bubble.GadgetMode=-1; + var carried=bubble.CaptureLevelState(-1)!; + Near(carried.ForwardPitch,-10,0,"cleanup retains the field rather than inferring it from current mode"); + var destination=FlatSimulation();destination.LevelCode="VR04"; + Check(destination.ApplyRetainedLevelState(carried with{MovementMode=1}),"route accepts proven retained pitch fields"); + Check(destination.FacingTarget==Vector3.Zero&&!destination.FacingDirty,"route Init resets destination independently of retained pitches"); + destination.Step(forward); + Near(destination.FacingTarget.X,-10,0,"first ordinary air input can consume a prior Bubble pitch seed"); + Near(destination.ForwardAirPitch,-40,0,"ordinary apply restores its own pitch seeds afterward"); + destination.Step(forward); + Near(destination.FacingTarget.X,-40,0,"following input consumes ordinary seed"); + } +} + static void ReplayRates() { LabSimulation? reference = null; @@ -524,8 +588,10 @@ static void JetpackControl() } Check(straight.Position.Z > 400 && left.Yaw > 20 && MathF.IEEERemainder(right.Yaw,360)<-20, "powered Up moves from rest and Left/Right turn while airborne"); - Check(left.Position.X < -50 && right.Position.X > 50 && left.Position.Y > initialHeight, - "powered paths change direction and retain vertical lift"); + //Recovered forward pitch attenuates horizontal travel; this verifies a + //measurable change of path without retaining the old flat-air distance. + Check(left.Position.X < -30 && right.Position.X > 30 && left.Position.Y > initialHeight, + $"powered paths change direction and retain vertical lift: left={left.Position}, right={right.Position}, initialY={initialHeight}"); var beforeBrake = left.Speed; for (var i = 0; i < 40; i++) left.Step(new(false, true, false, false, true)); Check(beforeBrake > 0 && left.Speed == 0 && left.TurnRate == 0 && !left.Grounded, diff --git a/tests/GamePort.PatrolTests/GamePort.PatrolTests.csproj b/tests/GamePort.PatrolTests/GamePort.PatrolTests.csproj index 7094cc6..2fe2e09 100644 --- a/tests/GamePort.PatrolTests/GamePort.PatrolTests.csproj +++ b/tests/GamePort.PatrolTests/GamePort.PatrolTests.csproj @@ -45,5 +45,6 @@ + diff --git a/tests/test_jimmy_air_target_state.py b/tests/test_jimmy_air_target_state.py new file mode 100644 index 0000000..28ff2eb --- /dev/null +++ b/tests/test_jimmy_air_target_state.py @@ -0,0 +1,44 @@ +"""Original target/current Euler, initialization and retained seed ownership.""" +from pathlib import Path +import sys +import unittest + +ROOT=Path(__file__).resolve().parents[1] +sys.path.insert(0,str(ROOT/'tools/binary')) +from jimmy_air_target_state import collect + + +class JimmyAirTargetStateEvidence(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.report=collect(ROOT.parent/'Original') + + def test_original_instruction_sites_and_virtual_bindings(self): + self.assertEqual(len(self.report['sites']),32) + self.assertEqual(len(self.report['slots']),9) + self.assertEqual(len(self.report['ranges']),11) + for row in self.report['sites']+self.report['ranges']: + self.assertEqual(int(row['va'],16)-0x400000,int(row['file_offset'],16)) + slots={r['slot']:r['target'] for r in self.report['slots']} + self.assertEqual(slots['0x36c'],'0x472660') + self.assertEqual(slots['0x330'],'0x472420') + self.assertEqual(slots['0x3d8'],'0x43a420') + + def test_actual_start_data_is_upright_without_conflating_target_init(self): + route=self.report['route'] + self.assertEqual([r['rotation'] for r in route],[[0,155,0],[0,290,0],[0,220,0]]) + self.assertEqual([r['start_tag'] for r in route],['STARTEXP','PHONEBOOTH','PHONEBOOTH']) + self.assertEqual(self.report['destination_euler_fields'],['0x274','0x278','0x27c']) + self.assertNotEqual(self.report['current_euler_fields'],self.report['destination_euler_fields']) + + def test_seed_writes_belong_to_apply_and_constructor(self): + sites={r['name']:r['bytes'] for r in self.report['sites']} + self.assertTrue(sites['constructor_forward_pitch'].endswith('000020c2')) + self.assertTrue(sites['ordinary_apply_forward_pitch'].endswith('000020c2')) + self.assertTrue(sites['bubble_apply_forward_pitch'].endswith('000020c1')) + self.assertEqual(sites['destination_marks_dirty'],'c6410a01') + self.assertEqual(sites['init_clears_facing_dirty'],'88460a') + self.assertEqual(self.report['pitch_seed_fields']['interface'],['0x72c','0x730']) + + +if __name__=='__main__':unittest.main() diff --git a/tests/test_jimmy_model_bridge.py b/tests/test_jimmy_model_bridge.py new file mode 100644 index 0000000..88bd9dd --- /dev/null +++ b/tests/test_jimmy_model_bridge.py @@ -0,0 +1,33 @@ +"""Original Jimmy model-cache/OMT transform source and native fixture guards.""" +from pathlib import Path +import hashlib,json,sys,unittest +ROOT=Path(__file__).resolve().parents[1] +sys.path.insert(0,str(ROOT/'tools/binary')) +from jimmy_model_bridge import collect + +class JimmyModelBridgeEvidence(unittest.TestCase): + def fixture(self): + return json.loads((ROOT/'tests/GamePort.JimmyRenderTests/original-render-reference.json').read_text()) + + def test_original_ranges_constants_and_bindings(self): + actual=collect(ROOT.parent/'Original');fixture=self.fixture() + for key,value in actual.items():self.assertEqual(value,fixture[key],key) + self.assertEqual(actual['degree_constants']['0x4d6408'],45.51111111111111) + self.assertEqual(actual['degree_constants']['0x4d6410'],360) + self.assertEqual(len(actual['bindings']),5) + + def test_native_fixture_scope_counts_and_provenance(self): + f=self.fixture();self.assertEqual(len(f['models']),14);self.assertEqual(len(f['angles']),12) + for name,digest in f['files'].items(): + self.assertEqual(len(digest),64) + if name.startswith('tools/'):self.assertEqual(hashlib.sha256((ROOT/name).read_bytes()).hexdigest(),digest) + cases={c['name']:c for c in f['angles']} + self.assertEqual(cases['forward']['observed'],[14564,2048,15702]) + self.assertEqual(cases['quarter']['observed'],[4096,8192,12288]) + self.assertEqual(cases['revolutions']['observed'],[0,0,0]) + models={c['name']:c for c in f['models']} + self.assertEqual(models['zero_root']['observed'][:12],models['other_root']['observed'][:12]) + self.assertEqual(models['other_root']['observed'][12:],[1000,1011.25,-2500]) + self.assertTrue(all(c['render'][-1]==6 for c in f['models'])) + +if __name__=='__main__':unittest.main() diff --git a/tools/binary/jimmy_air_target_state.py b/tools/binary/jimmy_air_target_state.py new file mode 100644 index 0000000..2673729 --- /dev/null +++ b/tools/binary/jimmy_air_target_state.py @@ -0,0 +1,120 @@ +#!/usr/bin/env python3 +"""Read-only Jimmy destination-Euler and retained air-pitch ownership evidence.""" +import argparse +import hashlib +import json +import re +import struct +from pathlib import Path + +from checkpoint_script_state import EXE_SHA256, find_case, read_va +from pe_inspect import PE +from retained_streamer import collect as collect_streamer + +REA_ID = 'ev_0d64cc58fa8f5573fc8e61e0f2c20e36288099212bd2257d3a3121361fd6c904' +SITES = ( + ('constructor_forward_pitch', 0x437445, 'c785ec070000000020c2'), + ('constructor_backward_pitch', 0x43744f, 'c785f007000000002041'), + ('ordinary_apply_forward_pitch', 0x437fbc, 'c786ec070000000020c2'), + ('ordinary_apply_backward_pitch', 0x437fc6, 'c786f007000000002041'), + ('bubble_apply_forward_pitch', 0x43880a, 'c787ec070000000020c1'), + ('bubble_apply_backward_pitch', 0x438814, 'c787f007000000002041'), + ('destination_x', 0x472668, '898174020000'), + ('destination_y', 0x472672, '899178020000'), + ('destination_z', 0x472678, '89817c020000'), + ('destination_marks_dirty', 0x47267e, 'c6410a01'), + ('init_clears_destination_x', 0x4709ca, '898674020000'), + ('init_clears_destination_y', 0x4709d0, '898678020000'), + ('init_clears_destination_z', 0x4709d6, '89867c020000'), + ('init_enables_facing', 0x4709e2, 'c6460501'), + ('init_clears_facing_dirty', 0x4709e6, '88460a'), + ('init_other_yaw_scalar', 0x4378c1, '89961c060000'), + ('ground_auto_turn_destination', 0x43957c, 'ff926c030000'), + ('ground_auto_destination', 0x439599, 'ff926c030000'), + ('ground_ordinary_destination', 0x4395c9, 'ff936c030000'), + ('air_destination', 0x439e2d, 'ff956c030000'), + ('base_update_before_owner_gate', 0x43796a, 'e8e166fdff'), + ('raw_owner_gate', 0x437a1b, '8b0de4995000'), + ('facing_enabled_read', 0x43a433, '8a4605'), + ('facing_dirty_read', 0x43a43e, '8a460a'), + ('facing_clears_dirty', 0x43a44f, 'c6460a00'), + ('bubble_cleanup_mode', 0x42804f, '66899ec4070000'), + ('start_authored_rotation_get', 0x4239b2, 'ff9070010000'), + ('start_full_rotation_set', 0x4239e6, 'ff9674010000'), + ('authored_rotation_calls_current', 0x471702, 'ff9030030000'), + ('current_euler_x', 0x472428, '898124020000'), + ('current_euler_y', 0x472432, '899128020000'), + ('current_euler_z', 0x472438, '89812c020000'), +) +SLOTS = ((0x28,0x437890),(0x170,0x4716a0),(0x174,0x4716d0), + (0x328,0x4723f0),(0x330,0x472420),(0x334,0x458f90), + (0x36c,0x472660),(0x3d8,0x43a420),(0x410,0x42afc0)) +RANGES = ((0x437890,0x4378cc),(0x437c40,0x437f7f), + (0x43915d,0x4395cf),(0x439900,0x439e33), + (0x472660,0x472685),(0x43a420,0x43a5cd), + (0x4709c8,0x4709f8),(0x428037,0x4280cc), + (0x4239a3,0x4239ec),(0x4716d0,0x471716), + (0x472420,0x472441)) + + +def collect(root, rea_disassembly=None): + root=Path(root) + pe=PE(find_case(root,'Neutron.exe')) + if hashlib.sha256(pe.data).hexdigest()!=EXE_SHA256: + raise ValueError('Unsupported original EXE identity') + sites=[] + for name,va,expected in SITES: + actual=read_va(pe,va,len(bytes.fromhex(expected))).hex() + if actual!=expected:raise ValueError(f'Changed source {name} at {va:#x}') + sites.append(dict(name=name,va=hex(va),file_offset=hex(pe.offset(va-pe.base)),bytes=actual)) + slots=[] + for slot,target in SLOTS: + actual=struct.unpack('Signature==IMAGE_NT_SIGNATURE&&nt->FileHeader.Machine==IMAGE_FILE_MACHINE_I386&&nt->OptionalHeader.ImageBase==0x400000&&nt->OptionalHeader.SizeOfImage==0x299000,"PE identity"); + mapped=VirtualAlloc(NULL,0x299000,MEM_COMMIT|MEM_RESERVE,PAGE_EXECUTE_READWRITE);require(mapped!=NULL,"private map"); + IMAGE_SECTION_HEADER*s=IMAGE_FIRST_SECTION(nt);require((unsigned char*)(s+nt->FileHeader.NumberOfSections)<=d+n,"section bounds"); + for(unsigned i=0;iFileHeader.NumberOfSections;i++){require((uint64_t)s[i].PointerToRawData+s[i].SizeOfRawData<=(uint64_t)n&&(uint64_t)s[i].VirtualAddress+s[i].SizeOfRawData<=0x299000,"section data");memcpy(mapped+s[i].VirtualAddress,d+s[i].PointerToRawData,s[i].SizeOfRawData);}free(d); + uint32_t targets[]={0x4d6408,0x4d6410,0x696054};uint32_t ranges[][2]={{0x473540,0x4735da},{0x4802d4,0x4802f2}}; + for(unsigned r=0;r<2;r++)for(uint32_t p=ranges[r][0];p+4<=ranges[r][1];p++){uint32_t v;memcpy(&v,AT(p),4);for(unsigned i=0;i<3;i++)if(v==targets[i]){v=(uintptr_t)AT(v);memcpy(AT(p),&v,4);p+=3;break;}} + AT(0x4802ca)[0]=0xe9;int32_t delta=0x4802d4-0x4802ca-5;memcpy(AT(0x4802ca)+1,&delta,4); + *(int*)AT(0x696054)=0; +} +static void angle(const char*name,float x,float y,float z){ + unsigned char actor[0x500]={0};game=actor+0xc0;*(void**)game=angles; + *(float*)(game+0x224)=x;*(float*)(game+0x228)=y;*(float*)(game+0x22c)=z; + ((void(TC*)(void*))AT(0x473540))(game); + printf("ANGLE %s in=%.9g,%.9g,%.9g out=%d,%d,%d\n",name,x,y,z,*(int16_t*)(actor+0x50),*(int16_t*)(actor+0x52),*(int16_t*)(actor+0x54)); +} +int main(void){setbuf(stdout,NULL);map_source();angles[0x328/4]=(uintptr_t)AT(0x4723f0);angles[0x3e4/4]=(uintptr_t)AT(0x462500); + angle("zero",0,0,0);angle("forward",-40,45,-15);angle("backward",10,45,15); + angle("quarter",90,180,270);angle("revolutions",360,720,-360);angle("negative",-.5f,-40,-359.999f); + angle("fractional",.001f,359.999f,-.001f);angle("arbitrary",1.f/60,30,7.3f);angle("large",1440.75f,-725.25f,9999.99f); + angle("exact_units",45.f/2048,90.f/2048,135.f/2048);angle("canonical",360,360,360);angle("seam",359.99f,-.01f,-720.01f); + puts("JIMMY_MODEL_ANGLES_COMPLETE");return 0;} diff --git a/tools/binary/jimmy_model_bridge_probe.c b/tools/binary/jimmy_model_bridge_probe.c new file mode 100644 index 0000000..efe16f9 --- /dev/null +++ b/tools/binary/jimmy_model_bridge_probe.c @@ -0,0 +1,45 @@ +/* Original OMT compute_hxform only. Execute in an isolated copied install; + synthetic element/parent and zero dynamic offset, no renderer/game entrypoint. */ +#include +#include +#include +#include +#include +#define TC __attribute__((thiscall)) +typedef void (TC *compute_fn)(void*,void*,void*); +static unsigned char element[512];static uintptr_t table[128];static compute_fn matrix; +static void TC offset(void*self,float*x,float*y,float*z){(void)self;*x=*y=*z=0;} +static void require(int ok,const char*label){if(!ok){fprintf(stderr,"FAIL %s\n",label);exit(2);}} +static void one(compute_fn compute,const char*name,int ax,int ay,int az,float px,float py,float pz){ + float parent[15]={1,0,0,0,0,1,0,0,0,0,1,0,0,0,0},out[15]; + memset(element,0,sizeof(element));*(void**)element=table; + *(float*)(element+0x44)=px;*(float*)(element+0x48)=py;*(float*)(element+0x4c)=pz; + *(int16_t*)(element+0x50)=ax;*(int16_t*)(element+0x52)=ay;*(int16_t*)(element+0x54)=az; + for(int i=0;i<15;i++)out[i]=-999; + compute(element,parent,out); + printf("MODEL %s in=%d,%d,%d,%.9g,%.9g,%.9g out=",name,ax,ay,az,px,py,pz); + for(int i=0;i<15;i++)printf("%s%.9g",i?",":"",out[i]);puts(""); + float model[17];for(int i=0;i<17;i++)model[i]=-999;matrix(element,out,model); + printf("MATRIX %s out=",name);for(int i=0;i<16;i++)printf("%s%.9g",i?",":"",model[i]);printf(",%d\n",*(int*)(model+16)); +} +int main(void){ + setbuf(stdout,NULL);HMODULE h=LoadLibraryA("Z:\\work\\game\\OMT2.dll");require(h!=NULL,"copied OMT load"); + compute_fn f=(compute_fn)GetProcAddress(h,"?compute_hxform@OMediaElement@@UAEXAAVOMediaRenderHTransform@@0@Z");require(f!=NULL,"export"); + matrix=(compute_fn)GetProcAddress(h,"?compute_model_matrix@OMediaElement@@UAEXAAVOMediaRenderHTransform@@AAVOMediaMatrix_4x4@@@Z");require(matrix!=NULL,"model export"); + table[0x7c/4]=(uintptr_t)offset; + one(f,"upright",0,0,0,100,75.9f,-200); + one(f,"pitch90",4096,0,0,100,75.9f,-200); + one(f,"yaw90",0,4096,0,100,75.9f,-200); + one(f,"roll90",0,0,4096,100,75.9f,-200); + one(f,"air_forward",14564,2048,15702,100,500,-200); + one(f,"air_brake",455,2048,682,100,500,-200); + one(f,"full_axes",1365,2503,910,-123.5f,811.25f,70.125f); + one(f,"negative_units",-1820,-2048,-682,-123.5f,811.25f,70.125f); + one(f,"seam",16383,16383,16383,0,0,0); + one(f,"canonical360",16384,16384,16384,0,0,0); + one(f,"halfturn",8192,8192,8192,0,0,0); + one(f,"tiny",1,2,3,0,0,0); + one(f,"zero_root",14564,2048,15702,0,0,0); + one(f,"other_root",14564,2048,15702,1000,1011.25f,-2500); + puts("JIMMY_MODEL_BRIDGE_COMPLETE");return 0; +}