[Scummvm-cvs-logs] SF.net SVN: scummvm: [27077] scummvm/trunk/engines/agos

Kirben at users.sourceforge.net Kirben at users.sourceforge.net
Mon Jun 4 07:18:12 CEST 2007


Revision: 27077
          http://scummvm.svn.sourceforge.net/scummvm/?rev=27077&view=rev
Author:   Kirben
Date:     2007-06-03 22:18:11 -0700 (Sun, 03 Jun 2007)

Log Message:
-----------
Virtualise a few sound functions.

Modified Paths:
--------------
    scummvm/trunk/engines/agos/agos.h
    scummvm/trunk/engines/agos/res_snd.cpp

Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h	2007-06-04 05:05:02 UTC (rev 27076)
+++ scummvm/trunk/engines/agos/agos.h	2007-06-04 05:18:11 UTC (rev 27077)
@@ -809,7 +809,6 @@
 	void setWindowImage(uint16 mode, uint16 vga_res_id);
 	void setWindowImageEx(uint16 mode, uint16 vga_res);
 
-	void playSpeech(uint speech_id, uint vga_sprite_id);
 	void skipSpeech();
 
 	bool printNameOf(Item *item, uint x, uint y);
@@ -1187,7 +1186,7 @@
 	virtual void windowNewLine(WindowBlock *window);
 	void windowDrawChar(WindowBlock *window, uint x, uint y, byte chr);
 
-	void loadMusic(uint music);
+	virtual void loadMusic(uint music);
 	void loadModule(uint music);
 
 	void checkTimerCallback();
@@ -1473,10 +1472,14 @@
 	virtual void addArrows(WindowBlock *window);
 	virtual uint setupIconHitArea(WindowBlock *window, uint num, uint x, uint y, Item *item_ptr);
 
+	virtual void playSpeech(uint speech_id, uint vga_sprite_id);
+
 	virtual void listSaveGames(char *dst);
 	virtual void userGame(bool load);
 	virtual int userGameGetKey(bool *b, char *buf, uint maxChar);
 
+	virtual void loadMusic(uint music);
+
 	virtual void vcStopAnimation(uint zone, uint sprite);
 };
 
@@ -1516,6 +1519,10 @@
 
 	virtual void addArrows(WindowBlock *window);
 	virtual uint setupIconHitArea(WindowBlock *window, uint num, uint x, uint y, Item *item_ptr);
