From d65aa8729d28958087a395a88e5001588c6b067e Mon Sep 17 00:00:00 2001 From: Tyler McGavran Date: Fri, 19 Apr 2024 22:06:26 -0400 Subject: [PATCH] Update some attempts (#595) * Update some attempts * Matched a func --- .../audio/external/func_800C1C88.s | 73 -- src/audio/external.c | 982 +++++++----------- src/audio/external.h | 12 +- src/code_80091750.c | 82 +- src/code_80091750.h | 7 +- src/save.c | 4 +- 6 files changed, 409 insertions(+), 751 deletions(-) delete mode 100644 asm/non_matchings/audio/external/func_800C1C88.s diff --git a/asm/non_matchings/audio/external/func_800C1C88.s b/asm/non_matchings/audio/external/func_800C1C88.s deleted file mode 100644 index 43c157a1c..000000000 --- a/asm/non_matchings/audio/external/func_800C1C88.s +++ /dev/null @@ -1,73 +0,0 @@ -glabel func_800C1C88 -/* 0C2888 800C1C88 3C098019 */ lui $t1, %hi(D_8018FB90) # $t1, 0x8019 -/* 0C288C 800C1C8C 2529FB90 */ addiu $t1, %lo(D_8018FB90) # addiu $t1, $t1, -0x470 -/* 0C2890 800C1C90 91220000 */ lbu $v0, ($t1) -/* 0C2894 800C1C94 240A003C */ li $t2, 60 -/* 0C2898 800C1C98 3C088019 */ lui $t0, %hi(D_8018EFD8) # $t0, 0x8019 -/* 0C289C 800C1C9C 004A0019 */ multu $v0, $t2 -/* 0C28A0 800C1CA0 2508EFD8 */ addiu $t0, %lo(D_8018EFD8) # addiu $t0, $t0, -0x1028 -/* 0C28A4 800C1CA4 27BDFFF0 */ addiu $sp, $sp, -0x10 -/* 0C28A8 800C1CA8 AFA40010 */ sw $a0, 0x10($sp) -/* 0C28AC 800C1CAC 240100FF */ li $at, 255 -/* 0C28B0 800C1CB0 03A06825 */ move $t5, $sp -/* 0C28B4 800C1CB4 AFA50014 */ sw $a1, 0x14($sp) -/* 0C28B8 800C1CB8 AFA60018 */ sw $a2, 0x18($sp) -/* 0C28BC 800C1CBC 304400FF */ andi $a0, $v0, 0xff -/* 0C28C0 800C1CC0 00007012 */ mflo $t6 -/* 0C28C4 800C1CC4 010E1821 */ addu $v1, $t0, $t6 -/* 0C28C8 800C1CC8 906F002A */ lbu $t7, 0x2a($v1) -/* 0C28CC 800C1CCC 51E10032 */ beql $t7, $at, .L800C1D98 -/* 0C28D0 800C1CD0 00001025 */ move $v0, $zero -/* 0C28D4 800C1CD4 008A0019 */ multu $a0, $t2 -/* 0C28D8 800C1CD8 3C0B8019 */ lui $t3, %hi(D_8018FB91) # $t3, 0x8019 -/* 0C28DC 800C1CDC 256BFB91 */ addiu $t3, %lo(D_8018FB91) # addiu $t3, $t3, -0x46f -/* 0C28E0 800C1CE0 91660000 */ lbu $a2, ($t3) -/* 0C28E4 800C1CE4 240C00FF */ li $t4, 255 -/* 0C28E8 800C1CE8 44802000 */ mtc1 $zero, $f4 -/* 0C28EC 800C1CEC 0000C012 */ mflo $t8 -/* 0C28F0 800C1CF0 01182821 */ addu $a1, $t0, $t8 -/* 0C28F4 800C1CF4 A0A60029 */ sb $a2, 0x29($a1) -/* 0C28F8 800C1CF8 00CA0019 */ multu $a2, $t2 -/* 0C28FC 800C1CFC 0000C812 */ mflo $t9 -/* 0C2900 800C1D00 01197021 */ addu $t6, $t0, $t9 -/* 0C2904 800C1D04 A1C2002A */ sb $v0, 0x2a($t6) -/* 0C2908 800C1D08 906F002A */ lbu $t7, 0x2a($v1) -/* 0C290C 800C1D0C A1620000 */ sb $v0, ($t3) -/* 0C2910 800C1D10 00A01025 */ move $v0, $a1 -/* 0C2914 800C1D14 31F800FF */ andi $t8, $t7, 0xff -/* 0C2918 800C1D18 030A0019 */ multu $t8, $t2 -/* 0C291C 800C1D1C A12F0000 */ sb $t7, ($t1) -/* 0C2920 800C1D20 0000C812 */ mflo $t9 -/* 0C2924 800C1D24 01197021 */ addu $t6, $t0, $t9 -/* 0C2928 800C1D28 A1CC0029 */ sb $t4, 0x29($t6) -/* 0C292C 800C1D2C 8FB80014 */ lw $t8, 0x14($sp) -/* 0C2930 800C1D30 8FAF0014 */ lw $t7, 0x14($sp) -/* 0C2934 800C1D34 8FAE0014 */ lw $t6, 0x14($sp) -/* 0C2938 800C1D38 27190004 */ addiu $t9, $t8, 4 -/* 0C293C 800C1D3C ACB90004 */ sw $t9, 4($a1) -/* 0C2940 800C1D40 ACAF0000 */ sw $t7, ($a1) -/* 0C2944 800C1D44 8FB90018 */ lw $t9, 0x18($sp) -/* 0C2948 800C1D48 25CF0008 */ addiu $t7, $t6, 8 -/* 0C294C 800C1D4C 8FB80018 */ lw $t8, 0x18($sp) -/* 0C2950 800C1D50 ACAF0008 */ sw $t7, 8($a1) -/* 0C2954 800C1D54 8FAF0018 */ lw $t7, 0x18($sp) -/* 0C2958 800C1D58 272E0004 */ addiu $t6, $t9, 4 -/* 0C295C 800C1D5C ACB8000C */ sw $t8, 0xc($a1) -/* 0C2960 800C1D60 ACAE0010 */ sw $t6, 0x10($a1) -/* 0C2964 800C1D64 25F80008 */ addiu $t8, $t7, 8 -/* 0C2968 800C1D68 93B90023 */ lbu $t9, 0x23($sp) -/* 0C296C 800C1D6C 93AE0013 */ lbu $t6, 0x13($sp) -/* 0C2970 800C1D70 8FAF0024 */ lw $t7, 0x24($sp) -/* 0C2974 800C1D74 A0AC002A */ sb $t4, 0x2a($a1) -/* 0C2978 800C1D78 ACB80014 */ sw $t8, 0x14($a1) -/* 0C297C 800C1D7C ACA70024 */ sw $a3, 0x24($a1) -/* 0C2980 800C1D80 E4A4001C */ swc1 $f4, 0x1c($a1) -/* 0C2984 800C1D84 A0B90028 */ sb $t9, 0x28($a1) -/* 0C2988 800C1D88 A0AE0030 */ sb $t6, 0x30($a1) -/* 0C298C 800C1D8C 10000002 */ b .L800C1D98 -/* 0C2990 800C1D90 ACAF0038 */ sw $t7, 0x38($a1) -/* 0C2994 800C1D94 00001025 */ move $v0, $zero -.L800C1D98: -/* 0C2998 800C1D98 01A0E825 */ move $sp, $t5 -/* 0C299C 800C1D9C 03E00008 */ jr $ra -/* 0C29A0 800C1DA0 25BD0010 */ addiu $sp, $t5, 0x10 diff --git a/src/audio/external.c b/src/audio/external.c index 97e9c085a..ac6f94545 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -333,6 +333,7 @@ s8 func_800C16E8(f32 arg0, f32 arg1, u8 cameraId) { } else { var_f2 = 100.0f; var_f14 = 200.0f; + if (1) { } var_f16 = 5.0f; var_f18 = 3.3333333f; } @@ -424,41 +425,37 @@ void func_800C19D0(u8 arg0, u8 arg1, u8 arg2) { } } -#ifdef MIPS_TO_C -//generated by m2c commit beb457dabfc7a01ec6540a5404a6a05097a13602 on Oct-16-2023 struct Unk_8018EFD8 *func_800C1C88(u8 arg0, Vec3f position, f32 *velocity, f32 *arg3, u8 arg4, u32 soundBits) { struct Unk_8018EFD8 *temp_a1; struct Unk_8018EFD8 *temp_v1; u8 temp_t7; + u8 why1; - temp_v1 = &D_8018EFD8[D_8018FB90]; - if (temp_v1->next != 0xFF) { - temp_a1 = &D_8018EFD8[D_8018FB90 & 0xFF]; - temp_a1->prev = D_8018FB91; - D_8018EFD8[D_8018FB91].next = D_8018FB90; - temp_t7 = temp_v1->next; - D_8018FB91 = D_8018FB90; - D_8018FB90 = temp_t7; - D_8018EFD8[temp_t7 & 0xFF].prev = 0xFF; - temp_a1->posY = position + 4; - temp_a1->posX = position; - temp_a1->posZ = position + 8; - temp_a1->velX = velocity; - temp_a1->velY = velocity + 4; - temp_a1->next = 0xFF; - temp_a1->velZ = velocity + 8; - temp_a1->unk24 = arg3; - temp_a1->unk18[1] = 0.0f; - temp_a1->cameraId = arg4; - temp_a1->unk30 = arg0; - temp_a1->soundBits = soundBits; - return temp_a1; + if (D_8018EFD8[D_8018FB90].next != 0xFF) { + why1 = D_8018FB90; + D_8018EFD8[why1].prev = D_8018FB91; + temp_a1 = &D_8018EFD8[D_8018FB90]; + D_8018EFD8[D_8018FB91].next = why1; + temp_t7 = temp_a1->next; + D_8018FB91 = why1; + D_8018FB90 = D_8018EFD8[D_8018FB90].next; + D_8018EFD8[D_8018FB90].prev = 0xFF; + D_8018EFD8[why1].posX = &position[0]; + D_8018EFD8[why1].posY = &position[1]; + D_8018EFD8[why1].posZ = &position[2]; + D_8018EFD8[why1].next = 0xFF; + D_8018EFD8[why1].velX = &velocity[0]; + D_8018EFD8[why1].velY = &velocity[1]; + D_8018EFD8[why1].velZ = &velocity[2]; + D_8018EFD8[why1].unk18[1] = 0.0f; + D_8018EFD8[why1].unk24 = arg3; + D_8018EFD8[why1].cameraId = arg4; + D_8018EFD8[why1].unk30 = arg0; + D_8018EFD8[why1].soundBits = soundBits; + return &D_8018EFD8[why1]; } return NULL; } -#else -GLOBAL_ASM("asm/non_matchings/audio/external/func_800C1C88.s") -#endif void func_800C1DA4(Camera *arg0, Vec3s rot, struct Unk_8018EFD8 *arg2) { f32 x; @@ -1018,263 +1015,172 @@ void func_800C36C4(u8 arg0, u8 arg1, u8 arg2, u8 arg3) { D_801930D0[arg0].unk_012 = 1; } -#ifdef MIPS_TO_C -//generated by m2c commit beb457dabfc7a01ec6540a5404a6a05097a13602 on Oct-17-2023 +#ifdef NON_MATCHING +//generated by m2c commit 1c7b040b356d06b5171add65d8ee527a500b156e on Apr-01-2024 void func_800C3724(void) { - f32 temp_f2; + u8 var_s5; f32 var_f0; - f32 var_f0_2; - f32 var_f16; - f32 var_f6; - f32 var_f8; - s32 temp_a0; - s32 temp_a1; - s32 temp_a3; - s32 temp_a3_2; - s32 temp_at; + u16 temp_a3_2; s32 temp_lo; s32 temp_s1; - s32 temp_t2_3; - s32 temp_t3; - s32 temp_t4_2; - s32 temp_t5_2; - s32 temp_t7; - s32 temp_t7_3; s32 temp_t9_2; - s32 temp_v1; - s32 var_a2; - s32 var_s0; - s32 var_s0_2; - s32 var_s2; - s32 var_s2_2; - s32 var_s5; - s32 var_t0; - struct SequencePlayer *temp_a1_2; - struct_D_801930D0_entry *temp_s0; - struct_D_801930D0_entry *temp_s0_2; - struct_D_801930D0_entry *temp_s0_3; - struct_D_801930D0_entry *temp_s3; - struct_D_801930D0_entry *temp_s4; - struct_D_801930D0_entry *temp_s4_2; - u16 temp_t2_2; - u16 temp_t4; - u16 temp_t5; - u16 temp_t7_2; - u16 temp_v0; - u16 temp_v0_2; - u16 temp_v0_3; - u16 temp_v1_2; - u16 temp_v1_3; + u16 var_a2; + u8 var_s2; + u8 var_t0; u32 temp_t5_3; - u32 temp_t9; - u32 temp_v0_5; u8 temp_a1_3; - u8 temp_t2; - u8 temp_v0_4; - u8 temp_v1_4; + s32 var_a1; + struct_D_801930D0_entry *temp_s0; + struct_D_801930D0_entry *temp_s2; + struct_D_801930D0_entry *temp_s4_2; - var_s5 = 0; - do { - temp_s3 = &D_801930D0[var_s5]; - if (temp_s3->unk_012 != 0) { + for (var_s5 = 0; var_s5 < 3; var_s5++) { + if (D_801930D0[var_s5].unk_012 != 0) { var_f0 = 1.0f; - var_s2 = 0; - do { - temp_t2 = D_801930D0[var_s5].unk_00E[var_s2]; - var_f6 = (f32) temp_t2; - if ((s32) temp_t2 < 0) { - var_f6 += 4294967296.0f; - } - temp_t3 = (var_s2 + 1) & 0xFF; - temp_at = temp_t3 < 3; - var_s2 = temp_t3; - var_f0 *= var_f6 / 127.0f; - } while (temp_at != 0); - func_800C3448((temp_s3->unk_011 << 0x10) | 0x40000000 | (var_s5 << 0x18) | ((u32) (var_f0 * 127.0f) & 0xFF)); - temp_s3->unk_012 = 0; + for (var_s2 = 0; var_s2 < 3; var_s2++) { + temp_s4_2 = &D_801930D0[var_s5]; + var_f0 *= temp_s4_2->unk_00E[var_s2] / 127.0f; + } + func_800C3448((D_801930D0[var_s5].unk_011 << 0x10) | 0x40000000 | ((var_s5 & 0xFF) << 0x18) | ((u32) (var_f0 * 127.0f) & 0xFF)); + D_801930D0[var_s5].unk_012 = 0; } - temp_v0 = temp_s3->unk_00C; - temp_t4 = temp_v0 - 1; - if (temp_v0 != 0) { - temp_s3->unk_00C = temp_t4; - if (temp_t4 & 0xFFFF) { - temp_s3->unk_000 -= temp_s3->unk_008; + if (D_801930D0[var_s5].unk_00C != 0) { + D_801930D0[var_s5].unk_00C--; + if (D_801930D0[var_s5].unk_00C) { + D_801930D0[var_s5].unk_000 -= D_801930D0[var_s5].unk_008; } else { - temp_s3->unk_000 = temp_s3->unk_004; + D_801930D0[var_s5].unk_000 = D_801930D0[var_s5].unk_004; } - func_800CBB88(((var_s5 & 0xFF) << 0x10) | 0x41000000, temp_s3->unk_000); + func_800CBB88(((var_s5 & 0xFF) << 0x10) | 0x41000000, D_801930D0[var_s5].unk_000); } - temp_a1 = temp_s3->unk_014; - if (temp_a1 != 0) { - temp_t9 = (u32) (temp_a1 & 0xFF0000) >> 0xF; - temp_a0 = temp_a1 & 0xFFF; - temp_a3 = temp_t9 & 0xFF; - var_t0 = temp_t9 & 0xFF; - var_a2 = temp_a0 & 0xFFFF; - if (temp_a3 == 0) { - var_t0 = (temp_a3 + 1) & 0xFF; + if (D_801930D0[var_s5].unk_014 != 0) { + var_t0 = (u32) (D_801930D0[var_s5].unk_014 & 0xFF0000) >> 0xF; + var_a1 = D_801930D0[var_s5].unk_014 & 0xFFF; + var_a2 = var_a1; + if (var_t0 == 0) { + var_t0++; } - temp_a1_2 = &gSequencePlayers[var_s5]; - if (((u32) temp_a1_2->unk0 >> 0x1F) != 0) { - temp_t9_2 = ((u32) (temp_a1 & 0xF000) >> 0xC) & 0xFF; - temp_lo = (s32) temp_a1_2->tempo / 48; - temp_a3_2 = temp_lo & 0xFFFF; - if (temp_t9_2 != 1) { - temp_v1 = temp_a0 & 0xFFFF; - switch (temp_t9_2) { /* switch 1; irregular */ - case 2: /* switch 1 */ - if (temp_v1 < temp_a3_2) { - var_a2 = (temp_a3_2 - temp_v1) & 0xFFFF; - } - break; - case 3: /* switch 1 */ - var_f16 = (f32) temp_a3_2; - if (temp_a3_2 < 0) { - var_f16 += 4294967296.0f; - } - var_a2 = (u32) (var_f16 * ((f32) (temp_a0 & 0xFFFF) / 100.0f)) & 0xFFFF; - break; - case 4: /* switch 1 */ - temp_v0_2 = temp_s3->unk_018; - var_a2 = temp_a3_2 & 0xFFFF; - if (temp_v0_2 != 0) { - var_a2 = temp_v0_2 & 0xFFFF; - } - break; - } - } else { - var_a2 = (temp_a0 + temp_a3_2) & 0xFFFF; + if (gSequencePlayers[var_s5 & 0xFF].enabled != 0) { + temp_lo = (s32) gSequencePlayers[var_s5 & 0xFF].tempo / TATUMS_PER_BEAT; + temp_a3_2 = temp_lo; + temp_t9_2 = ((D_801930D0[var_s5].unk_014 & 0xF000) >> 0xC) & 0xFF; + switch (temp_t9_2) { /* switch 1; irregular */ + case 1: + var_a2 += temp_a3_2; + break; + case 2: /* switch 1 */ + if (var_a1 < temp_a3_2) { + var_a2 = (temp_a3_2 - var_a1); + } + break; + case 3: /* switch 1 */ + var_a2 = (u32) (temp_a3_2 * ((f32) (var_a1 & 0xFFFF) / 100.0f)); + break; + case 4: /* switch 1 */ + if (D_801930D0[var_s5].unk_018 != 0) { + var_a2 = D_801930D0[var_s5].unk_018; + } else { + var_a2 = temp_a3_2; + } + break; } - temp_f2 = (f32) temp_lo; if (var_a2 >= 0x12D) { var_a2 = 0x12C; } - if (temp_s3->unk_018 == 0) { - temp_s3->unk_018 = (u16) temp_a3_2; + if (D_801930D0[var_s5].unk_018 == 0) { + D_801930D0[var_s5].unk_018 = temp_a3_2; } - var_f0_2 = (f32) var_a2; - if (var_a2 < 0) { - var_f0_2 += 4294967296.0f; - } - temp_s3->unk_020 = (bitwise s32) var_f0_2; - temp_s3->unk_01C = (bitwise s32) temp_f2; - var_f8 = (f32) var_t0; - if (var_t0 < 0) { - var_f8 += 4294967296.0f; - } - temp_s3->unk_028 = (u16) var_t0; - temp_s3->unk_024 = (bitwise s32) ((temp_f2 - var_f0_2) / var_f8); + D_801930D0[var_s5].unk_020 = var_a2; + D_801930D0[var_s5].unk_01C = temp_lo; + D_801930D0[var_s5].unk_024 = (D_801930D0[var_s5].unk_01C - D_801930D0[var_s5].unk_020) / var_t0; + D_801930D0[var_s5].unk_028 = (u16) var_t0; } - temp_s3->unk_014 = 0; + D_801930D0[var_s5].unk_014 = 0; } - temp_v0_3 = temp_s3->unk_028; - temp_t7_2 = temp_v0_3 - 1; - if (temp_v0_3 != 0) { - temp_s3->unk_028 = temp_t7_2; - if (temp_t7_2 & 0xFFFF) { - temp_s3->unk_01C = (bitwise s32) ((bitwise f32) temp_s3->unk_01C - (bitwise f32) temp_s3->unk_024); + if (D_801930D0[var_s5].unk_028 != 0) { + D_801930D0[var_s5].unk_028--; + if (D_801930D0[var_s5].unk_028) { + D_801930D0[var_s5].unk_01C -= D_801930D0[var_s5].unk_024; } else { - temp_s3->unk_01C = temp_s3->unk_020; + D_801930D0[var_s5].unk_01C = D_801930D0[var_s5].unk_020; } - func_800CBBB8(((var_s5 & 0xFF) << 0x10) | 0x47000000, (u32) (s32) temp_s3->unk_01C); + func_800CBBB8(((var_s5 & 0xFF) << 0x10) | 0x47000000, (u32) (s32) D_801930D0[var_s5].unk_01C); } - if (temp_s3->unk_246 != 0) { - temp_s4 = &D_801930D0[var_s5]; - var_s0 = 0; - do { - temp_v1_2 = temp_s4->unk_044[var_s0].unk_0C; - temp_t5 = temp_v1_2 - 1; - if (temp_v1_2 != 0) { - temp_s4->unk_044[var_s0].unk_0C = temp_t5; - if (temp_t5 & 0xFFFF) { - temp_s4->unk_044[var_s0].unk_00 -= temp_s4->unk_044[var_s0].unk_08; + if (D_801930D0[var_s5].unk_246 != 0) { + for (var_s2 = 0; var_s2 < 0x10; var_s2++) { + temp_s4_2 = &D_801930D0[var_s5]; + if (temp_s4_2->unk_044[var_s2].unk_0C != 0) { + temp_s4_2->unk_044[var_s2].unk_0C--; + if (temp_s4_2->unk_044[var_s2].unk_0C) { + temp_s4_2->unk_044[var_s2].unk_00 -= temp_s4_2->unk_044[var_s2].unk_08; } else { - temp_s3->unk_044[var_s0].unk_00 = temp_s3->unk_044[var_s0].unk4; - temp_s3->unk_246 ^= 1 << var_s0; + temp_s4_2->unk_044[var_s2].unk_00 = temp_s4_2->unk_044[var_s2].unk_04; + temp_s4_2->unk_246 ^= 1 << var_s2; } - func_800CBB88(((var_s5 & 0xFF) << 0x10) | 0x01000000 | ((var_s0 & 0xFF) << 8), temp_s4->unk_044[var_s0].unk_00); + func_800CBB88(((var_s5 & 0xFF) << 0x10) | 0x01000000 | ((var_s2 & 0xFF) << 8), temp_s4_2->unk_044[var_s2].unk_00); } - temp_t7_3 = (var_s0 + 1) & 0xFF; - var_s0 = temp_t7_3; - } while (temp_t7_3 < 0x10); + } } - if (temp_s3->unk_244 != 0) { - temp_s4_2 = &D_801930D0[var_s5]; - var_s0_2 = 0; - do { - temp_v1_3 = temp_s4_2->unk_044[var_s0_2].unk_1C; - temp_t2_2 = temp_v1_3 - 1; - if (temp_v1_3 != 0) { - temp_s4_2->unk_044[var_s0_2].unk_1C = temp_t2_2; - if (temp_t2_2 & 0xFFFF) { - temp_s4_2->unk_044[var_s0_2].unk_10 -= temp_s4_2->unk_044[var_s0_2].unk_18; + if (D_801930D0[var_s5].unk_244 != 0) { + for (var_s2 = 0; var_s2 < 0x10; var_s2++) { + temp_s4_2 = &D_801930D0[var_s5]; + if (temp_s4_2->unk_044[var_s2].unk_1C != 0) { + temp_s4_2->unk_044[var_s2].unk_1C--; + if (temp_s4_2->unk_044[var_s2].unk_1C) { + temp_s4_2->unk_044[var_s2].unk_10 -= temp_s4_2->unk_044[var_s2].unk_18; } else { - temp_s3->unk_044[var_s0_2].unk_10 = temp_s3->unk_044[var_s0_2].unk14; - temp_s3->unk_244 ^= 1 << var_s0_2; + temp_s4_2->unk_044[var_s2].unk_10 = temp_s4_2->unk_044[var_s2].unk_14; + temp_s4_2->unk_244 ^= 1 << var_s2; } - func_800CBB88(((var_s5 & 0xFF) << 0x10) | 0x04000000 | ((var_s0_2 & 0xFF) << 8), temp_s4_2->unk_044[var_s0_2].unk_10); + func_800CBB88(((var_s5 & 0xFF) << 0x10) | 0x04000000 | ((var_s2 & 0xFF) << 8), temp_s4_2->unk_044[var_s2].unk_10); } - temp_t4_2 = (var_s0_2 + 1) & 0xFF; - var_s0_2 = temp_t4_2; - } while (temp_t4_2 < 0x10); + } } - temp_v0_4 = temp_s3->unk_041; - if (temp_v0_4 != 0) { - temp_v1_4 = temp_s3->unk_040; - if (temp_v1_4 != 0) { - temp_s3->unk_040 = temp_v1_4 - 1; + if (D_801930D0[var_s5].unk_041 != 0) { + if (D_801930D0[var_s5].unk_040 != 0) { + D_801930D0[var_s5].unk_040--; } else { - var_s2_2 = 0; - if (((u32) gSequencePlayers[var_s5].unk0 >> 0x1F) == 0) { - if ((s32) temp_v0_4 > 0) { - do { - temp_v0_5 = D_801930D0[var_s5].unk_02C[var_s2_2]; - temp_t5_3 = ((u32) (temp_v0_5 & 0xF00000) >> 0x14) & 0xFF; - temp_t2_3 = temp_v0_5 & 0xFF; - temp_s1 = ((u32) (temp_v0_5 & 0xF0000) >> 0x10) & 0xFF; - temp_a1_3 = ((u32) (temp_v0_5 & 0xFF00) >> 8) & 0xFF; - switch (temp_t5_3) { - case 0: - temp_s0 = &D_801930D0[temp_s1]; - temp_s0->unk_012 = 1; - temp_s0->unk_00E[1] = 0x7F; - break; - case 1: - func_800C3448(temp_s3->unk_248 | 0x30000000 | (var_s5 << 0x18)); - break; - case 2: - temp_s0_2 = &D_801930D0[temp_s1]; - func_800C3448(temp_s0_2->unk_248 | (temp_s1 << 0x18) | 0x10000); - temp_s0_2->unk_012 = 1; - temp_s0_2->unk_00E[1] = 0x7F; - break; - case 3: - func_800C3448((temp_s1 << 0x18) | 0xB0003000 | (temp_a1_3 << 0x10) | temp_t2_3); - break; - case 4: - func_800C3448((temp_s1 << 0x18) | 0xB0004000 | (temp_t2_3 << 0x10)); - break; - case 5: - temp_s0_3 = &D_801930D0[temp_s1]; - func_800C3448((temp_s0_3->unk_042 << 0x10) | (temp_s1 << 0x18) | (temp_v0_5 & 0xFFFF)); - func_800C36C4(temp_s1 & 0xFF, 1U, 0x7FU, 0U); - temp_s0_3->unk_042 = 0; - break; - case 6: - temp_s3->unk_042 = temp_a1_3; - break; - } - temp_t5_2 = (var_s2_2 + 1) & 0xFF; - var_s2_2 = temp_t5_2; - } while (temp_t5_2 < (s32) temp_s3->unk_041); + if (gSequencePlayers[var_s5].enabled == 0) { + for (var_s2 = 0; var_s2 < D_801930D0[var_s5].unk_041; var_s2++) { + temp_s4_2 = &D_801930D0[var_s5]; + var_a1 = temp_s4_2->unk_02C[var_s2] & 0xFF; + temp_t5_3 = ((u32) (temp_s4_2->unk_02C[var_s2] & 0xF00000) >> 0x14) & 0xFF; + temp_s1 = ((u32) (temp_s4_2->unk_02C[var_s2] & 0xF0000) >> 0x10) & 0xFF; + temp_a1_3 = ((u32) (temp_s4_2->unk_02C[var_s2] & 0xFF00) >> 8) & 0xFF; + switch (temp_t5_3) { + case 0: + D_801930D0[temp_s1].unk_012 = 1; + D_801930D0[temp_s1].unk_00E[1] = 0x7F; + break; + case 1: + func_800C3448(temp_s4_2->unk_248 | 0x30000000 | (var_s5 << 0x18)); + break; + case 2: + func_800C3448(D_801930D0[temp_s1].unk_248 | (temp_s1 << 0x18) | 0x10000); + D_801930D0[temp_s1].unk_012 = 1; + D_801930D0[temp_s1].unk_00E[1] = 0x7F; + break; + case 3: + func_800C3448((temp_s1 << 0x18) | 0xB0003000 | (temp_a1_3 << 0x10) | var_a1); + break; + case 4: + func_800C3448((temp_s1 << 0x18) | 0xB0004000 | (var_a1 << 0x10)); + break; + case 5: + func_800C3448((D_801930D0[temp_s1].unk_042 << 0x10) | (temp_s1 << 0x18) | (temp_s4_2->unk_02C[var_s2] & 0xFFFF)); + func_800C36C4(temp_s1 & 0xFF, 1U, 0x7FU, 0U); + D_801930D0[temp_s1].unk_042 = 0; + break; + case 6: + temp_s4_2->unk_042 = temp_a1_3; + break; + } } - temp_s3->unk_041 = 0; + D_801930D0[var_s5].unk_041 = 0; } } } - temp_t7 = (var_s5 + 1) & 0xFF; - var_s5 = temp_t7; - } while (temp_t7 < 3); + } } #else #ifdef VERSION_EU @@ -1346,7 +1252,7 @@ void func_800C40F0(u8 arg0) { } } -void play_sound(u32 soundBits, Vec3f *position, u8 cameraId, f32 *arg3, f32 *arg4, u8 *arg5) { +void play_sound(u32 soundBits, Vec3f *position, u8 cameraId, f32 *arg3, f32 *arg4, s8 *arg5) { u8 bank; struct Sound *temp_v0; @@ -1413,152 +1319,85 @@ void func_800C41CC(u8 arg0, struct SoundCharacteristics *arg1) { } // Probably a variant of `process_sound_request` from SM64 -#ifdef MIPS_TO_C -//generated by m2c commit beb457dabfc7a01ec6540a5404a6a05097a13602 on Oct-18-2023 +#ifdef NON_MATCHING +// https://decomp.me/scratch/fmmyb +// Stack issue concerning `var_t2` and `var_t3`, no idea how to fix it void func_800C4398(void) { - u8 sp4F; - u8 sp4D; - struct Sound *sp48; - u8 sp43; - u32 sp3C; - struct SoundCharacteristics *sp30; - f32 *temp_v0_3; - struct Sound *var_a2; - struct SoundCharacteristics *temp_s0; - struct SoundCharacteristics *temp_s0_2; - struct SoundCharacteristics *temp_s0_3; - struct SoundCharacteristics *temp_t0; - struct SoundCharacteristics *temp_t1; - struct SoundCharacteristics *var_t1; - u32 temp_a1; - u32 temp_a1_2; - u32 temp_v0; - u32 var_t3; - u8 *temp_a3; - u8 *temp_v0_2; - u8 temp_a0; - u8 temp_a0_2; - u8 temp_a1_3; - u8 temp_t6; - u8 temp_t6_2; - u8 temp_v1; + u8 bank; + u8 soundIndex; u8 var_a3; + struct Sound *var_a2; u8 var_t2; - u8 var_t5; - u8 var_v0; - u8 var_v0_2; - u8 var_v1; + u32 var_t3; var_a2 = &sSoundRequests[sNumProcessedSoundRequests]; - temp_a1 = var_a2->soundBits; - if (temp_a1 != 0) { - temp_t6 = ((u32) (temp_a1 & 0xF0000000) >> 0x1C) & 0xFF; - var_v1 = sSoundBanks[temp_t6]->next; - var_t5 = temp_t6; - var_a3 = 0; - var_v0 = var_v1; - if ((var_v1 != 0xFF) && (var_v1 != 0)) { - var_t1 = sSoundBanks[temp_t6]; - var_t3 = sp3C; - var_t2 = sp43; -loop_4: - temp_s0 = &var_t1[var_v1]; - if (var_a2->position == temp_s0->unk00) { - temp_a1_2 = var_a2->soundBits; - temp_v0 = temp_s0->soundBits; - temp_a0 = (*D_800EA1A0)[(D_800EA1C0 * 6) + var_t5]; - if (temp_a1_2 == temp_v0) { - var_a3 = temp_a0 & 0xFF; - var_v0_2 = var_a3; - } else { - if (var_a3 == 0) { - var_t2 = var_v1 & 0xFF; - goto block_11; - } - if ((u32) (temp_v0 & 0xFF00) < (u32) (var_t3 & 0xFF00)) { - var_t2 = var_v1 & 0xFF; -block_11: - var_t3 = temp_v0; - } - var_v0_2 = (var_a3 + 1) & 0xFF; - var_a3 = var_v0_2; - if (var_v0_2 == temp_a0) { - var_v1 = 0; - if ((u32) (temp_a1_2 & 0xFF00) >= (u32) (var_t3 & 0xFF00)) { - var_v1 = var_t2 & 0xFF; - } - } + if (var_a2->soundBits == 0) return; + + bank = ((u32) (var_a2->soundBits & 0xF0000000) >> 0x1C); + soundIndex = sSoundBanks[bank][0].next; + var_a3 = 0; + while ((soundIndex != 0xFF) && (soundIndex != 0)) { + if (var_a2->position == sSoundBanks[bank][soundIndex].unk00) { + if (var_a2->soundBits == sSoundBanks[bank][soundIndex].soundBits) { + var_a3 = D_800EA1A0[D_800EA1C0][bank]; + } else { + if (var_a3 == 0) { + var_t2 = soundIndex; + var_t3 = sSoundBanks[bank][soundIndex].soundBits; + } else if ((u32) (sSoundBanks[bank][soundIndex].soundBits & 0xFF00) < (u32) (var_t3 & 0xFF00)) { + var_t2 = soundIndex; + var_t3 = sSoundBanks[bank][soundIndex].soundBits; } - if (var_v0_2 == temp_a0) { - if ((temp_a1_2 & 0x08000000) || (temp_a1_2 & 0x40000) || (var_t2 == var_v1)) { - temp_s0_2 = &var_t1[var_v1]; - if ((temp_s0_2->soundBits & 0x80000) && (temp_s0_2->soundStatus != 1)) { - sp4F = var_t5; - sp3C = var_t3; - sp43 = var_t2; - sp30 = var_t1; - sp4D = var_a3; - sp48 = var_a2; - func_800C40F0(temp_s0_2->unk2C); - } - temp_s0_2->cameraId = var_a2->cameraId; - temp_s0_2->soundBits = var_a2->soundBits; - temp_s0_2->freshness = 2; - temp_s0_2->soundStatus = (u8) ((u32) (var_a2->soundBits & 0x01000000) >> 0x18); - temp_s0_2->unk10 = var_a2->unk0C; - temp_s0_2->unk14 = var_a2->unk10; - temp_s0_2->unk18 = (s8 *) var_a2->unk14; + var_a3++; + if (var_a3 == D_800EA1A0[D_800EA1C0][bank]) { + if ((u32) (var_a2->soundBits & 0xFF00) >= (u32) (var_t3 & 0xFF00)) { + soundIndex = var_t2; + } else { + soundIndex = 0; } - var_v1 = 0; } } - var_v0 = var_v1; - if (var_v1 != 0) { - var_v1 = var_t1[var_v1].next; - var_v0 = var_v1; - } - if (var_v0 != 0xFF) { - if (var_v0 == 0) { - sp3C = var_t3; - sp43 = var_t2; - } else { - goto loop_4; + if (var_a3 == D_800EA1A0[D_800EA1C0][bank]) { + if ((var_a2->soundBits & 0x08000000) || (var_a2->soundBits & 0x40000) || (soundIndex == var_t2)) { + if ((sSoundBanks[bank][soundIndex].soundBits & 0x80000) && (sSoundBanks[bank][soundIndex].soundStatus != 1)) { + func_800C40F0(sSoundBanks[bank][soundIndex].unk2C); + } + sSoundBanks[bank][soundIndex].cameraId = var_a2->cameraId; + sSoundBanks[bank][soundIndex].soundBits = var_a2->soundBits; + sSoundBanks[bank][soundIndex].soundStatus = ((var_a2->soundBits & 0x01000000) >> 0x18); + sSoundBanks[bank][soundIndex].freshness = 2; + sSoundBanks[bank][soundIndex].unk10 = var_a2->unk0C; + sSoundBanks[bank][soundIndex].unk14 = var_a2->unk10; + sSoundBanks[bank][soundIndex].unk18 = var_a2->unk14; } + soundIndex = 0; } } - temp_a3 = &sSoundBankFreeListFront[var_t5]; - temp_a1_3 = *temp_a3; - temp_t1 = sSoundBanks[var_t5]; - temp_t0 = &temp_t1[temp_a1_3]; - temp_v1 = temp_t0->next; - if ((temp_v1 != 0xFF) && (var_v0 != 0)) { - temp_s0_3 = &temp_t1[temp_a1_3 & 0xFF]; - temp_s0_3->unk00 = var_a2->position; - temp_s0_3->unk04 = var_a2->position + 4; - temp_s0_3->unk08 = var_a2->position + 8; - temp_s0_3->cameraId = var_a2->cameraId; - temp_s0_3->unk10 = var_a2->unk0C; - temp_s0_3->unk14 = var_a2->unk10; - temp_s0_3->unk18 = (s8 *) var_a2->unk14; - temp_s0_3->soundBits = var_a2->soundBits; - temp_s0_3->freshness = 2; - temp_v0_2 = &sSoundBankUsedListBack[var_t5]; - temp_a0_2 = *temp_v0_2; - temp_s0_3->soundStatus = (u8) ((u32) (var_a2->soundBits & 0x01000000) >> 0x18); - temp_s0_3->prev = temp_a0_2; - temp_t1[temp_a0_2].next = temp_a1_3; - temp_t6_2 = temp_t0->next; - *temp_v0_2 = temp_a1_3; - *temp_a3 = temp_t6_2; - temp_t1[temp_t6_2 & 0xFF].prev = 0xFF; - temp_s0_3->next = 0xFF; - return; + if (soundIndex != 0) { + soundIndex = sSoundBanks[bank][soundIndex].next; } - if (temp_v1 == 0xFF) { - temp_v0_3 = var_a2->position; - if (D_800EA1C8 != temp_v0_3) { - temp_v0_3->unk4 = 100000.0f; - } + } + if ((sSoundBanks[bank][sSoundBankFreeListFront[bank]].next != 0xFF) && (soundIndex != 0)) { + soundIndex = sSoundBankFreeListFront[bank]; + sSoundBanks[bank][soundIndex].unk00 = &(*var_a2->position)[0]; + sSoundBanks[bank][soundIndex].unk04 = &(*var_a2->position)[1]; + sSoundBanks[bank][soundIndex].unk08 = &(*var_a2->position)[2]; + sSoundBanks[bank][soundIndex].cameraId = var_a2->cameraId; + sSoundBanks[bank][soundIndex].unk10 = var_a2->unk0C; + sSoundBanks[bank][soundIndex].unk14 = var_a2->unk10; + sSoundBanks[bank][0, soundIndex].unk18 = var_a2->unk14; + sSoundBanks[bank][soundIndex].soundBits = var_a2->soundBits; + sSoundBanks[bank][soundIndex].soundStatus = (u8) ((u32) (var_a2->soundBits & 0x01000000) >> 0x18); + sSoundBanks[bank][soundIndex].freshness = 2; + sSoundBanks[bank][soundIndex].prev = sSoundBankUsedListBack[bank]; + sSoundBanks[bank][sSoundBankUsedListBack[bank]].next = sSoundBankFreeListFront[bank]; + sSoundBankUsedListBack[bank] = sSoundBankFreeListFront[bank]; + sSoundBankFreeListFront[bank] = sSoundBanks[bank][sSoundBankFreeListFront[bank]].next; + sSoundBanks[bank][sSoundBankFreeListFront[bank]].prev = 0xFF; + sSoundBanks[bank][soundIndex].next = 0xFF; + } else if (sSoundBanks[bank][sSoundBankFreeListFront[bank]].next == 0xFF) { + if (D_800EA1C8 != *var_a2->position) { + (*var_a2->position)[1] = 100000.0f; } } } @@ -1589,264 +1428,151 @@ void delete_sound_from_bank(u8 bankId, u8 soundId) { } // Guessing this is `select_current_sounds`? -#ifdef MIPS_TO_C -//generated by m2c commit beb457dabfc7a01ec6540a5404a6a05097a13602 on Oct-17-2023 +#ifdef NON_MATCHING +// https://decomp.me/scratch/cqBii +struct why { + u32 priority; + u8 soundIndex; +}; void func_800C4888(u8 bankId) { - u8 spCE; - u8 spCC; - ? sp7C; - struct_D_80192AB8_entry *sp70; - struct SoundCharacteristics *sp6C; - struct SoundCharacteristics *sp68; - s32 sp60; - f32 *temp_v0; - f32 temp_f0; - f32 temp_f0_2; - f32 temp_f2; - f32 var_f0; - s32 temp_a2; - s32 temp_at; - s32 temp_s5; - s32 temp_t6; - s32 temp_t6_2; - s32 temp_t7; - s32 temp_t7_2; - s32 temp_t7_3; - s32 temp_t8; - s32 temp_t8_3; - s32 temp_t8_4; - s32 temp_t9; - s32 temp_v0_3; - s32 temp_v0_4; - s32 temp_v0_5; - s32 var_a1; - s32 var_a1_2; - s32 var_a1_3; - s32 var_s0; - s32 var_s0_2; - s32 var_s2; - s32 var_t3; - s32 var_t3_2; - s32 var_t3_3; - s32 var_v1; - struct SoundCharacteristics *temp_a0_2; - struct SoundCharacteristics *temp_t2; - struct SoundCharacteristics *temp_v0_7; - struct_D_80192AB8_entry *temp_s3; - struct_D_80192AB8_entry *var_a2; - u32 temp_t8_2; - u32 temp_v0_2; - u8 temp_a1; - u8 temp_a3_3; - u8 temp_a3_4; - u8 temp_t4; - u8 temp_v1; - u8 var_s3; - u8 var_t0; + u8 i; + u8 j; + u8 k; + u8 latestSoundIndex; + u8 var_s2; + u8 var_v1; + u8 soundIndex; u8 var_t1; - u8 var_t2; - u8 var_v1_2; - void *temp_a0; - void *temp_a0_3; - void *temp_a0_4; - void *temp_a3; - void *temp_a3_2; - void *temp_v0_6; + u8 someTemp; + f32 var_f0; + s32 requestedPriority; + struct why sp7C[8]; + s32 temp_t8; + struct SoundCharacteristics *temp_t2; - temp_s5 = bankId & 0xFF; var_s2 = 0; - var_t3 = 0; - do { - temp_t7 = (var_t3 + 1) & 0xFF; - temp_at = temp_t7 < 8; - temp_a3 = &sp7C + (var_t3 * 8); - var_t3 = temp_t7; - temp_a3->unk0 = 0x7FFFFFFF; - temp_a3->unk4 = 0xFFU; - } while (temp_at != 0); - var_s3 = sSoundBanks[temp_s5]->next; - var_s0 = 0; - if (var_s3 != 0xFF) { - sp6C = sSoundBanks[temp_s5]; - do { - temp_t2 = &sp6C[var_s3]; - if ((temp_t2->soundStatus == 1) && ((temp_t2->soundBits & 0x08000000) == 0x08000000)) { - temp_t2->freshness -= 1; - } - if (temp_t2->freshness == 0) { - delete_sound_from_bank(temp_s5 & 0xFF, var_s3 & 0xFF); - } else if (temp_t2->soundStatus != 0) { - temp_v0 = temp_t2->unk00; - if (D_800EA1C8 == temp_v0) { - temp_t2->distance = 0.0f; - } else { - temp_f2 = *temp_v0; - temp_f0 = *temp_t2->unk08; - temp_t2->distance = (temp_f0 * temp_f0) + (temp_f2 * temp_f2); - } - temp_v0_2 = temp_t2->soundBits; - temp_t8 = ((u32) (temp_v0_2 & 0xFF00) >> 8) & 0xFF; - if (temp_v0_2 & 0x100000) { - temp_v0_3 = 0xFFU - temp_t8; - temp_t2->priority = temp_v0_3 * temp_v0_3 * 0x5A4; - } else { - temp_v0_4 = 0xFFU - temp_t8; - temp_t8_2 = (u32) temp_t2->distance + (temp_v0_4 * temp_v0_4 * 0x5A4); - temp_t2->priority = temp_t8_2; - temp_f0_2 = *temp_t2->unk08; - if (temp_f0_2 > 0.0f) { - temp_t2->priority = temp_t8_2 + (s32) (temp_f0_2 * 6.0f); - } - } - temp_t8_3 = ((u32) (temp_t2->soundBits & 0x30000) >> 0x10) & 0xFF; - if (temp_t8_3 != 0) { - var_f0 = 4000000.0f / (f32) (temp_t8_3 * temp_t8_3); - } else { - var_f0 = 1e10f; - } - if (var_f0 < temp_t2->distance) { - if (temp_t2->soundStatus == 4) { - sp68 = temp_t2; - func_800CBBE8((temp_t2->unk2C << 8) | 0x06020000, 0); - if (temp_t2->soundBits & 0x08000000) { - delete_sound_from_bank(temp_s5 & 0xFF, var_s3 & 0xFF); - var_s3 = var_s0 & 0xFF; - } - } - } else { - var_t3_2 = 0; - temp_t4 = (*D_800EA188)[(D_800EA1C0 * 6) + temp_s5]; - if ((s32) temp_t4 > 0) { - do { - temp_a3_2 = &sp7C + (var_t3_2 * 8); - temp_v0_5 = temp_t4 - 1; - var_a1 = temp_v0_5 & 0xFF; - temp_a2 = var_t3_2; - if ((u32) temp_a3_2->unk0 >= (u32) temp_t2->priority) { - if (var_s2 < (s32) temp_t4) { - var_s2 = (var_s2 + 1) & 0xFF; - } - var_t3_2 = temp_t4 & 0xFF; - if (temp_a2 < (temp_v0_5 & 0xFF)) { - var_v1 = var_a1; - do { - temp_v0_6 = &sp7C + (var_v1 * 8); - temp_a0 = &sp7C + (var_a1 * 8); - temp_a0->unk0 = (s32) temp_v0_6->unk-8; - var_v1 = (var_a1 - 1) & 0xFF; - var_a1 = var_v1; - temp_a0->unk4 = (u8) temp_v0_6->unk-4; - } while (temp_a2 < var_v1); - } - temp_a3_2->unk0 = temp_t2->priority; - temp_a3_2->unk4 = var_s3; - } - temp_t9 = (var_t3_2 + 1) & 0xFF; - var_t3_2 = temp_t9; - } while (temp_t9 < (s32) temp_t4); - } - } - var_s0 = var_s3 & 0xFF; - } - var_s3 = sp6C[var_s0].next; - } while (var_s3 != 0xFF); + for (i = 0; i < 8; i++) { + sp7C[i].priority = 0x7FFFFFFF; + sp7C[i].soundIndex = 0xFF; } - var_t1 = (*D_800EA188)[(D_800EA1C0 * 6) + temp_s5]; - var_t3_3 = 0; - if (var_s2 > 0) { - sp6C = sSoundBanks[temp_s5]; - do { - temp_t7_2 = (var_t3_3 + 1) & 0xFF; - temp_v0_7 = &sp6C[(&sp7C + (var_t3_3 * 8))->unk4]; - temp_v1 = temp_v0_7->soundStatus; - if (temp_v1 == 1) { - temp_v0_7->soundStatus = 2; - } else if (temp_v1 == 4) { - temp_v0_7->soundStatus = 3; - } - var_t3_3 = temp_t7_2; - } while (temp_t7_2 < var_s2); - var_t3_3 = 0; - } - var_t0 = var_t1; - if ((s32) var_t1 > 0) { - var_a2 = D_80192AB8[temp_s5]; - do { - temp_s3 = &var_a2[var_t3_3]; - temp_a1 = temp_s3->unk4; - var_v1_2 = 0; - if (temp_a1 == 0xFF) { - var_v1_2 = 1; + latestSoundIndex = 0; + soundIndex = sSoundBanks[bankId][0].next; + while (soundIndex != 0xFF) { + temp_t2 = &sSoundBanks[bankId][soundIndex]; + if ((temp_t2->soundStatus == 1) && ((temp_t2->soundBits & 0x08000000) == 0x08000000)) { + temp_t2->freshness -= 1; + } + if (temp_t2->freshness == 0) { + delete_sound_from_bank(bankId, soundIndex); + } else if (temp_t2->soundStatus != 0) { + if (D_800EA1C8 == *temp_t2->unk00) { + temp_t2->distance = 0.0f; } else { - temp_a0_2 = &sSoundBanks[temp_s5][temp_a1]; - temp_a3_3 = temp_a0_2->soundStatus; - if (temp_a3_3 == 4) { - if (temp_a0_2->soundBits & 0x08000000) { - sp70 = var_a2; - sp60 = (s32) var_t0; - spCE = var_t1; - spCC = (u8) var_t3_3; - delete_sound_from_bank(temp_s5 & 0xFF, temp_a1); - var_v1_2 = 1; - } else { - temp_a0_2->soundStatus = 1; - var_v1_2 = 1; - } - } else if (temp_a3_3 == 0) { - temp_s3->unk4 = 0xFFU; - var_v1_2 = 1; - } else { - var_a1_2 = 0; - if ((s32) var_t0 > 0) { - do { - temp_a0_3 = &sp7C + (var_a1_2 * 8); - if (temp_a1 == temp_a0_3->unk4) { - temp_a0_3->unk4 = 0xFFU; - var_a1_2 = var_t1 & 0xFF; - } - temp_t7_3 = (var_a1_2 + 1) & 0xFF; - var_a1_2 = temp_t7_3; - } while (temp_t7_3 < (s32) var_t0); - } + temp_t2->distance = ((*temp_t2->unk00)[0] * (*temp_t2->unk00)[0]) + (*temp_t2->unk08 * *temp_t2->unk08); + } + requestedPriority = ((u32) (temp_t2->soundBits & 0xFF00) >> 8) & 0xFF; + if (temp_t2->soundBits & 0x100000) { + temp_t2->priority = (0xFF - requestedPriority) * (0xFF - requestedPriority) * 0x5A4; // 0x5a4 = 1444 = 38 * 38 + } else { + temp_t2->priority = (u32) temp_t2->distance + ((0xFF - requestedPriority) * (0xFF - requestedPriority) * 0x5A4); // 0x5a4 = 1444 = 38 * 38 + if (*temp_t2->unk08 > 0.0f) { + temp_t2->priority += (s32) (*temp_t2->unk08 * 6.0f); } } - var_t2 = var_v1_2; - if (var_v1_2 == 1) { - var_a1_3 = 0; - if ((s32) var_t0 > 0) { - do { - temp_a0_4 = &sp7C + (var_a1_3 * 8); - temp_a3_4 = temp_a0_4->unk4; - if ((temp_a3_4 != 0xFF) && (sSoundBanks[temp_s5][temp_a3_4].soundStatus != 3)) { - var_s0_2 = 0; - if ((s32) var_t0 > 0) { - do { - if (temp_a3_4 == var_a2[var_s0_2].unk4) { - var_v1_2 = 0; - var_s0_2 = var_t1 & 0xFF; - } - temp_t6_2 = (var_s0_2 + 1) & 0xFF; - var_s0_2 = temp_t6_2; - } while (temp_t6_2 < (s32) var_t0); - var_t2 = var_v1_2; - } - if (var_t2 == 1) { - temp_s3->unk4 = temp_a3_4; - temp_a0_4->unk4 = 0xFFU; - var_a1_3 = (var_t0 + 1) & 0xFF; - } + temp_t8 = ((u32) (temp_t2->soundBits & 0x30000) >> 0x10) & 0xFF; + if (temp_t8 != 0) { + var_f0 = 4000000.0f / (f32) (temp_t8 * temp_t8); + } else { + var_f0 = 1e10f; + } + if (var_f0 < temp_t2->distance) { + if (temp_t2->soundStatus == 4) { + func_800CBBE8((temp_t2->unk2C << 8) | 0x06020000, 0); + if (temp_t2->soundBits & 0x08000000) { + delete_sound_from_bank(bankId, soundIndex); + soundIndex = latestSoundIndex; + } + } + } else { + var_t1 = D_800EA188[D_800EA1C0][bankId]; + for (i = 0; i < var_t1; i++) { + if (sp7C[i].priority >= temp_t2->priority) { + if (var_s2 < var_t1) { + var_s2++; } - temp_t8_4 = (var_a1_3 + 1) & 0xFF; - var_a1_3 = temp_t8_4; - } while (temp_t8_4 < (s32) var_t0); - } - if (var_t0 == var_a1_3) { - temp_s3->unk4 = 0xFFU; + for (j = var_t1 - 1; j > i; j--) { + sp7C[j].priority = sp7C[j - 1].priority; + sp7C[j].soundIndex = sp7C[j - 1].soundIndex; + } + sp7C[i].priority = temp_t2->priority; + sp7C[i].soundIndex = soundIndex; + i = var_t1; + } } } - temp_t6 = (var_t3_3 + 1) & 0xFF; - var_t3_3 = temp_t6; - } while (temp_t6 < (s32) var_t0); + latestSoundIndex = soundIndex; + } + soundIndex = sSoundBanks[bankId][latestSoundIndex].next; + } + var_t1 = D_800EA188[D_800EA1C0][bankId]; + for (i = 0; i < var_s2; i++) { + someTemp = sSoundBanks[bankId][sp7C[i].soundIndex].soundStatus; + if (someTemp == 1) { + sSoundBanks[bankId][sp7C[i].soundIndex].soundStatus = 2; + } else if (someTemp == 4) { + sSoundBanks[bankId][sp7C[i].soundIndex].soundStatus = 3; + } + } + for (i = 0; i < var_t1; i++) { + var_v1 = 0; + soundIndex = D_80192AB8[bankId][i][4]; + if (soundIndex == 0xFF) { + var_v1 = 1; + } else { + temp_t2 = &sSoundBanks[bankId][soundIndex]; + if (temp_t2->soundStatus == 4) { + if (temp_t2->soundBits & 0x08000000) { + delete_sound_from_bank(bankId, soundIndex); + var_v1 = 1; + } else { + temp_t2->soundStatus = 1; + var_v1 = 1; + } + } else if (temp_t2->soundStatus == 0) { + D_80192AB8[bankId][i][4] = 0xFF; + var_v1 = 1; + } else { + for (j = 0; j < var_t1; j++) { + if (soundIndex == sp7C[j].soundIndex) { + sp7C[j].soundIndex = 0xFF; + j = var_t1; + } + } + } + } + var_s2--; + if (var_v1 == 1) { + for (j = 0; j < var_t1; j++) { + soundIndex = sp7C[j].soundIndex; + if ((soundIndex != 0xFF) && (sSoundBanks[bankId][soundIndex].soundStatus != 3)) { + for (k = 0; k < var_t1; k++) { + if (soundIndex == D_80192AB8[bankId][k][4]) { + var_v1 = 0; + k = var_t1; + } + } + if (var_v1 == 1) { + D_80192AB8[bankId][i][4] = soundIndex; + sp7C[j].soundIndex = 0xFF; + j = var_t1 + 1; + var_s2--; + } + } + } + if (j == var_t1) { + D_80192AB8[bankId][i][4] = 0xFF; + } + } } } #else diff --git a/src/audio/external.h b/src/audio/external.h index 14c4c7640..6425b936a 100644 --- a/src/audio/external.h +++ b/src/audio/external.h @@ -52,7 +52,7 @@ struct Sound { /* 0x09 */ // u8 compilerPadding0[3]; /* 0x0C */ f32 *unk0C; /* 0x10 */ f32 *unk10; - /* 0x14 */ u8 *unk14; + /* 0x14 */ s8 *unk14; }; // size = 0x18 struct Unk_800E9F7C { @@ -150,12 +150,12 @@ typedef struct { /* 0x011 */ u8 unk_011; /* 0x012 */ u8 unk_012; /* 0x013 */ u8 unk_013; - /* 0x014 */ s32 unk_014; + /* 0x014 */ u32 unk_014; /* 0x018 */ u16 unk_018; /* 0x01A */ u16 unk_01A; - /* 0x01C */ s32 unk_01C; - /* 0x020 */ s32 unk_020; - /* 0x024 */ s32 unk_024; + /* 0x01C */ f32 unk_01C; + /* 0x020 */ f32 unk_020; + /* 0x024 */ f32 unk_024; /* 0x028 */ u16 unk_028; /* 0x02A */ u16 unk_02A; /* 0x02C */ u32 unk_02C[5]; // Array size guessed @@ -229,7 +229,7 @@ void func_800C3F70(void); void func_800C400C(void); void func_800C4084(u16); void func_800C40F0(u8); -void play_sound(u32, Vec3f*, u8, f32*, f32*, u8*); +void play_sound(u32, Vec3f*, u8, f32*, f32*, s8*); void func_800C41CC(u8, struct SoundCharacteristics*); void func_800C4398(void); void delete_sound_from_bank(u8, u8); diff --git a/src/code_80091750.c b/src/code_80091750.c index fd27a1c0b..f1eb3aefb 100644 --- a/src/code_80091750.c +++ b/src/code_80091750.c @@ -41,7 +41,7 @@ u16 *D_8018D9B0; u8 *D_8018D9B4; u8 *D_8018D9B8; u8 *D_8018D9BC; -struct_8018EE10_entry_cont *D_8018D9C0; +void *D_8018D9C0; /** * List of bytes indexed by character ID * Indicates number of Grand Prix points that character @@ -4086,6 +4086,7 @@ void *segmented_to_virtual_dupe_2(const void *addr) { } #ifdef NON_MATCHING +// https://decomp.me/scratch/NAZ12 // Register allocation nonsense void func_80099184(MkTexture *arg0) { u16 var_a1_2; @@ -4121,8 +4122,10 @@ void func_80099184(MkTexture *arg0) { dma_copy_base_729a30(var_s1->textureData, var_s1->height * var_s1->width * 2, &D_8018D9B0[gD_8018E118TotalSize]); } - D_8018E118[gNumD_8018E118Entries].textureData = var_s1->textureData; - D_8018E118[gNumD_8018E118Entries].offset = gD_8018E118TotalSize; + thing = &D_8018E118[gNumD_8018E118Entries]; + thing->textureData = var_s1->textureData; + thing = &D_8018E118[gNumD_8018E118Entries]; + thing->offset = gD_8018E118TotalSize; gD_8018E118TotalSize += (var_s1->height * var_s1->width); gNumD_8018E118Entries += 1; @@ -4136,6 +4139,7 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_80099184.s") #endif #ifdef NON_MATCHING +// https://decomp.me/scratch/O2tkD // Register allocation nonsense void func_80099394(MkTexture *arg0) { UNUSED u16 var_a1_2; @@ -4178,6 +4182,7 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_80099394.s") #ifdef NON_MATCHING // Register allocation nonsense +// https://decomp.me/scratch/Wv2MX void func_8009952C(MkTexture *arg0) { UNUSED u16 var_a1_2; s32 var_v0; @@ -4222,6 +4227,7 @@ void func_8009969C(MkTexture *arg0) { #ifdef NON_MATCHING // Register allocation nonsense +// https://decomp.me/scratch/hwAAp void func_800996BC(MkTexture *arg0, s32 arg1) { u16 var_a1_2; s32 var_v0; @@ -7391,8 +7397,7 @@ void func_800A1F30(UNUSED struct_8018D9E0_entry *unused) { } #ifdef NON_MATCHING -// Lots and lots of register allocation differences -// No idea what the source of it is, permuter isn't having any luck either +// Register allocation stuff, minor stack diffs void func_800A1FB0(struct_8018D9E0_entry *arg0) { Unk_D_800E70A0 spE0; UNUSED s32 stackPadding0; @@ -7421,12 +7426,12 @@ void func_800A1FB0(struct_8018D9E0_entry *arg0) { case 0x16: /* switch 1 */ case 0x17: /* switch 1 */ case 0x18: /* switch 1 */ - for (var_s2 = 0; var_s2 < 4; var_s2++) { - set_text_color_rainbow_if_selected(D_8018EDEC - 0x15, var_s2, TEXT_YELLOW); - func_80093324(0x00000032, 0x55 + (0x23 * var_s2), D_800E7868[var_s2], 0, 0.9f, 1.0f); - if (var_s2 == (D_8018EDEC - 0x15)) { + for (stackPadding0 = 0; stackPadding0 < 4; stackPadding0++) { + func_80092224(D_8018EDEC - 0x15, stackPadding0, 3); + func_80093324(0x00000032, 0x55 + (0x23 * stackPadding0), D_800E7868[stackPadding0], 0, 0.9f, 1.0f); + if (stackPadding0 == (D_8018EDEC - 0x15)) { spE0.column = 0x0032; - spE0.row = 0x55 + (0x23 * var_s2); + spE0.row = 0x55 + (0x23 * stackPadding0); } } set_text_color(1); @@ -7435,22 +7440,22 @@ void func_800A1FB0(struct_8018D9E0_entry *arg0) { case 0x1E: /* switch 1 */ case 0x1F: /* switch 1 */ set_text_color(3); - for (var_s2 = 0; var_s2 < 3; var_s2++) { - func_80093324(0x00000028, 0x55 + (0x14 * var_s2), D_800E7878[var_s2], 0, 1.0f, 1.0f); + for (stackPadding0 = 0; stackPadding0 < 3; stackPadding0++) { + func_80093324(0x00000028, 0x55 + (0x14 * stackPadding0), D_800E7878[stackPadding0], 0, 1.0f, 1.0f); } - for (var_s2 = 0; var_s2 < 2; var_s2++) { - set_text_color_rainbow_if_selected(D_8018EDEC - 0x1E, var_s2, TEXT_GREEN); - func_80093324(0x00000084, 0x96 + (0x19 * var_s2), D_800E7840[var_s2], 0, 1.0f, 1.0f); - if (var_s2 == (D_8018EDEC - 0x1E)) { + for (stackPadding0 = 0; stackPadding0 < 2; stackPadding0++) { + func_80092224(D_8018EDEC - 0x1E, stackPadding0, 1); + func_80093324(0x00000084, 0x96 + (0x19 * stackPadding0), D_800E7840[stackPadding0], 0, 1.0f, 1.0f); + if (stackPadding0 == (D_8018EDEC - 0x1E)) { spE0.column = 0x0084; - spE0.row = 0x96 + (0x19 * var_s2); + spE0.row = 0x96 + (0x19 * stackPadding0); } } break; case 0x20: /* switch 1 */ set_text_color(3); - for (var_s2 = 0; var_s2 < 3; var_s2++) { - func_80093324(0x00000032, 0x55 + (0x14 * var_s2), D_800E7884[var_s2], 0, 1.0f, 1.0f); + for (stackPadding0 = 0; stackPadding0 < 3; stackPadding0++) { + func_80093324(0x00000032, 0x55 + (0x14 * stackPadding0), D_800E7884[stackPadding0], 0, 1.0f, 1.0f); } break; case 0x2A: /* switch 1 */ @@ -7459,8 +7464,8 @@ void func_800A1FB0(struct_8018D9E0_entry *arg0) { case 0x2D: /* switch 1 */ set_text_color(2); var_s1 = D_8018EDEC - 0x2A; - for (var_s2 = 0; var_s2 < 3; var_s2++) { - func_80093324(0x00000032, 0x55 + (0x14 * var_s2), D_800E78D0[(var_s1 * 3) + var_s2], 0, 0.9f, 0.9f); + for (stackPadding0 = 0; stackPadding0 < 3; stackPadding0++) { + func_80093324(0x00000032, 0x55 + (0x14 * stackPadding0), D_800E78D0[(var_s1 * 3) + stackPadding0], 0, 0.9f, 0.9f); } break; case 0x34: /* switch 1 */ @@ -7469,23 +7474,23 @@ void func_800A1FB0(struct_8018D9E0_entry *arg0) { case 0x37: /* switch 1 */ set_text_color(2); var_s1 = D_8018EDEC - 0x34; - for (var_s2 = 0; var_s2 < 4; var_s2++) { - func_80093324(0x00000023, 0x55 + (0x14 * var_s2), D_800E7890[(var_s1 * 4) + var_s2], 0, 0.8f, 0.8f); + for (stackPadding0 = 0; stackPadding0 < 4; stackPadding0++) { + func_80093324(0x00000023, 0x55 + (0x14 * stackPadding0), D_800E7890[(var_s1 * 4) + stackPadding0], 0, 0.8f, 0.8f); } break; case 0x41: /* switch 1 */ case 0x42: /* switch 1 */ set_text_color(2); var_s1 = D_8018EDEC - 0x41; - for (var_s2 = 0; var_s2 < 3; var_s2++) { - func_80093324(0x00000041, 0x55 + (0x14 * var_s2), D_800E7900[(var_s1 * 3) + var_s2], 0, 0.9f, 0.9f); + for (stackPadding0 = 0; stackPadding0 < 3; stackPadding0++) { + func_80093324(0x00000041, 0x55 + (0x14 * stackPadding0), D_800E7900[(var_s1 * 3) + stackPadding0], 0, 0.9f, 0.9f); } break; case 0x46: /* switch 1 */ case 0x47: /* switch 1 */ set_text_color(3); - for (var_s2 = 0; var_s2 < 3; var_s2++) { - func_80093324(0x00000050, 0x55 + (0x14 * var_s2), D_800E7A48[var_s2], 0, 1.0f, 1.0f); + for (stackPadding0 = 0; stackPadding0 < 3; stackPadding0++) { + func_80093324(0x00000050, 0x55 + (0x14 * stackPadding0), D_800E7A48[stackPadding0], 0, 1.0f, 1.0f); } break; case 0x28: /* switch 1 */ @@ -7529,7 +7534,7 @@ void func_800A1FB0(struct_8018D9E0_entry *arg0) { if (var_s1 == 0) { var_v1 = &D_8018EE10[var_s2]; } else { - var_v1 = (struct_8018EE10_entry *) &D_8018D9C0[var_s2]; + var_v1 = &((struct_8018EE10_entry*)D_8018D9C0)[var_s2]; } if (var_v1->ghostDataSaved == 0) { func_80093324(0x2A + (var_s1 * 0x89), 0x96 + (0x1E * var_s2), D_800E7A44, 0, 0.5f, 0.5f); @@ -7565,7 +7570,7 @@ void func_800A1FB0(struct_8018D9E0_entry *arg0) { if (var_s1 == 0) { var_v1 = &D_8018EE10[var_s2]; } else { - var_v1 = (struct_8018EE10_entry *) &D_8018D9C0[var_s2]; + var_v1 = &((struct_8018EE10_entry*)D_8018D9C0)[var_s2]; } if (var_v1->ghostDataSaved == 0) { func_80093324(0x2A + (var_s1 * 0x89), 0x96 + (0x1E * var_s2), D_800E7A44, 0, 0.5f, 0.5f); @@ -7574,6 +7579,7 @@ void func_800A1FB0(struct_8018D9E0_entry *arg0) { } } } + // Register allocation diffs here for (var_s2 = 0; var_s2 < 2; var_s2++) { if (var_s2 == (D_8018EDEC - 0x38)) { spE0.column = 0x6E + (0x32 * var_s2); @@ -7586,16 +7592,16 @@ void func_800A1FB0(struct_8018D9E0_entry *arg0) { case 0x3A: /* switch 1 */ case 0x3B: /* switch 1 */ case 0x3C: /* switch 1 */ - temp_v0 = (D_8018EDEC - 0x3A) / 2; + var_s5 = (D_8018EDEC - 0x3A) / 2; set_text_color(2); - draw_text(0x000000A0, 0x00000055, D_800E7938[temp_v0], 0, 1.0f, 1.0f); + draw_text(0x000000A0, 0x00000055, D_800E7938[var_s5], 0, 1.0f, 1.0f); for (var_s1 = 0; var_s1 < 2; var_s1++) { set_text_color(3); draw_text(0x5C + (0x82 * var_s1), 0x0000007D, D_800E7918[var_s1], 0, 0.75f, 0.75f); for (var_s2 = 0; var_s2 < 2; var_s2++) { if (var_s1 == 0) { if (var_s2 == arg0->unk1C) { - if (temp_v0 == 0) { + if (var_s5 == 0) { set_text_color(2); } else { set_text_color(gGlobalTimer % 3); @@ -7613,7 +7619,7 @@ void func_800A1FB0(struct_8018D9E0_entry *arg0) { if (var_s1 == 0) { var_v1 = &D_8018EE10[var_s2]; } else { - var_v1 = (struct_8018EE10_entry *) &D_8018D9C0[var_s2]; + var_v1 = &((struct_8018EE10_entry*)D_8018D9C0)[var_s2]; } if (var_v1->ghostDataSaved == 0) { func_80093324(0x2A + (var_s1 * 0x89), 0x96 + (0x1E * var_s2), D_800E7A44, 0, 0.5f, 0.5f); @@ -8115,7 +8121,6 @@ void func_800A474C(s32 recordType, s32 column, s32 row) { char sp38[3]; struct_8018D9E0_entry *temp_v0; s32 sp30; - if (gGamestate == 4) { sp30 = 0; } else { @@ -8144,10 +8149,14 @@ void func_800A474C(s32 recordType, s32 column, s32 row) { } else { textColor = TEXT_YELLOW; } - } else if (temp_v0->unk20 != 0) { - textColor = gGlobalTimer % 3; } else { + // huh? textColor = TEXT_YELLOW; + if (temp_v0->unk20 != 0) { + textColor = gGlobalTimer; + textColor %= 3; + } else { + } } } else { textColor = TEXT_YELLOW; @@ -8157,6 +8166,7 @@ void func_800A474C(s32 recordType, s32 column, s32 row) { get_time_record_minutes(temp_t0, sp38); func_800939C8(column + 0x27, row, sp38, 0, 0.65f, 0.65f); func_80093324(column + 0x32, row, "'", 0, 0.65f, 0.65f); + if (!textColor) {} get_time_record_seconds(temp_t0, sp38); func_800939C8(column + 0x3B, row, sp38, 0, 0.65f, 0.65f); func_80093324(column + 0x46, row, "\"", 0, 0.65f, 0.65f); diff --git a/src/code_80091750.h b/src/code_80091750.h index a64773280..631bc0632 100644 --- a/src/code_80091750.h +++ b/src/code_80091750.h @@ -400,11 +400,6 @@ void func_800AF740(struct_8018D9E0_entry*); void rmonPrintf(const char *, ...); void tkmk00decode(u8*, u8*, u8*, s32); -typedef struct struct_8018EE10_entry_cont { - struct_8018EE10_entry arr[1]; - -} struct_8018EE10_entry_cont; - /* File specific defines */ #define D_8018D9E0_SIZE 0x20 @@ -426,7 +421,7 @@ extern u16 *D_8018D9B0; extern u8 *D_8018D9B4; extern u8 *D_8018D9B8; extern u8 *D_8018D9BC; -extern struct_8018EE10_entry_cont *D_8018D9C0; +extern void *D_8018D9C0; extern s8 gGPPointsByCharacterId[8]; extern s8 gCharacterIdByGPOverallRank[]; extern s8 D_8018D9D8; diff --git a/src/save.c b/src/save.c index fd8f58144..664a0faf8 100644 --- a/src/save.c +++ b/src/save.c @@ -925,7 +925,7 @@ s32 func_800B65F4(s32 arg0, s32 arg1) { } writeStatus = osPfsReadWriteFile(&gControllerPak2FileHandle, gControllerPak2FileNote, 0U, (arg0 * 0x3C00) + 0x100, 0x00003C00, (u8 *) D_800DC714); if (writeStatus == 0) { - temp_s3 = &D_8018D9C0->arr[arg0]; + temp_s3 = &((struct_8018EE10_entry*)D_8018D9C0)[arg0]; for (i = 0; i < 0x3C; i++) { if (temp_s3->unk_07[i] != func_800B60E8(i)) { temp_s3->ghostDataSaved = 0; @@ -986,7 +986,7 @@ u8 func_800B68F4(s32 arg0) { s32 i; checksum = 0; for (i = 0; i < 0x43; i++) { - u8 *addr = (u8 *) (&D_8018D9C0[arg0]); + u8 *addr = &((u8*)D_8018D9C0)[arg0]; checksum += addr[i] * multiplier + i; } return checksum;