summaryrefslogtreecommitdiff
path: root/arm7/lib/src
diff options
context:
space:
mode:
authorMichael Panzlaff <michael.panzlaff@fau.de>2021-08-01 12:39:24 +0200
committerMichael Panzlaff <michael.panzlaff@fau.de>2021-08-25 18:03:50 +0200
commit07509f83f91c412f9150c52b4467429ac46eefe2 (patch)
tree0e299dba7efe65b4bac35f7ac67b02d09fba8ba8 /arm7/lib/src
parent94657eec81f491a4d5925b2965bb1ea0d635705e (diff)
arm7: split SND into SND_global and SND_channel
Diffstat (limited to 'arm7/lib/src')
-rw-r--r--arm7/lib/src/SND_channel.c (renamed from arm7/lib/src/SND.c)51
-rw-r--r--arm7/lib/src/SND_command.c3
-rw-r--r--arm7/lib/src/SND_exChannel.c5
-rw-r--r--arm7/lib/src/SND_global.c53
-rw-r--r--arm7/lib/src/SND_main.c2
-rw-r--r--arm7/lib/src/SND_work.c1
6 files changed, 62 insertions, 53 deletions
diff --git a/arm7/lib/src/SND.c b/arm7/lib/src/SND_channel.c
index c4b9d900..99b80a7c 100644
--- a/arm7/lib/src/SND.c
+++ b/arm7/lib/src/SND_channel.c
@@ -1,11 +1,6 @@
-#include "SND.h"
+#include "SND_channel.h"
#include "registers.h"
-#include "syscall.h"
-
-#include "OS_system.h"
-#include "PM.h"
-#include "SND_exChannel.h"
#include "SND_work.h"
static int sMasterPan = -1;
@@ -154,47 +149,3 @@ static int CalcSurroundDecay(int vol, int pan) {
return vol * (-sSurroundDecay * (pan - 40) + ((sSurroundDecay + 0x7FFF) << 6)) >> 21;
}
}
-
-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));
-}
diff --git a/arm7/lib/src/SND_command.c b/arm7/lib/src/SND_command.c
index ada6161c..bcb43d73 100644
--- a/arm7/lib/src/SND_command.c
+++ b/arm7/lib/src/SND_command.c
@@ -7,10 +7,11 @@
#include "PXI_fifo.h"
#include "OS_message.h"
#include "OS_system.h"
-#include "SND.h"
+#include "SND_channel.h"
#include "SND_alarm.h"
#include "SND_capture.h"
#include "SND_exChannel.h"
+#include "SND_global.h"
#include "SND_main.h"
#include "SND_seq.h"
#include "SND_work.h"
diff --git a/arm7/lib/src/SND_exChannel.c b/arm7/lib/src/SND_exChannel.c
index 7e41aea3..01bd4f3e 100644
--- a/arm7/lib/src/SND_exChannel.c
+++ b/arm7/lib/src/SND_exChannel.c
@@ -1,5 +1,6 @@
#include "SND_exChannel.h"
+#include "SND_channel.h"
#include "SND_main.h"
#include "SND_work.h"
#include "SND_util.h"
@@ -16,6 +17,8 @@ static u32 sWeakLockedChannelMask;
// TODO remove this extern once we actually know where this table is
extern u8 sSampleDataShiftTable[4];
+static u16 CalcDecayCoeff(int vol);
+
void SND_ExChannelInit(void) {
struct SNDExChannel *chn;
s32 i;
@@ -471,7 +474,7 @@ int SND_GetLfoValue(struct SNDLfo *lfo) {
}
}
-u16 CalcDecayCoeff(int vol) {
+static u16 CalcDecayCoeff(int vol) {
if (vol == 127)
return 0xFFFF;
else if (vol == 126)
diff --git a/arm7/lib/src/SND_global.c b/arm7/lib/src/SND_global.c
new file mode 100644
index 00000000..0654934f
--- /dev/null
+++ b/arm7/lib/src/SND_global.c
@@ -0,0 +1,53 @@
+#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));
+}
diff --git a/arm7/lib/src/SND_main.c b/arm7/lib/src/SND_main.c
index 96dcdc78..24e81d2c 100644
--- a/arm7/lib/src/SND_main.c
+++ b/arm7/lib/src/SND_main.c
@@ -2,11 +2,11 @@
#include "global.h"
-#include "SND.h"
#include "SND_alarm.h"
#include "SND_capture.h"
#include "SND_command.h"
#include "SND_exChannel.h"
+#include "SND_global.h"
#include "SND_seq.h"
#include "SND_util.h"
#include "SND_work.h"
diff --git a/arm7/lib/src/SND_work.c b/arm7/lib/src/SND_work.c
index 3f0d10f0..d40ccdc6 100644
--- a/arm7/lib/src/SND_work.c
+++ b/arm7/lib/src/SND_work.c
@@ -1,5 +1,6 @@
#include "SND_work.h"
+#include "SND_channel.h"
#include "SND_exChannel.h"
#include "SND_capture.h"