aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sherlock/resources.cpp20
-rw-r--r--engines/sherlock/resources.h1
-rw-r--r--engines/sherlock/scene.cpp54
3 files changed, 56 insertions, 19 deletions
diff --git a/engines/sherlock/resources.cpp b/engines/sherlock/resources.cpp
index 02030119c0..9acba0ba2f 100644
--- a/engines/sherlock/resources.cpp
+++ b/engines/sherlock/resources.cpp
@@ -428,10 +428,22 @@ Common::SeekableReadStream *Resources::decompress(Common::SeekableReadStream &so
/**
* Decompress an LZW compressed resource
*/
+Common::SeekableReadStream *Resources::decompress(Common::SeekableReadStream &source, uint32 outSize) {
+ int inSize = (_vm->getGameID() == GType_RoseTattoo) ? source.readUint32LE() : -1;
+ byte *outBuffer = (byte *)malloc(outSize);
+ Common::MemoryReadStream *outStream = new Common::MemoryReadStream(outBuffer, outSize, DisposeAfterUse::YES);
+
+ decompressLZ(source, outBuffer, outSize, inSize);
+
+ return outStream;
+}
+
+/**
+ * Decompress an LZW compressed resource
+ */
void Resources::decompress(Common::SeekableReadStream &source, byte *buffer, uint32 outSize) {
- assert(_vm->getGameID() == GType_RoseTattoo);
+ int inputSize = (_vm->getGameID() == GType_RoseTattoo) ? source.readUint32LE() : -1;
- uint32 inputSize = source.readUint32LE();
decompressLZ(source, buffer, outSize, inputSize);
}
@@ -442,7 +454,7 @@ Common::SeekableReadStream *Resources::decompressLZ(Common::SeekableReadStream &
byte *outBuffer = (byte *)malloc(outSize);
Common::MemoryReadStream *outStream = new Common::MemoryReadStream(outBuffer, outSize, DisposeAfterUse::YES);
- decompressLZ(source, outSize);
+ decompressLZ(source, outBuffer, outSize, -1);
return outStream;
}
@@ -451,7 +463,7 @@ void Resources::decompressLZ(Common::SeekableReadStream &source, byte *outBuffer
uint16 lzWindowPos;
uint16 cmd;
byte *outBufferEnd = outBuffer + outSize;
- uint32 endPos = source.pos() + inSize;
+ int32 endPos = source.pos() + inSize;
memset(lzWindow, 0xFF, 0xFEE);
lzWindowPos = 0xFEE;
diff --git a/engines/sherlock/resources.h b/engines/sherlock/resources.h
index 0765ce4642..a3208520ea 100644
--- a/engines/sherlock/resources.h
+++ b/engines/sherlock/resources.h
@@ -91,6 +91,7 @@ public:
int resourceIndex() const;
Common::SeekableReadStream *decompress(Common::SeekableReadStream &source);
+ Common::SeekableReadStream *decompress(Common::SeekableReadStream &source, uint32 outSize);
void decompress(Common::SeekableReadStream &source, byte *buffer, uint32 outSize);
static void decompressLZ(Common::SeekableReadStream &source, byte *outBuffer, int32 outSize, int32 inSize);
static Common::SeekableReadStream *decompressLZ(Common::SeekableReadStream &source, uint32 outSize);
diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp
index e473217ba9..54155db4bb 100644
--- a/engines/sherlock/scene.cpp
+++ b/engines/sherlock/scene.cpp
@@ -316,28 +316,52 @@ bool Scene::loadScene(const Common::String &filename) {
bgInfo[idx].load(*rrmStream);
// Read information
- int shapeSize = _vm->getGameID() == GType_SerratedScalpel ? 569 : 591;
- Common::SeekableReadStream *infoStream = !_lzwMode ? rrmStream :
- Resources::decompressLZ(*rrmStream, bgHeader._numImages * shapeSize +
- bgHeader._descSize + bgHeader._seqSize);
+ if (_vm->getGameID() == GType_SerratedScalpel) {
+ Common::SeekableReadStream *infoStream = !_lzwMode ? rrmStream :
+ res.decompress(*rrmStream, bgHeader._numImages * 569 + bgHeader._descSize + bgHeader._seqSize);
+
+ _bgShapes.resize(bgHeader._numStructs);
+ for (int idx = 0; idx < bgHeader._numStructs; ++idx)
+ _bgShapes[idx].load(*infoStream, _vm->getGameID() == GType_RoseTattoo);
+
+ if (bgHeader._descSize) {
+ _descText.resize(bgHeader._descSize);
+ infoStream->read(&_descText[0], bgHeader._descSize);
+ }
+
+ if (bgHeader._seqSize) {
+ _sequenceBuffer.resize(bgHeader._seqSize);
+ infoStream->read(&_sequenceBuffer[0], bgHeader._seqSize);
+ }
+
+ if (_lzwMode)
+ delete infoStream;
+ } else {
+ // Load shapes
+ Common::SeekableReadStream *infoStream = !_lzwMode ? rrmStream : res.decompress(*rrmStream, bgHeader._numImages * 625);
+
+ _bgShapes.resize(bgHeader._numStructs);
+ for (int idx = 0; idx < bgHeader._numStructs; ++idx)
+ _bgShapes[idx].load(*infoStream, _vm->getGameID() == GType_RoseTattoo);
- _bgShapes.resize(bgHeader._numStructs);
- for (int idx = 0; idx < bgHeader._numStructs; ++idx)
- _bgShapes[idx].load(*infoStream, _vm->getGameID() == GType_RoseTattoo);
+ if (_lzwMode)
+ delete infoStream;
- if (bgHeader._descSize) {
+ // Load description text
_descText.resize(bgHeader._descSize);
- infoStream->read(&_descText[0], bgHeader._descSize);
- }
+ if (_lzwMode)
+ res.decompress(*rrmStream, (byte *)&_descText[0], bgHeader._descSize);
+ else
+ rrmStream->read(&_descText[0], bgHeader._descSize);
- if (bgHeader._seqSize) {
+ // Load sequences
_sequenceBuffer.resize(bgHeader._seqSize);
- infoStream->read(&_sequenceBuffer[0], bgHeader._seqSize);
+ if (_lzwMode)
+ res.decompress(*rrmStream, &_sequenceBuffer[0], bgHeader._seqSize);
+ else
+ rrmStream->read(&_sequenceBuffer[0], bgHeader._seqSize);
}
- if (_lzwMode)
- delete infoStream;
-
// Set up the list of images used by the scene
_images.resize(bgHeader._numImages + 1);
for (int idx = 0; idx < bgHeader._numImages; ++idx) {