summaryrefslogtreecommitdiff
path: root/src/egg/audio/eggAudioSystem.cpp
blob: 50d8634de719fdc43d9f08d4e50de1cda0e9ba67 (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
#include <egg/audio/eggAudioSystem.h>
#include <nw4r/snd/snd_SoundSystem.h>

namespace EGG {

AudioSystem *AudioSystem::sInstanse;

AudioSystem::AudioSystem() {
    field_0x00 = 1.0f;
    field_0x08 = 0;
    field_0x04 = 0;
    sInstanse = this;
}

AudioSystem::~AudioSystem() {}

void AudioSystem::fn_804B7270(s32 frame) {
    if (field_0x08 == 0 && field_0x04 == 0) {
        field_0x00 = nw4r::snd::SoundSystem::GetMasterVolume();
        nw4r::snd::SoundSystem::SetMasterVolume(0.0f, frame * 16.666667f);
        field_0x04 = 1;
    }
}

void AudioSystem::fn_804B7370() {
    if (field_0x08 == 0) {
        nw4r::snd::SoundSystem::SetMasterVolume(field_0x00, 0);
        field_0x04 = 0;
    }
}

void AudioSystem::fn_804B73D0(s32 frame) {
    if (field_0x08 == 0) {
        field_0x08 = 1;
        nw4r::snd::SoundSystem::SetMasterVolume(0.0f, frame * 16.666667f);
    }
}

void AudioSystem::calc() {
    f32 masterVolume = nw4r::snd::SoundSystem::GetMasterVolume();

    if (field_0x08 == 1 && masterVolume == 0.0f) {
        nw4r::snd::SoundSystem::PrepareReset();
        nw4r::snd::SoundSystem::WaitForResetReady();
        field_0x08 = 2;
    }

    if (field_0x08 != 2 && field_0x04 == 1 && masterVolume == 0.0f) {
        field_0x04 = 2;
    }
}

} // namespace EGG