aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2009-03-06 13:09:10 +0000
committerFilippos Karapetis2009-03-06 13:09:10 +0000
commitc4a09af0afd5a4599a45366a47a8a5f90f20f067 (patch)
tree57a07dc5eca5c021d65005adb75d77f85077c465 /engines
parentb8a2b38e4168c34813aa8ab6f3b8d371e799fbad (diff)
downloadscummvm-rg350-c4a09af0afd5a4599a45366a47a8a5f90f20f067.tar.gz
scummvm-rg350-c4a09af0afd5a4599a45366a47a8a5f90f20f067.tar.bz2
scummvm-rg350-c4a09af0afd5a4599a45366a47a8a5f90f20f067.zip
Cleanup and unification. Merged decryptinit3() inside decrypt3()
svn-id: r39155
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/scicore/decompress0.cpp8
-rw-r--r--engines/sci/scicore/decompress01.cpp12
-rw-r--r--engines/sci/scicore/decompress1.cpp2
3 files changed, 8 insertions, 14 deletions
diff --git a/engines/sci/scicore/decompress0.cpp b/engines/sci/scicore/decompress0.cpp
index 36129e896f..6aaa6fc063 100644
--- a/engines/sci/scicore/decompress0.cpp
+++ b/engines/sci/scicore/decompress0.cpp
@@ -238,19 +238,20 @@ int decompress0(Resource *result, Common::ReadStream &stream, int sci_version) {
uint16 compressedLength;
uint16 compressionMethod;
uint8 *buffer;
+ uint8 type;
result->id = stream.readUint16LE();
if (stream.err())
return SCI_ERROR_IO_ERROR;
result->number = result->id & 0x07ff;
- uint8 type = result->id >> 11;
+ type = result->id >> 11;
+
+ result->type = (ResourceType)type;
if ((result->number > sci_max_resource_nr[sci_version]) || (type > kResourceTypeInvalid))
return SCI_ERROR_DECOMPRESSION_INSANE;
- result->type = (ResourceType)type;
-
compressedLength = stream.readUint16LE();
result->size = stream.readUint16LE();
compressionMethod = stream.readUint16LE();
@@ -259,7 +260,6 @@ int decompress0(Resource *result, Common::ReadStream &stream, int sci_version) {
if (result->size > SCI_MAX_RESOURCE_SIZE)
return SCI_ERROR_RESOURCE_TOO_BIG;
- // With SCI0, this simply cannot happen.
if (compressedLength > 4)
compressedLength -= 4;
diff --git a/engines/sci/scicore/decompress01.cpp b/engines/sci/scicore/decompress01.cpp
index 2a4f9d10fd..4ef6d88abc 100644
--- a/engines/sci/scicore/decompress01.cpp
+++ b/engines/sci/scicore/decompress01.cpp
@@ -51,7 +51,8 @@ static int16 curtoken, endtoken;
uint32 gbits(int numbits, uint8 * data, int dlen);
-void decryptinit3() {
+int decrypt3(uint8 *dest, uint8 *src, int length, int complength) {
+ // Init
int i;
lastchar = lastbits = s_bitstring = stakptr = 0;
@@ -65,9 +66,9 @@ void decryptinit3() {
tokens[i].next = 0;
tokens[i].data = 0;
}
-}
-int decrypt3(uint8 *dest, uint8 *src, int length, int complength) {
+ // Start decrypting
+
static int16 token;
while (length != 0) {
switch (decryptstart) {
@@ -514,10 +515,6 @@ int decompress01(Resource *result, Common::ReadStream &stream, int sci_version)
if (stream.err())
return SCI_ERROR_IO_ERROR;
- //if ((result->size < 0) || (compressedLength < 0))
- // return SCI_ERROR_DECOMPRESSION_INSANE;
- // This return will never happen in SCI0 or SCI1 (does it have any use?)
-
if (result->size > SCI_MAX_RESOURCE_SIZE)
return SCI_ERROR_RESOURCE_TOO_BIG;
@@ -566,7 +563,6 @@ int decompress01(Resource *result, Common::ReadStream &stream, int sci_version)
case 2:
case 3:
case 4:
- decryptinit3();
if (decrypt3(result->data, buffer, result->size, compressedLength)) {
overflow = true;
} else {
diff --git a/engines/sci/scicore/decompress1.cpp b/engines/sci/scicore/decompress1.cpp
index 9bc95a05a3..06b7f05103 100644
--- a/engines/sci/scicore/decompress1.cpp
+++ b/engines/sci/scicore/decompress1.cpp
@@ -249,7 +249,6 @@ int unpackDCL(uint8* dest, uint8* src, int length, int complength) {
return 0;
}
-void decryptinit3();
int decrypt3(uint8* dest, uint8* src, int length, int complength);
int decompress1(Resource *result, Common::ReadStream &stream, int sci_version) {
@@ -349,7 +348,6 @@ int decompress1(Resource *result, Common::ReadStream &stream, int sci_version) {
case 2: // ???
case 3:
case 4:
- decryptinit3();
if (decrypt3(result->data, buffer, result->size, compressedLength)) {
free(result->data);
result->data = 0; // So that we know that it didn't work