commit 21ff1d8f9213698b5226c1c9768fa9badd10633c
parent d317bbc50ad86cd5c56457e2fe5401853a3847c6
Author: anon <anon@example.com>
Date: Sun, 18 Oct 2026 09:10:02 +0000
Wait for valid skeletons before initializing shadow height
Diffstat:
2 files changed, 110 insertions(+), 1 deletion(-)
diff --git a/src/game/kkr.dll/lifted-0081.c b/src/game/kkr.dll/lifted-0081.c
@@ -4680,6 +4680,18 @@ L_36117305:
ecx = eax; /* 0x36117305: mov ecx, eax */
RECOMP_ICALL(MEM32(0x3616FFE8)); /* 0x36117307: call dword ptr [0x3616ffe8] */
RECOMP_FLAGS_IN();
+ /* RCATMesh_t::GetAttractor (bbr.dll!25112790) returns a placeholder
+ * at (100000, 100000, 100000) for an inactive indexed mesh. Keep the
+ * height uninitialized until the real head attractor is available and
+ * MaybeUpdateSkeleton (bbr.dll!2510F990) can initialize its bone data. */
+ {
+ uint32_t mesh = MEM32(eax + 0x28);
+ if (MEM32(mesh + 0x280) ||
+ (!MEM8(mesh + 0x288) && MEM32(mesh + 0x284) != 0xffffffffu)) {
+ MEM8(esi + 0x39) = 0;
+ goto L_36117C9F;
+ }
+ }
MEM32(ebp + (-0x54)) = eax; /* 0x3611730D: mov dword ptr [ebp - 0x54], eax */
MEM32(ebp + (-0x134)) = 0x3F800000u; /* 0x36117310: mov dword ptr [ebp - 0x134], 0x3f800000 */
MEM32(ebp + (-0x130)) = 0; /* 0x3611731A: mov dword ptr [ebp - 0x130], 0 */
diff --git a/src/tests/shadow_contact.c b/src/tests/shadow_contact.c
@@ -6,10 +6,12 @@ void sub_36117150(void);
enum {
controller = 0x50000000, owner = 0x50001000,
shadow = 0x50004000, playfield = 0x50005000,
- surface = 0x50006000, position = 0x50007000, engine = 0x50008000
+ surface = 0x50006000, position = 0x50007000, engine = 0x50008000,
+ visual = 0x50002000, mesh = 0x50003000, world_matrix = 0x5000c000
};
static unsigned timing_calls, geometry_calls, update_calls, segment_calls;
static unsigned line_calls, sample_calls;
+static unsigned attractor_calls;
static int line_hit;
static float contact_normal_y;
static float first_endpoint[3], updated_direction[3];
@@ -20,6 +22,24 @@ static void find_owner(void) { g_eax = owner; g_esp += 4; }
static void get_playfield(void) { assert(g_ecx == owner); g_eax = playfield; g_esp += 4; }
static void get_surface(void) { assert(g_ecx == playfield); g_eax = surface; g_esp += 4; }
static void get_position(void) { assert(g_ecx == owner); g_eax = position; g_esp += 4; }
+static void cast_owner(void) { g_eax = owner; g_esp += 4; }
+static void get_mesh(void) { assert(g_ecx == owner); g_eax = visual; g_esp += 4; }
+static void get_world_matrix(void) { assert(g_ecx == mesh + 0x3c); g_eax = world_matrix; g_esp += 4; }
+
+static void get_attractor(void)
+{
+ assert(g_ecx == visual && MEM32(g_esp + 4) == 0);
+ ++attractor_calls;
+ uint32_t matrix = MEM32(g_esp + 8);
+ if (!MEM8(mesh + 0x288) && MEM32(mesh + 0x284) != 0xffffffff) {
+ *(float *)ADDR(matrix + 0x30) = 100000;
+ *(float *)ADDR(matrix + 0x34) = 100000;
+ *(float *)ADDR(matrix + 0x38) = 100000;
+ } else {
+ *(float *)ADDR(matrix + 0x34) = 2;
+ }
+ g_esp += 12;
+}
static void geometry(void)
{
@@ -103,6 +123,10 @@ recomp_func_t recomp_lookup_import(uint32_t address) { abort(); }
recomp_func_t recomp_lookup(uint32_t address)
{
switch (address) {
+ case 0x3615fd86: return cast_owner;
+ case 0x70000034: return get_mesh;
+ case 0x70000038: return get_attractor;
+ case 0x7000003c: return get_world_matrix;
case 0x360fc300: return timing;
case 0x360d3b40: return sun;
case 0x360887d0: return clamp;
@@ -128,6 +152,18 @@ static void arrange_fixture(void)
memset((void *)ADDR(0x50000000), 0, 0x10000);
timing_calls = geometry_calls = update_calls = segment_calls = 0;
line_calls = sample_calls = 0; line_hit = 0; contact_normal_y = 0;
+ attractor_calls = 0;
+ MEM32(owner + 0xc8) = visual;
+ MEM32(visual + 0x28) = mesh;
+ MEM32(0x3616ffe8) = 0x70000034;
+ MEM32(0x3616f834) = 0x70000038;
+ MEM32(0x3616f3a0) = 0x7000003c;
+ MEM32(0x3616ffb0) = 0x7000000c;
+ *(float *)ADDR(world_matrix) = 1;
+ *(float *)ADDR(world_matrix + 0x14) = 1;
+ *(float *)ADDR(world_matrix + 0x28) = 1;
+ *(float *)ADDR(world_matrix + 0x3c) = 1;
+ *(float *)ADDR(world_matrix + 0x34) = 1;
MEM8(0x3630d684) = 1;
MEM32(0x3616ff70) = 0x70000000;
MEM32(0x3616ffac) = 0x70000004;
@@ -274,6 +310,63 @@ static void repeated_light_keeps_current_position(void)
assert(updated_direction[2] == 0);
}
+static void inactive_attractor_defers_shadow_height(void)
+{
+ arrange_fixture();
+ MEM32(controller + 0x28) = 0;
+ MEM8(controller + 0x39) = 1;
+
+ run_controller();
+
+ assert(MEM32(controller + 0x28) == 0);
+ assert(attractor_calls == 0 && geometry_calls == 0 && line_calls == 0);
+ assert(timing_calls == 1 && segment_calls == 1 && update_calls == 0);
+ assert(MEM8(controller + 0x39) == 0);
+}
+
+static void activated_attractor_initializes_shadow_height(void)
+{
+ arrange_fixture();
+ MEM32(controller + 0x28) = 0;
+ run_controller();
+ MEM8(mesh + 0x288) = 1;
+ line_hit = 1; contact_normal_y = 1;
+
+ run_controller();
+
+ assert(*(float *)ADDR(controller + 0x28) == 2);
+ assert(attractor_calls == 1 && geometry_calls == 1 && update_calls == 1);
+ assert(first_endpoint[1] == -17);
+}
+
+static void unindexed_attractor_initializes_shadow_height(void)
+{
+ arrange_fixture();
+ MEM32(controller + 0x28) = 0;
+ MEM32(mesh + 0x284) = 0xffffffff;
+
+ run_controller();
+
+ assert(*(float *)ADDR(controller + 0x28) == 2);
+ assert(attractor_calls == 1 && geometry_calls == 1);
+}
+
+static void throttled_skeleton_defers_first_height_until_update(void)
+{
+ arrange_fixture();
+ MEM32(controller + 0x28) = 0;
+ MEM8(mesh + 0x288) = 1;
+ MEM32(mesh + 0x280) = 1;
+
+ run_controller();
+
+ assert(MEM32(controller + 0x28) == 0 && attractor_calls == 0);
+ assert(geometry_calls == 0 && line_calls == 0);
+ MEM32(mesh + 0x280) = 0;
+ run_controller();
+ assert(*(float *)ADDR(controller + 0x28) == 2 && attractor_calls == 1);
+}
+
int main(void)
{
assert(guest_map("shadow fixture", 0x50000000, 0x10000));
@@ -285,5 +378,9 @@ int main(void)
normal_threshold_and_unordered_cases();
light_direction_tracks_inputs();
repeated_light_keeps_current_position();
+ inactive_attractor_defers_shadow_height();
+ activated_attractor_initializes_shadow_height();
+ unindexed_attractor_initializes_shadow_height();
+ throttled_skeleton_defers_first_height_until_update();
puts("shadow-contact: failed contacts, retained sampling, recovery and guest ABI passed");
}