aboutsummaryrefslogtreecommitdiff
path: root/src/psp/audio.c
diff options
context:
space:
mode:
authorptitSeb2017-11-30 22:49:38 +0100
committerptitSeb2017-11-30 22:49:38 +0100
commitde29b11a88dbdd3af0824e59b51528b91ee73c54 (patch)
treee1aabf8752043998663279fae4359a18c4b4af07 /src/psp/audio.c
parentd87f450f51372ddf013e6bac09f1ef588e6f8bea (diff)
downloadhydracastlelabyrinth-de29b11a88dbdd3af0824e59b51528b91ee73c54.tar.gz
hydracastlelabyrinth-de29b11a88dbdd3af0824e59b51528b91ee73c54.tar.bz2
hydracastlelabyrinth-de29b11a88dbdd3af0824e59b51528b91ee73c54.zip
First commit. Version works on Linux (keyboard only, not configurable)
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