2020-10-03 15:22:44 +00:00
|
|
|
#include "global.h"
|
2020-05-01 02:00:39 +00:00
|
|
|
|
|
|
|
void func_8006BA00(GlobalContext* globalCtx) {
|
|
|
|
SoundSource* sources = &globalCtx->soundSources[0];
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
// clang-format off
|
|
|
|
for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) { sources[i].countdown = 0; }
|
|
|
|
// clang-format on
|
|
|
|
}
|
|
|
|
|
|
|
|
void func_8006BA30(GlobalContext* globalCtx) {
|
2021-02-14 00:49:40 +00:00
|
|
|
SoundSource* source = &globalCtx->soundSources[0];
|
2020-05-01 02:00:39 +00:00
|
|
|
s32 i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) {
|
|
|
|
if (source->countdown != 0) {
|
|
|
|
if (DECR(source->countdown) == 0) {
|
2021-11-07 16:58:50 +00:00
|
|
|
Audio_StopSfxByPos(&source->relativePos);
|
2020-05-01 02:00:39 +00:00
|
|
|
} else {
|
2020-08-08 15:23:16 +00:00
|
|
|
SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->mf_11D60, &source->originPos, &source->relativePos);
|
2020-05-01 02:00:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
source++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Audio_PlaySoundAtPosition(GlobalContext* globalCtx, Vec3f* pos, s32 duration, u16 sfxId) {
|
|
|
|
s32 countdown;
|
|
|
|
SoundSource* source;
|
2021-02-14 00:49:40 +00:00
|
|
|
s32 smallestCountdown = 0xFFFF;
|
2020-05-01 02:00:39 +00:00
|
|
|
SoundSource* backupSource;
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
source = &globalCtx->soundSources[0];
|
|
|
|
for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) {
|
|
|
|
if (source->countdown == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
countdown = source->countdown;
|
|
|
|
if (countdown < smallestCountdown) {
|
|
|
|
smallestCountdown = countdown;
|
|
|
|
backupSource = source;
|
|
|
|
}
|
|
|
|
source++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i >= ARRAY_COUNT(globalCtx->soundSources)) {
|
|
|
|
source = backupSource;
|
2021-11-07 16:58:50 +00:00
|
|
|
Audio_StopSfxByPos(&source->relativePos);
|
2020-05-01 02:00:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
source->originPos = *pos;
|
|
|
|
source->countdown = duration;
|
|
|
|
|
2020-08-08 15:23:16 +00:00
|
|
|
SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->mf_11D60, &source->originPos, &source->relativePos);
|
2020-05-01 02:00:39 +00:00
|
|
|
Audio_PlaySoundGeneral(sfxId, &source->relativePos, 4, &D_801333E0, &D_801333E0, &D_801333E8);
|
|
|
|
}
|