[Scummvm-cvs-logs] SF.net SVN: scummvm: [21900] scummvm/trunk/engines/simon

kirben at users.sourceforge.net kirben at users.sourceforge.net
Fri Apr 14 22:25:02 CEST 2006


Revision: 21900
Author:   kirben
Date:     2006-04-14 22:24:44 -0700 (Fri, 14 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21900&view=rev

Log Message:
-----------
Add support for switching voice file in PC versions of FF and cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/simon/items.cpp
    scummvm/trunk/engines/simon/simon.cpp
    scummvm/trunk/engines/simon/sound.cpp
    scummvm/trunk/engines/simon/sound.h
    scummvm/trunk/engines/simon/vga.cpp
Modified: scummvm/trunk/engines/simon/items.cpp
===================================================================
--- scummvm/trunk/engines/simon/items.cpp	2006-04-15 01:56:49 UTC (rev 21899)
+++ scummvm/trunk/engines/simon/items.cpp	2006-04-15 05:24:44 UTC (rev 21900)
@@ -1837,7 +1837,18 @@
 
 void SimonEngine::o3_checkCD() {
 	// 135: switch CD
-	debug(0, "Switch to CD number %d", readVariable(97));
+	uint disc = readVariable(97);
+
+	if (!strcmp(_gameDescription->extra, "4CD")) {
+		_sound->switchVoiceFile(disc);
+	} else if (!strcmp(_gameDescription->extra, "2CD")) {
+		if (disc == 1 || disc == 2)
+			_sound->switchVoiceFile(1);
+		else if (disc == 3 || disc == 4)
+			_sound->switchVoiceFile(2);
+	}
+
+	debug(0, "Switch to CD number %d", disc);
 }
 
 void SimonEngine::o3_screenTextBox() {

Modified: scummvm/trunk/engines/simon/simon.cpp
===================================================================
--- scummvm/trunk/engines/simon/simon.cpp	2006-04-15 01:56:49 UTC (rev 21899)
+++ scummvm/trunk/engines/simon/simon.cpp	2006-04-15 05:24:44 UTC (rev 21900)
@@ -3268,10 +3268,12 @@
 			}
 			_skipVgaWait = true;
 		} else {
-			if (_subtitles && _language != Common::HB_ISR) {
+			if (getGameType() == GType_SIMON2 && _subtitles && _language != Common::HB_ISR) {
 				loadVoice(speech_id);
 				return;
-			} else if (_subtitles && _scriptVar2) {
+			}
+
+			if (_subtitles && _scriptVar2) {
 				loadSprite(4, 2, 5, 0, 0, 0);
 				waitForSync(205);
 				kill_sprite_simon2(2,5);

Modified: scummvm/trunk/engines/simon/sound.cpp
===================================================================
--- scummvm/trunk/engines/simon/sound.cpp	2006-04-15 01:56:49 UTC (rev 21899)
+++ scummvm/trunk/engines/simon/sound.cpp	2006-04-15 05:24:44 UTC (rev 21900)
@@ -256,8 +256,18 @@
 	_hasVoiceFile = false;
 	_ambientPlaying = 0;
 
-	// SIMON1CD32 uses separate speech files
-	if (!(_vm->getFeatures() & GF_TALKIE) || (_vm->getGameId() == GID_SIMON1CD32))
+	if (_vm->getFeatures() & GF_TALKIE) {
+		loadVoiceFile(gss);
+
+		if (_vm->getGameType() == GType_SIMON1)
+			loadSfxFile(gss);
+	}
+
+}
+
+void Sound::loadVoiceFile(const GameSpecificSettings *gss) {
+	// Game versions which use separate voice files
+	if (_vm->getGameType() == GType_FF || _vm->getGameId() == GID_SIMON1CD32)
 		return;
 
 	File *file = new File();
@@ -320,42 +330,43 @@
 			_voice = new VocSound(_mixer, file);
 		}
 	}
+}
 
