diff --git a/README.md b/README.md index 26ebcfa..c761b1f 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ jump, and holding jump uses the jet pack after obtaining it. **O** raises/lowers the objective panel. **R** resets the scene placement with current progression; **C** pauses into inspection, **F11** toggles fullscreen, **Escape** quits during ordinary play. Use `--skip-intro` to begin with control or `--mute` for silent play. +The lab camera sequence stops background music and DEFAULT restarts it when +control returns, including after skipping. The original lab pickup is internally tagged `shrinkray`; the original objective art identifies it as the **jet pack**. Its practice prompt accepts **Y** or a click diff --git a/docs/analysis/sound-effects.md b/docs/analysis/sound-effects.md index a09dd70..4c54db5 100644 --- a/docs/analysis/sound-effects.md +++ b/docs/analysis/sound-effects.md @@ -43,3 +43,30 @@ output in Original. Managed merge tests reject conflicting identities. The SDL dummy-device --effects-audio-smoke consumes original58/59 streams, retains a one-shot while stopping the loop, adds230 independently and clears all streams. No physical speaker, original timing/position or native Windows audio claim follows. + + +## Cutscene music correction from user testing + +The user reported music continuing during cutscenes in the packaged build. +The prior consumer always looped STRT music underneath all speech. Original CAM +activation416776..4167E1 explicitly checks current music database696004, obtains +Jimmy complete+0xA38 handle, calls47D7A0(handle,0), unloads his selected music +archive+0xA4C and clears696004. This happens before the new speech starts. +DEFAULT447D5C returns early if Jimmy already controls the player; otherwise +447F12..447F45 reloads his selected music and starts it again (source wave0). + +SceneDirector now emits MusicStopped before an actual CAM speech and MusicRestarted +when DEFAULT returns control from a sequence. SceneAudio disposes the music stream +on stop and restarts the selected track on return; this is a restart, not a silent +advancing/resumed loop. Speech, effects and source scene actions remain separate. +The lab chain begins with CAM, so music stays stopped through its intervening MCA +shots until DEFAULT. A standalone MCA has its own source path431280; a universal +mute-on-any-speech rule is not established and has not been invented. + +Seven exact EXE instruction checks guard the stop/restart sites. Director tests +check stop-before-speech, silence between chained shots, one natural restart, +no repeat restart with Jimmy already controlled, and skip restoration. The SDL +dummy --cutscene-audio-smoke runs the actual16-cue lab chain against original audio +resources and verifies zero queued music throughout, natural restart, reset silence +and skip restart. It passes. This fixes the implemented lab music lifecycle; +physical output/native Windows comparison remains user/runtime validation work. diff --git a/docs/architecture.md b/docs/architecture.md index 27fdc01..c57aeaa 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -108,3 +108,10 @@ SceneAudio mixes independent SDL streams for music/speech/one-shots and owner-ke effect loops. Pickup and mechanism events are connected, including loop stop on bar movement completion/reset. Original positional/channel/volume policies and jetpack sound callbacks remain open; no online audio or services are used. + + +Original CAM music stop and DEFAULT restart are director events subscribed by +SceneAudio. Stopping disposes the loop and retains its selected resource identity; +return starts the selected track again. Standalone speech streams do not decide +music policy. Tests distinguish source CAM lifecycle from generic music/speech +mixing and cover natural completion, reset and skip. diff --git a/docs/compatibility.md b/docs/compatibility.md index 0e06408..b18411f 100644 --- a/docs/compatibility.md +++ b/docs/compatibility.md @@ -35,11 +35,11 @@ separate evidence categories. **The game is not fully reconstructed/playable yet | TSK saves/task gates | All12 originals byte-round-trip | Bounded parse/write, task/items/score/checkpoint CLI resume; full game-state/menu save incomplete | | Lab CAM/MCA/AI interpreter | Source sequence tests + Linux GPU pass |16 speech cues, recovered camera formulas, skip/actions/control restoration; no original comparison | | Dynamic actors/sprites/models | Linux GPU pass |Carl/Goddard/Jimmy morphs, source Canv timing and9 original lab props; billboard/alpha, pivots and playback timing remain provisional | -| Scene music/speech | Linux dummy-device pass |Independent stream consumption and speech replacement; speakers/latency/Windows audio unverified | +| Scene music/speech | Linux dummy-device pass |CAM stops music before speech; full lab chain stays silent, DEFAULT restarts on completion/skip; reset tested. Packaged Linux/Wine64 lifecycle checks pass; speakers/latency/native Windows unverified | | VR01 star/trophy contacts | Source-data tests pass |5-point stars,300 trophy, acquired flags and contact-enter semantics; distance/exclusions/box approximation | | RETURN / renderer recreation | Linux headless pass |Original VR01 RETURN dispatch renders VR01 thenLV1B, zero validation errors; fades/window transition unverified | | Supplied scene availability |All35 GAMs supplied;33 have OMT geometry |Level3B/E GAMs are duplicate four-entity records apart from level code; registered OMT archives absent, normal gameplay use unverified; no substitution or established blocker | -| Lab task/contact route | Managed and headless GPU pass |Explanation/jetpack/Carl/exit reachesSCENE60, score150 andlevel1; direct contacts do not verify navigation | +| Lab task/contact route | Managed input replay + headless GPU pass |888 input-only movement steps with live contacts/NPC updates reachSCENE60, score150, jetpack andlevel1; separate direct-contact GPU rebuild check | | Patrol/support |10 patrol +13 support groups pass |Source phases/profiles and8 DLL magnitude refs; Carl sensing, Goddard follow and full wall response incomplete | | Buttons/doors | Source state tests and GPU props pass |Cooldown, hold/reversal, original model transforms; source broadphase/box order with modern narrowphase | | Dynamic collision |10 managed groups pass |Includes actual closed/open lab bars; full source solver/activation exclusions incomplete | diff --git a/docs/progress.md b/docs/progress.md index 72b0580..c88d625 100644 --- a/docs/progress.md +++ b/docs/progress.md @@ -4,6 +4,25 @@ user-verified Windows rendering checkpoint into an interactive original lab and jet pack tutorial flow. This is not a verified faithful complete scene or release. +## Latest user-tested correction + +User testing found background music continuing during cutscenes. Recovered CAM +416776..4167E1 stops/unloads the selected music; DEFAULT447F12..447F45 restarts it +when control returns. The runtime now performs that handoff. Source-byte/director +checks and actual SDL dummy streams verify silence through all16 lab cues, normal +completion restart, reset silence and skip restart. See analysis/sound-effects.md. +Both platform executables were republished with this correction. The packaged +Linux and isolated Wine64 Windows executables pass the full music-lifecycle audio +check. Linux packaged prompt/input/resize still passes with zero Vulkan validation +errors. Native Windows listening remains unverified by the agent; source user +report and exact static rules support this fix. + +An additional managed replay now walks through explanation, jet pack, Carl and +outside LOAD using only movement inputs, source live contacts and NPC patrol/body +updates. It reachesSCENE60/score150 with jet pack owned after888 movement steps +and7100.55 travel; the player is never repositioned. This strengthens port lab +navigation coverage without proving original collision/cadence fidelity. + ## Current integrated behavior - Default play runs LV1B STARTEXP and its16-cue CAM/MCA/AI camera/speech sequence. @@ -57,7 +76,7 @@ confidence and approximation boundaries are retained there. Managed checks cover source data, director/actions/cameras, task/interactions, patrol, recovered support, moving-box collision, jetpack states and HUD composition. -Python currently has35 top-level regression tests plus2 targeted UI extraction tests. +Python currently has36 top-level regression tests plus2 targeted UI extraction tests. Existing11 collision and13 movement groups pass;14 jetpack groups pass. Eight quick-magnitude float results are checked against an isolated original DLL probe. Original mode2 standing/jump animation probes confirm zero dynamic-point offsets @@ -70,9 +89,12 @@ jumps once, rises418.98 units and lands; VR immunity retains20 energy. The ordin with the explicit state table. These measurements verify port behavior only. See artifacts/full-integration-test.log and practice/jetpack logs for current checks. -The full scripts/test.sh integration passed:35 Python regressions,2 targeted UI +The full scripts/test.sh integration passed at c929f94:35 Python regressions,2 targeted UI checks, all managed groups, GPU story/route/practice/VR04 replays, SDL dummy streams -and539 unchanged original hashes. Both self-contained packages rebuilt successfully. +and539 unchanged original hashes. The subsequent music correction passes targeted +source-byte/director/SDL audio checks on both packages, plus native Linux window +and input-only managed navigation regressions; hashes were reverified. +Both self-contained packages rebuilt successfully. Linux package runs the12s story without SDK/source/Original mounted, zero Vulkan validation errors. Its GTX1070/Xvfb practice window pauses, receives N, resumes11 steps and resizes800x600 with zero validation errors and original pickup audio. diff --git a/docs/tasks.md b/docs/tasks.md index 853b2b2..6919c3e 100644 --- a/docs/tasks.md +++ b/docs/tasks.md @@ -24,12 +24,14 @@ compile, runtime and original-fidelity verification are separate. ## Immediate continuation -1. Integration suite and both packages pass; commit this stable milestone locally. - Keep native Windows story/input/audio pending and preserve current evidence. - Re-run checks only when new changes or unresolved concerns justify them. -2. Exercise the lab route through actual walking/navigation, buttons and doors. - Current lab-route smoke directly invokes source contacts; it is not navigation - or original-fidelity evidence. Recover runtime42AF00 checkpoint restoration on +1. Integration milestone c929f94 and the subsequent cutscene music/navigation + correction are implemented/tested and republished. Preserve native Windows + story/input/audio as pending; source user feedback is distinct from agent Wine + checks. Continue original physics/audio/UI recovery and lab underground traversal. +2. Managed input-only lab navigation now reaches the outside LOAD with live source + contacts and NPC updates. Keep the direct-contact smoke distinguished from this + replay. Extend coverage to underground button/door traversal and runtime + reference comparison. Recover runtime42AF00 checkpoint restoration on VR return separately from saved STRT/RETURN strings and unknown TSK StoredVector. 3. Recover47BD80 collision response/479D20 movement phase and source object exclusions. Support trace/magnitude/radii/factors and dynamic broadphase are recovered; diff --git a/scripts/package.sh b/scripts/package.sh index 1e66f64..4b3fefb 100755 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -31,6 +31,11 @@ for rid in linux-x64 win-x64; do cp docs/dependencies.md "$out/licenses/DEPENDENCIES.md" cp -a docs/. "$out/docs/" cp README.md "$out/SOURCE-README.md" + { + printf 'source_commit=%s\n' "$(git rev-parse HEAD)" + printf 'source_dirty=%s\n' "$(if [[ -n "$(git status --porcelain)" ]]; then echo yes; else echo no; fi)" + printf 'packaged_utc=%s\n' "$(date -u +%FT%TZ)" + } > "$out/BUILD-INFO.txt" cat > "$out/README.md" <<'NOTES' # Neutron lab story and jet pack checkpoint diff --git a/scripts/test.sh b/scripts/test.sh index 4249126..b28d1ce 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -10,6 +10,7 @@ dotnet run --project tests/GamePort.DirectorTests -- ../Original dotnet run --project tests/GamePort.PatrolTests -- ../Original dotnet run --project tests/GamePort.SupportTests -- ../Original dotnet run --project tests/GamePort.InteractionTests -- ../Original +dotnet run --project tests/GamePort.LabRouteTests -- ../Original dotnet run --project tests/GamePort.DynamicCollisionTests -- ../Original dotnet run --project tests/GamePort.JetpackTests python3 tests/GamePort.HudTests/test_ui.py @@ -38,6 +39,7 @@ PY SDL_AUDIODRIVER=dummy dotnet run --no-build -- --effects-audio-smoke artifacts/extracted/effects/effects.json SDL_AUDIODRIVER=dummy dotnet run --no-build -- --audio-smoke artifacts/extracted/sounds/Wave_00000001_save.wav SDL_AUDIODRIVER=dummy dotnet run --no-build -- --scene-audio-smoke artifacts/extracted/level1b/entities/entities.json +SDL_AUDIODRIVER=dummy dotnet run --no-build -- --cutscene-audio-smoke artifacts/extracted/level1b/entities/entities.json python3 tools/recon/inventory.py ../Original --verify docs/original-manifest.json if [[ "${NEUTRON_WINDOW_TEST:-0}" == 1 ]]; then dotnet run --no-build -- --smoke-practice-window --frames 12 --screenshot artifacts/test-practice-window.ppm diff --git a/src/GamePort/Audio/SceneAudio.cs b/src/GamePort/Audio/SceneAudio.cs index 5875774..3603211 100644 --- a/src/GamePort/Audio/SceneAudio.cs +++ b/src/GamePort/Audio/SceneAudio.cs @@ -7,6 +7,7 @@ public sealed class SceneAudio : IDisposable { private readonly PreparedEntityResources resources; private SdlAudio? music, speech; + private (string Database, int Id)? selectedMusic; private readonly List effects = []; private readonly Dictionary loops = new(StringComparer.OrdinalIgnoreCase); public int EffectCount => effects.Count; @@ -17,8 +18,15 @@ public sealed class SceneAudio : IDisposable public SceneAudio(PreparedEntityResources resources) => this.resources = resources; public void Music(string database, int id) { - music?.Dispose(); music = null; - if (resources.Wave(database, id) is { } wave) music = new(wave.Path, true); + selectedMusic = (database, id); + RestartMusic(); + } + public void StopMusic() { music?.Dispose(); music = null; } + public void RestartMusic() + { + StopMusic(); + if (selectedMusic is { } selection && resources.Wave(selection.Database, selection.Id) is { } wave) + music = new(wave.Path, true); } public void Speech(string database, int id) { @@ -57,5 +65,5 @@ public sealed class SceneAudio : IDisposable for (var i = effects.Count - 1; i >= 0; i--) if (effects[i].QueuedBytes == 0) { effects[i].Dispose(); effects.RemoveAt(i); } } - public void Dispose() { StopEffects(); StopSpeech(); music?.Dispose(); music = null; } + public void Dispose() { StopEffects(); StopSpeech(); StopMusic(); } } diff --git a/src/GamePort/Game/SceneDirector.cs b/src/GamePort/Game/SceneDirector.cs index f284a87..2d66e80 100644 --- a/src/GamePort/Game/SceneDirector.cs +++ b/src/GamePort/Game/SceneDirector.cs @@ -80,6 +80,8 @@ public sealed class SceneDirector public Vector3? CameraEye { get; private set; } public Vector3? CameraTarget { get; private set; } public event Action? Speech; + public event Action? MusicStopped; + public event Action? MusicRestarted; public event Action? ActorChanged; public event Action? Unsupported; @@ -359,6 +361,10 @@ public sealed class SceneDirector if (!IsNone(animation)) { target.Animation = animation!; ActorChanged?.Invoke(target); } shot = new Shot(entity, index, target, duration); UpdateCamera(shot); + // CAM416776..4167E1 stops the selected music handle and unloads its + // database before speech. Do not infer this from every speech stream: + // standalone MCA activation has a separate source path. + if (index < 0) MusicStopped?.Invoke(); Speech?.Invoke(database, sound); } @@ -482,11 +488,15 @@ public sealed class SceneDirector private void RestoreControl() { + var wasControlled = Controlled; shot = null; ControlledTag = level.Player?.Tag; InventoryEnabled = true; CameraEye = CameraTarget = null; skipping = false; + // DEFAULT447D5C skips the restart if Jimmy already owns control; + //447F12..447F45 reloads his selected music and starts wave0 again. + if (!wasControlled) MusicRestarted?.Invoke(); // Original DEFAULT invokes a Jimmy help/inventory callback at SCENE30; // it does not assign a new task value or complete the lab. } diff --git a/src/GamePort/Program.cs b/src/GamePort/Program.cs index aafc669..b09489d 100644 --- a/src/GamePort/Program.cs +++ b/src/GamePort/Program.cs @@ -69,6 +69,7 @@ internal static class Program --audio PATH Play recovered WAV; --loop-audio repeats it --audio-smoke PATH Verify audio-stream consumption --scene-audio-smoke PATH Verify music/speech streams from entities.json + --cutscene-audio-smoke PATH Verify original cutscene music stop/restart --effects-audio-smoke PATH Verify default effect bank and loop lifetime --smoke-transition Headless VR01 RETURN / renderer-recreation check --smoke-lab-route Headless source lab contact route / next-scene rebuild @@ -98,6 +99,33 @@ internal static class Program if (parent.Exists && parent.LinkTarget != null) throw new ArgumentException("Save output directory must not redirect through a symbolic link"); } if (args.Contains("--verify-assets")) return VerifyAssets(root); + if (Option(args, "--cutscene-audio-smoke") is { } cutsceneManifest) + { + var bank = new PreparedEntityResources(cutsceneManifest); + var cutsceneLevel = GamLevel.Load(AssetPath.Resolve(root, "gam/level1b.gam")); + var cutsceneSave = OriginalSave.Load(AssetPath.Resolve(root, "NewGame.tsk")); + var cutscene = new SceneDirector(cutsceneLevel, new TaskStates(cutsceneSave.Tasks), bank.Duration); + using var mixer = new SceneAudio(bank); + cutscene.Speech += mixer.Speech; + cutscene.MusicStopped += mixer.StopMusic; + cutscene.MusicRestarted += mixer.RestartMusic; + mixer.Music("musicsecretlab.omt", 0); + if (mixer.QueuedMusicBytes <= 0) throw new InvalidOperationException("No gameplay music before cutscene test"); + cutscene.Begin(cutsceneLevel.FindStart()!); + var silentDuring = mixer.QueuedMusicBytes == 0 && mixer.QueuedSpeechBytes > 0; + for (var tick = 0; tick < 18000 && !cutscene.Controlled; tick++) + { + cutscene.Step(FixedStepClock.Step); + if (!cutscene.Controlled && mixer.QueuedMusicBytes != 0) silentDuring = false; + } + var naturalRestart = cutscene.Controlled && mixer.QueuedMusicBytes > 0; + cutscene.Begin(cutsceneLevel.FindStart()!); + var resetSilent = mixer.QueuedMusicBytes == 0; + mixer.StopSpeech(); cutscene.Skip(); + var skipRestart = cutscene.Controlled && mixer.QueuedMusicBytes > 0; + Console.WriteLine($"Cutscene audio: music silent through intro={silentDuring}, natural restart={naturalRestart}, reset silent={resetSilent}, skip restart={skipRestart}."); + return silentDuring && naturalRestart && resetSilent && skipRestart ? 0 : 2; + } if (Option(args, "--effects-audio-smoke") is { } effectsManifest) { using var mixer = new SceneAudio(new PreparedEntityResources(effectsManifest)); @@ -325,6 +353,8 @@ internal static class Program if (sceneAudio != null) { director.Speech += sceneAudio.Speech; + director.MusicStopped += sceneAudio.StopMusic; + director.MusicRestarted += sceneAudio.RestartMusic; interactions!.SoundEffect += id => sceneAudio.Effect(id); mechanisms!.Sound += (actor, id, loop) => sceneAudio.Effect(id, loop ? actor.Tag : null); mechanisms.StopSound += actor => sceneAudio.StopLoop(actor.Tag); diff --git a/tests/GamePort.DirectorTests/Program.cs b/tests/GamePort.DirectorTests/Program.cs index dccbed8..6284363 100644 --- a/tests/GamePort.DirectorTests/Program.cs +++ b/tests/GamePort.DirectorTests/Program.cs @@ -10,12 +10,19 @@ var save = OriginalSave.Load(AssetPath.Resolve(root,"NewGame.tsk")); var tasks = new TaskStates(save.Tasks); var director = new SceneDirector(level,tasks,(_,_)=>.1); var cues = 0; -director.Speech += (_,_)=>cues++; +var musicPlaying = true; +var musicRestarts = 0; +director.MusicStopped += () => musicPlaying = false; +director.MusicRestarted += () => { musicPlaying = true; musicRestarts++; }; +director.Speech += (_,_)=>{ Check(!musicPlaying,"Lab cutscene music must stop before speech and stay stopped between shots"); cues++; }; director.Begin(level.FindStart()!); Check(!director.Controlled && director.CurrentTag == "LABEXP1", "STRT must freeze into original first camera"); for(var i=0;i<200 && !director.Controlled;i++) director.Step(.1f); Check(director.Controlled && !director.Blocked && cues>10, "Complete original intro trigger/camera chain"); Check(tasks.Get("SCENE")==30, "Intro must not invent a progression/task advance"); +Check(musicPlaying && musicRestarts == 1,"DEFAULT must restart selected music after natural intro completion"); +director.Trigger("default"); +Check(musicRestarts == 1,"DEFAULT with Jimmy already controlled must not restart music"); var endGoddard = director.FindActor("C3DGODDARD")!.Position; Check(endGoddard==director.FindActor("phone2")!.Position,"AI teleport position actions must execute"); Check(director.Issues.Any(x=>x.Detail.Contains("Patrol")),"Unsupported patrol must remain explicit"); @@ -23,10 +30,15 @@ Console.WriteLine($"PASS original lab sequence: {cues} original speech cues, cor var skip = new SceneDirector(level,new TaskStates(save.Tasks),(_,_)=>10); var skipCues=0; +var skipMusicPlaying=true; +skip.MusicStopped+=()=>skipMusicPlaying=false; +skip.MusicRestarted+=()=>skipMusicPlaying=true; skip.Speech += (_,_)=>skipCues++; skip.Begin(level.FindStart()!); +Check(!skipMusicPlaying,"First CAM must stop gameplay music"); skip.Skip(); Check(skip.Controlled && !skip.Blocked && skipCues==1,"Skip must fast-forward voices and return control"); +Check(skipMusicPlaying,"Skipping must restore selected gameplay music"); Check(skip.FindActor("C3DGODDARD")!.Position==endGoddard,"Skip must preserve AI/toggle actions"); Console.WriteLine("PASS original intro skip preserves action sequence"); diff --git a/tests/GamePort.LabRouteTests/GamePort.LabRouteTests.csproj b/tests/GamePort.LabRouteTests/GamePort.LabRouteTests.csproj new file mode 100644 index 0000000..06c0804 --- /dev/null +++ b/tests/GamePort.LabRouteTests/GamePort.LabRouteTests.csproj @@ -0,0 +1,9 @@ + + Exenet10.0enableenablefalse + + + + + + + diff --git a/tests/GamePort.LabRouteTests/Program.cs b/tests/GamePort.LabRouteTests/Program.cs new file mode 100644 index 0000000..e9e39cd --- /dev/null +++ b/tests/GamePort.LabRouteTests/Program.cs @@ -0,0 +1,104 @@ +using System.Numerics; +using GamePort.Assets; +using GamePort.Game; +using GamePort.Application; + +// An explicit modern input replay, not recovered original navigation/AI. The +// player is never repositioned and all contacts use the live collision result. +var original = Path.GetFullPath(args.Length == 1 ? args[0] : "../Original"); +var prepared = Path.GetFullPath("artifacts/extracted"); +var level = GamLevel.Load(AssetPath.Resolve(original, "gam/level1b.gam")); +var start = level.FindStart()!; +var world = Mesh.LoadSceneJson(Path.Combine(prepared, "level1b/scene.json")); +var save = OriginalSave.Load(Path.Combine(original, "NewGame.tsk")); +var tasks = new TaskStates(save.Tasks); +var resources = new PreparedEntityResources(Path.Combine(prepared, "level1b/entities/entities.json")); +var director = new SceneDirector(level, tasks, resources.Duration); +var interactions = new SceneInteractions(director, tasks, save, level.Code); +var mechanisms = new SceneMechanisms(director); +var visuals = new StaticSceneVisuals(world, director, original, Path.Combine(prepared, "level1b/models")); +var simulation = new LabSimulation(new SceneCollision(world), AseMesh.Load(AssetPath.Resolve(original, "ASE/jimstop.ase")), + start.Position, start.Rotation.Y) { JetpackInventoryState = () => interactions.Inventory.State(0, 3) }; +simulation.DynamicRootResolver = (before, after, radius) => DynamicBodyResponse.Resolve(visuals.DoorColliders(), before, after, radius); +var patrols = new List(); +foreach (var actor in director.Actors.Where(a => a.Kind is "3DOG" or "3CAR")) +{ + var physics = new OriginalScenePhysics(world); + var grounded = false; + var patrol = new ActorPatrol(actor, director.FindActor, (body, dt) => + { + var step = physics.Step(body.Position, body.Velocity, actor.Kind == "3DOG" ? 130 : 100, + actor.Kind == "3DOG" ? .3f : .75f, grounded, dt); + grounded = step.Supported; + return new(step.Body.Position, step.Body.Velocity); + }); + patrols.Add(patrol); + director.RegisterPatrolConsumer(actor.Tag); + director.ActorChanged += changed => { if (ReferenceEquals(changed, actor)) patrol.SynchronizeAuthoredState(); }; +} +var practice = new PracticePrompt(); +interactions.PracticeRequested += practice.Show; +var prompts = 0; +LevelTransition? destination = null; +interactions.Transition += request => destination ??= request; +director.Begin(start); +interactions.Reset(); mechanisms.Reset(); director.Skip(); + +Vector2 Point(string tag) +{ + var p = director.FindActor(tag)!.Position; + return new(p.X, p.Z); +} +// Source trigger/item/marker/exit locations plus an explicit doorway approach. +// The approach avoids the wall outside the authored exit opening. +var exit = Point("LABTONEIGH"); +var route = new[] { Point("teleportexplanation"), Point("shrinkray"), Point("CARLESC3"), + new Vector2(exit.X, 500), exit }; +var sceneStates = new[] { 35, 50, 60, 60, 60 }; +for (var leg = 0; leg < route.Length && destination == null; leg++) +{ + var arrived = false; + for (var tick = 0; tick < 2400; tick++) + { + if (practice.Active) + { + Require(practice.Mode == 0, "Wrong lab practice mode"); + practice.Key(17, Vector2.Zero); // N resumes; no direct task/pickup mutation. + prompts++; + } + var difference = route[leg] - new Vector2(simulation.Position.X, simulation.Position.Z); + if (difference.Length() < 90) { arrived = true; break; } + var desiredYaw = MathF.Atan2(-difference.X, difference.Y) * 180 / MathF.PI; + var error = MathF.IEEERemainder(desiredYaw - simulation.Yaw, 360); + if (director.Controlled) + { + var previous = simulation.ActorRoot; + simulation.Step(new(MathF.Abs(error) < 30, false, error > 1, error < -1, false)); + Require(Vector3.Distance(previous, simulation.ActorRoot) < 100, "Player warped during input replay"); + director.SyncActor(level.Player!.Tag!, simulation.ActorRoot, new(0, simulation.Yaw, 0)); + director.Touch(level.Player!.Tag!, simulation.ActorRoot); + interactions.Update(simulation.ActorRoot, simulation.InteractionRadius); + if (practice.Active) continue; // Same modal activation boundary as Program. + mechanisms.Update(simulation.ActorRoot, simulation.InteractionRadius); + } + mechanisms.Step(FixedStepClock.Step); + foreach (var patrol in patrols) patrol.Step(FixedStepClock.Step); + director.Step(FixedStepClock.Step); + if (destination != null) break; + } + Require(arrived || destination != null, $"Input route blocked at leg{leg}: {simulation.ActorRoot}"); + Require(tasks.Get("SCENE") == sceneStates[leg], $"Wrong task state after walking leg{leg}"); + Console.WriteLine($"PASS walked leg{leg}: SCENE={tasks.Get("SCENE")}, root={simulation.ActorRoot}"); +} +Require(destination is { LevelFile: "level1.gam", StartPoint: "level1" }, "Walking did not enter the source outside LOAD"); +Require(interactions.Score == 150 && interactions.Inventory.State(0, 3) == 1 && prompts == 1, + "Walking route did not preserve jetpack/Carl score, inventory and practice dispatch"); +Require(simulation.Steps > 500 && simulation.Travel > 5000 && simulation.Jumps == 0, "Walking route did not exercise actual movement"); +Require(!director.Blocked, "Source director blocked during the walking route"); +Console.WriteLine($"PASS input-only lab route ->level1.gam, score150, jetpack owned, practice declined once. {simulation.Report}"); +Console.WriteLine("This verifies port navigation through the lab; original collision/cadence/behavior fidelity remains unverified."); + +static void Require(bool condition, string message) +{ + if (!condition) throw new InvalidOperationException(message); +} diff --git a/tests/test_sound_bank.py b/tests/test_sound_bank.py index 1c2862f..1904183 100644 --- a/tests/test_sound_bank.py +++ b/tests/test_sound_bank.py @@ -48,6 +48,20 @@ class SoundBankTests(unittest.TestCase): self.assertEqual(exe[0x589de:0x589e3], bytes.fromhex('e8 5d 4c 02 00')) self.assertEqual(exe[0x7d3bc:0x7d3c2], bytes.fromhex('56 68 65 76 61 57')) + def test_cutscene_stops_music_and_default_restarts_original_handle(self): + exe = (ORIGINAL/'Neutron.exe').read_bytes() + for offset, expected in [ + (0x16776, 'a1 04 60 69 00'), # CAM current music database. + (0x16790, '8b 90 38 0a 00 00'), # Jimmy music handle. + (0x16796, '53 52 e8 03 70 06 00'), # Stop(handle,0). + (0x167e1, '89 1d 04 60 69 00'), # Clear current music DB. + (0x47d5c, '3b c6 75 3f'), # DEFAULT skips restart when Jimmy owns control. + (0x47f20, 'a3 04 60 69 00'), # Restore selected music DB. + (0x47f37, '53 6a 00 6a ff 50 e8 ce 57 03 00'), # Wave0,loop. + ]: + raw = bytes.fromhex(expected) + self.assertEqual(exe[offset:offset+len(raw)], raw, hex(offset+0x400000)) + if __name__ == '__main__': unittest.main() diff --git a/tools/recon/reference_capture.py b/tools/recon/reference_capture.py index 13d3cb6..e48d5c4 100644 --- a/tools/recon/reference_capture.py +++ b/tools/recon/reference_capture.py @@ -58,6 +58,10 @@ def inside(args): application += ['--smoke-walk'] if args.port_walk else ['--smoke-practice-window'] if args.port_practice else ['--story', '--story-time', '12'] if args.port_story else ['--inspect', '--time', '0.05'] application += ['--smoke-window'] if args.port_window and not (args.port_walk or args.port_practice) else [] application += [] if args.port_window or args.port_walk or args.port_practice else ['--headless'] + if args.port_cutscene_audio: + application = ['/opt/wine-stable/bin/wine', r'Z:\port\GamePort.exe', + '--assets', r'Z:\port\assets', '--cutscene-audio-smoke', + r'Z:\port\scenes\level1b\entities\entities.json'] if args.asset_probe: application = ['/opt/wine-stable/bin/wine', r'Z:\probe.exe', args.probe_model] wine = subprocess.Popen(application, cwd='/work' if args.port_smoke else '/work/game', stdout=wlog, stderr=wlog, env=wine_env) @@ -99,15 +103,17 @@ def main(): p.add_argument('--port-walk', action='store_true', help='Windows port walking/jump/keyboard/resize checkpoint under Wine64') p.add_argument('--port-story', action='store_true', help='Windows port original-resource story/camera render under Wine64') p.add_argument('--port-practice', action='store_true', help='Windows port practice modal/input/resize under Wine64') + p.add_argument('--port-cutscene-audio', action='store_true', help='Windows port cutscene music lifecycle under Wine64') p.add_argument('--asset-probe', action='store_true', help='Run compiled read-only OMT shape probe inside isolated copy') p.add_argument('--probe-model', default=r'ASE\jimstop.ase') p.add_argument('--probe-executable', type=Path, help='Local probe executable to mount read-only for --asset-probe') p.add_argument('--output', type=Path) args = p.parse_args() - args.port_smoke = args.port_smoke or args.port_window or args.port_walk or args.port_story or args.port_practice + args.port_smoke = args.port_smoke or args.port_window or args.port_walk or args.port_story or args.port_practice or args.port_cutscene_audio if args.port_smoke and args.asset_probe: p.error('Select either port smoke or asset probe') if args.port_story and (args.port_window or args.port_walk or args.port_practice): p.error('Story comparison uses headless fixed time; select one port check') if args.port_practice and (args.port_walk or args.port_window): p.error('Select one windowed port check') + if args.port_cutscene_audio and (args.port_practice or args.port_story or args.port_walk or args.port_window): p.error('Select audio lifecycle or rendering check') if args.probe_executable and not args.asset_probe: p.error('--probe-executable requires --asset-probe') if not 3 <= args.seconds <= 120: p.error('--seconds must be 3..120') if args.inside: return inside(args) @@ -158,15 +164,19 @@ def main(): if args.port_walk: cmd += ['--port-walk'] if args.port_story: cmd += ['--port-story'] if args.port_practice: cmd += ['--port-practice'] + if args.port_cutscene_audio: cmd += ['--port-cutscene-audio'] if args.asset_probe: cmd += ['--asset-probe', '--probe-model', args.probe_model] print('Running isolated Windows port' if args.port_smoke else 'Running copied original', 'with no network and no original-directory mount:', work, flush=True) subprocess.run(cmd, check=True, timeout=args.seconds + 40) print('Capture metadata:', work/'capture.json') if args.port_smoke: result = json.loads((work/'capture.json').read_text()) - if result['captures'][-1]['wineExit'] != 0 or not (work/'port-frame.ppm').is_file(): + evidence_ok = ('Cutscene audio: music silent through intro=True, natural restart=True, reset silent=True, skip restart=True.' + in (work/'wine.log').read_text()) if args.port_cutscene_audio else (work/'port-frame.ppm').is_file() + if result['captures'][-1]['wineExit'] != 0 or not evidence_ok: raise SystemExit('Windows port smoke did not pass; inspect wine.log (native Windows remains unverified)') - print('Windows port rendered under Wine; native Windows validation is still required') + print('Windows port audio lifecycle passed under Wine; native Windows validation is still required' if args.port_cutscene_audio + else 'Windows port rendered under Wine; native Windows validation is still required') if args.asset_probe: result = json.loads((work/'capture.json').read_text()) if result['captures'][-1]['wineExit'] != 0 or 'VERTICES ' not in (work/'wine.log').read_text():