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

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Tue Jun 22 17:18:56 CEST 2010


Revision: 50144
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50144&view=rev
Author:   mthreepwood
Date:     2010-06-22 15:18:55 +0000 (Tue, 22 Jun 2010)

Log Message:
-----------
Add support for the QFG3 demo audio map and audio resources. Based on a patch by Walter.

Modified Paths:
--------------
    scummvm/trunk/engines/sci/resource_audio.cpp
    scummvm/trunk/engines/sci/sound/audio.cpp

Modified: scummvm/trunk/engines/sci/resource_audio.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource_audio.cpp	2010-06-22 15:05:09 UTC (rev 50143)
+++ scummvm/trunk/engines/sci/resource_audio.cpp	2010-06-22 15:18:55 UTC (rev 50144)
@@ -110,17 +110,19 @@
 	_headerSize = file->readByte();
 
 	if (type == kResourceTypeAudio) {
-		if (_headerSize != 11 && _headerSize != 12) {
+		if (_headerSize != 7 && _headerSize != 11 && _headerSize != 12) {
 			warning("Unsupported audio header");
 			unalloc();
 			return false;
 		}
 
-		// Load sample size
-		file->seek(7, SEEK_CUR);
-		size = file->readUint32LE();
-		// Adjust offset to point at the header data again
-		file->seek(-11, SEEK_CUR);
+		if (_headerSize != 7) { // Size is defined already from the map
+			// Load sample size
+			file->seek(7, SEEK_CUR);
+			size = file->readUint32LE();
+			// Adjust offset to point at the header data again
+			file->seek(-11, SEEK_CUR);
+		}
 	}
 
 	return loadPatch(file);
@@ -247,7 +249,6 @@
 // w syncAscSize (iff seq has bit 6 set)
 
 int ResourceManager::readAudioMapSCI11(ResourceSource *map) {
-	bool isEarly = true;
 	uint32 offset = 0;
 	Resource *mapRes = findResource(ResourceId(kResourceTypeMap, map->_volumeNumber), false);
 
@@ -263,11 +264,16 @@
 
 	byte *ptr = mapRes->data;
 
+	// Heuristic to detect entry size
+	uint32 entrySize = 0;
+	for (int i = mapRes->size - 1; i >= 0; --i) {
+		if (ptr[i] == 0xff)
+			entrySize++;
+		else
+			break;
+	}
+
 	if (map->_volumeNumber == 65535) {
-		// Heuristic to detect late SCI1.1 map format
-		if ((mapRes->size >= 6) && (ptr[mapRes->size - 6] != 0xff))
-			isEarly = false;
-
 		while (ptr < mapRes->data + mapRes->size) {
 			uint16 n = READ_LE_UINT16(ptr);
 			ptr += 2;
@@ -275,7 +281,7 @@
 			if (n == 0xffff)
 				break;
 
-			if (isEarly) {
+			if (entrySize == 6) {
 				offset = READ_LE_UINT32(ptr);
 				ptr += 4;
 			} else {
@@ -285,10 +291,25 @@
 
 			addResource(ResourceId(kResourceTypeAudio, n), src, offset);
 		}
+	} else if (map->_volumeNumber == 0 && entrySize == 10 && ptr[3] == 0) {
+		// QFG3 demo format
+		// ptr[3] would be 'seq' in the normal format and cannot possibly be 0
+		while (ptr < mapRes->data + mapRes->size) {
+			uint16 n = READ_BE_UINT16(ptr);
+			ptr += 2;
+
+			if (n == 0xffff)
+				break;
+
+			offset = READ_LE_UINT32(ptr);
+			ptr += 4;
+			uint32 size = READ_LE_UINT32(ptr);
+			ptr += 4;
+
+			addResource(ResourceId(kResourceTypeAudio, n), src, offset, size);
+		}
 	} else {
-		// Heuristic to detect late SCI1.1 map format
-		if ((mapRes->size >= 11) && (ptr[mapRes->size - 11] == 0xff))
-			isEarly = false;
+		bool isEarly = (entrySize != 11); 
 
 		if (!isEarly) {
 			offset = READ_LE_UINT32(ptr);

Modified: scummvm/trunk/engines/sci/sound/audio.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/audio.cpp	2010-06-22 15:05:09 UTC (rev 50143)
+++ scummvm/trunk/engines/sci/sound/audio.cpp	2010-06-22 15:18:55 UTC (rev 50144)
@@ -182,17 +182,28 @@
 
 // Sierra SOL audio file reader
 // Check here for more info: http://wiki.multimedia.cx/index.php?title=Sierra_Audio
-static bool readSOLHeader(Common::SeekableReadStream *audioStream, int headerSize, uint32 &size, uint16 &audioRate, byte &audioFlags) {
-	if (headerSize != 11 && headerSize != 12) {
+static bool readSOLHeader(Common::SeekableReadStream *audioStream, int headerSize, uint32 &size, uint16 &audioRate, byte &audioFlags, uint32 resSize) {
+	if (headerSize != 7 && headerSize != 11 && headerSize != 12) {
 		warning("SOL audio header of size %i not supported", headerSize);
 		return false;
 	}
 
-	audioStream->readUint32LE();			// skip "SOL" + 0 (4 bytes)
+	uint32 tag = audioStream->readUint32BE();
+
+	if (tag != MKID_BE('SOL\0')) {
+		warning("No 'SOL' FourCC found");
+		return false;
+	}
+
 	audioRate = audioStream->readUint16LE();
 	audioFlags = audioStream->readByte();
 
-	size = audioStream->readUint32LE();
+	// For the QFG3 demo format, just use the resource size
+	// Otherwise, load it from the header
+	if (headerSize == 7)
+		size = resSize;
+	else
+		size = audioStream->readUint32LE();
 	return true;
 }
 
@@ -294,7 +305,7 @@
 			// SCI1.1
 			Common::MemoryReadStream headerStream(audioRes->_header, audioRes->_headerSize, DisposeAfterUse::NO);
 
-			if (readSOLHeader(&headerStream, audioRes->_headerSize, size, _audioRate, audioFlags)) {
+			if (readSOLHeader(&headerStream, audioRes->_headerSize, size, _audioRate, audioFlags, audioRes->size)) {
 				Common::MemoryReadStream dataStream(audioRes->data, audioRes->size, DisposeAfterUse::NO);
 				data = readSOLAudio(&dataStream, size, audioFlags, flags);
 			}


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