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

waltervn at users.sourceforge.net waltervn at users.sourceforge.net
Sat Oct 10 03:38:50 CEST 2009


Revision: 44859
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44859&view=rev
Author:   waltervn
Date:     2009-10-10 01:38:45 +0000 (Sat, 10 Oct 2009)

Log Message:
-----------
SCI: Adlib: Add support for loading patch data from adl.drv

Modified Paths:
--------------
    scummvm/trunk/engines/sci/sfx/softseq/adlib.cpp
    scummvm/trunk/engines/sci/sfx/softseq/adlib.h

Modified: scummvm/trunk/engines/sci/sfx/softseq/adlib.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/softseq/adlib.cpp	2009-10-10 00:07:19 UTC (rev 44858)
+++ scummvm/trunk/engines/sci/sfx/softseq/adlib.cpp	2009-10-10 01:38:45 UTC (rev 44859)
@@ -608,19 +608,26 @@
 	renewNotes(-1, play);
 }
 
-void MidiDriver_Adlib::loadResource(Resource *res) {
+bool MidiDriver_Adlib::loadResource(const byte *data, uint size) {
+	if ((size != 1344) && (size != 2690) && (size != 5382)) {
+		warning("ADLIB: Unsupported patch format (%i bytes)", size);
+		return false;
+	}
+
 	for (int i = 0; i < 48; i++)
-		loadInstrument(res->data + (28 * i));
+		loadInstrument(data + (28 * i));
 
-	if (res->size == 2690) {
+	if (size == 2690) {
 		for (int i = 48; i < 96; i++)
-			loadInstrument(res->data + 2 + (28 * i));
-	} else if (res->size == 5382) {
+			loadInstrument(data + 2 + (28 * i));
+	} else if (size == 5382) {
 		for (int i = 48; i < 190; i++)
-			loadInstrument(res->data + (28 * i));
+			loadInstrument(data + (28 * i));
 		_rhythmKeyMap = new byte[kRhythmKeys];
-		memcpy(_rhythmKeyMap, res->data + 5320, kRhythmKeys);
+		memcpy(_rhythmKeyMap, data + 5320, kRhythmKeys);
 	}
+
+	return true;
 }
 
 int MidiPlayer_Adlib::open(ResourceManager *resMan) {
@@ -628,19 +635,35 @@
 
 	// Load up the patch.003 file, parse out the instruments
 	Resource *res = resMan->findResource(ResourceId(kResourceTypePatch, 3), 0);
+	bool ok = false;
 
-	if (!res) {
-		warning("ADLIB: Failed to load patch.003");
-		return -1;
+	if (res) {
+		ok = static_cast<MidiDriver_Adlib *>(_driver)->loadResource(res->data, res->size);
+	} else {
+		// Early SCI0 games have the sound bank embedded in the adlib driver
+
+		Common::File f;
+
+		if (f.open("ADL.DRV")) {
+			int size = f.size();
+			const uint patchSize = 1344;
+
+			if ((size == 5684) || (size == 5720) || (size == 5727)) {
+				byte *buf = new byte[patchSize];
+
+				if (f.seek(0x45a) && (f.read(buf, patchSize) == patchSize))
+					ok = static_cast<MidiDriver_Adlib *>(_driver)->loadResource(buf, patchSize);
+
+				delete[] buf;
+			}
+		}
 	}
 
-	if ((res->size != 1344) && (res->size != 2690) && (res->size != 5382)) {
-		warning("ADLIB: Unsupported patch format (%i bytes)", res->size);
+	if (!ok) {
+		warning("ADLIB: Failed to load patch.003");
 		return -1;
 	}
 
-	static_cast<MidiDriver_Adlib *>(_driver)->loadResource(res);
-
 	return static_cast<MidiDriver_Adlib *>(_driver)->open(getSciVersion() <= SCI_VERSION_0_LATE);
 }
 

Modified: scummvm/trunk/engines/sci/sfx/softseq/adlib.h
===================================================================
--- scummvm/trunk/engines/sci/sfx/softseq/adlib.h	2009-10-10 00:07:19 UTC (rev 44858)
+++ scummvm/trunk/engines/sci/sfx/softseq/adlib.h	2009-10-10 01:38:45 UTC (rev 44859)
@@ -54,7 +54,7 @@
 
 	void setVolume(byte volume);
 	void playSwitch(bool play);
-	void loadResource(Resource *res);
+	bool loadResource(const byte *data, uint size);
 
 private:
 	enum ChannelID {


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