Refactor usecode task management and enhance teleportation logic
- Improved the queueUsecodeTask function to streamline process termination and context management. - Added robust error handling for event context creation and memory writing. - Enhanced the loadSceneAsync function to better handle avatar teleportation, including a new teleporter process. - Expanded entity dispatch tests to cover movement and teleporter processes, ensuring correct behavior under various conditions. - Introduced new tests for usecode runtime memory allocation and context creation, validating edge cases and error handling. - Updated flex archive tests to ensure proper loading and unloading of usecode slot chunk caches.
This commit is contained in:
parent
8c23bb02c9
commit
0771c86043
12 changed files with 1091 additions and 253 deletions
|
|
@ -133,13 +133,21 @@ Current layout claims that matter for class lifting:
|
|||
- `+0x117/+0x119` cache the owner-linked source pair
|
||||
- `+0x123` behaves as a busy or active flag in the sync/dispatch path
|
||||
|
||||
`CreateFromSlotIndex` initializes the embedded interpreter, copies the item parameter only when mode flags are nonzero, copies optional `ucparam` bytes into the backward-growing stack, then reserves four bytes for the prior stack pointer when both are present. The host VM models this order and the `+0x11f` relative offset, but does not synthesize the original segment:offset pointer or map the runtime-owned code and owner buffers yet.
|
||||
`CreateFromSlotIndex` initializes the embedded interpreter, copies the item parameter only when mode flags are nonzero, copies optional `ucparam` bytes into the backward-growing stack, then reserves four bytes for the prior stack pointer when both are present. `createUsecodeContext` now builds a bounded host context from caller-supplied runtime pointers: it allocates the `0x124` process body and `0x82` call-stack buffer, maps code/owner pointers through `UsecodeRuntimeMemory`, writes the interpreter's stack/base/limit fields, copies only the active stack window, stores the saved pointer at the recovered relative location, and seeds the initial far-call pair. Invalid source ranges and stack overflow fail before leaving partial allocations. `usecode_vm_tests` checks the process bytes, pointer ranges, parameter ordering, call-stack bytes, and cleanup.
|
||||
|
||||
`createUsecodeEventContext` adds the retail owner-row and event-slot inputs. `UsecodeTaskRegistry::addWithContext` owns the resulting context allocations for the task lifetime. The window use-request path now searches nearby item candidates, selects an eligible event through the owner rows, creates the context-backed task, writes its process ID output word, and copies the context bytes into the owned process entry. The retail BOX_NS test exercises candidate-driven selection and VM execution through injected item/timer services; it verifies frame/render changes and releases all context allocations on task removal.
|
||||
|
||||
This is still host-side selection and execution, not the original `Usecode_ItemCallEvent` dispatcher or proven `CreateFromSlotIndex` call chain. The exact runtime meaning of the initial slot/value-add call-frame pair remains unverified, as do original owner-resource callback parity and general far-pointer dispatch.
|
||||
|
||||
The embedded interpreter initializes its stack limit to 199 bytes; the host bootstrap rejects a combined initial item/context payload and saved-pointer slot above that limit.
|
||||
|
||||
The host opcode service currently maps segment `0` to the task's item-memory buffer through `UsecodeProcessTask::readMappedItemWord`; all other segments are rejected. This centralizes the existing fixture behavior but is not a general segmented address space.
|
||||
|
||||
`UsecodeClass` now reads the first header dword as the extra-slot count. `initializeUsecodeSlotOwnerBuffers` copies the six-byte descriptors from class `+0x14` into a host buffer of `0xc0 + 6 * extraSlotCount` bytes and creates `32 + extraSlotCount` state words initialized to `0xffff`, matching `InitSlotOwnerBuffers`; retail `EVENT` and `NPCTRIG` cover the base and one-extra-slot cases. `UsecodeSlotChunkCache` reads descriptors through this buffer, tracks ensure/release counts, and unloads only at count zero, restoring the state sentinel so a later ensure reloads the body. This remains an archive-backed host model: the 0x16-byte `UProcess_1420_0000` object, owner-helper materialization, runtime loaded-list record, and far-pointer allocation/restoration are not implemented.
|
||||
`UsecodeClass` now reads the first header dword as the extra-slot count. `initializeUsecodeSlotOwnerBuffers` copies the six-byte descriptors from class `+0x14` into a host buffer of `0xc0 + 6 * extraSlotCount` bytes and creates `32 + extraSlotCount` state words initialized to `0xffff`, matching `InitSlotOwnerBuffers`; retail `EVENT` and `NPCTRIG` cover the base and one-extra-slot cases.
|
||||
|
||||
`UsecodeSlotChunkCache` now models the verified `UProcess_1420_0000` layout as a 0x16-byte record: a 16-bit vtable offset, previous/next far links at `+0x02/+0x06`, chunk-buffer far pointer at `+0x0a`, saved source pair at `+0x0e`, and slot/chunk indices at `+0x12/+0x14`. The host allocates a bounded segment for each process and chunk buffer, initializes the chunk buffer to `0xff`, copies the archive-backed body, replaces the descriptor's source pair with the buffer pointer, and links the process at the loaded-list head. On zero-count eviction it restores the saved source pair, resets state to `0xffff`, unlinks both neighbors, and releases both allocations. Retail `EVENT`/`NPCTRIG` tests and a synthetic two-node list cover reuse, eviction, pointer restoration, and list unlinking.
|
||||
|
||||
`UsecodeRuntimeMemory` currently assigns one bounded region per nonzero segment, with at most 64 KiB per allocation and range-checked reads/writes. This is host address-space scaffolding, not a recovered DOS allocator. Materialization reads from the loaded `UsecodeClass` byte buffer; the original `EntityVmOwnerResource` callback and live runtime allocation/address parity remain unverified.
|
||||
|
||||
Current caution:
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@ The exported files are evidence, not directly compilable game source. Keep them
|
|||
- 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.
|
||||
|
||||
## Source-Backed In-Game Vertical Slice
|
||||
Current progress correction: the long progress paragraph below predates the latest selector change. `E` now walks `itemGrabSearchCandidates` in source order and queues the first candidate with an eligible `use` event; it does not select the nearest eligible item. This remains host-side selection, not the original `Item_Grab`/`Usecode_ItemCallEvent` dispatch.
|
||||
|
||||
The immediate target is a fresh game on retail map 1 at the original starting teleporter, with an avatar owned by the ported item/NPC runtime, a tick and input path that actually drive that avatar, a changing world image, and at least one original-script-backed interaction. The current host-controlled sprite over a frozen map does **not** count. Keep the diagnostic traversal view separate while replacing its behavior; no DOSBox parity gate is required for this Windows milestone.
|
||||
The immediate target is a fresh game on retail map 1 at the original starting teleporter, with an avatar owned by the ported item/NPC runtime, a tick and input path that actually drive that avatar, a changing world image, and at least one original-script-backed interaction. The current host item/process movement and live-item rendering are useful verified steps, but do **not** count as the original loop or interaction. Keep the diagnostic traversal view separate while replacing its behavior; no DOSBox parity gate is required for this Windows milestone.
|
||||
|
||||
1. **Startup and spawn:** port the fresh-game branch of `Game_Start` (`1020:0000`) through `Teleporter_CreateProcessDirect(1, 0x1e, 1)` and its placement callee. Resolve egg `0x1e` from original map data, not from the map bounds, and prove its coordinates and the spawned avatar/item ID in a retail-data test. Do not implement intro movies, main menu, save loading, or warp overrides for this slice.
|
||||
2. **Live world ownership:** initialize the original item cache and NPC/avatar state for that map. The displayed avatar must be the same numbered, mutable item advanced by the process runtime; reject a separately drawn or separately positioned stand-in.
|
||||
|
|
@ -28,13 +26,7 @@ The immediate target is a fresh game on retail map 1 at the original starting te
|
|||
5. **Real interaction:** implement one reachable map-1 usecode event through the original item find/grab, VM dispatch, and resulting world-state mutation. Demonstrate a repeatable before/input/after trace and visible effect; a script lookup or release-request counter is not an interaction.
|
||||
6. **Acceptance:** launch the normal Windows executable with retail data, start map 1 at egg `0x1e`, move and interact without a diagnostic shortcut, and verify on-screen state plus a deterministic integration test. Keep absent combat, audio, menus, persistence, and broader missions listed as limitations, not silently simulated features.
|
||||
|
||||
Progress: the map-1 fixed-map test identifies one family-8/frame-1 item with low quality byte `0x1e` (the teleporter's item-search predicate); startup centers on that egg instead of the map-bounds midpoint. The live item owner reserves avatar item `1` with defaults from `NPC_Init` (`10e8:000c`) and applies the coordinate/map write from `NPC_Teleport` (`10e8:29f2`). Win32 directional events now pass through the kernel keyboard queue to a registered controller entry; an owned `AnimPrimitiveProcess` advances the avatar item on 40 Hz host ticks. A cached map renderer redraws snapshots of mutable map items in source sorter order on a worker thread, while the avatar pose is still drawn in a separate screen overlay. Fast-area GLOB eggs now hatch into numbered live children using the `1098:039c` placement/status rules; the renderer replaces a hatched egg's preview expansion with those items. The interpreter's initial stack and 31-entry code-address stack are compiled and tested against exported `1418:00e8/0244/0000`; the host VM executes a tested opcode subset and task lifecycle. Retail-data tests execute `CARD_NS` spawning `SWITCH` and the `BOX_NS` timer chain through a changed live item frame and rendered scene. The Windows host queues a selected retail release-event body from the item-process callback and reports its task state, but this remains diagnostic: `F` host-selects the nearby item, the original `Item_Grab`/`Usecode_ItemCallEvent` dispatch is not ported, and `E` starts a nearest eligible use event through host selection. The task bytecode offset is now named `usecodeEventBytecodeOffset` (`0x0e`) and verified against raw `CARD_NS`, `BOX_NS`, and `RECHFLNS` bodies: each has a 14-byte prefix followed by opcode `0x0b`; Ghidra shows the selected event chunk pointer is passed with intra-chunk offset zero. The prefix field meanings remain untyped. These are partial translations of steps 1-5, **not completed milestones**: `Game_Start` (`1020:0000`), teleporter scheduling, complete item cache, controller actions beyond directional movement, original camera/draw-list integration, and original USECODE event dispatch remain open. Collision is approximate; no normal-input, end-to-end interaction acceptance exists. Steps 5-6 remain open.
|
||||
|
||||
Retail map-1 probing at the starting egg found four children after fast-area GLOB hatching and no eligible `use` script on those children; no direct fixed-map item within 1,024 staged units has an eligible event body. The nearest direct `use` items are panel/card objects roughly 8,800 staged units away. Their event bodies delegate to `TRIGGER.slot_20` or `SWITCH.slot_21`, which require additional VM, timer, selector, and world-state services. A renderer regression confirms that moving hatched children changes live scene pixels, but this is not script execution or proof that those distant interactions are reachable through the current collision path.
|
||||
|
||||
Control-path evidence for step 3: live `CRUSADER.EXE` disassembly at `1130:224b-226a` compares event selectors against the five words at `1130:273b` (`1, 2, 4, 0x10, 0x100`); the matching CS jump-table words at `1130:274f` target `226e, 2276, 22b6, 22bd, 22b6`. The gameplay-key case at `1130:22bd` copies all 12 bytes of the incoming key event. The exported `Controller_HandleKeyEvent` pseudo-C contains an invalid branch after this table and must not be compiled verbatim. The 32-slot, 12-byte pending-key ring (`11d0:3533/3ad4/3a74/3aad`) and a registered-subscriber dispatch (`11d0:3c4d`) are ported in `ProcessKernel`; tests cover order, full/overflow, wrap, and delivery to a controller entry rather than the excluded keyboard process. The 0x40-byte controller entry mirrors the keyboard registration and daemon/update flags of `ControllerProcess_CreateProcess` (`1130:00e3`), **but the window does not create it or feed its queue**. `Controller_PickNextAnimByKeyevent` (`1130:12d6`) reads two keyboard state arrays through `Keyboard_GetKeyState` (`11d0:39b9`, DS offsets `3652` and `3352`) and selects animation through NPC state and services. `Kernel_11d0_39fb` installs the DOS interrupt-9 keyboard path through `FUN_1218_059b`; exported C exposes the arrays' reads/resets but not their hardware writer. Recover the key-state update semantics from the interrupt path and port the controller's reachable movement branches before replacing host polling; do not guess their edge/held meaning.
|
||||
|
||||
Animation dependency for step 3: live disassembly at `1130:1eda-1ef0` supplies `NPC_DoAnim` (`10e8:0252`) with the controlled NPC item pointer, animation number, direction, and two zero arguments that the exported controller pseudo-C omits. The unarmed walk/run cases allocate `AnimPrimitiveProcess` (`1150:0000`, size `0x5b`); live disassembly at `1150:0033-009c` confirms its normal vtable offset `0x2a57`, event type `0xf0`, and linear-capable setup. A kernel-owned constructor with this layout, item/type registration, direction, and clip metadata now has a byte-level test. `AnimPrimitive_SetStartFrame` (`1150:17b2`) is ported and tested for two-step/looping and controlled-avatar frame-skip branches. Its tick (`1150:1906`) still needs NPC animation-frame state, fast-area/collision behavior, item updates, transitions, and teardown. The Windows host frame counter is not this process. Finish the tick and collision result before swapping the default control path.
|
||||
Current blocker: the normal host window resolves egg `0x1e` from map 1 and places host item 1 at that retail record, then routes queued input through host controller and animation processes that mutate the same live item. These are tested host models, not calls through `Game_Start`, `Teleporter_CreateProcessDirect`, or the original kernel loop. A test using the production-equivalent item search at the egg spawn found one candidate and no eligible `use` event. The BOX_NS effect test therefore still uses a fixture origin; a reachable target and original item/event dispatch remain open. Nearby panel/card scripts also require additional VM, timer, selector, and world-state services.
|
||||
|
||||
## Current Inputs
|
||||
|
||||
|
|
@ -43,62 +35,9 @@ Animation dependency for step 3: live disassembly at `1130:1eda-1ef0` supplies `
|
|||
- `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
|
||||
## Rebuild 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 and `11d0:0445/19b5` post-scan group selection, `Process_Sleep`/`Unlink`, the 0x42-byte Stand constructor fields, `StandProcess::Run` (`1100:0359`), a kernel-owned SystemTimer constructor/counter (`11c0:0000/00f8`), and partial Keyboard/KeyDaemon registration. The harness executes the NPC decision tree through host services and delivers timer events explicitly; real NPC data, timer interrupts/rescheduling, original keyboard queue/player input, 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, one-pass scheduler scan and post-scan active-group selection, owned Stand process layout, and recovered Stand `Run`/NPC decision and timer-counter branches. It does not have the original NPC service data, DOS timer delivery, keyboard event queue, or game loop.
|
||||
`rebuild/remorse/` contains the MSVC/CMake build, retail-data readers, diagnostic map/window, partial process/item/USECODE runtime, and focused tests. These are host infrastructure and partial source ports, not a playable game; subsystem documents retain detailed implementation evidence.
|
||||
|
||||
## Why The Export Does Not Compile Yet
|
||||
|
||||
|
|
@ -130,63 +69,6 @@ It can replace DOS extender, VGA, sound, input, timing, file, and memory service
|
|||
|
||||
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.
|
||||
|
||||
|
|
@ -298,25 +180,12 @@ Work:
|
|||
|
||||
Exit criteria: a clean checkout/build can run against a retail data directory with documented setup steps.
|
||||
|
||||
## Current Execution Focus
|
||||
## Historical Implementation Evidence
|
||||
|
||||
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. Kernel-owned source/type transitions and active-group increment now have focused coverage, but the static source/type setters still lack item-cache context; runtime binary parity is not established.
|
||||
|
||||
### Process Source-Port Ledger
|
||||
Partial process and item ports below are retained as technical evidence, not as the active work order. Follow **Near-Term Next Actions** for current priorities.
|
||||
|
||||
| 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. |
|
||||
| `IncrementGroupId@11e0_0405.c` | Group increment, current-active-group assertion, and 29-to-30 rejection translated; harness and CTest invoke it | Live `11e0:040b-0466` masks the group byte to five bits, checks next group `< 30` and `DS:39c9 == old group`, then calls `SetGroupId` and `Kernel_11d0_19b5`. The host passes the owning kernel and group counts explicitly; assertions become exceptions, without a DOS runtime trace. |
|
||||
| `SetSourceType@11e0_01b6.c`, `SetEventTypeChecked@11e0_0227.c` | Kernel-owned item source and event-type transitions compiled and exercised by the item-process constructor, CTest reassignment/teardown | Source change stamps `+0x04`, marks the new item's presence bit, refreshes the old bit by searching unterminated processes from slot 3, and moves the type bit when `+0x06` is `0xf0..0xf7`. Type change stamps `+0x06`, sets the new type bit and refreshes the old type; values above `0x0fff` assert after the write. Per-item presence bits (`DS:3a04`) and per-item process-type bytes (`DS:3a08`) are separate host-owned tables. Static setters without kernel context remain partial; other item-cache mutations and binary parity are unverified. |
|
||||
| `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. |
|
||||
| `Kernel_11d0_19b5` (`11d0:19b5`), `Kernel_11d0_0445` (`11d0:0445`) | Active-group writer and empty-group highest-ordinary-group selection translated; invoked after diagnostic scans in harness/window, CTest checks change flag and groups 30/31 exclusion | Exported globals initialize active group `DS:39c9` to 1 and pending byte `DS:39a2` to 0. Writer marks pending only when group changes; selector scans all occupied process slots (including terminated entries until cleanup), ignores groups 30/31 for the maximum, then clears pending. Host rejects invalid group IDs and uses explicit group counters; original group-table allocation, mid-scan early stop, and runtime traces remain unported. |
|
||||
| `Item_CreateProcess` (`10a0:0020`), `ItemProcess_Run` (`10a0:0078`), `Item_Release` (`10a0:2a06`) | Owned 0x32-byte item process constructed and advanced by the scheduler from a staged retail map record; release request, event-body queueing, task state, termination, and presence cleanup are exercised by the diagnostic host | Live disassembly confirms function-table root `0x102f`, item number at `+0x04`, event type `0xf1` at `+0x06`, then `Item_Release` followed unconditionally by the vtable terminate slot. The host callback receives mask `0x200` and `UC_Release` ordinal `9`, resolves an eligible retail body, and queues it in the host VM task registry. Only supported opcodes/services execute; unsupported paths halt the task. This remains a diagnostic trigger, not the original `Item_Grab` path; child teardown and general vtable dispatch remain unported. |
|
||||
|
|
@ -356,18 +225,6 @@ Live Ghidra decompilation shows that vertical `GravityProcess_Run` impacts use s
|
|||
|
||||
The standalone `AreaSearch_SweepTestPt` bounds stage (`10e0:0b39`) clamps X/Y to `0..0x7fff` and Z to `0..0xfa`, reports failed-direction bits `1/2/4`, and distinguishes a horizontal hard failure from Z clamping. The source's `World_MapBlockInFastArea` (`10a8:0000`) rotated block predicate and eight-corner start/destination footprint gate are testable with an explicit fast-area range. `World_CalcFastAreaLimits` (`10a8:0048`) now supplies the source sum ±5 / difference ±3 block window from a world center. The window refreshes a player-centered host range after movement and dispatches any owned gravity processes through its timed scheduler; it still does not create gravity entries or repaint moved map items in the static preview. The sweep's item-iterator rectangle and live candidate query follow inclusive X/Y filtering and Y-then-X block order. The per-item sweep uses 16-unit X/Y extents, 8-unit Z extents with the source zero-height fallback, and six axis-face tests that report one-unit-before-contact points and failed-direction bits. A read-only live collector combines those tests with candidate order, shape solidity and flip flags. The host selects a solid hit in source order when any axis is strictly closer, retains the earlier hit on a tie, and accumulates direction bits across contacts. Damaging-only face contacts are recorded in candidate order without blocking the resolved point. With an explicitly enabled floor-gap limit, the host also identifies the closest solid support beneath the destination footprint for source limits 0 and 9; this support metadata does not change the destination. The resolved sweep now reports fast-area failure at the original point with direction bits 1/2 and clamps out-of-range Z with bit 4; the gravity runner conservatively rejects these unsupported responses before mutation. `runResolvedGravity` moves an owned item to a solid-hit point after its strict process wake, damps and reverses horizontal speed on collision, and sleeps the process again. `scanResolvedGravity` dispatches this bounded runner through the host scheduler; tests verify a wall impact, a later move away, and no repeat within the same tick. The remaining gaps are vertical collision response, item status/cache writes, collision events, stationary fall search, and an actual window gravity producer and moving-item renderer. Original runtime parity remains unverified.
|
||||
|
||||
Original DOS debugging and runtime verification are postponed indefinitely until requested again. The DOSBox-X debugger session has been stopped; do not treat a live trace as a prerequisite for the source-port work below. Keep unverified parity claims labeled as such.
|
||||
|
||||
Next source-port checks, in call-chain order:
|
||||
|
||||
1. Keep the `0x23ff/0x2400` process item boundary until source-derived allocation limits support changing it; do not infer a wider live table from staged map IDs.
|
||||
2. Keep the original scheduler wait behind a host timing boundary. `11d0:04cd/0575` reallocates and copies three segmented process tables; defer a direct port until the host's vector-backed slot/capacity semantics are explicitly modeled. Post-scan active-group selection is now statically translated, with runtime parity explicitly deferred.
|
||||
3. Verify and extend the host free-ID/container slice against live runtime traces; synthetic tests now cover family-7 contained-record staging and family-6 runtime insertion, but item-cache status/fast-area effects and the `Item_PopToEnd` runtime append path remain unverified.
|
||||
4. Port an explicit item-status model before implementing vertical gravity responses; bounds and fast-area failures are explicit but conservatively rejected, and live gravity branches also require controlled-NPC identity and random-response behavior.
|
||||
5. Extend scheduled gravity with item status/cache writes and collision events; add a real window gravity producer and dynamic item renderer before claiming visible gameplay movement.
|
||||
6. Connect the approved-move `Item_Grab` path to a ported `Item_LegalMoveToPointWithCollisionInfo` sweep and item-cache lifecycle, without changing the separate Windows `F` release fixture.
|
||||
7. Lift `EntityVmContext::CreateFromSlotIndex` (`1420:0eec`) and the `Inter_1418_0244` interpreter/context layout, replacing host task setup with the original event-frame and parameter semantics; extend opcode/intrinsic coverage before claiming event parity.
|
||||
|
||||
## 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.
|
||||
|
|
@ -645,77 +502,22 @@ python rebuild/remorse/tools/import_export_slice.py classes/Remorse/EntityDispat
|
|||
|
||||
## 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.
|
||||
- **Build foundation:** `remorse_core`, the Windows game, MSVC/CMake build entry point, and focused CTest targets are in place.
|
||||
- **Retail data:** loaders cover the resources used by the current map, rendering, item, and USECODE slices. The preview renderer and Win32 window remain diagnostic infrastructure.
|
||||
- **Process and world state:** partial scheduler/process behavior, staged item placement/search, and selected item-cache operations are compiled and tested. The host does not yet run the original game loop or item runtime.
|
||||
- **Teleporter startup slice:** live Ghidra evidence confirms `TeleporterProcess` is `0x36` bytes, with vtable `0x0f3a`, target map at `+0x32`, and egg ID at `+0x34`. The host kernel owns this typed process and models its same-map run by resolving a family-8/frame-1 destination whose quality low byte matches the requested ID, then moving item 1. Map loading now creates, runs, and retires this process using a local kernel. It does not port `Game_Start`, temporary-stasis wait, cross-map camera/NPC setup, collision/fall, sound, or original scheduler dispatch.
|
||||
- **USECODE:** class/event parsing, a tested opcode subset, task lifecycle, and bounded `CreateFromSlotIndex` context construction are implemented. The window's use request now searches nearby item candidates, applies owner-row event selection, creates a context-backed task, and mirrors the context bytes into the process entry. A retail `BOX_NS` regression follows candidate search through context ownership and VM execution, checks six frame transitions and a rendered pixel change, then verifies output-pointer and allocation cleanup. This remains host-side dispatch with fixture-provided VM services, not original dispatcher parity or a verified interaction from the map-1 spawn.
|
||||
- **Runtime chunks:** the host now models the 0x16-byte `UProcess_1420_0000` record, bounded far-memory allocations for chunk/process buffers, the doubly linked loaded-process list, descriptor-pointer replacement/restoration, and zero-count eviction. Retail `EVENT` and `NPCTRIG` plus a two-node fixture cover load, reuse, release, reload, and unlink behavior. The host materializer reads archive-backed class bytes; parity with the original owner-resource callback and allocator remains unverified.
|
||||
|
||||
## What Is Left To Do
|
||||
## Later Scope
|
||||
|
||||
- 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.
|
||||
After the first source-backed interaction, complete the original player/item loop, save/load, combat, mission flow, audio, frontend, and retail-map coverage. Keep the current preview and window as test hosts until recovered runtime behavior replaces their stand-ins.
|
||||
|
||||
## Near-Term Next Actions
|
||||
|
||||
1. Verify the live `Process` group-table allocation/initialization and compare the compiled active-group writer/selector (`11d0:19b5/0445`) and `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; compare the staged map-item/ItemProcess IDs and Stand's 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. Complete runtime chunk materialization before context dispatch: extend the tested archive-backed `UsecodeSlotChunkCache` through `InitSlotOwnerBuffers`/`EnsureSlotChunkLoaded` (`1420:1866/19fd`), port the `0x16`-byte `UProcess_1420_0000` allocation and owner-helper materialization, then model loaded-list ownership, far-pointer restoration, release, and eviction. After that, map runtime-owned code into host VM memory, lift `CreateFromSlotIndex`/`Inter_1418_0244`, and execute a selected retail event with verified item/process side effects before connecting it to the window. Continue through original item/draw-list output, save/load, audio, and frontend chains for playable mission progression.
|
||||
1. **Close the event path:** identify an eligible retail `use` target reachable from the original map-1 spawn. The exact production-equivalent search at egg `0x1e` currently returns one candidate and no eligible event. Then exercise movement to a real target, owner selection, context creation, and VM execution through supported runtime services, verifying a process/world-state effect. The BOX_NS regression verifies candidate-driven selection and visible frame output from a fixture origin only; it does not close this action or establish `Usecode_ItemCallEvent` parity.
|
||||
2. **Integrate the map-1 loop:** port `Game_Start` (`1020:0000`) and the teleporter constructor/run lifecycle rather than host initialization; add the stasis wait, original target-map transition and item search, collision/fall, then move input and animation onto the recovered kernel loop. The current tests cover same-map egg resolution, shared item-1 mutation, and host input/scheduler behavior, not those binary lifecycle semantics or source draw-order/camera parity. Keep the normal window on the original path before calling the vertical slice accepted.
|
||||
|
||||
## Current Bottom Line
|
||||
Runtime-cache progress correction: the host now models the extra-slot header, descriptor/state buffers, ensure/release counts, and archive-backed zero-count unload/reload. It still lacks `UProcess_1420_0000` allocation, owner-helper materialization, loaded-list ownership, and runtime far-pointer restoration; complete those prerequisites before far-address integration and the numbered context-dispatch action above.
|
||||
|
||||
The project has a buildable diagnostic host, retail resource loaders, partial original scheduler scan, and owned Stand and item-process entries. The Windows diagnostic registry runs an item process bound to a staged retail map record, queues an eligible release body into the subset VM, and runs a Stand entry under the host tick. Retail tests demonstrate script-driven item-frame mutation. The `E` selector now iterates bounded, source-order candidates from `itemGrabSearchCandidates` (the modeled `Item_Grab` query) and queues the first candidate with an eligible `use` body, replacing its earlier nearest-distance choice. This is source-derived candidate selection, not original interaction dispatch: the window still constructs the item identity and queues the event body directly, and no visible before/input/after interaction is proven. The partial `CreateFromSlotIndex` slice writes the verified slot index (`+0x32`), value offset (`+0x34`), owner-source far pointer (`+0x11b`), mode byte (`+0x121`), and cleared parameter/active fields (`+0x11f/+0x122`) into the allocated 0x124-byte context. The VM bootstrap now copies the item parameter only for nonzero mode flags, then optional context bytes, reserves the four-byte saved-stack-pointer slot, and records the context-relative parameter offset; focused tests cover the ordering and zero-mode case. Real segment:offset pointer mapping, runtime code/owner-resource addresses, and embedded interpreter-context execution remain unported. `F` remains a separate release diagnostic. The original item cache/block IDs, full `Item_Grab`/`Usecode_ItemCallEvent`/`CreateFromSlotIndex` chain, real NPC ownership/services, nonempty-child teardown, DOS timer/keyboard interrupts, full scheduler, original startup/player chain, and renderer integration remain open. This is not a playable-game milestone; the next measure is mapping far addresses into the host VM and using them to execute one selected retail event through original context dispatch.
|
||||
The host now materializes archive-backed USECODE chunks and builds tested 0x124-byte contexts with bounded source pointers and an initialized 0x82-byte call stack. Its window routes use-request candidates through owner-row selection into a context-backed task; the BOX_NS regression verifies VM-driven frame changes, rendered output, and cleanup, while a separate retail test confirms no eligible event at the original spawn. Retail egg selection and placement of item 1 are covered, the typed `TeleporterProcess` performs its tested same-map egg move, and a deterministic host input/tick test verifies that the item-owned animation process moves item 1. Original `Game_Start`, the full teleporter lifecycle, `Usecode_ItemCallEvent`/context-dispatch, owner-resource callback parity, a reachable retail interaction, and original loop/render parity remain incomplete. Whole-game and playable-game acceptance remain unmet.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue