From a274670fe8d81f168d2262fd63b7ccebf464d755 Mon Sep 17 00:00:00 2001 From: Cristian Cerroni Date: Tue, 3 Nov 2026 11:09:16 -0500 Subject: [PATCH] Recover Rocketship flight components against original-code probes --- AGENTS.md | 10 +- docs/architecture.md | 14 + docs/compatibility.md | 9 + docs/decisions.md | 9 + docs/gameplay/grappler.md | 123 ++++++ docs/gameplay/rocketship-assets.md | 97 +++++ docs/gameplay/rocketship-component.md | 75 ++++ docs/gameplay/rocketship.md | 167 ++++++++ docs/progress.md | 28 ++ docs/reverse-engineering.md | 13 + docs/tasks.md | 20 +- scripts/test.sh | 1 + src/GamePort/Game/RocketFlight.cs | 110 +++++ .../GamePort.RocketFlightTests.csproj | 8 + tests/GamePort.RocketFlightTests/Program.cs | 194 +++++++++ .../original-input-reference.json | 381 ++++++++++++++++++ .../original-vertical-reference.json | 329 +++++++++++++++ tests/test_grappler.py | 86 ++++ tests/test_rocketship.py | 49 +++ tests/test_rocketship_resources.py | 101 +++++ tools/binary/grappler.py | 188 +++++++++ tools/binary/rocketship.py | 311 ++++++++++++++ tools/extractors/rocketship_resources.py | 141 +++++++ 23 files changed, 2462 insertions(+), 2 deletions(-) create mode 100644 docs/gameplay/grappler.md create mode 100644 docs/gameplay/rocketship-assets.md create mode 100644 docs/gameplay/rocketship-component.md create mode 100644 docs/gameplay/rocketship.md create mode 100644 src/GamePort/Game/RocketFlight.cs create mode 100644 tests/GamePort.RocketFlightTests/GamePort.RocketFlightTests.csproj create mode 100644 tests/GamePort.RocketFlightTests/Program.cs create mode 100644 tests/GamePort.RocketFlightTests/original-input-reference.json create mode 100644 tests/GamePort.RocketFlightTests/original-vertical-reference.json create mode 100644 tests/test_grappler.py create mode 100644 tests/test_rocketship.py create mode 100644 tests/test_rocketship_resources.py create mode 100644 tools/binary/grappler.py create mode 100644 tools/binary/rocketship.py create mode 100644 tools/extractors/rocketship_resources.py diff --git a/AGENTS.md b/AGENTS.md index 5c58aeb..7ea1423 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -46,7 +46,15 @@ changes. Current gadget controls/resources/primary-fire findings belong in docs/gameplay/. Distinguish static recovery, implementation, port tests and original runtime evidence. Main owns integration/runtime; gadget investigators have exclusive named files, not shared directories. -Latest continuation: docs/gameplay/baseball-implementation.md. Baseball's20-slot +Latest continuation: docs/gameplay/rocketship-component.md. Rocketship input and +vertical arithmetic are isolated/tested against28 copied-original observations; +the vehicle is not live. Close its aircraft collision, Euler/camera and owned +helper/attachment lifecycle gates before VR02 integration. Grappler source is in +docs/gameplay/grappler.md; no approximate hook/pull mechanic is enabled. Friend +research assessment is docs/reviews/jn-engine-survey.md; use its decompiler leads +with REA/source checks, not its tuned C gameplay. All ownership has returned. +Playable package baseline remains d6ca417; no package rebuild for this component. +Baseball continuation: docs/gameplay/baseball-implementation.md. Its20-slot pool, hold/release aiming, original TIME art and boundedVR07 moving targets are implemented; original dynamic pair discovery/other enemy consumers remain open. Scooter recovery is saved in docs/gameplay/scooter.md; do not invent wheel supports. diff --git a/docs/architecture.md b/docs/architecture.md index 77ba4bb..52a740c 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -270,3 +270,17 @@ and queued work are not cleared by a transform setter. The original full wrapper registry, body response and morph clock are still not reconstructed by this bridge. See checkpoint/control-phase-implementation.md. REA tooling is separate from runtime architecture; setup/provenance are in rea.md. + +## Isolated vehicle components + +RocketFlight separates ordinary keyboard scalar/bank input from vertical +acceleration publication. The source applies retained state before the controlled +input/camera callback. It neither integrates a body nor owns a camera/passenger; +no live runtime path calls it yet. Twenty-eight isolated copied-original numeric +references support its bounded arithmetic. Aircraft callbacks, full Euler/camera, +owned-versus-placed property/reset and helper lifetime remain gates before an +explicit vehicle owner is added to PlayerSceneBinding/director scheduling. +The exact resource exporter is opt-in and assigns no attachment transforms. +See gameplay/rocketship-component.md. Grappler's distinct source ownership and +geometry/material/swing contract is in gameplay/grappler.md; it is not a simple +player movement mode or nearest-tag interaction. diff --git a/docs/compatibility.md b/docs/compatibility.md index 7bfa5a2..80c83c1 100644 --- a/docs/compatibility.md +++ b/docs/compatibility.md @@ -3,6 +3,15 @@ Compilation, native runtime, original behavior and full feature completion are separate evidence categories. **The game is not fully reconstructed/playable yet.** +Rocketship component/Grappler recovery (2026-11-03): isolated keyboard/vertical +math matches28 copied-original Wine32 observations across13 managed groups. +Rocket source3/resource5/Grappler12 and existing Gadget15/Movement25 groups pass; +main .NET10 build succeeds with the existing NU1900 metadata warning.539 originals +verify unchanged. Exact resource export remains opt-in; no live vehicle/Grappler, +new Vulkan/native Windows or whole-original gameplay verification is claimed. +No package rebuild: playable d6ca417 remains baseline. Next live gates and full +scope are recorded in gameplay/rocketship-component.md. + Supplied jn-engine assessment (2026-11-03): documentation/source/artifact review only; no new build or runtime validation. Same declared EXE, different declared OMT2.dll;254 ASE/126 PNG/35 GAM files match byte for byte. All539 original hashes diff --git a/docs/decisions.md b/docs/decisions.md index 8c19a6e..d5cf398 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -239,3 +239,12 @@ evidence. Capture tooling/derived scenes are present; raw OMTC, analysed Ghidra database and proposed gameplay state traces are not. Record offered permission before source import. Assessment: reviews/jn-engine-survey.md. +42. **Verify vehicle arithmetic before connecting live ownership.** RocketFlight + preserves per-callback input acceleration, support/brake ordering and retained + vertical-command publication, compared with28 isolated copied-original cases. + Radius50 is collision size, not render scale; rates650/−650 are acceleration, + not assigned velocity. Do not substitute Jimmy's body/camera for aircraft + callbacks or claim the scalar component is a live Rocketship. Resolve owned + versus placed properties, passenger/effect lifetime and control/camera phase + before VR02 integration. Grappler's geometry/material/swing contract likewise + forbids nearest-hook/direct-pull replacement. See gameplay/rocketship-component.md. diff --git a/docs/gameplay/grappler.md b/docs/gameplay/grappler.md new file mode 100644 index 0000000..8d7e3e1 --- /dev/null +++ b/docs/gameplay/grappler.md @@ -0,0 +1,123 @@ +# Grappler source contract and integration gate + +2026-11-03. Item7/raw7, using the supplied target6 decompiler bodies as leads, +then independently reading the hashed EXE instructions. No friend gameplay code +imported. Static recovery and twelve Python source/projection tests only: no live +Grappler, original gameplay execution or Windows validation is claimed. + +## Identity, REA and guarded evidence + +Neutron.exe SHA256 is `f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8`. +All addresses below are preferred-base EXE virtual addresses; for these text spans +the file offset is VA−400000. `tools/binary/grappler.py` guards twelve spans, +three virtuals, two dispatch entries, sixteen constants and four strings; +`artifacts/grappler-contract/source.json` records each exact offset/hash. + +REA6.8.0/Ghidra12.1.4 with project launcher/profile +`e1ad533d4cc0333c2136fe0894217de2d61feea098240326e78633f9e4ddcbf9` +decompiled jump predicate42A730, Evidence +`ev_4c43cfa8fa5d66c31111d49510aba391f069b446160a448c5544ea042dd452c4`. +Complete replies/export/snapshot are in +`artifacts/grappler-contract/rea-trajectory-20261103/`. +426A70's VA selector failed fallback file mapping; corrected offsets26A70, +29D00 and29C10 mapped correctly but have no recognized procedures in this +default Ghidra analysis. Those explicit errors are retained separately under +`rea-trajectory-offset-20261103/`; no identical retry followed. The older +`rea-controller/` attempt had an IPC denial. This run used the permitted local +Unix socket access and closed both owned sessions. No REA/config repair occurred. + +Supporting decompilation is `../../../jn-engine-master/docs/decomp/evidence/ +c3djimmy_target6.md`, helpers426A70/429D00/429C10. Its forced `__thiscall`, +`unaff_retaddr` and uninitialized aliases are not ABI proof. Byte-guarded objdump +and known game-interface helpers establish the contracts below; full-Euler/x87 +and body execution still need separate references. + +## Owners and fields + +Jimmy complete pointer owns game interface+C0. Complete vtable4A3BDC has +188→429D00 (swing/aim),1C0→426A70 (held primary),204→429C10 (detach). +These offsets are distinct from movement mode complete+7C4. + +| Owner | State and evidence | +|---|---| +| Jimmy complete+B0C | Owned C3DGraplingHook: ctor41EEB0 called422800, pointer stored422810, named at422821..82C; not a nearest serialized hook actor | +| Jimmy complete+B14 | Owned C3DTargetCursor: ctor4453B0 called42255B, stored42256B, named/hidden42257C..59D | +| Jimmy complete+A1C | Companion hidden and movement/collision disabled on equip/attach; cleanup restores only under its own9E8/visibility gates | +| Jimmy complete+1E04 | Loop34 audio handle;−1 sentinel; also touched by pre-mode-check swing helper | +| Globals4F8210/4F82CC | Attached byte / signed16 anchor index; constructor422761/767 initializes zero | +| Global4F8214+index*16 | Float4 anchor, copied from ray hit5CFC60 at426BA7..BD6; no tagged target search | +| Globals4F82B4/B8 | First rope length/current rope length; constructor zeroes both; first-length/scaling write only when B4==0 | +| Globals4F82BC/C0/C4/C8 | Horizontal swing scalars, elapsed damping time, fast-reel target | +| Jimmy complete+864 | Set on attach, cleared detach/cleanup; retain as an action flag until inherited consumers are fully recovered | +| Jimmy complete+7C8..7E0,854..85C | Follow eye/target and smoothing fields changed during equip/attach/detach | + +Constructor zeroes the first anchor XYZ and scalars at42276E..7BE. Neither +guarded detach nor raw7 cleanup clears first lengthB4. Full helper persistence +through retained level loads remains a separate lifetime question. The indexed +region permits multiple slots by address arithmetic; do not invent a wrapping +rope/anchor stack: the bounded EXE references inspected show initialization and +reads of index, with no proven advancing writer. + +## Input/update and state transitions + +426030 receives Jimmy's game interface. After modal/game/control gates it runs +438A60 input then complete188→429D00 at426098; a true result ends Jimmy's active +controller pass. Held primary later reaches1C0→426A70 at4266C8 before the common +energy helper1C4 at4266DB. Thus Grappler attachment has no local energy charge and +precedes that shared zero-energy reject. Do not add an energy cost from menu index. + +- **Equip:** jump-table4298E8 slot8 selects4297DD; hide/disable companion, + follow eye(0,50,−350), target(0,150,80), raw mode7. Optional inventory/menu + tutorial command9B remains its own branch. +- **Aim:** 429D00 samples root+Y116. After mode7's fast reel and optional jump + detach, its end portion performs a geometry ray from current root to full-Euler + local point(0,2400,2400), helper47C210. Distance<450 hides cursor and returns + true. Selected-polygon material IDs60..69,80..89,210..219,−1,170 also hide/block. + Polygon without material blocks; material without definition passes this test; + absent selected polygon passes it. A valid cursor is placed100 back from the + hit along ray direction. This is not a query for the nearest3GRA entity. +- **Attach / held primary:**426A70 returns false outside raw7; otherwise consumes + primary even on a miss. While unattached it stops+A3C, repeats the root/local + point ray, stores hit anchor, sets current length=distance(root,hit)−100. + If B4==0, scale rope Z by length/600 and preserve first length. Set attached + byte and+864, reset jump word+7E8 and linked jump effect+6C0, emitSFX31, restart + loop34, clear horizontal swing/time, preserve velocityX/Z but setY100. + Fast-reel target=anchorY−rootY−200; eyeY400/Z−650, smoothing(.8,1,.8). +- **Reel:** when already attached and old length>250, subtract250*dt and ensure + loop34. Otherwise stop loop34. There is **no final250 clamp**. Swing helper + independently subtracts950*dt when target=double.2, clamp each±50, multiply .95 when + length<350 else .98, then subtract float.2 **once**, not in a while loop. + Rope model orientation/placement and a separate shadow down-ray are also owned + here. This depends on full Euler/table math and body/camera shared context. +- **Detach:** independent jump predicate42A730 with attached and no held fire + calls204→429C10. Clear attachment/+864, restore eye(0,50,−350), target(0,130,100) + and smoothing(1.6,1,1.6). Multiply swing globals by.96 but **set body velocity + to(0,0,0)**, selectFALL, stop loop34 and hide rope. No invented launch impulse. +- **Collision:** game-interface override42A660 calls base43AA40, clears horizontal + swing and releases if their prior magnitude>60; pointer adjustment−C0 reaches + complete204. Shared collision dispatch/callback ownership remains a live gate. +- **Unequip:** raw7 cleanup4287AC restores eligible companion, detaches, restores + ordinary camera170, clears attached/+864, hides cursor; common tail sets raw−1. + +## Implementation boundary and verification + +The twelve Python tests verify byte identities, selected-material range edges and +missing-material branches, accepted-hit scalar initialization/reattach retention, +250/950 overshoot behavior, damping threshold/clamp/one-step timing and independent +jump/fire release. Host arithmetic projections explicitly omit x87 intermediate +precision, actual ray traversal, body/camera/actor execution. They do not establish +original runtime parity. + +Safe now: use these isolated scalar rules and ownership map as implementation +contracts/tests. **Do not enable live Grappler as nearest-hook/direct pull.** Close +full-Euler ray/filter and selected-material context in VR08; body47B4B0 under +attached state including callback42A660; model/pose placement and shared camera +ownership; fresh/retained helper lifetime and control-loss cleanup. B4's first +length retention and simultaneous jump/fire are necessary regressions. REA's +missing function boundaries could be addressed on a copied analysis project using +the supplied explicit-boundary approach, without blindly trusting forced ABI. diff --git a/docs/gameplay/rocketship-assets.md b/docs/gameplay/rocketship-assets.md new file mode 100644 index 0000000..e428154 --- /dev/null +++ b/docs/gameplay/rocketship-assets.md @@ -0,0 +1,97 @@ +# Rocketship resources and VR02 authored data + +2026-11-03. Read-only original asset inspection plus exact resource export. +No original binary executed; no original/friend-tree changes. Binary ownership, +physics, transforms, animation timing and material flags belong to +[Rocketship recovery](rocketship.md), not to geometric compatibility. + +`tools/extractors/rocketship_resources.py` exposes +`export_rocketship(original, output)`. It validates all12 source hashes, ASE +sample/topology and decoded RGBA identities before writing a separate directory. +It rejects original subtrees/ancestors and existing descendant symlinks. Four +source-named animation manifests reference exact original PNG pixels; no family +action names, transforms, invented UVs, interpolation or material flags are set. +Generated data: `artifacts/rocket-assets/resources/rocketship.json`. + +```bash +python3 tools/extractors/rocketship_resources.py ../Original --output artifacts/rocket-assets/resources +python3 -m unittest discover -s tests -p test_rocketship_resources.py -v +``` + +## Meshes and textures + +Coordinates use the existing independently matched ASE conversion `(x,z,y)`, +texture `(u,-v)`; exporter preserves sample positions. Original smoothing remains +unrecovered; existing ASE exporter reconstructs flat normals. + +| Source | Indexed vertices / faces | Exact source sample times | fps / ticks per frame | Texture topology | +|---|---|---|---|---| +|strato.ASE / strato01|159 /262|0|30 /160|Own497 UVs,262 texture faces| +|firestrato.ASE / Cylinder01|7 /6|0,480,960|10 /480|Own10 UVs,6 texture faces| +|jimdrive.ASE / 01jimmy|426 /814|0,480|10 /480|No UVs; original jimstop426 base| +|godrocket.ASE / point|222 /411|0,960,1920|5 /960|No UVs; original godpoint222 base| + +The two morphs retain the base's faces/UVs by vertex index, matching existing +original-morph exporter semantics. This establishes renderable resource +compatibility; runtime DRIVE/ROCK selection/attachment still needs binary proof. +The three godrocket samples share bounds but contain different indexed positions; +retain all samples rather than treating identical bounds as a static clip. + +| Exact PNG | Size | Decoded RGBA SHA256 | +|---|---|---| +|strato.png|256×256|`b1b18454fe0413e3ce885a61e4407c808060da0fe29ef2aec26ccd4e39437f31`| +|fire.png|100×100|`07dbbc4c6b99b6fa5fe424f2f917e03352a9c635fdc1593fc12f354be83a9a7f`| +|jimycarl.png|256×256|`5e54ccb99e9e060843cd7f80fd93ff8bf47f8779666e41d4240398354a278a3f`| +|goddard02.png|256×256|`9eb24c8fa41ddf08d2f33dd7b7513b632d4262cfc26cab3383c54258b9647a62`| + +Retained REA body-init43DD10 Evidence +`ev_d7bf671456c93939ac04ab612e10181e729e078de4bfc06b22f4b5302d71da00` +(`artifacts/rocket-contract/rea-core/00.json`) verifies HIDEFAULT→Strato.ase, +strato.png, DEFAULT and game110(50.0). EXE VAs in this range map to file offset +VA−400000. The source setter110→471240 establishes50 as body radius; it is not +a visual scale. Constructor4192E0 also binds DEFAULT→firestrato.ASE/fire.png; +see the accompanying Rocketship source report for guards/Evidence. Driver/dog +resource candidates are exported without +asserting their runtime state/visibility/material bindings. Do not substitute +rocket.ASE, rocketfire.ASE or objects.omt shape26 merely because their names +sound appropriate; their topology differs from this recovered Strato binding. + +## VR02 and campaign corpus + +All35 supplied GAMs were parsed.32 contain one3ROC; Level3B/3E and VR08 do not. +Two independent3FLA records occur in Level2 (offset7267) and Level2b (4C20), +not VR02; this does not count constructor-owned fire children. Complete observed +placement values are retained in `artifacts/rocket-assets/placements.json`. + +VR02.gam SHA256 +`3be92e270bd14e6fc41db702e68c894562128d23d46704b89f7abb1914bebc5c`. +All18 entity records/ordinals/property bytes/offsets are retained in the manifest. +Its sole3ROC is ordinal1, file offset1CD; position +`(445.8588257,74.9721756,598.4440918)`, yaw9.9755859375, TaskNameLIBBY. +Authored fields: MaxHeight3900, MaxSpeed1400, AccelRate400, DecelRate1, Up650, +Down−650, MaxVertVelocity650, NewGravity0, AccelLean20, DecelLean−20. These +values do not define the flying algorithm or active Jimmy-owned rocket spawn. + +PHONEBOOTH/STRT points at intro3MCA `rs`; the source intro target list is +rs1/rs2/rs3/Jim1. There are **two rs1 patrol entities**, ordinals13/15, +offsets23DE/2C09. Preserve distinct records and original lookup behavior; do not +deduplicate tags or assume which position the original resolver chooses. Seven +3PIC records use indices3101..3107; LOAD offset21B9 targets RETURN with radius400. + +VR02.omt SHA256 +`ab041f663cd5e68d58e590feeb7661f308a70ccc682a32c49ccd82b74bec61c0`. +One shape0 `Box01`, offset74464,93802 bytes,424 indexed vertices/880 triangle +polygons; no NC-named shape. Material counts:0→160,2→96,3→192,5→400,null→32. +Retain the32 textureless polygons in collision data; absence of special Jimmy +materials alone does not prove game-class registration or flying-body admission. +The current route camera/static-body factory also excludes VR02 pending those +source gates. Resource export does not change that factory. + +## Verification and remaining boundaries + +Five resource checks pass: exact pixels/source sampling and mesh indices, +base-topology UV/sample-position binding, VR02 offsets/duplicate tags/null +polygons, protected output paths and changed-source/pixel rejection before output. +Standalone CLI export succeeds. No port gameplay, Vulkan, native Windows or +full original-runtime comparison is claimed by these checks. Main owns shared +prepare/package wiring; resources are currently opt-in via the new exporter. diff --git a/docs/gameplay/rocketship-component.md b/docs/gameplay/rocketship-component.md new file mode 100644 index 0000000..56e0d02 --- /dev/null +++ b/docs/gameplay/rocketship-component.md @@ -0,0 +1,75 @@ +# Rocketship arithmetic and resource checkpoint + +2026-11-03. Continued gadgets after the supplied jn-engine assessment c6eb186. +Kept the playable d6ca417 source/packages and parked collision baseline intact. +Independent investigators owned Rocketship source, resources and Grappler source; +primary reviewed/integrated their files. All ownership has returned. + +## Implemented and tested + +`src/GamePort/Game/RocketFlight.cs` implements ordinary keyboard scalar/bank input +from41A6C0 and vertical publication from41A470..41A6A8. It is an isolated component, +not a connected live vehicle. Input updates retained state after application in +the ordinary source update; no input-before-integration reorder was introduced. +Caller owns body integration, X/Z vectors, facing and camera state. + +Important source behavior preserved: + +- Acceleration400 is per callback; support loss500*dt follows it. Down brakes + even with Up held, then Up wins the published vertical flags. +- Bank changes160*dt, clamps±45, and prior keyboard bank returns at130*dt. +- Up/Down650/−650 are acceleration commands, not direct velocities. Publication + subtracts global gravity; current velocity independently clamps±650. +- Below speed100, prior vertical command survives and the height clamp is skipped. + At the ceiling, root Y clamps but positive Vy survives; neutral snapping uses + a strict(−60,60) band. + +Two isolated copied-original probes establish14 input-prefix and14 vertical-suffix +references. Generated Win32 harnesses used synthetic mouse/support/transform/audio +or body accessors, skipped camera/horizontal/integration paths and ran in separate +Wine32 namespaces. Original entrypoint/gameplay did not execute. Source bounds, +REA Evidence, file offsets and complete provenance are in +[rocketship.md](rocketship.md) and `artifacts/rocket-contract/`. + +Numeric fixtures in `tests/GamePort.RocketFlightTests/` retain source, body, +generator, executable and log hashes. Thirteen managed groups compare all claimed +scalar/flag outputs with absolute tolerance.0002, reject nonfinite comparisons, +and cover phase/threshold/priority/invalid-input cases. Destination Euler and +source-preserved X/Z values are outside this scalar API's comparison. The test +is registered in `scripts/test.sh`; no live simulation path uses the component +yet. No bit-identical general x87 or original cadence claim is made. + +`rocketship_resources.py` exports exact Strato/firestrato geometry, compatible +Jimmy/Goddard morph samples, PNG pixels and VR02 records after12 source hashes and +topology/pixel checks. Five tests cover output protection and resource identity. +It remains opt-in; shared preparation/package resources were not changed. + +## Research integrated + +[Rocketship source](rocketship.md) establishes Jimmy's owned ship, rider/control +handoff and cleanup, radius50/factor.6/friction.8, FireStrato binding and VR02's +false game polygon filter. The friend's label “visual scalar50” was corrected +through the original setter. Live body/factory admission remains unchanged. + +[Grappler source](grappler.md) establishes owned rope/cursor, full-Euler ray and +material gates, attach/reel/swing/detach ordering and retained first rope length. +Twelve Python source/projection checks pass. No nearest-hook/direct-pull mechanic +or friend gameplay code was imported. Guarded tools also preserve provider gaps; +the existing local REA launcher was used without configuration changes. + +Validation:13 Rocket managed groups,3 Rocket source groups,5 resource groups, +12 Grappler groups,15 existing Gadget and25 Movement groups pass. Main .NET10 build +passes with the existing NU1900 unavailable metadata warning;539 original hashes +verify unchanged. Independent read-only review agrees with the declared component +scope. No new Vulkan/live gameplay/native Windows checks or package rebuild was +needed or claimed; prior playable releases remain the user testing baseline. + +## Next coherent chunk + +Close the aircraft-specific370/374/378 collision callbacks, normal Euler/slip/ +roll/facing and shared camera record update. Establish owned-versus-placed3ROC +property/reset behavior and retained helper lifetime. Then integrate explicit +vehicle ownership, passenger/Goddard/fire transforms and audio, mount/cleanup, +VR02 live body and F1 controls, with input/unequip/control-loss/RETURN regressions. +The source radius/support alone cannot justify using Jimmy's body/camera as a +vehicle replacement. Grappler's body/camera/material-context gates remain separate. diff --git a/docs/gameplay/rocketship.md b/docs/gameplay/rocketship.md new file mode 100644 index 0000000..b794725 --- /dev/null +++ b/docs/gameplay/rocketship.md @@ -0,0 +1,167 @@ +# Rocketship ownership and bounded flight components + +2026-11-03. Original static recovery, guarded bytes and two isolated original +component probes. Friend research supplied useful class/function names; its +prototype vehicle mechanics were not imported. No live vehicle implementation +or original whole-game/native Windows verification is claimed by this report. +Primary owns any modern integration and its separate validation. + +## Evidence and identity + +EXE SHA256 `f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8`. +`tools/binary/rocketship.py` guards ten source spans, six virtual targets and eight +constants, with PE-mapped file offsets in +`artifacts/rocket-contract/source-contract.json`. These .text VAs map to raw +offset VA−400000. Full disassembly windows are retained beside the report. +No friend OMT2.dll address is assumed applicable to our different DLL build. + +| Source | REA Evidence | Retained path | +|---|---|---| +|43D840 constructor|`ev_0f31a079ff84847fd27d3e41de320d6bedddcbf3917b5f3e2b345773809a0b86`|rocket-contract/rea-core/01.json| +|43DD10 visual/body init|`ev_d7bf671456c93939ac04ab612e10181e729e078de4bfc06b22f4b5302d71da00`|rocket-contract/rea-core/00.json| +|41A140 apply|`ev_ba8607f59d6ebc468cd956e6b1c8d295eecb21889055130da4706e6cbc8e6ba2`|rocket-contract/rea-flight-ipc/00.json| +|41A6C0 input/camera|`ev_ef4490ca220408f61e74f4d122b472f9055475ec4b51e2446620a54ffd1c7b2c`|rocket-contract/rea-flight-ipc/01.json| +|43E7E0 controlled callback|`ev_20502f86a5c3c7bee2ea47608f89d578286785d1ba540b5fa7f7e56ed90505a0`|rocket-contract/rea-flight-ipc/04.json| +|4192E0 fire constructor|`ev_4f74f2325cf84e07d75696f1903bfff3800a02f9b6b706431a5b90b66a83c914`|rocket-contract/rea-flight-ipc/05.json| + +Paths in that table are below `artifacts/`. Complete replies, bundles and closed +snapshots are retained. Initial `rea-flight/` failed at the known local Unix +socket sandbox boundary; one IPC-authorized retry succeeded.43DB10/43DF70 still +are not recognized as procedures in that profile; their saved errors are not +pseudocode evidence. Their bounded source instructions are guarded/reviewed. +419550 was queried as a possible effect initializer but is Flag construction; +it is not used to establish Rocketship behavior. No configuration was changed. + +## State ownership, selection and cleanup + +Jimmy's complete object owns a separate Rocketship allocation at+AB0, initialized +through constructor43D840; complete vtable4B2A4C, game-interface +vtable4B25AC at complete+C0. The ship's complete+740/interface+680 is a pointer to +the **complete Jimmy rider**, resolving the friend's unnamed linked-actor field. +Twenty other linked slots retain a separate unresolved effect/child role. + +Item1 branch42944D..429686 uses this owned pointer; there is no nearest placed +3ROC search. It activates the ship, copies Jimmy root/Euler via game310/328 into +ship318/330, transfers game118 control to ship+C0 at4295A5, stores rider+740 at +4295B4, disables Jimmy physical participation through1E4, hides/disables relevant +companion flags, selects Jimmy DRIVE and writes raw gadget1 at42967F. Null owned +pointer skips this equip body. Availability/HUD commands remain separate. + +Raw1 cleanup428512..42871D disables/hides ship flags, restores Jimmy game118 +ownership at4285BA, restores companion policy, clears ship+740 at4286AE, clears +Jimmy acceleration/velocity, selects the normal animation/movement state, closes +HUD mode and writes raw−1. The original raw cleanup belongs to ownership change, +not just a rendered model toggle. Retained helper life and unmount-root timing +need the ordinary update/loader context before live integration. + +43DD10 game110→471240 initializes authored34 and live15C **radius50**, not a visual +scale50.43D840 sets factor float32(.6); inherited419B70 sets friction float32(.8). +Thus ordinary radius×factor support clearance is30, distinct from Jimmy75.9. +Shape transforms/render scale are separate. This corrects the friend report's +"visual scalar" label. No wheel child construction was observed. + +## Input/apply ordering and exact bounded arithmetic + +Rocket registry update43DF70 calls inherited41A140 before its passenger/effect +tail. Controlled callback43E7E0 gates on407060 false and475CA0 true, then invokes +41A6C0, optionally updates a fire-held timer and calls rider complete1AC with dt. +**Apply consumes retained input state; input does not integrate the body.** + +Offsets below are relative to the game interface (game pointer=complete+C0; +addC0 to these offsets for complete-object fields): speed608, bank614, +previous bank618, cap604, max height620, +up/down638/639, prior keyboard-bank flag63A, vertical command65C, mouse pitch66C. +The shared flying properties include acceleration5FC400, deceleration6001, +cap6041400, height620, rates624650/628−650 and velocity cap62C650. Inherited +constructor defaults are distinct from GAM reapplication and level-specific259 +overrides;43DCE1 writes VR02 max height3900. + +Keyboard/zero-mouse41A6C0 order: + +1. Left bank +=160dt; else Right -=160dt. After keyboard release a retained + keyboard-origin bank approaches0 at130dt. Mouse-origin bank has no such return. +2. Up adds AccelRate **per callback** if below cap, then clamps cap. Without Up, + speed>cap×float32(.90909094) loses DecelRate×.5 per callback. +3. Supported state independently subtracts500dt, clamped0, even with Up held. +4. Down subtracts DecelRate×dt if supported or DecelRate×.1 in air from positive + speed; negative speed adds DecelRate toward0. Up+Down still performs this + braking, then Up clears the published Down flag. Bank clamps to±45. + +Source Up/Down keys are50985E/509860, Left/Right50985D/50985F. Analog thresholds +are strictly>.5/<−.5. Right mouse509834 and accumulated mouse pitch>15 also give +Up;50993A or pitch<−15 give Down. Mouse Y accumulates×dt and moves toward the +±10 band by20dt outside it. Nonzero mouse X supplies bank delta×dt instead of +keyboard steering. Boost/barrel-roll globals and complete camera tail remain +outside the primary keyboard component; do not expose ordinary keyboard scope +as complete input support. + +41A470..41A6A8 vertical publication is independently recoverable: + +- speed<100 preserves prior65C and skips the height decision. +- At speed>=100, rootY>=MaxHeight clamps root only and sets command0, or DownRate + if prior Down. Below ceiling, prior Up/Down selects their respective command. +- Neutral uses−160 for Vy>0,+160 otherwise; strict−60 +/// Bounded ordinary keyboard branch of C3DFlyingObject41A6C0. Input updates +/// retained scalars/flags after41A140's application in the ordinary update. Mouse, +/// analog, boost/roll, camera and body integration are separate contracts. +/// See gameplay/rocketship.md; this component does not enable a live vehicle. +/// +public static class RocketFlight +{ + public static RocketSteering StepKeyboardInput(RocketSteering state, PlayerInput input, + bool supported, float seconds, RocketFlightTuning tuning) + { + Validate(tuning, seconds); + if (!float.IsFinite(state.Speed) || !float.IsFinite(state.Bank)) + throw new ArgumentOutOfRangeException(nameof(state)); + + var bank = state.Bank; + var keyboardBank = state.KeyboardBank; + if (input.Left) { bank += 160 * seconds; keyboardBank = true; } + else if (input.Right) { bank -= 160 * seconds; keyboardBank = true; } + else if (keyboardBank) + bank = bank < 0 ? MathF.Min(0, bank + 130 * seconds) : MathF.Max(0, bank - 130 * seconds); + + var speed = state.Speed; + //41A8C2: acceleration is per callback, unlike the later500*dt support + //loss. Do not convert it into a conventional acceleration-per-second. + if (input.Forward) + { + if (speed < tuning.MaximumSpeed) speed = MathF.Min(tuning.MaximumSpeed, speed + tuning.Acceleration); + } + else if (speed > tuning.MaximumSpeed * .9090909361839294f) + speed -= tuning.Deceleration * .5f; + + if (supported) speed = MathF.Max(0, speed - 500 * seconds); + + //41A9CA: Down still brakes when Up is also held; Up only wins the + //published vertical flag after this scalar update. + if (input.Backward) + { + if (speed > 0) speed = MathF.Max(0, speed - tuning.Deceleration * (supported ? seconds : .1f)); + else if (speed < 0) speed = MathF.Min(0, speed + tuning.Deceleration); + } + return new(speed, Math.Clamp(bank, -45, 45), keyboardBank, + input.Forward, input.Backward && !input.Forward); + } + + /// + ///41A47F..41A6A8 vertical publication only. World/body integration precedes + /// this callback; UpRate/DownRate are requested acceleration, not velocity. + /// The below100 branch retains65C and does not clamp height. The height + /// clamp changes root Y, not the current velocity. Caller retains X/Z. + /// + public static RocketVerticalStep StepVertical(RocketVerticalState state, + RocketSteering steering, RocketFlightTuning tuning, float gravity) + { + ValidateTuning(tuning); + if (!float.IsFinite(state.Height) || !float.IsFinite(state.Velocity) + || !float.IsFinite(state.CommandedAcceleration) || !float.IsFinite(steering.Speed) + || !float.IsFinite(gravity)) throw new ArgumentOutOfRangeException(nameof(state)); + + var height = state.Height; + var velocity = state.Velocity; + var command = state.CommandedAcceleration; + if (steering.Speed >= 100) + { + if (height >= tuning.MaximumHeight) + { + height = tuning.MaximumHeight; + command = steering.Down ? tuning.DownRate : 0; + } + else if (steering.Up) command = tuning.UpRate; + else if (steering.Down) command = tuning.DownRate; + else + { + command = velocity > 0 ? -160 : 160; + if (velocity > -60 && velocity < 60) { velocity = 0; command = 0; } + } + } + velocity = Math.Clamp(velocity, -tuning.MaximumVerticalSpeed, tuning.MaximumVerticalSpeed); + return new(new(height, velocity, command), command - gravity); + } + + private static void Validate(RocketFlightTuning tuning, float seconds) + { + if (!float.IsFinite(seconds) || seconds <= 0 || seconds >= 1) + throw new ArgumentOutOfRangeException(nameof(seconds)); + ValidateTuning(tuning); + } + + private static void ValidateTuning(RocketFlightTuning tuning) + { + if (!float.IsFinite(tuning.Acceleration) || tuning.Acceleration < 0 + || !float.IsFinite(tuning.Deceleration) || tuning.Deceleration < 0 + || !float.IsFinite(tuning.MaximumSpeed) || tuning.MaximumSpeed <= 0 + || !float.IsFinite(tuning.MaximumHeight) || !float.IsFinite(tuning.UpRate) + || !float.IsFinite(tuning.DownRate) || !float.IsFinite(tuning.MaximumVerticalSpeed) + || tuning.MaximumVerticalSpeed < 0) + throw new ArgumentOutOfRangeException(nameof(tuning)); + } +} diff --git a/tests/GamePort.RocketFlightTests/GamePort.RocketFlightTests.csproj b/tests/GamePort.RocketFlightTests/GamePort.RocketFlightTests.csproj new file mode 100644 index 0000000..cc27f95 --- /dev/null +++ b/tests/GamePort.RocketFlightTests/GamePort.RocketFlightTests.csproj @@ -0,0 +1,8 @@ + + Exenet10.0 + enableenablefalse + + + + + diff --git a/tests/GamePort.RocketFlightTests/Program.cs b/tests/GamePort.RocketFlightTests/Program.cs new file mode 100644 index 0000000..18d881e --- /dev/null +++ b/tests/GamePort.RocketFlightTests/Program.cs @@ -0,0 +1,194 @@ +using GamePort.Game; +using System.Text.Json; + +var checks = new (string Name, Action Check)[] +{ + ("acceleration is per callback and does not pull an overspeed value down", Acceleration), + ("support loss follows acceleration, including both vertical keys", SupportOrder), + ("coast threshold is strict and loss is per callback", Coasting), + ("braking depends on support and clamps both signs", Braking), + ("Up wins published flags after simultaneous Down braking", BothDirections), + ("left precedence, bank limits and prior keyboard release", Bank), + ("vertical rates publish acceleration after compensating gravity", VerticalCommands), + ("strict neutral velocity band and symmetric existing velocity cap", VerticalBand), + ("height clamp retains velocity and allows Down acceleration", HeightClamp), + ("low scalar retains acceleration and skips height clamp", LowSpeed), + ("fourteen copied-original input-prefix numeric references", OriginalReferences), + ("fourteen copied-original vertical-suffix numeric references", OriginalVerticalReferences), + ("state, tuning and timestep admission", Invalid), +}; +foreach (var (name, check) in checks) { check(); Console.WriteLine($"PASS {name}"); } +Console.WriteLine($"Rocket flight checks: {checks.Length} passed. Recovered arithmetic; not live/original gameplay verification."); + +static RocketFlightTuning Tuning() => new(400, 1, 1400, 3900, 650, -650, 650); +static PlayerInput Input(bool up = false, bool down = false, bool left = false, bool right = false) + => new(up, down, left, right, false); +static RocketSteering Step(float speed = 0, PlayerInput input = default, bool supported = false, + float dt = .1f, float bank = 0, bool keyboardBank = false) + => RocketFlight.StepKeyboardInput(new(speed, bank, keyboardBank), input, supported, dt, Tuning()); + +static void Acceleration() +{ + Near(Step(input: Input(up:true), dt:.01f).Speed,400,"short callback"); + Near(Step(input: Input(up:true), dt:.5f).Speed,400,"long callback"); + Near(Step(1300,Input(up:true)).Speed,1400,"cap crossing"); + Near(Step(1500,Input(up:true)).Speed,1500,"retained overspeed"); +} +static void SupportOrder() +{ + Near(Step(input:Input(up:true),supported:true).Speed,350,"accelerate then support loss"); + Near(Step(25,supported:true).Speed,0,"support loss clamps"); + Near(Step(100,Input(up:true,down:true),supported:true).Speed,449.9f,"accel, support, then Down"); + Near(Step(-20,supported:true).Speed,0,"negative supported scalar"); +} +static void Coasting() +{ + var threshold=1400*.9090909361839294f; + Near(Step(threshold).Speed,threshold,"equal threshold"); + Near(Step(1400,dt:.01f).Speed,1399.5f,"short callback coast"); + Near(Step(1400,dt:.5f).Speed,1399.5f,"long callback coast"); + Near(Step(1000).Speed,1000,"low coast retains scalar"); +} +static void Braking() +{ + Near(Step(100,Input(down:true),dt:.25f).Speed,99.9f,"air brake"); + Near(Step(500,Input(down:true),supported:true,dt:.25f).Speed,374.75f,"support brake"); + Near(Step(.05f,Input(down:true)).Speed,0,"positive crossing"); + Near(Step(-.5f,Input(down:true)).Speed,0,"negative crossing"); + Near(Step(-3,Input(down:true)).Speed,-2,"negative per-call recovery"); + Near(Step(1400,Input(down:true)).Speed,1399.4f,"coast precedes brake"); +} +static void BothDirections() +{ + var both=Step(0,Input(up:true,down:true)); + Near(both.Speed,399.9f,"Down brakes newly accelerated speed"); + Check(both.Up&&!both.Down,"Up wins flags"); + Check(Step(input:Input(down:true)).Down,"Down alone"); + Check(!Step().Up&&!Step().Down,"fresh flags clear old requests"); +} +static void Bank() +{ + Near(Step(input:Input(left:true,right:true)).Bank,16,"left precedence"); + Near(Step(input:Input(right:true)).Bank,-16,"right sign"); + Near(Step(input:Input(left:true),bank:44).Bank,45,"positive cap"); + Near(Step(input:Input(right:true),bank:-44).Bank,-45,"negative cap"); + Near(Step(bank:20,keyboardBank:true).Bank,7,"release positive"); + Near(Step(bank:-20,keyboardBank:true).Bank,-7,"release negative"); + Near(Step(bank:5,keyboardBank:true).Bank,0,"release crossing"); + Near(Step(bank:20).Bank,20,"non-keyboard bank retained"); + Check(Step(input:Input(left:true)).KeyboardBank,"keyboard origin set"); +} +static RocketVerticalStep Vertical(float height=1000,float velocity=0,float command=0, + float speed=500,bool up=false,bool down=false) + => RocketFlight.StepVertical(new(height,velocity,command),new(speed,0,Up:up,Down:down),Tuning(),-800); +static void VerticalCommands() +{ + var up=Vertical(up:true); + Near(up.State.CommandedAcceleration,650,"up command"); + Near(up.BodyAcceleration,1450,"up compensates gravity"); + Near(up.State.Velocity,0,"up does not assign velocity"); + Near(Vertical(down:true).BodyAcceleration,150,"down compensates gravity"); + Near(Vertical().BodyAcceleration,800,"neutral cancels gravity"); + Near(Vertical(up:true,down:true).State.CommandedAcceleration,650,"below ceiling Up precedence"); + Near(Vertical(speed:100,up:true).BodyAcceleration,1450,"inclusive speed threshold"); +} +static void VerticalBand() +{ + Near(Vertical(velocity:59.9f).State.Velocity,0,"positive snap"); + Near(Vertical(velocity:-59.9f).State.Velocity,0,"negative snap"); + Near(Vertical(velocity:60).State.CommandedAcceleration,-160,"positive boundary"); + Near(Vertical(velocity:-60).State.CommandedAcceleration,160,"negative boundary"); + Near(Vertical(velocity:700,up:true).State.Velocity,650,"upper cap"); + Near(Vertical(velocity:-700,down:true).State.Velocity,-650,"lower cap"); + Near(Vertical(velocity:700).State.CommandedAcceleration,-160,"neutral decision precedes cap"); +} +static void HeightClamp() +{ + var ceiling=Vertical(height:4000,velocity:123,up:true); + Near(ceiling.State.Height,3900,"ceiling root clamp"); + Near(ceiling.State.Velocity,123,"height clamp preserves velocity"); + Near(ceiling.State.CommandedAcceleration,0,"ceiling rejects Up acceleration"); + Near(Vertical(height:3900,down:true).State.CommandedAcceleration,-650,"Down at equal ceiling"); + Near(Vertical(height:3900,up:true,down:true).State.CommandedAcceleration,-650,"ceiling Down priority"); +} +static void LowSpeed() +{ + var low=Vertical(height:5000,velocity:700,command:-321,speed:99,up:true); + Near(low.State.Height,5000,"below100 does not clamp height"); + Near(low.State.CommandedAcceleration,-321,"retained65C"); + Near(low.BodyAcceleration,479,"retained command still compensates gravity"); + Near(low.State.Velocity,650,"low speed still caps velocity"); +} +static void OriginalReferences() +{ + using var doc=JsonDocument.Parse(File.ReadAllText(Path.Combine(AppContext.BaseDirectory,"original-input-reference.json"))); + var root=doc.RootElement; + Check(root.GetProperty("source_sha256").GetString()=="f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8","original identity"); + var tuning=root.GetProperty("tuning"); + var parameters=Tuning() with{Acceleration=tuning.GetProperty("acceleration").GetSingle(), + Deceleration=tuning.GetProperty("deceleration").GetSingle(),MaximumSpeed=tuning.GetProperty("maximum_speed").GetSingle()}; + Check(root.GetProperty("cases").GetArrayLength()==14,"reference count"); + foreach(var sample in root.GetProperty("cases").EnumerateArray()) + { + var name=sample.GetProperty("name").GetString(); + var input=sample.GetProperty("input");var expected=sample.GetProperty("observed"); + var keys=Input(input.GetProperty("up").GetBoolean(),input.GetProperty("down").GetBoolean(), + input.GetProperty("left").GetBoolean(),input.GetProperty("right").GetBoolean()); + var state=new RocketSteering(input.GetProperty("speed").GetSingle(),input.GetProperty("bank").GetSingle(), + input.GetProperty("keyboard").GetBoolean()); + var actual=RocketFlight.StepKeyboardInput(state,keys,input.GetProperty("supported").GetBoolean(),input.GetProperty("dt").GetSingle(),parameters); + Near(actual.Speed,expected.GetProperty("speed").GetSingle(),$"{name} scalar"); + Near(actual.Bank,expected.GetProperty("bank").GetSingle(),$"{name} bank"); + Check(actual.Up==expected.GetProperty("up").GetBoolean()&&actual.Down==expected.GetProperty("down").GetBoolean(),$"{name} vertical flags"); + Check(actual.KeyboardBank==expected.GetProperty("keyboard").GetBoolean(),$"{name} bank origin"); + //The source also observed destination Euler. It belongs to the still + //separate facing/rotation contract and is deliberately not compared here. + } +} +static void OriginalVerticalReferences() +{ + using var doc=JsonDocument.Parse(File.ReadAllText(Path.Combine(AppContext.BaseDirectory,"original-vertical-reference.json"))); + var root=doc.RootElement; + Check(root.GetProperty("source_sha256").GetString()=="f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8","original vertical identity"); + var tuning=root.GetProperty("tuning"); + var parameters=Tuning() with{MaximumHeight=tuning.GetProperty("maximum_height").GetSingle(), + UpRate=tuning.GetProperty("up_rate").GetSingle(),DownRate=tuning.GetProperty("down_rate").GetSingle(), + MaximumVerticalSpeed=tuning.GetProperty("maximum_vertical_speed").GetSingle()}; + Check(root.GetProperty("cases").GetArrayLength()==14,"vertical reference count"); + foreach(var sample in root.GetProperty("cases").EnumerateArray()) + { + var name=sample.GetProperty("name").GetString(); + var input=sample.GetProperty("input");var expected=sample.GetProperty("observed"); + var state=new RocketVerticalState(input.GetProperty("height").GetSingle(),input.GetProperty("velocity").GetSingle(),input.GetProperty("command").GetSingle()); + var steering=new RocketSteering(input.GetProperty("speed").GetSingle(),0,Up:input.GetProperty("up").GetBoolean(),Down:input.GetProperty("down").GetBoolean()); + var actual=RocketFlight.StepVertical(state,steering,parameters,input.GetProperty("gravity").GetSingle()); + Near(actual.State.Height,expected.GetProperty("height").GetSingle(),$"{name} height"); + Near(actual.State.Velocity,expected.GetProperty("velocity").GetSingle(),$"{name} velocity"); + Near(actual.State.CommandedAcceleration,expected.GetProperty("command").GetSingle(),$"{name} retained65C"); + Near(actual.BodyAcceleration,expected.GetProperty("bodyacceleration").GetSingle(),$"{name} published acceleration"); + //X/Z were preserved by the original suffix. This scalar component + //returns only Y and cannot overwrite the caller's X/Z vectors. + } +} +static void Invalid() +{ + foreach(var dt in new[]{0f,-.1f,1,float.NaN,float.PositiveInfinity}) + Reject(()=>Step(dt:dt)); + Reject(()=>Step(float.NaN)); Reject(()=>Step(bank:float.PositiveInfinity)); + Reject(()=>RocketFlight.StepKeyboardInput(default,default,false,.1f,Tuning() with{MaximumSpeed=0})); + Reject(()=>RocketFlight.StepKeyboardInput(default,default,false,.1f,Tuning() with{Deceleration=-1})); + Reject(()=>Vertical(height:float.NaN)); Reject(()=>Vertical(velocity:float.PositiveInfinity)); + Reject(()=>Vertical(command:float.NaN)); Reject(()=>Vertical(speed:float.NaN)); + Reject(()=>RocketFlight.StepVertical(default,default,Tuning(),float.NaN)); +} +static void Near(float value,float expected,string message) +{ + if(!float.IsFinite(value)||!float.IsFinite(expected)||MathF.Abs(value-expected)>.0002f) + throw new Exception($"{message}: {value} != {expected}"); +} +static void Check(bool condition,string message) { if(!condition)throw new Exception(message); } +static void Reject(Action action) +{ + try { action(); } catch(ArgumentOutOfRangeException) { return; } + throw new Exception("Expected invalid input rejection"); +} diff --git a/tests/GamePort.RocketFlightTests/original-input-reference.json b/tests/GamePort.RocketFlightTests/original-input-reference.json new file mode 100644 index 0000000..5b49a9e --- /dev/null +++ b/tests/GamePort.RocketFlightTests/original-input-reference.json @@ -0,0 +1,381 @@ +{ + "scope": "Copied41A6C0 input prefix, synthetic mouse/support/Euler/audio, camera tail skipped", + "source_sha256": "f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8", + "generator_sha256": "14cd616f8153fda668a52294ce78eba5d3f11d1c6a55ac5b377600c20700eae9", + "executable_sha256": "759350e214755fd5253034242be4453bb2ea3d205f997c56923f46cd9694d010", + "log_sha256": "1b4a35d24d0efc763d1fdc66dc22ba90dccfdb8688d5488fd84d5f3069d46bae", + "source_input_body_sha256": "4c68ae3cf48aecf266ef0a9e8ec81646bd4b774251aac4e38563765a51db2625", + "tuning": { + "acceleration": 400.0, + "deceleration": 1.0, + "maximum_speed": 1400.0, + "acceleration_lean": 20.0, + "deceleration_lean": -20.0 + }, + "cases": [ + { + "name": "up_air", + "input": { + "speed": 0.0, + "bank": 0.0, + "keyboard": false, + "up": true, + "down": false, + "left": false, + "right": false, + "supported": false, + "dt": 0.01666666753590107 + }, + "observed": { + "speed": 400.0, + "bank": 0.0, + "keyboard": false, + "up": true, + "down": false, + "dest": [ + 20.0, + 0.0, + -0.0 + ] + } + }, + { + "name": "up_air_dt", + "input": { + "speed": 0.0, + "bank": 0.0, + "keyboard": false, + "up": true, + "down": false, + "left": false, + "right": false, + "supported": false, + "dt": 0.10000000149011612 + }, + "observed": { + "speed": 400.0, + "bank": 0.0, + "keyboard": false, + "up": true, + "down": false, + "dest": [ + 20.0, + 0.0, + -0.0 + ] + } + }, + { + "name": "up_supported", + "input": { + "speed": 0.0, + "bank": 0.0, + "keyboard": false, + "up": true, + "down": false, + "left": false, + "right": false, + "supported": true, + "dt": 0.01666666753590107 + }, + "observed": { + "speed": 391.666656, + "bank": 0.0, + "keyboard": false, + "up": true, + "down": false, + "dest": [ + 20.0, + 0.0, + -0.0 + ] + } + }, + { + "name": "up_down_air", + "input": { + "speed": 0.0, + "bank": 0.0, + "keyboard": false, + "up": true, + "down": true, + "left": false, + "right": false, + "supported": false, + "dt": 0.01666666753590107 + }, + "observed": { + "speed": 399.899994, + "bank": 0.0, + "keyboard": false, + "up": true, + "down": false, + "dest": [ + 20.0, + 0.0, + -0.0 + ] + } + }, + { + "name": "up_down_supported", + "input": { + "speed": 0.0, + "bank": 0.0, + "keyboard": false, + "up": true, + "down": true, + "left": false, + "right": false, + "supported": true, + "dt": 0.01666666753590107 + }, + "observed": { + "speed": 391.649994, + "bank": 0.0, + "keyboard": false, + "up": true, + "down": false, + "dest": [ + 20.0, + 0.0, + -0.0 + ] + } + }, + { + "name": "coast_high", + "input": { + "speed": 1400.0, + "bank": 0.0, + "keyboard": false, + "up": false, + "down": false, + "left": false, + "right": false, + "supported": false, + "dt": 0.01666666753590107 + }, + "observed": { + "speed": 1399.5, + "bank": 0.0, + "keyboard": false, + "up": false, + "down": false, + "dest": [ + 0.0, + 0.0, + -0.0 + ] + } + }, + { + "name": "coast_low", + "input": { + "speed": 1200.0, + "bank": 0.0, + "keyboard": false, + "up": false, + "down": false, + "left": false, + "right": false, + "supported": false, + "dt": 0.01666666753590107 + }, + "observed": { + "speed": 1200.0, + "bank": 0.0, + "keyboard": false, + "up": false, + "down": false, + "dest": [ + 0.0, + 0.0, + -0.0 + ] + } + }, + { + "name": "down_air", + "input": { + "speed": 1000.0, + "bank": 0.0, + "keyboard": false, + "up": false, + "down": true, + "left": false, + "right": false, + "supported": false, + "dt": 0.01666666753590107 + }, + "observed": { + "speed": 999.900024, + "bank": 0.0, + "keyboard": false, + "up": false, + "down": true, + "dest": [ + -20.0, + 0.0, + -0.0 + ] + } + }, + { + "name": "down_supported", + "input": { + "speed": 1000.0, + "bank": 0.0, + "keyboard": false, + "up": false, + "down": true, + "left": false, + "right": false, + "supported": true, + "dt": 0.01666666753590107 + }, + "observed": { + "speed": 991.650024, + "bank": 0.0, + "keyboard": false, + "up": false, + "down": true, + "dest": [ + -20.0, + 0.0, + -0.0 + ] + } + }, + { + "name": "left_precedence", + "input": { + "speed": 0.0, + "bank": 0.0, + "keyboard": false, + "up": false, + "down": false, + "left": true, + "right": true, + "supported": false, + "dt": 0.10000000149011612 + }, + "observed": { + "speed": 0.0, + "bank": 16.0, + "keyboard": true, + "up": false, + "down": false, + "dest": [ + 0.0, + 0.0, + 0.0 + ] + } + }, + { + "name": "keyboard_recenter", + "input": { + "speed": 0.0, + "bank": 10.0, + "keyboard": true, + "up": false, + "down": false, + "left": false, + "right": false, + "supported": false, + "dt": 0.10000000149011612 + }, + "observed": { + "speed": 0.0, + "bank": 0.0, + "keyboard": true, + "up": false, + "down": false, + "dest": [ + 0.0, + 0.0, + 0.0 + ] + } + }, + { + "name": "mouse_origin_hold", + "input": { + "speed": 0.0, + "bank": 10.0, + "keyboard": false, + "up": false, + "down": false, + "left": false, + "right": false, + "supported": false, + "dt": 0.10000000149011612 + }, + "observed": { + "speed": 0.0, + "bank": 10.0, + "keyboard": false, + "up": false, + "down": false, + "dest": [ + 0.0, + 0.0, + 0.0 + ] + } + }, + { + "name": "bank_cap", + "input": { + "speed": 0.0, + "bank": 44.0, + "keyboard": true, + "up": false, + "down": false, + "left": true, + "right": false, + "supported": false, + "dt": 0.10000000149011612 + }, + "observed": { + "speed": 0.0, + "bank": 45.0, + "keyboard": true, + "up": false, + "down": false, + "dest": [ + 0.0, + 0.0, + 0.0 + ] + } + }, + { + "name": "negative_down", + "input": { + "speed": -2.0, + "bank": 0.0, + "keyboard": false, + "up": false, + "down": true, + "left": false, + "right": false, + "supported": false, + "dt": 0.10000000149011612 + }, + "observed": { + "speed": -1.0, + "bank": 0.0, + "keyboard": false, + "up": false, + "down": true, + "dest": [ + -20.0, + 0.0, + -0.0 + ] + } + } + ] +} diff --git a/tests/GamePort.RocketFlightTests/original-vertical-reference.json b/tests/GamePort.RocketFlightTests/original-vertical-reference.json new file mode 100644 index 0000000..f4050fe --- /dev/null +++ b/tests/GamePort.RocketFlightTests/original-vertical-reference.json @@ -0,0 +1,329 @@ +{ + "scope": "Copied41A470..41A6A8 vertical publication, synthetic body getters/setters, no integration", + "source_sha256": "f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8", + "generator_sha256": "07afdc2dad05fd659485bc670deac9f141fce87b7e938ab07f60648bb0fd8512", + "executable_sha256": "42fd409ca24e694f1c96e285a3de7f0af21f5a697605afb64e5874f575fd29da", + "log_sha256": "7b8d7079112826613ddc4fe115e7326a8a36c21444e9289bceda17743297b601", + "source_input_body_sha256": "20fc706986e58791dc19334a01a772dd517cbd260079382dac2f009fc8707bb7", + "tuning": { + "acceleration": 400.0, + "deceleration": 1.0, + "maximum_speed": 1400.0, + "acceleration_lean": 20.0, + "deceleration_lean": -20.0, + "maximum_height": 3900.0, + "up_rate": 650.0, + "down_rate": -650.0, + "maximum_vertical_speed": 650.0 + }, + "cases": [ + { + "name": "low_speed_retained", + "input": { + "speed": 99.0, + "height": 5000.0, + "velocity": 900.0, + "command": 123.0, + "up": false, + "down": false, + "gravity": -800.0 + }, + "observed": { + "height": 5000.0, + "velocity": 650.0, + "command": 123.0, + "bodyacceleration": 923.0, + "vx": 11.0, + "vz": 22.0, + "ax": 33.0, + "az": 44.0 + } + }, + { + "name": "up_below", + "input": { + "speed": 100.0, + "height": 100.0, + "velocity": 0.0, + "command": 0.0, + "up": true, + "down": false, + "gravity": -800.0 + }, + "observed": { + "height": 100.0, + "velocity": 0.0, + "command": 650.0, + "bodyacceleration": 1450.0, + "vx": 11.0, + "vz": 22.0, + "ax": 33.0, + "az": 44.0 + } + }, + { + "name": "down_below", + "input": { + "speed": 100.0, + "height": 100.0, + "velocity": 0.0, + "command": 0.0, + "up": false, + "down": true, + "gravity": -800.0 + }, + "observed": { + "height": 100.0, + "velocity": 0.0, + "command": -650.0, + "bodyacceleration": 150.0, + "vx": 11.0, + "vz": 22.0, + "ax": 33.0, + "az": 44.0 + } + }, + { + "name": "neutral_positive", + "input": { + "speed": 100.0, + "height": 100.0, + "velocity": 60.0, + "command": 0.0, + "up": false, + "down": false, + "gravity": -800.0 + }, + "observed": { + "height": 100.0, + "velocity": 60.0, + "command": -160.0, + "bodyacceleration": 640.0, + "vx": 11.0, + "vz": 22.0, + "ax": 33.0, + "az": 44.0 + } + }, + { + "name": "neutral_negative", + "input": { + "speed": 100.0, + "height": 100.0, + "velocity": -60.0, + "command": 0.0, + "up": false, + "down": false, + "gravity": -800.0 + }, + "observed": { + "height": 100.0, + "velocity": -60.0, + "command": 160.0, + "bodyacceleration": 960.0, + "vx": 11.0, + "vz": 22.0, + "ax": 33.0, + "az": 44.0 + } + }, + { + "name": "neutral_snap_positive", + "input": { + "speed": 100.0, + "height": 100.0, + "velocity": 59.9900016784668, + "command": 0.0, + "up": false, + "down": false, + "gravity": -800.0 + }, + "observed": { + "height": 100.0, + "velocity": 0.0, + "command": 0.0, + "bodyacceleration": 800.0, + "vx": 11.0, + "vz": 22.0, + "ax": 33.0, + "az": 44.0 + } + }, + { + "name": "neutral_snap_negative", + "input": { + "speed": 100.0, + "height": 100.0, + "velocity": -59.9900016784668, + "command": 0.0, + "up": false, + "down": false, + "gravity": -800.0 + }, + "observed": { + "height": 100.0, + "velocity": 0.0, + "command": 0.0, + "bodyacceleration": 800.0, + "vx": 11.0, + "vz": 22.0, + "ax": 33.0, + "az": 44.0 + } + }, + { + "name": "neutral_zero", + "input": { + "speed": 100.0, + "height": 100.0, + "velocity": 0.0, + "command": 99.0, + "up": false, + "down": false, + "gravity": -800.0 + }, + "observed": { + "height": 100.0, + "velocity": 0.0, + "command": 0.0, + "bodyacceleration": 800.0, + "vx": 11.0, + "vz": 22.0, + "ax": 33.0, + "az": 44.0 + } + }, + { + "name": "ceiling_up", + "input": { + "speed": 100.0, + "height": 5000.0, + "velocity": 300.0, + "command": 0.0, + "up": true, + "down": false, + "gravity": -800.0 + }, + "observed": { + "height": 3900.0, + "velocity": 300.0, + "command": 0.0, + "bodyacceleration": 800.0, + "vx": 11.0, + "vz": 22.0, + "ax": 33.0, + "az": 44.0 + } + }, + { + "name": "ceiling_down", + "input": { + "speed": 100.0, + "height": 5000.0, + "velocity": -900.0, + "command": 0.0, + "up": false, + "down": true, + "gravity": -800.0 + }, + "observed": { + "height": 3900.0, + "velocity": -650.0, + "command": -650.0, + "bodyacceleration": 150.0, + "vx": 11.0, + "vz": 22.0, + "ax": 33.0, + "az": 44.0 + } + }, + { + "name": "velocity_cap_up", + "input": { + "speed": 100.0, + "height": 100.0, + "velocity": 900.0, + "command": 0.0, + "up": true, + "down": false, + "gravity": -800.0 + }, + "observed": { + "height": 100.0, + "velocity": 650.0, + "command": 650.0, + "bodyacceleration": 1450.0, + "vx": 11.0, + "vz": 22.0, + "ax": 33.0, + "az": 44.0 + } + }, + { + "name": "velocity_cap_down", + "input": { + "speed": 100.0, + "height": 100.0, + "velocity": -900.0, + "command": 0.0, + "up": false, + "down": true, + "gravity": -800.0 + }, + "observed": { + "height": 100.0, + "velocity": -650.0, + "command": -650.0, + "bodyacceleration": 150.0, + "vx": 11.0, + "vz": 22.0, + "ax": 33.0, + "az": 44.0 + } + }, + { + "name": "zero_gravity_up", + "input": { + "speed": 100.0, + "height": 100.0, + "velocity": 0.0, + "command": 0.0, + "up": true, + "down": false, + "gravity": 0.0 + }, + "observed": { + "height": 100.0, + "velocity": 0.0, + "command": 650.0, + "bodyacceleration": 650.0, + "vx": 11.0, + "vz": 22.0, + "ax": 33.0, + "az": 44.0 + } + }, + { + "name": "low_speed_gravity", + "input": { + "speed": 0.0, + "height": 100.0, + "velocity": -10.0, + "command": -33.0, + "up": true, + "down": false, + "gravity": -800.0 + }, + "observed": { + "height": 100.0, + "velocity": -10.0, + "command": -33.0, + "bodyacceleration": 767.0, + "vx": 11.0, + "vz": 22.0, + "ax": 33.0, + "az": 44.0 + } + } + ] +} diff --git a/tests/test_grappler.py b/tests/test_grappler.py new file mode 100644 index 0000000..8bc23ad --- /dev/null +++ b/tests/test_grappler.py @@ -0,0 +1,86 @@ +"""Original-byte guards and bounded Grappler scalar references; no gameplay run.""" +from pathlib import Path +import sys +import unittest + +ROOT=Path(__file__).resolve().parents[1] +sys.path.insert(0,str(ROOT/'tools/binary')) +from grappler import (attach_scalars, collect, f32, fast_reel, held_reel, + jump_detaches, material_blocks_aim, swing_scalars) + + +class GrapplerSourceTests(unittest.TestCase): + def test_original_identity_dispatchers_and_constants(self): + report=collect(ROOT.parent/'Original') + self.assertEqual(len(report['bodies']),12) + self.assertEqual(len(report['constants']),16) + self.assertEqual(report['raw_mode'],7) + self.assertEqual(report['aim_local_point'],[0,2400,2400]) + self.assertTrue(all(int(b['va'],16)-int(b['file_offset'],16)==0x400000 + for b in report['bodies'])) + + def test_material_ranges_are_inclusive_and_have_real_holes(self): + for value in [60,69,80,89,210,219,-1,170]: + self.assertTrue(material_blocks_aim(value),value) + for value in [59,70,79,90,209,220,-2,0,111,169,171]: + self.assertFalse(material_blocks_aim(value),value) + + def test_material_absence_is_not_equivalent_to_definition_absence(self): + self.assertTrue(material_blocks_aim(0,material_present=False)) + self.assertFalse(material_blocks_aim(60,definition_present=False)) + self.assertFalse(material_blocks_aim(60,polygon=False,material_present=False)) + + def test_attach_sets_vertical100_and_first_scale_from_distance_minus100(self): + result=attach_scalars((0,0,0),(0,300,400),(10,-200,20)) + self.assertEqual(result.length,400.) + self.assertEqual(result.initial_length,400.) + self.assertEqual(result.scale_z,f32(400*f32(1/600))) + self.assertEqual(result.reel_target,100.) + self.assertEqual(result.velocity,(10,100,20)) + + def test_reattach_retains_first_scale_even_when_length_changes(self): + result=attach_scalars((0,0,0),(0,600,800),initial_length=400.) + self.assertEqual(result.length,900.) + self.assertEqual(result.initial_length,400.) + self.assertIsNone(result.scale_z) + + def test_held_reel_can_undershoot250_and_stays_afterward(self): + length=held_reel(251.,.1) + self.assertEqual(length,226.) + self.assertEqual(held_reel(length,.1),226.) + self.assertEqual(held_reel(250.,.1),250.) + + def test_fast_reel_can_undershoot_target(self): + self.assertEqual(fast_reel(251.,250.,.1),156.) + self.assertEqual(fast_reel(250.,250.,.1),250.) + + def test_swing_acceleration_precedes_discrete_damping(self): + x,z,t=swing_scalars(10.,20.,0.,.1,100.,-200.,400.) + self.assertAlmostEqual(x,8.3,places=5) + self.assertAlmostEqual(z,23.4,places=5) + self.assertEqual(t,f32(.1)) + + def test_swing_350_boundary_and_clamp(self): + short=swing_scalars(100.,-100.,.2,0.,0.,0.,349.) + long=swing_scalars(100.,-100.,.2,0.,0.,0.,350.) + self.assertEqual(short[:2],(f32(50*f32(.95)),f32(-50*f32(.95)))) + self.assertEqual(long[:2],(f32(50*f32(.98)),f32(-50*f32(.98)))) + + def test_long_tick_damps_only_once_and_retains_elapsed_remainder(self): + x,z,t=swing_scalars(50.,50.,0.,.6,0.,0.,400.) + self.assertEqual(x,f32(50*f32(.98))) + self.assertEqual(z,x) + self.assertAlmostEqual(t,.4,places=6) + + def test_jump_release_requires_no_primary_fire(self): + self.assertTrue(jump_detaches(jump_held=True,fire_held=False,attached=True)) + for values in [(True,True,True),(False,False,True),(True,False,False)]: + self.assertFalse(jump_detaches(jump_held=values[0],fire_held=values[1],attached=values[2])) + + def test_nonfinite_and_negative_time_rejected_by_projection_boundary(self): + for function,args in [(held_reel,(300.,-.1)),(fast_reel,(300.,250.,float('nan')))]: + with self.assertRaises(ValueError):function(*args) + with self.assertRaises(ValueError):attach_scalars((0,0),(0,0,0)) + + +if __name__=='__main__':unittest.main() diff --git a/tests/test_rocketship.py b/tests/test_rocketship.py new file mode 100644 index 0000000..256d992 --- /dev/null +++ b/tests/test_rocketship.py @@ -0,0 +1,49 @@ +"""Original source identity/ABI guards and rejected component-capture ingestion.""" +from pathlib import Path +import sys +import tempfile +import unittest + +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT/'tools/binary')) +from rocketship import collect, probe_results + + +class RocketSourceTests(unittest.TestCase): + def test_original_spans_and_pointer_bases(self): + report = collect(ROOT.parent/'Original') + self.assertEqual(len(report['bodies']), 10) + self.assertEqual(len(report['vtables']), 6) + self.assertEqual(report['rider_pointer'], 'complete rocket+740 = game interface+680') + self.assertEqual(report['radius'], 50) + self.assertEqual(report['item'], report['raw_mode']) + self.assertTrue(all(int(b['va'], 16)-int(b['file_offset'], 16) == 0x400000 + for b in report['bodies'])) + self.assertTrue(any(v['table'] == '0x4cdd30' and v['slot'] == '0x134' + and v['target'] == '0x475cd0' for v in report['vtables'])) + + def test_changed_executable_is_rejected(self): + data = bytearray((ROOT.parent/'Original/Neutron.exe').read_bytes()) + data[0x1a8dc] ^= 1 + with tempfile.TemporaryDirectory() as temp: + path = Path(temp)/'Neutron.exe' + path.write_bytes(data) + with self.assertRaisesRegex(ValueError, 'identity'): + collect(Path(temp)) + + def test_missing_or_repeated_original_samples_are_rejected(self): + report = collect(ROOT.parent/'Original') + with tempfile.TemporaryDirectory() as temp: + log = Path(temp)/'wine.log' + executable = Path(temp)/'absent.exe' + log.write_text('CASE up_air speed=400\n') + with self.assertRaisesRegex(ValueError, 'Incomplete'): + probe_results(report, log, executable) + line = 'CASE up_air speed=400 bank=0 keyboard=0 up=1 down=0 dest=20,0,0\n' + log.write_text(line*2+'ROCKET_INPUT_COMPONENT_COMPLETE:\n') + with self.assertRaisesRegex(ValueError, 'repeated'): + probe_results(report, log, executable) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_rocketship_resources.py b/tests/test_rocketship_resources.py new file mode 100644 index 0000000..d3ae7b9 --- /dev/null +++ b/tests/test_rocketship_resources.py @@ -0,0 +1,101 @@ +from pathlib import Path +import hashlib +import json +import sys +import tempfile +import unittest +from unittest.mock import patch + +ROOT = Path(__file__).resolve().parents[1] +ORIGINAL = ROOT.parent/'Original' +sys.path.insert(0, str(ROOT/'tools/extractors')) +from rocketship_resources import CLIPS, SOURCES, TEXTURES, export_rocketship +from ase import expand_mesh, read_ase +from entities import resolve_asset +from omt import FormatError + + +@unittest.skipUnless(ORIGINAL.exists(), 'Original assets are local integration fixtures') +class RocketshipResourceTests(unittest.TestCase): + def test_exact_original_pixels_and_authored_sampling(self): + with tempfile.TemporaryDirectory() as directory: + output = Path(directory)/'rocketship' + manifest = export_rocketship(ORIGINAL, output) + self.assertEqual(manifest, json.loads((output/'rocketship.json').read_text())) + self.assertEqual((manifest['schema'], manifest['sources']), (1, SOURCES)) + expected_textures = {name: (width, height, sha) for name, width, height, sha in TEXTURES} + for entry, (stem, _, texture, vertices, faces, times) in zip(manifest['animations'], CLIPS): + animation = json.loads((output/entry['path']).read_text()) + self.assertEqual([frame['time'] for frame in animation['frames']], list(times)) + self.assertEqual((entry['indexedVertices'], entry['polygons']), (vertices, faces)) + rgba = (output/stem/animation['texture']['path']).read_bytes() + self.assertEqual((animation['texture']['width'], animation['texture']['height'], + hashlib.sha256(rgba).hexdigest()), expected_textures[texture]) + for frame in animation['frames']: + mesh = json.loads((output/stem/frame['path']).read_text()) + self.assertEqual(len(mesh['vertices']), faces*3) + self.assertEqual(mesh['indices'], list(range(faces*3))) + + def test_morphs_use_exact_base_uv_topology_and_sample_positions(self): + with tempfile.TemporaryDirectory() as directory: + output = Path(directory)/'rocketship' + export_rocketship(ORIGINAL, output) + for stem, base in (('jimdrive', 'jimstop'), ('godrocket', 'godpoint')): + source = read_ase(resolve_asset(ORIGINAL, f'ASE/{stem}.ASE')) + topology = read_ase(resolve_asset(ORIGINAL, f'ASE/{base}.ASE'))['objects'][0]['samples'][0] + self.assertFalse(source['objects'][0]['samples'][0]['textureFaces']) + manifest = json.loads((output/stem/'animation.json').read_text()) + self.assertEqual(manifest['morphBase']['sha256'], SOURCES[f'ASE/{base}.ASE']) + for sample, frame in zip(source['objects'][0]['samples'], manifest['frames']): + expected = expand_mesh({**sample, 'faces': topology['faces'], + 'textureFaces': topology['textureFaces'], 'uvs': topology['uvs']}) + actual = json.loads((output/stem/frame['path']).read_text()) + self.assertEqual(actual['vertices'], [list(p) for p in expected['vertices']]) + self.assertEqual(actual['uvs'], [list(p) for p in expected['uvs']]) + + def test_vr02_preserves_source_offsets_duplicate_tags_and_null_polygons(self): + with tempfile.TemporaryDirectory() as directory: + manifest = export_rocketship(ORIGINAL, Path(directory)/'rocketship') + entities = manifest['tutorial']['entities'] + self.assertEqual(len(entities), 18) + rocket = next(e for e in entities if e['kind'] == '3ROC') + self.assertEqual((rocket['ordinal'], rocket['offset']), (1, 0x1cd)) + values = {p['name']: p['value'] for p in rocket['properties']} + self.assertEqual((values['MaxHeight'], values['MaxSpeed'], values['AccelRate'], + values['DecelRate'], values['NewGravity']), (3900, 1400, 400, 1, 0)) + points = [e for e in entities if e['kind'] == '3PAT'] + tags = [next(p['value'] for p in e['properties'] if p['name'] == 'ObjectTag') for e in points] + self.assertEqual(tags, ['rs1', 'rs1', 'rs2', 'rs3']) + self.assertEqual(manifest['staticGeometry']['materialPolygons'], + {'0': 160, '2': 96, '3': 192, '5': 400, 'null': 32}) + + def test_original_ancestors_and_descendant_symlinks_rejected(self): + for output in (ORIGINAL, ORIGINAL/'generated', ORIGINAL.parent): + with self.subTest(output=output), self.assertRaises(ValueError): + export_rocketship(ORIGINAL, output) + with tempfile.TemporaryDirectory() as directory: + output = Path(directory)/'rocketship' + output.mkdir() + target = Path(directory)/'unchanged' + target.write_bytes(b'unchanged') + (output/'strato.rgba').symlink_to(target) + with self.assertRaises(ValueError): + export_rocketship(ORIGINAL, output) + self.assertEqual(target.read_bytes(), b'unchanged') + + def test_changed_source_and_bad_pixels_rejected_before_output(self): + with tempfile.TemporaryDirectory() as directory: + output = Path(directory)/'rocketship' + with patch('rocketship_resources.digest', return_value='0'*64), \ + patch('rocketship_resources.read_ase') as decoder, self.assertRaises(FormatError): + export_rocketship(ORIGINAL, output) + decoder.assert_not_called() + self.assertFalse(output.exists()) + with patch('rocketship_resources.read_png', return_value=dict(width=1, height=1, rgba=b'\0'*4)), \ + self.assertRaises(FormatError): + export_rocketship(ORIGINAL, output) + self.assertFalse(output.exists()) + + +if __name__ == '__main__': + unittest.main() diff --git a/tools/binary/grappler.py b/tools/binary/grappler.py new file mode 100644 index 0000000..03e41bd --- /dev/null +++ b/tools/binary/grappler.py @@ -0,0 +1,188 @@ +#!/usr/bin/env python3 +"""Guarded Grappler evidence and isolated scalar projections, no target execution. + +The projections omit ray traversal, Euler/table precision, body dispatch and +camera scheduling. They are not a live gadget or original-runtime oracle. +""" +from __future__ import annotations + +import argparse +from dataclasses import dataclass +import hashlib +import json +import math +from pathlib import Path +import struct + +from checkpoint_script_state import EXE_SHA256, find_case, read_va +from pe_inspect import PE + + +BODIES = ( + ('cursor_owner', 0x42255b, 0x4225a0, '86c2500c8105768c3568faacb4001b3713639806c68961e6af00411b4388789c'), + ('rope_owner', 0x4227fc, 0x422831, '53178e76063eb6400f277b91a63a38ebd6d65f1e0e73af86bf5ca99e5f4b82d4'), + ('constructor_globals', 0x422761, 0x4227be, 'e914d43a038f8f4e99996a58f9cb9041c691b6a412ef64ed2a7c7a0357d1a091'), + ('update_gate', 0x426030, 0x4260a6, 'bf3bcca296c7fc5d3c7dd5e79bdd9311b5fcee7606842978346706dbdab9d1b7'), + ('primary_order', 0x42668f, 0x4266e9, '7774c6cb2aa7d6784bb0c74490c6f67ac9b96c9724dca9f4f2856519103bf320'), + ('fire_attach', 0x426a70, 0x426e35, 'b4f77baf95e5f3b2b9cb07c58b3fa771d064ac2720346e1e04c90bad7aea76ac'), + ('cleanup', 0x4287ac, 0x42882f, 'e59ec9d7f88f250552ca090897899be125dbf4b3b6194106755646d7d4b689ca'), + ('equip', 0x4297dd, 0x4298bf, '77ddf32d73f9b387f2d4375e4f7c16c893ae5452eef1f57fd24d4ff0b52e50a5'), + ('detach', 0x429c10, 0x429cf7, 'aad9706ec19de0d162827fe957e91fb4a513423d6e6901de9a29e4c780f7df97'), + ('swing', 0x429d00, 0x42a660, '9f4f17bafbca614ee64094df4d951c53cb122f8e15adb9fd7f8a58be589cc2f3'), + ('collision', 0x42a660, 0x42a714, 'd52831057c35afbdb73babff81857a6a3cfb2466f639b8be0a80e6300d386b0c'), + ('jump_predicate', 0x42a730, 0x42a7a0, '8a736de3111c9c803d0748e2d3a385fda2156894467a335a3e5e55df7fa046e2'), +) +CONSTANTS = ( + (0x48d96c, 'f', 100.), (0x4a3e58, 'f', 250.), + (0x4a3e5c, 'f', 0.0016666667070239782), + (0x4a3e64, 'f', 0.9599999785423279), + (0x4a3e68, 'f', 450.), (0x4a3e6c, 'f', 0.20000000298023224), + (0x4a3e70, 'f', 0.9800000190734863), + (0x4a3e74, 'f', 0.949999988079071), (0x4a3e78, 'f', -50.), + (0x4a3e80, 'd', .17), (0x4a3e88, 'f', 950.), + (0x4a3e8c, 'f', 116.), (0x4a2ad0, 'd', .2), + (0x49fae4, 'f', 350.), (0x48d400, 'f', 50.), + (0x49d5b4, 'f', 60.), +) + + +def collect(original: Path | str): + pe = PE(find_case(Path(original), 'Neutron.exe')) + digest = hashlib.sha256(pe.data).hexdigest() + if digest != EXE_SHA256: + raise ValueError('Unexpected original EXE identity') + bodies = [] + for name, start, end, expected in BODIES: + actual = hashlib.sha256(read_va(pe, start, end-start)).hexdigest() + if actual != expected: + raise ValueError(f'Changed source span {name}') + bodies.append(dict(name=name, va=hex(start), end_va=hex(end), + file_offset=hex(pe.offset(start-pe.base)), sha256=actual)) + virtuals = ((0x188, 0x429d00), (0x1c0, 0x426a70), (0x204, 0x429c10)) + for slot, expected in virtuals: + if struct.unpack('=450. + + Missing selected polygon passes this material check; present polygon without + material blocks. A present material without definition passes. This predicate + does not reproduce ray admission or the enclosing helper's return value. + """ + if not polygon: + return False + if not material_present: + return True + if not definition_present: + return False + return (60 <= material_id <= 69 or 80 <= material_id <= 89 or + 210 <= material_id <= 219 or material_id in (-1, 170)) + + +@dataclass(frozen=True) +class AttachmentScalars: + length: float + initial_length: float + scale_z: float | None + reel_target: float + velocity: tuple[float, float, float] + + +def attach_scalars(root, hit, velocity=(0.,0.,0.), *, initial_length=0.): + """426BE8..426D85 accepted hit; no clamping or negative-length repair. + + Host sqrt and explicit float stores are a bounded arithmetic projection, + not a bit-exact x87 execution oracle. Initial scale is assigned only when + global4F82B4 is zero; unequip/detach do not clear that global. + """ + if len(root) != 3 or len(hit) != 3 or len(velocity) != 3: + raise ValueError('Three-vectors required') + finite(*root, *hit, *velocity, initial_length) + length = f32(math.sqrt(sum((a-b)**2 for a,b in zip(hit,root)))-100.) + scale = f32(length*f32(1/600)) if initial_length == 0. else None + return AttachmentScalars(length, length if initial_length == 0. else initial_length, + scale, f32(hit[1]-root[1]-200.), + (velocity[0],100.,velocity[2])) + + +def held_reel(length, dt): + """426DAC..426DFD: strict old length>250, no final minimum clamp.""" + finite(length, dt) + if dt < 0: + raise ValueError('Nonnegative dt required') + return f32(length-dt*250.) if length > 250. else length + + +def fast_reel(length, target, dt): + """429DCB..429DE8: target=double .2, + clamp50, multiply .95/.98, then subtract float .2 ONCE (not a loop). + """ + finite(x,z,timer,dt,rope_offset_x,rope_offset_z,length) + if dt < 0: + raise ValueError('Nonnegative dt required') + timer = f32(timer+dt) + x = f32(x-rope_offset_x*dt*.17) + z = f32(z-rope_offset_z*dt*.17) + if timer >= .2: + gain = f32(.95 if length < 350. else .98) + x = f32(max(-50., min(50., x))*gain) + z = f32(max(-50., min(50., z))*gain) + timer = f32(timer-f32(.2)) + return x,z,timer + + +def jump_detaches(*, jump_held, fire_held, attached): + """429DF9..429E2C uses independent jump/fire predicates.""" + return bool(jump_held and attached and not fire_held) + + +if __name__ == '__main__': + cli = argparse.ArgumentParser(description=__doc__) + cli.add_argument('original', type=Path) + cli.add_argument('--output', type=Path) + args = cli.parse_args() + result = json.dumps(collect(args.original), indent=2)+'\n' + if args.output: + args.output.parent.mkdir(parents=True, exist_ok=True) + args.output.write_text(result) + else: + print(result, end='') diff --git a/tools/binary/rocketship.py b/tools/binary/rocketship.py new file mode 100644 index 0000000..6aa243c --- /dev/null +++ b/tools/binary/rocketship.py @@ -0,0 +1,311 @@ +#!/usr/bin/env python3 +"""Read-only Rocketship contracts and isolated input/vertical probe generators. + +The input probe executes copied41A6C0 only through41AC0E, with synthetic +mouse/support/transform/audio dependencies. The vertical probe executes only +41A470..41A6A8 with synthetic body accessors. Neither runs the original game. +""" +from __future__ import annotations +import argparse +import hashlib +import json +import math +from pathlib import Path +import re +import struct +from checkpoint_script_state import EXE_SHA256, find_case, read_va +from pe_inspect import PE + +BODIES = ( + ('ctor', 0x43d840, 0x43da40, '33d27053c2070f0c278bf3e14808d16c4479893d1ccb16c1ac8e199dfd9e53ba'), + ('init', 0x43dd10, 0x43dd92, 'cd6e843749b7c87db7df223fd98f5f16c5b01b7097c0b0d4a661dd28eb1bd494'), + ('flying_ctor', 0x419b70, 0x419db0, '85c0e74764282ed55e2c7268a0dec5944097b16f1a9df71054e5458b446ee2c0'), + ('flight_apply', 0x41a140, 0x41a6b1, '20fc706986e58791dc19334a01a772dd517cbd260079382dac2f009fc8707bb7'), + ('flight_input', 0x41a6c0, 0x41ade1, '4c68ae3cf48aecf266ef0a9e8ec81646bd4b774251aac4e38563765a51db2625'), + ('rocket_input', 0x43e7e0, 0x43e854, 'db973aebd9dad23de493d79606b3016e3e04c7ba029452ee07a6fd6e9abfd5b9'), + ('mount', 0x42944d, 0x429686, '2e8e15c52bf02a06afe2a56ccf8b31551368aefcde046c444ddb01a3ef978c70'), + ('cleanup', 0x428512, 0x42871d, 'e35f82a6b4e791e77278cdf84bc3878237d57c54355254cfbeff3923d2c70ee6'), + ('vr02_ctor', 0x456270, 0x456360, '058e77e27d8dbb2de5306c0582ccc1c7caf81cf29ae64caa43d3d1cd174b63c8'), + ('fire_ctor', 0x4192e0, 0x41944c, 'e66ca12f68c3fc87bd855d0865871d387627684e31429460b84139f28e77afdb'), +) +VTABLES = ((0x4b25ac, 0x110, 0x471240), (0x4b25ac, 0x264, 0x471b40), + (0x4b25ac, 0x3c4, 0x43df70), (0x4b25ac, 0x3cc, 0x43e7e0), + (0x4b2a4c, 0x128, 0x43ea80), (0x4cdd30, 0x134, 0x475cd0)) +CONSTANTS = ((0x49d5b0, -60.), (0x49d5b4, 60.), (0x49d5b8, 0.0181818176060915), + (0x49d5d4, 0.10000000149011612), (0x49d5dc, 0.9090909361839294), + (0x49d5e4, 160.), (0x49b1fc, 130.), (0x48e5bc, 500.)) +PROBE_GLOBALS = (0x509a50, 0x50985d, 0x50985f, 0x509aa0, 0x509aa4, + 0x48d914, 0x48d948, 0x48d94c, 0x49b1fc, 0x49d5e4, + 0x509882, 0x509881, 0x509885, 0x509891, 0x509848, + 0x50985e, 0x509834, 0x49d5e0, 0x49d5dc, 0x48e5bc, + 0x509860, 0x50993a, 0x49d5d8, 0x49d5d4, 0x48e5ec, + 0x495324, 0x49d5d0, 0x49d5cc, 0x49d5c8) +VERTICAL_GLOBALS = (0x48d96c, 0x48d914, 0x49d5b4, 0x49d5b0, 0x5cfc04) + + +def collect(original: Path | str): + pe = PE(find_case(Path(original), 'Neutron.exe')) + if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256: + raise ValueError('Unexpected original EXE identity') + bodies = [] + for name, start, end, expected in BODIES: + digest = hashlib.sha256(read_va(pe, start, end-start)).hexdigest() + if digest != expected: + raise ValueError(f'Changed source span {name}') + bodies.append(dict(name=name, va=hex(start), file_offset=hex(pe.offset(start-pe.base)), + length=end-start, sha256=digest)) + for table, slot, target in VTABLES: + if struct.unpack(' +#include +#include +#include +#include +#define TC __attribute__((thiscall)) +static unsigned char *mapped,object[0x1000],camera[0x100]; +static uintptr_t table[0x400/4],outer[0x200/4]; +static int grounded; +static short mouse_x,mouse_y; +static float euler[4],destination[3]; +#define AT(va) (mapped+(va)-0x400000) +#define F(g,off) (*(float*)((g)+(off))) +static void require(int condition,const char*message){if(!condition){fprintf(stderr,"FAIL %s\n",message);exit(2);}} +static void __cdecl mouse(short*x,short*y){*x=mouse_x;*y=mouse_y;} +static int TC supported(void*self){(void)self;return grounded;} +static float* TC rotation(void*self,float*out){(void)self;memcpy(out,euler,sizeof(euler));return out;} +static void TC desired(void*self,float x,float y,float z){(void)self;destination[0]=x;destination[1]=y;destination[2]=z;} +static void TC sound(void*self,int mode){(void)self;(void)mode;} +static void TC missing(void*self){(void)self;require(0,"unexpected virtual");} +static const struct{uint32_t va,target;} relocations[]={ +/* RELOCATIONS */ +}; +static void map_copy(void){ + mapped=VirtualAlloc(NULL,0x299000,MEM_COMMIT|MEM_RESERVE,PAGE_EXECUTE_READWRITE); + require(mapped!=NULL,"map copied source"); + FILE*f=fopen("Neutron.exe","rb");require(f!=NULL,"copied EXE"); + fseek(f,0,SEEK_END);long size=ftell(f);rewind(f);require(size==1019904,"bounded EXE size"); + unsigned char*data=malloc(size);require(data!=NULL,"file buffer"); + require(fread(data,1,size,f)==(size_t)size,"read source");fclose(f); + require(*(uint16_t*)data==IMAGE_DOS_SIGNATURE,"DOS header"); + uint32_t offset=*(uint32_t*)(data+0x3c);require(offset<(uint32_t)size-sizeof(IMAGE_NT_HEADERS32),"NT bounds"); + IMAGE_NT_HEADERS32*nt=(void*)(data+offset); + require(nt->Signature==IMAGE_NT_SIGNATURE&&nt->FileHeader.Machine==IMAGE_FILE_MACHINE_I386&&nt->OptionalHeader.ImageBase==0x400000&&nt->OptionalHeader.SizeOfImage==0x299000,"PE identity"); + IMAGE_SECTION_HEADER*sections=IMAGE_FIRST_SECTION(nt); + require((unsigned char*)(sections+nt->FileHeader.NumberOfSections)<=data+size,"section table"); + for(unsigned i=0;iFileHeader.NumberOfSections;i++){ + IMAGE_SECTION_HEADER*s=§ions[i]; + require((uint64_t)s->PointerToRawData+s->SizeOfRawData<=(uint64_t)size&&(uint64_t)s->VirtualAddress+s->SizeOfRawData<=0x299000,"section bounds"); + memcpy(mapped+s->VirtualAddress,data+s->PointerToRawData,s->SizeOfRawData); + } + free(data); + for(unsigned i=0;i str: + return hashlib.sha256(data).hexdigest() + + +def _json(path: Path, value): + path.write_text(json.dumps(value, separators=(',', ':'), allow_nan=False)+'\n', encoding='utf-8') + + +def export_rocketship(original: Path, output: Path) -> dict: + original, output = original.resolve(), output.resolve() + if output.is_relative_to(original) or original.is_relative_to(output): + raise ValueError('Output must be separate from the original installation') + if output.exists() and any(p.is_symlink() for p in output.rglob('*')): + raise ValueError('Generated Rocketship paths must not contain symlinks') + paths = {name: resolve_asset(original, name) for name in SOURCES} + for name, path in paths.items(): + if digest(path.read_bytes()) != SOURCES[name]: + raise FormatError(f'Unexpected original Rocketship source identity: {name}') + animations = {name: read_ase(path) for name, path in paths.items() if name.startswith('ASE/')} + for stem, base, _, vertices, faces, times in CLIPS: + animation = animations[f'ASE/{stem}.ASE'] + if len(animation['objects']) != 1: + raise FormatError('Unexpected Rocketship animation object count') + samples = animation['objects'][0]['samples'] + if tuple(s['time'] for s in samples) != times or any( + (len(s['vertices']), len(s['faces'])) != (vertices, faces) for s in samples): + raise FormatError('Unexpected Rocketship source mesh or sample times') + topology = animations[f'ASE/{base}.ASE']['objects'][0]['samples'][0] if base else samples[0] + if len(topology['vertices']) != vertices or not topology['textureFaces']: + raise FormatError('Rocketship morph base lacks compatible textured topology') + textures, rgba_pixels = {}, {} + for stem, width, height, rgba_sha in TEXTURES: + decoded = read_png(paths[f'png/{stem}.png']) + rgba = decoded.pop('rgba') + if (decoded['width'], decoded['height'], len(rgba), digest(rgba)) != ( + width, height, width*height*4, rgba_sha): + raise FormatError('Unexpected Rocketship decoded pixels') + textures[stem] = dict(path=f'../{stem}.rgba', source=paths[f'png/{stem}.png'].name, + sourceSha256=SOURCES[f'png/{stem}.png'], rgbaSha256=rgba_sha, **decoded) + rgba_pixels[stem] = rgba + level = parse(paths['gam/VR02.gam'].read_bytes()) + entities = [dict(ordinal=index, **asdict(entity)) for index, entity in enumerate(level.entities)] + rockets = [e for e in entities if e['kind'] == '3ROC'] + if len(entities) != 18 or len(rockets) != 1 or rockets[0]['offset'] != 0x1cd: + raise FormatError('Unexpected VR02 authored Rocketship identity') + database = Database(paths['omt/VR02.omt']) + shape_entries = [entry for entry in database.entries if entry.type == '3DSh'] + if len(shape_entries) != 1: + raise FormatError('Unexpected VR02 static shape set') + entry = shape_entries[0] + shape = read_shape(database.payload(entry)) + if (entry.id, entry.name, entry.offset, entry.size, len(shape['vertices']), len(shape['polygons'])) != ( + 0, 'Box01', 74464, 93802, 424, 880): + raise FormatError('Unexpected VR02 static mesh metadata') + material_counts = Counter(str(p['material']['id']) if p['material'] else 'null' for p in shape['polygons']) + static = dict(source='VR02.omt', sha256=SOURCES['omt/VR02.omt'], shapeId=entry.id, + shapeName=entry.name, sourceOffset=entry.offset, sourceBytes=entry.size, + indexedVertices=424, polygons=880, materialPolygons=dict(sorted(material_counts.items())), + registrationPolicy='Asset inventory only; game-class filter and actor body admission require source proof') + manifest = dict(schema=1, sources=SOURCES.copy(), animations=[], + tutorial=dict(source='VR02.gam', sha256=SOURCES['gam/VR02.gam'], entities=entities), + staticGeometry=static, + bindingPolicy='Original resource data; caller owns verified action selection, attachment, transforms, material flags and timing') + output.mkdir(parents=True, exist_ok=True) + for stem, rgba in rgba_pixels.items(): + (output/f'{stem}.rgba').write_bytes(rgba) + for stem, base, texture, vertices, faces, times in CLIPS: + animation = export_ase(paths[f'ASE/{stem}.ASE'], output/stem, + paths[f'ASE/{base}.ASE'] if base else None) + animation['texture'] = textures[texture] + _json(output/stem/'animation.json', animation) + manifest['animations'].append(dict(source=paths[f'ASE/{stem}.ASE'].name, + path=f'{stem}/animation.json', texture=texture, + indexedVertices=vertices, polygons=faces, sourceTimes=list(times))) + _json(output/'rocketship.json', manifest) + return manifest + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('original', type=Path) + parser.add_argument('--output', type=Path, required=True) + args = parser.parse_args() + export_rocketship(args.original, args.output) + print(f'Original Rocketship resources exported: {args.output}/rocketship.json') + + +if __name__ == '__main__': + main()