summaryrefslogtreecommitdiff
path: root/arm7/lib/src/SND_global.c
diff options
context:
space:
mode:
authorPikalaxALT <PikalaxALT@users.noreply.github.com>2021-08-28 14:40:42 -0400
committerGitHub <noreply@github.com>2021-08-28 14:40:42 -0400
commit3e43c51f3902901642255bb9e932656e136afc1a (patch)
tree5b438458b1ebd92e25413aee8bcf5368b9d71049 /arm7/lib/src/SND_global.c
parente6e6e3a36e2f7413b5278a88696932b9dd22555a (diff)
parent7994935696dcf9d81888e2d9d991f4b6a3e00738 (diff)
Merge branch 'master' into pikalax_work
Diffstat (limited to 'arm7/lib/src/SND_global.c')
-rw-r--r--arm7/lib/src/SND_global.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/arm7/lib/src/SND_global.c b/arm7/lib/src/SND_global.c
new file mode 100644
index 00000000..c78fcd5f
--- /dev/null
+++ b/arm7/lib/src/SND_global.c
@@ -0,0 +1,63 @@
+#include "SND_global.h"
+
+#include "SND_channel.h"
+#include "SND_work.h"
+
+#include "OS_system.h"
+#include "PM.h"
+#include "registers.h"
+#include "syscall.h"
+
+void SND_Enable(void)
+{
+ reg_SOUNDCNT_MIX |= 0x80;
+}
+
+void SND_Disable(void)
+{
+ reg_SOUNDCNT_MIX &= ~0x80;
+}
+
+void SND_Shutdown(void)
+{
+ SND_Disable();
+
+ for (int i = 0; i < SND_CHANNEL_COUNT; i++)
+ {
+ SND_StopChannel(i, 1);
+ }
+
+ reg_SNDCAPxCNT(0) = 0;
+ reg_SNDCAPxCNT(1) = 0;
+}
+
+void SND_BeginSleep(void)
+{
+ SND_Disable();
+ SVC_SoundBiasReset(0x80);
+ OS_SpinWait(0x40000);
+ PMi_ResetControl(1);
+ reg_POWCNT2 &= ~1;
+}
+
+void SND_EndSleep(void)
+{
+ reg_POWCNT2 |= 1; // enable speakers
+ PMi_SetControl(1);
+ SVC_SoundBiasSet(0x100);
+ OS_SpinWait(0x7AB80); // what does this wait for and how long does it wait?
+ SND_Enable();
+}
+
+void SND_SetMasterVolume(int vol)
+{
+ reg_SOUNDCNT_VOL = (u8)vol;
+}
+
+void SND_SetOutputSelector(
+ int leftOutputFrom, int rightOutputFrom, int outputCh1ToMixer, int outputCh3ToMixer)
+{
+ int masterEnable = (reg_SOUNDCNT_MIX & 0x80) ? 1 : 0;
+ reg_SOUNDCNT_MIX = (u8)((masterEnable << 7) | (outputCh3ToMixer << 5) |
+ (outputCh1ToMixer << 4) | (rightOutputFrom << 2) | (leftOutputFrom));
+}