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

Kirben at users.sourceforge.net Kirben at users.sourceforge.net
Mon Jun 4 16:25:06 CEST 2007


Revision: 27080
          http://scummvm.svn.sourceforge.net/scummvm/?rev=27080&view=rev
Author:   Kirben
Date:     2007-06-04 07:25:02 -0700 (Mon, 04 Jun 2007)

Log Message:
-----------
Only call MIDI code, in games which use MIDI based music.

Modified Paths:
--------------
    scummvm/trunk/engines/agos/agos.h
    scummvm/trunk/engines/agos/input.cpp
    scummvm/trunk/engines/agos/res_snd.cpp
    scummvm/trunk/engines/agos/script.cpp
    scummvm/trunk/engines/agos/script_e1.cpp
    scummvm/trunk/engines/agos/vga_s2.cpp

Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h	2007-06-04 08:56:00 UTC (rev 27079)
+++ scummvm/trunk/engines/agos/agos.h	2007-06-04 14:25:02 UTC (rev 27080)
@@ -1186,8 +1186,10 @@
 	virtual void windowNewLine(WindowBlock *window);
 	void windowDrawChar(WindowBlock *window, uint x, uint y, byte chr);
 
-	virtual void loadMusic(uint music);
-	void loadModule(uint music);
+	void loadMusic(uint track);
+	void playModule(uint music);
+	virtual void playMusic(uint16 track, uint16 track);
+	void stopMusic();
 
 	void checkTimerCallback();
 	void delay(uint delay);
@@ -1478,7 +1480,7 @@
 	virtual void userGame(bool load);
 	virtual int userGameGetKey(bool *b, char *buf, uint maxChar);
 
-	virtual void loadMusic(uint music);
+	virtual void playMusic(uint16 music, uint16 track);
 
 	virtual void vcStopAnimation(uint zone, uint sprite);
 };
@@ -1521,8 +1523,6 @@
 	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/input.cpp
===================================================================
--- scummvm/trunk/engines/agos/input.cpp	2007-06-04 08:56:00 UTC (rev 27079)
+++ scummvm/trunk/engines/agos/input.cpp	2007-06-04 14:25:02 UTC (rev 27080)
@@ -558,21 +558,33 @@
 				_speech ^= 1;
 		}
 	case '+':
-		_midi.setVolume(_midi.getVolume() + 16);
+		if ((getPlatform() == Common::kPlatformAcorn && (getFeatures() & GF_TALKIE)) ||
+			getPlatform() == Common::kPlatformPC || getPlatform() == Common::kPlatformWindows) {
+			_midi.setVolume(_midi.getVolume() + 16);
+		}
 		_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) + 16);
 		break;
 	case '-':
-		_midi.setVolume(_midi.getVolume() - 16);
+		if ((getPlatform() == Common::kPlatformAcorn && (getFeatures() & GF_TALKIE)) ||
+			getPlatform() == Common::kPlatformPC || getPlatform() == Common::kPlatformWindows) {
+			_midi.setVolume(_midi.getVolume() - 16);
+		}
 		_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) - 16);
 		break;
 	case 'm':
-		_midi.pause(_musicPaused ^= 1);
+		if ((getPlatform() == Common::kPlatformAcorn && (getFeatures() & GF_TALKIE)) ||
+			getPlatform() == Common::kPlatformPC || getPlatform() == Common::kPlatformWindows) {
+			_midi.pause(_musicPaused ^= 1);
+		} else {
+			// TODO
+		}
 		break;
 	case 's':
-		if (getGameId() == GID_SIMON1DOS)
+		if (getGameId() == GID_SIMON1DOS) {
 			_midi._enable_sfx ^= 1;
-		else
+		} else {
 			_sound->effectsPause(_effectsPaused ^= 1);
+		}
 		break;
 	case 'b':
 		_sound->ambientPause(_ambientPaused ^= 1);

Modified: scummvm/trunk/engines/agos/res_snd.cpp
===================================================================
--- scummvm/trunk/engines/agos/res_snd.cpp	2007-06-04 08:56:00 UTC (rev 27079)
+++ scummvm/trunk/engines/agos/res_snd.cpp	2007-06-04 14:25:02 UTC (rev 27080)
@@ -120,9 +120,26 @@
 	}
 }
 