+
+	virtual void playSpeech(uint speech_id, uint vga_sprite_id);
+
+	virtual void loadMusic(uint music);
 };
 
 class AGOSEngine_Feeble : public AGOSEngine_Simon2 {

Modified: scummvm/trunk/engines/agos/res_snd.cpp
===================================================================
--- scummvm/trunk/engines/agos/res_snd.cpp	2007-06-04 05:05:02 UTC (rev 27076)
+++ scummvm/trunk/engines/agos/res_snd.cpp	2007-06-04 05:18:11 UTC (rev 27077)
@@ -41,59 +41,59 @@
 
 namespace AGOS {
 
-void AGOSEngine::playSpeech(uint speech_id, uint vgaSpriteId) {
-	if (getGameType() == GType_SIMON1) {
-		if (speech_id == 9999) {
-			if (_subtitles)
-				return;
-			if (!getBitFlag(14) && !getBitFlag(28)) {
-				setBitFlag(14, true);
-				_variableArray[100] = 15;
-				animate(4, 1, 130, 0, 0, 0);
-				waitForSync(130);
-			}
-			_skipVgaWait = true;
-		} else {
-			if (_subtitles && _scriptVar2) {
-				animate(4, 2, 204, 0, 0, 0);
-				waitForSync(204);
-				stopAnimate(204);
-			}
-			if (vgaSpriteId < 100)
-				stopAnimate(vgaSpriteId + 201);
+void AGOSEngine_Simon1::playSpeech(uint speech_id, uint vgaSpriteId) {
+	if (speech_id == 9999) {
+		if (_subtitles)
+			return;
+		if (!getBitFlag(14) && !getBitFlag(28)) {
+			setBitFlag(14, true);
+			_variableArray[100] = 15;
+			animate(4, 1, 130, 0, 0, 0);
+			waitForSync(130);
+		}
+		_skipVgaWait = true;
+	} else {
+		if (_subtitles && _scriptVar2) {
+			animate(4, 2, 204, 0, 0, 0);
+			waitForSync(204);
+			stopAnimate(204);
+		}
+		if (vgaSpriteId < 100)
+			stopAnimate(vgaSpriteId + 201);
 
-			loadVoice(speech_id);
+		loadVoice(speech_id);
 
-			if (vgaSpriteId < 100)
-				animate(4, 2, vgaSpriteId + 201, 0, 0, 0);
+		if (vgaSpriteId < 100)
+			animate(4, 2, vgaSpriteId + 201, 0, 0, 0);
+	}
+}
+
+void AGOSEngine_Simon2::playSpeech(uint speech_id, uint vgaSpriteId) {
+	if (speech_id == 0xFFFF) {
+		if (_subtitles)
+			return;
+		if (!getBitFlag(14) && !getBitFlag(28)) {
+			setBitFlag(14, true);
+			_variableArray[100] = 5;
+			animate(4, 1, 30, 0, 0, 0);
+			waitForSync(130);
 		}
+		_skipVgaWait = true;
 	} else {
-		if (speech_id == 0xFFFF) {
-			if (_subtitles)
-				return;
-			if (!getBitFlag(14) && !getBitFlag(28)) {
-				setBitFlag(14, true);
-				_variableArray[100] = 5;
-				animate(4, 1, 30, 0, 0, 0);
-				waitForSync(130);
-			}
-			_skipVgaWait = true;
-		} else {
-			if (getGameType() == GType_SIMON2 && _subtitles && _language != Common::HB_ISR) {
-				loadVoice(speech_id);
-				return;
-			}
+		if (getGameType() == GType_SIMON2 && _subtitles && _language != Common::HB_ISR) {
+			loadVoice(speech_id);
+			return;
+		}
 
-			if (_subtitles && _scriptVar2) {
-				animate(4, 2, 5, 0, 0, 0);
-				waitForSync(205);
-				stopAnimateSimon2(2,5);
-			}
+		if (_subtitles && _scriptVar2) {
+			animate(4, 2, 5, 0, 0, 0);
+			waitForSync(205);
+			stopAnimateSimon2(2,5);
+		}
 
-			stopAnimateSimon2(2, vgaSpriteId + 2);
-			loadVoice(speech_id);
-			animate(4, 2, vgaSpriteId + 2, 0, 0, 0);
-		}
+		stopAnimateSimon2(2, vgaSpriteId + 2);
+		loadVoice(speech_id);
+		animate(4, 2, vgaSpriteId + 2, 0, 0, 0);
 	}
 }
 
@@ -162,89 +162,93 @@
 	_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_modHandle, audioStream);
 }
 
-void AGOSEngine::loadMusic(uint music) {
+void AGOSEngine_Simon2::loadMusic(uint music) {
 	char buf[4];
 
-	if (getGameType() == GType_SIMON2) {
-		_midi.stop();
+	_midi.stop();
+	_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET);
+	_gameFile->read(buf, 4);
+	if (!memcmp(buf, "FORM", 4)) {
 		_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET);
+		_midi.loadXMIDI(_gameFile);
+	} else {
+		_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET);
+		_midi.loadMultipleSMF(_gameFile);
+	}
+
+	_lastMusicPlayed = music;
+	_nextMusicToPlay = -1;
+}
+
+void AGOSEngine_Simon1::loadMusic(uint music) {
+	char buf[4];
+
+	_midi.stop();
+	_midi.setLoop(true); // Must do this BEFORE loading music. (GMF may have its own override.)
+
+	// Support for compressed music from the ScummVM Music Enhancement Project
+	AudioCD.stop();
+	AudioCD.play(music + 1, -1, 0, 0);
+	if (AudioCD.isPlaying())
+		return;
+
+	if (getGameId() == GID_SIMON1ACORN) {
+		// TODO: Add support for Desktop Tracker format
+	} else if (getPlatform() == Common::kPlatformAmiga) {
+		loadModule(music);
+	} else if (getFeatures() & GF_TALKIE) {
+		// WORKAROUND: For a script bug in the CD versions
+		// We skip this music resource, as it was replaced by
+		// a sound effect, and the script was never updated.
+		if (music == 35)
+			return;
+
+		_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET);
 		_gameFile->read(buf, 4);
-		if (!memcmp(buf, "FORM", 4)) {
-			_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET);
-			_midi.loadXMIDI(_gameFile);
+		if (!memcmp(buf, "GMF\x1", 4)) {
+			_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET);
+			_midi.loadSMF(_gameFile, music);
 		} else {
-			_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET);
+			_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET);
 			_midi.loadMultipleSMF(_gameFile);
 		}
 
