diff --git a/asm/non_matchings/code_80091750/func_80095AE0.s b/asm/non_matchings/code_80091750/func_80095AE0.s deleted file mode 100644 index 9d69df18cd..0000000000 --- a/asm/non_matchings/code_80091750/func_80095AE0.s +++ /dev/null @@ -1,62 +0,0 @@ -glabel func_80095AE0 -/* 0966E0 80095AE0 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 0966E4 80095AE4 44857000 */ mtc1 $a1, $f14 -/* 0966E8 80095AE8 44876000 */ mtc1 $a3, $f12 -/* 0966EC 80095AEC AFA60020 */ sw $a2, 0x20($sp) -/* 0966F0 80095AF0 24050010 */ li $a1, 16 -/* 0966F4 80095AF4 00001025 */ move $v0, $zero -/* 0966F8 80095AF8 00801825 */ move $v1, $a0 -.L80095AFC: -/* 0966FC 80095AFC 24420004 */ addiu $v0, $v0, 4 -/* 096700 80095B00 AC600000 */ sw $zero, ($v1) -/* 096704 80095B04 AC600004 */ sw $zero, 4($v1) -/* 096708 80095B08 AC600008 */ sw $zero, 8($v1) -/* 09670C 80095B0C AC60000C */ sw $zero, 0xc($v1) -/* 096710 80095B10 1445FFFA */ bne $v0, $a1, .L80095AFC -/* 096714 80095B14 24630010 */ addiu $v1, $v1, 0x10 -/* 096718 80095B18 3C014780 */ li $at, 0x47800000 # 65536.000000 -/* 09671C 80095B1C 44810000 */ mtc1 $at, $f0 -/* 096720 80095B20 C7A80028 */ lwc1 $f8, 0x28($sp) -/* 096724 80095B24 27A20014 */ addiu $v0, $sp, 0x14 -/* 096728 80095B28 46006102 */ mul.s $f4, $f12, $f0 -/* 09672C 80095B2C 27A30010 */ addiu $v1, $sp, 0x10 -/* 096730 80095B30 24050001 */ li $a1, 1 -/* 096734 80095B34 46004282 */ mul.s $f10, $f8, $f0 -/* 096738 80095B38 27A6000C */ addiu $a2, $sp, 0xc -/* 09673C 80095B3C 27A70008 */ addiu $a3, $sp, 8 -/* 096740 80095B40 46007482 */ mul.s $f18, $f14, $f0 -/* 096744 80095B44 4600218D */ trunc.w.s $f6, $f4 -/* 096748 80095B48 4600540D */ trunc.w.s $f16, $f10 -/* 09674C 80095B4C 440F3000 */ mfc1 $t7, $f6 -/* 096750 80095B50 C7A60020 */ lwc1 $f6, 0x20($sp) -/* 096754 80095B54 4600910D */ trunc.w.s $f4, $f18 -/* 096758 80095B58 44198000 */ mfc1 $t9, $f16 -/* 09675C 80095B5C 46003202 */ mul.s $f8, $f6, $f0 -/* 096760 80095B60 AFAF0014 */ sw $t7, 0x14($sp) -/* 096764 80095B64 44092000 */ mfc1 $t1, $f4 -/* 096768 80095B68 AFB90010 */ sw $t9, 0x10($sp) -/* 09676C 80095B6C AFA9000C */ sw $t1, 0xc($sp) -/* 096770 80095B70 4600428D */ trunc.w.s $f10, $f8 -/* 096774 80095B74 440B5000 */ mfc1 $t3, $f10 -/* 096778 80095B78 00000000 */ nop -/* 09677C 80095B7C AFAB0008 */ sw $t3, 8($sp) -/* 096780 80095B80 844C0000 */ lh $t4, ($v0) -/* 096784 80095B84 A48C0000 */ sh $t4, ($a0) -/* 096788 80095B88 846D0000 */ lh $t5, ($v1) -/* 09678C 80095B8C A4850014 */ sh $a1, 0x14($a0) -/* 096790 80095B90 A48D000A */ sh $t5, 0xa($a0) -/* 096794 80095B94 84CE0000 */ lh $t6, ($a2) -/* 096798 80095B98 A48E0018 */ sh $t6, 0x18($a0) -/* 09679C 80095B9C 84EF0000 */ lh $t7, ($a3) -/* 0967A0 80095BA0 A485001E */ sh $a1, 0x1e($a0) -/* 0967A4 80095BA4 A48F001A */ sh $t7, 0x1a($a0) -/* 0967A8 80095BA8 84580002 */ lh $t8, 2($v0) -/* 0967AC 80095BAC A4980020 */ sh $t8, 0x20($a0) -/* 0967B0 80095BB0 84790002 */ lh $t9, 2($v1) -/* 0967B4 80095BB4 A499002A */ sh $t9, 0x2a($a0) -/* 0967B8 80095BB8 84C80002 */ lh $t0, 2($a2) -/* 0967BC 80095BBC A4880038 */ sh $t0, 0x38($a0) -/* 0967C0 80095BC0 84E90002 */ lh $t1, 2($a3) -/* 0967C4 80095BC4 27BD0018 */ addiu $sp, $sp, 0x18 -/* 0967C8 80095BC8 03E00008 */ jr $ra -/* 0967CC 80095BCC A489003A */ sh $t1, 0x3a($a0) diff --git a/asm/non_matchings/update_objects/func_8007C4A4.s b/asm/non_matchings/update_objects/func_8007C4A4.s deleted file mode 100644 index e652742aa4..0000000000 --- a/asm/non_matchings/update_objects/func_8007C4A4.s +++ /dev/null @@ -1,47 +0,0 @@ -glabel func_8007C4A4 -/* 07D0A4 8007C4A4 000470C0 */ sll $t6, $a0, 3 -/* 07D0A8 8007C4A8 01C47023 */ subu $t6, $t6, $a0 -/* 07D0AC 8007C4AC 3C0F8016 */ lui $t7, %hi(gObjectList) # $t7, 0x8016 -/* 07D0B0 8007C4B0 25EF5C18 */ addiu $t7, %lo(gObjectList) # addiu $t7, $t7, 0x5c18 -/* 07D0B4 8007C4B4 000E7140 */ sll $t6, $t6, 5 -/* 07D0B8 8007C4B8 01CF1821 */ addu $v1, $t6, $t7 -/* 07D0BC 8007C4BC 946200C0 */ lhu $v0, 0xc0($v1) -/* 07D0C0 8007C4C0 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 07D0C4 8007C4C4 AFBF0014 */ sw $ra, 0x14($sp) -/* 07D0C8 8007C4C8 0002C0C0 */ sll $t8, $v0, 3 -/* 07D0CC 8007C4CC 0302C021 */ addu $t8, $t8, $v0 -/* 07D0D0 8007C4D0 0018C080 */ sll $t8, $t8, 2 -/* 07D0D4 8007C4D4 03001025 */ move $v0, $t8 -/* 07D0D8 8007C4D8 04410004 */ bgez $v0, .L8007C4EC -/* 07D0DC 8007C4DC 0002CC03 */ sra $t9, $v0, 0x10 -/* 07D0E0 8007C4E0 3401FFFF */ li $at, 65535 -/* 07D0E4 8007C4E4 00220821 */ addu $at, $at, $v0 -/* 07D0E8 8007C4E8 0001CC03 */ sra $t9, $at, 0x10 -.L8007C4EC: -/* 07D0EC 8007C4EC 3328FFFF */ andi $t0, $t9, 0xffff -/* 07D0F0 8007C4F0 29010013 */ slti $at, $t0, 0x13 -/* 07D0F4 8007C4F4 10200009 */ beqz $at, .L8007C51C -/* 07D0F8 8007C4F8 01003025 */ move $a2, $t0 -/* 07D0FC 8007C4FC 24050080 */ li $a1, 128 -/* 07D100 8007C500 AFA30020 */ sw $v1, 0x20($sp) -/* 07D104 8007C504 0C01C87A */ jal set_object_flag_status_false -/* 07D108 8007C508 AFA8001C */ sw $t0, 0x1c($sp) -/* 07D10C 8007C50C 8FA30020 */ lw $v1, 0x20($sp) -/* 07D110 8007C510 8FA6001C */ lw $a2, 0x1c($sp) -/* 07D114 8007C514 1000000A */ b .L8007C540 -/* 07D118 8007C518 A06600D2 */ sb $a2, 0xd2($v1) -.L8007C51C: -/* 07D11C 8007C51C 24050080 */ li $a1, 128 -/* 07D120 8007C520 AFA30020 */ sw $v1, 0x20($sp) -/* 07D124 8007C524 0C01C870 */ jal set_object_flag_status_true -/* 07D128 8007C528 AFA6001C */ sw $a2, 0x1c($sp) -/* 07D12C 8007C52C 8FA6001C */ lw $a2, 0x1c($sp) -/* 07D130 8007C530 8FA30020 */ lw $v1, 0x20($sp) -/* 07D134 8007C534 24090024 */ li $t1, 36 -/* 07D138 8007C538 01265023 */ subu $t2, $t1, $a2 -/* 07D13C 8007C53C A06A00D2 */ sb $t2, 0xd2($v1) -.L8007C540: -/* 07D140 8007C540 8FBF0014 */ lw $ra, 0x14($sp) -/* 07D144 8007C544 27BD0028 */ addiu $sp, $sp, 0x28 -/* 07D148 8007C548 03E00008 */ jr $ra -/* 07D14C 8007C54C 00000000 */ nop diff --git a/src/code_80091750.c b/src/code_80091750.c index 570c281ef5..cf08bb0842 100644 --- a/src/code_80091750.c +++ b/src/code_80091750.c @@ -2814,45 +2814,59 @@ Gfx *func_800959F8(Gfx *displayListHead, Vtx *arg1) { return displayListHead; } -#ifdef MIPS_TO_C -//generated by m2c commit eefca95b040d7ee0c617bc58f9ac6cd1cf7bce87 on Sep-01-2023 -void func_80095AE0(Mtx *arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) { - s32 sp14; - s32 sp10; - s32 spC; - s32 sp8; - Mtx *var_v1; - s32 var_v0; +typedef struct { + u16 i[4][4]; + u16 f[4][4]; +} Mtx_u; + +typedef union { + Mtx_u u; + Mtx_t m; + long long int force_structure_alignment; +} Mtx2; + +typedef union { + s16 s[2]; + s32 w; +} TheWhyUnion; + +// Why... Why... Why... This function is so bad it's not going in the header. +void func_80095AE0(Mtx2 *arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) { + TheWhyUnion sp14; + TheWhyUnion sp10; + TheWhyUnion spC; + TheWhyUnion sp8; + s32 i; - var_v0 = 0; - var_v1 = arg0; - do { - var_v0 += 4; - var_v1->m[0][0] = 0; - var_v1->m[0][1] = 0; - var_v1->m[0][2] = 0; - var_v1->m[0][3] = 0; - var_v1 += 0x10; - } while (var_v0 != 0x10); - sp14 = (s32) (arg3 * 65536.0f); - sp10 = (s32) (arg4 * 65536.0f); - spC = (s32) (arg1 * 65536.0f); - sp8 = (s32) (arg2 * 65536.0f); - arg0->unk0 = (s16) sp14.unk0; - arg0->unk14 = 1; - arg0->unkA = (s16) sp10.unk0; - arg0->unk18 = (s16) spC.unk0; - arg0->unk1E = 1; - arg0->unk1A = (s16) sp8.unk0; - arg0->unk20 = (s16) sp14.unk2; - arg0->unk2A = (s16) sp10.unk2; - arg0->unk38 = (s16) spC.unk2; - arg0->unk3A = (s16) sp8.unk2; -} + +#ifdef AVOID_UB + for (int row = 0; row < 4; row++) { + for (int col = 0; col < 4; col++) { + arg0->m[row][col] = 0; + } + } #else -GLOBAL_ASM("asm/non_matchings/code_80091750/func_80095AE0.s") + for(i = 0; i < 16; i++) {\ + arg0->m[0][i] = 0; + } #endif + sp14.w = arg3 * 65536.0f; + sp10.w = arg4 * 65536.0f; + spC.w = arg1 * 65536.0f; + sp8.w = arg2 * 65536.0f; + arg0->u.i[0][0] = sp14.s[0]; + arg0->u.i[1][1] = sp10.s[0]; + arg0->u.i[2][2] = 1; + arg0->u.i[3][0] = spC.s[0]; + arg0->u.i[3][1] = sp8.s[0]; + arg0->u.i[3][3] = 1; + arg0->u.f[0][0] = sp14.s[1]; + arg0->u.f[1][1] = sp10.s[1]; + arg0->u.f[3][0] = spC.s[1]; + arg0->u.f[3][1] = sp8.s[1]; +} + Gfx *func_80095BD0(Gfx *displayListHead, u8 *arg1, f32 arg2, f32 arg3, u32 arg4, u32 arg5, f32 arg6, f32 arg7) { Vtx *var_a1; Mtx *sp28; diff --git a/src/code_80091750.h b/src/code_80091750.h index 631bc06325..98e145aa41 100644 --- a/src/code_80091750.h +++ b/src/code_80091750.h @@ -155,7 +155,6 @@ Gfx *draw_flash_select_case(Gfx*, s32, s32, s32, s32, s32); Gfx *draw_flash_select_case_slow(Gfx*, s32, s32, s32, s32); Gfx *draw_flash_select_case_fast(Gfx*, s32, s32, s32, s32); Gfx *func_800959F8(Gfx*, Vtx*); -void func_80095AE0(Mtx*, f32, f32, f32, f32); Gfx *func_80095BD0(Gfx*, u8*, f32, f32, u32, u32, f32, f32); Gfx *func_80095E10(Gfx*, s8, s32, s32, s32, s32, s32, s32, s32, s32, u8 *, u32, u32); Gfx *func_800963F0(Gfx*, s8, s32, s32, f32, f32, s32, s32, s32, s32, s32, s32, u8 *, u32, u32); diff --git a/src/update_objects.c b/src/update_objects.c index 439fdb03f0..d4572e5a03 100644 --- a/src/update_objects.c +++ b/src/update_objects.c @@ -4186,32 +4186,19 @@ UNUSED void func_8007C49C(void) { } -#ifdef NON_MATCHING -// https://decomp.me/scratch/IH8Vx -// No idea what the source of the diff is void func_8007C4A4(s32 objectIndex) { - s32 temp_t8; - s32 var_t1; + u16 var_t9; - temp_t8 = gObjectList[objectIndex].direction_angle[1] * 0x24; - var_t1 = temp_t8 >> 0x10; - if (temp_t8 < 0) { - var_t1 = temp_t8 + 0xFFFF; - var_t1 >>= 0x10; - } - var_t1 &= 0xFFFF; - if (var_t1 < 0x13) { - set_object_flag_status_false(objectIndex, 0x80); - gObjectList[objectIndex].itemDisplay = var_t1; - } - else { - set_object_flag_status_true(objectIndex, 0x80); - gObjectList[objectIndex].itemDisplay = 0x24 - var_t1; + var_t9 = gObjectList[objectIndex].unk_0BE[1] * 0x24 / 0x10000; + + if (var_t9 < 0x13) { + set_object_flag_unk_054_false(objectIndex, 0x80); + gObjectList[objectIndex].itemDisplay = var_t9; + } else { + set_object_flag_unk_054_true(objectIndex, 0x80); + gObjectList[objectIndex].itemDisplay = 0x24 - var_t9; } } -#else -GLOBAL_ASM("asm/non_matchings/update_objects/func_8007C4A4.s") -#endif void func_8007C550(s32 objectIndex) { gObjectList[objectIndex].direction_angle[1] = func_800417B4(gObjectList[objectIndex].direction_angle[1], atan2s(gObjectList[objectIndex].velocity[0], gObjectList[objectIndex].velocity[2]));