blob: 9cc18bfa57758c9f101c3fe00b2203d710bd1d3b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#include "global.h"
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) {
SoundSource* source = &globalCtx->soundSources[0];
s32 i;
for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) {
if (source->countdown != 0) {
if (DECR(source->countdown) == 0) {
Audio_StopSfxByPos(&source->relativePos);
} else {
SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &source->originPos, &source->relativePos);
}
}
source++;
}
}
void Audio_PlaySoundAtPosition(GlobalContext* globalCtx, Vec3f* pos, s32 duration, u16 sfxId) {
s32 countdown;
SoundSource* source;
s32 smallestCountdown = 0xFFFF;
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;
Audio_StopSfxByPos(&source->relativePos);
}
source->originPos = *pos;
source->countdown = duration;
SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &source->originPos, &source->relativePos);
Audio_PlaySoundGeneral(sfxId, &source->relativePos, 4, &D_801333E0, &D_801333E0, &D_801333E8);
}
|