-void AGOSEngine::loadModule(uint music) {
-	_mixer->stopHandle(_modHandle);
+void AGOSEngine::loadMusic(uint music) {
+	char buf[4];
 
+	stopMusic();
+
+	_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::playModule(uint music) {
 	char filename[15];
 	File f;
 
@@ -135,7 +152,7 @@
 
 	f.open(filename);
 	if (f.isOpen() == false) {
-		error("loadModule: Can't load module from '%s'", filename);
+		error("playModule: Can't load module from '%s'", filename);
 	}
 
 	Audio::AudioStream *audioStream;
@@ -145,7 +162,7 @@
 		uint srcSize = f.size();
 		byte *srcBuf = (byte *)malloc(srcSize);
 		if (f.read(srcBuf, srcSize) != srcSize)
-			error("loadModule: Read failed");
+			error("playModule: Read failed");
 
 		uint dstSize = READ_BE_UINT32(srcBuf + srcSize - 4);
 		byte *dstBuf = (byte *)malloc(dstSize);
@@ -162,30 +179,9 @@
 	_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_modHandle, audioStream);
 }
 
-void AGOSEngine_Simon2::loadMusic(uint music) {
-	char buf[4];
+void AGOSEngine_Simon1::playMusic(uint16 music, uint16 track) {
+	stopMusic();
 
-	_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);
@@ -195,14 +191,18 @@
 	if (getGameId() == GID_SIMON1ACORN) {
 		// TODO: Add support for Desktop Tracker format
 	} else if (getPlatform() == Common::kPlatformAmiga) {
-		loadModule(music);
+		playModule(music);
 	} else if (getFeatures() & GF_TALKIE) {
+		char buf[4];
+
 		// 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.setLoop(true); // Must do this BEFORE loading music. (GMF may have its own override.)
+
 		_gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music], SEEK_SET);
 		_gameFile->read(buf, 4);
 		if (!memcmp(buf, "GMF\x1", 4)) {
@@ -214,30 +214,35 @@
 		}
 
 		_midi.startTrack(0);
+		_midi.startTrack(track);
 	} 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);
+			error("playMusic: Can't load music from '%s'", filename);
 
+		_midi.setLoop(true); // Must do this BEFORE loading music. (GMF may have its own override.)
+
 		if (getFeatures() & GF_DEMO)
 			_midi.loadS1D(&f);
 		else
 			_midi.loadSMF(&f, music);
 
 		_midi.startTrack(0);
+		_midi.startTrack(track);
 	}
 }
 
-void AGOSEngine::loadMusic(uint music) {
+void AGOSEngine::playMusic(uint16 music, uint16 track) {
+	stopMusic();
+
 	if (getPlatform() == Common::kPlatformAmiga) {
-		loadModule(music);
+		playModule(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.
 
 		char filename[15];
@@ -245,13 +250,23 @@
 		sprintf(filename, "MOD%d.MUS", music);
 		f.open(filename);
 		if (f.isOpen() == false)
-			error("loadMusic: Can't load music from '%s'", filename);
+			error("playMusic: Can't load music from '%s'", filename);
 
 		_midi.loadS1D(&f);
 		_midi.startTrack(0);
+		_midi.startTrack(track);
 	}
 }
 
+void AGOSEngine::stopMusic() {
+	if ((getPlatform() == Common::kPlatformAcorn && (getFeatures() & GF_TALKIE)) ||
+		getPlatform() == Common::kPlatformPC || getPlatform() == Common::kPlatformWindows) {
+		_midi.stop();
+	} else {
+		_mixer->stopHandle(_modHandle);
+	}
+}
+
 void AGOSEngine::playSting(uint a) {
 	if (!_midi._enable_sfx)
 		return;

Modified: scummvm/trunk/engines/agos/script.cpp
===================================================================
--- scummvm/trunk/engines/agos/script.cpp	2007-06-04 08:56:00 UTC (rev 27079)
+++ scummvm/trunk/engines/agos/script.cpp	2007-06-04 14:25:02 UTC (rev 27080)
@@ -722,13 +722,12 @@
 
 void AGOSEngine::o_playTune() {
 	// 127:  play tune
-	int music = getVarOrWord();
-	int track = getVarOrWord();
+	uint16 music = getVarOrWord();
+	uint16 track = getVarOrWord();
 
 	if (music != _lastMusicPlayed) {
 		_lastMusicPlayed = music;
-		loadMusic(music);
-		_midi.startTrack(track);
+		playMusic(music, track);
 	}
 }
 

Modified: scummvm/trunk/engines/agos/script_e1.cpp
===================================================================
--- scummvm/trunk/engines/agos/script_e1.cpp	2007-06-04 08:56:00 UTC (rev 27079)
+++ scummvm/trunk/engines/agos/script_e1.cpp	2007-06-04 14:25:02 UTC (rev 27080)
@@ -843,20 +843,16 @@
 
 void AGOSEngine_Elvira1::oe1_playTune() {
 	// 264: play tune
-	int music = getVarOrWord();
-	int track = getVarOrWord();
+	uint16 music = getVarOrWord();
+	uint16 track = getVarOrWord();
 
 	if (music != _lastMusicPlayed) {
 		_lastMusicPlayed = music;
 		// No tune under water
 		if (music == 4) {
-			if (getPlatform() == Common::kPlatformAmiga)
-				_mixer->stopHandle(_modHandle);
-			else
-				_midi.stop();
+			stopMusic();
 		} else {
-			loadMusic(music);
-			_midi.startTrack(track);
+			playMusic(music, track);
 		}
 	}
 }

Modified: scummvm/trunk/engines/agos/vga_s2.cpp
===================================================================
--- scummvm/trunk/engines/agos/vga_s2.cpp	2007-06-04 08:56:00 UTC (rev 27079)
+++ scummvm/trunk/engines/agos/vga_s2.cpp	2007-06-04 14:25:02 UTC (rev 27080)
@@ -194,7 +194,7 @@
 	int16 loop = vcReadNextWord();
 
 	if (track == -1 || track == 999) {
-		_midi.stop();
+		stopMusic();
 	} else {
 		_midi.setLoop(loop != 0);
 		_midi.startTrack(track);


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