aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
authorEugene Sandulenko2004-04-29 01:24:18 +0000
committerEugene Sandulenko2004-04-29 01:24:18 +0000
commitd7835da8c7d3bc223c8b1ec84e9b0b7439dbb6fc (patch)
tree95aebf0be9cbe8765c51cb9e947dd3034d6a7e8f /saga
parent4c889000f2dd40f32286bb5637fdbcd869b5cee6 (diff)
downloadscummvm-rg350-d7835da8c7d3bc223c8b1ec84e9b0b7439dbb6fc.tar.gz
scummvm-rg350-d7835da8c7d3bc223c8b1ec84e9b0b7439dbb6fc.tar.bz2
scummvm-rg350-d7835da8c7d3bc223c8b1ec84e9b0b7439dbb6fc.zip
Voices are played
svn-id: r13668
Diffstat (limited to 'saga')
-rw-r--r--saga/reinherit.h13
-rw-r--r--saga/saga.cpp2
-rw-r--r--saga/sndres.cpp4
-rw-r--r--saga/sndres.h3
-rw-r--r--saga/sound.cpp24
-rw-r--r--saga/sound.h27
6 files changed, 53 insertions, 20 deletions
diff --git a/saga/reinherit.h b/saga/reinherit.h
index 8da29e0a19..c6e5c107e1 100644
--- a/saga/reinherit.h
+++ b/saga/reinherit.h
@@ -103,19 +103,6 @@ struct R_SURFACE {
void *impl_src;
};
-struct R_SOUNDBUFFER {
- const uchar *res_data;
- size_t res_len;
-
- long s_freq;
- int s_samplebits;
- int s_stereo;
- int s_signed;
-
- const uchar *s_buf;
- size_t s_buf_len;
-};
-
#define R_RGB_RED 0x00FF0000UL
#define R_RGB_GREEN 0x0000FF00UL
#define R_RGB_BLUE 0x000000FFUL
diff --git a/saga/saga.cpp b/saga/saga.cpp
index 2f46cdd658..668f354551 100644
--- a/saga/saga.cpp
+++ b/saga/saga.cpp
@@ -253,7 +253,7 @@ void SagaEngine::go() {
}
/* Initialize system specific sound */
- _sound = new Sound(MainData.sound_enabled);
+ _sound = new Sound(this, _mixer, MainData.sound_enabled);
if (!MainData.sound_enabled) {
R_printf(R_STDOUT, "Sound disabled.\n");
}
diff --git a/saga/sndres.cpp b/saga/sndres.cpp
index 5feb0f677a..a8d925494c 100644
--- a/saga/sndres.cpp
+++ b/saga/sndres.cpp
@@ -75,6 +75,8 @@ int SndRes::playVoice(ulong voice_rn) {
R_SOUNDBUFFER snd_buffer;
int result;
+ debug(0, "SndRes::playVoice(%ld)", voice_rn);
+
result = load(_voice_ctxt, voice_rn, &snd_buffer);
if (result != R_SUCCESS) {
return R_FAILURE;
@@ -135,7 +137,7 @@ int SndRes::load(R_RSCFILE_CONTEXT *snd_ctxt, ulong snd_rn, R_SOUNDBUFFER *snd_b
return R_SUCCESS;
}
-int SndRes::loadVocSound(const uchar *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_buf_i) {
+int SndRes::loadVocSound(byte *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_buf_i) {
R_VOC_HEADER_BLOCK voc_hb;
R_VOC_GENBLOCK voc_gb;
R_VOC_BLOCK1 voc_b1;
diff --git a/saga/sndres.h b/saga/sndres.h
index 8b3a06fefa..1d4e797d87 100644
--- a/saga/sndres.h
+++ b/saga/sndres.h
@@ -33,6 +33,7 @@
#include "rscfile_mod.h"
#include "game_mod.h"
+#include "sound.h"
namespace Saga {
@@ -78,7 +79,7 @@ class SndRes {
private:
int load(R_RSCFILE_CONTEXT *snd_ctxt, ulong snd_rn, R_SOUNDBUFFER *snd_buf_i);
- int loadVocSound(const uchar *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_buf_i);
+ int loadVocSound(byte *snd_res, size_t snd_res_len, R_SOUNDBUFFER *snd_buf_i);
int _init;
diff --git a/saga/sound.cpp b/saga/sound.cpp
index 7bb2b88b26..1b3b95d91d 100644
--- a/saga/sound.cpp
+++ b/saga/sound.cpp
@@ -31,13 +31,16 @@
#include "sound.h"
#include "game_mod.h"
+#include "sound/mixer.h"
+
namespace Saga {
/*
* Begin module component
\*--------------------------------------------------------------------------*/
-Sound::Sound(int enabled) {
+Sound::Sound(SagaEngine *vm, SoundMixer *mixer, int enabled) :
+ _vm(vm), _mixer(mixer) {
int result;
/* Load sound module resource file contexts */
@@ -52,7 +55,7 @@ Sound::Sound(int enabled) {
}
/* Grab sound resource information for the current game */
- //GAME_GetSoundInfo(&SoundModule.snd_info);
+ GAME_GetSoundInfo(&_snd_info);
_soundInitialized = 1;
return;
@@ -112,12 +115,21 @@ int Sound::stop(int channel) {
}
int Sound::playVoice(R_SOUNDBUFFER *buf) {
- (void)buf;
+ byte flags;
+ int game_id = GAME_GetGame();
if (!_soundInitialized) {
return R_FAILURE;
}
+ if((game_id == R_GAME_ITE_DISK) || (game_id == R_GAME_ITE_DEMO)) {
+ flags = SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE;
+ } else {
+ flags = SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_16BITS |
+ SoundMixer::FLAG_LITTLE_ENDIAN;
+ }
+ _mixer->playRaw(&_voiceHandle, buf->res_data, buf->res_len, buf->s_freq, flags);
+
return R_SUCCESS;
}
@@ -126,6 +138,8 @@ int Sound::pauseVoice(void) {
return R_FAILURE;
}
+ _mixer->pauseHandle(_voiceHandle, true);
+
return R_SUCCESS;
}
@@ -134,6 +148,8 @@ int Sound::resumeVoice(void) {
return R_FAILURE;
}
+ _mixer->pauseHandle(_voiceHandle, false);
+
return R_SUCCESS;
}
@@ -142,6 +158,8 @@ int Sound::stopVoice(void) {
return R_FAILURE;
}
+ _mixer->stopHandle(_voiceHandle);
+
return R_SUCCESS;
}
diff --git a/saga/sound.h b/saga/sound.h
index ef7d43fc92..37f13d1a82 100644
--- a/saga/sound.h
+++ b/saga/sound.h
@@ -32,13 +32,29 @@
#define SAGA_SOUND_H_
#include "rscfile_mod.h"
+#include "game_mod.h"
+#include "sound/mixer.h"
namespace Saga {
+struct R_SOUNDBUFFER {
+ byte *res_data;
+ uint32 res_len;
+
+ uint s_freq;
+ int s_samplebits;
+ int s_stereo;
+ int s_signed;
+
+ const uchar *s_buf;
+ size_t s_buf_len;
+};
+
+
class Sound {
public:
- Sound(int enabled);
+ Sound(SagaEngine *vm, SoundMixer *mixer, int enabled);
~Sound(void);
int play(int sound_rn, int channel);
@@ -55,9 +71,18 @@ class Sound {
int _soundInitialized;
+ R_GAME_SOUNDINFO _snd_info;
+
R_RSCFILE_CONTEXT *_soundContext;
R_RSCFILE_CONTEXT *_voiceContext;
+ SagaEngine *_vm;
+ SoundMixer *_mixer;
+
+ PlayingSoundHandle _effectHandle;
+ PlayingSoundHandle _voiceHandle;
+ PlayingSoundHandle _musictHandle;
+
};
} // End of namespace Saga