aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2005-04-29 10:07:00 +0000
committerTorbjörn Andersson2005-04-29 10:07:00 +0000
commit9bd7d78199341c0698c0047eff0228f3fdc9f1a1 (patch)
tree56b2c4787f65c5f4a86701f361bd2681a50acd6d
parentf8283f3aa5871f382e6ef1583655cfb83626877c (diff)
downloadscummvm-rg350-9bd7d78199341c0698c0047eff0228f3fdc9f1a1.tar.gz
scummvm-rg350-9bd7d78199341c0698c0047eff0228f3fdc9f1a1.tar.bz2
scummvm-rg350-9bd7d78199341c0698c0047eff0228f3fdc9f1a1.zip
Some limited - and quite possibly wrong - sound effects support. I have
assumed, given their tiny size, that the sound samples are 8-bit mono. Looping is not implemented yet. Some sounds are skipped since the engine asks that they be played at a negative sample rate. (I think there is more to this than just a simple signed/unsigned issue, because they sound wrong even if I treat the frequency as unsigned.) svn-id: r17862
-rw-r--r--gob/gob.cpp2
-rw-r--r--gob/gob.h2
-rw-r--r--gob/sound.cpp70
-rw-r--r--gob/sound.h6
4 files changed, 54 insertions, 26 deletions
diff --git a/gob/gob.cpp b/gob/gob.cpp
index e8e9d292b9..a7117ac35a 100644
--- a/gob/gob.cpp
+++ b/gob/gob.cpp
@@ -88,7 +88,7 @@ REGISTER_PLUGIN(GOB, "Gob Engine")
namespace Gob {
#define MAX_TIME_DELTA 100
- GobEngine *_vm = NULL;
+GobEngine *_vm = NULL;
GobEngine::GobEngine(GameDetector *detector, OSystem * syst) : Engine(syst) {
diff --git a/gob/gob.h b/gob/gob.h
index d492d77a84..a0a9878dd5 100644
--- a/gob/gob.h
+++ b/gob/gob.h
@@ -54,5 +54,7 @@ public:
};
+extern GobEngine *_vm;
+
} // End of namespace Gob
#endif
diff --git a/gob/sound.cpp b/gob/sound.cpp
index b724bb3c0e..25553531db 100644
--- a/gob/sound.cpp
+++ b/gob/sound.cpp
@@ -23,31 +23,57 @@
#include "gob/global.h"
#include "gob/sound.h"
namespace Gob {
- int16 snd_checkProAudio(void) {return 0;}
- int16 snd_checkAdlib(void) {return 0;}
- int16 snd_checkBlaster(void) {return 0;}
- void snd_setBlasterPort(int16 port) {return;}
- void snd_speakerOn(int16 frequency) {return;}
- void snd_speakerOff(void) {return;}
- void snd_stopSound(int16 arg){return;}
- void snd_setResetTimerFlag(char flag){return;}
-
- void snd_playSample(Snd_SoundDesc * soundDesc, int16 repCount, int16 frequency) {;}
- void snd_cleanupFuncCallback() {;}
- CleanupFuncPtr (snd_cleanupFunc);
- //CleanupFuncPtr snd_cleanupFunc;// = &snd_cleanupFuncCallback();
-
- int16 snd_soundPort;
- char snd_playingSound;
-
- void snd_writeAdlib(int16 port, int16 data) {
+
+SoundHandle soundHandle;
+
+int16 snd_checkProAudio(void) {return 0;}
+int16 snd_checkAdlib(void) {return 0;}
+int16 snd_checkBlaster(void) {return 0;}
+void snd_setBlasterPort(int16 port) {return;}
+void snd_speakerOn(int16 frequency) {return;}
+void snd_speakerOff(void) {return;}
+void snd_stopSound(int16 arg){return;}
+void snd_setResetTimerFlag(char flag){return;}
+
+void snd_playSample(Snd_SoundDesc *sndDesc, int16 repCount, int16 frequency) {
+ if (repCount != 1)
+ warning("snd_playSample: repCount = %d - not implemented", repCount);
+ if (frequency < 0) {
+ warning("snd_playSample: frequency = %d - this is weird", frequency);
return;
}
- Snd_SoundDesc *snd_loadSoundData(const char *path) {
- return NULL;
- }
-void snd_freeSoundData(Snd_SoundDesc * sndDesc) {;}
+ _vm->_mixer->playRaw(&soundHandle, sndDesc->data, sndDesc->size, frequency, 0);
+}
+
+void snd_cleanupFuncCallback() {;}
+CleanupFuncPtr (snd_cleanupFunc);
+//CleanupFuncPtr snd_cleanupFunc;// = &snd_cleanupFuncCallback();
+
+int16 snd_soundPort;
+char snd_playingSound;
+
+void snd_writeAdlib(int16 port, int16 data) {
+ return;
+}
+
+Snd_SoundDesc *snd_loadSoundData(const char *path) {
+ Snd_SoundDesc *sndDesc;
+ int32 size;
+
+ size = data_getDataSize(path);
+ sndDesc = (Snd_SoundDesc *)malloc(size);
+ sndDesc->size = size;
+ sndDesc->data = data_getData(path);
+
+ return sndDesc;
+}
+
+void snd_freeSoundData(Snd_SoundDesc *sndDesc) {
+ free(sndDesc->data);
+ free(sndDesc);
+}
+
void snd_playComposition(Snd_SoundDesc ** samples, int16 *composit, int16 freqVal) {;}
void snd_waitEndPlay(void) {;}
diff --git a/gob/sound.h b/gob/sound.h
index d26f366f7f..bffe28dd68 100644
--- a/gob/sound.h
+++ b/gob/sound.h
@@ -50,10 +50,10 @@ typedef struct Snd_SoundDesc {
int16 flag;
} Snd_SoundDesc;
-void snd_playSample(Snd_SoundDesc * soundDesc, int16 repCount, int16 frequency);
+void snd_playSample(Snd_SoundDesc *sndDesc, int16 repCount, int16 frequency);
Snd_SoundDesc *snd_loadSoundData(const char *path);
-void snd_freeSoundData(Snd_SoundDesc * sndDesc);
-void snd_playComposition(Snd_SoundDesc ** samples, int16 *composit, int16 freqVal);
+void snd_freeSoundData(Snd_SoundDesc *sndDesc);
+void snd_playComposition(Snd_SoundDesc **samples, int16 *composit, int16 freqVal);
void snd_waitEndPlay(void);
} // End of namespace Gob