diff options
author | Kari Salminen | 2008-06-10 21:34:26 +0000 |
---|---|---|
committer | Kari Salminen | 2008-06-10 21:34:26 +0000 |
commit | 420d29932b31457eb840e19979abea35bc96770c (patch) | |
tree | ebaa38b390a8f0c138208dc7d5bd6aa72c4dfe26 /engines | |
parent | 7453cf8b0b297b8a8e5b0dec13405ccc924abf8b (diff) | |
download | scummvm-rg350-420d29932b31457eb840e19979abea35bc96770c.tar.gz scummvm-rg350-420d29932b31457eb840e19979abea35bc96770c.tar.bz2 scummvm-rg350-420d29932b31457eb840e19979abea35bc96770c.zip |
unpackerHelper2(numBits) -> copyRelocatesBytes(offset, numBytes) and some revising of the unpacking routine.
svn-id: r32653
Diffstat (limited to 'engines')
-rw-r--r-- | engines/cine/unpack.cpp | 30 | ||||
-rw-r--r-- | engines/cine/unpack.h | 4 |
2 files changed, 17 insertions, 17 deletions
diff --git a/engines/cine/unpack.cpp b/engines/cine/unpack.cpp index 85841631af..01cbe5476c 100644 --- a/engines/cine/unpack.cpp +++ b/engines/cine/unpack.cpp @@ -73,12 +73,10 @@ void CineUnpacker::unpackHelper1(byte numBits, byte addCount) { } } -void CineUnpacker::unpackHelper2(byte numBits) { - uint16 i = getBits(numBits); - uint16 count = _size + 1; - _datasize -= count; - while (count--) { - *_dst = *(_dst + i); +void CineUnpacker::copyRelocatedBytes(uint16 offset, uint16 numBytes) { + _datasize -= numBytes; + while (numBytes--) { + *_dst = *(_dst + offset); --_dst; } } @@ -87,28 +85,30 @@ bool CineUnpacker::unpack(byte *dst, const byte *src, int srcLen) { _src = src + srcLen - 4; _datasize = readSource(); _dst = dst + _datasize - 1; - _size = 0; _crc = readSource(); _chk = readSource(); _crc ^= _chk; do { if (!nextBit()) { - _size = 1; if (!nextBit()) { unpackHelper1(3, 0); } else { - unpackHelper2(8); + uint16 numBytes = 2; + uint16 offset = getBits(8); + copyRelocatedBytes(offset, numBytes); } } else { uint16 c = getBits(2); if (c == 3) { unpackHelper1(8, 8); - } else if (c < 2) { - _size = c + 2; - unpackHelper2(c + 9); - } else { - _size = getBits(8); - unpackHelper2(12); + } else if (c < 2) { // c == 0 || c == 1 + uint16 numBytes = c + 3; + uint16 offset = getBits(c + 9); + copyRelocatedBytes(offset, numBytes); + } else { // c == 2 + uint16 numBytes = getBits(8) + 1; + uint16 offset = getBits(12); + copyRelocatedBytes(offset, numBytes); } } } while (_datasize > 0 && _src >= src - 4); diff --git a/engines/cine/unpack.h b/engines/cine/unpack.h index bd658e51e6..39a7aca8e5 100644 --- a/engines/cine/unpack.h +++ b/engines/cine/unpack.h @@ -42,9 +42,9 @@ private: int nextBit(); uint16 getBits(byte numBits); void unpackHelper1(byte numBits, byte addCount); - void unpackHelper2(byte numBits); + void copyRelocatedBytes(uint16 offset, uint16 numBytes); private: - int _size, _datasize; + int _datasize; uint32 _crc; uint32 _chk; byte *_dst; |