Add log file for emulator execution on 2026-10-12

- Created a new log file `log-20261012.txt` to capture emulator activity.
- Logged initialization steps including HTTP API startup, program executor creation, and MCP server launch.
- Captured errors related to missing files during DOS operations.
- Documented invalid opcode exception leading to emulation halt.
- Included detailed state information at the time of errors for debugging purposes.
This commit is contained in:
Maddo 2026-10-13 00:56:16 +02:00
commit 522c52d65d
9 changed files with 238 additions and 152 deletions

View file

@ -98,20 +98,32 @@ There are not yet C# archive or map readers, rendering or simulation systems, a
### M7. No Remorse Startup and Input-Driven Movement Slice - In Progress
- `ShapeData_GetDamagingAndSolidFlags` (`1010:0000`) returns a base mask of `0x8000`, adding `0x0001` for `SI_SOLID` and `0x0020` for `SI_DAMAGING`. `AreaSearch_TestCandidateSweepCollision` (`10e0:032e`) passes only the mover/candidate mask intersection to `AreaSearch_RecordSweepContact` as its blocking boolean; eligible damaging or special contacts can be geometrically recorded without becoming `firstcollision`. The rebuild gates blocking candidates on this mask intersection and uses TYPEFLAG extents for its face sweep. Live disassembly at `10e0:032e` tests positive X/Y/Z faces before negative X/Y/Z faces; the host now follows that priority and retains zero-size TYPEFLAG axes as collision planes instead of dropping those candidates. The installed local map 1 contains 1,221 solid records with at least one zero footpad dimension. Synthetic regressions cover zero X/Y/Z dimensions and the mixed-sign horizontal/vertical corner. Retail shape 1 has `SI_SOLID`; a synthetic non-solid-mover regression verifies that a solid candidate does not block it. Nonblocking damage notifications, special candidate rules, and the native map-fast-area broadphase remain unmodeled.
- Live No Remorse `CRUSADER.EXE` Ghidra evidence: `1020:0000` (`Game_Start`) initializes gameplay and calls `Teleporter_CreateProcessDirect(1, 0x1e, 1)`; `10e8:000c` (`NPC_Init`) initializes avatar item 1 with shape 1/frame 0. Teleporter creation and hatch paths at `1090:04ce`, `1090:0072`, `1090:05fd`, `1090:0718`, and `1090:022d` support the modeled two-hop route. Movement behavior is derived from live decompilation and local static retail assets; runtime comparison is out of scope.
- The configured local map-1 data resolves record 1341 as the `0x1e` staging egg at `(6399,6399,0)`, record 1342 as the active `0x63` trigger (packed range `0x44`, map 1), and record 6556 as the destination egg at `(30328,29656,16)`. The retail corpus is not fingerprint-verified.
- `NoRemorseFreshStart` creates a simulation-owned avatar (shape 1/frame 0), models both teleports, and schedules movement for that same entity. The normal `--data-root <install directory>` path loads map 1 and its local scene; `--map` remains a separate fixed-map diagnostic.
- SDL key handling preserves absolute eight-direction controls with NumLock off. With NumLock on, Up/Down hold advance/reverse and Left/Right request relative turns; turn key repeats produce additional discrete turns. Losing window focus releases held movement. Caps Lock and Shift continue to choose walk versus run. This is the verified cardinal movement subset, not the full DOS keypad, modifier, or action-key controller.
- SDL key handling preserves absolute eight-direction controls with NumLock off. With NumLock on, Up/Down hold advance/reverse and Left/Right hold relative turns. Turn input now accumulates angular change at 90 degrees/second in slow mode and 225 degrees/second in fast mode, then quantizes to the active 8- or 16-direction pose; this replaces the former immediate sector snap and arbitrary eight-tick repeat delay. Losing window focus releases held movement. Shift/Caps Lock select walk versus run, with the result inverted when a weapon is active to match DOS. This is the verified cardinal movement mapping; full DOS controller parity is not established.
- Core movement loads shape 1 stand, walk, reverse, unarmed-run, combat-stand, and armed-run clips from `ANIM.DAT`, advances direction-specific frame metadata, and applies the signed 9-bit stride multiplied by two through the native direction projection table, the clip rotation flag, signed Z displacement, 12-bit shape-frame ID, and horizontal-flip bit. The local retail walk/run headers are `[17, 5, 2, 0]` and `[12, 5, 2, 0]`; these are static-data findings, not runtime observations. The host honors two-step starts, the looping frame path, and frame-repeat delays.
- Live Ghidra evidence: `1130:12d6` (`Controller_PickNextAnimByKeyevent`) uses current facing for NumLock-on advance/reverse; relative left/right turns select stand animation `0` when unarmed and combat stand `4` when armed. The follow-up direction step is two slots for the 8-direction stand clip and one slot for the 16-direction combat stand clip. An active weapon selects run animation `0x30` instead of unarmed run `3`; `Controller_UpdateAvatarAngle` at `1130:10cf` confirms the weapon-out combat-stance turn path. The host implements these modes and exposes weapon-drawn state through `AvatarInputQueue.EnqueueWeaponDrawn`; inventory and weapon-ready actions do not yet drive that state. `1150:016f` (`AnimPrimitive_CheckToStartNewAnimation`) starts animation processes, and `1150:1906` (`AnimPrimitiveProcess_Run`) advances metadata and displacement.
- The animation caller sends grounded frames through `AreaSearch_SweepShapeBetweenPointsWithStepUp` at `10e0:162f` with flags `0x11`; airborne frames call `AreaSearch_SweepTestPt` at `10e0:0b39` directly with flags `4`. The grounded wrapper first tries the requested sweep, then on failure tests vertical clearance and the raised destination at +8, followed by +9. The host models that retry as separate vertical and horizontal TYPEFLAG-bound sweeps, and keeps the direct-only path for airborne frames. For a rejected grounded solid sweep, it retains the last legal position and enters a blocked state. SDL key-repeat events can retry a held direction, while other repeated key-downs do not advance the movement animation. `AnimPrimitiveProcess_Run` at `1150:1906` applies frame flip metadata to persistent `FLG_Flipped` status before collision, but the `gotBlocked` jump bypasses `Item_SetFrame`; the host now preserves that status update without advancing the blocked sprite frame. The native candidate-area scan, point-sweep details, AreaSearch flags, and collision notifications/hurl response remain unimplemented.
- Live Ghidra evidence: `1130:12d6` (`Controller_PickNextAnimByKeyevent`) uses current facing for NumLock-on advance/reverse; relative left/right turns select stand animation `0` when unarmed and combat stand `4` when armed. The follow-up direction step is two slots for the 8-direction stand clip and one slot for the 16-direction combat stand clip. Its `iswalk` selection defaults to walk without a weapon and run with one; Shift reverses that choice. An active weapon selects run animation `0x30` instead of unarmed run `3`; `Controller_UpdateAvatarAngle` at `1130:10cf` confirms the weapon-out combat-stance turn path. The host stores weapons as five avatar-owned entities in `AvatarWeaponLoadout`, tracks an active slot from 1 through 5, skips empty slots when cycling, and now carries explicit small/large weapon metadata for ready, combat-stand, and run animation selection. Weapon-size metadata remains caller-supplied until pickup/item metadata is implemented. `1150:016f` (`AnimPrimitive_CheckToStartNewAnimation`) starts or transitions animation processes, and `1150:1906` (`AnimPrimitiveProcess_Run`) advances metadata and displacement.
- Movement stance/action extension: `Controller_UpdateAvatarAngle` (`1130:10cf`) selects combat stand `4` or kneel-small-weapon `0x2e` from combat stance and kneeling state without an active-weapon lookup in that pose-selection path. The host now models held aim independently of weapon ownership, kneel start/stop/idle (`0x28`/`0x29`/`0x2e`), slides (`0x1c`/`0x1d`), standing/crouched combat rolls (`0x3d`/`0x3e`, `0x17`/`0x18`), quick jump (`0x3a`), reverse step (`2`), and weapon advance (`0x24`). SDL action bindings use physical keypad scancodes: KP5 crouches; Ctrl+KP8 jumps or stands up, Ctrl+KP4/KP6 roll, and Ctrl+KP2 crouches; Alt+KP8 advances with a weapon, Alt+KP4/KP6 slide, and Alt+KP2 reverses; KP Divide advances with a weapon without Alt/Ctrl. Ctrl diagonal rolls use KP7/KP9/KP1/KP3 with Num Lock off; Alt keypad directions select facing-relative slides with Num Lock on. Right mouse supplies held aim, which the host now disengages when translational movement starts; this is separate from the persistent Space weapon-ready state. Target/crosshair parity remains open. The verified keypad subset does not cover full DOS controller behavior, weapon pickup/drop, firing, small/large weapon-specific poses, or per-weapon graphics. Synthetic tests cover aim without a weapon, aim release and movement cancellation, crouch transitions, both combat-roll variants, action frames/displacement, and the other mapped movement clips.
- DOS Space-ready transition: `Controller_HandleKeyEvent` (`1130:2211`) passes key events through `Controller_PickNextAnimByKeyevent`, then checks `NPC_IsLastAnimNotWalkStandStow` (`10e8:1f4d`). On a Space key-down from `Walk`, `Stand`, `QuickJump`, or either unready-weapon animation, it requests `Anim_ReadyWeapon_SmallWpn` (`7`) through `NPC_DoAnim` (`10e8:0252`). `Anim_GetModifiedAnimForWeapon` (`1128:2105`) remaps that request to `Anim_ReadyWeapon_LargeWpn` (`0x0c`) when the active weapon is large. The retail shape-1 ready clips are 11 frames/8 directions (`7`) and 15 frames/8 directions (`0x0c`); `AnimPrimitive_CheckToStartNewAnimation` transitions the completed ready clip to combat stand `4`, which is remapped to large combat stand `0x25` for a large weapon. `NPC_DoAnim`'s ready cases set the ready flag; the ready state persists after Space is released. A later Space key-down in a non-neutral pose enters `Crusader_TryToFireWeapon`; the key-up path releases firing state. The host maps Space key-down to a persistent ready action, plays the size-specific ready clip, then settles into the matching combat stand. Right mouse aim remains separate, and the subsequent firing/release mechanics are still unimplemented.
- `Game_CycleActiveAvatarWeaponForward` (`13e8:0c72`) cycles the active slot through inventory offsets 1-5, skipping empty entries, then refreshes weapon/ammo notifications and changes combat/kneeling poses only when applicable. `NPC_GetActiveWeaponOffset` (`10e8:331f`) returns the slot and `NPC_GetActiveWeaponItem` (`10e8:33b0`) resolves its item. `Controller_UpdateAvatarAngle` (`1130:10cf`) derives the 16-way facing from the aim direction and selects combat stand `4` or kneeling small-weapon pose `0x2e`; `Target_UpdateSmallCrosshairs` (`1130:0708`) places the native small reticle. Right mouse and the pointer continue to update aim through the fixed-map viewport and draw a host reticle. Eight axis/diagonal tests cover native-facing quantization; manual SDL aim interaction has not been checked. Native `WpnCache_Init` (`1158:03ff`) loads `STATIC/WPNOVLAY.DAT` and caches weapon overlays by animation; overlay rendering remains deferred.
- The animation caller sends grounded frames through `AreaSearch_SweepShapeBetweenPointsWithStepUp` at `10e0:162f` with flags `0x11`; airborne frames call `AreaSearch_SweepTestPt` at `10e0:0b39` directly with flags `4`. The grounded wrapper first tries the requested sweep, then on failure tests vertical clearance and the raised destination at +8, followed by +9. The host models that retry as separate vertical and horizontal TYPEFLAG-bound sweeps, and keeps the direct-only path for airborne frames. A retail-backed isolated-obstacle regression uses map 1 records 6538 (`0x0019`), 6703 (`0x01ca`), and 6635 (`0x0550`) with the actual `TYPEFLAG.DAT` and shape-1 `ANIM.DAT` data: `0x0019` blocks at the contact plane, while the table and chest records cross only after the avatar steps from Z=16 to Z=24. This matches the native +8 probe and does not reproduce tunneling for these instances; the low-object traversal is native step-up behavior. For a rejected grounded solid sweep, the host retains the last legal position and enters a blocked state. SDL key-repeat events can retry a held direction, while other repeated key-downs do not advance the movement animation. `AnimPrimitiveProcess_Run` at `1150:1906` applies frame flip metadata to persistent `FLG_Flipped` status before collision, but the `gotBlocked` jump bypasses `Item_SetFrame`; the host now preserves that status update without advancing the blocked sprite frame. Additional live AreaSearch evidence: `AreaSearch_SweepTestPt` (`10e0:0b39`) derives the mover's X/Y/Z extents from packed shape data, swaps horizontal extents when flipped, checks map-fast-area corners at both endpoints, and initializes an item iterator over swept bounds expanded by `0x100`. `AreaSearch_TestCandidateSweepCollision` (`10e0:032e`) derives each candidate's shape extents, applies vertical and solid/damage filters, and computes contact offsets against candidate box faces. `AreaSearch_RecordSweepContact` (`10e0:0228`) stores contacts and conditionally updates `firstcollision` and blocked state. This is more specific than the host TYPEFLAG AABB sweep, but the AreaSearch field/flag meanings, exact collision-notification policy, and hurl response remain unresolved; full native collision parity is not established.
- `AreaSearch_CollideMove` (`10e0:123a`) commits the resolved `srch->pt` with `Item_Move`. For `firstcollision`, it queues paired `0x20b`/`0x20c` hit and got-hit processes with computed impact strength, except matching quantity/reagent shapes may take the stacking path; eligible additional contact-list entries receive paired notifications with zero strength. The temporary process list is then run and destroyed. Exact contact eligibility and downstream hurl response remain open.
- Validation after the collision/input corrections: `dotnet build .\CrusaderRebuild.slnx --configuration Debug` succeeded, and all 133 core tests passed with the installed No Remorse data selected through `CRUSADER_REMORSE_DATA_ROOT`, including the retail-backed named-geometry step-up regression. Interactive SDL gameplay has not yet been rechecked.
- `AreaSearch_SweepTestPt` (`10e0:0b39`) marks an endpoint invalid when signed X/Y or Z exceeds the supported range, clamps `srch->pt`, and returns failure even if the broadphase scan completes. For an in-range endpoint, a recorded solid contact can still return success with `srch->pt` clipped to the contact; `AnimPrimitiveProcess_Run` then commits that point through `AreaSearch_CollideMove`. The C# movement path now rejects clamped out-of-range endpoints but commits valid clipped contacts and their frame metadata. Synthetic regressions cover both paths; exact native candidate/contact policy remains unresolved.
- Map-loaded entity snapshots now derive horizontal flip from FIXED.DAT status bit `0x20`, matching the flag already consumed by the renderer.
- The SDL scene sends all spawned or source-pose-changed world entities to a persistent map-render session. The session caches static indexed pixels and prepared shape frames, indexes static nodes in 128-pixel spatial cells, and recomposes only merged old/new sprite bounds intersecting the current viewport. Camera shifts refresh only visible dynamic sprites; deferred offscreen bounds are skipped until visible. The App reuses one streaming SDL texture and converts/uploads only returned patches. The live map's static-item crop recenters around the avatar before its `0x1000` world-coordinate radius is exhausted, then rebuilds the scene and texture so records outside the startup crop enter view; this is rolling map rendering, not a verified native tile-streaming implementation. The live avatar is not drawn as a topmost overlay. Snap camera follow is the default; `--smooth-camera` enables host-side exponential follow and edge clamping. Large position jumps and Z changes snap the camera so the modeled startup teleports do not leave interpolation trails.
- The top-left HUD displays FPS. Frame pacing targets 60 FPS and waits only for the remaining frame budget instead of adding a fixed 16 ms sleep after rendering; sustained runtime performance remains unmeasured. Press `H` to toggle the temporary hack mover; while active, `HACK MODE (H)` appears at the top of the screen and a left click inside the map teleports the avatar to that projected world position at its current Z. This is a rebuild debugging control, not a port of the original mover. Follow zoom is limited to 0.5x-1x, using the original 640x480 screen as the native-scale reference. The map fills the available host area without side bars; wider aspect ratios show additional horizontal world. At 0.5x, the visible source dimensions are approximately doubled. The fixed-map diagnostic remains fit-to-window.
- Renderer comparison with the earlier C++ implementation found two omission cases: fresh-start rendering inherited the diagnostic default that filters roof-flagged shapes, and C# allowed invisible map records to act as occluders although C++ excludes them. Gameplay now includes roofs, and invisible records no longer cull overlapping sprites. The separate map diagnostic retains its roof toggle/default.
- Synthetic tests cover absolute controls, tank advance/reverse, unarmed 8-way and armed 16-way turns, armed run-clip selection, held/released input, walk/run selection, stand transitions, animation displacement and cadence, shape-frame/flip metadata, imported FIXED.DAT flip status, flip-state update before blocked frame rejection, focus-loss release, facing, rollback and held-input retry on map and spawned solid collisions, grounded low-solid step-up, spawn-overlap exit, renderer patch parity, sprite removal, moving bounds, zoom/camera behavior, and projection. Opt-in retail tests cover the roof-flagged shape `0x003c`, the avatar in the shared sort pass, start-scene crop, and the full route followed by movement of the same avatar ID.
- `dotnet build CrusaderRebuild.slnx` passed. With `CRUSADER_REMORSE_DATA_ROOT` set to the configured No Remorse install, `dotnet test CrusaderRebuild.slnx` passed all 114 tests. An earlier SDL launch smoke test loaded retail resources, rendered a crop with 1,155 static scene items, and entered the event loop; it was stopped with Ctrl+C. The rolling map window has not yet had a manual boundary-crossing check because the existing debugger session was left undisturbed.
- M7 remains incomplete: inventory/weapon-ready transitions into the weapon-drawn movement state, other DOS keypad and modifier combinations, target/crosshair angle updates, exact AreaSearch candidate selection and point-sweep behavior, native collision response/hurl behavior, frame-skip handling, visual input verification, rolling-map boundary verification, measured continuous-motion performance, and parity with native occlusion. The current TYPEFLAG AABB sweep is not full collision parity. Runtime comparison is intentionally out of scope for this movement work. The 320x200 rectangle in `Camera_RedrawViewportAndGameplayOverlays` is a centered redraw region, not the full screen; `Init_Everything` initializes viewport bounds through 639x479. Do not claim native movement or scheduler parity.
- Synthetic tests cover absolute controls, tank advance/reverse, unarmed 8-way and armed 16-way turns, armed run-clip selection, held/released input, walk/run selection, stand transitions, animation displacement and cadence, shape-frame/flip metadata, imported FIXED.DAT flip status, flip-state update before blocked frame rejection, focus-loss release, facing, valid solid-contact clipping with frame/flip commit and held-input retry, out-of-range endpoint rejection, grounded low-solid step-up, spawn-overlap exit, renderer patch parity, sprite removal, moving bounds, zoom/camera behavior, and projection. Opt-in retail tests cover the roof-flagged shape `0x003c`, the avatar in the shared sort pass, start-scene crop, and the full route followed by movement of the same avatar ID.
- A prior retail-enabled `dotnet test CrusaderRebuild.slnx` run passed all 117 tests with zero skips. After the movement extension, the solution build succeeded without warnings, the current default full suite passed 114 tests with 13 data-gated retail skips (`CRUSADER_REMORSE_DATA_ROOT` was unset), and the avatar-movement-focused filter passed all 24 tests. Synthetic coverage includes boundary rejection, valid solid-contact clipping, and non-solid-mover pass-through. An earlier SDL launch smoke test loaded retail resources, rendered a crop with 1,155 static scene items, and entered the event loop; it was stopped with Ctrl+C. The rolling map window has not yet had a manual boundary-crossing check because the existing debugger session was left undisturbed.
- M7 remains incomplete: weapon pickup/drop, correct initial loadout population, firing, small/large-specific pose metadata, per-weapon `WPNOVLAY.DAT` graphics, other DOS keypad and modifier combinations, native reticle/target-acquisition parity, exact AreaSearch candidate selection and point-sweep behavior, native collision response/hurl behavior, frame-skip handling, manual visual input verification, rolling-map boundary verification, measured continuous-motion performance, and parity with native occlusion. The current TYPEFLAG AABB sweep is not full collision parity. Runtime comparison is intentionally out of scope for this movement work. The 320x200 rectangle in `Camera_RedrawViewportAndGameplayOverlays` is a centered redraw region, not the full screen; `Init_Everything` initializes viewport bounds through 639x479. Do not claim native movement or scheduler parity.
- Validation after the ready/aim slice: the focused 8-case aim-facing test passed; `dotnet build CrusaderRebuild.slnx` succeeded; retail-enabled `dotnet test CrusaderRebuild.slnx` passed all 141 tests with zero failures. Manual SDL aim interaction remains unverified.
- Keyboard weapon-input correction: Space key-down from a neutral animation starts the native ready/draw animation; the resulting weapon-ready state persists after key-up. A later Space press enters native firing, which remains unimplemented. Keypad `*` cycles weapons, and right mouse aim remains independent from weapon readiness.
- DOS turn/aim correction: `Controller_UpdateAvatarAngle` (`1130:10cf`) applies 2 degrees per slow-turn keyboard cycle and 5 degrees per fast-turn cycle when `BYTE_1478_6046` is zero; the DOS keyboard daemon runs at 45 cycles/second, yielding 90/225 degrees per second. The native updater can use a separate accelerated global rate, which is not yet modeled. The host integrates the standard rates at its 60 Hz fixed step and quantizes to the current pose's direction count. Aim clears on translational input and remains off while translation is held; the separate weapon-ready flag is unchanged. Focused turn/aim tests passed 7/7. The full Debug solution build succeeded, and the complete suite passed 147/147 with zero skips. Manual SDL verification remains open.
- Ghidra follow-up verification: `AreaSearch_SweepShapeBetweenPointsWithStepUp` (`10e0:162f`) retries grounded horizontal movement at exactly `start Z + 8`, then exactly `start Z + 9`; it does not derive the step amount from an obstacle's TYPEFLAG footpad. Its raised probes run only when the endpoint Z matches the start Z and the packed destination flags include `0x10`. `AnimPrimitiveProcess_Run` (`1150:212c`) supplies grounded flags `0x11`; its airborne branch supplies `0x04` and does not use the step-up retry. The retail single-obstacle test now covers map records 6674/6677 (`0x003c`), 6701 (`0x00aa`), and 6702 (`0x0586`) as ground-level blocks, and confirms records 6703 (`0x01ca`) and 6635 (`0x0550`) cross at exactly +8. These instance-specific results match the native probes; broader collision parity remains open.
## Implementation Rules