2020-10-03 15:22:44 +00:00
|
|
|
#include "ultra64.h"
|
|
|
|
#include "global.h"
|
2020-10-26 11:58:56 +00:00
|
|
|
#include "vt.h"
|
2020-07-20 01:08:50 +00:00
|
|
|
|
2020-10-26 11:58:56 +00:00
|
|
|
typedef struct {
|
|
|
|
/* 0x00 */ u16 sfxId;
|
|
|
|
/* 0x04 */ Vec3f* pos;
|
|
|
|
/* 0x08 */ u8 unk_8;
|
2021-08-30 00:08:41 +00:00
|
|
|
/* 0x0C */ f32* freqScale;
|
2020-11-16 08:31:08 +00:00
|
|
|
/* 0x10 */ f32* unk_10;
|
2021-08-30 00:08:41 +00:00
|
|
|
/* 0x14 */ s8* reverbAdd;
|
|
|
|
} SoundRequest; // size = 0x18
|
2020-07-20 01:08:50 +00:00
|
|
|
|
2020-10-26 11:58:56 +00:00
|
|
|
typedef struct {
|
|
|
|
/* 0x00 */ f32 unk_0;
|
|
|
|
/* 0x04 */ f32 unk_4;
|
|
|
|
/* 0x08 */ f32 unk_8;
|
|
|
|
/* 0x0C */ u16 unk_C;
|
|
|
|
} Struct_800F8EA0; // size = 0x10
|
2020-07-20 01:08:50 +00:00
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
// rodata for Audio_ProcessSoundRequest (this file)
|
|
|
|
// (probably moved to .data due to -use_readwrite_const)
|
2021-08-12 19:37:37 +00:00
|
|
|
char D_80133340[] = "SE";
|
2020-07-20 01:08:50 +00:00
|
|
|
|
2021-08-12 19:37:37 +00:00
|
|
|
// rodata for func_800F7CEC (this file)
|
2020-10-26 11:58:56 +00:00
|
|
|
char D_80133344[] = VT_COL(RED, WHITE) "<INAGAKI CHECK> dist over! flag:%04X ptr:%08X pos:%f-%f-%f" VT_RST "\n";
|
|
|
|
|
2021-08-12 19:37:37 +00:00
|
|
|
// file padding
|
2020-10-26 11:58:56 +00:00
|
|
|
s32 D_8013338C = 0;
|
|
|
|
|
2021-08-12 19:37:37 +00:00
|
|
|
// rodata for Audio_ProcessSeqCmd (code_800F9280.c)
|
|
|
|
char D_80133390[] = "SEQ H";
|
|
|
|
char D_80133398[] = " L";
|
2020-10-26 11:58:56 +00:00
|
|
|
|
2021-08-12 19:37:37 +00:00
|
|
|
// data
|
2020-10-26 11:58:56 +00:00
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
// sSoundRequests ring buffer endpoints. read index <= write index, wrapping around mod 256.
|
|
|
|
u8 sSoundRequestWriteIndex = 0;
|
|
|
|
u8 sSoundRequestReadIndex = 0;
|
2020-10-26 11:58:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Array of pointers to arrays of SoundBankEntry of sizes: 9, 12, 22, 20, 8, 3, 5
|
|
|
|
*
|
|
|
|
* 0 : Player Bank size 9
|
|
|
|
* 1 : Item Bank size 12
|
|
|
|
* 2 : Environment Bank size 22
|
|
|
|
* 3 : Enemy Bank size 20
|
|
|
|
* 4 : System Bank size 8
|
|
|
|
* 5 : Ocarina Bank size 3
|
|
|
|
* 6 : Voice Bank size 5
|
|
|
|
*/
|
|
|
|
SoundBankEntry* gSoundBanks[7] = {
|
|
|
|
D_8016BAD0, D_8016BC80, D_8016BEC0, D_8016C2E0, D_8016C6A0, D_8016C820, D_8016C8B0,
|
|
|
|
};
|
|
|
|
|
|
|
|
u8 sBankSizes[ARRAY_COUNT(gSoundBanks)] = {
|
|
|
|
ARRAY_COUNT(D_8016BAD0), ARRAY_COUNT(D_8016BC80), ARRAY_COUNT(D_8016BEC0), ARRAY_COUNT(D_8016C2E0),
|
|
|
|
ARRAY_COUNT(D_8016C6A0), ARRAY_COUNT(D_8016C820), ARRAY_COUNT(D_8016C8B0),
|
|
|
|
};
|
|
|
|
|
|
|
|
u8 D_801333CC = 0;
|
|
|
|
|
|
|
|
u16 D_801333D0 = 0;
|
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
Vec3f D_801333D4 = { 0.0f, 0.0f, 0.0f }; // default pos
|
2020-10-26 11:58:56 +00:00
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
f32 D_801333E0 = 1.0f; // default freqScale
|
2020-10-26 11:58:56 +00:00
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
s32 D_801333E4 = 0; // unused
|
2020-10-26 11:58:56 +00:00
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
s8 D_801333E8 = 0; // default reverbAdd
|
2020-10-26 11:58:56 +00:00
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
s32 D_801333EC = 0; // unused
|
2020-10-26 11:58:56 +00:00
|
|
|
|
|
|
|
u8 D_801333F0 = 0;
|
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
u8 gAudioSEFlagSwapOff = 0;
|
2020-10-26 11:58:56 +00:00
|
|
|
|
|
|
|
u8 D_801333F8 = 0;
|
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
extern SoundRequest sSoundRequests[0x100];
|
|
|
|
extern Struct_800F8EA0 D_8016E270[7];
|
2020-10-26 11:58:56 +00:00
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
void Audio_SetSoundBanksMute(u16 muteMask) {
|
2020-10-26 11:58:56 +00:00
|
|
|
u8 bankId;
|
|
|
|
|
|
|
|
for (bankId = 0; bankId < ARRAY_COUNT(gSoundBanks); bankId++) {
|
2021-08-30 00:08:41 +00:00
|
|
|
if (muteMask & 1) {
|
|
|
|
gSoundBankMuted[bankId] = true;
|
2020-10-26 11:58:56 +00:00
|
|
|
} else {
|
2021-08-30 00:08:41 +00:00
|
|
|
gSoundBankMuted[bankId] = false;
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
2021-08-30 00:08:41 +00:00
|
|
|
muteMask = muteMask >> 1;
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-27 23:44:58 +00:00
|
|
|
void Audio_QueueSeqCmdMute(u8 arg0) {
|
2020-10-26 11:58:56 +00:00
|
|
|
D_801333D0 |= (1 << arg0);
|
2021-07-27 23:44:58 +00:00
|
|
|
Audio_SetVolScale(0, 2, 0x40, 0xF);
|
|
|
|
Audio_SetVolScale(3, 2, 0x40, 0xF);
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
|
2021-07-27 23:44:58 +00:00
|
|
|
void Audio_ClearBGMMute(u8 arg0) {
|
2020-10-26 11:58:56 +00:00
|
|
|
D_801333D0 &= ((1 << arg0) ^ 0xFFFF);
|
|
|
|
if (D_801333D0 == 0) {
|
2021-07-27 23:44:58 +00:00
|
|
|
Audio_SetVolScale(0, 2, 0x7F, 0xF);
|
|
|
|
Audio_SetVolScale(3, 2, 0x7F, 0xF);
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
// a4 is often the same as freqScale. (u8)(*a4 * 127.0f) is sent to script on IO port 2
|
|
|
|
void Audio_PlaySoundGeneral(u16 sfxId, Vec3f* pos, u8 a2, f32* freqScale, f32* a4, s8* reverbAdd) {
|
2020-10-26 11:58:56 +00:00
|
|
|
u8 i;
|
2021-08-30 00:08:41 +00:00
|
|
|
SoundRequest* req;
|
2020-10-26 11:58:56 +00:00
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
if (!gSoundBankMuted[SFX_BANK_SHIFT(sfxId)]) {
|
|
|
|
req = &sSoundRequests[sSoundRequestWriteIndex];
|
|
|
|
if (!gAudioSEFlagSwapOff) {
|
2020-10-26 11:58:56 +00:00
|
|
|
for (i = 0; i < 10; i++) {
|
2021-08-30 00:08:41 +00:00
|
|
|
if (sfxId == gAudioSEFlagSwapSource[i]) {
|
|
|
|
if (gAudioSEFlagSwapMode[i] == 0) { // "SWAP"
|
|
|
|
sfxId = gAudioSEFlagSwapTarget[i];
|
|
|
|
} else { // "ADD"
|
|
|
|
req->sfxId = gAudioSEFlagSwapTarget[i];
|
|
|
|
req->pos = pos;
|
|
|
|
req->unk_8 = a2;
|
|
|
|
req->freqScale = freqScale;
|
|
|
|
req->unk_10 = a4;
|
|
|
|
req->reverbAdd = reverbAdd;
|
|
|
|
sSoundRequestWriteIndex++;
|
|
|
|
req = &sSoundRequests[sSoundRequestWriteIndex];
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
2021-08-30 00:08:41 +00:00
|
|
|
i = 10; // "break;"
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-08-30 00:08:41 +00:00
|
|
|
req->sfxId = sfxId;
|
|
|
|
req->pos = pos;
|
|
|
|
req->unk_8 = a2;
|
|
|
|
req->freqScale = freqScale;
|
|
|
|
req->unk_10 = a4;
|
|
|
|
req->reverbAdd = reverbAdd;
|
|
|
|
sSoundRequestWriteIndex++;
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
void Audio_RemoveMatchingSoundRequests(u8 aspect, SoundBankEntry* cmp) {
|
|
|
|
SoundRequest* req;
|
|
|
|
s32 remove;
|
|
|
|
u8 i = sSoundRequestReadIndex;
|
2020-10-26 11:58:56 +00:00
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
for (; i != sSoundRequestWriteIndex; i++) {
|
|
|
|
remove = false;
|
|
|
|
req = &sSoundRequests[i];
|
|
|
|
switch (aspect) {
|
2020-10-26 11:58:56 +00:00
|
|
|
case 0:
|
2021-08-31 13:22:56 +00:00
|
|
|
if (SFX_BANK_MASK(req->sfxId) == SFX_BANK_MASK(cmp->sfxId)) {
|
2021-08-30 00:08:41 +00:00
|
|
|
remove = true;
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2021-08-31 13:22:56 +00:00
|
|
|
if (SFX_BANK_MASK(req->sfxId) == SFX_BANK_MASK(cmp->sfxId) && (&req->pos->x == cmp->posX)) {
|
2021-08-30 00:08:41 +00:00
|
|
|
remove = true;
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-08-30 00:08:41 +00:00
|
|
|
if (&req->pos->x == cmp->posX) {
|
|
|
|
remove = true;
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-08-31 13:22:56 +00:00
|
|
|
if (&req->pos->x == cmp->posX && req->sfxId == cmp->sfxId) {
|
2021-08-30 00:08:41 +00:00
|
|
|
remove = true;
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
2021-08-31 13:22:56 +00:00
|
|
|
if (req->unk_8 == cmp->unk_C && req->sfxId == cmp->sfxId) {
|
2021-08-30 00:08:41 +00:00
|
|
|
remove = true;
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
2021-08-31 13:22:56 +00:00
|
|
|
if (req->sfxId == cmp->sfxId) {
|
2021-08-30 00:08:41 +00:00
|
|
|
remove = true;
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2021-08-30 00:08:41 +00:00
|
|
|
if (remove) {
|
|
|
|
req->sfxId = 0;
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
void Audio_ProcessSoundRequest(void) {
|
2021-08-31 13:22:56 +00:00
|
|
|
u16 sfxId;
|
|
|
|
u8 count;
|
|
|
|
u8 index;
|
|
|
|
SoundRequest* req;
|
|
|
|
SoundBankEntry* entry;
|
2021-09-01 22:33:37 +00:00
|
|
|
SoundParams* soundParams;
|
2021-08-31 13:22:56 +00:00
|
|
|
s32 bankId;
|
2021-09-01 22:33:37 +00:00
|
|
|
u8 evictImportance;
|
|
|
|
u8 evictIndex;
|
2020-10-26 11:58:56 +00:00
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
req = &sSoundRequests[sSoundRequestReadIndex];
|
2021-09-01 22:33:37 +00:00
|
|
|
evictIndex = 0x80;
|
2021-08-30 00:08:41 +00:00
|
|
|
if (req->sfxId == 0) {
|
2020-10-26 11:58:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-08-31 13:22:56 +00:00
|
|
|
bankId = SFX_BANK(req->sfxId);
|
|
|
|
if ((1 << bankId) & D_801333F0) {
|
2021-08-30 00:08:41 +00:00
|
|
|
AudioDebug_ScrPrt((const s8*)D_80133340, req->sfxId);
|
2021-08-31 13:22:56 +00:00
|
|
|
bankId = SFX_BANK(req->sfxId);
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
2021-08-31 13:22:56 +00:00
|
|
|
count = 0;
|
|
|
|
index = gSoundBanks[bankId][0].next;
|
|
|
|
while (index != 0xFF && index != 0) {
|
|
|
|
if (gSoundBanks[bankId][index].posX == &req->pos->x) {
|
2021-09-01 22:33:37 +00:00
|
|
|
if ((gSoundParams[SFX_BANK_SHIFT(req->sfxId)][SFX_INDEX(req->sfxId)].params & 0x20) &&
|
|
|
|
gSoundParams[SFX_BANK_SHIFT(req->sfxId)][SFX_INDEX(req->sfxId)].importance ==
|
|
|
|
gSoundBanks[bankId][index].sfxImportance) {
|
2021-03-27 20:01:50 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-08-31 13:22:56 +00:00
|
|
|
if (gSoundBanks[bankId][index].sfxId == req->sfxId) {
|
|
|
|
count = D_80130594[D_801333CC][bankId];
|
2021-03-27 20:01:50 +00:00
|
|
|
} else {
|
2021-08-31 13:22:56 +00:00
|
|
|
if (count == 0) {
|
2021-09-01 22:33:37 +00:00
|
|
|
evictIndex = index;
|
2021-08-31 13:22:56 +00:00
|
|
|
sfxId = gSoundBanks[bankId][index].sfxId & 0xFFFF;
|
2021-09-01 22:33:37 +00:00
|
|
|
evictImportance = gSoundParams[SFX_BANK_SHIFT(sfxId)][SFX_INDEX(sfxId)].importance;
|
|
|
|
} else if (gSoundBanks[bankId][index].sfxImportance < evictImportance) {
|
|
|
|
evictIndex = index;
|
2021-08-31 13:22:56 +00:00
|
|
|
sfxId = gSoundBanks[bankId][index].sfxId & 0xFFFF;
|
2021-09-01 22:33:37 +00:00
|
|
|
evictImportance = gSoundParams[SFX_BANK_SHIFT(sfxId)][SFX_INDEX(sfxId)].importance;
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
2021-08-31 13:22:56 +00:00
|
|
|
count++;
|
|
|
|
if (count == D_80130594[D_801333CC][bankId]) {
|
2021-09-01 22:33:37 +00:00
|
|
|
if (gSoundParams[SFX_BANK_SHIFT(req->sfxId)][SFX_INDEX(req->sfxId)].importance >= evictImportance) {
|
|
|
|
index = evictIndex;
|
|
|
|
} else {
|
|
|
|
index = 0;
|
|
|
|
}
|
2021-03-27 20:01:50 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-31 13:22:56 +00:00
|
|
|
if (count == D_80130594[D_801333CC][bankId]) {
|
2021-09-01 22:33:37 +00:00
|
|
|
soundParams = &gSoundParams[SFX_BANK_SHIFT(req->sfxId)][SFX_INDEX(req->sfxId)];
|
|
|
|
if ((req->sfxId & 0xC00) || (soundParams->params & 4) || (index == evictIndex)) {
|
|
|
|
if ((gSoundBanks[bankId][index].sfxParams & 8) && gSoundBanks[bankId][index].unk_2A != 1) {
|
2021-08-31 13:22:56 +00:00
|
|
|
Audio_ClearBGMMute(gSoundBanks[bankId][index].unk_2E);
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
2021-08-31 13:22:56 +00:00
|
|
|
gSoundBanks[bankId][index].unk_C = req->unk_8;
|
|
|
|
gSoundBanks[bankId][index].sfxId = req->sfxId;
|
|
|
|
gSoundBanks[bankId][index].unk_2A = 1;
|
|
|
|
gSoundBanks[bankId][index].unk_2B = 2;
|
|
|
|
gSoundBanks[bankId][index].freqScale = req->freqScale;
|
|
|
|
gSoundBanks[bankId][index].unk_14 = req->unk_10;
|
|
|
|
gSoundBanks[bankId][index].reverbAdd = req->reverbAdd;
|
2021-09-01 22:33:37 +00:00
|
|
|
gSoundBanks[bankId][index].sfxParams = soundParams->params;
|
|
|
|
gSoundBanks[bankId][index].sfxImportance = soundParams->importance;
|
2021-08-31 13:22:56 +00:00
|
|
|
} else if (gSoundBanks[bankId][index].unk_2A == 5) {
|
|
|
|
gSoundBanks[bankId][index].unk_2A = 4;
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
2021-08-31 13:22:56 +00:00
|
|
|
index = 0;
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-31 13:22:56 +00:00
|
|
|
if (index != 0) {
|
|
|
|
index = gSoundBanks[bankId][index].next;
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-31 13:22:56 +00:00
|
|
|
if (gSoundBanks[bankId][D_8016E1A8[bankId]].next != 0xFF && index != 0) {
|
|
|
|
index = D_8016E1A8[bankId];
|
|
|
|
entry = &gSoundBanks[bankId][index];
|
|
|
|
entry->posX = &req->pos->x;
|
|
|
|
entry->posY = &req->pos->y;
|
|
|
|
entry->posZ = &req->pos->z;
|
|
|
|
entry->unk_C = req->unk_8;
|
|
|
|
entry->freqScale = req->freqScale;
|
|
|
|
entry->unk_14 = req->unk_10;
|
|
|
|
entry->reverbAdd = req->reverbAdd;
|
2021-09-01 22:33:37 +00:00
|
|
|
soundParams = &gSoundParams[SFX_BANK_SHIFT(req->sfxId)][SFX_INDEX(req->sfxId)];
|
|
|
|
entry->sfxParams = soundParams->params;
|
|
|
|
entry->sfxImportance = soundParams->importance;
|
2021-08-31 13:22:56 +00:00
|
|
|
entry->sfxId = req->sfxId;
|
|
|
|
entry->unk_2A = 1;
|
|
|
|
entry->unk_2B = 2;
|
|
|
|
entry->prev = D_8016E1A0[bankId];
|
|
|
|
gSoundBanks[bankId][D_8016E1A0[bankId]].next = D_8016E1A8[bankId];
|
|
|
|
D_8016E1A0[bankId] = D_8016E1A8[bankId];
|
|
|
|
D_8016E1A8[bankId] = gSoundBanks[bankId][D_8016E1A8[bankId]].next;
|
|
|
|
gSoundBanks[bankId][D_8016E1A8[bankId]].prev = 0xFF;
|
|
|
|
entry->next = 0xFF;
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-20 01:08:50 +00:00
|
|
|
|
2020-10-26 11:58:56 +00:00
|
|
|
void func_800F7B54(u8 bankId, u8 bankIndex) {
|
|
|
|
SoundBankEntry* entry = &gSoundBanks[bankId][bankIndex];
|
|
|
|
u8 i;
|
|
|
|
|
2021-09-01 22:33:37 +00:00
|
|
|
if (entry->sfxParams & 8) {
|
2021-07-27 23:44:58 +00:00
|
|
|
Audio_ClearBGMMute(entry->unk_2E);
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
if (bankIndex == D_8016E1A0[bankId]) {
|
|
|
|
D_8016E1A0[bankId] = entry->prev;
|
|
|
|
} else {
|
|
|
|
gSoundBanks[bankId][entry->next].prev = entry->prev;
|
|
|
|
}
|
|
|
|
gSoundBanks[bankId][entry->prev].next = entry->next;
|
|
|
|
entry->next = D_8016E1A8[bankId];
|
|
|
|
entry->prev = 0xFF;
|
|
|
|
gSoundBanks[bankId][D_8016E1A8[bankId]].prev = bankIndex;
|
|
|
|
D_8016E1A8[bankId] = bankIndex;
|
|
|
|
entry->unk_2A = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < D_80130578[D_801333CC][bankId]; i++) {
|
|
|
|
if (D_8016E1B8[bankId][i].unk_4 == bankIndex) {
|
|
|
|
D_8016E1B8[bankId][i].unk_4 = 0xFF;
|
|
|
|
i = D_80130578[D_801333CC][bankId];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-20 01:08:50 +00:00
|
|
|
|
2021-03-27 20:01:50 +00:00
|
|
|
void func_800F7CEC(u8 arg0) {
|
2021-08-30 00:08:41 +00:00
|
|
|
u8 phi_s3;
|
2021-03-27 20:01:50 +00:00
|
|
|
u8 spAE;
|
|
|
|
u8 phi_s4;
|
2021-08-30 00:08:41 +00:00
|
|
|
u8 i;
|
|
|
|
u8 j;
|
2021-03-27 20:01:50 +00:00
|
|
|
u8 phi_s0;
|
2021-09-01 22:33:37 +00:00
|
|
|
u8 sfxImportance;
|
2021-03-27 20:01:50 +00:00
|
|
|
u8 phi_v1_5;
|
|
|
|
u8 temp2;
|
|
|
|
u16 temp3;
|
|
|
|
f32 tempf1;
|
2021-08-30 00:08:41 +00:00
|
|
|
SoundBankEntry* entry;
|
2021-03-27 20:01:50 +00:00
|
|
|
Struct_800F7CEC sp84[3];
|
|
|
|
Struct_800F7CEC* temp_s4_3;
|
|
|
|
s32 pad;
|
|
|
|
|
|
|
|
phi_s3 = 0;
|
2021-08-30 00:08:41 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
2021-09-01 22:33:37 +00:00
|
|
|
sp84[i].priority = 0x7FFFFFFF;
|
2021-08-30 00:08:41 +00:00
|
|
|
sp84[i].unk_4 = 0xFF;
|
2021-03-27 20:01:50 +00:00
|
|
|
}
|
|
|
|
phi_s4 = gSoundBanks[arg0][0].next;
|
|
|
|
phi_s0 = 0;
|
|
|
|
while (phi_s4 != 0xFF) {
|
2021-08-31 13:22:56 +00:00
|
|
|
if ((1 == gSoundBanks[arg0][phi_s4].unk_2A) && (gSoundBanks[arg0][phi_s4].sfxId & 0xC00)) {
|
2021-03-27 20:01:50 +00:00
|
|
|
gSoundBanks[arg0][phi_s4].unk_2B--;
|
2021-08-31 13:22:56 +00:00
|
|
|
} else if (!(gSoundBanks[arg0][phi_s4].sfxId & 0xC00) && (gSoundBanks[arg0][phi_s4].unk_2A == 5)) {
|
2021-07-27 23:44:58 +00:00
|
|
|
Audio_QueueCmdS8((gSoundBanks[arg0][phi_s4].unk_2E << 8) | 0x6020000, 0);
|
2021-03-27 20:01:50 +00:00
|
|
|
func_800F7B54(arg0, phi_s4);
|
|
|
|
}
|
|
|
|
if (gSoundBanks[arg0][phi_s4].unk_2B == 0) {
|
|
|
|
func_800F7B54(arg0, phi_s4);
|
|
|
|
} else if (gSoundBanks[arg0][phi_s4].unk_2A != 0) {
|
2021-08-30 00:08:41 +00:00
|
|
|
entry = &gSoundBanks[arg0][phi_s4];
|
2021-03-27 20:01:50 +00:00
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
if (&D_801333D4.x == entry[0].posX) {
|
|
|
|
entry->dist = 0.0f;
|
2021-03-27 20:01:50 +00:00
|
|
|
} else {
|
2021-08-30 00:08:41 +00:00
|
|
|
tempf1 = *entry->posY * 1;
|
|
|
|
entry->dist = (SQ(*entry->posX) + SQ(tempf1) + SQ(*entry->posZ)) * 1;
|
2021-03-27 20:01:50 +00:00
|
|
|
}
|
2021-09-01 22:33:37 +00:00
|
|
|
sfxImportance = entry->sfxImportance;
|
|
|
|
if (entry->sfxParams & 0x10) {
|
|
|
|
entry->priority = SQ(0xFF - sfxImportance) * SQ(76);
|
2021-03-27 20:01:50 +00:00
|
|
|
} else {
|
2021-08-30 00:08:41 +00:00
|
|
|
if (entry->dist > 0x7FFFFFD0) {
|
|
|
|
entry->dist = 0x70000008;
|
2021-08-31 13:22:56 +00:00
|
|
|
osSyncPrintf(D_80133344, entry->sfxId, entry->posX, entry->posZ, *entry->posX, *entry->posY,
|
|
|
|
*entry->posZ);
|
2021-03-27 20:01:50 +00:00
|
|
|
}
|
2021-08-31 13:22:56 +00:00
|
|
|
temp3 = entry->sfxId;
|
2021-09-01 22:33:37 +00:00
|
|
|
entry->priority = (u32)entry->dist + (SQ(0xFF - sfxImportance) * SQ(76)) + temp3 - temp3;
|
2021-08-30 00:08:41 +00:00
|
|
|
if (*entry->posZ < 0.0f) {
|
2021-09-01 22:33:37 +00:00
|
|
|
entry->priority += (s32)(-*entry->posZ * 6.0f);
|
2021-03-27 20:01:50 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-30 00:08:41 +00:00
|
|
|
if (entry->dist > SQ(1e5f)) {
|
|
|
|
if (entry->unk_2A == 4) {
|
|
|
|
Audio_QueueCmdS8((entry->unk_2E << 8) | 0x6020000, 0);
|
2021-08-31 13:22:56 +00:00
|
|
|
if (entry->sfxId & 0xC00) {
|
2021-03-27 20:01:50 +00:00
|
|
|
func_800F7B54(arg0, phi_s4);
|
|
|
|
phi_s4 = phi_s0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
spAE = D_80130578[D_801333CC][arg0];
|
2021-08-30 00:08:41 +00:00
|
|
|
for (i = 0; i < spAE; i++) {
|
2021-09-01 22:33:37 +00:00
|
|
|
if (sp84[i].priority >= entry->priority) {
|
2021-03-27 20:01:50 +00:00
|
|
|
if (phi_s3 < D_80130578[D_801333CC][arg0]) {
|
|
|
|
phi_s3++;
|
|
|
|
}
|
2021-08-30 00:08:41 +00:00
|
|
|
for (j = spAE - 1; j > i; j--) {
|
2021-09-01 22:33:37 +00:00
|
|
|
sp84[j].priority = sp84[j - 1].priority;
|
2021-08-30 00:08:41 +00:00
|
|
|
sp84[j].unk_4 = sp84[j - 1].unk_4;
|
2021-03-27 20:01:50 +00:00
|
|
|
}
|
2021-09-01 22:33:37 +00:00
|
|
|
sp84[i].priority = entry->priority;
|
2021-08-30 00:08:41 +00:00
|
|
|
sp84[i].unk_4 = phi_s4;
|
2021-09-01 22:33:37 +00:00
|
|
|
i = spAE; // "break;"
|
2021-03-27 20:01:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
phi_s0 = phi_s4;
|
|
|
|
}
|
|
|
|
phi_s4 = gSoundBanks[arg0][phi_s0].next;
|
|
|
|
}
|
2021-08-30 00:08:41 +00:00
|
|
|
for (i = 0; i < phi_s3; i++) {
|
|
|
|
entry = &gSoundBanks[arg0][sp84[i].unk_4];
|
|
|
|
if (entry->unk_2A == 1) {
|
|
|
|
entry->unk_2A = 2;
|
|
|
|
} else if (entry->unk_2A == 4) {
|
|
|
|
entry->unk_2A = 3;
|
2021-03-27 20:01:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
spAE = D_80130578[D_801333CC][arg0];
|
2021-08-30 00:08:41 +00:00
|
|
|
for (i = 0; i < spAE; i++) {
|
2021-03-27 20:01:50 +00:00
|
|
|
phi_v1_5 = 0;
|
2021-08-30 00:08:41 +00:00
|
|
|
temp_s4_3 = &D_8016E1B8[arg0][i];
|
2021-03-27 20:01:50 +00:00
|
|
|
|
|
|
|
if (temp_s4_3->unk_4 == 0xFF) {
|
|
|
|
phi_v1_5 = 1;
|
|
|
|
} else {
|
2021-08-30 00:08:41 +00:00
|
|
|
entry = &gSoundBanks[arg0][temp_s4_3[0].unk_4];
|
|
|
|
if (entry->unk_2A == 4) {
|
2021-08-31 13:22:56 +00:00
|
|
|
if (entry->sfxId & 0xC00) {
|
2021-03-27 20:01:50 +00:00
|
|
|
func_800F7B54(arg0, temp_s4_3->unk_4);
|
|
|
|
} else {
|
2021-08-30 00:08:41 +00:00
|
|
|
entry->unk_2A = 1;
|
2021-03-27 20:01:50 +00:00
|
|
|
}
|
|
|
|
phi_v1_5 = 1;
|
2021-08-30 00:08:41 +00:00
|
|
|
} else if (entry->unk_2A == 0) {
|
2021-03-27 20:01:50 +00:00
|
|
|
temp_s4_3->unk_4 = 0xFF;
|
|
|
|
phi_v1_5 = 1;
|
|
|
|
} else {
|
2021-08-30 00:08:41 +00:00
|
|
|
for (j = 0; j < spAE; j++) {
|
|
|
|
if (temp_s4_3->unk_4 == sp84[j].unk_4) {
|
|
|
|
sp84[j].unk_4 = 0xFF;
|
|
|
|
j = spAE;
|
2021-03-27 20:01:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
phi_s3--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (phi_v1_5 == 1) {
|
2021-08-30 00:08:41 +00:00
|
|
|
for (j = 0; j < spAE; j++) {
|
|
|
|
temp2 = sp84[j].unk_4;
|
2021-03-27 20:01:50 +00:00
|
|
|
if ((temp2 != 0xFF) && (gSoundBanks[arg0][temp2].unk_2A != 3)) {
|
|
|
|
for (phi_s0 = 0; phi_s0 < spAE; phi_s0++) {
|
|
|
|
if (temp2 == D_8016E1B8[arg0][phi_s0].unk_4) {
|
|
|
|
phi_v1_5 = 0;
|
|
|
|
phi_s0 = spAE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (phi_v1_5 == 1) {
|
|
|
|
temp_s4_3->unk_4 = temp2;
|
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
sp84[j].unk_4 = 0xFF;
|
2021-03-27 20:01:50 +00:00
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
j = spAE + 1;
|
2021-03-27 20:01:50 +00:00
|
|
|
phi_s3--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-08-30 00:08:41 +00:00
|
|
|
if (j == spAE) {
|
2021-03-27 20:01:50 +00:00
|
|
|
temp_s4_3->unk_4 = 0xFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-20 01:08:50 +00:00
|
|
|
|
2020-10-26 11:58:56 +00:00
|
|
|
void func_800F8480(u8 bankId) {
|
|
|
|
u8 bankIndex;
|
|
|
|
SequenceChannel* seqChannel;
|
|
|
|
SoundBankEntry* entry;
|
|
|
|
u8 i;
|
|
|
|
|
|
|
|
for (i = 0; i < D_80130578[D_801333CC][bankId]; i++) {
|
|
|
|
bankIndex = D_8016E1B8[bankId][i].unk_4;
|
|
|
|
if (bankIndex != 0xFF) {
|
|
|
|
entry = &gSoundBanks[bankId][bankIndex];
|
2021-07-27 23:44:58 +00:00
|
|
|
seqChannel = gAudioContext.seqPlayers[2].channels[D_8016E260];
|
2020-10-26 11:58:56 +00:00
|
|
|
if (entry->unk_2A == 2) {
|
|
|
|
entry->unk_2E = D_8016E260;
|
2021-09-01 22:33:37 +00:00
|
|
|
if (entry->sfxParams & 8) {
|
2021-07-27 23:44:58 +00:00
|
|
|
Audio_QueueSeqCmdMute(D_8016E260);
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
2021-09-01 22:33:37 +00:00
|
|
|
if (entry->sfxParams & 0xC0) {
|
|
|
|
switch (entry->sfxParams & 0xC0) {
|
2020-10-26 11:58:56 +00:00
|
|
|
case 0x40:
|
|
|
|
entry->unk_2F = Audio_NextRandom() & 0xF;
|
|
|
|
break;
|
|
|
|
case 0x80:
|
|
|
|
entry->unk_2F = Audio_NextRandom() & 0x1F;
|
|
|
|
break;
|
|
|
|
case 0xC0:
|
|
|
|
entry->unk_2F = Audio_NextRandom() & 0x3F;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
entry->unk_2F = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-08-30 00:08:41 +00:00
|
|
|
Audio_SetSoundProperties(bankId, bankIndex, D_8016E260);
|
2021-07-27 23:44:58 +00:00
|
|
|
Audio_QueueCmdS8(0x06020000 | ((D_8016E260 & 0xFF) << 8), 1);
|
2021-08-31 13:22:56 +00:00
|
|
|
Audio_QueueCmdS8(0x06020000 | ((D_8016E260 & 0xFF) << 8) | 4, entry->sfxId & 0xFF);
|
2020-10-26 11:58:56 +00:00
|
|
|
if (D_80130570[bankId] != 0) {
|
2021-08-31 13:22:56 +00:00
|
|
|
Audio_QueueCmdS8(0x06020000 | ((D_8016E260 & 0xFF) << 8) | 5, (entry->sfxId & 0x100) >> 8);
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
2021-08-31 13:22:56 +00:00
|
|
|
if (entry->sfxId & 0xC00) {
|
2020-10-26 11:58:56 +00:00
|
|
|
entry->unk_2A = 4;
|
|
|
|
} else {
|
|
|
|
entry->unk_2A = 5;
|
|
|
|
}
|
|
|
|
} else if ((u8)seqChannel->soundScriptIO[1] == 0xFF) {
|
|
|
|
func_800F7B54(bankId, bankIndex);
|
|
|
|
} else if (entry->unk_2A == 3) {
|
2021-08-30 00:08:41 +00:00
|
|
|
Audio_SetSoundProperties(bankId, bankIndex, D_8016E260);
|
2021-08-31 13:22:56 +00:00
|
|
|
if (entry->sfxId & 0xC00) {
|
2020-10-26 11:58:56 +00:00
|
|
|
entry->unk_2A = 4;
|
|
|
|
} else {
|
|
|
|
entry->unk_2A = 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
D_8016E260++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void func_800F87A0(u8 bankId) {
|
|
|
|
SoundBankEntry* entry;
|
|
|
|
s32 pad;
|
2021-08-30 00:08:41 +00:00
|
|
|
SoundBankEntry cmp;
|
2020-10-26 11:58:56 +00:00
|
|
|
u8 bankIndex = gSoundBanks[bankId][0].next;
|
|
|
|
|
|
|
|
while (bankIndex != 0xFF) {
|
|
|
|
entry = &gSoundBanks[bankId][bankIndex];
|
|
|
|
if (entry->unk_2A >= 3) {
|
2021-07-27 23:44:58 +00:00
|
|
|
Audio_QueueCmdS8(0x06020000 | ((entry->unk_2E & 0xFF) << 8), 0);
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
if (entry->unk_2A != 0) {
|
|
|
|
func_800F7B54(bankId, bankIndex);
|
|
|
|
}
|
|
|
|
bankIndex = gSoundBanks[bankId][0].next;
|
|
|
|
}
|
2021-08-31 13:22:56 +00:00
|
|
|
cmp.sfxId = bankId << 12;
|
2021-08-30 00:08:41 +00:00
|
|
|
Audio_RemoveMatchingSoundRequests(0, &cmp);
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void func_800F8884(u8 bankId, Vec3f* pos) {
|
|
|
|
SoundBankEntry* entry;
|
|
|
|
u8 bankIndex = gSoundBanks[bankId][0].next;
|
|
|
|
u8 bankIndex2 = 0;
|
|
|
|
|
|
|
|
while (bankIndex != 0xFF) {
|
|
|
|
entry = &gSoundBanks[bankId][bankIndex];
|
|
|
|
if (entry->posX == &pos->x) {
|
|
|
|
if (entry->unk_2A >= 3) {
|
2021-07-27 23:44:58 +00:00
|
|
|
Audio_QueueCmdS8(0x06020000 | ((entry->unk_2E & 0xFF) << 8), 0);
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
if (entry->unk_2A != 0) {
|
|
|
|
func_800F7B54(bankId, bankIndex);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
bankIndex2 = bankIndex;
|
|
|
|
}
|
|
|
|
bankIndex = gSoundBanks[bankId][bankIndex2].next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void func_800F89A0(u8 bankId, Vec3f* pos) {
|
2021-08-30 00:08:41 +00:00
|
|
|
SoundBankEntry cmp;
|
2020-10-26 11:58:56 +00:00
|
|
|
|
|
|
|
func_800F8884(bankId, pos);
|
2021-08-31 13:22:56 +00:00
|
|
|
cmp.sfxId = bankId << 12;
|
2021-08-30 00:08:41 +00:00
|
|
|
cmp.posX = &pos->x;
|
|
|
|
Audio_RemoveMatchingSoundRequests(1, &cmp);
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void func_800F89E8(Vec3f* pos) {
|
|
|
|
u8 i;
|
2021-08-30 00:08:41 +00:00
|
|
|
SoundBankEntry cmp;
|
2020-10-26 11:58:56 +00:00
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_COUNT(gSoundBanks); i++) {
|
|
|
|
func_800F8884(i, pos);
|
|
|
|
}
|
2021-08-30 00:08:41 +00:00
|
|
|
cmp.posX = &pos->x;
|
|
|
|
Audio_RemoveMatchingSoundRequests(2, &cmp);
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void func_800F8A44(Vec3f* pos, u16 sfxId) {
|
|
|
|
SoundBankEntry* entry;
|
|
|
|
u8 bankIndex = gSoundBanks[SFX_BANK(sfxId)][0].next;
|
|
|
|
u8 bankIndex2 = 0;
|
2021-08-30 00:08:41 +00:00
|
|
|
SoundBankEntry cmp;
|
2020-10-26 11:58:56 +00:00
|
|
|
|
|
|
|
while (bankIndex != 0xFF) {
|
|
|
|
entry = &gSoundBanks[SFX_BANK(sfxId)][bankIndex];
|
2021-08-31 13:22:56 +00:00
|
|
|
if (entry->posX == &pos->x && entry->sfxId == sfxId) {
|
2020-10-26 11:58:56 +00:00
|
|
|
if (entry->unk_2A >= 3) {
|
2021-07-27 23:44:58 +00:00
|
|
|
Audio_QueueCmdS8(0x06020000 | ((entry->unk_2E & 0xFF) << 8), 0);
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
if (entry->unk_2A != 0) {
|
|
|
|
func_800F7B54(SFX_BANK(sfxId), bankIndex);
|
|
|
|
}
|
|
|
|
bankIndex = 0xFF;
|
|
|
|
} else {
|
|
|
|
bankIndex2 = bankIndex;
|
|
|
|
}
|
|
|
|
if (bankIndex != 0xFF) {
|
|
|
|
bankIndex = gSoundBanks[SFX_BANK(sfxId)][bankIndex2].next;
|
|
|
|
}
|
|
|
|
}
|
2021-08-30 00:08:41 +00:00
|
|
|
cmp.posX = &pos->x;
|
2021-08-31 13:22:56 +00:00
|
|
|
cmp.sfxId = sfxId;
|
2021-08-30 00:08:41 +00:00
|
|
|
Audio_RemoveMatchingSoundRequests(3, &cmp);
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void func_800F8BA0(u8 arg0, u16 sfxId) {
|
|
|
|
SoundBankEntry* entry;
|
|
|
|
u8 bankIndex = gSoundBanks[SFX_BANK(sfxId)][0].next;
|
|
|
|
u8 bankIndex2 = 0;
|
2021-08-30 00:08:41 +00:00
|
|
|
SoundBankEntry cmp;
|
2020-10-26 11:58:56 +00:00
|
|
|
|
|
|
|
while (bankIndex != 0xFF) {
|
|
|
|
entry = &gSoundBanks[SFX_BANK(sfxId)][bankIndex];
|
2021-08-31 13:22:56 +00:00
|
|
|
if (entry->unk_C == arg0 && entry->sfxId == sfxId) {
|
2020-10-26 11:58:56 +00:00
|
|
|
if (entry->unk_2A >= 3) {
|
2021-07-27 23:44:58 +00:00
|
|
|
Audio_QueueCmdS8(0x06020000 | ((entry->unk_2E & 0xFF) << 8), 0);
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
if (entry->unk_2A != 0) {
|
|
|
|
func_800F7B54(SFX_BANK(sfxId), bankIndex);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
bankIndex2 = bankIndex;
|
|
|
|
}
|
|
|
|
if (bankIndex != 0xFF) {
|
|
|
|
bankIndex = gSoundBanks[SFX_BANK(sfxId)][bankIndex2].next;
|
|
|
|
}
|
|
|
|
}
|
2021-08-30 00:08:41 +00:00
|
|
|
cmp.unk_C = arg0;
|
2021-08-31 13:22:56 +00:00
|
|
|
cmp.sfxId = sfxId;
|
2021-08-30 00:08:41 +00:00
|
|
|
Audio_RemoveMatchingSoundRequests(4, &cmp);
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
|
2021-07-27 23:44:58 +00:00
|
|
|
void Audio_StopSfx(u32 sfxId) {
|
2020-10-26 11:58:56 +00:00
|
|
|
SoundBankEntry* entry;
|
|
|
|
u8 bankIndex = gSoundBanks[SFX_BANK(sfxId)][0].next;
|
|
|
|
u8 bankIndex2 = 0;
|
2021-08-30 00:08:41 +00:00
|
|
|
SoundBankEntry cmp;
|
2020-07-20 01:08:50 +00:00
|
|
|
|
2020-10-26 11:58:56 +00:00
|
|
|
while (bankIndex != 0xFF) {
|
|
|
|
entry = &gSoundBanks[SFX_BANK(sfxId)][bankIndex];
|
2021-08-31 13:22:56 +00:00
|
|
|
if (entry->sfxId == sfxId) {
|
2020-10-26 11:58:56 +00:00
|
|
|
if (entry->unk_2A >= 3) {
|
2021-07-27 23:44:58 +00:00
|
|
|
Audio_QueueCmdS8(0x06020000 | ((entry->unk_2E & 0xFF) << 8), 0);
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
if (entry->unk_2A != 0) {
|
|
|
|
func_800F7B54(SFX_BANK(sfxId), bankIndex);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
bankIndex2 = bankIndex;
|
|
|
|
}
|
|
|
|
bankIndex = gSoundBanks[SFX_BANK(sfxId)][bankIndex2].next;
|
|
|
|
}
|
2021-08-31 13:22:56 +00:00
|
|
|
cmp.sfxId = sfxId;
|
2021-08-30 00:08:41 +00:00
|
|
|
Audio_RemoveMatchingSoundRequests(5, &cmp);
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
2020-07-20 01:08:50 +00:00
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
void Audio_ProcessSoundRequests(void) {
|
|
|
|
while (sSoundRequestWriteIndex != sSoundRequestReadIndex) {
|
|
|
|
Audio_ProcessSoundRequest();
|
|
|
|
sSoundRequestReadIndex++;
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-20 01:08:50 +00:00
|
|
|
|
2020-10-26 11:58:56 +00:00
|
|
|
void func_800F8EA0(u8 arg0, u8 arg1, u16 arg2) {
|
|
|
|
if (arg2 == 0) {
|
|
|
|
arg2++;
|
|
|
|
}
|
|
|
|
D_8016E270[arg0].unk_4 = arg1 / 127.0f;
|
|
|
|
D_8016E270[arg0].unk_C = arg2;
|
|
|
|
D_8016E270[arg0].unk_8 = ((D_8016E270[arg0].unk_0 - D_8016E270[arg0].unk_4) / arg2);
|
|
|
|
}
|
2020-07-20 01:08:50 +00:00
|
|
|
|
2020-10-26 11:58:56 +00:00
|
|
|
void func_800F8F34(u8 arg0) {
|
|
|
|
if (D_8016E270[arg0].unk_C != 0) {
|
|
|
|
D_8016E270[arg0].unk_C--;
|
|
|
|
if (D_8016E270[arg0].unk_C != 0) {
|
|
|
|
D_8016E270[arg0].unk_0 -= D_8016E270[arg0].unk_8;
|
|
|
|
} else {
|
|
|
|
D_8016E270[arg0].unk_0 = D_8016E270[arg0].unk_4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-20 01:08:50 +00:00
|
|
|
|
2020-10-26 11:58:56 +00:00
|
|
|
void func_800F8F88(void) {
|
|
|
|
u8 i;
|
2020-07-20 01:08:50 +00:00
|
|
|
|
2021-07-27 23:44:58 +00:00
|
|
|
if (IS_SEQUENCE_CHANNEL_VALID(gAudioContext.seqPlayers[2].channels[0])) {
|
2020-10-26 11:58:56 +00:00
|
|
|
D_8016E260 = 0;
|
|
|
|
for (i = 0; i < ARRAY_COUNT(gSoundBanks); i++) {
|
|
|
|
func_800F7CEC(i);
|
|
|
|
func_800F8480(i);
|
|
|
|
func_800F8F34(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-20 01:08:50 +00:00
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
u8 Audio_IsSfxPlaying(u32 sfxId) {
|
2020-10-26 11:58:56 +00:00
|
|
|
SoundBankEntry* entry;
|
|
|
|
u8 bankIndex = gSoundBanks[SFX_BANK(sfxId)][0].next;
|
2020-07-20 01:08:50 +00:00
|
|
|
|
2020-10-26 11:58:56 +00:00
|
|
|
while (bankIndex != 0xFF) {
|
|
|
|
entry = &gSoundBanks[SFX_BANK(sfxId)][bankIndex];
|
2021-08-31 13:22:56 +00:00
|
|
|
if (entry->sfxId == sfxId) {
|
2020-10-26 11:58:56 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bankIndex = entry->next;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2020-07-20 01:08:50 +00:00
|
|
|
|
2020-10-26 11:58:56 +00:00
|
|
|
void func_800F905C(void) {
|
|
|
|
u8 bankId;
|
|
|
|
u8 i;
|
|
|
|
u8 bankIndex;
|
2020-07-20 01:08:50 +00:00
|
|
|
|
2021-08-30 00:08:41 +00:00
|
|
|
sSoundRequestWriteIndex = 0;
|
|
|
|
sSoundRequestReadIndex = 0;
|
2020-10-26 11:58:56 +00:00
|
|
|
D_801333D0 = 0;
|
|
|
|
for (bankId = 0; bankId < ARRAY_COUNT(gSoundBanks); bankId++) {
|
|
|
|
D_8016E1A0[bankId] = 0;
|
|
|
|
D_8016E1A8[bankId] = 1;
|
|
|
|
D_8016E1B0[bankId] = 0;
|
2021-08-30 00:08:41 +00:00
|
|
|
gSoundBankMuted[bankId] = false;
|
2020-10-26 11:58:56 +00:00
|
|
|
D_8016E270[bankId].unk_0 = 1.0f;
|
|
|
|
D_8016E270[bankId].unk_C = 0;
|
|
|
|
}
|
|
|
|
for (bankId = 0; bankId < ARRAY_COUNT(gSoundBanks); bankId++) {
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
D_8016E1B8[bankId][i].unk_4 = 0xFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (bankId = 0; bankId < ARRAY_COUNT(gSoundBanks); bankId++) {
|
|
|
|
gSoundBanks[bankId][0].prev = 0xFF;
|
|
|
|
gSoundBanks[bankId][0].next = 0xFF;
|
|
|
|
for (i = 1; i < sBankSizes[bankId] - 1; i++) {
|
|
|
|
gSoundBanks[bankId][i].prev = i - 1;
|
|
|
|
gSoundBanks[bankId][i].next = i + 1;
|
|
|
|
}
|
|
|
|
gSoundBanks[bankId][i].prev = i - 1;
|
|
|
|
gSoundBanks[bankId][i].next = 0xFF;
|
|
|
|
}
|
|
|
|
if (D_801333F8 == 0) {
|
|
|
|
for (bankId = 0; bankId < 10; bankId++) {
|
2021-08-30 00:08:41 +00:00
|
|
|
gAudioSEFlagSwapSource[bankId] = 0;
|
|
|
|
gAudioSEFlagSwapTarget[bankId] = 0;
|
|
|
|
gAudioSEFlagSwapMode[bankId] = 0;
|
2020-10-26 11:58:56 +00:00
|
|
|
}
|
|
|
|
D_801333F8++;
|
|
|
|
}
|
|
|
|
}
|