From 7a4f7cbddb61466e2dc67afae11357948f81abc7 Mon Sep 17 00:00:00 2001 From: itsgrimetime <990274+itsgrimetime@users.noreply.github.com> Date: Tue, 30 Dec 2025 09:00:12 -0800 Subject: [PATCH 1/3] Match mpIsland_8005AE1C MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 100% match achieved via decomp.me scratch qXzkT. Key matching insights: - Use goto-based loop structure with check-at-end pattern - Variable declaration order affects register allocation (prev_b before prev_a) - Use `end > v0` with forward goto instead of `end <= v0` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/melee/mp/mpisland.c | 125 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/src/melee/mp/mpisland.c b/src/melee/mp/mpisland.c index c6d053f8f7..532b1cdcd3 100644 --- a/src/melee/mp/mpisland.c +++ b/src/melee/mp/mpisland.c @@ -347,3 +347,128 @@ void mpIsland_8005ACE8(mp_UnkStruct0* arg0, Vec3* arg1, Vec3* arg2) var_r30++; } } + +static float mpIsland_804D8158; + +void mpIsland_8005AE1C(mp_UnkStruct0** arg0, mp_UnkStruct0** arg1, int arg2, + int arg3, bool arg4) +{ + mp_UnkStruct0* prev_b; + mp_UnkStruct0* prev_a; + mp_UnkStruct0* cur; + mp_UnkStruct0* next; + CollVtx* vtx; + int end; + float z_val; + u16 v0; + + prev_b = NULL; + prev_a = NULL; + + vtx = mpGetGroundCollVtx(); + cur = *arg0; + end = arg2 + arg3; + z_val = mpIsland_804D8158; + + goto loop1_check; +loop1_body: + v0 = cur->x4; + next = cur->next; + + if ((int) v0 < arg2) { + if ((int) cur->x6 < arg2) { + goto add_to_prev_b_1; + } + } + + if (end > (int) v0) { + goto do_assign_1; + } + if (end <= (int) cur->x6) { + goto add_to_prev_b_1; + } + +do_assign_1: + cur->x8.x = vtx[v0].pos.x; + cur->x8.y = vtx[cur->x4].pos.y; + cur->x8.z = z_val; + cur->x14.x = vtx[cur->x6].pos.x; + cur->x14.y = vtx[cur->x6].pos.y; + cur->x14.z = z_val; + + if (arg4) { + goto add_to_prev_b_1; + } + if (cur->x20 & 2) { + goto add_to_prev_b_1; + } + cur->x20 |= 2; + cur->next = prev_a; + prev_a = cur; + goto loop1_next; + +add_to_prev_b_1: + cur->next = prev_b; + prev_b = cur; + +loop1_next: + cur = next; +loop1_check: + if (cur != NULL) { + goto loop1_body; + } + + cur = *arg1; + z_val = mpIsland_804D8158; + + goto loop2_check; +loop2_body: + v0 = cur->x4; + next = cur->next; + + if ((int) v0 < arg2) { + if ((int) cur->x6 < arg2) { + goto add_to_prev_a_2; + } + } + + if (end > (int) v0) { + goto do_assign_2; + } + if (end <= (int) cur->x6) { + goto add_to_prev_a_2; + } + +do_assign_2: + cur->x8.x = vtx[v0].pos.x; + cur->x8.y = vtx[cur->x4].pos.y; + cur->x8.z = z_val; + cur->x14.x = vtx[cur->x6].pos.x; + cur->x14.y = vtx[cur->x6].pos.y; + cur->x14.z = z_val; + + if (arg4 == false) { + goto add_to_prev_a_2; + } + if ((cur->x20 & 2) == 0) { + goto add_to_prev_a_2; + } + cur->x20 &= ~2; + cur->next = prev_b; + prev_b = cur; + goto loop2_next; + +add_to_prev_a_2: + cur->next = prev_a; + prev_a = cur; + +loop2_next: + cur = next; +loop2_check: + if (cur != NULL) { + goto loop2_body; + } + + *arg0 = prev_b; + *arg1 = prev_a; +} From 9eed9fd1fbeb655934661423f67773a1ccf3f928 Mon Sep 17 00:00:00 2001 From: itsgrimetime <990274+itsgrimetime@users.noreply.github.com> Date: Tue, 30 Dec 2025 09:07:00 -0800 Subject: [PATCH 2/3] Match mpIsland_8005B334, update struct layout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 100% match achieved via decomp.me scratch 0cY7A. Also updates: - mpIsland_80458E88_t struct to have correct pointer layout - mpIsland_8005B004 signature with 7 parameters 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/melee/mp/mpisland.c | 74 +++++++++++++++++++++++++++++++++++------ src/melee/mp/mpisland.h | 6 ++-- src/melee/mp/types.h | 17 +++++----- 3 files changed, 74 insertions(+), 23 deletions(-) diff --git a/src/melee/mp/mpisland.c b/src/melee/mp/mpisland.c index 532b1cdcd3..9a7e33f70a 100644 --- a/src/melee/mp/mpisland.c +++ b/src/melee/mp/mpisland.c @@ -35,14 +35,14 @@ void mpIsland_8005A6F8(void) { mpIsland_80458E88.next = NULL; - mpIsland_80458E88.x4 = 0; - mpIsland_80458E88.x8.x = 0; - mpIsland_80458E88.x8.y = 0; - mpIsland_80458E88.x14.y = 0; - mpIsland_80458E88.x14.z = 0; - mpIsland_80458E88.x8.z = 0; - mpIsland_80458E88.x14.x = 0; - mpIsland_80458E88.x20 = 0; + mpIsland_80458E88.x4 = NULL; + mpIsland_80458E88.x8 = NULL; + mpIsland_80458E88.xC = NULL; + mpIsland_80458E88.x14 = NULL; + mpIsland_80458E88.x1C = NULL; + mpIsland_80458E88.x10 = NULL; + mpIsland_80458E88.x18 = NULL; + mpIsland_80458E88.x20 = NULL; } void mpIsland_8005A728(void) @@ -88,9 +88,9 @@ void mpIsland_8005A728(void) v0 = (short*) mpLib_8004D164(); v1 = mpGetGroundCollLine(); v2 = mpGetGroundCollVtx(); - v23 = &mpIsland_80458E88.x4; - v24_2 = &mpIsland_80458E88.x8.x; - v22_2 = &mpIsland_80458E88.x8.y; + v23 = (int*) &mpIsland_80458E88.x4; + v24_2 = (s32*) &mpIsland_80458E88.x8; + v22_2 = (s32*) &mpIsland_80458E88.xC; mpIsland_8005A6F8(); memzero(v33, 0x600u); @@ -472,3 +472,55 @@ void mpIsland_8005AE1C(mp_UnkStruct0** arg0, mp_UnkStruct0** arg1, int arg2, *arg0 = prev_b; *arg1 = prev_a; } + +/// #mpIsland_8005B004 + +void mpIsland_8005B334(int arg0, int arg1, int arg2, bool arg3) +{ + mp_UnkStruct0* temp; + + if (mpIsland_80458E88.x8 != NULL) { + mpIsland_80458E88.x8->next = NULL; + } else { + mpIsland_80458E88.next = NULL; + } + + if (mpIsland_80458E88.xC != NULL) { + mpIsland_80458E88.xC->next = NULL; + } else { + mpIsland_80458E88.x4 = NULL; + } + + mpIsland_8005AE1C(&mpIsland_80458E88.next, &mpIsland_80458E88.x18, arg1, + arg2, arg3); + mpIsland_8005AE1C(&mpIsland_80458E88.x4, &mpIsland_80458E88.x1C, arg1, arg2, + arg3); + mpIsland_8005B004(&mpIsland_80458E88.x10, &mpIsland_80458E88.x20, arg0, 1, + arg1, arg2, arg3); + mpIsland_8005B004(&mpIsland_80458E88.x14, &mpIsland_80458E88.x20, arg0, 2, + arg1, arg2, arg3); + + // Find end of first list and link + temp = mpIsland_80458E88.next; + while (temp != NULL && temp->next != NULL) { + temp = temp->next; + } + if (temp != NULL) { + temp->next = mpIsland_80458E88.x10; + } else { + mpIsland_80458E88.next = mpIsland_80458E88.x10; + } + mpIsland_80458E88.x8 = temp; + + // Find end of second list and link + temp = mpIsland_80458E88.x4; + while (temp != NULL && temp->next != NULL) { + temp = temp->next; + } + if (temp != NULL) { + temp->next = mpIsland_80458E88.x14; + } else { + mpIsland_80458E88.x4 = mpIsland_80458E88.x14; + } + mpIsland_80458E88.xC = temp; +} diff --git a/src/melee/mp/mpisland.h b/src/melee/mp/mpisland.h index 79434acd76..69a6976cf0 100644 --- a/src/melee/mp/mpisland.h +++ b/src/melee/mp/mpisland.h @@ -14,9 +14,9 @@ /* 05AC14 */ mp_UnkStruct0* mpIsland_8005AC14(Vec3*, float); /* 05AC8C */ bool mpIsland_8005AC8C(mp_UnkStruct0* arg0); /* 05ACE8 */ void mpIsland_8005ACE8(mp_UnkStruct0*, Vec3*, Vec3*); -/* 05AE1C */ UNK_RET mpIsland_8005AE1C(UNK_PARAMS); -/* 05B004 */ UNK_RET mpIsland_8005B004(UNK_PARAMS); -/* 05B334 */ UNK_RET mpIsland_8005B334(int, int, int, bool); +/* 05AE1C */ void mpIsland_8005AE1C(mp_UnkStruct0** arg0, mp_UnkStruct0** arg1, int arg2, int arg3, bool arg4); +/* 05B004 */ void mpIsland_8005B004(mp_UnkStruct0** arg0, mp_UnkStruct0** arg1, int arg2, int arg3, int arg4, int arg5, bool arg6); +/* 05B334 */ void mpIsland_8005B334(int arg0, int arg1, int arg2, bool arg3); extern mpIsland_Palette mpIsland_TerrainPalette; struct mpIsland_80458E88_t; diff --git a/src/melee/mp/types.h b/src/melee/mp/types.h index b077dc0ea1..f1bf27b161 100644 --- a/src/melee/mp/types.h +++ b/src/melee/mp/types.h @@ -14,15 +14,14 @@ struct mpIsland_80458E88_t { /* +0 */ mp_UnkStruct0* next; - /* +4 */ int x4; - /* +8 */ S32Vec3 x8; - /* +14 */ S32Vec3 x14; - /* +20 */ int x20; - /* +24 */ short x24; - /* +26 */ short x26; - /* +28 */ short x28; - /* +2A */ short x2A; - /* +2C */ mp_UnkStruct3* ptr; + /* +4 */ mp_UnkStruct0* x4; + /* +8 */ mp_UnkStruct0* x8; + /* +C */ mp_UnkStruct0* xC; + /* +10 */ mp_UnkStruct0* x10; + /* +14 */ mp_UnkStruct0* x14; + /* +18 */ mp_UnkStruct0* x18; + /* +1C */ mp_UnkStruct0* x1C; + /* +20 */ mp_UnkStruct0* x20; }; struct mpIsland_PaletteEntry { From d2c5219c2488496cbf03fe0751a5c1266883b560 Mon Sep 17 00:00:00 2001 From: Robin Avery Date: Tue, 30 Dec 2025 14:28:08 -0500 Subject: [PATCH 3/3] Fix broken function --- src/melee/mp/mpisland.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/melee/mp/mpisland.c b/src/melee/mp/mpisland.c index 9a7e33f70a..3f40932716 100644 --- a/src/melee/mp/mpisland.c +++ b/src/melee/mp/mpisland.c @@ -38,10 +38,10 @@ void mpIsland_8005A6F8(void) mpIsland_80458E88.x4 = NULL; mpIsland_80458E88.x8 = NULL; mpIsland_80458E88.xC = NULL; - mpIsland_80458E88.x14 = NULL; + mpIsland_80458E88.x18 = NULL; mpIsland_80458E88.x1C = NULL; mpIsland_80458E88.x10 = NULL; - mpIsland_80458E88.x18 = NULL; + mpIsland_80458E88.x14 = NULL; mpIsland_80458E88.x20 = NULL; } @@ -493,8 +493,8 @@ void mpIsland_8005B334(int arg0, int arg1, int arg2, bool arg3) mpIsland_8005AE1C(&mpIsland_80458E88.next, &mpIsland_80458E88.x18, arg1, arg2, arg3); - mpIsland_8005AE1C(&mpIsland_80458E88.x4, &mpIsland_80458E88.x1C, arg1, arg2, - arg3); + mpIsland_8005AE1C(&mpIsland_80458E88.x4, &mpIsland_80458E88.x1C, arg1, + arg2, arg3); mpIsland_8005B004(&mpIsland_80458E88.x10, &mpIsland_80458E88.x20, arg0, 1, arg1, arg2, arg3); mpIsland_8005B004(&mpIsland_80458E88.x14, &mpIsland_80458E88.x20, arg0, 2,