From f449a455bca4ab37bff31e1b6cdcaba501aac2f7 Mon Sep 17 00:00:00 2001 From: Drew T <50529377+Druthulu@users.noreply.github.com> Date: Wed, 26 Aug 2026 14:00:50 -0600 Subject: [PATCH] =?UTF-8?q?feat(decomp):=20ov=5FSC02=5F027/func=5F801831F4?= =?UTF-8?q?=20+=20ov=5FSC06=5F000/func=5F80182E38=20banked=20=E2=80=94=20t?= =?UTF-8?q?he=20resolver's=202=20DIFF=20refusals=20autopsied=20to=20bytes:?= =?UTF-8?q?=20each=20was=20a=20wrong=20internal-j=20target=20(goto-to-rech?= =?UTF-8?q?eck=20vs=20cross-jumped=20call;=20shared=20negu=20vs=20else-arm?= =?UTF-8?q?=20negu)=20that=20rtu's=20R=5FMIPS=5F26=20masking=20hid;=20one-?= =?UTF-8?q?line=20semantic=20fixes,=20whole-binary=20SHA=20green=20(P31=20?= =?UTF-8?q?T1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ov_SC02_027/ov_SC02_027_jr_8017D898.c | 32 +++++++++- src/ov_SC06_000/ov_SC06_000_jr_8017AE2C.c | 76 ++++++++++++++++++++++- 2 files changed, 106 insertions(+), 2 deletions(-) diff --git a/src/ov_SC02_027/ov_SC02_027_jr_8017D898.c b/src/ov_SC02_027/ov_SC02_027_jr_8017D898.c index 3adfd780c..ed8cfa7ad 100644 --- a/src/ov_SC02_027/ov_SC02_027_jr_8017D898.c +++ b/src/ov_SC02_027/ov_SC02_027_jr_8017D898.c @@ -5646,7 +5646,37 @@ void *arg0; } -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8017D898", func_801831F4); +extern u16 D_80126B5E; + +void func_801831F4(s32 arg) +{ + register s32 a0 __asm__("$4"); + + a0 = arg; + switch (*(s16 *)((s32)a0 + 0x70)) { + case 1: + if (*(s16 *)(*(s32 *)((s32)a0 + 0x64) + 0xFE) == *(s16 *)((s32)a0 + 0x70)) { + s32 *base = (s32 *)(*(s32 *)((s32)a0 + 0x20)); + s32 r = *(base + 1) & 0x7FFFFFFF; + *(base + 1) = r; + __asm__("" :: "r"(base), "r"(r)); + *(u16 *)((s32)a0 + 0x5C) = 0xCC00; + func_80182AA4((void *)a0); /* direct call: the retail bytes `j .L80183298` land on the shared jal (cross-jump), not on the recheck */ + } + break; + case 3: + if (*(s16 *)&D_80126B5E >= 0x281) { + *(u16 *)(*(s32 *)((s32)a0 + 0x20) + 0x10) = 0; + } + /* fall through */ + default: + if (*(s16 *)(*(s32 *)((s32)a0 + 0x64) + 0xFE) == *(s16 *)((s32)a0 + 0x70)) { + func_80182AA4((void *)a0); + } + break; + } +} + void func_801832B0(u8 *a0) { diff --git a/src/ov_SC06_000/ov_SC06_000_jr_8017AE2C.c b/src/ov_SC06_000/ov_SC06_000_jr_8017AE2C.c index 2f1ff3fdc..33f09016d 100644 --- a/src/ov_SC06_000/ov_SC06_000_jr_8017AE2C.c +++ b/src/ov_SC06_000/ov_SC06_000_jr_8017AE2C.c @@ -7956,7 +7956,81 @@ void func_80182CD8(int param_1) } -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8017AE2C", func_80182E38); +void func_80182E38(int param_1) +{ + extern s32 D_80126B58; + extern s32 D_801AECB0; + extern unsigned char D_8018C644; + extern void func_8004978C(s16 *a0, void *a1); + extern void func_8018325C(s32 a0, void *a1, void *a2); + extern void func_8012E014(s32 a0); + extern void func_8012B2CC(s32 a0); + + short *dst; + char mat[0x20]; + char sv[8]; + int v0; + int t1; + int t2; + unsigned int uVar2; + int t; + + dst = (short *)&D_80126B58; + if (*(short *)(param_1 + 0x70) < 4) { + *(unsigned short *)(sv + 2) = 0; + *(unsigned short *)(sv + 0) = 0; + t1 = *(short *)(*(int *)(param_1 + 0x64) + 0x100); + if (t1 >= -0xd0) { + v0 = -0x1a0; /* retail: -0x1A0 in the j delay slot, jumping PAST the negu */ + } else { + t = (t1 + 0xc0) * 0x3600; + v0 = -(((int)t >> 16) + 0x1a0); /* the negu belongs to the else-arm only */ + } + *(short *)(sv + 4) = v0; + func_8004978C((s16 *)(*(int *)(param_1 + 0x20) + 0x10), mat); + __asm__ __volatile__( + "lw $12, 0(%0)\n" "lw $13, 4(%0)\n" + "ctc2 $12, $0\n" "ctc2 $13, $1\n" + "lw $12, 8(%0)\n" "lw $13, 12(%0)\n" "lw $14, 16(%0)\n" + "ctc2 $12, $2\n" "ctc2 $13, $3\n" "ctc2 $14, $4\n" + : : "r"(mat) : "$12", "$13", "$14", "memory"); + __asm__ __volatile__("lwc2 $0, 0(%0)\n" "lwc2 $1, 4(%0)\n" : : "r"(sv) : "memory"); + __asm__ __volatile__("nop\n" "nop\n" "mvmva 1, 0, 0, 3, 0\n" : : : "memory"); + __asm__ __volatile__( + "mfc2 $12, $9\n" "mfc2 $13, $10\n" "mfc2 $14, $11\n" + "sh $12, 0(%0)\n" "sh $13, 2(%0)\n" "sh $14, 4(%0)\n" + : : "r"(sv) : "$12", "$13", "$14", "memory"); + *(short *)(param_1 + 6) = *(unsigned short *)(*(int *)(param_1 + 0x64) + 6) + *(unsigned short *)(sv + 0); + *(short *)(param_1 + 10) = *(unsigned short *)(*(int *)(param_1 + 0x64) + 10) + *(unsigned short *)(sv + 2); + *(short *)(param_1 + 14) = *(unsigned short *)(*(int *)(param_1 + 0x64) + 14) + *(unsigned short *)(sv + 4); + t2 = *(short *)(*(int *)(param_1 + 0x64) + 0x100); + if (t2 != 0 && t2 >= -0x24f) { + uVar2 = *(unsigned int *)(param_1 + 0x1c); + *(unsigned int *)(param_1 + 0x1c) = uVar2 + 1; + if ((uVar2 & 7) == 0) { + *(short *)(sv + 0) = -0x48; + *(short *)(sv + 2) = 0; + *(short *)(sv + 4) = 0x58; + func_8018325C(param_1, mat, sv); + *(short *)(sv + 0) = 0x48; + func_8018325C(param_1, mat, sv); + } + } + } else { + *(short *)(param_1 + 6) = *(unsigned short *)(*(int *)(param_1 + 0x64) + 6); + *(short *)(param_1 + 10) = *(unsigned short *)(*(int *)(param_1 + 0x64) + 10); + *(short *)(param_1 + 14) = *(unsigned short *)(*(int *)(param_1 + 0x64) + 14); + } + if (D_801AECB0 == 0 && *(unsigned char *)(param_1 + 0x74) != 0) { + func_8012E014(param_1); + *(dst + 5) = + (*(unsigned short *)(param_1 + 10) + + *(unsigned short *)(&D_8018C644 + (*(short *)(param_1 + 0xfe) << 4))) - 1; + } else { + func_8012B2CC(param_1); + } +} + extern void (*D_8018C66C[])(void);