diff options
author | Paul Gilbert | 2015-03-16 00:02:45 -0400 |
---|---|---|
committer | Paul Gilbert | 2015-03-16 00:02:45 -0400 |
commit | 02657f5a91bba15c7d494f71d0c975ece7178861 (patch) | |
tree | ff554df902afa8979d99fc6029b9e38ecd95cfbd | |
parent | 6cfb7169b94e0c3c665d7799584eb8e5a7f337b3 (diff) | |
download | scummvm-rg350-02657f5a91bba15c7d494f71d0c975ece7178861.tar.gz scummvm-rg350-02657f5a91bba15c7d494f71d0c975ece7178861.tar.bz2 scummvm-rg350-02657f5a91bba15c7d494f71d0c975ece7178861.zip |
SHERLOCK: Fix loading of sprite for startup animation
-rw-r--r-- | engines/sherlock/animation.cpp | 2 | ||||
-rw-r--r-- | engines/sherlock/sprite.cpp | 47 | ||||
-rw-r--r-- | engines/sherlock/sprite.h | 6 |
3 files changed, 31 insertions, 24 deletions
diff --git a/engines/sherlock/animation.cpp b/engines/sherlock/animation.cpp index 3da0201a61..4111f6f88f 100644 --- a/engines/sherlock/animation.cpp +++ b/engines/sherlock/animation.cpp @@ -91,7 +91,7 @@ void Animation::playPrologue(const Common::String &filename, int minDelay, int f // Load initial image Common::String vdaName = baseName + ".vda"; Common::SeekableReadStream *vdaStream = _vm->_res->load(vdaName); - Sprite sprite(*vdaStream); + Sprite sprite(*vdaStream, true); // TODO diff --git a/engines/sherlock/sprite.cpp b/engines/sherlock/sprite.cpp index f686f0b27e..ee7c8e5019 100644 --- a/engines/sherlock/sprite.cpp +++ b/engines/sherlock/sprite.cpp @@ -25,8 +25,8 @@ namespace Sherlock { -Sprite::Sprite(Common::SeekableReadStream &stream) { - load(stream); +Sprite::Sprite(Common::SeekableReadStream &stream, bool skipPal) { + load(stream, skipPal); } Sprite::~Sprite() { @@ -37,22 +37,26 @@ Sprite::~Sprite() { /** * Load the data of the sprite */ -void Sprite::load(Common::SeekableReadStream &stream) { - while (!stream.eos()) { +void Sprite::load(Common::SeekableReadStream &stream, bool skipPal) { + while (stream.pos() < stream.size()) { SpriteFrame frame; - frame._width = stream.readUint16LE() + 1; frame._height = stream.readUint16LE() + 1; frame._flags = stream.readUint16LE(); stream.readUint16LE(); + if (skipPal) + frame._flags = 0; + if (frame._flags & 0xFF) { + // Nibble packed frame data frame._size = (frame._width * frame._height) / 2; - } else if (frame._flags & 0x0100) { + } else if (frame._flags & RLE_ENCODED) { // this size includes the header size, which we subtract frame._size = stream.readUint16LE() - 11; frame._rleMarker = stream.readByte(); } else { + // Uncompressed data frame._size = frame._width * frame._height; } @@ -74,24 +78,25 @@ void Sprite::decompressFrame(SpriteFrame &frame, const byte *src) { if (frame._flags & 0xFF) { debug("TODO: Sprite::decompressFrame() 4-bits/pixel\n"); - } else if (frame._flags & 0x0100) { + } else if (frame._flags & RLE_ENCODED) { + // RLE encoded byte *dst = (byte *)frame._frame.getPixels(); - for (uint16 h = 0; h < frame._height; ++h) { - int16 w = frame._width; - while (w > 0) { - if (*src == frame._rleMarker) { - byte rleColor = src[1]; - byte rleCount = src[2]; - src += 3; - w -= rleCount; - while (rleCount--) - *dst++ = rleColor; - } else { - *dst++ = *src++; - w--; - } + + int size = frame._width * frame._height; + while (size > 0) { + if (*src == frame._rleMarker) { + byte rleColor = src[1]; + byte rleCount = src[2]; + src += 3; + size -= rleCount; + while (rleCount--) + *dst++ = rleColor; + } else { + *dst++ = *src++; + --size; } } + assert(size == 0); } else { // Uncompressed frame Common::copy(src, src + frame._width * frame._height, diff --git a/engines/sherlock/sprite.h b/engines/sherlock/sprite.h index 1f81cf8071..17566c81bd 100644 --- a/engines/sherlock/sprite.h +++ b/engines/sherlock/sprite.h @@ -30,6 +30,8 @@ namespace Sherlock { +enum { RLE_ENCODED = 0x0100 }; + struct SpriteFrame { uint32 _size; uint16 _width, _height; @@ -41,10 +43,10 @@ struct SpriteFrame { class Sprite: public Common::Array<SpriteFrame> { private: - void load(Common::SeekableReadStream &stream); + void load(Common::SeekableReadStream &stream, bool skipPal); void decompressFrame(SpriteFrame &frame, const byte *src); public: - Sprite(Common::SeekableReadStream &stream); + Sprite(Common::SeekableReadStream &stream, bool skipPal = false); ~Sprite(); }; |