-		_lastMusicPlayed = music;
-		_nextMusicToPlay = -1;
-	} else if (getGameType() == GType_SIMON1) {
-		_midi.stop();
-		_midi.setLoop(true); // Must do this BEFORE loading music. (GMF may have its own override.)
+		_midi.startTrack(0);
+	} else {
+		char filename[15];
+		File f;
+		sprintf(filename, "MOD%d.MUS", music);
+		f.open(filename);
+		if (f.isOpen() == false)
+			error("loadMusic: Can't load music from '%s'", filename);
 
-		// Support for compressed music from the ScummVM Music Enhancement Project
-		AudioCD.stop();
-		AudioCD.play(music + 1, -1, 0, 0);
-		if (AudioCD.isPlaying())
-			return;
+		if (getFeatures() & GF_DEMO)
+			_midi.loadS1D(&f);
+		else
+			_midi.loadSMF(&f, music);
 
-		if (getGameId() == GID_SIMON1ACORN) {
-			// TODO: Add support for Desktop Tracker format
-		} else if (getPlatform() == Common::kPlatformAmiga) {
-			loadModule(music);
-		} else if (getFeatures() & GF_TALKIE) {
-			// WORKAROUND: For a script bug in the CD versions
-			// We skip this music resource, as it was replaced by
-			// a sound effect, and the script was never updated.
-			if (music == 35)
-				return;
+		_midi.startTrack(0);
+	}
+}
 
-			_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET);
-			_gameFile->read(buf, 4);
-			if (!memcmp(buf, "GMF\x1", 4)) {
-				_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET);
-				_midi.loadSMF(_gameFile, music);
-			} else {
-				_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET);
-				_midi.loadMultipleSMF(_gameFile);
-			}
-
-			_midi.startTrack(0);
-		} else {
-			char filename[15];
-			File f;
-			sprintf(filename, "MOD%d.MUS", music);
-			f.open(filename);
-			if (f.isOpen() == false)
-				error("loadMusic: Can't load music from '%s'", filename);
-
-			if (getFeatures() & GF_DEMO)
-				_midi.loadS1D(&f);
-			else
-				_midi.loadSMF(&f, music);
-
-			_midi.startTrack(0);
-		}
+void AGOSEngine::loadMusic(uint music) {
+	if (getPlatform() == Common::kPlatformAmiga) {
+		loadModule(music);
+	} else if (getPlatform() == Common::kPlatformAtariST) {
+		// TODO: Add support for music formats used
 	} else {
-		if (getPlatform() == Common::kPlatformAmiga) {
-			loadModule(music);
-		} else if (getPlatform() == Common::kPlatformAtariST) {
-			// TODO: Add support for music formats used
-		} else {
-			_midi.stop();
-			_midi.setLoop(true); // Must do this BEFORE loading music.
+		_midi.stop();
+		_midi.setLoop(true); // Must do this BEFORE loading music.
 
-			char filename[15];
-			File f;
-			sprintf(filename, "MOD%d.MUS", music);
-			f.open(filename);
-			if (f.isOpen() == false)
-				error("loadMusic: Can't load music from '%s'", filename);
+		char filename[15];
+		File f;
+		sprintf(filename, "MOD%d.MUS", music);
+		f.open(filename);
+		if (f.isOpen() == false)
+			error("loadMusic: Can't load music from '%s'", filename);
 
-			_midi.loadS1D(&f);
-			_midi.startTrack(0);
-		}
+		_midi.loadS1D(&f);
+		_midi.startTrack(0);
 	}
 }
 


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