[Scummvm-cvs-logs] CVS: scummvm/sound voc.cpp,1.17,1.18

Max Horn fingolfin at users.sourceforge.net
Wed May 5 03:59:01 CEST 2004


Update of /cvsroot/scummvm/scummvm/sound
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13286

Modified Files:
	voc.cpp 
Log Message:
Remove odd sample rate hack (for DOTT demo); instead, be slightly less strict about VOC headers, since DOTT demo (and maybe others) use buggy VOC headers

Index: voc.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/voc.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- voc.cpp	2 May 2004 22:33:20 -0000	1.17
+++ voc.cpp	5 May 2004 10:58:07 -0000	1.18
@@ -30,19 +30,13 @@
 
 
 int getSampleRateFromVOCRate(int vocSR) {
-	if (vocSR == 0x83) {
-		// FIXME: This is a special hack added by Kirben on Fri Nov 7 11:11:06 2003 UTC,
-		// with the comment: "Correct voc rate in DOTT demo".
-		// It's not clear to me whether this is indeed a proper workaround for a broken
-		// data file, or just a random fix... ?
-		return 11025;
-	} else if (vocSR == 0xa5 || vocSR == 0xa6) {
+	if (vocSR == 0xa5 || vocSR == 0xa6) {
 		return 11025;
 	} else if (vocSR == 0xd2 || vocSR == 0xd3) {
 		return 22050;
 	} else {
 		int sr = 1000000L / (256L - vocSR);
-		// Inexect% sampling rates occur e.g. in the kitchen in Monkey Island,
+		// inexact sampling rates occur e.g. in the kitchen in Monkey Island,
 		// very easy to reach right from the start of the game.
 		//warning("inexact sample rate used: %i (0x%x)", sr, vocSR);
 		return sr;
@@ -51,7 +45,14 @@
 
 byte *readVOCFromMemory(byte *ptr, int &size, int &rate, int &loops, int &begin_loop, int &end_loop) {
 	
-	assert(memcmp(ptr, "Creative Voice File\x1A", 20) == 0);
+	// Verify the VOC header. We are a little bit lenient here to work around
+	// some invalid VOC headers used in various SCUMM games (they have 0x0
+	// instead of 0x1A after the "Creative Voice File" string).
+	if (memcmp(ptr, "Creative Voice File", 19) != 0)
+		error("readVOCFromMemory: Invalid header");
+	if (ptr[19] != 0x1A)
+		debug(3, "readVOCFromMemory: Partially invalid header");
+	
 	int32 offset = READ_LE_UINT16(ptr + 20);
 	int16 version = READ_LE_UINT16(ptr + 22);
 	int16 code = READ_LE_UINT16(ptr + 24);
@@ -126,11 +127,15 @@
 			goto invalid;
 	} else {
 	invalid:;
-		warning("loadVOCFile: invalid header");
+		warning("loadVOCFile: Invalid header");
 		return NULL;
 	}
 
-	assert(memcmp(&fileHeader, "Creative Voice File\x1A", 20) == 0);
+	if (memcmp(fileHeader.desc, "Creative Voice File", 19) != 0)
+		error("loadVOCFile: Invalid header");
+	if (fileHeader.desc[19] != 0x1A)
+		debug(3, "loadVOCFile: Partially invalid header");
+
 	//int32 offset = FROM_LE_16(fileHeader.datablock_offset);
 	int16 version = FROM_LE_16(fileHeader.version);
 	int16 code = FROM_LE_16(fileHeader.id);





More information about the Scummvm-git-logs mailing list