aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorMax Horn2003-03-08 23:04:24 +0000
committerMax Horn2003-03-08 23:04:24 +0000
commitd8dc1295fbd4f1a80f7a935667bdd073e2467cd0 (patch)
treea1c4807e7c19082ce6f4377b0845293e73418254 /scumm
parentce0f95dff2d0a8673491ad9583be77dfcec4e0ec (diff)
downloadscummvm-rg350-d8dc1295fbd4f1a80f7a935667bdd073e2467cd0.tar.gz
scummvm-rg350-d8dc1295fbd4f1a80f7a935667bdd073e2467cd0.tar.bz2
scummvm-rg350-d8dc1295fbd4f1a80f7a935667bdd073e2467cd0.zip
cleanup / optimization
svn-id: r6779
Diffstat (limited to 'scumm')
-rw-r--r--scumm/bundle.cpp128
1 files changed, 61 insertions, 67 deletions
diff --git a/scumm/bundle.cpp b/scumm/bundle.cpp
index 0faf7f3f03..a7e197e4e4 100644
--- a/scumm/bundle.cpp
+++ b/scumm/bundle.cpp
@@ -24,7 +24,7 @@
#include "bundle.h"
#include "file.h"
-int16 imcTable[] = {
+const int16 imcTable[] = {
0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x0010, 0x0011,
0x0013, 0x0015, 0x0017, 0x0019, 0x001C, 0x001F, 0x0022, 0x0025, 0x0029, 0x002D,
0x0032, 0x0037, 0x003C, 0x0042, 0x0049, 0x0050, 0x0058, 0x0061, 0x006B, 0x0076,
@@ -36,57 +36,59 @@ int16 imcTable[] = {
0x3BB9, 0x41B2, 0x4844, 0x4F7E, 0x5771, 0x602F, 0x69CE, 0x7462, 0x7FFF
};
-byte imxOtherTable1[] = {
- 0xFF, 0x04, 0xFF, 0x04
-};
-
-byte imxOtherTable2[] = {
- 0xFF, 0xFF, 0x02, 0x08, 0xFF, 0xFF, 0x02, 0x08
-};
-
-byte imxOtherTable3[] = {
- 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x02, 0x04, 0x06,
- 0xFF, 0xFF, 0xFF, 0xFF, 0x01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Codec(int32 codec, byte *comp_input, byte *comp_output,
return output_size;
}
- do {
+ while (left--) {
curTableEntry = _destImcTable[curTablePos];
decompTable = curTableEntry - 2;
var3b = (1 << decompTable) << 1;
readPos = src + (tableEntrySum >> 3);
if (readPos+1 >= (comp_input+input_size)) {
- printf("Overflow!!! %d >= %d\n", (int)readPos+1, (int)comp_input+input_size);
+ warning("Overflow!!! %d >= %d", (int)readPos+1, (int)comp_input+input_size);
}
readWord = (uint16)(READ_BE_UINT16(readPos) << (tableEntrySum & 7));
otherTablePos = (byte)(readWord >> (16 - curTableEntry));
@@ -892,27 +894,19 @@ int32 Bundle::decompressCodec(int32 codec, byte *comp_input, byte *comp_output,
outputWord = -0x8000;
dst[destPos] = ((int16)outputWord) >> 8;
dst[destPos + 1] = (byte)(outputWord);
- switch (decompTable) {
- case 0: curTablePos += (signed char)imxOtherTable1[otherTablePos];
- break;
- case 1: curTablePos += (signed char)imxOtherTable2[otherTablePos];
- break;
- case 2: curTablePos += (signed char)imxOtherTable3[otherTablePos];
- break;
- case 3: curTablePos += (signed char)imxOtherTable4[otherTablePos];
- break;
- case 4: curTablePos += (signed char)imxOtherTable5[otherTablePos];
- break;
- case 5: curTablePos += (signed char)imxOtherTable6[otherTablePos];
- break;
- }
+
+ assert(decompTable < 6);
+ curTablePos += (signed char)imxOtherTable[decompTable][otherTablePos];
+
+ // Clip data
if (curTablePos > 88)
curTablePos = 88;
if (curTablePos < 0)
curTablePos = 0;
+
destPos += channels << 1;
imcTableEntry = imcTable[curTablePos];
- } while (--left != 0);
+ }
}
}
break;