aboutsummaryrefslogtreecommitdiff
path: root/src/psp/audio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/psp/audio.c')
-rw-r--r--src/psp/audio.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/src/psp/audio.c b/src/psp/audio.c
new file mode 100644
index 0000000..7b4242f
--- /dev/null
+++ b/src/psp/audio.c
@@ -0,0 +1,87 @@
+#include "audio.h"
+#include "../game.h"
+
+void PHL_AudioInit()
+{
+ oslInitAudio();
+}
+
+void PHL_AudioClose()
+{
+ oslDeinitAudio();
+}
+
+//Each system can use a custom music file format
+OSL_SOUND* PHL_LoadMusic(char* fname, int loop)
+{
+ char stream = 0;
+
+ OSL_SOUND* result = NULL;
+
+ char fullPath[40];
+ strcpy(fullPath, fname);
+ strcat(fullPath, ".bgm");
+
+ FILE* file;
+
+ if ( (file = fopen(fullPath, "r")) ) {
+ fclose(file);
+ result = oslLoadSoundFile(fullPath, stream);
+ oslSetSoundLoop(result, loop);
+ }
+
+ return result;
+}
+
+OSL_SOUND* PHL_LoadSound(char* fname)
+{
+ char stream = 0;
+
+ OSL_SOUND* result = NULL;
+
+ char fullPath[40];
+ strcpy(fullPath, fname);
+
+ FILE* file;
+
+ if ( (file = fopen(fullPath, "r")) ) {
+ fclose(file);
+ result = oslLoadSoundFile(fullPath, stream);
+ oslSetSoundLoop(result, 0);
+ }
+
+ return result;
+}
+
+
+void PHL_PlayMusic(OSL_SOUND* snd)
+{
+ //Music always plays on the first channel
+ PHL_PlaySound(snd, 0);
+}
+
+void PHL_PlaySound(OSL_SOUND* snd, int channel)
+{
+ if (snd) {
+ oslPlaySound(snd, channel);
+ }
+}
+
+void PHL_StopMusic()
+{
+ PHL_StopSound(bgmMusic, 0);
+}
+
+void PHL_StopSound(OSL_SOUND* snd, int channel)
+{
+ if (snd) {
+ oslStopSound(snd);
+ }
+}
+
+void PHL_FreeSound(OSL_SOUND* snd)
+{
+ if (snd) {
+ oslDeleteSound(snd);
+ }
+} \ No newline at end of file