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

waltervn at users.sourceforge.net waltervn at users.sourceforge.net
Thu Jun 4 17:56:14 CEST 2009


Revision: 41170
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41170&view=rev
Author:   waltervn
Date:     2009-06-04 15:56:11 +0000 (Thu, 04 Jun 2009)

Log Message:
-----------
SCI: Added support for early SCI1.1 audio maps.

Modified Paths:
--------------
    scummvm/trunk/engines/sci/resource.cpp
    scummvm/trunk/engines/sci/resource.h

Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp	2009-06-04 14:29:20 UTC (rev 41169)
+++ scummvm/trunk/engines/sci/resource.cpp	2009-06-04 15:56:11 UTC (rev 41170)
@@ -1252,14 +1252,8 @@
 	return false;
 }
 
-bool AudioResource::findAudEntrySCI11(uint32 audioNumber, uint32 volume, uint32 &offset, bool getSync, uint32 *size) {
-	// 65535.MAP structure:
-	// =========
-	// 6 byte entries:
-	// w nEntry
-	// dw offset
-
-	// Other map files:
+bool AudioResource::findAudEntrySCI11Late(uint32 audioNumber, uint32 &offset, bool getSync, uint32 *size) {
+	// Map structure:
 	// ===============
 	// Header:
 	// dw baseOffset
@@ -1275,6 +1269,114 @@
 	uint32 n;
 	offset = 0;
 
+	byte *ptr = _audioMapSCI11->data;
+
+	offset = READ_UINT32(ptr);
+	ptr += 4;
+
+	while (ptr < _audioMapSCI11->data + _audioMapSCI11->size) {
+		n = READ_BE_UINT32(ptr);
+		ptr += 4;
+
+		if (n == 0xffffffff)
+			break;
+
+		offset += (READ_UINT16(ptr) | (ptr[2] << 16));
+		ptr += 3;
+
+		int syncSkip = 0;
+
+		if (n & 0x80) {
+			n ^= 0x80;
+
+			if (getSync) {
+				if (size)
+					*size = READ_UINT16(ptr);
+			} else {
+				syncSkip = READ_UINT16(ptr);
+			}
+
+			ptr += 2;
+
+			if (n & 0x40) {
+				n ^= 0x40;
+
+				if (!getSync)
+					syncSkip += READ_UINT16(ptr);
+
+				ptr += 2;
+			}
+
+			offset += syncSkip;
+
+			if (n == audioNumber)
+				return true;
+
+		} else {
+			if (n == audioNumber)
+				return !getSync;
+		}
+
+		offset -= syncSkip;
+	}
+
+	return false;
+}
+
+bool AudioResource::findAudEntrySCI11Early(uint32 audioNumber, uint32 &offset, bool getSync, uint32 *size) {
+	// Map structure:
+	// ===============
+	// 10-byte entries:
+	// b noun
+	// b verb
+	// b cond
+	// b seq
+	// dw offset
+	// w syncSize + syncAscSize
+
+	uint32 n;
+	offset = 0;
+
+	byte *ptr = _audioMapSCI11->data;
+
+	while (ptr < _audioMapSCI11->data + _audioMapSCI11->size) {
+		n = READ_BE_UINT32(ptr);
+		ptr += 4;
+
+		if (n == 0xffffffff)
+			break;
+
+		offset = READ_UINT32(ptr);
+		ptr += 4;
+
+		int syncSize = READ_UINT16(ptr);
+		ptr += 2;
+
+		if (n == audioNumber) {
+			if (getSync) {
+				if (size)
+					*size = syncSize;
+				return true;
+			} else {
+				offset += syncSize;
+				return true;
+			}
+		}
+	}
+
+	return false;
+}
+
+bool AudioResource::findAudEntrySCI11(uint32 audioNumber, uint32 volume, uint32 &offset, bool getSync, uint32 *size) {
+	// 65535.MAP structure:
+	// =========
+	// 6 byte entries:
+	// w nEntry
+	// dw offset
+
+	uint32 n;
+	offset = 0;
+
 	if (_audioMapSCI11 && _audioMapSCI11->number != volume) {
 		_resMgr->unlockResource(_audioMapSCI11, _audioMapSCI11->number, kResourceTypeMap);
 		_audioMapSCI11 = 0;
@@ -1301,53 +1403,16 @@
 				return true;
 		}
 	} else {
-		offset = READ_UINT32(ptr);
-		ptr += 4;
-
-		while (ptr < _audioMapSCI11->data + _audioMapSCI11->size) {
-			n = READ_BE_UINT32(ptr);
-			ptr += 4;
-
-			if (n == 0xffffffff)
-				break;
-
-			offset += (READ_UINT16(ptr) | (ptr[2] << 16));
-			ptr += 3;
-
-			int syncSkip = 0;
-
-			if (n & 0x80) {
-				n ^= 0x80;
-
-				if (getSync) {
-					if (size)
-						*size = READ_UINT16(ptr);
-				} else {
-					syncSkip = READ_UINT16(ptr);
-				}
-
-				ptr += 2;
-
-				if (n & 0x40) {
-					n ^= 0x40;
-
-					if (!getSync)
-						syncSkip += READ_UINT16(ptr);
-
-					ptr += 2;
-				}
-
-				offset += syncSkip;
-
-				if (n == audioNumber)
-					return true;
-
-			} else {
-				if (n == audioNumber)
-					return !getSync;
-			}
-
-			offset -= syncSkip;
+		// In early SCI1.1 the map is terminated with 10x 0xff, in late SCI1.1
+		// with 11x 0xff. If we look at the 11th last byte in an early SCI1.1
+		// map, this will be the high byte of the Sync length of the last entry.
+		// As Sync resources are relative small, we should never encounter a
+		// Sync with a size of 0xffnn. As such, the following heuristic should be
+		// sufficient to tell these map formats apart.
+		if (_audioMapSCI11->size >= 11 && (ptr[_audioMapSCI11->size - 11] == 0xff))
+			return findAudEntrySCI11Late(audioNumber, offset, getSync, size);
+		else {
+			return findAudEntrySCI11Early(audioNumber, offset, getSync, size);
 		}
 	}
 

Modified: scummvm/trunk/engines/sci/resource.h
===================================================================
--- scummvm/trunk/engines/sci/resource.h	2009-06-04 14:29:20 UTC (rev 41169)
+++ scummvm/trunk/engines/sci/resource.h	2009-06-04 15:56:11 UTC (rev 41170)
@@ -343,6 +343,8 @@
 
 	bool findAudEntrySCI1(uint16 audioNumber, byte &volume, uint32 &offset, uint32 &size);
 	bool findAudEntrySCI11(uint32 audioNumber, uint32 volume, uint32 &offset, bool getSync = false, uint32 *size = NULL);
+	bool findAudEntrySCI11Late(uint32 audioNumber, uint32 &offset, bool getSync, uint32 *size);
+	bool findAudEntrySCI11Early(uint32 audioNumber, uint32 &offset, bool getSync, uint32 *size);
 };
 
 } // End of namespace Sci


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