commit 6248eb5d9d9e1c27b32a7fff59c69160df83ae03
parent 56d3b32c0f84d2b0e5860e1f56468daa8c7c5383
Author: anon <anon@example.com>
Date: Sat, 17 Oct 2026 12:59:48 +0000
Initialize mesh player control to preserve animation throttling
Diffstat:
4 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/src/Makefile.linux b/src/Makefile.linux
@@ -222,6 +222,7 @@ test: build/linux/window build/linux/graphics build/linux/atoi build/linux/stric
./build/linux/fpu-stack
./build/linux/water-ring
./build/linux/skinning
+ ./build/linux/animation-initialization
./build/linux/vertex-initialization
./build/linux/ground-height
./build/linux/tile-corners
@@ -505,3 +506,9 @@ build/linux/shadow-contact: tests/shadow_contact.c game/kkr.dll/lifted-0081.c ru
$(CC) $(CPPFLAGS) $(CFLAGS) -ffunction-sections -fdata-sections $(filter %.c,$^) -Wl,--gc-sections -pthread -lm -o $@
test: build/linux/shadow-contact
+
+build/linux/animation-initialization: tests/animation_initialization.c game/bbr.dll/lifted-0032.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 -pthread -lm -o $@
+
+test: build/linux/animation-initialization
diff --git a/src/Makefile.wasm b/src/Makefile.wasm
@@ -101,3 +101,7 @@ build/wasm/terrain-tile.js: tests/terrain_tile.c game/llr.dll/lifted-0023.c game
build/wasm/shadow-contact.js: tests/shadow_contact.c game/kkr.dll/lifted-0081.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/animation-initialization.js: tests/animation_initialization.c game/bbr.dll/lifted-0032.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 $@
diff --git a/src/game/bbr.dll/lifted-0032.c b/src/game/bbr.dll/lifted-0032.c
@@ -272,6 +272,8 @@ L_25094C20:
MEM32(esi + 0x78) = eax; /* 0x25094C6F: mov dword ptr [esi + 0x78], eax */
MEM32(esi + 0x7C) = eax; /* 0x25094C72: mov dword ptr [esi + 0x7c], eax */
MEM8(esi + 0x81) = (uint8_t)(LO8(eax)); /* 0x25094C75: mov byte ptr [esi + 0x81], al */
+ /* NPC animation uses distance throttling until explicitly player-controlled. */
+ MEM8(esi + 0x83) = 0;
MEM32(esi) = 0x25155A8Cu; /* 0x25094C7B: mov dword ptr [esi], 0x25155a8c */
RECOMP_ICALL(0x25094D10u); /* 0x25094C81: call 0x25094d10 */ /* not lifted */
RECOMP_FLAGS_IN();
@@ -333,6 +335,8 @@ L_25094CC7:
MEM32(esi + 0x78) = eax; /* 0x25094CE1: mov dword ptr [esi + 0x78], eax */
MEM32(esi + 0x7C) = eax; /* 0x25094CE4: mov dword ptr [esi + 0x7c], eax */
MEM8(esi + 0x81) = (uint8_t)(LO8(eax)); /* 0x25094CE7: mov byte ptr [esi + 0x81], al */
+ /* NPC animation uses distance throttling until explicitly player-controlled. */
+ MEM8(esi + 0x83) = 0;
eax = MEM32(ebp + 0x1C); /* 0x25094CED: mov eax, dword ptr [ebp + 0x1c] */
PUSH32(esp, eax); /* 0x25094CF0: push eax */
ecx = esi; /* 0x25094CF1: mov ecx, esi */
diff --git a/src/tests/animation_initialization.c b/src/tests/animation_initialization.c
@@ -0,0 +1,45 @@
+#include "recomp_types.h"
+#include <assert.h>
+
+void sub_25094C20(void);
+void sub_25094C90(void);
+static unsigned initialized;
+static void initialize_mesh(void)
+{
+ assert(MEM8(g_ecx + 0x83) == 0);
+ ++initialized;
+ 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)
+{
+ assert(address == 0x25094d10);
+ return initialize_mesh;
+}
+
+static void test_new_mesh(recomp_func_t constructor, unsigned arguments)
+{
+ memset((void *)ADDR(0x50000000), 0xa5, 0x100);
+ g_ecx = 0x50000000;
+ g_esp = 0x5000ff00;
+ memset((void *)ADDR(g_esp), 0, 64);
+ g_ebx = 111; g_esi = 222; g_edi = 333; g_ebp = 444;
+ initialized = 0;
+
+ constructor();
+
+ assert(MEM8(0x50000083) == 0);
+ assert(initialized == 1);
+ assert(g_eax == 0x50000000);
+ assert(g_esp == 0x5000ff00 + arguments + 4);
+ assert(g_ebx == 111 && g_esi == 222 && g_edi == 333 && g_ebp == 444);
+}
+
+int main(void)
+{
+ assert(guest_map("animation constructor fixture", 0x50000000, 0x10000));
+ test_new_mesh(sub_25094C20, 24);
+ test_new_mesh(sub_25094C90, 28);
+ puts("animation initialization: both mesh constructors clear player control and preserve guest ABI");
+}