[Scummvm-cvs-logs] CVS: scummvm/queen cutaway.cpp,1.121,1.122 graphics.cpp,1.91,1.92 logic.cpp,1.182,1.183 sound.cpp,1.34,1.35 sound.h,1.17,1.18 talk.cpp,1.87,1.88

Joost Peters joostp at users.sourceforge.net
Tue Jan 27 21:30:52 CET 2004


Update of /cvsroot/scummvm/scummvm/queen
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1720/queen

Modified Files:
	cutaway.cpp graphics.cpp logic.cpp sound.cpp sound.h talk.cpp 
Log Message:
Seperate SFX and Speech.
this fixes the 'pauses' in the car-chase scene and other scene which use
speech and sfx simultaneously.


Index: cutaway.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/cutaway.cpp,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -d -r1.121 -r1.122
--- cutaway.cpp	25 Jan 2004 14:21:37 -0000	1.121
+++ cutaway.cpp	25 Jan 2004 22:10:05 -0000	1.122
@@ -1330,7 +1330,7 @@
 			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())

Index: graphics.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/graphics.cpp,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -d -r1.91 -r1.92
--- graphics.cpp	23 Jan 2004 16:57:45 -0000	1.91
+++ graphics.cpp	25 Jan 2004 22:10:08 -0000	1.92
@@ -328,7 +328,7 @@
 			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 @@
 	// 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;
 	}
 }

Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.cpp,v
retrieving revision 1.182
retrieving revision 1.183
diff -u -d -r1.182 -r1.183
--- logic.cpp	22 Jan 2004 22:28:30 -0000	1.182
+++ logic.cpp	25 Jan 2004 22:10:21 -0000	1.183
@@ -1722,7 +1722,7 @@
 	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);

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/sound.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- sound.cpp	25 Jan 2004 16:57:05 -0000	1.34
+++ sound.cpp	25 Jan 2004 22:10:23 -0000	1.35
@@ -67,21 +67,26 @@
 	}
 }
 
-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 @@
 			name[i] = '0';
 	}
 	strcat(name, ".SB");
-	sfxPlay(name);
+	waitFinished(isSpeech);
+	sfxPlay(name, isSpeech);
 }
 
 void Sound::playSong(int16 songNum) {
@@ -112,7 +118,7 @@
 
 	if (_tune[newTune].sfx[0]) {
 		if (sfxOn())
-			playSfx(_tune[newTune].sfx[0]);
+			playSfx(_tune[newTune].sfx[0], false);
 		return;
 	}
 
@@ -148,30 +154,27 @@
 }
 
 
-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
 

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/sound.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- sound.h	25 Jan 2004 16:29:19 -0000	1.17
+++ sound.h	25 Jan 2004 22:10:23 -0000	1.18
@@ -53,13 +53,12 @@
 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 @@
 	static const int16 _jungleList[];
 
 protected:
+	void waitFinished(bool isSpeech);
+
 	SoundMixer *_mixer;
 	QueenEngine *_vm;
 
@@ -100,27 +101,28 @@
 	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
 

Index: talk.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/talk.cpp,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -d -r1.87 -r1.88
--- talk.cpp	23 Jan 2004 16:58:13 -0000	1.87
+++ talk.cpp	25 Jan 2004 22:10:23 -0000	1.88
@@ -780,7 +780,7 @@
 
 		if (frame > 500) {
 			frame -= 500;
-			_vm->sound()->playSfx(_vm->logic()->currentRoomSfx());
+			_vm->sound()->playSfx(_vm->logic()->currentRoomSfx(), false);
 		}
 
 		if (torso) {
@@ -902,7 +902,7 @@
 			// 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 @@
 	// 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;
 





More information about the Scummvm-git-logs mailing list