-	if ((_vm->getGameType() == GType_SIMON1) && (_vm->getFeatures() & GF_TALKIE)) {
-		file = new File();
+void Sound::loadSfxFile(const GameSpecificSettings *gss) {
+	File *file = new File();
+
 #ifdef USE_MAD
-		if (!_hasEffectsFile && gss->mp3_effects_filename && gss->mp3_effects_filename[0]) {
-			file->open(gss->mp3_effects_filename);
-			if (file->isOpen()) {
-				_hasEffectsFile = true;
-				_effects = new MP3Sound(_mixer, file);
-			}
+	if (!_hasEffectsFile && gss->mp3_effects_filename && gss->mp3_effects_filename[0]) {
+		file->open(gss->mp3_effects_filename);
+		if (file->isOpen()) {
+			_hasEffectsFile = true;
+			_effects = new MP3Sound(_mixer, file);
 		}
+	}
 #endif
 #ifdef USE_VORBIS
-		if (!_hasEffectsFile && gss->vorbis_effects_filename && gss->vorbis_effects_filename[0]) {
-			file->open(gss->vorbis_effects_filename);
-			if (file->isOpen()) {
-				_hasEffectsFile = true;
-				_effects = new VorbisSound(_mixer, file);
-			}
+	if (!_hasEffectsFile && gss->vorbis_effects_filename && gss->vorbis_effects_filename[0]) {
+		file->open(gss->vorbis_effects_filename);
+		if (file->isOpen()) {
+			_hasEffectsFile = true;
+			_effects = new VorbisSound(_mixer, file);
 		}
+	}
 #endif
 #ifdef USE_FLAC
-		if (!_hasEffectsFile && gss->flac_effects_filename && gss->flac_effects_filename[0]) {
-			file->open(gss->flac_effects_filename);
-			if (file->isOpen()) {
-				_hasEffectsFile = true;
-				_effects = new FlacSound(_mixer, file);
-			}
+	if (!_hasEffectsFile && gss->flac_effects_filename && gss->flac_effects_filename[0]) {
+		file->open(gss->flac_effects_filename);
+		if (file->isOpen()) {
+			_hasEffectsFile = true;
+			_effects = new FlacSound(_mixer, file);
 		}
+	}
 #endif
-		if (!_hasEffectsFile && gss->voc_effects_filename && gss->voc_effects_filename[0]) {
-			file->open(gss->voc_effects_filename);
-			if (file->isOpen()) {
-				_hasEffectsFile = true;
-				_effects = new VocSound(_mixer, file);
-			}
+	if (!_hasEffectsFile && gss->voc_effects_filename && gss->voc_effects_filename[0]) {
+		file->open(gss->voc_effects_filename);
+		if (file->isOpen()) {
+			_hasEffectsFile = true;
+			_effects = new VocSound(_mixer, file);
 		}
 	}
 }
@@ -460,57 +471,6 @@
 	}
 }
 
-void Sound::playSoundData(byte *soundData, uint sound, uint pan, uint vol, bool ambient) {
-	byte flags;
-	int rate;
-
-	if (ambient == true) {
-		if (sound == _ambientPlaying)
-			return;
-
-		_ambientPlaying = sound;
-
-		if (_ambientPaused)
-			return;
-	} else {
-		if (_effectsPaused)
-			return;
-	}
-
-	int size = READ_LE_UINT32(soundData + 4);
-	Common::MemoryReadStream stream(soundData, size);
-	if (!loadWAVFromStream(stream, size, rate, flags)) {
-		error("playSoundData: Not a valid WAV data");
-	}
-
-	byte *buffer = (byte *)malloc(size);
-	memcpy(buffer, soundData + stream.pos(), size);
-
-	if (ambient == true) {
-		_mixer->stopHandle(_ambientHandle);
-		_mixer->playRaw(&_ambientHandle, buffer, size, rate, Audio::Mixer::FLAG_LOOP|flags);
-	} else {
-		_mixer->playRaw(&_effectsHandle, buffer, size, rate, flags);
-	}
-}
-
-void Sound::playVoiceData(byte *soundData, uint sound) {
-	byte flags;
-	int rate;
-
-	int size = READ_LE_UINT32(soundData + 4);
-	Common::MemoryReadStream stream(soundData, size);
-	if (!loadWAVFromStream(stream, size, rate, flags)) {
-		error("playSoundData: Not a valid WAV data");
-	}
-
-	byte *buffer = (byte *)malloc(size);
-	memcpy(buffer, soundData + stream.pos(), size);
-
-	_mixer->stopHandle(_voiceHandle);
-	_mixer->playRaw(&_voiceHandle, buffer, size, rate, flags);
-}
-
 void Sound::playEffects(uint sound) {
 	if (!_effects)
 		return;
@@ -570,4 +530,74 @@
 	}
 }
 
+// Feeble Files specific
+void Sound::playSoundData(byte *soundData, uint sound, uint pan, uint vol, bool ambient) {
+	byte flags;
+	int rate;
+
+	if (ambient == true) {
+		if (sound == _ambientPlaying)
+			return;
+
+		_ambientPlaying = sound;
+
+		if (_ambientPaused)
+			return;
+	} else {
+		if (_effectsPaused)
+			return;
+	}
+
+	int size = READ_LE_UINT32(soundData + 4);
+	Common::MemoryReadStream stream(soundData, size);
+	if (!loadWAVFromStream(stream, size, rate, flags)) {
+		error("playSoundData: Not a valid WAV data");
+	}
+
+	byte *buffer = (byte *)malloc(size);
+	memcpy(buffer, soundData + stream.pos(), size);
+
+	if (ambient == true) {
+		_mixer->stopHandle(_ambientHandle);
+		_mixer->playRaw(&_ambientHandle, buffer, size, rate, Audio::Mixer::FLAG_LOOP|flags);
+	} else {
+		_mixer->playRaw(&_effectsHandle, buffer, size, rate, flags);
+	}
+}
+
+void Sound::playVoiceData(byte *soundData, uint sound) {
+	byte flags;
+	int rate;
+
+	int size = READ_LE_UINT32(soundData + 4);
+	Common::MemoryReadStream stream(soundData, size);
+	if (!loadWAVFromStream(stream, size, rate, flags)) {
+		error("playSoundData: Not a valid WAV data");
+	}
+
+	byte *buffer = (byte *)malloc(size);
+	memcpy(buffer, soundData + stream.pos(), size);
+
+	_mixer->stopHandle(_voiceHandle);
+	_mixer->playRaw(&_voiceHandle, buffer, size, rate, flags);
+}
+
+void Sound::switchVoiceFile(uint disc) {
+	if (_lastVoiceFile != disc) {
+		stopAll();
+
+		char filename[16];
+		_lastVoiceFile = disc;
+		sprintf(filename, "voices%d.wav",disc);
+		File *file = new File();
+		file->open(filename);
+		if (file->isOpen() == false) {
+			warning("playVoice: Can't load voice file %s", filename);
+			return;
+		}
+		delete _voice;
+		_voice = new WavSound(_mixer, file);
+	}
+}
+
 } // End of namespace Simon

Modified: scummvm/trunk/engines/simon/sound.h
===================================================================
--- scummvm/trunk/engines/simon/sound.h	2006-04-15 01:56:49 UTC (rev 21899)
+++ scummvm/trunk/engines/simon/sound.h	2006-04-15 05:24:44 UTC (rev 21900)
@@ -58,6 +58,9 @@
 	Sound(SimonEngine *vm, const GameSpecificSettings *gss, Audio::Mixer *mixer);
 	~Sound();
 
+	void loadVoiceFile(const GameSpecificSettings *gss);
+	void loadSfxFile(const GameSpecificSettings *gss);
+
 	void readSfxFile(const char *filename);
 	void loadSfxTable(Common::File *gameFile, uint32 base);
 	void readVoiceFile(const char *filename);
@@ -69,6 +72,7 @@
 	// Feeble Files specific
 	void playSoundData(byte *soundData, uint sound, uint pan, uint vol, bool ambient);
 	void playVoiceData(byte *soundData, uint sound);
+	void switchVoiceFile(uint disc);
 
 	bool hasVoice() const;
 	bool isVoiceActive() const;

Modified: scummvm/trunk/engines/simon/vga.cpp
===================================================================
--- scummvm/trunk/engines/simon/vga.cpp	2006-04-15 01:56:49 UTC (rev 21899)
+++ scummvm/trunk/engines/simon/vga.cpp	2006-04-15 05:24:44 UTC (rev 21900)
@@ -2217,8 +2217,10 @@
 }
 
 void SimonEngine::vc64_skipIfSpeechEnded() {
-	if (!_sound->isVoiceActive() || (_subtitles && _language != Common::HB_ISR))
+	if ((getGameType() == GType_SIMON2 && _subtitles && _language != Common::HB_ISR) ||
+		!_sound->isVoiceActive()) {
 		vcSkipNextInstruction();
+	}
 }
 
 void SimonEngine::vc65_slowFadeIn() {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list