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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Mon Mar 2 23:16:44 CET 2009


Revision: 39082
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39082&view=rev
Author:   thebluegr
Date:     2009-03-02 22:16:44 +0000 (Mon, 02 Mar 2009)

Log Message:
-----------
Gave decompression methods more descriptive names. Some cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/sci/scicore/decompress0.cpp
    scummvm/trunk/engines/sci/scicore/decompress01.cpp
    scummvm/trunk/engines/sci/scicore/decompress1.cpp
    scummvm/trunk/engines/sci/scicore/decompress11.cpp
    scummvm/trunk/engines/sci/scicore/resource.h

Modified: scummvm/trunk/engines/sci/scicore/decompress0.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/decompress0.cpp	2009-03-02 21:45:31 UTC (rev 39081)
+++ scummvm/trunk/engines/sci/scicore/decompress0.cpp	2009-03-02 22:16:44 UTC (rev 39082)
@@ -38,7 +38,7 @@
 //#define _SCI_DECOMPRESS_DEBUG
 
 // 9-12 bit LZW encoding
-int decrypt1(uint8 *dest, uint8 *src, int length, int complength) {
+int unpackLZW(uint8 *dest, uint8 *src, int length, int complength) {
 	// Doesn't do length checking yet
 	/* Theory: Considering the input as a bit stream, we get a series of
 	** 9 bit elements in the beginning. Every one of them is a 'token'
@@ -102,7 +102,7 @@
 				if (token > 0xff) {
 					if (token >= tokenctr) {
 #ifdef _SCI_DECOMPRESS_DEBUG
-						warning("decrypt1: Bad token %x", token);
+						warning("unpackLZW: Bad token %x", token);
 #endif
 						// Well this is really bad
 						// May be it should throw something like SCI_ERROR_DECOMPRESSION_INSANE
@@ -111,7 +111,7 @@
 						if (destctr + tokenlastlength > length) {
 #ifdef _SCI_DECOMPRESS_DEBUG
 							// For me this seems a normal situation, It's necessary to handle it
-							warning("decrypt1: Trying to write beyond the end of array(len=%d, destctr=%d, tok_len=%d)",
+							warning("unpackLZW: Trying to write beyond the end of array(len=%d, destctr=%d, tok_len=%d)",
 							       length, destctr, tokenlastlength);
 #endif
 							i = 0;
@@ -128,7 +128,7 @@
 					tokenlastlength = 1;
 					if (destctr >= length) {
 #ifdef _SCI_DECOMPRESS_DEBUG
-						warning("decrypt1: Try to write single byte beyond end of array");
+						warning("unpackLZW: Try to write single byte beyond end of array");
 #endif
 					} else
 						dest[destctr++] = (byte)token;
@@ -160,7 +160,7 @@
 /* modifications.                                                          */
 /***************************************************************************/
 
-// decrypt2 helper function
+// unpackHuffman helper function
 int16 getc2(uint8 *node, uint8 *src, uint16 *bytectr, uint16 *bitctr, int complength) {
 	uint16 next;
 
@@ -195,7 +195,7 @@
 }
 
 // Huffman token decryptor
-int decrypt2(uint8* dest, uint8* src, int length, int complength) {
+int unpackHuffman(uint8* dest, uint8* src, int length, int complength) {
 	// no complength checking atm */
 	uint8 numnodes, terminator;
 	uint8 *nodes;
@@ -299,12 +299,12 @@
 		break;
 
 	case 1: // LZW compression
-		if (decrypt1(result->data, buffer, result->size, compressedLength))
+		if (unpackLZW(result->data, buffer, result->size, compressedLength))
 			overflow = true;
 		break;
 
 	case 2: // Some sort of Huffman encoding
-		if (decrypt2(result->data, buffer, result->size, compressedLength))
+		if (unpackHuffman(result->data, buffer, result->size, compressedLength))
 			overflow = true;
 		break;
 

Modified: scummvm/trunk/engines/sci/scicore/decompress01.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/decompress01.cpp	2009-03-02 21:45:31 UTC (rev 39081)
+++ scummvm/trunk/engines/sci/scicore/decompress01.cpp	2009-03-02 22:16:44 UTC (rev 39082)
@@ -559,7 +559,7 @@
 		break;
 
 	case 1: // Some huffman encoding
-		if (decrypt2(result->data, buffer, result->size, compressedLength))
+		if (unpackHuffman(result->data, buffer, result->size, compressedLength))
 			overflow = true;
 		break;
 

Modified: scummvm/trunk/engines/sci/scicore/decompress1.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/decompress1.cpp	2009-03-02 21:45:31 UTC (rev 39081)
+++ scummvm/trunk/engines/sci/scicore/decompress1.cpp	2009-03-02 22:16:44 UTC (rev 39082)
@@ -137,7 +137,7 @@
 
 #define DCL_ASCII_MODE 1
 
-static int decrypt4_hdyn(byte *dest, int length, struct bit_read_struct *reader) {
+static int unpackDCL_hdyn(byte *dest, int length, struct bit_read_struct *reader) {
 	int mode, length_param, value, val_length, val_distance;
 	int write_pos = 0;
 
@@ -243,7 +243,7 @@
 	return 0;
 }
 
-int decrypt4(uint8* dest, uint8* src, int length, int complength) {
+int unpackDCL(uint8* dest, uint8* src, int length, int complength) {
 	struct bit_read_struct reader;
 
 	reader.length = complength;
@@ -251,7 +251,7 @@
 	reader.bytepos = 0;
 	reader.data = src;
 
-	return -decrypt4_hdyn(dest, length, &reader);
+	return -unpackDCL_hdyn(dest, length, &reader);
 }
 
 void decryptinit3();
@@ -340,7 +340,7 @@
 		break;
 
 	case 1: // LZW
-		if (decrypt2(result->data, buffer, result->size, compressedLength)) {
+		if (unpackHuffman(result->data, buffer, result->size, compressedLength)) {
 			free(result->data);
 			result->data = 0; // So that we know that it didn't work
 			result->status = SCI_STATUS_NOMALLOC;
@@ -351,30 +351,7 @@
 		break;
 
 	case 2: // ???
-		decryptinit3();
-		if (decrypt3(result->data, buffer, result->size, compressedLength)) {
-			free(result->data);
-			result->data = 0; // So that we know that it didn't work
-			result->status = SCI_STATUS_NOMALLOC;
-			free(buffer);
-			return SCI_ERROR_DECOMPRESSION_OVERFLOW;
-		}
-		result->status = SCI_STATUS_ALLOCATED;
-		break;
-
 	case 3:
-		decryptinit3();
-		if (decrypt3(result->data, buffer, result->size, compressedLength)) {
-			free(result->data);
-			result->data = 0; // So that we know that it didn't work
-			result->status = SCI_STATUS_NOMALLOC;
-			free(buffer);
-			return SCI_ERROR_DECOMPRESSION_OVERFLOW;
-		}
-		result->data = view_reorder(result->data, result->size);
-		result->status = SCI_STATUS_ALLOCATED;
-		break;
-
 	case 4:
 		decryptinit3();
 		if (decrypt3(result->data, buffer, result->size, compressedLength)) {
@@ -384,7 +361,11 @@
 			free(buffer);
 			return SCI_ERROR_DECOMPRESSION_OVERFLOW;
 		}
-		result->data = pic_reorder(result->data, result->size);
+
+		if (compressionMethod == 3)
+			result->data = view_reorder(result->data, result->size);
+		if (compressionMethod == 4)
+			result->data = pic_reorder(result->data, result->size);
 		result->status = SCI_STATUS_ALLOCATED;
 		break;
 

Modified: scummvm/trunk/engines/sci/scicore/decompress11.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/decompress11.cpp	2009-03-02 21:45:31 UTC (rev 39081)
+++ scummvm/trunk/engines/sci/scicore/decompress11.cpp	2009-03-02 22:16:44 UTC (rev 39082)
@@ -32,7 +32,7 @@
 
 namespace Sci {
 
-int decrypt4(uint8* dest, uint8* src, int length, int complength);
+int unpackDCL(uint8* dest, uint8* src, int length, int complength);
 
 int decompress11(Resource *result, Common::ReadStream &stream, int sci_version) {
 	uint16 compressedLength;
@@ -110,7 +110,7 @@
 	case 18:
 	case 19:
 	case 20:
-		if (decrypt4(result->data, buffer, result->size, compressedLength)) {
+		if (unpackDCL(result->data, buffer, result->size, compressedLength)) {
 			free(result->data);
 			result->data = 0; // So that we know that it didn't work
 			result->status = SCI_STATUS_NOMALLOC;

Modified: scummvm/trunk/engines/sci/scicore/resource.h
===================================================================
--- scummvm/trunk/engines/sci/scicore/resource.h	2009-03-02 21:45:31 UTC (rev 39081)
+++ scummvm/trunk/engines/sci/scicore/resource.h	2009-03-02 22:16:44 UTC (rev 39082)
@@ -412,11 +412,11 @@
 	**               encountered.
 	*/
 
-	int decrypt2(uint8* dest, uint8* src, int length, int complength);
+	int unpackHuffman(uint8* dest, uint8* src, int length, int complength);
 	/* Huffman token decryptor - defined in decompress0.c and used in decompress01.c
 	*/
 
-	int decrypt4(uint8* dest, uint8* src, int length, int complength);
+	int unpackDCL(uint8* dest, uint8* src, int length, int complength);
 	/* DCL inflate- implemented in decompress1.c
 	*/
 


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