summaryrefslogtreecommitdiff
path: root/src/egg/audio/eggAudioSystem.cpp
diff options
context:
space:
mode:
authorrobojumper <robojumper@gmail.com>2024-10-16 03:44:09 +0200
committerGitHub <noreply@github.com>2024-10-15 21:44:09 -0400
commitbf79fa17fbc106fd06c545732ad875275821376e (patch)
tree17249f9386cb4e6d174090772ac7fe2cb702a5d9 /src/egg/audio/eggAudioSystem.cpp
parent40b04ad7247e1d60ac99f62698e7c04388bfcdfc (diff)
Untangle eggAudio a bit (#61)
* Untangle eggAudio a bit * eggAudioRmtSpeakerMgr with a regswap * Fix eggAudioRmtSpeakerMgr (thanks Cuyler!) * eggAudioUtility with two regswaps
Diffstat (limited to 'src/egg/audio/eggAudioSystem.cpp')
-rw-r--r--src/egg/audio/eggAudioSystem.cpp52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/egg/audio/eggAudioSystem.cpp b/src/egg/audio/eggAudioSystem.cpp
index 12b88463..50d8634d 100644
--- a/src/egg/audio/eggAudioSystem.cpp
+++ b/src/egg/audio/eggAudioSystem.cpp
@@ -1,3 +1,53 @@
#include <egg/audio/eggAudioSystem.h>
+#include <nw4r/snd/snd_SoundSystem.h>
-namespace EGG {} // namespace EGG
+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