Restore Goddard leveling and Scooter positional pitch processing

This commit is contained in:
UnixNight committed 2026-11-04 18:27:56 -05:00
1 parent 74be19eb15
commit fccc0b9d1b
24 files changed
+967 -8

No files matched your search

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net10.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable><EnableDefaultCompileItems>false</EnableDefaultCompileItems></PropertyGroup>
<ItemGroup>
<Compile Include="Program.cs"/>
<Compile Include="../../src/GamePort/Game/ScooterAudio.cs"/>
<Compile Include="../../src/GamePort/Game/OriginalBodySupport.cs"/>
<None Include="original-frequency-reference.json" CopyToOutputDirectory="PreserveNewest"/>
</ItemGroup>
</Project>
@@ -0,0 +1,27 @@
using System.Numerics;
using System.Text.Json;
using GamePort.Game;
using var doc=JsonDocument.Parse(File.ReadAllText(Path.Combine(AppContext.BaseDirectory,"original-frequency-reference.json")));
int count=0;
foreach(var c in doc.RootElement.GetProperty("cases").EnumerateArray())
{
var i=c.GetProperty("input").EnumerateArray().Select(x=>x.GetSingle()).ToArray();
var o=c.GetProperty("observed").EnumerateArray().Select(x=>x.GetSingle()).ToArray();
float history=i[2];int frequency=ScooterAudio.PositionalFrequency((int)i[0],i[1],ref history);
Check(frequency==(int)o[0]&&history==o[1],$"Copied original position case{count}: {frequency}/{history} != {o[0]}/{o[1]}");count++;
}
Check(count==11,"complete native positional cases");
Console.WriteLine("PASS eleven copied-original positional frequency observations, including zero-distance and signed history");
Check(ScooterAudio.EngineFrequency(11025,1485)==50885,"recovered maximum-speed engine command preserved");
Check(ScooterAudio.EngineFrequency(11025,-594)==7000,"engine-only reverse floor");
var audio=new ScooterAudio();
int adjusted=audio.Frequency(11025,1485,Vector3.Zero,new(0,0,800));
Check(adjusted==50285&&audio.History==600,"listener correction follows nominal engine command");
Check(audio.Frequency(11025,1485,Vector3.Zero,new(0,0,800))==50735&&audio.History==150,"history is last correction rather than distance");
audio.Reset();Check(audio.History==0,"new channel clears history");
Check(audio.Frequency(11025,-594,Vector3.Zero,new(0,0,500))==6625,"positional correction follows7000 engine floor, not a second7000 clamp");
Check(audio.Frequency(11025,1485,Vector3.Zero,Vector3.Zero)==6625&&audio.History==375,"zero distance retains preceding device frequency/history");
Console.WriteLine("PASS engine command, source position adjustment, channel reset and reverse ordering");
static void Check(bool condition,string name){if(!condition)throw new Exception(name);}
@@ -0,0 +1,180 @@
{
"exe_sha256": "f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8",
"dll_sha256": "3ec41ead011adf56387a6dbd4580e5b5a9721b5f8020c8a56420f42824354943",
"ranges": [
{
"kind": "engine",
"va": "0x412ed0",
"file_offset": "0x12ed0",
"length": 185,
"sha256": "c9274c2d5dd0ee80dd96d43840dcd4981e296705f32eca0c1b6a894bed142f42"
},
{
"kind": "channel_start",
"va": "0x47d561",
"file_offset": "0x7d561",
"length": 149,
"sha256": "621a9b9802bf37238103922923bbc56272aeac4d41a58e05dc555c4e3d247854"
},
{
"kind": "position",
"va": "0x47d9d0",
"file_offset": "0x7d9d0",
"length": 590,
"sha256": "8a1ef6303a32a33d95b3cf8ecbdc01b2cebbfa66460bd99294a182e1d1ca73e9"
},
{
"kind": "dx_frequency",
"va": "0x1003bba0",
"file_offset": "0x3bba0",
"length": 90,
"sha256": "d40d2dab6a1f1bce28438e38aa24e2e226eea7993a7fa3def93bed34f77b8024"
}
],
"constants": {
"0x495310": 0.5263157894736842,
"0x495308": 51.0,
"0x49d5ac": 0.75
},
"scope": "Copied original47D9D0 with synthetic actor/channel/engine/camera and original OMT vector/trig; no game entrypoint. Engine formula and DX bounds are statically recovered.",
"cases": [
{
"input": [
11025.0,
200.0,
200.0
],
"observed": [
11025.0,
0.0,
1.0
]
},
{
"input": [
11025.0,
200.0,
0.0
],
"observed": [
10875.0,
150.0,
1.0
]
},
{
"input": [
11025.0,
200.0,
150.0
],
"observed": [
10988.0,
37.0,
1.0
]
},
{
"input": [
11025.0,
200.0,
37.0
],
"observed": [
10903.0,
122.0,
1.0
]
},
{
"input": [
50885.0,
800.0,
0.0
],
"observed": [
50285.0,
600.0,
1.0
]
},
{
"input": [
50885.0,
800.0,
600.0
],
"observed": [
50735.0,
150.0,
1.0
]
},
{
"input": [
11025.0,
100.0,
200.0
],
"observed": [
10950.0,
-75.0,
1.0
]
},
{
"input": [
7000.0,
500.0,
0.0
],
"observed": [
6625.0,
375.0,
1.0
]
},
{
"input": [
11025.0,
0.0,
200.0
],
"observed": [
11025.0,
200.0,
0.0
]
},
{
"input": [
11025.0,
123.75,
100.0
],
"observed": [
11008.0,
17.0,
1.0
]
},
{
"input": [
11025.0,
100.0,
123.75
],
"observed": [
11008.0,
-17.0,
1.0
]
}
],
"files": {
"tools/binary/scooter_pitch.py": "dc46cc2cc73362e1e44fddfdeb68d2b89b21ce69fb4ea376d031ee40a124ef99",
"tools/binary/grappler_scalar_probe.c": "c51cc1ecefaf7a90e69a40624fd0e8cd7e01500359c4e67aee6213bb36f4a810",
"artifacts/scooter-pitch/scooter_pitch_probe.exe": "0b09a95fe4287f79e8c110be5c9d1cf3dbab4cc057db6f9be728003aa3a1b917",
"artifacts/scooter-pitch/probe/wine.log": "3cbce35209b32332cdd86e6b464df4c42781fdc505e635b1116040c1f5c585ba"
}
}
@@ -6,5 +6,6 @@
<Compile Include="../../src/GamePort/Application/PlayerGadgetMaterial.cs"/>
<Compile Include="../../src/GamePort/Application/ScooterVisuals.cs"/>
<None Include="original-motion-reference.json" CopyToOutputDirectory="PreserveNewest"/>
<None Include="original-leveling-reference.json" CopyToOutputDirectory="PreserveNewest"/>
</ItemGroup>
</Project>
+31
View File
@@ -15,6 +15,8 @@ var tests=new(string,Action)[]{("copied-original drive/input/facing/terrain obse
("actual tutorial RETURN accepts the passenger and cleans vehicle",Return),
("original vehicle/wheel/rider geometry stays unit scale",Visuals),
("outside companion follows, freezes while summoned, and returns near Jimmy",Companion),
("tilted dismount preserves handoff then Goddard gradually levels",DismountTilt),
("copied-original Goddard leveling rates and seams",GoddardOriginal),
};
foreach(var(name,test)in tests){test();Console.WriteLine("PASS "+name);}Console.WriteLine($"Scooter integration: {tests.Length} groups passed.");
static void Original()
@@ -132,6 +134,35 @@ static void Companion()
NearV(dog.Position,jimmy.Position+RocketOrientation.Rotate(new(0,0,-800),jimmy.Rotation),"far follow warp");
f.D.EnsureCompanion(jimmy.Position,Vector3.Zero);NearV(dog.Position,jimmy.Position,"explicit reset placement updates existing actor");
}
static void DismountTilt()
{
using var f=new Fixture("VR05");var dog=f.D.FindActor("C3DGODDARD")!;
var patrol=new ActorPatrol(dog,f.D.FindActor,(b,_)=>b){FollowPlayer=true};
f.Summon();f.Mount();
for(int i=0;i<20;i++)f.Frame(new(true,false,true,false,false));
var rotation=f.S.Rotation;Check(Math.Abs(rotation.Z)>10,"actual steering produces vehicle lean");
f.I.Inventory.SelectGadget(-1);NearV(dog.Rotation,rotation,"cleanup copies full source Euler");
static float Tilt(float degrees)=>MathF.Abs((degrees+540)%360-180);
float before=Tilt(dog.Rotation.Z);patrol.Step(.1f);
Check(Tilt(dog.Rotation.Z)<before&&Tilt(dog.Rotation.Z)>before*.9f,"leveling is gradual in next AI phase");
for(int i=0;i<300;i++)patrol.Step(FixedStepClock.Step);
Check(Tilt(dog.Rotation.Z)<before*.25f,"companion does not retain scooter lean");
dog.MovementEnabled=false;rotation=dog.Rotation;patrol.Step(.1f);Check(dog.Rotation==rotation,"disabled companion does not update facing");
}
static void GoddardOriginal()
{
using var document=JsonDocument.Parse(File.ReadAllText(Path.Combine(AppContext.BaseDirectory,"original-leveling-reference.json")));
int compared=0;
foreach(var c in document.RootElement.GetProperty("cases").EnumerateArray())
{
var p=c.GetProperty("input").EnumerateArray().Select(v=>v.GetSingle()).ToArray();
if(p[6]==0||p[7]==0)continue; //Native gate observations are guarded separately.
var o=c.GetProperty("observed").EnumerateArray().Select(v=>v.GetSingle()).ToArray();
var rotation=new Vector3(p[0],p[1],p[2]);for(int i=0;i<(int)p[5];i++)rotation=ActorPatrol.GoddardFacing(rotation,p[3],p[4]);
NearV(rotation,new(o[0],o[1],o[2]),c.GetProperty("name").GetString()!);compared++;
}
Check(compared==9,"nine active native leveling observations");
}
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)<.02f,$"{name}: {a} != {b}");
static void NearV(Vector3 a,Vector3 b,string name)=>Check(Vector3.Distance(a,b)<.04f,$"{name}: {a} != {b}");
@@ -0,0 +1,237 @@
{
"source_sha256": "f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8",
"ranges": [
{
"va": "0x4096e0",
"file_offset": "0x96e0",
"length": 429,
"sha256": "16008268af9cb0e2a04891d3743cb9c9fa36b42e55f67f807c0f97df716cec1d"
},
{
"va": "0x4093bd",
"file_offset": "0x93bd",
"length": 27,
"sha256": "66249ec334f140cd090fe7e25c6476ebfbff6be31a7346c234d10d1ff1e496ee"
},
{
"va": "0x41c8db",
"file_offset": "0x1c8db",
"length": 49,
"sha256": "d30bf58fc7fc8d9b51c6fe88b9135fb33856f5bb53f2ded2a23d7c2000606639"
},
{
"va": "0x472480",
"file_offset": "0x72480",
"length": 240,
"sha256": "406c3904538abe07d88ca440e39ca56c00765d0871943991ba7b792da4803c16"
}
],
"scope": "Copied4096E0 plus472480, Goddard factors, synthetic enabled/dirty actor; no original AI/body/game entrypoint.",
"files": {
"tools/binary/goddard_leveling.py": "ea082906a5b2cb799238f1c4f4d04ac23e5a672f3665cbcf8c4de11ffd4c22ae",
"tools/binary/goddard_leveling_probe.c": "5fb6ce399234fbaaa54f64365f899384c16876fb3722cd90561aeb43786061c5",
"tools/binary/grappler_scalar_probe.c": "c51cc1ecefaf7a90e69a40624fd0e8cd7e01500359c4e67aee6213bb36f4a810",
"artifacts/scooter-dismount-followup/goddard_leveling_probe.exe": "51bdc2b13fda9865b5ad67184195e057396fd339f3bca16f37975c42e01e2270",
"artifacts/scooter-dismount-followup/probe-ready/wine.log": "dac3580123ff07f7c5d97a2d66f3a314b660cbc2ab434bed984f5e910c985584"
},
"cases": [
{
"name": "tilted",
"input": [
20.0,
90.0,
30.0,
90.0,
0.100000001,
1.0,
1.0,
1.0
],
"observed": [
19.3999996,
90.0,
29.1000004
]
},
{
"name": "opposite",
"input": [
340.0,
90.0,
330.0,
90.0,
0.100000001,
1.0,
1.0,
1.0
],
"observed": [
340.600006,
90.0,
330.899994
]
},
{
"name": "seam",
"input": [
350.0,
359.0,
350.0,
1.0,
0.100000001,
1.0,
1.0,
1.0
],
"observed": [
350.299988,
359.640015,
350.299988
]
},
{
"name": "negative",
"input": [
-20.0,
-10.0,
-30.0,
20.0,
0.100000001,
1.0,
1.0,
1.0
],
"observed": [
341.0,
360.0,
331.0
]
},
{
"name": "equal180",
"input": [
180.0,
180.0,
180.0,
0.0,
0.100000001,
1.0,
1.0,
1.0
],
"observed": [
174.600006,
122.399994,
174.600006
]
},
{
"name": "over180",
"input": [
181.0,
181.0,
181.0,
0.0,
0.100000001,
1.0,
1.0,
1.0
],
"observed": [
186.369995,
238.279999,
186.369995
]
},
{
"name": "tick",
"input": [
20.0,
90.0,
30.0,
90.0,
0.0166666675,
1.0,
1.0,
1.0
],
"observed": [
19.8999996,
90.0,
29.8500004
]
},
{
"name": "five_seconds",
"input": [
20.0,
90.0,
30.0,
90.0,
0.0166666675,
300.0,
1.0,
1.0
],
"observed": [
4.44584179,
90.0,
6.6687665
]
},
{
"name": "upright",
"input": [
0.0,
90.0,
0.0,
90.0,
0.100000001,
1.0,
1.0,
1.0
],
"observed": [
0.0,
90.0,
0.0
]
},
{
"name": "disabled",
"input": [
20.0,
90.0,
30.0,
90.0,
0.100000001,
1.0,
0.0,
1.0
],
"observed": [
20.0,
90.0,
30.0
]
},
{
"name": "clean",
"input": [
20.0,
90.0,
30.0,
90.0,
0.100000001,
1.0,
1.0,
0.0
],
"observed": [
20.0,
90.0,
30.0
]
}
]
}
+18
View File
@@ -0,0 +1,18 @@
"""Source identity and saved original Goddard facing observations."""
from pathlib import Path
import hashlib,json,sys,unittest
ROOT=Path(__file__).resolve().parents[1]
sys.path.insert(0,str(ROOT/'tools/binary'))
from goddard_leveling import collect
class GoddardLevelingEvidence(unittest.TestCase):
def test_source_ranges_and_original_offsets(self):
source=collect(ROOT.parent/'Original');fixture=json.loads((ROOT/'tests/GamePort.ScooterTests/original-leveling-reference.json').read_text())
self.assertEqual(source['source_sha256'],fixture['source_sha256']);self.assertEqual(source['ranges'],fixture['ranges'])
for span in source['ranges']:self.assertEqual(int(span['file_offset'],16),int(span['va'],16)-0x400000)
def test_probe_source_provenance_and_gates(self):
fixture=json.loads((ROOT/'tests/GamePort.ScooterTests/original-leveling-reference.json').read_text());self.assertEqual(len(fixture['cases']),11)
for file,hash_ in fixture['files'].items():
if file.startswith('tools/'):self.assertEqual(hashlib.sha256((ROOT/file).read_bytes()).hexdigest(),hash_)
for case in fixture['cases']:
if case['name'] in ('clean','disabled'):self.assertEqual(case['observed'],case['input'][:3])
if __name__=='__main__':unittest.main()
+35
View File
@@ -0,0 +1,35 @@
"""Original engine/positional frequency guards and probe provenance."""
from pathlib import Path
import hashlib
import json
import sys
import unittest
ROOT=Path(__file__).resolve().parents[1]
sys.path.insert(0,str(ROOT/'tools/binary'))
from scooter_pitch import collect
class ScooterPitchEvidence(unittest.TestCase):
def test_original_sources_constants_ranges_and_offsets(self):
source=collect(ROOT.parent/'Original')
fixture=json.loads((ROOT/'tests/GamePort.ScooterAudioTests/original-frequency-reference.json').read_text())
for key in ('exe_sha256','dll_sha256','ranges','constants'):self.assertEqual(source[key],fixture[key])
self.assertEqual(len(source['ranges']),4)
self.assertEqual(source['constants'],{'0x495310':1/1.9,'0x495308':51.,'0x49d5ac':.75})
for row in source['ranges']:
base=0x10000000 if row['kind']=='dx_frequency' else 0x400000
self.assertEqual(int(row['file_offset'],16),int(row['va'],16)-base)
def test_provenance_and_complete_copied_original_cases(self):
fixture=json.loads((ROOT/'tests/GamePort.ScooterAudioTests/original-frequency-reference.json').read_text())
self.assertEqual(len(fixture['cases']),11)
for path,digest in fixture['files'].items():
self.assertEqual(len(digest),64)
if path.startswith('tools/'):
self.assertEqual(hashlib.sha256((ROOT/path).read_bytes()).hexdigest(),digest)
cases=fixture['cases']
self.assertEqual(cases[0]['observed'],[11025,0,1])
self.assertEqual(cases[4]['observed'],[50285,600,1])
self.assertEqual(cases[6]['observed'],[10950,-75,1])
self.assertEqual(cases[8]['observed'],[11025,200,0])
if __name__=='__main__':unittest.main()