[Scummvm-cvs-logs] CVS: scummvm/sword2/driver d_sound.cpp,1.82,1.83

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Mon Dec 1 23:42:00 CET 2003


Update of /cvsroot/scummvm/scummvm/sword2/driver
In directory sc8-pr-cvs1:/tmp/cvs-serv5584/driver

Modified Files:
	d_sound.cpp 
Log Message:
cleanup


Index: d_sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/d_sound.cpp,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- d_sound.cpp	16 Nov 2003 14:18:29 -0000	1.82
+++ d_sound.cpp	2 Dec 2003 07:41:04 -0000	1.83
@@ -292,7 +292,7 @@
 
 /**
  * This function loads and decompresses a list of speech from a cluster, but
- * does not play it. This is primarily used by PlayCompSpeech(), but also to
+ * does not play it. This is primarily used by playCompSpeech(), but also to
  * store the voice-overs for the animated cutscenes until they are played.
  * @param filename the file name of the speech cluster file
  * @param speechid the text line id used to reference the speech
@@ -302,7 +302,7 @@
 uint32 Sound::preFetchCompSpeech(const char *filename, uint32 speechid, uint16 **buf) {
 	uint32 i;
 	uint8 *data8;
-	uint32 speechIndex[2];
+	uint32 speechPos, speechLength;
 	File fp;
 	uint32 bufferSize;
 
@@ -315,30 +315,24 @@
 
 	fp.seek((speechid + 1) * 8, SEEK_SET);
 
-	if (fp.read(speechIndex, sizeof(uint32) * 2) != (sizeof(uint32) * 2)) {
-		fp.close();
-		return 0;
-	}
-
-#ifdef SCUMM_BIG_ENDIAN
-	speechIndex[0] = SWAP_BYTES_32(speechIndex[0]);
-	speechIndex[1] = SWAP_BYTES_32(speechIndex[1]);
-#endif
+	speechPos = fp.readUint32LE();
+	speechLength = fp.readUint32LE();
 
-	if (!speechIndex[0] || !speechIndex[1]) {
+	if (!speechPos || !speechLength) {
 		fp.close();
 		return 0;
 	}
 
 	// Create a temporary buffer for compressed speech
-	if ((data8 = (uint8 *) malloc(speechIndex[1])) == NULL) {
+	data8 = (uint8 *) malloc(speechLength);
+	if (!data8) {
 		fp.close();
 		return 0;
 	}
 
-	fp.seek(speechIndex[0], SEEK_SET);
+	fp.seek(speechPos, SEEK_SET);
 
-	if (fp.read(data8, speechIndex[1]) != speechIndex[1]) {
+	if (fp.read(data8, speechLength) != speechLength) {
 		fp.close();
 		free(data8);
 		return 0;
@@ -348,7 +342,7 @@
 
 	// Decompress data into speech buffer.
 
-	bufferSize = (speechIndex[1] - 1) * 2;
+	bufferSize = (speechLength - 1) * 2;
 
 	*buf = (uint16 *) malloc(bufferSize);
 	if (!*buf) {
@@ -361,7 +355,7 @@
 	// Starting Value
 	data16[0] = READ_LE_UINT16(data8);
 
-	for (i = 1; i < speechIndex[1] - 1; i++) {
+	for (i = 1; i < speechLength - 1; i++) {
 		if (GetCompressedSign(data8[i + 1]))
 			data16[i] = data16[i - 1] - (GetCompressedAmplitude(data8[i + 1]) << GetCompressedShift(data8[i + 1]));
 		else





More information about the Scummvm-git-logs mailing list