From 32d2fde8e41316fdd8d4fe99711b3e8619d75a75 Mon Sep 17 00:00:00 2001 From: JoshDuMan <40190173+JoshDuMan@users.noreply.github.com> Date: Thu, 17 Feb 2022 12:02:55 -0500 Subject: [PATCH] Match func_8004C444 (#648) * Match func_8004C444 * Update audio.h * Delete func_8004C444.s * Update audio.h * Ethan * UnkAl48 * Update 26840_len_20d0.c --- src/26840_len_20d0.c | 39 ++++++++- src/audio.h | 5 +- .../26840_len_20d0/func_8004C444.s | 87 ------------------- 3 files changed, 41 insertions(+), 90 deletions(-) delete mode 100644 ver/us/asm/nonmatchings/26840_len_20d0/func_8004C444.s diff --git a/src/26840_len_20d0.c b/src/26840_len_20d0.c index 3fbb7c67ef..fad61139c5 100644 --- a/src/26840_len_20d0.c +++ b/src/26840_len_20d0.c @@ -197,7 +197,44 @@ INCLUDE_ASM(void, "26840_len_20d0", snd_set_modifiers, SoundManager* manager, So void snd_set_player_modifiers(SoundManager* manager, SoundSFXEntry* sfxEntry); INCLUDE_ASM(void, "26840_len_20d0", snd_set_player_modifiers, SoundManager* manager, SoundSFXEntry* sfxEntry); -INCLUDE_ASM(s16, "26840_len_20d0", func_8004C444, SoundManager* manager); +void func_8004C578(SoundManager*, SoundPlayer*, UnkAl48*, u32); +void func_8004C884(SoundManager*, SoundPlayer*, UnkAl48*, u32); + +s16 func_8004C444(SoundManager* arg0) { + u32 phi_a3 = arg0->sfxPlayerSelector; + u16 temp = arg0->unk_60; + u16 playCounter = arg0->playCounter; + SoundPlayer* temp_a1; + UnkAl48* temp_a2; + u8 i; + + arg0->unk_60 = temp + playCounter; + + for (i = phi_a3, phi_a3 += 8; i < (u8)phi_a3; i++){ + temp_a1 = &arg0->unk_16C[i - arg0->sfxPlayerSelector]; + if (temp_a1->sefDataReadPos != 0) { + arg0->unk_04 = temp_a2 = &arg0->soundData->unk_1320[i]; + if (arg0->unk_04->unk_45 <= arg0->unk_BC) { + arg0->unk_BF = i; + switch (temp_a1->sfxParamsFlags & 3) { + case 0: + func_8004C578(arg0, temp_a1, temp_a2, i); + break; + case 1: + func_8004C884(arg0, temp_a1, temp_a2, i); + break; + case 2: // Yes, this is needed. + break; + } + } else { + temp_a1->sefDataReadPos = NULL; + temp_a1->currentSoundID = 0; + temp_a1->unk_98 = 0; + } + } + } + return 0; +} INCLUDE_ASM(s32, "26840_len_20d0", func_8004C578); diff --git a/src/audio.h b/src/audio.h index 5ea8885bf1..d403529447 100644 --- a/src/audio.h +++ b/src/audio.h @@ -5,6 +5,7 @@ struct BGMPlayer; struct UnkAl19E0; +struct UnkAl48; typedef void (*UnkFuncAl)(void); @@ -179,7 +180,7 @@ typedef struct SoundPlayer { /* 0x94 */ u8 unk_94; /* 0x95 */ char unk_05; /* 0x96 */ s16 currentSoundID; - /* 0x98 */ char unk_98[0x1]; + /* 0x98 */ u8 unk_98; /* 0x99 */ u8 unk_99; /* 0x9A */ s8 sfxParamsFlags; /* 0x9B */ u8 sfxPan; @@ -205,7 +206,7 @@ typedef struct SoundSefHeader { typedef struct SoundManager { /* 0x000 */ struct UnkAl19E0* soundData; - /* 0x004 */ char unk_04[0x4]; + /* 0x004 */ struct UnkAl48* unk_04; /* 0x008 */ s32* sefData; /* 0x00C */ s32* normalSounds[8]; /* 0x02C */ s32* soundsWithBit2000; diff --git a/ver/us/asm/nonmatchings/26840_len_20d0/func_8004C444.s b/ver/us/asm/nonmatchings/26840_len_20d0/func_8004C444.s deleted file mode 100644 index d2f2af24cf..0000000000 --- a/ver/us/asm/nonmatchings/26840_len_20d0/func_8004C444.s +++ /dev/null @@ -1,87 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_8004C444 -/* 27844 8004C444 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 27848 8004C448 AFB00010 */ sw $s0, 0x10($sp) -/* 2784C 8004C44C 0080802D */ daddu $s0, $a0, $zero -/* 27850 8004C450 AFBF0020 */ sw $ra, 0x20($sp) -/* 27854 8004C454 AFB3001C */ sw $s3, 0x1c($sp) -/* 27858 8004C458 AFB20018 */ sw $s2, 0x18($sp) -/* 2785C 8004C45C AFB10014 */ sw $s1, 0x14($sp) -/* 27860 8004C460 920300BD */ lbu $v1, 0xbd($s0) -/* 27864 8004C464 96020062 */ lhu $v0, 0x62($s0) -/* 27868 8004C468 96040032 */ lhu $a0, 0x32($s0) -/* 2786C 8004C46C 0060882D */ daddu $s1, $v1, $zero -/* 27870 8004C470 24630008 */ addiu $v1, $v1, 8 -/* 27874 8004C474 322700FF */ andi $a3, $s1, 0xff -/* 27878 8004C478 00441021 */ addu $v0, $v0, $a0 -/* 2787C 8004C47C 306300FF */ andi $v1, $v1, 0xff -/* 27880 8004C480 AE020060 */ sw $v0, 0x60($s0) -/* 27884 8004C484 00E3102B */ sltu $v0, $a3, $v1 -/* 27888 8004C488 10400033 */ beqz $v0, .L8004C558 -/* 2788C 8004C48C 24130001 */ addiu $s3, $zero, 1 -/* 27890 8004C490 0060902D */ daddu $s2, $v1, $zero -.L8004C494: -/* 27894 8004C494 920200BD */ lbu $v0, 0xbd($s0) -/* 27898 8004C498 00E21023 */ subu $v0, $a3, $v0 -/* 2789C 8004C49C 00021840 */ sll $v1, $v0, 1 -/* 278A0 8004C4A0 00621821 */ addu $v1, $v1, $v0 -/* 278A4 8004C4A4 00031880 */ sll $v1, $v1, 2 -/* 278A8 8004C4A8 00621823 */ subu $v1, $v1, $v0 -/* 278AC 8004C4AC 00031880 */ sll $v1, $v1, 2 -/* 278B0 8004C4B0 00621823 */ subu $v1, $v1, $v0 -/* 278B4 8004C4B4 00031880 */ sll $v1, $v1, 2 -/* 278B8 8004C4B8 2463016C */ addiu $v1, $v1, 0x16c -/* 278BC 8004C4BC 02032821 */ addu $a1, $s0, $v1 -/* 278C0 8004C4C0 8CA20000 */ lw $v0, ($a1) -/* 278C4 8004C4C4 1040001F */ beqz $v0, .L8004C544 -/* 278C8 8004C4C8 000710C0 */ sll $v0, $a3, 3 -/* 278CC 8004C4CC 00471021 */ addu $v0, $v0, $a3 -/* 278D0 8004C4D0 000210C0 */ sll $v0, $v0, 3 -/* 278D4 8004C4D4 8E030000 */ lw $v1, ($s0) -/* 278D8 8004C4D8 24421320 */ addiu $v0, $v0, 0x1320 -/* 278DC 8004C4DC 00623021 */ addu $a2, $v1, $v0 -/* 278E0 8004C4E0 AE060004 */ sw $a2, 4($s0) -/* 278E4 8004C4E4 90C30045 */ lbu $v1, 0x45($a2) -/* 278E8 8004C4E8 920200BC */ lbu $v0, 0xbc($s0) -/* 278EC 8004C4EC 0043102B */ sltu $v0, $v0, $v1 -/* 278F0 8004C4F0 54400012 */ bnel $v0, $zero, .L8004C53C -/* 278F4 8004C4F4 ACA00000 */ sw $zero, ($a1) -/* 278F8 8004C4F8 A21100BF */ sb $s1, 0xbf($s0) -/* 278FC 8004C4FC 90A2009A */ lbu $v0, 0x9a($a1) -/* 27900 8004C500 30430003 */ andi $v1, $v0, 3 -/* 27904 8004C504 10730009 */ beq $v1, $s3, .L8004C52C -/* 27908 8004C508 28620002 */ slti $v0, $v1, 2 -/* 2790C 8004C50C 5040000E */ beql $v0, $zero, .L8004C548 -/* 27910 8004C510 26310001 */ addiu $s1, $s1, 1 -/* 27914 8004C514 5460000C */ bnel $v1, $zero, .L8004C548 -/* 27918 8004C518 26310001 */ addiu $s1, $s1, 1 -/* 2791C 8004C51C 0C01315E */ jal func_8004C578 -/* 27920 8004C520 0200202D */ daddu $a0, $s0, $zero -/* 27924 8004C524 08013152 */ j .L8004C548 -/* 27928 8004C528 26310001 */ addiu $s1, $s1, 1 -.L8004C52C: -/* 2792C 8004C52C 0C013221 */ jal func_8004C884 -/* 27930 8004C530 0200202D */ daddu $a0, $s0, $zero -/* 27934 8004C534 08013152 */ j .L8004C548 -/* 27938 8004C538 26310001 */ addiu $s1, $s1, 1 -.L8004C53C: -/* 2793C 8004C53C A4A00096 */ sh $zero, 0x96($a1) -/* 27940 8004C540 A0A00098 */ sb $zero, 0x98($a1) -.L8004C544: -/* 27944 8004C544 26310001 */ addiu $s1, $s1, 1 -.L8004C548: -/* 27948 8004C548 322700FF */ andi $a3, $s1, 0xff -/* 2794C 8004C54C 00F2102B */ sltu $v0, $a3, $s2 -/* 27950 8004C550 1440FFD0 */ bnez $v0, .L8004C494 -/* 27954 8004C554 00000000 */ nop -.L8004C558: -/* 27958 8004C558 8FBF0020 */ lw $ra, 0x20($sp) -/* 2795C 8004C55C 8FB3001C */ lw $s3, 0x1c($sp) -/* 27960 8004C560 8FB20018 */ lw $s2, 0x18($sp) -/* 27964 8004C564 8FB10014 */ lw $s1, 0x14($sp) -/* 27968 8004C568 8FB00010 */ lw $s0, 0x10($sp) -/* 2796C 8004C56C 0000102D */ daddu $v0, $zero, $zero -/* 27970 8004C570 03E00008 */ jr $ra -/* 27974 8004C574 27BD0028 */ addiu $sp, $sp, 0x28