aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoost Peters2004-01-25 22:10:23 +0000
committerJoost Peters2004-01-25 22:10:23 +0000
commit0d974b9daa4df60a87255cc6f477c9696034c24f (patch)
tree762999f9d9b24e66d075660937a97276643b870c
parentb106eb1e43e8f5a3c3fd78e547b2f7945969375b (diff)
downloadscummvm-rg350-0d974b9daa4df60a87255cc6f477c9696034c24f.tar.gz
scummvm-rg350-0d974b9daa4df60a87255cc6f477c9696034c24f.tar.bz2
scummvm-rg350-0d974b9daa4df60a87255cc6f477c9696034c24f.zip
Seperate SFX and Speech.
this fixes the 'pauses' in the car-chase scene and other scene which use speech and sfx simultaneously. svn-id: r12599
-rw-r--r--queen/cutaway.cpp2
-rw-r--r--queen/graphics.cpp4
-rw-r--r--queen/logic.cpp2
-rw-r--r--queen/sound.cpp41
-rw-r--r--queen/sound.h20
-rw-r--r--queen/talk.cpp6
6 files changed, 40 insertions, 35 deletions
diff --git a/queen/cutaway.cpp b/queen/cutaway.cpp
index 59eda765fc..dddf2aed3f 100644
--- a/queen/cutaway.cpp
+++ b/queen/cutaway.cpp
@@ -1330,7 +1330,7 @@ void Cutaway::handleText(
char voiceFileName[MAX_STRING_SIZE];
findCdCut(_basename, index, voiceFileName);
strcat(voiceFileName, "1");
- _vm->sound()->playSfx(voiceFileName);
+ _vm->sound()->playSfx(voiceFileName, true);
}
if (OBJECT_TYPE_TEXT_SPEAK == type && _vm->sound()->speechOn() && !_vm->subtitles())
diff --git a/queen/graphics.cpp b/queen/graphics.cpp
index 24a0cf571e..44bf4add97 100644
--- a/queen/graphics.cpp
+++ b/queen/graphics.cpp
@@ -328,7 +328,7 @@ void Graphics::sortBobs() {
if (pbs->animating) {
pbs->animOneStep();
if (pbs->frameNum > 500) { // SFX frame
- _vm->sound()->playSfx(_vm->logic()->currentRoomSfx());
+ _vm->sound()->playSfx(_vm->logic()->currentRoomSfx(), false);
pbs->frameNum -= 500;
}
}
@@ -1087,7 +1087,7 @@ void BamScene::playSfx() {
// this problem since their playSfx() function returns immediately
// if a sound is already being played.
if (_lastSoundIndex == 0 || _index - _lastSoundIndex >= SFX_SKIP) {
- _vm->sound()->playSfx(_vm->logic()->currentRoomSfx());
+ _vm->sound()->playSfx(_vm->logic()->currentRoomSfx(), false);
_lastSoundIndex = _index;
}
}
diff --git a/queen/logic.cpp b/queen/logic.cpp
index 4c034ffe87..7eb5617eeb 100644
--- a/queen/logic.cpp
+++ b/queen/logic.cpp
@@ -1722,7 +1722,7 @@ void Logic::asmMakeLightningHitPlane() {
lightningBob->y = 0;
// 23/2/95 - Play lightning SFX
- _vm->sound()->playSfx(currentRoomSfx());
+ _vm->sound()->playSfx(currentRoomSfx(), false);
_vm->bankMan()->unpack(18, lightningBob->frameNum, 15);
_vm->bankMan()->unpack(4, planeBob ->frameNum, 15);
diff --git a/queen/sound.cpp b/queen/sound.cpp
index 7dbcff7a66..ccfcf23a5d 100644
--- a/queen/sound.cpp
+++ b/queen/sound.cpp
@@ -67,21 +67,26 @@ Sound *Sound::giveSound(SoundMixer *mixer, QueenEngine *vm, uint8 compression) {
}
}
-void Sound::waitSfxFinished() {
- while(_sfxHandle.isActive())
- _vm->input()->delay(10);
+void Sound::waitFinished(bool isSpeech) {
+ if (isSpeech)
+ while(_speechHandle.isActive())
+ _vm->input()->delay(10);
+ else
+ while(_sfxHandle.isActive())
+ _vm->input()->delay(10);
}
-void Sound::playSfx(uint16 sfx) {
+void Sound::playSfx(uint16 sfx, bool isSpeech) {
if (sfx != 0) {
char name[13];
strcpy(name, _sfxName[sfx - 1]);
strcat(name, ".SB");
- sfxPlay(name);
+ waitFinished(isSpeech);
+ sfxPlay(name, isSpeech);
}
}
-void Sound::playSfx(const char *base) {
+void Sound::playSfx(const char *base, bool isSpeech) {
char name[13];
strcpy(name, base);
// alter filename to add zeros and append ".SB"
@@ -90,7 +95,8 @@ void Sound::playSfx(const char *base) {
name[i] = '0';
}
strcat(name, ".SB");
- sfxPlay(name);
+ waitFinished(isSpeech);
+ sfxPlay(name, isSpeech);
}
void Sound::playSong(int16 songNum) {
@@ -112,7 +118,7 @@ void Sound::playSong(int16 songNum) {
if (_tune[newTune].sfx[0]) {
if (sfxOn())
- playSfx(_tune[newTune].sfx[0]);
+ playSfx(_tune[newTune].sfx[0], false);
return;
}
@@ -148,30 +154,27 @@ void Sound::loadState(uint32 ver, byte *&ptr) {
}
-void SBSound::playSound(byte *sound, uint32 size) {
+void SBSound::playSound(byte *sound, uint32 size, bool isSpeech) {
byte flags = SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE;
- _mixer->playRaw(&_sfxHandle, sound, size, 11025, flags);
+ _mixer->playRaw(isSpeech ? &_speechHandle : &_sfxHandle, sound, size, 11025, flags);
}
-void SBSound::sfxPlay(const char *name) {
- waitSfxFinished();
+void SBSound::sfxPlay(const char *name, bool isSpeech) {
if (_vm->resource()->fileExists(name))
- playSound(_vm->resource()->loadFileMalloc(name, SB_HEADER_SIZE), _vm->resource()->fileSize(name) - SB_HEADER_SIZE);
+ playSound(_vm->resource()->loadFileMalloc(name, SB_HEADER_SIZE), _vm->resource()->fileSize(name) - SB_HEADER_SIZE, isSpeech);
}
#ifdef USE_MAD
-void MP3Sound::sfxPlay(const char *name) {
- waitSfxFinished();
+void MP3Sound::sfxPlay(const char *name, bool isSpeech) {
if (_vm->resource()->fileExists(name))
- _mixer->playMP3(&_sfxHandle, _vm->resource()->giveCompressedSound(name), _vm->resource()->fileSize(name));
+ _mixer->playMP3(isSpeech ? &_speechHandle : &_sfxHandle, _vm->resource()->giveCompressedSound(name), _vm->resource()->fileSize(name));
}
#endif
#ifdef USE_VORBIS
-void OGGSound::sfxPlay(const char *name) {
- waitSfxFinished();
+void OGGSound::sfxPlay(const char *name, bool isSpeech) {
if (_vm->resource()->fileExists(name))
- _mixer->playVorbis(&_sfxHandle, _vm->resource()->giveCompressedSound(name), _vm->resource()->fileSize(name));
+ _mixer->playVorbis(isSpeech ? &_speechHandle : &_sfxHandle, _vm->resource()->giveCompressedSound(name), _vm->resource()->fileSize(name));
}
#endif
diff --git a/queen/sound.h b/queen/sound.h
index 52d24d2246..9b4897b0b9 100644
--- a/queen/sound.h
+++ b/queen/sound.h
@@ -53,13 +53,12 @@ class Sound {
public:
Sound(SoundMixer *mixer, QueenEngine *vm);
virtual ~Sound();
- virtual void sfxPlay(const char *name) = 0;
+ virtual void sfxPlay(const char *name, bool isSpeech) = 0;
static Sound *giveSound(SoundMixer *mixer, QueenEngine *vm, uint8 compression);
- void waitSfxFinished();
- void playSfx(uint16 sfx);
- void playSfx(const char *base);
+ void playSfx(uint16 sfx, bool isSpeech);
+ void playSfx(const char *base, bool isSpeech);
void playSong(int16 songNum);
- void stopSfx() { _mixer->stopHandle(_sfxHandle); }
+ void stopSpeech() { _mixer->stopHandle(_speechHandle); }
bool sfxOn() { return _sfxToggle; }
void sfxToggle(bool val) { _sfxToggle = val; }
@@ -86,6 +85,8 @@ public:
static const int16 _jungleList[];
protected:
+ void waitFinished(bool isSpeech);
+
SoundMixer *_mixer;
QueenEngine *_vm;
@@ -100,27 +101,28 @@ protected:
int16 _previousSong;
int16 _previousSongNum;
PlayingSoundHandle _sfxHandle;
+ PlayingSoundHandle _speechHandle;
};
class SilentSound : public Sound {
public:
SilentSound(SoundMixer *mixer, QueenEngine *vm) : Sound(mixer, vm) {};
- void sfxPlay(const char *name) { }
+ void sfxPlay(const char *name, bool isSpeech) { }
};
class SBSound : public Sound {
public:
SBSound(SoundMixer *mixer, QueenEngine *vm) : Sound(mixer, vm) {};
- void sfxPlay(const char *name);
+ void sfxPlay(const char *name, bool isSpeech);
protected:
- void playSound(byte *sound, uint32 size);
+ void playSound(byte *sound, uint32 size, bool isSpeech);
};
#ifdef USE_MAD
class MP3Sound : public Sound {
public:
MP3Sound(SoundMixer *mixer, QueenEngine *vm) : Sound(mixer, vm) {};
- void sfxPlay(const char *name);
+ void sfxPlay(const char *name, bool isSpeech);
};
#endif
diff --git a/queen/talk.cpp b/queen/talk.cpp
index 99ee86d27d..3a4c549548 100644
--- a/queen/talk.cpp
+++ b/queen/talk.cpp
@@ -780,7 +780,7 @@ void Talk::stringAnimation(const SpeechParameters *parameters, int startFrame, i
if (frame > 500) {
frame -= 500;
- _vm->sound()->playSfx(_vm->logic()->currentRoomSfx());
+ _vm->sound()->playSfx(_vm->logic()->currentRoomSfx(), false);
}
if (torso) {
@@ -902,7 +902,7 @@ void Talk::defaultAnimation(
// Skip through text more quickly
if (_vm->input()->keyVerb() == VERB_SKIP_TEXT) {
_vm->input()->clearKeyVerb();
- _vm->sound()->stopSfx();
+ _vm->sound()->stopSpeech();
break;
}
}
@@ -940,7 +940,7 @@ void Talk::speakSegment(
// play it. This voice was used in room 30 (N8) when talking to Klunk.
if (!(_vm->resource()->getLanguage() == FRENCH && !strcmp(voiceFileName, "c30e_102"))
&& _vm->sound()->speechOn())
- _vm->sound()->playSfx(voiceFileName);
+ _vm->sound()->playSfx(voiceFileName, true);
int faceDirectionCommand = 0;