aboutsummaryrefslogtreecommitdiff
path: root/engines/mads/compression.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2014-05-20 22:07:53 -0400
committerPaul Gilbert2014-05-20 22:07:53 -0400
commit876ef49a3a7596ff2d26195923d43b1a886ca065 (patch)
treeaf92529540a11927a3a5615c09927402290095cf /engines/mads/compression.cpp
parent6bfc9ce8f25d5d08e3a0aa1d5fa55e3dfe93b97f (diff)
downloadscummvm-rg350-876ef49a3a7596ff2d26195923d43b1a886ca065.tar.gz
scummvm-rg350-876ef49a3a7596ff2d26195923d43b1a886ca065.tar.bz2
scummvm-rg350-876ef49a3a7596ff2d26195923d43b1a886ca065.zip
MADS: Fix loading sprite in scene 701
Diffstat (limited to 'engines/mads/compression.cpp')
-rw-r--r--engines/mads/compression.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/engines/mads/compression.cpp b/engines/mads/compression.cpp
index 6563de51a3..de893e7b1a 100644
--- a/engines/mads/compression.cpp
+++ b/engines/mads/compression.cpp
@@ -69,18 +69,20 @@ void MadsPack::initialise(Common::SeekableReadStream *stream) {
_items[i].size = READ_LE_UINT32(header + 2);
_items[i].compressedSize = READ_LE_UINT32(header + 6);
- _items[i].data = new byte[_items[i].size];
- if (_items[i].size == _items[i].compressedSize) {
+ byte *sourceData = new byte[_items[i].compressedSize];
+ stream->read(sourceData, _items[i].compressedSize);
+
+ if (_items[i].size == _items[i].compressedSize &&
+ !FabDecompressor::isCompressed(sourceData)) {
// Entry isn't compressed
- stream->read(_items[i].data, _items[i].size);
+ _items[i].data = sourceData;
} else {
// Decompress the entry
- byte *compressedData = new byte[_items[i].compressedSize];
- stream->read(compressedData, _items[i].compressedSize);
+ _items[i].data = new byte[_items[i].size];
FabDecompressor fab;
- fab.decompress(compressedData, _items[i].compressedSize, _items[i].data, _items[i].size);
- delete[] compressedData;
+ fab.decompress(sourceData, _items[i].compressedSize, _items[i].data, _items[i].size);
+ delete[] sourceData;
}
}
@@ -96,6 +98,10 @@ MadsPack::~MadsPack() {
//--------------------------------------------------------------------------
+bool FabDecompressor::isCompressed(const byte *srcData) {
+ return strncmp((const char *)srcData, "FAB", 3) == 0;
+}
+
void FabDecompressor::decompress(const byte *srcData, int srcSize, byte *destData, int destSize) {
byte copyLen, copyOfsShift, copyOfsMask, copyLenMask;
unsigned long copyOfs;