[Scummvm-cvs-logs] CVS: scummvm sound.cpp,1.110,1.111 util.h,1.3,1.4 util.cpp,1.3,1.4

Max Horn fingolfin at users.sourceforge.net
Thu Jul 25 09:30:03 CEST 2002


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv7610

Modified Files:
	sound.cpp util.h util.cpp 
Log Message:
added simple hexdump() function (nice for debugging); added some debug code for Zak256 sounds

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound.cpp,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- sound.cpp	25 Jul 2002 15:37:31 -0000	1.110
+++ sound.cpp	25 Jul 2002 16:29:07 -0000	1.111
@@ -224,7 +224,45 @@
 	if ((_features & GF_OLD256) && (ptr != NULL)) {
 		char *sound;
 		int size = READ_LE_UINT32(ptr);
-		ptr+=0x16;
+		
+#if 1
+		// FIXME - this is just some debug output for Zak256
+		if (size != 30) {
+			char name[9];
+			memcpy(name, ptr+22, 8);
+			name[8] = 0;
+			printf("Going to play Zak256 sound '%s':\n", name);
+			hexdump(ptr, 0x40);
+		}
+		/*
+		There seems to be some pattern in the Zak256 sound data. Two typical
+		examples are these:
+		
+		d7 10 00 00 53 4f d1 10  |....SO..|
+		00 00 00 00 04 00 ff 00  |........|
+		64 00 00 00 01 00 64 6f  |d.....do|
+		6f 72 6f 70 65 6e 40 a8  |oropen at .|
+		57 14 a1 10 00 00 50 08  |W.....P.|
+		00 00 00 00 00 00 b3 07  |........|
+		00 00 3c 00 00 00 04 80  |..<.....|
+		03 02 0a 01 8c 82 87 81  |........|
+
+		5b 07 00 00 53 4f 55 07  |[...SOU.|
+		00 00 00 00 04 00 ff 00  |........|
+		64 00 00 00 01 00 64 72  |d.....dr|
+		77 6f 70 65 6e 00 53 a8  |wopen.S.|
+		57 14 25 07 00 00 92 03  |W.%.....|
+		00 00 00 00 00 00 88 03  |........|
+		00 00 3c 00 00 00 82 82  |..<.....|
+		83 84 86 88 89 8b 89 89  |........|
+		
+		As you can see, there are quite some patterns, e.g.
+		the 00 00 00 3c - the sound data seems to start at
+		offset 54.
+		*/
+#endif
+		
+		ptr += 0x16;
 
 		if (size == 30) {
 #ifdef COMPRESSED_SOUND_FILE
@@ -234,15 +272,16 @@
 			return;
 		}
 
-		sound = (char*)malloc(size-0x36);
-		for (int x=0; x<(size-0x36); x++) {
+		size -= 0x36;
+		sound = (char*)malloc(size);
+		for (int x = 0; x < size; x++) {
 			int bit = *ptr++;
 			if (bit<0x80) sound[x] = 0x7F-bit; else sound[x] = bit;
 		}
 
 		// FIXME: Something in the header signifies looping. Need to track it down and add a 
 		//	  mixer flag or something.
-		_mixer->play_raw(NULL, sound, size-0x36, 11000, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
+		_mixer->play_raw(NULL, sound, size, 11000, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
 		return;
 	}
 

Index: util.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/util.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- util.h	18 Jul 2002 20:26:35 -0000	1.3
+++ util.h	25 Jul 2002 16:29:07 -0000	1.4
@@ -27,6 +27,11 @@
 int Blend(int src, int dst, byte *palette);
 void ClearBlendCache(byte *palette, int weight);
 
+/*
+ * Print hexdump of the data passed in, 8 bytes a row
+ */
+void hexdump(const byte * data, int len);
+
 
 namespace ScummVM {
 

Index: util.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/util.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- util.cpp	18 Jul 2002 20:26:35 -0000	1.3
+++ util.cpp	25 Jul 2002 16:29:07 -0000	1.4
@@ -82,6 +82,48 @@
 
 #pragma mark -
 
+/*
+ * Print hexdump of the data passed in, 8 bytes a row
+ */
+void hexdump(const byte * data, int len)
+{
+	int i;
+	byte c;
+	while (len >= 8) {
+		for (i = 0; i < 8; i++)
+			printf("%02x ", data[i]);
+		printf(" |");
+		for (i = 0; i < 8; i++) {
+			c = data[i];
+			if (c < 32 || c > 127)
+				c = '.';
+			printf("%c", c);
+		}
+		printf("|\n");
+		data += 8;
+		len -= 8;
+	}
+
+	for (i = 0; i < len; i++)
+		printf("%02x ", data[i]);
+	for (; i < 8; i++)
+		printf("   ");
+	printf(" |");
+	for (i = 0; i < len; i++) {
+		c = data[i];
+		if (c < 32 || c > 127)
+			c = '.';
+		printf("%c", c);
+	}
+	for (; i < 8; i++)
+		printf(" ");
+	printf("|\n");
+}
+
+
+#pragma mark -
+
+
 namespace ScummVM {
 
 String::String(const char *str)





More information about the Scummvm-git-logs mailing list