Refactor entity dispatch entry management and enhance item grab search tests
This commit is contained in:
parent
25f258393f
commit
49a15602b6
6 changed files with 57 additions and 12 deletions
|
|
@ -565,7 +565,7 @@ Use this sequence to move the normal Windows launch path from host-modeled behav
|
|||
| Interaction | [`startNearbyUsecode`](../rebuild/remorse/src/windowed_game_main.cpp#L287) and [`runUsecodeTasks`](../rebuild/remorse/src/windowed_game_main.cpp#L319) perform host candidate selection, context/task setup, and a bounded VM subset. | Item search has source-derived/translated pieces, but original `Item_Grab` (`10a0:2970`), `Usecode_ItemCallEvent` (`1420:0e3a`), and event dispatch are **not integrated end to end**; no verified reachable spawn interaction yet. | Keep archive/resource reads and memory allocation behind host services; execute recovered search, dispatch, and VM behavior in the core. |
|
||||
| Presentation | [`paintWindow`](../rebuild/remorse/src/windowed_game_main.cpp#L884) crops a rendered fixed-map image and composites a separately rendered live-player patch; the renderer refreshes that patch and sometimes rebuilds the full scene. | Retail asset decoding and host sorting are implemented, but the original live draw-list, source order, and camera path are **not ported**; this remains preview-style presentation. | Keep pixel buffers and projection platform-neutral; isolate GDI presentation, then replace static-scene recentering with recovered live rendering. |
|
||||
|
||||
2. **Prove the source-to-build pipeline:** choose a small, already-understood exported function used by the runtime (for example, a process sleep/timer primitive), clean its types, globals, layout, and calling convention, then compile and link that implementation into `remorse_core`. Replace the matching host-authored behavior with this compiled function and test its state changes against the export and Ghidra evidence. The import helper is staging only; do not count a staged export or isolated test as integrated.
|
||||
2. **Prove the source-to-build pipeline (complete for one primitive):** `EntityDispatchEntry::SetGroupId` (`11e0:02a8`) is now a separately compiled `remorse_core` translation unit derived from `exports/src_remorse/functions/classes/Remorse/EntityDispatchEntry/SetGroupId@11e0_02a8.c`. Its corrected host signature receives the entry and 32-element count table explicitly; the existing `EntityDispatchEntry::setGroupId` boundary preserves the host exception for invalid IDs and delegates the verified low-five-bit update/count transitions to the compiled body. `entity_dispatch_entry_tests` passes through initialization, same-group preservation, reassignment, and count updates. This proves one source-to-build integration slice, not general export compatibility or binary runtime parity. Continue with a stateful scheduler primitive whose globals and call path can be represented explicitly; the import helper remains staging only.
|
||||
3. **Restore the original startup and tick path:** port the minimum dependency chain for `Game_Start` (`1020:0000`), teleporter placement/waiting, kernel scheduler, timer, and item/NPC ownership. Route normal startup and simulation through these compiled functions; retain modeled startup and host polling only as diagnostics until parity checks pass.
|
||||
4. **Move player behavior onto that path:** replace host-created avatar/controller state, movement-step policy, and approximate collision with the recovered item, keyboard, controller, animation, and collision call chain. Feed Win32 input and timing into explicit host-service adapters; the game logic must not depend directly on Win32 APIs.
|
||||
5. **Reconnect presentation and interaction:** render the live mutable world through recovered draw-list/order and camera behavior, then complete one reachable map-1 interaction through original item search, event dispatch, VM execution, and a visible world mutation. Keep the static preview as a regression oracle, not the normal gameplay renderer.
|
||||
|
|
@ -574,9 +574,13 @@ Use this sequence to move the normal Windows launch path from host-modeled behav
|
|||
|
||||
## Near-Term Next Actions
|
||||
|
||||
1. **Close the event path:** identify and reach an eligible retail `use` target from the actual level-start pad at `(30328, 29656, 16)`. The exact production-equivalent search at egg `0x1e` still returns one candidate and no eligible event, but that is the intermediate staging point, not the current avatar location; rerun the search from the destination. Map-wide evidence includes the inactive/map-array `PANELNS`, a `CARD_NS` whose authorized state requires keycard 6, and a frame-0 `CHEST_EW` at staged `(1087, 2559, 0)` whose recovered handler attempts a legal shape swap to `0x054b` before animating. The host implements `Item.setShape` (`0x24`), but `FREE.slot_2d`'s family check, `Item.legal_create`, and temporary-item lifecycle are still missing; the chest's collision route is unverified. Next prove reachability and implement only the required recovered services, then exercise owner selection, context creation, VM execution, and a process/world-state effect. The BOX_NS regression still verifies candidate-driven selection and visible frame output from a fixture origin only; it does not close this action or establish `Usecode_ItemCallEvent` parity.
|
||||
1. **Close the event path:** identify and reach an eligible retail `use` target from the actual level-start pad at `(30328, 29656, 16)`. The retail `Item_Grab` search now has a regression at that destination: it returns items `6812, 6811, 6810, 6804, 6786, 6785` in source order, and none has eligible `use` event 1. This replaces the historical staging-point candidate result but does not establish reachability beyond the six-item search area. Map-wide evidence includes the inactive/map-array `PANELNS`, a `CARD_NS` whose authorized state requires keycard 6, and a frame-0 `CHEST_EW` at staged `(1087, 2559, 0)` whose recovered handler attempts a legal shape swap to `0x054b` before animating. The host implements `Item.setShape` (`0x24`), but `FREE.slot_2d`'s family check, `Item.legal_create`, and temporary-item lifecycle are still missing; the chest's collision route is unverified. Next trace candidate searches along a verified movement route from the pad, then implement only the required recovered services and exercise owner selection, context creation, VM execution, and a process/world-state effect. The BOX_NS regression still 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 replace host initialization; the window now models the clear-stasis waiter and both same-map teleports to the level-start pad, but does not implement the original wait lists or call chain. Next port the original target-map transition and item search, collision/fall, then move input and animation onto the recovered kernel loop. The current tests cover egg resolution and host stasis ordering, shared item-1 mutation, and host input/scheduler behavior, not binary lifecycle parity or source draw-order/camera behavior. Keep the normal window on the original path before calling the vertical slice accepted.
|
||||
|
||||
## Current Bottom Line
|
||||
|
||||
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. Retail tests now verify the complete map-1 startup placement from egg `0x1e` through active trigger item 1598/ID `0x63` to destination egg item 6812 at `(30328, 29656, 16)`, with item 1 and persistent runtime processes intact. The normal window has been confirmed at that destination, and the player sprite anchor was aligned with map-object rendering. The no-eligible-event result at egg `0x1e` describes only the former staging point; destination candidates still need to be scanned. A deterministic host input/tick test verifies that the item-owned animation process moves item 1. Original `Game_Start`, full `Process_WaitFor` parity, cross-map 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.
|
||||
### Destination-Pad Interaction Search (2026-10-07)
|
||||
|
||||
The retail `flex_archive_tests` startup path now runs the existing source-derived `Item_Grab` search after the modeled two-hop startup places item 1 at item 6812. It asserts the six search results in source order and runs each through the retail USECODE owner-row/event selector; all six reject `use` event 1. This resolves the roadmap's stale staging-point search question only. No reachable event target, original event dispatcher, or interaction is established.
|
||||
|
||||
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. Retail tests now verify the complete map-1 startup placement from egg `0x1e` through active trigger item 1598/ID `0x63` to destination egg item 6812 at `(30328, 29656, 16)`, with item 1 and persistent runtime processes intact. The normal window has been confirmed at that destination, and the player sprite anchor was aligned with map-object rendering. The no-eligible-event result at egg `0x1e` describes only the former staging point; the destination search now confirms six nearby items and no eligible event. A deterministic host input/tick test verifies that the item-owned animation process moves item 1. Original `Game_Start`, full `Process_WaitFor` parity, cross-map 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.
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ add_library(remorse_core
|
|||
src/map_renderer.cpp
|
||||
src/map_sorter.cpp
|
||||
src/palette.cpp
|
||||
src/ported/entity_dispatch_entry_set_group_id.cpp
|
||||
src/runtime.cpp
|
||||
src/shape_archive.cpp
|
||||
src/type_flags.cpp
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include "remorse/animation_archive.h"
|
||||
#include "remorse/collision.h"
|
||||
#include "remorse/fixed_map.h"
|
||||
#include "ported/entity_dispatch_entry_port.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
|
@ -1230,15 +1231,7 @@ void EntityDispatchEntry::setGroupId(EntityDispatchEntryBase& entry, u8 groupId,
|
|||
if (groupId == 0 || groupId > 31) {
|
||||
throw std::invalid_argument("process group ID must be in 1..31");
|
||||
}
|
||||
const u8 oldGroupId = entry.bytes[groupIdOffset] & 0x1f;
|
||||
if (oldGroupId == groupId) {
|
||||
return;
|
||||
}
|
||||
if (oldGroupId != 0) {
|
||||
--groupCounts[oldGroupId];
|
||||
}
|
||||
entry.bytes[groupIdOffset] = groupId;
|
||||
++groupCounts[groupId];
|
||||
ported::setEntityDispatchEntryGroupId(entry, groupId, groupCounts);
|
||||
}
|
||||
|
||||
void EntityDispatchEntry::incrementGroupId(EntityDispatchEntryBase& entry, ProcessKernel& kernel, u16 (&groupCounts)[32])
|
||||
|
|
|
|||
10
rebuild/remorse/src/ported/entity_dispatch_entry_port.h
Normal file
10
rebuild/remorse/src/ported/entity_dispatch_entry_port.h
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "remorse/entity_dispatch_entry.h"
|
||||
|
||||
namespace remorse::ported {
|
||||
|
||||
void setEntityDispatchEntryGroupId(EntityDispatchEntryBase& entry, u8 groupId,
|
||||
u16 (&groupCounts)[32]);
|
||||
|
||||
} // namespace remorse::ported
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#include "entity_dispatch_entry_port.h"
|
||||
|
||||
namespace remorse::ported {
|
||||
|
||||
void setEntityDispatchEntryGroupId(EntityDispatchEntryBase& entry, u8 groupId,
|
||||
u16 (&groupCounts)[32])
|
||||
{
|
||||
const u8 oldGroupId = entry.bytes[0x08] & 0x1f;
|
||||
if (oldGroupId == 0 || oldGroupId != groupId) {
|
||||
if (oldGroupId != 0) {
|
||||
--groupCounts[oldGroupId];
|
||||
}
|
||||
entry.bytes[0x08] = groupId;
|
||||
++groupCounts[groupId];
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace remorse::ported
|
||||
|
|
@ -360,6 +360,25 @@ int main()
|
|||
integratedStartupKernel.processAt(processIdOf(integratedTimer)) == &integratedTimer->base &&
|
||||
integratedStartupKernel.processAt(processIdOf(integratedKeyboard)) == &integratedKeyboard->base &&
|
||||
integratedStartupKernel.processAt(processIdOf(integratedController)) == &integratedController->base);
|
||||
const auto destinationUseCandidates = remorse::itemGrabSearchCandidates(
|
||||
*integratedAvatar, integratedStartupWorld.mapItems(), *typeFlags);
|
||||
assert(destinationUseCandidates);
|
||||
const std::array<remorse::u16, 6> expectedDestinationCandidates{6812, 6811, 6810, 6804, 6786, 6785};
|
||||
assert(destinationUseCandidates->size() == expectedDestinationCandidates.size());
|
||||
unsigned eligibleDestinationUses = 0;
|
||||
for (std::size_t index = 0; index < destinationUseCandidates->size(); ++index) {
|
||||
const auto& candidate = (*destinationUseCandidates)[index];
|
||||
assert(candidate.itemNumber == expectedDestinationCandidates[index]);
|
||||
const auto* item = integratedStartupWorld.findItem(candidate.itemNumber);
|
||||
assert(item && item->data.shape < typeFlags->size());
|
||||
const auto& shape = (*typeFlags)[item->data.shape];
|
||||
const remorse::UsecodeItemIdentity destinationIdentity{item->itemNumber, item->data.shape,
|
||||
item->data.flags, item->data.quality, shape.family, false};
|
||||
const auto eligible = remorse::selectEligibleUsecodeEvent(*usecode, *retailOwnerRows,
|
||||
destinationIdentity, remorse::UsecodeClassBases{0, 0x800, 0x900}, 0x02, 1);
|
||||
eligibleDestinationUses += eligible.has_value();
|
||||
}
|
||||
assert(eligibleDestinationUses == 0);
|
||||
const auto spawnUseCandidates = remorse::itemGrabSearchCandidates(
|
||||
*spawnedAvatar, spawnSearchWorld.mapItems(), *typeFlags);
|
||||
assert(spawnUseCandidates);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue