[Scummvm-cvs-logs] SF.net SVN: scummvm:[52211] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Thu Aug 19 15:52:21 CEST 2010


Revision: 52211
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52211&view=rev
Author:   thebluegr
Date:     2010-08-19 13:52:21 +0000 (Thu, 19 Aug 2010)

Log Message:
-----------
SCI: Added checking for the existence of a GM track, to determine if device ID 7 or 12 should be used. Fixes the GM music in the demo of QFG3, which is using an in-between version of SCI1 and SCI1.1

Modified Paths:
--------------
    scummvm/trunk/engines/sci/resource.h
    scummvm/trunk/engines/sci/resource_audio.cpp
    scummvm/trunk/engines/sci/sound/drivers/midi.cpp

Modified: scummvm/trunk/engines/sci/resource.h
===================================================================
--- scummvm/trunk/engines/sci/resource.h	2010-08-19 12:43:37 UTC (rev 52210)
+++ scummvm/trunk/engines/sci/resource.h	2010-08-19 13:52:21 UTC (rev 52211)
@@ -315,6 +315,7 @@
 
 	void setAudioLanguage(int language);
 	int getAudioLanguage() const;
+	bool isGMTrackIncluded();
 	bool isVGA() const { return (_viewType == kViewVga) || (_viewType == kViewVga11); }
 	bool isAmiga32color() const { return _viewType == kViewAmiga; }
 	bool isSci11Mac() const { return _volVersion == kResVersionSci11Mac; }

Modified: scummvm/trunk/engines/sci/resource_audio.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource_audio.cpp	2010-08-19 12:43:37 UTC (rev 52210)
+++ scummvm/trunk/engines/sci/resource_audio.cpp	2010-08-19 13:52:21 UTC (rev 52211)
@@ -519,6 +519,35 @@
 	return (_audioMapSCI1 ? _audioMapSCI1->_volumeNumber : 0);
 }
 
+bool ResourceManager::isGMTrackIncluded() {
+	// This check only makes sense for SCI1 and newer games
+	if (getSciVersion() < SCI_VERSION_1_EARLY)
+		return false;
+
+	// SCI2 and newer games always have GM tracks
+	if (getSciVersion() >= SCI_VERSION_2)
+		return true;
+
+	// For the leftover games, we can safely use SCI_VERSION_1_EARLY for the soundVersion
+	const SciVersion soundVersion = SCI_VERSION_1_EARLY;
+
+	// Read song 1 and check if it has a GM track
+	bool result = false;
+	SoundResource *song1 = new SoundResource(1, this, soundVersion);
+	if (!song1) {
+		warning("ResourceManager::isGMTrackIncluded: track 1 not found");
+		return false;
+	}
+
+	SoundResource::Track *gmTrack = song1->getTrackByType(0x07);
+	if (gmTrack)
+		result = true;
+
+	delete song1;
+
+	return result;
+}
+
 SoundResource::SoundResource(uint32 resourceNr, ResourceManager *resMan, SciVersion soundVersion) : _resMan(resMan), _soundVersion(soundVersion) {
 	Resource *resource = _resMan->findResource(ResourceId(kResourceTypeSound, resourceNr), true);
 	int trackNr, channelNr;

Modified: scummvm/trunk/engines/sci/sound/drivers/midi.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/drivers/midi.cpp	2010-08-19 12:43:37 UTC (rev 52210)
+++ scummvm/trunk/engines/sci/sound/drivers/midi.cpp	2010-08-19 13:52:21 UTC (rev 52211)
@@ -97,7 +97,7 @@
 	};
 
 	bool _isMt32;
-	bool _isOldPatchFormat;
+	bool _useMT32Track;
 	bool _hasReverb;
 	bool _playSwitch;
 	int _masterVolume;
@@ -119,7 +119,7 @@
 	byte _sysExBuf[kMaxSysExSize];
 };
 
-MidiPlayer_Midi::MidiPlayer_Midi(SciVersion version) : MidiPlayer(version), _playSwitch(true), _masterVolume(15), _isMt32(false), _hasReverb(false), _isOldPatchFormat(true) {
+MidiPlayer_Midi::MidiPlayer_Midi(SciVersion version) : MidiPlayer(version), _playSwitch(true), _masterVolume(15), _isMt32(false), _hasReverb(false), _useMT32Track(true) {
 	MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI);
 	_driver = createMidi(dev);
 
@@ -820,9 +820,15 @@
 			// Detect the format of patch 1, so that we know what play mask to use
 			res = resMan->findResource(ResourceId(kResourceTypePatch, 1), 0);
 			if (!res)
-				_isOldPatchFormat = false;
+				_useMT32Track = false;
 			else
-				_isOldPatchFormat = !isMt32GmPatch(res->data, res->size);
+				_useMT32Track = !isMt32GmPatch(res->data, res->size);
+
+			// Check if the songs themselves have a GM track
+			if (!_useMT32Track) {
+				if (!resMan->isGMTrackIncluded())
+					_useMT32Track = true;
+			}
 		} else {
 			// No GM patch found, map instruments using MT-32 patch
 
@@ -897,7 +903,7 @@
 		if (_isMt32)
 			return 0x0c;
 		else
-			return _isOldPatchFormat ? 0x0c : 0x07;
+			return _useMT32Track ? 0x0c : 0x07;
 	}
 }
 


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