diff options
| author | Tyler McGavran <tyler.taggerung@gmail.com> | 2024-02-22 12:33:39 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-22 12:33:39 -0500 |
| commit | 91e881c107f24ecf2ddea8fdbbdd21093721fa73 (patch) | |
| tree | 716005a322d16412b4614d40ad9eac5cfdc7d324 /src/audio/external.c | |
| parent | b0653d7416fdd792c06d06b1678bcd27977ab5b2 (diff) | |
Matches in audio/external (#570)
Also deleted an unused .c file, its current name is `effects.c`
Signed-off-by: Taggerung <tyler.taggerung@email.com>
Co-authored-by: Taggerung <tyler.taggerung@email.com>
Diffstat (limited to 'src/audio/external.c')
| -rw-r--r-- | src/audio/external.c | 258 |
1 files changed, 103 insertions, 155 deletions
diff --git a/src/audio/external.c b/src/audio/external.c index a3ae6d612..66295fd0e 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -9,6 +9,7 @@ #include "audio/data.h" #include "audio/port_eu.h" #include "code_800029B0.h" +#include "code_80005FD0.h" #include "code_80091750.h" s8 D_8018EF10; @@ -21,7 +22,7 @@ Camera *gCopyCamera[4]; Vec3f gVelocityCamera[4]; Vec3f gCameraLastPos[4]; u8 D_8018FC08; -u16 D_8018FC10[4][2]; +s16 D_8018FC10[4][2]; struct Sound sSoundRequests[0x100]; struct SoundCharacteristics sSoundBanks[SOUND_BANK_COUNT][20]; u8 sSoundBankUsedListBack[SOUND_BANK_COUNT]; @@ -578,80 +579,59 @@ Vec3f *func_800C21E8(Vec3f pos, u32 soundBits) { return ret; } -#ifdef MIPS_TO_C -//generated by m2c commit beb457dabfc7a01ec6540a5404a6a05097a13602 on Oct-18-2023 -void func_800C2274(s32 player) { +void func_800C2274(u8 player) { s16 sp46; - s16 sp44; - s16 sp42; - s16 temp_a1; - s16 temp_t2; - s16 var_s0; s16 var_s1; - s32 temp_a3; - s32 var_a2; - struct SequenceChannel *temp_v0; - u16 *temp_s1; - u16 *temp_v0_2; - u16 *temp_v0_3; + s16 sp42; + u8 var_s0; u8 temp_s0; + u8 why = 0xFF; + s32 var_a2; - temp_a3 = player & 0xFF; var_a2 = 0xF; - if (((u32) gSequencePlayers[temp_a3] >> 0x1F) != 0) { + if (gSequencePlayers[player].enabled != 0) { switch (gScreenModeSelection) { /* irregular */ - case 0: - break; - case 1: - var_a2 = 0xE; - break; - case 3: + case 0: + break; + case 1: + var_a2 = 0xE; + break; + case 3: + if (gPlayerCountSelection1 == 3) { + var_a2 = 0xD; + } else { var_a2 = 0xC; - if (gPlayerCountSelection1 == 3) { - var_a2 = 0xD; - } - break; + } + break; } - temp_v0 = gSequencePlayers[temp_a3].channels[var_a2]; - temp_s0 = (u8) temp_v0->soundScriptIO[0]; - if (temp_s0 != (u8) 0x00FFU) { - sp46 = temp_v0->soundScriptIO[1] & 3; - var_s1 = temp_v0->soundScriptIO[2] & 0xF; + temp_s0 = gSequencePlayers[player].channels[var_a2]->soundScriptIO[0]; + if (temp_s0 != why) { + sp46 = gSequencePlayers[player].channels[var_a2]->soundScriptIO[1] % 4u; + var_s1 = gSequencePlayers[player].channels[var_a2]->soundScriptIO[2] % 16u; if (var_s1 >= 0xA) { var_s1 = 9; } - sp42 = temp_v0->soundScriptIO[3] & 7; - func_800CBBE8(((temp_a3 & 0xFF) << 0x10) | 0x06000000 | ((var_a2 & 0xFF) << 8), -1); - sp44 = var_s1; + sp42 = gSequencePlayers[player].channels[var_a2]->soundScriptIO[3] % 8u; + func_800CBBE8(((player & 0xFF) << 0x10) | 0x06000000 | ((var_a2 & 0xFF) << 8), -1); } switch (temp_s0) { /* switch 1; irregular */ - case 1: /* switch 1 */ - temp_v0_2 = D_8018FC10[sp46]; - temp_v0_2->unk0 = (u16) sp44; - var_s0 = 0; - temp_v0_2->unk2 = sp42; - do { - temp_s1 = D_8018FC10[var_s0]; - temp_a1 = (s16) temp_s1->unk0; - if (temp_a1 != (s16) 0x00FFU) { - func_8001AAAC(var_s0, temp_a1, temp_s1->unk2); - temp_s1->unk0 = 0x00FF; - } - temp_t2 = (var_s0 + 1) & 0xFF; - var_s0 = temp_t2; - } while (temp_t2 < 4); - return; - case 2: /* switch 1 */ - temp_v0_3 = D_8018FC10[sp46]; - temp_v0_3->unk0 = (u16) sp44; - temp_v0_3->unk2 = sp42; - break; + case 1: /* switch 1 */ + D_8018FC10[sp46][0] = var_s1; + D_8018FC10[sp46][1] = sp42; + for (var_s0 = 0; var_s0 < 4; var_s0++) { + if (D_8018FC10[var_s0][0] != why) { + func_8001AAAC(var_s0, D_8018FC10[var_s0][0], D_8018FC10[var_s0][1]); + D_8018FC10[var_s0][0] = why; + } + } + break; + case 2: /* switch 1 */ + D_8018FC10[sp46][0] = var_s1; + D_8018FC10[sp46][1] = sp42; + break; } } } -#else -GLOBAL_ASM("asm/non_matchings/audio/external/func_800C2274.s") -#endif void func_800C2474(void) { u8 var_v0; @@ -2068,33 +2048,28 @@ void func_800C4FE4(u8 bankId) { GLOBAL_ASM("asm/non_matchings/audio/external/func_800C4FE4.s") #endif -#ifdef MIPS_TO_C -//generated by m2c commit beb457dabfc7a01ec6540a5404a6a05097a13602 on Oct-17-2023 +// Seems somewhat similar to certain parts of `select_current_sounds` from SM64 void func_800C5278(u8 bankId) { + s32 stackPadding0; + u8 soundId; struct SoundCharacteristics sp60; - s32 temp_s7; - struct SoundCharacteristics *temp_s0; - struct SoundCharacteristics *temp_s2; - temp_s7 = bankId & 0xFF; - temp_s2 = sSoundBanks[temp_s7]; - if (temp_s2->next != 0xFF) { - do { - temp_s0 = &sSoundBanks[temp_s7][temp_s2->next]; - if ((s32) temp_s0->soundStatus >= 3) { - func_800CBBE8((temp_s0->unk2C << 8) | 0x06020000, 0); - } - if (temp_s0->soundStatus != 0) { - delete_sound_from_bank(temp_s7 & 0xFF, temp_s2->next & 0xFF); - } - } while (temp_s2->next != 0xFF); + soundId = sSoundBanks[bankId][0].next; + while (soundId != 0xFF) { + if (sSoundBanks[bankId][soundId].soundStatus >= 3) { + func_800CBBE8(((sSoundBanks[bankId][soundId].unk2C & 0xff) << 8) | 0x06020000, 0); + } + if (sSoundBanks[bankId][soundId].soundStatus != 0) { + delete_sound_from_bank(bankId, soundId); + } + // This feels wrong, I think it only works because `delete_sound_from_bank` + // modifies `sSoundBanks[bankId][0].next`, which allows us to eventually(?) + // break out of the loop + soundId = sSoundBanks[bankId][0].next; } - sp60.soundBits = temp_s7 << 0x1C; - func_800C41CC(0U, &sp60); + sp60.soundBits = bankId << 0x1C; + func_800C41CC(0, &sp60); } -#else -GLOBAL_ASM("asm/non_matchings/audio/external/func_800C5278.s") -#endif void func_800C5384(u8 arg0, Vec3f *arg1) { u8 curr; @@ -2129,101 +2104,74 @@ void func_800C54B8(u8 arg0, Vec3f *arg1) { } void func_800C550C(Vec3f *arg0) { - UNUSED s32 pad[11]; u8 i; - Vec3f *sp3C; + struct SoundCharacteristics sp3C; for(i = 0; i < 6; i++) { func_800C5384(i, arg0); } - sp3C = arg0; - func_800C41CC(2U, (struct SoundCharacteristics*) &sp3C); + sp3C.unk00 = arg0; + func_800C41CC(2, &sp3C); } -#ifdef MIPS_TO_C -//generated by m2c commit beb457dabfc7a01ec6540a5404a6a05097a13602 on Oct-18-2023 -void func_800C5578(Vec3f arg0, u32 soundBits) { - u32 sp84; - f32 *sp60; - s32 temp_t8; - s32 var_s3; - struct SoundCharacteristics *temp_s0; - struct SoundCharacteristics *temp_s4; - u8 var_s1; - u8 var_v0; +void func_800C5578(Vec3f *arg0, u32 soundBits) { + s32 stackPadding0; + u8 bankId; + u8 next; + u8 curr; + struct SoundCharacteristics sp60; - temp_t8 = ((u32) (soundBits & 0xF0000000) >> 0x1C) & 0xFF; - var_s1 = sSoundBanks[temp_t8]->next; - var_s3 = 0; - var_v0 = var_s1; - if (var_s1 != 0xFF) { - temp_s4 = sSoundBanks[temp_t8]; - do { - temp_s0 = &temp_s4[var_s1]; - if ((arg0 == temp_s0->unk00) && (soundBits == temp_s0->soundBits)) { - if ((s32) temp_s0->soundStatus >= 3) { - func_800CBBE8((temp_s0->unk2C << 8) | 0x06020000, 0); - } - if (temp_s0->soundStatus != 0) { - delete_sound_from_bank(temp_t8 & 0xFF, var_s1 & 0xFF); - } - var_s1 = 0xFF; - var_v0 = 0xFF; - } else { - var_s3 = var_s1 & 0xFF; + bankId = (soundBits & 0xF0000000) >> 0x1C; + next = sSoundBanks[bankId][0].next; + curr = 0; + while (next != 0xFF) { + if ((arg0 == sSoundBanks[bankId][next].unk00) && (soundBits == sSoundBanks[bankId][next].soundBits)) { + if (sSoundBanks[bankId][next].soundStatus >= 3) { + func_800CBBE8(((sSoundBanks[bankId][next].unk2C & 0xff) << 8) | 0x06020000, 0); } - if (var_v0 != 0xFF) { - var_s1 = temp_s4[var_s3].next; - var_v0 = var_s1; + if (sSoundBanks[bankId][next].soundStatus != 0) { + delete_sound_from_bank(bankId, next); } - } while (var_v0 != 0xFF); + next = 0xFF; + } else { + curr = next; + } + if (next != 0xFF) { + next = sSoundBanks[bankId][curr].next; + } } - sp60 = arg0; - sp84 = soundBits; - func_800C41CC(3U, (struct SoundCharacteristics *) &sp60); + sp60.unk00 = arg0; + sp60.soundBits = soundBits; + func_800C41CC(3, &sp60); } -#else -GLOBAL_ASM("asm/non_matchings/audio/external/func_800C5578.s") -#endif -#ifdef MIPS_TO_C -//generated by m2c commit beb457dabfc7a01ec6540a5404a6a05097a13602 on Oct-17-2023 void func_800C56F0(u32 soundBits) { + s32 stackPadding0; + u8 bankId; + u8 next; + u8 curr; struct SoundCharacteristics sp68; - s32 temp_t8; - s32 var_s2; - struct SoundCharacteristics *temp_s0; - struct SoundCharacteristics *temp_s3; - u8 var_s1; - temp_t8 = ((u32) (soundBits & 0xF0000000) >> 0x1C) & 0xFF; - var_s1 = sSoundBanks[temp_t8]->next; - var_s2 = 0; - if (var_s1 != 0xFF) { - temp_s3 = sSoundBanks[temp_t8]; - do { - temp_s0 = &temp_s3[var_s1]; - if (soundBits == temp_s0->soundBits) { - if ((s32) temp_s0->soundStatus >= 3) { - func_800CBBE8((temp_s0->unk2C << 8) | 0x06020000, 0); - } - if (temp_s0->soundStatus != 0) { - delete_sound_from_bank(temp_t8 & 0xFF, var_s1 & 0xFF); - } - var_s1 = temp_s3[var_s2].next; - } else { - var_s2 = var_s1 & 0xFF; - var_s1 = temp_s3[var_s2].next; + bankId = (soundBits & 0xF0000000) >> 0x1C; + next = sSoundBanks[bankId][0].next; + curr = 0; + while (next != 0xFF) { + if (soundBits == sSoundBanks[bankId][next].soundBits) { + if (sSoundBanks[bankId][next].soundStatus >= 3) { + func_800CBBE8(((sSoundBanks[bankId][next].unk2C & 0xff) << 8) | 0x06020000, 0); + } + if (sSoundBanks[bankId][next].soundStatus != 0) { + delete_sound_from_bank(bankId, next); } - } while (var_s1 != 0xFF); + } else { + curr = next; + } + next = sSoundBanks[bankId][curr].next; } sp68.soundBits = soundBits; - func_800C41CC(5U, &sp68); + func_800C41CC(5, &sp68); } -#else -GLOBAL_ASM("asm/non_matchings/audio/external/func_800C56F0.s") -#endif // Might be process_all_sound_requests void func_800C5848(void) { |
