Crusader_Decomp/docs/remorse-windows-rebuild-roadmap.md
Maddo 202679f857 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.
2026-09-25 21:41:20 +02:00

643 lines
56 KiB
Markdown

# Remorse Windows Rebuild Roadmap
## Purpose
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 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
- `exports/src_remorse/export_manifest.json` reports `CRUSADER.EXE`, 2,984 exported function files, 9 fallback function files, 57 global buckets, and 15,403 global definitions.
- `exports/src_remorse/CRUSADER.EXE.h` contains the bulk Ghidra data types and provisional structure definitions.
- `exports/src_remorse/functions/` contains split function bodies, including class-like folders such as `Remorse/EntityDispatchEntry`, `Remorse/SpriteNode`, `Remorse/EntityVmRuntime`, and related process families.
- Existing rebuild planning is in `docs/remorse-cpp-decompilation-plan.md`, `docs/remorse-rebuild-abi-notes.md`, and `docs/remorse-cpp-compatibility-header-draft.md`.
## First Concrete Scaffold
The first host rebuild scaffold is now under `rebuild/remorse/`.
It is deliberately separate from `exports/src_remorse/` because the export is generated, ignored by git, and still contains syntax and ABI artifacts that modern compilers cannot accept wholesale.
Current scaffold files:
- `rebuild/remorse/CMakeLists.txt`: CMake target for a Windows-friendly C++17 executable named `remorse_rebuild`.
- `rebuild/remorse/build_msvc.cmd`: repeatable MSVC/CMake build, test, and harness-run command.
- `rebuild/remorse/include/remorse/combat_tactics.h`: typed reader for `COMBAT.DAT` tactic records.
- `rebuild/remorse/include/remorse/compat.h`: exact-width aliases, far-pointer placeholders, packing macros, and calling-convention marker macros.
- `rebuild/remorse/include/remorse/export_prelude.h`: temporary bridge types for staged Ghidra-export imports.
- `rebuild/remorse/include/remorse/entity_dispatch_entry.h`: first hand-maintained class-family skeleton, anchored to the `11e0:0000` / older `0008:ba00` allocation evidence.
- `rebuild/remorse/include/remorse/file_system.h`: first host file/path discovery shim for replacing DOS install-path assumptions.
- `rebuild/remorse/include/remorse/flex_archive.h`: standard FLEX archive directory parser.
- `rebuild/remorse/include/remorse/fixed_map.h`: typed `FIXED.DAT` map table and 16-byte item-record reader.
- `rebuild/remorse/include/remorse/glob_archive.h`: typed `GLOB.FLX` object-entry reader.
- `rebuild/remorse/include/remorse/map_renderer.h`: first dependency-free map preview renderer and BMP writer.
- `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/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`: 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.
- `rebuild/remorse/tests/glob_archive_tests.cpp`: checks `STATIC/GLOB.FLX` parses into at least one populated glob object.
- `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 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
The current exported C is very valuable, but it is not compiler-ready source for either DOS or Windows.
Known blockers visible in the export:
- C++ namespace-qualified function names appear inside `.c` files, for example `Remorse::EntityDispatchEntry::InitBase`.
- Ghidra calling-convention spellings such as `__cdecl16far`, `__cdecl16near`, `__stdcall16far`, and `__regcall` are not portable host compiler syntax.
- Ghidra undefined-width types and decompiler temporaries (`undefined`, `undefined2`, `undefined4`, `unaff_SS`, `unaff_CS`, synthetic stack variables, and return-storage pointers) need type and calling-convention cleanup.
- Header output includes invalid or provisional C declarations such as structure names containing spaces.
- Switch-table and global-byte exports are emitted as raw `undefined` objects that need relocation-aware or data-layout-aware modeling.
- Some functions still rely on segmented pointer reconstruction through expressions such as `CONCAT22`, not host pointers.
- The original binary is a DOS protected-mode `MZ -> NE` program using Phar Lap 286 extender behavior and far calls, so a modern Windows build needs a platform/runtime replacement rather than a simple relink.
## Rebuild Tracks
### Track A: Historical Executable Reconstruction
This track tries to rebuild something close to the original DOS protected-mode executable model.
It must preserve segmented pointers, far-call provenance, original-style packing, external runtime calls, and NE/Phar Lap assumptions. It is the hardest path and is not the primary route to modern Windows compatibility, but it remains important because it keeps the reverse-engineered ABI honest.
### Track B: Windows Source Port
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.
For the stated goal of running on modern Windows, Track B is the practical primary track. Track A should still guide early type cleanup so the port does not accidentally erase evidence.
## Conversion Strategy
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. 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: 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
Goal: every step builds, runs tests, and keeps provenance visible.
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
Goal: replace DOS installation assumptions with modern host services.
Work:
- game-data root discovery
- case-insensitive path resolution
- binary reads
- DOS-style file-handle facade
- writable config/save/user-data root
- command-line and config parsing
- logging and fatal-error reporting
Exit criteria: the harness can find data, open/read assets through the same facade future game code will use, and write test save/config output outside the read-only retail data root.
### Phase 2: Core Resource Loaders
Goal: typed loaders for the files needed before gameplay can start.
Work:
- palettes: `GAMEPAL.PAL`, misc palettes, palette transforms
- FLEX archives: `COMBAT.DAT`, `GLOB.FLX`, `SHAPES.FLX`, `EUSECODE.FLX`, fonts/gumps/icons
- maps: `FIXED.DAT`, glob expansion, type flags
- shapes: Crusader frame directory and RLE decode
- usecode archive chunk discovery
Exit criteria: a smoke test can load one map, expand globs, decode referenced shapes, and produce an in-memory scene without executing gameplay.
### Phase 3: Minimal Renderer
Goal: put a real Crusader world image on screen on Windows.
Work:
- choose initial graphics layer, likely SDL for window/input/timing/audio portability
- convert paletted frames to host pixels
- implement deterministic fixed-map painter first
- add debug overlay/status console for loaded map and camera position
Exit criteria: running the host executable opens a window and displays a recognizable fixed-map scene from retail data.
### Phase 4: Process, Item, And Entity Runtime
Goal: lift the core object/process model into host source.
Work:
- typed `Process` / `EntityDispatchEntry` layout
- item allocation, fixed-format conversion, map item cache
- scheduler/process list
- sprite-node/draw-list families
- core entity fields and update lanes
Exit criteria: the host runtime can instantiate map items/entities and advance a deterministic tick without requiring the full original VM yet.
### Phase 5: Input, Camera, And Player Loop
Goal: make the rendered world navigable.
Work:
- keyboard/mouse abstraction
- camera scroll/viewport state
- cursor/selection state
- player/avatar process skeleton
- collision/line-of-sight primitives as needed
Exit criteria: the user can launch the host build, view a map, move the camera/avatar test object, and observe stable tick/update behavior.
### Phase 6: USECODE / VM Runtime
Goal: execute game scripts from original `EUSECODE.FLX`.
Work:
- import and type `EntityVmRuntime`, owner-resource, context, and slot-entry families
- parse usecode chunks and dispatch tables
- implement VM value stack, globals, calls, and event dispatch
- cross-check against existing usecode extraction tools
Exit criteria: selected map triggers and object interactions execute through the host VM with traceable parity against known extracted usecode behavior.
### Phase 7: Gameplay Systems
Goal: make core No Remorse gameplay work.
Work:
- actor movement and animation
- combat tactic interpreter from `COMBAT.DAT`
- projectiles and hit resolution
- inventory/equipment
- doors, elevators, panels, triggers, movable walls
- save/load state
Exit criteria: a small scenario can be played end to end with movement, combat, interaction, and persistence.
### Phase 8: Media And Presentation
Goal: reach production game flow rather than only a debug map runner.
Work:
- menu/frontend flow
- fonts/gumps/icons/HUD
- music/audio mixer
- flic/movie playback
- cutscene and mission transition behavior
Exit criteria: the host build can boot through a recognizable frontend and enter gameplay using retail resources.
### Phase 9: Whole-Game Integration And Parity
Goal: turn subsystem success into a working game.
Work:
- mission progression
- all retail maps/resource variants
- error recovery and missing-data handling
- deterministic trace comparisons for high-risk systems
- long-run smoke tests
Exit criteria: the game can be started, played across mission transitions, saved, loaded, and exited on modern Windows.
### Phase 10: Packaging And Modernization
Goal: make it usable outside the development repo.
Work:
- data-root picker or command-line root selection
- per-user config/save directory
- release build profile
- crash logs
- user documentation
- optional quality-of-life settings that do not obscure parity bugs
Exit criteria: a clean checkout/build can run against a retail data directory with documented setup steps.
## Current Execution Focus
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
The first source-conversion helper is `rebuild/remorse/tools/import_export_slice.py`.
Its job is intentionally modest: copy one folder from `exports/src_remorse/functions/` into ignored staging output under `rebuild/remorse/imported/`, rewrite Ghidra's direct `CRUSADER.EXE.h` include to `remorse/export_prelude.h`, convert known 16-bit calling-convention tokens to compatibility macros, and write an import report listing cleanup signals such as `unaff_SS`, `unaff_CS`, `CONCAT22`, and hidden return-storage parameters.
Example:
```powershell
python rebuild/remorse/tools/import_export_slice.py classes/Remorse/EntityDispatchEntry
```
The generated staging files are not linked into `remorse_rebuild`. They are a workbench for turning one exported subsystem into hand-maintained source.
The first run against `classes/Remorse/EntityDispatchEntry` staged 24 files, replaced 62 calling-convention tokens, preserved 46 namespace-qualified references, and reported `CONCAT22`, `unaff_CS`, and `unaff_SS` as cleanup signals.
## Windows Runtime Work Needed
To run on Windows, the rebuild needs replacement layers for these original services:
- process startup and command-line/config parsing
- DOS file APIs and search paths
- Phar Lap / DOS extender memory services
- segmented far-pointer memory model, at least as a compatibility abstraction
- VGA/SVGA video mode setup, palette writes, bank switching, and blitting
- keyboard, mouse, and joystick input
- timer/tick scheduling
- audio device and mixer services
- movie playback and RIFF/audio frame handling
- save/load paths and user-writable data locations
- game data discovery for retail install layouts and repository fixtures
The first Windows runtime should prefer clear host abstractions over direct Win32 calls where possible. SDL or another portability layer is a reasonable later choice for graphics, input, timing, and audio, but that should be selected after the first resource-loading and render smoke tests are defined.
## Recommended First Subsystems
Keep source slices small enough to compile and test while following original call edges, not independently designing a replacement engine.
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
The first manually maintained game-shaped source is `EntityDispatchEntry`.
Current evidence used:
- live export folder: `exports/src_remorse/functions/classes/Remorse/EntityDispatchEntry/`
- base initializer: `InitBase@11e0_0000.c`
- 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, 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
The first platform-replacement layer is a host file-system shim.
Current behavior:
- inspects a candidate root for `CRUSADER.EXE`, `CRUSADER.CFG`, `STATIC`, and `USECODE`
- walks upward from the current directory until it finds a usable game-data root
- resolves game-data-relative paths case-insensitively for ASCII DOS-style names
- blocks parent traversal through `..`
- reads binary files into host byte buffers
- reports the root path from the host harness
- adds a CTest target that expects the repository root to contain the retail executable and data folders, then reads `STATIC/GAMEPAL.PAL`
This starts replacing the original DOS install-directory assumptions with explicit modern path discovery. It is intentionally narrow; file handles, writable save paths, and retail/install-layout variants are still to come.
## First Data Parser
The first parsed retail data asset is `STATIC/GAMEPAL.PAL`.
Current behavior:
- resolves `STATIC/GAMEPAL.PAL` through the host file-system shim
- requires exactly 768 bytes
- parses the file into 256 RGB triples
- reports the parsed color count from the host harness
- validates the path through `palette_tests`
This gives the future renderer a tiny but real data pipeline: host path discovery, binary load, format validation, and typed in-memory representation.
## First Archive Parser
The first archive parser handles the standard Crusader FLEX directory used by files such as `COMBAT.DAT`, `GLOB.FLX`, `SHAPES.FLX`, and `EUSECODE.FLX`.
Current behavior:
- reads the entry count at file offset `0x54`
- reads 8-byte directory rows at file offset `0x80`
- treats rows as little-endian `<u32 offset, u32 size>`
- skips empty rows and rejects out-of-file entries
- extracts individual populated entries by index
- validates `STATIC/COMBAT.DAT` as 14 populated records with entry 0 named `Dumb`
This is the first reusable loader shared by AI tactics, glob objects, shapes, and usecode archives.
## First Typed Archive Consumer
The first typed FLEX consumer is `COMBAT.DAT`.
Current behavior:
- loads the outer FLEX directory through `loadFlexArchive`
- parses each populated record's 16-byte NUL-padded tactic name
- reads four little-endian block offsets
- exposes the remaining bytes as tactic bytecode
- validates the shipped archive as 14 tactics, with entry 0 named `Dumb` and block offsets `0x002c` / `0x0031`
This is not yet the combat bytecode interpreter, but it establishes the pattern for moving from raw archive chunks to typed subsystem inputs.
## First Fixed-Map Loader
`FIXED.DAT` is now the next typed world-data input.
Current behavior:
- reads the map count at file offset `0x54`
- reads 8-byte map table rows at file offset `0x80`
- treats each row as little-endian `<u32 offset, u32 size>`
- parses 16-byte fixed-item records into typed fields
- applies the verified Crusader coordinate scale: disk `x/y * 2`
- validates all map table rows parse, at least one map is non-empty, and out-of-range map indices are rejected
This is the first step toward a host-side map scene assembled from retail data.
## First Glob Loader
`GLOB.FLX` is now parsed as the companion object-expansion archive for fixed maps.
Current behavior:
- loads the outer FLEX directory through `loadFlexArchive`
- reads each glob object as `u16 count` followed by repeated 6-byte entries
- parses each entry as `x:u8`, `y:u8`, `z:u8`, `shape:u16`, `frame:u8`
- validates the archive contains at least one glob object with entries
This prepares the next step: expanding fixed-map glob eggs into concrete world objects using the coordinate rules in `docs/map-rendering.md`.
## First Typeflag Loader
`TYPEFLAG.DAT` is now parsed as the shape-family metadata source needed by map expansion and rendering.
Current behavior:
- requires 9-byte records
- decodes the 20-bit typeflag field using the same byte layout as the Python map renderer
- decodes shape family, footpad dimensions, and animation type
- validates the shipped file contains 2,048 shape records and includes glob-family shapes
This is the shape metadata layer needed before fixed-map records can be classified as drawables, glob eggs, triggers, roofs, editor objects, or other family-specific runtime objects.
## First Shape Decoder
`SHAPES.FLX` is now parsed as the first renderable art source.
Current behavior:
- loads the outer FLEX directory through `loadFlexArchive`
- parses the Crusader shape header and 8-byte per-frame table
- reads 28-byte frame bodies, per-line RLE offsets, frame dimensions, and draw offsets
- decodes row RLE into transparent-or-palette-index pixels
- validates the shipped archive can decode at least one visible frame
This completes the remaining Phase 2 requirement needed for a minimal map image: fixed records, glob records, shape metadata, palette, and decoded shape pixels.
## First Visual Preview Renderer
Phase 3 now has its first concrete artifact: `remorse_map_preview` writes a 24-bit BMP preview using only the source-port rebuild code and the shipped retail data.
Current behavior:
- defaults to map 1, the first non-empty fixed-map table entry in this data set
- expands first-level glob eggs using `GLOB.FLX`
- filters hidden marker/egg/roof families by default, matching the offline map-rendering workbench's first-pass policy
- decodes visible `SHAPES.FLX` frames and paints them with `GAMEPAL.PAL`
- writes a dependency-free BMP image under `rebuild/remorse/out/preview/`
Validated preview:
- command: `rebuild\remorse\out\build\Debug\remorse_map_preview.exe rebuild\remorse\out\preview\map1-preview.bmp 1`
- output: `rebuild/remorse/out/preview/map1-preview.bmp`
- image size: 1600x900
- raw fixed records: 7,547
- render items after filters/globs: 15,318
- decoded items: 15,318
- 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 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.
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
The first chosen Windows toolchain is Visual Studio Build Tools plus CMake. That means the expected compiler is MSVC `cl.exe`, usually reached through a Developer PowerShell or Developer Command Prompt.
Until CMake and MSVC are available in PATH, the source scaffold can be edited and syntax-checked by VS Code, but it cannot be built locally from this shell.
Current local toolchain finding:
- `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
From `rebuild/remorse/`, the intended host build loop is:
```powershell
cmake -S . -B out/build
cmake --build out/build
ctest --test-dir out/build -C Debug --output-on-failure
.\out\build\Debug\remorse_rebuild.exe ..\..\exports\src_remorse\export_manifest.json
```
For single-config generators, the executable may be under `out/build/remorse_rebuild.exe` instead of `out/build/Debug/`.
From the repository root, the repeatable MSVC path is:
```powershell
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:
```powershell
python rebuild/remorse/tools/import_export_slice.py classes/Remorse/EntityDispatchEntry
```
## What Is Done
- Established a separate rebuild tree under `rebuild/remorse/`.
- Added a CMake-based C++17 executable target.
- Added an initial compatibility header matching the earlier ABI draft categories.
- Added a temporary export prelude for staged decompiler-source imports.
- Added a minimal runtime harness that reads the exported decompilation manifest and reports the current export scope.
- 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.
- Added the first typed game-data parser for 256-color palette files and verified `STATIC/GAMEPAL.PAL` parses to 256 colors.
- Added a standard FLEX archive parser and verified `STATIC/COMBAT.DAT` exposes 14 populated records.
- Added a typed `COMBAT.DAT` tactic parser and verified entry 0 metadata against the existing combat note.
- Added a full staged rebuild plan from current harness through a playable and packaged modern Windows source port.
- Added a typed `FIXED.DAT` map loader for map table and 16-byte fixed-item records.
- Added a typed `GLOB.FLX` object parser for the fixed-map glob-expansion path.
- 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 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.
## What Is Left To Do
- 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.
- 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.
- 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. 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 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.