diff options
author | Paul Gilbert | 2015-05-12 22:02:59 -0400 |
---|---|---|
committer | Paul Gilbert | 2015-05-12 22:02:59 -0400 |
commit | 7a46c84c0d02ec3fb5aa9d607519af8fbcd2715e (patch) | |
tree | bff0492cc1fe7216ab67279594b7c8d3f26a9f21 /engines/sherlock/decompress.cpp | |
parent | 44fbef5498070ee12fddb42c067d943e56d22f0e (diff) | |
download | scummvm-rg350-7a46c84c0d02ec3fb5aa9d607519af8fbcd2715e.tar.gz scummvm-rg350-7a46c84c0d02ec3fb5aa9d607519af8fbcd2715e.tar.bz2 scummvm-rg350-7a46c84c0d02ec3fb5aa9d607519af8fbcd2715e.zip |
SHERLOCK: Beginnings of Rose Tattoo engine
Diffstat (limited to 'engines/sherlock/decompress.cpp')
-rw-r--r-- | engines/sherlock/decompress.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/engines/sherlock/decompress.cpp b/engines/sherlock/decompress.cpp index dfa573209f..8e02da3212 100644 --- a/engines/sherlock/decompress.cpp +++ b/engines/sherlock/decompress.cpp @@ -77,4 +77,52 @@ Common::SeekableReadStream *decompressLZ(Common::SeekableReadStream &source, int return outS; } + +/** + * Decompresses a Rose Tattoo resource + * +Common::SeekableReadStream *decompress32(Common::SeekableReadStream &source, int32 outSize) { + if (outSize == -1) { + outSize = source.readSint32LE(); + } + + byte lzWindow[8192]; + byte *outBuffer = new byte[outSize]; + byte *outBufferEnd = outBuffer + outSize; + Common::MemoryReadStream *outS = new Common::MemoryReadStream(outBuffer, outSize, DisposeAfterUse::YES); + + memset(lzWindow, 0xFF, 8192); + int lzWindowPos = 0xFEE; + int cmd = 0; + + do { + cmd >>= 1; + if (!(cmd & 0x100)) + cmd = source.readByte() | 0xFF00; + + if (cmd & 1) { + byte literal = source.readByte(); + *outBuffer++ = literal; + lzWindow[lzWindowPos] = literal; + lzWindowPos = (lzWindowPos + 1) & 0x0FFF; + } else { + int copyPos, copyLen; + copyPos = source.readByte(); + copyLen = source.readByte(); + copyPos = copyPos | ((copyLen & 0xF0) << 4); + copyLen = (copyLen & 0x0F) + 3; + while (copyLen--) { + byte literal = lzWindow[copyPos]; + copyPos = (copyPos + 1) & 0x0FFF; + *outBuffer++ = literal; + lzWindow[lzWindowPos] = literal; + lzWindowPos = (lzWindowPos + 1) & 0x0FFF; + } + } + } while (outBuffer < outBufferEnd); + + return outS; +} +*/ + } // namespace Sherlock |