Enhance Usecode handling with new structures and caching mechanisms
- Introduced UsecodeSlotOwnerBuffers for managing descriptors and chunk states. - Added UsecodeSlotChunkCache class for efficient loading and unloading of event bodies. - Updated UsecodeClass to include extraSlotCount and adjusted related functions. - Implemented tests for new functionality, ensuring correct behavior of slot management and event loading.
This commit is contained in:
parent
08a907f322
commit
8c23bb02c9
5 changed files with 187 additions and 14 deletions
|
|
@ -55,6 +55,8 @@ Live runtime-helper classification added during the 2026-04-05 MCP-upgrade pass:
|
|||
- obtains the chunk through `UProcess_1420_0000` using the owner-row offset/size, materializes it through the owner-resource helper, and caches the returned far pointer in the slot entry
|
||||
- marks the chunk present through the slot-local state arrays and updates the runtime-wide budget counters
|
||||
- `GetSlotChunkPtrAtOffset` (`1420:1d72`) returns that allocator-produced pointer plus the caller's intra-chunk offset; it does not expose a stable file/archive address
|
||||
- `ReleaseSlotChunkRef` (`1420:1d8d`) decrements a positive chunk-state reference count and asserts on an unretained chunk
|
||||
- `TryUnloadSlotChunk` (`1420:1e17`) unloads only a zero-count chunk, restores its saved source pointer, resets the state to `0xffff`, and removes its loaded-list record
|
||||
- `1420:1f24 entity_vm_runtime_apply_to_matching_owner_rows`
|
||||
- runtime-owned iterator over the owner list, used both for broad cleanup and for filtered slot/category work
|
||||
- `1420:2040 entity_vm_slot_entry_create_or_clear`
|
||||
|
|
@ -137,6 +139,8 @@ The embedded interpreter initializes its stack limit to 199 bytes; the host boot
|
|||
|
||||
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.
|
||||
|
||||
Current caution:
|
||||
|
||||
- context dispatch semantics are still active work, so this object should be modeled around lifecycle and data ownership first, not around final method names for every opcode-facing helper.
|
||||
|
|
|
|||
|
|
@ -17,6 +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.
|
||||
|
||||
|
|
@ -712,8 +713,9 @@ python rebuild/remorse/tools/import_export_slice.py classes/Remorse/EntityDispat
|
|||
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. Port `EnsureSlotChunkLoaded` (`1420:19fd`), its `UProcess_1420_0000` allocation and owner-helper materialization path, and the slot cache's far-pointer ownership. Then extend the host's segment-0 item-memory mapping to that runtime-owned code region, finish `CreateFromSlotIndex`/`Inter_1418_0244` context wiring, and execute one 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.
|
||||
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.
|
||||
|
||||
## 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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue