From 4e4339126e1e8939494f4c93a2e14533c6a7d63f Mon Sep 17 00:00:00 2001 From: Tyler McGavran Date: Tue, 22 Feb 2022 13:45:29 -0500 Subject: [PATCH] Match func_80091AC0 (#166) * Match func_80091AC0 * Match func_8009A6D4 Signed-off-by: Taggerung --- .../code_80091750/func_80091AC0.s | 46 ----------- .../code_80091750/func_8009A6D4.s | 41 ---------- src/code_80091750.c | 78 ++++++------------- src/code_80091750.h | 2 + 4 files changed, 27 insertions(+), 140 deletions(-) delete mode 100644 asm/non_matchings/code_80091750/func_80091AC0.s delete mode 100644 asm/non_matchings/code_80091750/func_8009A6D4.s diff --git a/asm/non_matchings/code_80091750/func_80091AC0.s b/asm/non_matchings/code_80091750/func_80091AC0.s deleted file mode 100644 index 5d7e561c2..000000000 --- a/asm/non_matchings/code_80091750/func_80091AC0.s +++ /dev/null @@ -1,46 +0,0 @@ -glabel func_80091AC0 -/* 0926C0 80091AC0 3C013FE0 */ li $at, 0x3FE00000 # 1.750000 -/* 0926C4 80091AC4 44810800 */ mtc1 $at, $f1 -/* 0926C8 80091AC8 44800000 */ mtc1 $zero, $f0 -/* 0926CC 80091ACC 00001025 */ move $v0, $zero -/* 0926D0 80091AD0 3C013FF0 */ li $at, 0x3FF00000 # 1.875000 -/* 0926D4 80091AD4 4620603C */ c.lt.d $f12, $f0 -/* 0926D8 80091AD8 00000000 */ nop -/* 0926DC 80091ADC 45030009 */ bc1tl .L80091B04 -/* 0926E0 80091AE0 4620603C */ c.lt.d $f12, $f0 -/* 0926E4 80091AE4 44811800 */ mtc1 $at, $f3 -/* 0926E8 80091AE8 44801000 */ mtc1 $zero, $f2 -/* 0926EC 80091AEC 00000000 */ nop -/* 0926F0 80091AF0 462C103E */ c.le.d $f2, $f12 -/* 0926F4 80091AF4 00000000 */ nop -/* 0926F8 80091AF8 45020018 */ bc1fl .L80091B5C -/* 0926FC 80091AFC ACC20000 */ sw $v0, ($a2) -/* 092700 80091B00 4620603C */ c.lt.d $f12, $f0 -.L80091B04: -/* 092704 80091B04 3C013FF0 */ li $at, 0x3FF00000 # 1.875000 -/* 092708 80091B08 44811800 */ mtc1 $at, $f3 -/* 09270C 80091B0C 3C014000 */ li $at, 0x40000000 # 2.000000 -/* 092710 80091B10 44817800 */ mtc1 $at, $f15 -/* 092714 80091B14 44801000 */ mtc1 $zero, $f2 -/* 092718 80091B18 44807000 */ mtc1 $zero, $f14 -/* 09271C 80091B1C 45020005 */ bc1fl .L80091B34 -/* 092720 80091B20 462E6303 */ div.d $f12, $f12, $f14 -/* 092724 80091B24 462E6302 */ mul.d $f12, $f12, $f14 -/* 092728 80091B28 10000003 */ b .L80091B38 -/* 09272C 80091B2C 2442FFFF */ addiu $v0, $v0, -1 -/* 092730 80091B30 462E6303 */ div.d $f12, $f12, $f14 -.L80091B34: -/* 092734 80091B34 24420001 */ addiu $v0, $v0, 1 -.L80091B38: -/* 092738 80091B38 4620603C */ c.lt.d $f12, $f0 -/* 09273C 80091B3C 00000000 */ nop -/* 092740 80091B40 4503FFF0 */ bc1tl .L80091B04 -/* 092744 80091B44 4620603C */ c.lt.d $f12, $f0 -/* 092748 80091B48 462C103E */ c.le.d $f2, $f12 -/* 09274C 80091B4C 00000000 */ nop -/* 092750 80091B50 4503FFEC */ bc1tl .L80091B04 -/* 092754 80091B54 4620603C */ c.lt.d $f12, $f0 -/* 092758 80091B58 ACC20000 */ sw $v0, ($a2) -.L80091B5C: -/* 09275C 80091B5C 03E00008 */ jr $ra -/* 092760 80091B60 46206006 */ mov.d $f0, $f12 diff --git a/asm/non_matchings/code_80091750/func_8009A6D4.s b/asm/non_matchings/code_80091750/func_8009A6D4.s deleted file mode 100644 index 8a9b57af5..000000000 --- a/asm/non_matchings/code_80091750/func_8009A6D4.s +++ /dev/null @@ -1,41 +0,0 @@ -glabel func_8009A6D4 #UNUSED -/* 09B2D4 8009A6D4 27BDFFD0 */ addiu $sp, $sp, -0x30 -/* 09B2D8 8009A6D8 AFB30028 */ sw $s3, 0x28($sp) -/* 09B2DC 8009A6DC AFB10020 */ sw $s1, 0x20($sp) -/* 09B2E0 8009A6E0 AFB0001C */ sw $s0, 0x1c($sp) -/* 09B2E4 8009A6E4 AFB20024 */ sw $s2, 0x24($sp) -/* 09B2E8 8009A6E8 3C108019 */ lui $s0, %hi(D_8018DEE0) # $s0, 0x8019 -/* 09B2EC 8009A6EC 3C118015 */ lui $s1, %hi(gDisplayListHead) # $s1, 0x8015 -/* 09B2F0 8009A6F0 3C138019 */ lui $s3, %hi(D_8018E060) # $s3, 0x8019 -/* 09B2F4 8009A6F4 AFBF002C */ sw $ra, 0x2c($sp) -/* 09B2F8 8009A6F8 2673E060 */ addiu $s3, %lo(D_8018E060) # addiu $s3, $s3, -0x1fa0 -/* 09B2FC 8009A6FC 26310298 */ addiu $s1, %lo(gDisplayListHead) # addiu $s1, $s1, 0x298 -/* 09B300 8009A700 2610DEE0 */ addiu $s0, %lo(D_8018DEE0) # addiu $s0, $s0, -0x2120 -/* 09B304 8009A704 3C128000 */ lui $s2, 0x8000 -/* 09B308 8009A708 8E0E000C */ lw $t6, 0xc($s0) -.L8009A70C: -/* 09B30C 8009A70C 01D27824 */ and $t7, $t6, $s2 -/* 09B310 8009A710 51E0000B */ beql $t7, $zero, .L8009A740 -/* 09B314 8009A714 26100018 */ addiu $s0, $s0, 0x18 -/* 09B318 8009A718 0C026A1E */ jal func_8009A878 -/* 09B31C 8009A71C 02002025 */ move $a0, $s0 -/* 09B320 8009A720 8E240000 */ lw $a0, ($s1) -/* 09B324 8009A724 02002825 */ move $a1, $s0 -/* 09B328 8009A728 00003025 */ move $a2, $zero -/* 09B32C 8009A72C 00003825 */ move $a3, $zero -/* 09B330 8009A730 0C02710D */ jal func_8009C434 -/* 09B334 8009A734 AFA00010 */ sw $zero, 0x10($sp) -/* 09B338 8009A738 AE220000 */ sw $v0, ($s1) -/* 09B33C 8009A73C 26100018 */ addiu $s0, $s0, 0x18 -.L8009A740: -/* 09B340 8009A740 5613FFF2 */ bnel $s0, $s3, .L8009A70C -/* 09B344 8009A744 8E0E000C */ lw $t6, 0xc($s0) -/* 09B348 8009A748 0C0266BB */ jal func_80099AEC -/* 09B34C 8009A74C 00000000 */ nop -/* 09B350 8009A750 8FBF002C */ lw $ra, 0x2c($sp) -/* 09B354 8009A754 8FB0001C */ lw $s0, 0x1c($sp) -/* 09B358 8009A758 8FB10020 */ lw $s1, 0x20($sp) -/* 09B35C 8009A75C 8FB20024 */ lw $s2, 0x24($sp) -/* 09B360 8009A760 8FB30028 */ lw $s3, 0x28($sp) -/* 09B364 8009A764 03E00008 */ jr $ra -/* 09B368 8009A768 27BD0030 */ addiu $sp, $sp, 0x30 diff --git a/src/code_80091750.c b/src/code_80091750.c index 4d08e7058..b5188bc9e 100644 --- a/src/code_80091750.c +++ b/src/code_80091750.c @@ -159,45 +159,29 @@ f64 func_80091A6C(f64 value, s32 exponent) { return value; } -#ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 +/** + * Its unclear what exact purpose this function serves + * The function multiplies/divides arg0 by 2 until its in + * the range (0.5, 1.0]. + * arg2 appears to track the exponent in the power-of-2 + * that would undo the changes to arg0 +**/ f64 func_80091AC0(f64 arg0, s32 *arg2) { - f64 phi_f12; - f64 phi_f12_2; - s32 phi_v0; - f64 phi_f12_3; - s32 phi_v0_2; - s32 phi_v0_3; + const f64 const1 = 2.0; + s32 exponent = 0; - phi_f12 = arg0; - phi_v0 = 0; - phi_f12_3 = arg0; - phi_v0_3 = 0; - if ((arg0 < 0.5) || (arg0 >= 1.0)) { - do { -loop_2: - if (phi_f12 < 0.5) { - phi_f12_2 = phi_f12 * 2.0; - phi_v0_2 = phi_v0_3 - 1; - } else { - phi_f12_2 = phi_f12 / 2.0; - phi_v0_2 = phi_v0_3 + 1; - } - phi_f12 = phi_f12_2; - phi_v0 = phi_v0_2; - phi_f12_3 = phi_f12_2; - phi_v0_3 = phi_v0_2; - if (phi_f12_2 < 0.5) { - goto loop_2; - } - } while (phi_f12_2 >= 1.0); + while ((arg0 < 0.5) || (arg0 >= 1.0)) { + if (arg0 < 0.5) { + arg0 *= const1; + exponent -= 1; + } else { + arg0 /= const1; + exponent += 1; + } } - *arg2 = phi_v0; - return phi_f12_3; + *arg2 = exponent; + return arg0; } -#else -GLOBAL_ASM("asm/non_matchings/code_80091750/func_80091AC0.s") -#endif void swap_values(s32 *arg0, s32 *arg1) { s32 temp; @@ -4648,28 +4632,16 @@ void func_8009A640(s32 arg0, s32 arg1, s32 arg2, MkAnimation *arg3) { GLOBAL_ASM("asm/non_matchings/code_80091750/func_8009A640.s") #endif -#ifdef MIPS_TO_C -//generated by mips_to_c commit dacbf209f1bb5d4acaecaf1fefff331d60ffd80c -extern ? D_8018E060; - UNUSED void func_8009A6D4(void) { - struct_8018DEE0_entry *temp_s0; - struct_8018DEE0_entry *phi_s0; - - phi_s0 = D_8018DEE0; - do { - if ((phi_s0->visible & 0x80000000) != 0) { - func_8009A878(phi_s0); - gDisplayListHead = func_8009C434((s32) gDisplayListHead, phi_s0, 0, 0, 0); + s32 index; + for (index = 0; index < D_8018DEE0_SIZE; index++) { + if ((D_8018DEE0[index].visible & 0x80000000) != 0) { + func_8009A878(&D_8018DEE0[index]); + gDisplayListHead = func_8009C434(gDisplayListHead, &D_8018DEE0[index], 0, 0, 0); } - temp_s0 = phi_s0 + 0x18; - phi_s0 = temp_s0; - } while (temp_s0 != &D_8018E060); + } func_80099AEC(); } -#else -GLOBAL_ASM("asm/non_matchings/code_80091750/func_8009A6D4.s") -#endif void func_8009A76C(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { struct_8018DEE0_entry *temp = &D_8018DEE0[arg0]; diff --git a/src/code_80091750.h b/src/code_80091750.h index 2582d22fc..e89017aca 100644 --- a/src/code_80091750.h +++ b/src/code_80091750.h @@ -48,6 +48,7 @@ typedef struct { f64 exponent_by_squaring(f64, s32); f64 func_80091A6C(f64, s32); +f64 func_80091AC0(f64, s32*); void swap_values(s32*, s32*); void func_80092148(); void func_800921B4(); @@ -112,6 +113,7 @@ void func_80099A70(); void func_8009A344(); void func_8009A594(s32, s32, MkAnimation*); void func_8009A640(s32, s32, s32, MkAnimation*); +void func_8009A6D4(); void func_8009A76C(s32, s32, s32, s32); void func_8009A7EC(s32, s32, s32, s32, s32); void func_8009A878(struct_8018DEE0_entry*);