diff options
author | Filippos Karapetis | 2009-03-02 22:16:44 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-03-02 22:16:44 +0000 |
commit | f31990f8978ec035c4e7c56601c3438a9a00c39b (patch) | |
tree | bfbc0fd8c9666d05ad51b03083df4b46ee93088a /engines | |
parent | 59e847dc2d2ee056f85ef7217ce63d48cd0f7235 (diff) | |
download | scummvm-rg350-f31990f8978ec035c4e7c56601c3438a9a00c39b.tar.gz scummvm-rg350-f31990f8978ec035c4e7c56601c3438a9a00c39b.tar.bz2 scummvm-rg350-f31990f8978ec035c4e7c56601c3438a9a00c39b.zip |
Gave decompression methods more descriptive names. Some cleanup
svn-id: r39082
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/scicore/decompress0.cpp | 16 | ||||
-rw-r--r-- | engines/sci/scicore/decompress01.cpp | 2 | ||||
-rw-r--r-- | engines/sci/scicore/decompress1.cpp | 37 | ||||
-rw-r--r-- | engines/sci/scicore/decompress11.cpp | 4 | ||||
-rw-r--r-- | engines/sci/scicore/resource.h | 4 |
5 files changed, 22 insertions, 41 deletions
diff --git a/engines/sci/scicore/decompress0.cpp b/engines/sci/scicore/decompress0.cpp index def3a20ea3..36129e896f 100644 --- a/engines/sci/scicore/decompress0.cpp +++ b/engines/sci/scicore/decompress0.cpp @@ -38,7 +38,7 @@ namespace Sci { //#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 @@ int decrypt1(uint8 *dest, uint8 *src, int length, int complength) { 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 @@ int decrypt1(uint8 *dest, uint8 *src, int length, int complength) { 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 @@ int decrypt1(uint8 *dest, uint8 *src, int length, int complength) { 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 @@ int decrypt1(uint8 *dest, uint8 *src, int length, int complength) { /* 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 @@ int16 getc2(uint8 *node, uint8 *src, uint16 *bytectr, uint16 *bitctr, int comple } // 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 @@ int decompress0(Resource *result, Common::ReadStream &stream, int sci_version) { 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; diff --git a/engines/sci/scicore/decompress01.cpp b/engines/sci/scicore/decompress01.cpp index dd3e140254..2a4f9d10fd 100644 --- a/engines/sci/scicore/decompress01.cpp +++ b/engines/sci/scicore/decompress01.cpp @@ -559,7 +559,7 @@ int decompress01(Resource *result, Common::ReadStream &stream, int sci_version) 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; diff --git a/engines/sci/scicore/decompress1.cpp b/engines/sci/scicore/decompress1.cpp index fa0e0abdf1..1289edde9c 100644 --- a/engines/sci/scicore/decompress1.cpp +++ b/engines/sci/scicore/decompress1.cpp @@ -137,7 +137,7 @@ static int huffman_lookup(struct bit_read_struct *inp, int *tree) { #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 @@ static int decrypt4_hdyn(byte *dest, int length, struct bit_read_struct *reader) 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 @@ int decrypt4(uint8* dest, uint8* src, int length, int complength) { reader.bytepos = 0; reader.data = src; - return -decrypt4_hdyn(dest, length, &reader); + return -unpackDCL_hdyn(dest, length, &reader); } void decryptinit3(); @@ -340,7 +340,7 @@ int decompress1(Resource *result, Common::ReadStream &stream, int sci_version) { 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 @@ int decompress1(Resource *result, Common::ReadStream &stream, int sci_version) { 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 @@ int decompress1(Resource *result, Common::ReadStream &stream, int sci_version) { 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; diff --git a/engines/sci/scicore/decompress11.cpp b/engines/sci/scicore/decompress11.cpp index d1b7cd1f73..637e7e3456 100644 --- a/engines/sci/scicore/decompress11.cpp +++ b/engines/sci/scicore/decompress11.cpp @@ -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 @@ int decompress11(Resource *result, Common::ReadStream &stream, int sci_version) 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; diff --git a/engines/sci/scicore/resource.h b/engines/sci/scicore/resource.h index abbe6a77ac..8ae8b03f4b 100644 --- a/engines/sci/scicore/resource.h +++ b/engines/sci/scicore/resource.h @@ -412,11 +412,11 @@ protected: ** 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 */ |