commit 89735fc46f91ef563b0f39c64d064d5b883a3c85
parent 078a0f6072df190a447e1b5e189f4deb755f5a6c
Author: anon <anon@example.com>
Date: Fri, 23 Oct 2026 17:47:00 +0000
Test original native input frame dispatch
Diffstat:
5 files changed, 260 insertions(+), 8 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -621,8 +621,13 @@ and server restarts. Turn every reproduced bug into a focused regression test.
online ability edit/reconnect in a focused run. Rapid multi-cell bursts can
act on the final cell or emit no equipment request. A cursor-only adapter
experiment passed its fixture but failed the full-game reproduction and was
- removed. Trace native InputInfo consumption and GUI hit testing before fixing
- this; include a real-game regression. See the
+ removed. Native input tracing and a regression now establish that the original
+ two-pass frame engine preprocesses all points before executing commands;
+ commands requesting the current hotspot reference see its final shared value,
+ even with distinct captured coordinates. Ordinary boots equip/remove
+ and a repeated cycle pass in the unchanged WASM game. Separate this original
+ behavior from new focus/reconnect defects; require a real-game reproduction
+ before changing input behavior. See the
[audit evidence and remaining checks](docs/native-equipment-input.md).
Captures: `local/armor-quality-smoke/` and `local/rapid-input-smoke/`.
- [ ] Audit item creation, assignment, movement and deletion. Cover exact
diff --git a/client/Makefile.linux b/client/Makefile.linux
@@ -169,6 +169,7 @@ build/linux/window: tests/window.c data/Clientr_exe.c runtime/linux_window.c run
test: build/linux/window build/linux/graphics build/linux/atoi build/linux/stricmp build/linux/stdio-input build/linux/guest-stat build/linux/chmod build/linux/create-directory build/linux/dynamic-imports build/linux/linecrypt build/linux/guest-heap build/linux/guest-crt build/linux/linux-platform build/linux/msvcp-strings build/linux/ace-token build/linux/msvcp-stdio-data build/linux/guest-eh build/linux/guest-rand build/linux/semaphore build/linux/guest-scanf build/linux/network-startup build/linux/os-version build/linux/guest-format build/linux/event build/linux/tls build/linux/module-filename build/linux/delete-file build/linux/guest-stdio build/linux/guest-exception build/linux/platform-diagnostics build/linux/new-handler
./build/linux/linecrypt
./build/linux/guest-heap
+ ./build/linux/native-input
./build/linux/guest-crt
./build/linux/getenv
./build/linux/linux-platform
@@ -639,3 +640,9 @@ build/linux/inflate-fast build/linux/inflate-fast-paged: tests/inflate_fast.c ga
$(CC) $(CPPFLAGS) $(CFLAGS) $(if $(filter %-paged,$@),-U__linux__) -ffunction-sections -fdata-sections $(filter %.c,$^) -Wl,--gc-sections -pthread -lm -o $@
test: build/linux/inflate-fast build/linux/inflate-fast-paged
+
+build/linux/native-input: tests/native_input.c game/ccr.dll/lifted-0000.c game/ccr.dll/lifted-0001.c data/ccr_dll.c runtime/guest_memory.c runtime/recomp_state.c runtime/recomp_types.h runtime/guest_memory.h
+ @mkdir -p $(@D)
+ $(CC) $(CPPFLAGS) $(CFLAGS) -ffunction-sections -fdata-sections $(filter %.c,$^) -Wl,--gc-sections -lm -o $@
+
+test: build/linux/native-input
diff --git a/client/Makefile.wasm b/client/Makefile.wasm
@@ -153,6 +153,10 @@ build/wasm/ground-height.js: tests/ground_height.c game/bbr.dll/lifted-0013.c ru
@mkdir -p $(@D)
$(CC) $(CPPFLAGS) $(CFLAGS) -ffunction-sections -fdata-sections $(filter %.c,$^) -Wl,--gc-sections -lm -o $@
+build/wasm/native-input.js: tests/native_input.c game/ccr.dll/lifted-0000.c game/ccr.dll/lifted-0001.c data/ccr_dll.c runtime/guest_memory.c runtime/recomp_state.c runtime/recomp_types.h runtime/guest_memory.h
+ @mkdir -p $(@D)
+ $(CC) $(CPPFLAGS) $(CFLAGS) -ffunction-sections -fdata-sections $(filter %.c,$^) -Wl,--gc-sections -lm -o $@
+
build/wasm/web/capture-test.html: tests/browser_capture.html build/wasm/web/capture-test.js
cp $< $@
diff --git a/client/tests/native_input.c b/client/tests/native_input.c
@@ -0,0 +1,194 @@
+#include "recomp_types.h"
+#include <assert.h>
+
+void game_data_ccr_dll(void);
+void sub_27003930(void);
+void sub_27003C60(void);
+void sub_27003E70(void);
+void sub_27003ED0(void);
+void sub_27003F00(void);
+void sub_270040C0(void);
+void sub_27004370(void);
+void sub_270046E0(void);
+void sub_270047F0(void);
+void sub_27004EA0(void);
+void sub_27004EF0(void);
+void sub_270051A0(void);
+void sub_27005500(void);
+void sub_27005540(void);
+
+static unsigned hotspot_count, command_count;
+static uint32_t hotspot_points[8], command_references[8];
+
+/* ccr.dll::InputConfig_t runs FramePreProcess before FrameProcess/ProcessInput. */
+/* Scene hit testing and command execution are outside the input-frame contract. */
+static void check_hotspot(void)
+{
+ /* The controlled scene uses x as its void reference; zero is empty space. */
+ uint32_t x = MEM32(g_esp + 4);
+ assert(hotspot_count < 8);
+ hotspot_points[hotspot_count++] = x;
+ MEM32(0x500000c4) = x;
+ g_esp += 16;
+}
+
+static void execute_command(void)
+{
+ assert(g_ecx == 0x50000900);
+ assert(command_count < 8);
+ command_references[command_count++] = MEM32(g_esp + 12);
+ g_esp += 20;
+}
+
+static void timer_instance(void) { g_eax = 0x50000f00; g_esp += 4; }
+static void hotspot_instance(void) { g_eax = 0x50000e00; g_esp += 4; }
+static void no_display(void) { g_eax = 0; g_esp += 4; }
+static void no_camera(void) { g_esp += 4; }
+static void no_modifiers(void) { g_eax = 0; g_esp += 8; }
+recomp_func_t recomp_lookup_manual(uint32_t address) { return NULL; }
+recomp_func_t recomp_lookup_import(uint32_t address) { abort(); }
+recomp_func_t recomp_lookup(uint32_t address)
+{
+ switch (address) {
+ case 0x27003930: return sub_27003930;
+ case 0x27003E70: return sub_27003E70;
+ case 0x27003ED0: return sub_27003ED0;
+ case 0x27004370: return sub_27004370;
+ case 0x270046E0: return sub_270046E0;
+ case 0x270047F0: return sub_270047F0;
+ case 0x27004EA0: return sub_27004EA0;
+ case 0x27004EF0: return sub_27004EF0;
+ case 0x270051A0: return sub_270051A0;
+ case 0x27005500: return sub_27005500;
+ case 0x27005540: return sub_27005540;
+ case 0x27001570: return execute_command;
+ case 0x270029e0: return hotspot_instance;
+ case 0x27010770: return check_hotspot;
+ case 0x270041f0: return no_camera;
+ case 0x11110000: return timer_instance;
+ case 0x11110004: return no_display;
+ case 0x11110008: return no_modifiers;
+ default: fprintf(stderr, "unexpected input call: %08x\n", address); abort();
+ }
+}
+
+static void initialize_input(void)
+{
+ memset((void *)ADDR(0x50000000), 0, 0x1000);
+ g_esp = 0x5000ff00;
+ hotspot_count = command_count = 0;
+
+ /* Reserve input-vector capacity so AddUserInput never needs an allocator. */
+ MEM32(0x500000dc) = 0x50000400;
+ MEM32(0x50000404) = MEM32(0x50000408) = 0x50000600;
+ MEM32(0x5000040c) = 0x50000680;
+
+ /* Keep press/release events below the native mouse-hold threshold. */
+ MEMF(0x50000014) = 0.3f;
+ MEMF(0x50000138) = MEMF(0x5000013c) = MEMF(0x50000140) = 10;
+ MEM32(0x50000f14) = 0x50000f80;
+ MEMF(0x50000f80) = 0.016f;
+
+ /* Two commands consume the current hotspot reference on right press/release. */
+ MEM32(0x50000010) = 0x50000420;
+ MEM32(0x50000424) = 0x50000440;
+ MEM32(0x50000428) = 2;
+ MEM32(0x50000440) = 0x50000460;
+ MEM32(0x50000460) = 0x50000480;
+ MEM32(0x50000468) = 0x50000500;
+ MEM32(0x50000480) = 0x50000440;
+ MEM32(0x50000488) = 0x50000540;
+ MEM32(0x50000508) = 5;
+ MEM32(0x50000548) = 8;
+ MEM32(0x5000050c) = MEM32(0x5000054c) = 4;
+ MEM32(0x50000510) = MEM32(0x50000550) = 0x50000900;
+}
+
+static void queue_input(uint32_t action, uint32_t x)
+{
+ MEM32(0x50000800) = action;
+ MEM32(0x50000804) = action != 0;
+ MEM32(0x50000808) = x;
+ MEM32(0x5000080c) = 20;
+ g_ecx = 0x50000000;
+ MEM32(g_esp + 4) = 0x50000800;
+ sub_27003C60();
+ assert(g_esp == 0x5000ff08);
+ g_esp -= 8;
+}
+
+static void process_frame(void)
+{
+ g_ecx = 0x50000000;
+ sub_27003F00();
+ assert(g_esp == 0x5000ff04);
+ g_esp -= 4;
+ g_ecx = 0x50000000;
+ sub_270040C0();
+ assert(g_esp == 0x5000ff04);
+ g_esp -= 4;
+ assert(MEM32(0x50000408) == 0x50000600);
+}
+
+static void clicks_in_separate_frames_use_their_own_hotspots(void)
+{
+ initialize_input();
+ queue_input(5, 100);
+ queue_input(8, 100);
+
+ process_frame();
+ queue_input(5, 200);
+ queue_input(8, 200);
+ process_frame();
+
+ assert(hotspot_count == 4 && command_count == 4);
+ assert(command_references[0] == 100 && command_references[1] == 100);
+ assert(command_references[2] == 200 && command_references[3] == 200);
+}
+
+static void clicks_in_one_frame_use_the_final_hotspot(void)
+{
+ initialize_input();
+ queue_input(5, 100);
+ queue_input(8, 100);
+ queue_input(5, 200);
+ queue_input(8, 200);
+
+ process_frame();
+
+ assert(hotspot_count == 4 && command_count == 4);
+ assert(hotspot_points[0] == 100 && hotspot_points[1] == 100);
+ assert(hotspot_points[2] == 200 && hotspot_points[3] == 200);
+ assert(command_references[0] == 200 && command_references[1] == 200);
+ assert(command_references[2] == 200 && command_references[3] == 200);
+}
+
+static void later_empty_click_is_visible_to_earlier_click_commands(void)
+{
+ initialize_input();
+ queue_input(5, 100);
+ queue_input(8, 100);
+ queue_input(5, 0);
+ queue_input(8, 0);
+
+ process_frame();
+
+ assert(hotspot_count == 4 && command_count == 4);
+ assert(hotspot_points[0] == 100 && hotspot_points[1] == 100);
+ assert(hotspot_points[2] == 0 && hotspot_points[3] == 0);
+ assert(command_references[0] == 0 && command_references[1] == 0);
+ assert(command_references[2] == 0 && command_references[3] == 0);
+}
+
+int main(void)
+{
+ assert(guest_map("native input fixture", 0x50000000, 0x10000));
+ game_data_ccr_dll();
+ MEM32(0x270291e4) = 0x11110000;
+ MEM32(0x27029274) = 0x11110004;
+ MEM32(0x27029158) = 0x11110008;
+ clicks_in_separate_frames_use_their_own_hotspots();
+ clicks_in_one_frame_use_the_final_hotspot();
+ later_empty_click_is_visible_to_earlier_click_commands();
+ puts("native input: event coordinates, two-pass frame dispatch and shared hotspot references passed");
+}
diff --git a/docs/native-equipment-input.md b/docs/native-equipment-input.md
@@ -25,20 +25,52 @@ the last contained gloves. Only gloves were equipped. A subsequent burst from
the boots cell to an empty cell produced no equipment request. The DOM traces
retain the individual coordinates, button transitions and focus state.
-The missing requests precede server equipment handling. This establishes an
-input reproduction, but does not distinguish the browser adapter from the
-original native input queue, GUI hit testing or frame timing. The original
+The missing requests precede server equipment handling. The original
`Clientr.exe::FUN_28003890` calls `GetCursorPos` when constructing an
-`InputInfo_t` for `InputConfig_t::AddUserInput`; its later consumer still needs
-to be traced. Retained REA evidence:
+`InputInfo_t` for `InputConfig_t::AddUserInput`. Retained REA evidence:
`ev_6fc9a68d1404266df5e15e19d863092352440683ba1c5f42ceaafb4b1c89097c`,
`local/wheel-input-smoke/clientr-input-evidence.json`.
+The original `ccr.dll` input engine then uses two passes:
+
+- `InputConfig_t::AddUserInput` (`0x10003c60`) copies each 16-byte input record,
+ including its coordinates, into the queue.
+- `InputConfig_t::FramePreProcess` (`0x10003f00`) visits all queued records,
+ updating mouse state and checking hotspots for each point. The current point
+ and hotspot reference are shared fields on the input instance.
+- `InputConfig_t::FrameProcess` (`0x100040c0`) subsequently executes the queued
+ inputs through `CheckInput` (`0x100046e0`) and `ProcessInput` (`0x10003930`).
+ A command requesting the current void reference reads the shared field at
+ `this + 0xc4`; there is no saved per-event copy of that command reference.
+
+Consequently, preserving each event's coordinates does not preserve a different
+command reference for each click in the frame. This behavior exists in the
+original input engine, independently of SDL's cursor sampling. The WASM burst
+reproduction is consistent with that engine behavior; it does not establish a
+new server or browser-adapter defect. The complete native gear-command and
+Windows event paths have not been replayed in isolation.
+
+`client/tests/native_input.c` exercises the unmodified lifted `AddUserInput`,
+`FramePreProcess`, `FrameProcess`, `CheckInput` and `ProcessInput` routines.
+Controlled scene hit testing supplies references and a command boundary records
+the received reference; timer, modifier and display services are also fixtures.
+It verifies separate-frame clicks retain their own references, same-frame clicks
+all use the last reference, and a later empty hotspot supplies a null reference
+to earlier commands. Scene-specific equipment commands are outside this
+fixture's coverage.
+The source evidence is retained in `local/rapid-input-smoke/ccr-input-evidence.json`.
+
A cursor-only adapter experiment made a queued Win32-position fixture pass,
but the published full game still lost the rapid boots-to-empty action.
That experiment was removed. Do not treat the fixture as a gameplay fix or
add an arbitrary hover delay as a product workaround.
+The unchanged published WASM client reproduced a boots-to-empty burst with no
+equipment request. The same boots instance then equipped correctly with an
+ordinary click, adding AC 281/246/281/211/42/42/42/42, and returned to inventory
+with zero AC on removal. Repeat equip/remove also passed. These native-game
+checks retain all eight fixture identities and their authored endpoint data.
+
## Repeating the audit
Use the single normal HTTPS preview and owned visitors. Capture the inventory
@@ -46,7 +78,17 @@ before each sequence; identify the actual item instance at each visual cell.
Vary press duration, movement after release, frame rate, focus transitions and
online profile reconnect independently. Compare emitted requests, exact native
instance locations, effective AC and SQLite locations after every sequence.
-Add an end-to-end regression for the eventual fix.
+Distinguish the original same-frame command behavior from a new input defect.
+Add an end-to-end regression before changing an observed deviation.
+
+Run the native contract fixture with:
+
+```sh
+make -C client -f Makefile.linux build/linux/native-input
+./client/build/linux/native-input
+make -C client -f Makefile.wasm build/wasm/native-input.js
+node client/build/wasm/native-input.js
+```
Artifacts are under `local/rapid-input-smoke/` and
`local/armor-quality-smoke/`. The former retains DOM traces, the rejected