Add comprehensive tests for collision detection, entity dispatch, file system, isometric controls, map rendering, and sorting
- Implemented collision tests to verify overlap and movement logic for collision bodies. - Enhanced entity dispatch entry tests to cover initialization, group ID management, and process handling. - Expanded file system tests to include crash diagnostics and ensure proper game data root detection. - Created isometric controls tests to validate movement requests and screen projection calculations. - Added map renderer tests to check fixed map loading and rendering functionality. - Introduced map sorter tests to confirm correct rendering order for various items.
This commit is contained in:
parent
8907604b84
commit
202679f857
27 changed files with 3530 additions and 81 deletions
|
|
@ -4,7 +4,17 @@
|
|||
|
||||
This note records the current effort to turn the live Ghidra analysis and the exported C decompilation of `CRUSADER.EXE` into a source tree that can be recompiled and eventually run on Windows, including modern Windows.
|
||||
|
||||
The short version: the project now has enough decompiled coverage to start a real rebuild lane, but the exported files are still evidence, not directly compilable game source. The safest path is to keep the export as an input corpus and move cleaned, subsystem-sized slices into a separate host rebuild tree with explicit ABI and platform boundaries.
|
||||
The deliverable is a functioning modern Windows game compiled from cleaned, traceable decompiled `CRUSADER.EXE` game code. Replace DOS/Phar Lap and hardware services at their call boundaries; retain and repair the original control flow, data structures, scheduler, rendering, input semantics, and gameplay logic wherever recoverable. This is a source port, not a clean-room engine reconstruction. Modding is a later goal, not an initial acceptance criterion.
|
||||
|
||||
The exported files are evidence, not directly compilable game source. Keep them unchanged and move verified, subsystem-sized function bodies into the rebuild tree, recording each original address and any corrections to decompiler artifacts. Do not substitute a newly designed gameplay implementation for an unported function and call that function complete.
|
||||
|
||||
## Recompilation Gate
|
||||
|
||||
- Every claimed port identifies its original NE address, exported function, unresolved decompiler ambiguities, and host-only substitutions. Distinguish direct translations, behaviorally verified ports, and temporary stand-ins.
|
||||
- Compile recovered game functions into `remorse_core`; call them from the runtime path that needs them, not only from isolated tests. Tests should compare state transitions, side effects, and error paths with binary/decompiler evidence where possible.
|
||||
- Keep DOS file, memory, timing, input, video, and audio replacements behind explicit platform boundaries. Resource parsers and the current preview/window remain useful diagnostics, but are not substitutes for porting the original game loop and its callees.
|
||||
- At each milestone, count original functions translated and exercised in the Windows build, platform calls replaced, and parity checks passed. A rendered scene or a controllable stand-in actor alone does not pass a game-code milestone.
|
||||
- Do not claim whole-game recompilation until startup, game ticks, interactions, mission flow, save/load, and presentation are driven by ported game code and playable on modern Windows using the original data.
|
||||
|
||||
## Current Inputs
|
||||
|
||||
|
|
@ -35,22 +45,27 @@ Current scaffold files:
|
|||
- `rebuild/remorse/include/remorse/palette.h`: first game-data parser for 256-color RGB palette files.
|
||||
- `rebuild/remorse/include/remorse/runtime.h`: minimal runtime/export-manifest surface.
|
||||
- `rebuild/remorse/include/remorse/shape_archive.h`: typed `SHAPES.FLX` shape-frame parser and row-RLE decoder.
|
||||
- `rebuild/remorse/include/remorse/animation_archive.h`: bounds-checked raw `ANIM.DAT` lookup, direction/frame metadata, sprite-frame and flip extraction, and authored movement-step decoding.
|
||||
- `rebuild/remorse/include/remorse/collision.h`: TYPEFLAG-sized collision volumes, swept movement query, and fixed-map/GLOB solid-volume extraction.
|
||||
- `rebuild/remorse/include/remorse/type_flags.h`: typed `TYPEFLAG.DAT` shape-family and flag decoder.
|
||||
- `rebuild/remorse/src/combat_tactics.cpp`: parses tactic names, four block offsets, and bytecode payloads from `COMBAT.DAT` entries.
|
||||
- `rebuild/remorse/src/entity_dispatch_entry.cpp`: minimal host-side `EntityDispatchEntry` behavior stubs for compile-time shape and early probing.
|
||||
- `rebuild/remorse/src/collision.cpp`: builds conservative solid volumes from fixed-map records and expanded glob children, then sweeps the player footpad against them.
|
||||
- `rebuild/remorse/src/entity_dispatch_entry.cpp`: partial source translation of process lifecycle, the `11d0:0255` scan, `Process_Sleep`/`Unlink`, the 0x42-byte Stand constructor fields, `StandProcess::Run` (`1100:0359`), and a kernel-owned SystemTimer constructor/counter (`11c0:0000/00f8`). The harness executes the NPC decision tree through host services and delivers timer events explicitly; real NPC data, timer interrupts/rescheduling, keyboard lane, and complete game tick remain unported.
|
||||
- `rebuild/remorse/src/file_system.cpp`: repository/retail data-root discovery using modern `std::filesystem`.
|
||||
- `rebuild/remorse/src/flex_archive.cpp`: loader for count-at-`0x54`, table-at-`0x80` FLEX archives.
|
||||
- `rebuild/remorse/src/fixed_map.cpp`: loader for `FIXED.DAT` map tables and scaled fixed-map item coordinates.
|
||||
- `rebuild/remorse/src/glob_archive.cpp`: parser for glob object entry lists inside `GLOB.FLX`.
|
||||
- `rebuild/remorse/src/map_preview_main.cpp`: command-line preview executable for writing a viewable BMP image.
|
||||
- `rebuild/remorse/src/windowed_game_main.cpp`: native Windows game shell, with async retail map/player/collision loading, shape-1 stand/walk/run sprites, metadata-driven 8-way movement, a following camera, and a position HUD.
|
||||
- `rebuild/remorse/src/map_renderer.cpp`: combines fixed maps, glob expansion, typeflags, shape frames, and palette data into a painted preview image.
|
||||
- `rebuild/remorse/src/palette.cpp`: `GAMEPAL.PAL`-style 768-byte palette parser.
|
||||
- `rebuild/remorse/src/runtime.cpp`: loads a summary from the Ghidra export manifest.
|
||||
- `rebuild/remorse/src/shape_archive.cpp`: ports the documented Crusader frame-table and row-RLE decode rules.
|
||||
- `rebuild/remorse/src/animation_archive.cpp`: parses shape-indexed animation tables and direction-major frame metadata from raw `ANIM.DAT`.
|
||||
- `rebuild/remorse/src/type_flags.cpp`: ports the verified 9-byte Crusader typeflag decode from the map-rendering tool.
|
||||
- `rebuild/remorse/src/main.cpp`: starts the host harness and prints the export status.
|
||||
- `rebuild/remorse/tests/combat_tactics_tests.cpp`: checks `COMBAT.DAT` parses to 14 tactics and entry 0 is `Dumb`.
|
||||
- `rebuild/remorse/tests/entity_dispatch_entry_tests.cpp`: first host-side check for the confirmed `EntityDispatchEntry` offsets.
|
||||
- `rebuild/remorse/tests/entity_dispatch_entry_tests.cpp`: checks entry offsets, group counters, ID assignment, 30-slot growth, lifecycle, scheduler gates/spawn/cleanup, sleep writes, strict wake deadline, the owned Stand layout, NPC-gated `Run` branches, and timer-counter carry.
|
||||
- `rebuild/remorse/tests/file_system_tests.cpp`: first host-side check that the current repository root can be recognized as a game-data root.
|
||||
- `rebuild/remorse/tests/flex_archive_tests.cpp`: checks `STATIC/COMBAT.DAT` as a small FLEX archive with 14 populated records.
|
||||
- `rebuild/remorse/tests/fixed_map_tests.cpp`: checks `STATIC/FIXED.DAT` map count and map 0 item-record loading.
|
||||
|
|
@ -58,10 +73,12 @@ Current scaffold files:
|
|||
- `rebuild/remorse/tests/map_renderer_tests.cpp`: checks map 1 can produce a non-empty preview image.
|
||||
- `rebuild/remorse/tests/palette_tests.cpp`: checks that `STATIC/GAMEPAL.PAL` parses into 256 colors.
|
||||
- `rebuild/remorse/tests/shape_archive_tests.cpp`: checks `STATIC/SHAPES.FLX` can decode at least one visible frame.
|
||||
- `rebuild/remorse/tests/animation_archive_tests.cpp`: checks ANIM.DAT parsing, signed displacement and direction rotation, sprite-frame/flip decoding, and retail shape-1 stand/walk/run references.
|
||||
- `rebuild/remorse/tests/collision_tests.cpp`: checks TYPEFLAG extents, swept obstruction, vertical clearance, flipped footprints, and fixed-map/GLOB placement extraction.
|
||||
- `rebuild/remorse/tests/type_flags_tests.cpp`: checks `STATIC/TYPEFLAG.DAT` parses 2,048 shape records and includes glob-family records.
|
||||
- `rebuild/remorse/tools/import_export_slice.py`: stages one exported function folder into `rebuild/remorse/imported/` for manual cleanup review.
|
||||
|
||||
This is not the game yet. It is the first buildable shell that future cleaned subsystems can link into without mutating the raw Ghidra export.
|
||||
This is not the game yet. It is a buildable diagnostic host with a source-backed itemless process lifecycle, partial scheduler scan, owned Stand process layout, and recovered Stand `Run`/NPC decision and timer-counter branches. It does not have the original NPC service data, timer interrupt registration, or game loop.
|
||||
|
||||
## Why The Export Does Not Compile Yet
|
||||
|
||||
|
|
@ -87,7 +104,7 @@ It must preserve segmented pointers, far-call provenance, original-style packing
|
|||
|
||||
### Track B: Windows Source Port
|
||||
|
||||
This track uses the recovered source, object layouts, and resource formats to build a behaviorally equivalent Windows program.
|
||||
This track compiles corrected decompiled game source, retaining original behavior and object layouts while replacing only the OS/hardware-facing calls needed to run it on Windows.
|
||||
|
||||
It can replace DOS extender, VGA, sound, input, timing, file, and memory services with host implementations, but it should initially preserve exact-width data layouts and far-pointer provenance so behavior can be compared back to the original.
|
||||
|
||||
|
|
@ -95,18 +112,18 @@ For the stated goal of running on modern Windows, Track B is the practical prima
|
|||
|
||||
## Conversion Strategy
|
||||
|
||||
1. Keep `exports/src_remorse/` as generated evidence.
|
||||
2. Move one subsystem at a time into `rebuild/remorse/` as cleaned C++.
|
||||
1. Keep `exports/src_remorse/` as generated evidence; keep a function-address ledger of what was translated, what is still a stand-in, and which callers actually execute the translation.
|
||||
2. Move one original call chain at a time into `rebuild/remorse/` as minimally corrected C/C++ with a documented address mapping and tests for the observed side effects.
|
||||
3. Compile every moved slice immediately, even before it is runnable game logic.
|
||||
4. Replace Ghidra pseudo-types with `remorse::u8`, `remorse::u16`, `remorse::u32`, `remorse::FarPtr16`, and explicit packed structs.
|
||||
5. Convert Ghidra calling-convention tokens into marker macros from `compat.h` until the final host calling surface is chosen.
|
||||
6. Keep raw address provenance in comments or mapping tables for every imported function.
|
||||
7. Build host runtime shims for platform services before trying to run gameplay.
|
||||
8. Validate behavior with extracted resources and deterministic smoke tests.
|
||||
7. Implement host runtime shims at the DOS/hardware call boundaries encountered by the ported chain; avoid duplicating game logic in the shim.
|
||||
8. Validate recovered behavior with binary evidence, retail resources, and deterministic trace/state comparisons; connect each port to its caller in the Windows runtime.
|
||||
|
||||
## Full Rebuild Plan
|
||||
|
||||
The practical target is Track B first: a modern Windows source port that loads original data and reproduces gameplay behavior. Track A remains an evidence constraint for layout, calling convention, far-pointer provenance, and validation.
|
||||
The practical target is Track B: recompile recovered game logic for Windows and replace the DOS platform boundary. Track A remains an evidence constraint for layout, calling convention, far-pointer provenance, and validation. The phases below describe supporting capabilities, not permission to implement an independent game first: prioritize ported startup -> tick -> player/item process -> renderer/interaction call chains over further standalone host features.
|
||||
|
||||
### Phase 0: Build And Evidence Discipline
|
||||
|
||||
|
|
@ -117,6 +134,7 @@ Exit criteria:
|
|||
- `rebuild\remorse\build_msvc.cmd Debug` passes from the repository root
|
||||
- every imported subsystem has address/source provenance in code or docs
|
||||
- generated Ghidra exports remain input evidence, not hand-edited source
|
||||
- at least one corrected exported function is compiled, tested against its documented side effects, and invoked by a host caller; list remaining placeholder behavior explicitly
|
||||
|
||||
### Phase 1: Host Runtime Foundation
|
||||
|
||||
|
|
@ -262,7 +280,52 @@ Exit criteria: a clean checkout/build can run against a retail data directory wi
|
|||
|
||||
## Current Execution Focus
|
||||
|
||||
The current active phase is Phase 2, core resource loaders. The immediate path is `FIXED.DAT` map table and item-record loading, then glob expansion, then shape-frame decoding, then a minimal map scene smoke test.
|
||||
The current active work must shift from Phase 3 host presentation to decompiled source conversion and call-chain integration (Phases 0 and 4). Core Phase 2 loaders, the footpad-aware overlap sorter, and the Windows map window are diagnostic infrastructure. The actor uses retail stand/walk/run metadata, authored XYZ displacements, and the original 16-way direction table, but its 20 Hz host tick, conservative TYPEFLAG collision, and fixed-map boundary are not the recovered player process or original AreaSearch. Floor support, step-up/ledge handling, moving items, interactions, and USECODE remain unported. Keep the window as a test host, not as the implementation template for game logic.
|
||||
|
||||
First narrow conversion: `Remorse::EntityDispatchEntry::SetGroupId` at `11e0:02a8` (older `0008:bca8`) validates 1..31, updates the group byte at `+0x08`, and adjusts 16-bit counters through the far table pointer at `DS:39c5`. Live disassembly confirms the entry far pointer at `[BP+6]`, group byte at `[BP+0xa]`, and word-sized counter operations; the decompiler's `_group_id` alias is not a real implicit argument. The host receives the entry and table explicitly. `InitBase` at `11e0:0000` stamps the function-table words `0x3b06` (`+0x00`), `0x2d10` (`+0x1e`), `0x3afe` (`+0x28`), initializes the observed scalars, and seeds the group through `SetGroupId`. The seed comes from `DS:39c9` (written by `Kernel_11d0_19b5`); the host receives it as explicit runtime state. The unknown `+0x09` is not deliberately written. The host-owned path performs allocate -> initialize -> register, records default name/new-process metadata, executes the conditional current-process extflag branch, and applies the post-registration sync predicate. Itemless termination and slot reclamation are present. The scheduler scan applies normal-process group/flag gates and timer wake logic at `11d0:0255`, and its callback invokes the compiled `StandProcess::Run` branch for the 0x42-byte host-owned Stand entry. The `1100:026e` NPC decision gates are compiled, with their item/visibility/activity operations passed through host services. Owned Stand entries now maintain the per-item presence bit; the kernel-owned timer and keyboard constructors register their diagnostic processes. This is **not** a complete constructor or process system: stack-segment assertion, nonempty item child teardown, NPC service implementations, DOS timer/keyboard event delivery, end-of-pass work, other process `Run` functions, and far-memory behavior remain absent. `IncrementGroupId`, `SetSourceType`, and `SetEventTypeChecked` remain stand-ins; runtime binary parity is not established.
|
||||
|
||||
### Process Source-Port Ledger
|
||||
|
||||
| Exported function | Compiled status | Evidence and remaining boundary |
|
||||
|---|---|---|
|
||||
| `SetGroupId@11e0_02a8.c` (`0008:bca8`) | Partial translation; invoked from host `InitBase`, CTest transitions and invalid IDs | Live `11e0:02ae-031b`: group byte parameter at `[BP+0xa]`, far entry pointer at `[BP+6]`, 2-byte counter stride via `DS:39c5`, overwrite entire `+0x08` byte when changing group. Host exception replaces `AssertError`; counter-table ownership and runtime trace still need verification. |
|
||||
| `InitBase@11e0_0000.c` (`0008:ba00`) | Function-table/scalar/group-seed subset plus host-owned allocate/register path; harness-invoked, CTest offsets, counters, IDs | Live `11e0:0006-014e`: optional alloc `11e0:014f`, table words `0x3b06/0x2d10/0x3afe`, group from `DS:39c9`, then `SetGroupId`, `Kernel_AddProcess` (`11d0:0aff`), conditional `Kernel_GetSomeProcId_11d0_177c` branch, `Process_11d0_19cd`. Host updates extflags `+0x18 |= 4` on an addressable, unterminated current process with bit `2` set; it still omits stack-segment assertion and segmented-pointer relocation. |
|
||||
| `Kernel_GetNextFreeProcId` (`11d0:0a97`), `Kernel_11d0_0716` | First-free slot and 30-slot growth translated; registered in host harness and CTest | Live decompile scans far process-pointer slots, grows parallel pointer/size/name arrays by 30 up to 1020 entries. Host stores native pointers, sizes, and default names; the original far-address mapping is not implemented. `Process_GetProcById` (`11d0:0bf3`) treats ID 0 as null even though the raw slot allocator may choose it. |
|
||||
| `Kernel_AddProcess` (`11d0:0aff`) | Process pointer, ID, allocation-size, count, optional new-process flag/counter, default-name subset translated | Live disassembly stamps `procid` at `+0x02`, consumes `g_kernelLastProcessAllocSize`, increments count, optionally sets `ExtProc_NewlyCreated` (`0x200`), and names the slot `Default`. Host omits initialized-state assertion, far-pointer representation, and runtime parity. |
|
||||
| `Process_11d0_19cd` / `Process_11d0_19ec` | Sync-flag predicate translated on the host creation path | Live `11d0:19ef-1a07` tests kernel flag and `procid > current ID`; `11d0:19e2-19e5` ORs `0x40` into process flags at `+0x16`. The conditional `InitBase` current-process extflag branch is also translated, without runtime parity. |
|
||||
| `Kernel_TerminteProcessByPid` (`11d0:18a3`), `Process_SetTerminatedState` | Immediate and deferred termination translated for host-owned base and zero-child-state Stand entries | Live `11d0:18e5-1939`: decrement group count; if extflags `+0x18 & 4`, clear slot and free immediately; otherwise set flags `+0x16 & 8`, increment terminated count; decrement live process count in either case. Host refreshes the per-item bit after termination; child lists, special event callbacks, and teardown for non-owned entries remain unported. |
|
||||
| `Kernel_ClearProcessSomethingAndName` (`11d0:1972`), `Kernel_11d0_1dcc` | Slot pointer/size/name clear and deferred cleanup for IDs >= 3 translated; ID reuse exercised | Live cleanup scans from ID 3, requires `+0x1a == 0`, clears the slot, frees the entry, and decrements terminated count. The clear helper itself does not decrement live process count. Other scheduler cleanup paths and process destructor dispatch remain unported. |
|
||||
| `FUN_11d0_0255` (`11d0:0255`) | Normal-process scan and timer wake translated; harness callback invokes compiled Stand `Run`, tests cover sleep/wake and scheduler gates | Live `11d0:02b4-03ac`: skip terminated, process sleep via `11e0:0379`, clear `Proc_Syncing` for one pass, skip nonzero `+0x24/+0x26`, `Proc_Waiting`, and off-group entries unless daemon or group 30/31; set current ID around vtable run call. Host receives an explicit timer tick, uses the original strict `start+duration < tick` wake comparison, and recognizes Stand's verified no-op completion slot (`1100:0fe3`); other completion targets remain unsupported. Immediate timer/keyboard interrupts, early-stop/group advance/table-maintenance tails, and general vtable dispatch remain unported. |
|
||||
| `Process_Sleep` (`11e0:0320`), `EntityDispatchEntry::Unlink` (`11e0:0353`) | Flag and 32-bit timer writes/clear translated; exact byte offsets and wake deadline tested | Live sleep ORs `0x1000` at `+0x18`, snapshots timer into `+0x0a/+0x0c`, writes duration to `+0x0e/+0x10`; unlink clears the flag and those four words. Host receives a tick instead of reading the original timer-process pointer. |
|
||||
| `NPCActionProcess::Create` (`1100:0000`), `StandProcess::CreateProcess` (`1100:02ed`) | Owned 0x42-byte Stand entry registered and run in harness; constructor fields, item number, and presence-bit transitions tested | Live chain stamps `+0x16 |= 0x300`, clears derived words `+0x32..0x3e`, stores NPC number at `+0x40`, ORs `0x101` at `+0x32`, sets Stand vtable `0x1f0f`, process name `Stand`, and event `0x258`. Host marks the item bit on registration and refreshes it after terminating a zero-child-state Stand, following `Item_MarkProcessPresent`/`Item_RefreshProcessPresenceFlag` (`11d0:3e0b/3e7f`). Item animation/cache reset, nonempty child-list destruction, and real NPC item ownership remain unported. |
|
||||
| `NPC_StartBehaviorInField0x8IfCanSeeControlledNPC` (`1100:026e`), `StandProcess::Run` (`1100:0359`) | Compiled NPC decision/Stand run branches; tests cover off-screen sleep, visible behavior start, already-current sleep, and strict wake | Live `1100:0274-02e9` reads NPC number from `+0x40`, tests entirely-on-screen, nonzero field-8 activity, not-current activity `0x71`, can-see-controlled-NPC, and starts the next behavior; `1100:035c-0382` sleeps 60 on false. `1478:1f0f` starts with far `Run` pointer `1100:0359`. Host services supply visibility/activity/item effects and timer tick; no real NPC item, general vtable resolver, or binary trace parity. |
|
||||
| `SystemTimerProcess_CreateProcess` (`11c0:0000`), `Process_RegisterForTimerEvents` (`11e0:19ba`), `Kernel_RegisterProcForTimerEvents` (`11d0:2dd8`), `SystemTimerProcess_Increment` (`11c0:00f8`) | Partial 0x4a-byte owned constructor and registered counter linked to harness and Windows diagnostic scheduler; zero initialization, 16-bit carry, uniqueness, process flags, registration gate, and strict Stand wake boundary tested | Exported `ConstructVtable3AD2/3AA6` (`11e0:14fb/1814`) sets interrupt/realtime flags and zeros the periodic tail; constructor stores period `0x3c` at `+0x36`, tail bit `2` at `+0x32`, and waiting/daemon/active-counter flags. Registration sets `Proc_GetTimerEvents` (`0x400`) and records the process ID; host delivery requires both. Increment carries from `+0x40` to `+0x42`. Original randomized reschedule, event type, active-counter globals, general timer list/dispatch, DOS interrupt source, and general timer teardown remain unported. |
|
||||
| `KeyboardProcess_CreateProcess` (`11b8:02e1`), `Process_RegisterForKeyboardEvents` (`11e0:172a`), `Kernel_RegisterForKeyboardEvents` (`11d0:3b74`), `Process_SetKeyboardInterruptFlag` (`11e0:17a4`), `KeyboardProcess_HandleKeyEvent` (`11b8:03ad`) | Partial owned 0x36-byte keyboard process registered by harness and diagnostic window; layout, flags, singleton, exhaustion, teardown refusal, and accepted/rejected callback copies tested | Inherits `ConstructVtable3AD2` (`11e0:14fb`) interrupt flag `0x100`, registers `ExtProc_KeyboardEvents` (`0x80`) once, sets `Proc_Waiting|Proc_Daemon` (`0x3`) and `ExtProc_KeyboardInterrupt` (`0x100`). Live disassembly at `11b8:03c5-0418` and bytes `11b8:041a-041f` confirm filter pair `0x10,0`; a nonzero character and field `+0x08` copy 12 bytes from `g_lastKeyEvent` to the supplied event and clear tail `+0x32 & ~0x10`. Window `WM_CHAR` supplies a host-synthesized event for the diagnostic count only; original callback registry, `KeyDaemon`, event queue, modifier state, and player-input routing remain unported. |
|
||||
| `KeyDaemon_CreateProcess` (`11b8:0000`) | Partial owned 0x40-byte constructor invoked after keyboard registration in harness and window; layout, singleton, and teardown refusal tested | Inherits `ConstructVtable3AD2/3AA6` (`11e0:14fb/1814`) interrupt/realtime flags `0x300`, sets `Proc_Daemon|Proc_Waiting` (`0x3`), `Proc_ImmediateTimer` (`0x2000`), timer-event bit `0x400`, derived tail `+0x32 |= 2`, and period `0x2d` at `+0x36`. The randomized schedule, timer list dispatch, held-key repeat callback, and DOS input state are not linked. |
|
||||
|
||||
Live Ghidra MCP decompilation and disassembly have resolved local stack ABI, scheduler gates, and call order, not runtime state parity. Do not promote the Stand harness trace to gameplay behavior until its host-supplied NPC services and remaining tick services can be checked against execution.
|
||||
|
||||
## First Interactive Windows Game Shell
|
||||
|
||||
`rebuild/remorse/out/build-nmake/remorse_game.exe` is the first windowed application target. It locates the game data root from its own executable path (or the current directory), defaults to map 1, and accepts an optional fixed-map index from 0 through 255.
|
||||
|
||||
From the repository root:
|
||||
|
||||
```powershell
|
||||
rebuild\remorse\build_msvc.cmd Debug
|
||||
.\rebuild\remorse\out\build-nmake\remorse_game.exe 1
|
||||
```
|
||||
|
||||
The application builds the selected retail map scene and player assets on a worker thread, then displays a resizable Win32 window with the game palette and dependency-sorted map art. Shape 1 uses `ANIM.DAT` actions 0 (stand), 1 (walk), and 3 (unarmed run); frame metadata selects the `SHAPES.FLX` pose, horizontal flip, and movement delta. The original keypad direction mapping is supported alongside WASD/arrows and diagonal combinations. Shift and Caps Lock select walk/run using the controller's same-state rule. A 40 Hz host simulation tick advances frame steps against fixed-map and expanded-glob solid volumes; it now catches up after long paints instead of discarding all elapsed time beyond 50 ms. The retail signed displacement decoder is unchanged. The prototype's forward-only host movement step skips the small backward stride on walk frames 4 and 12 of directions 6/7/10/11, which had made both actor and following camera reverse mid-stride. This comfort policy and host tick rate are not recovered controller behavior. The persistent GDI back buffer avoids painting each moving frame directly to the window. The HUD shows map, world position, facing, and locomotion state. Collision is an axis-aligned TYPEFLAG approximation; it does not reproduce original AreaSearch shape sweeps or step-up behavior, and the fixed-map record bounds remain the outer movement limit.
|
||||
|
||||
The second HUD row is an observable, separate process-runtime diagnostic: the host 40 Hz step delivers a registered SystemTimer event, advances the recovered scheduler scan, and runs an owned Stand entry through its verified off-screen sleep branch. Tick, remaining sleep ticks, and wake count update while the window is active. Three base entries reserve the low process IDs; the Stand entry and NPC number are diagnostic fixtures, not map NPCs or the player process. Host tick frequency is not the original DOS timer interrupt rate.
|
||||
The diagnostic kernel also registers a partial KeyboardProcess and KeyDaemon at startup. Text-capable Win32 key messages exercise the recovered keyboard filter/copy callback and update the key-event count on the HUD. The daemon does not receive timer events yet. The visible WASD/keypad controls still use host polling; these processes do not yet deliver player input.
|
||||
|
||||
The walk/run modifier choice is the isolated branch from `Controller_PickNextAnimByKeyevent` (`1130:12d6`) and `KeyEvent_IsShiftDown` (`11c8:016c`): bits `1|2` select Shift, bit `0x40` selects Caps Lock, and walk is selected when their Boolean states match. Win32 supplies modifier bits; NPC state, weapon-dependent actions, original keyboard events, and the remainder of the controller selector are not ported. Retail ANIM.DAT regression checks retain the signed reverse steps in the decoder while testing the host-only forward movement filter across all four affected walk directions.
|
||||
|
||||
On Windows, `remorse_game.exe`, `remorse_rebuild.exe`, and `remorse_map_preview.exe` configure crash reports at startup. Debug CRT assertions do not open Abort/Retry/Ignore windows; the terminate handler reports active C++ exception messages to the Visual Studio Debug output and stderr when available. Escaped/unhandled Windows exceptions log their code/address and suppress the fault popup. The GUI executable has no console stderr by default, so attach a debugger to see that output. A timeout-bounded CTest child process exercises the terminate reporter without a modal prompt. This does not replace a full crash dump or catch process termination that bypasses user-mode handlers.
|
||||
|
||||
This is the first interactive gameplay slice, not yet a playable game: movement has no actor collision response, and there are no enemies, triggers, sound, saves, or USECODE execution. The rendered map is the retail static scene, not a live simulation.
|
||||
|
||||
## Import-Slice Tool
|
||||
|
||||
|
|
@ -300,13 +363,13 @@ The first Windows runtime should prefer clear host abstractions over direct Win3
|
|||
|
||||
## Recommended First Subsystems
|
||||
|
||||
The first source slices should be small enough to compile and test without the entire game loop.
|
||||
Keep source slices small enough to compile and test while following original call edges, not independently designing a replacement engine.
|
||||
|
||||
1. Compatibility/runtime layer: exact types, packed layout helpers, far-pointer wrappers, host file paths, and logging.
|
||||
2. Resource/file loading helpers from the low segments, with DOS file calls replaced by host file services.
|
||||
3. Palette and fixed-format data structures, validated against known assets.
|
||||
4. `EntityDispatchEntry` as the first class-like family because it already has a named export folder and prior class-lifting notes.
|
||||
5. Sprite/node or map rendering data structures after basic resource loading is stable.
|
||||
1. Finish the `EntityDispatchEntry`/`Process` constructor, group-table, and scheduler path, including its globals and kernel calls; `SetGroupId` alone is only a partial foothold.
|
||||
2. Trace original startup and tick entrypoints into the process/player call chain, recording each address and the exact host service boundary it reaches.
|
||||
3. Port resource/file functions actually called by that chain, mapping only DOS-facing calls to the existing host file service.
|
||||
4. Port the original item/draw-list and render functions that consume the live process state; reuse decoded retail assets as parity fixtures.
|
||||
5. Lift the input, movement, interaction, and VM calls reachable from the playable path, replacing prototype logic when original code becomes available.
|
||||
|
||||
## First Hand-Maintained Game Skeleton
|
||||
|
||||
|
|
@ -319,7 +382,7 @@ Current evidence used:
|
|||
- older note anchor recorded in the decompiler comment: `0008:ba00`
|
||||
- allocation size visible in the decompiled initializer: `0x32` bytes
|
||||
|
||||
The current rebuild skeleton preserves the 0x32-byte object size and provides host-side stubs for base init, group-id update, source/item update, and event/proc-type update. The first confirmed offsets from the exported setter bodies are: source item at `+0x04`, event/proc type at `+0x06`, and group id in the low five bits at `+0x08`. These names are still conservative because the surrounding `Process` layout is not fully lifted into typed fields yet.
|
||||
The current rebuild skeleton preserves the 0x32-byte object size, translates group-ID counter transitions, and translates the table word stamps, scalar writes, and group-seed call from base init. A host-owned path now registers and reclaims itemless entries with first-free IDs, allocation-size/name bookkeeping, and the post-registration sync predicate. Source/item update and event/proc-type update remain stand-ins. The first confirmed offsets are: source item at `+0x04`, event/proc type at `+0x06`, and group ID in the low five bits at `+0x08`. The remaining item callbacks, kernel branches, and scheduler must be lifted before the process family can drive gameplay.
|
||||
|
||||
## First Windows Runtime Shim
|
||||
|
||||
|
|
@ -458,9 +521,9 @@ Validated preview:
|
|||
- painted items in the preview crop: 178
|
||||
- full scene bounds: 30,977 x 15,617
|
||||
|
||||
This is still a smoke renderer, not the final game renderer. It uses a simple stable paint order rather than the full engine/item-sorter dependency graph, but it proves the rebuild tree can now load original resources and produce a visible world image.
|
||||
This is still a smoke renderer, not the final game renderer. It now derives world boxes from `TYPEFLAG.DAT`, resolves overlapping sprite bounds with the engine-style dependency graph, and applies the recovered `below()` ordering and occlusion rules. Runtime-only sprite sorting and specialized cases remain outside this host preview.
|
||||
|
||||
After reviewing the first preview, the chosen next direction is render correctness: port fuller item sorting, improve roof/hidden-object policy, and add better crop/navigation controls before moving to an interactive runtime.
|
||||
The next renderer work is to validate window presentation and roof/hidden-object policy, then replace the debug marker with recovered player art and process behavior.
|
||||
|
||||
## Immediate Build Loop
|
||||
|
||||
|
|
@ -470,9 +533,9 @@ Until CMake and MSVC are available in PATH, the source scaffold can be edited an
|
|||
|
||||
Current local toolchain finding:
|
||||
|
||||
- Visual Studio Community 2026 is installed at `I:\Apps\VS\18\Community`.
|
||||
- After installing the Desktop C++ workload, `vcvars64.bat`, MSVC `19.50.35729.0`, and VS-bundled CMake `4.2.3` are usable through the Visual Studio developer environment.
|
||||
- Plain `cmake` is still not available before the Visual Studio environment is initialized, so `build_msvc.cmd` uses `vswhere` and `vcvars64.bat` before invoking CMake.
|
||||
- `vswhere` selects the registered Visual Studio Community 2026 installation at `C:\Program Files\Microsoft Visual Studio\18\Community`; the existing `out/build` cache points at an older `I:\Apps\VS\18\Community` path that CMake cannot resolve as an installed instance.
|
||||
- `vcvars64.bat`, MSVC `19.51.36246.0`, and VS-bundled CMake `4.2.3` are usable through the registered Visual Studio developer environment.
|
||||
- Plain `cmake` is still not available before the Visual Studio environment is initialized. `build_msvc.cmd` initializes MSVC with `vswhere`/`vcvars64.bat` and configures a separate NMake build under `out/build-nmake`.
|
||||
|
||||
### Host Harness
|
||||
|
||||
|
|
@ -493,6 +556,8 @@ From the repository root, the repeatable MSVC path is:
|
|||
rebuild\remorse\build_msvc.cmd Debug
|
||||
```
|
||||
|
||||
The wrapper's NMake build writes `remorse_rebuild.exe` directly under `rebuild/remorse/out/build-nmake/`; it leaves the existing Visual Studio generator cache under `out/build/` untouched.
|
||||
|
||||
### Staging One Export Slice
|
||||
|
||||
From the repository root:
|
||||
|
|
@ -511,6 +576,13 @@ python rebuild/remorse/tools/import_export_slice.py classes/Remorse/EntityDispat
|
|||
- Added an import-slice tool for staging individual exported function folders without linking them yet.
|
||||
- Ran the importer on `classes/Remorse/EntityDispatchEntry`; it staged 24 files, replaced 62 calling-convention tokens, and reported `CONCAT22`, `unaff_CS`, and `unaff_SS` as cleanup signals.
|
||||
- Added the first hand-maintained `EntityDispatchEntry` source skeleton and wired it into the CMake target.
|
||||
- Translated `11e0:02a8` group-ID validation, counter transitions, and no-op on an unchanged group into the compiled skeleton; other methods still have incomplete or placeholder behavior.
|
||||
- Replaced `InitBase`'s blanket clear with live-confirmed `11e0:0000` function-table stamps, scalar assignments, and the active-group `SetGroupId` call; seeded-byte tests protect unknown bytes while the rest of the constructor remains unported.
|
||||
- Added an owned host allocate/init/register call path, porting the first-free ID, 30-slot growth, process-ID/size/count bookkeeping, and `Process_11d0_19cd` syncing predicate. The harness now registers a process (ID 0); this does not run the original scheduler.
|
||||
- Added default process-name storage, optional `ExtProc_NewlyCreated` flag/counter, immediate and deferred itemless termination, and slot cleanup/ID reuse. The harness also terminates ID 3, cleans its slot, and registers another process at ID 3; normal ID 0 lookup is a special case.
|
||||
- Ported the conditional `InitBase` current-process extflag branch and the normal-process scan gates of `11d0:0255`. Tests cover group selection, one-pass sync, creation from a run callback, and cleanup during the scan.
|
||||
- Ported the original `Process_Sleep`/`Unlink` timer writes and wake check, then executed `StandProcess::Run` under the scheduler in the diagnostic harness. It now uses an owned 0x42-byte Stand entry, compiled `1100:026e` NPC decision gates with host-supplied services, and a timer value produced by `SystemTimerProcess_Increment`. CTest checks off-screen sleep, the strict 60-tick deadline, visible behavior start, already-current activity, Stand's no-op completion slot, and timer carry. Host-owned Stand termination now refreshes the per-item bit; tests cover two processes for one item, deferred reclamation, and final immediate removal. Live Ghidra names `Item_MarkProcessPresent`/`Item_ClearProcessPresent`/`Item_RefreshProcessPresenceFlag` at `11d0:3e0b/3e44/3e7f` anchor the port.
|
||||
- Configured the Windows GUI and console executables to emit CRT and unexpected-exception details to debugger output/stderr instead of modal crash prompts. CTest resets the CRT assert mode to window mode and verifies the installer removes it, then captures a deliberately terminating child process without a popup.
|
||||
- Split the scaffold into a `remorse_core` library, host executable, and first CTest target for `EntityDispatchEntry` setters.
|
||||
- Added the first host file-system shim and CTest target for game-data root discovery.
|
||||
- Extended the host file-system shim with case-insensitive data-path resolution, parent-traversal blocking, and binary file reads.
|
||||
|
|
@ -523,9 +595,17 @@ python rebuild/remorse/tools/import_export_slice.py classes/Remorse/EntityDispat
|
|||
- Added a typed `TYPEFLAG.DAT` parser for shape family, flags, dimensions, and animation metadata.
|
||||
- Added a typed `SHAPES.FLX` parser and row-RLE decoder for renderable frame pixels.
|
||||
- Added the first visual map preview renderer and BMP output command.
|
||||
- Added `remorse_game.exe`, a native Win32 window that asynchronously loads a retail map, displays the graph-sorted scene, and supports bounded WASD/arrow movement with a following camera.
|
||||
- Added a persistent GDI back buffer and disabled background erase for the window's movement redraw path.
|
||||
- Mapped keyboard movement to screen-cardinal directions through the inverse isometric transform and added a four-direction projection regression.
|
||||
- Added a camera-centered render origin and a renderer test covering fixed-size viewport output.
|
||||
- Documented the windowed app command and clearly scoped its current debug-marker/no-collision limitations.
|
||||
- Replaced the host preview's scalar paint key with a footpad-aware dependency graph based on the local Ultima 8/Crusader sorter, including pairwise overlap, `below()` rules, and occlusion handling.
|
||||
- Added a synthetic regression proving vertical separation can override the old `x+y` order, and retained the retail-data map-render smoke test.
|
||||
- Validated `remorse_map_preview` by rendering map 1 to `rebuild/remorse/out/preview/map1-preview.bmp` from original retail data.
|
||||
- Verified the scaffold with Visual Studio Community 2026: CMake configure succeeded, MSVC build succeeded, `ctest -C Debug` passed 2/2 tests, and `remorse_rebuild.exe` ran against `exports/src_remorse/export_manifest.json`.
|
||||
- Added `build_msvc.cmd` so the working build/test/harness loop is repeatable from the repository root.
|
||||
- Added `build_msvc.cmd` so the MSVC build/test/harness loop is repeatable from the repository root; it uses an isolated NMake build tree to avoid the local CMake Visual Studio-instance resolution failure.
|
||||
- Revalidated the wrapper with MSVC `19.51.36246.0`: all C++ targets built, all 11 CTest tests passed, and the host harness loaded the export manifest and retail resource summaries.
|
||||
- Documented the current blockers between the Ghidra export and compiler-ready source.
|
||||
- Split the goal into historical reconstruction and Windows source-port tracks.
|
||||
- Chose Visual Studio Build Tools plus CMake as the first intended Windows host toolchain.
|
||||
|
|
@ -535,27 +615,29 @@ python rebuild/remorse/tools/import_export_slice.py classes/Remorse/EntityDispat
|
|||
- Keep the host scaffold building as new source slices are added.
|
||||
- Lift the confirmed `EntityDispatchEntry` byte offsets into named packed fields once the surrounding `Process` layout is stable.
|
||||
- Convert the compatibility header from placeholders into enforced layout macros with static assertions.
|
||||
- Pick the first real subsystem slice and move it into `rebuild/remorse/`.
|
||||
- Extend the translated `SetGroupId` slice to its original initializer/callers and record the ported function addresses and parity checks.
|
||||
- Expand the host file-system shim into DOS file-handle replacements and writable save/config locations.
|
||||
- Model far pointers and segmented memory in a way that can support both trace comparison and Windows execution.
|
||||
- Normalize Ghidra exported types into valid C++ names without losing address provenance.
|
||||
- Replace raw global-byte exports with typed data definitions or resource loaders.
|
||||
- Define resource fixture tests for palette, shape, map, and usecode data.
|
||||
- Replace the current preview painter's simple ordering with a fuller item-sorter dependency graph.
|
||||
- Decide whether the first interactive window should use SDL, raw Win32/GDI, or another host layer.
|
||||
- Decide the graphics/input/audio platform layer for the Windows runtime.
|
||||
- Add explicit crop/navigation controls and tests for bounded map previews.
|
||||
- Validate roof/hidden-object rendering policy against selected retail scenes.
|
||||
- Keep the current Win32/GDI window as a diagnostic host while lifting the original player/process loop; choose other platform layers only as original DOS/hardware boundaries require them.
|
||||
- Replace the windowed prototype movement/collision with ported player and AreaSearch behavior, using retail art and the existing renderer for presentation.
|
||||
- Connect triggers and object interaction to the USECODE runtime after its value/context model is lifted.
|
||||
- Add CI-style smoke tests once the host toolchain and first resource loader compile reliably.
|
||||
|
||||
## Near-Term Next Actions
|
||||
|
||||
1. Open a Developer PowerShell with MSVC and CMake available, then run the CMake scaffold build.
|
||||
2. Replace the current `EntityDispatchEntry` byte-array fields with named packed fields as evidence allows.
|
||||
3. Add a small host-side test for the confirmed `+0x04`, `+0x06`, and `+0x08` setters once the MSVC/CMake toolchain is available.
|
||||
4. Map the first old DOS file functions onto the new host file-system shim.
|
||||
5. Add writable save/config path handling.
|
||||
6. Add layout assertions for the first recovered packed structs.
|
||||
7. Start a render/runtime decision note once the first resource smoke test passes.
|
||||
1. Verify the live `Process` group-table allocation/initialization and the active-group writer `11d0:19b5`; compare `11e0:02a8` side effects with an execution trace (including counter ownership and error paths).
|
||||
2. Complete `InitBase` (`11e0:0000`) and the kernel lifecycle by resolving the segment assertion, conditional kernel branch, item-linked teardown, process destructor dispatch and far-pointer storage; compare the host registry to real process snapshots.
|
||||
3. Trace `Init_Everything` -> `FUN_11d0_0255` -> the player process and additional vtable `Run` targets; verify Stand's ported presence-bit lifecycle against original snapshots, then port animation-cache and nonempty-child teardown against real NPC state.
|
||||
4. Port the real timer process and NPC service implementations, then scheduler keyboard, active-group advancement, remaining sleep-completion dispatch and table-maintenance tails; compare deterministic process-order/state traces before connecting the Windows window.
|
||||
5. Replace DOS file and memory APIs encountered by the ported chain with narrow host adapters; validate far-pointer/layout conversions against live evidence.
|
||||
6. Port original movement and AreaSearch/collision behavior before promoting the host actor movement from stand-in to gameplay code.
|
||||
7. Feed original item/draw-list output into the existing renderer, then lift USECODE dispatch, save/load, audio, and frontend chains as required for playable mission progression.
|
||||
|
||||
## Current Bottom Line
|
||||
|
||||
The project is now at the start of the recompilation lane: there is a buildable host target scaffold, a compatibility surface, and a documented path for importing cleaned decompiler output. The major remaining work is systematic conversion, platform replacement, and behavior validation, not another bulk export.
|
||||
The project has a buildable diagnostic host, retail resource loaders, a tested process lifecycle for host-owned base and zero-child-state Stand entries, a partial original scheduler scan, and an owned 0x42-byte Stand entry executing recovered NPC-decision and `Run` branches against a source-backed timer counter (`StandProcess Run sleep ticks: 60`, three other host callbacks). Creation and termination update the per-item presence bit, but this is **not** a game milestone: real NPC item ownership, nonempty-child teardown, visibility/activity service implementations, timer-process construction and interrupts, the complete tick, startup, player, renderer, and interaction chains remain unported; `remorse_game.exe` is not connected to this registry. The next measure of progress is a real item-linked Stand/NPC instance running on the original call chain with state trace parity.
|
||||
|
|
|
|||
63
docs/scummvm-crusader-movement-tap-turn.md
Normal file
63
docs/scummvm-crusader-movement-tap-turn.md
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
# ScummVM Crusader Movement Tap-Turn Fix
|
||||
|
||||
This note records the ScummVM-side movement fix for Crusader: No Remorse tap-turning while running.
|
||||
|
||||
## Problem
|
||||
|
||||
In ScummVM's Crusader implementation, quickly tapping left or right while holding run/forward could fail to rotate the Silencer. The code already had a pending-turn path for short key taps, but it only applied that path while the last animation was `run`, `combatRunSmallWeapon`, or `walk`.
|
||||
|
||||
That left out the start-run animations and the large-weapon combat-run animation. If a left/right tap arrived while the actor was still in `startRun`, `startRunSmallWeapon`, `startRunLargeWeapon`, or `combatRunLargeWeapon`, the pending turn could be cleared before it was applied.
|
||||
|
||||
## Decompiled Source Evidence
|
||||
|
||||
The exported Ghidra decompilation for retail `CRUSADER.EXE` shows the original controller treats more than plain run/walk as direction-adjustable movement.
|
||||
|
||||
Evidence files:
|
||||
|
||||
- `exports/src_remorse/functions/segments/seg_1130/Controller_PickNextAnimByKeyevent@1130_12d6.c`
|
||||
- `exports/src_remorse/functions/segments/seg_1130/Controller_UpdateAvatarAngle@1130_10cf.c`
|
||||
- `exports/src_remorse/functions/segments/seg_1130/Anim_1130_0f94@1130_0f94.c`
|
||||
|
||||
Relevant behavior:
|
||||
|
||||
- Left and right key events use the `0x11` / `0x12` temporary direction markers, then convert them into one direction step right or left according to the target animation's 8-dir or 16-dir mode.
|
||||
- If the controlled NPC is busy, `Controller_PickNextAnimByKeyevent` still allows a keydown turn to update the active animation direction when `Anim_1130_0f94` says the current animation supports direction updates.
|
||||
- `Anim_1130_0f94` includes `Anim_Walk`, `Anim_Run`, `Anim_StartRunning`, `Anim_CombatRun_SmallWpn`, `Anim_CombatRun_LargeWpn`, `Anim_StartRun_SmallWpn`, and `Anim_StartRun_LargeWpn` in that supported set.
|
||||
|
||||
So the original behavior does not limit tap-turn handling to only the settled run/walk loops. It also accepts direction changes during run startup and combat-run variants.
|
||||
|
||||
## ScummVM Change
|
||||
|
||||
Updated ScummVM file:
|
||||
|
||||
- `engines/ultima/ultima8/world/actors/cru_avatar_mover_process.cpp`
|
||||
|
||||
The `_isAnimRunningWalking` helper now returns true for:
|
||||
|
||||
- `Animation::run`
|
||||
- `Animation::startRun`
|
||||
- `Animation::combatRunSmallWeapon`
|
||||
- `Animation::combatRunLargeWeapon`
|
||||
- `Animation::startRunSmallWeapon`
|
||||
- `Animation::startRunLargeWeapon`
|
||||
- `Animation::walk`
|
||||
|
||||
This keeps the existing ScummVM pending-turn design, but widens the eligible animation window to match the original controller's supported movement animations. A quick left/right tap while run-forward is active can now be consumed during run startup or either combat-run variant instead of being discarded.
|
||||
|
||||
## Validation
|
||||
|
||||
Static validation performed:
|
||||
|
||||
- Confirmed the changed symbols already exist in ScummVM's Crusader animation enum.
|
||||
- Confirmed the ScummVM change is limited to the Crusader mover helper that gates pending turn application.
|
||||
|
||||
Runtime validation still needed:
|
||||
|
||||
- Build ScummVM with the Ultima engine enabled.
|
||||
- Start Crusader: No Remorse.
|
||||
- Hold run plus forward, tap left/right during run startup and while fully running, and confirm the Silencer rotates one direction step without releasing run/forward.
|
||||
- Repeat with weapon-ready combat run when possible, including a large weapon if available.
|
||||
|
||||
## Notes
|
||||
|
||||
The live Ghidra MCP bridge was not reachable during this pass, so the evidence above comes from the checked-out exported Ghidra decompilation under `exports/src_remorse/` rather than a fresh live decompile.
|
||||
Loading…
Add table
Add a link
Reference in a new issue