aboutsummaryrefslogtreecommitdiff
path: root/engines/lab/anim.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/lab/anim.cpp')
-rw-r--r--engines/lab/anim.cpp315
1 files changed, 5 insertions, 310 deletions
diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 6e12e92197..777a09ef3f 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -69,317 +69,12 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
_doBlack = false;
_diffWidth = 0;
_diffHeight = 0;
- _dataBytesPerRow = 0;
DrawBitMap = &_vm->_graphics->_dispBitMap;
for (int i = 0; i < 3 * 256; i++)
_diffPalette[i] = 0;
}
-/*------------------------ unDiff Horizontal Memory -------------------------*/
-
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size */
-/* is also a byte. */
-/*****************************************************************************/
-void Anim::unDiffByteByte(byte *dest, byte *diff) {
- uint16 skip, copy;
-
- while (1) {
- skip = *diff;
- diff++;
- copy = *diff;
- diff++;
-
- if (skip == 255) {
- if (copy == 0) {
- skip = READ_LE_UINT16(diff);
- diff += 2;
- copy = READ_LE_UINT16(diff);
- diff += 2;
- } else if (copy == 255)
- return;
- }
-
- dest += skip;
- memcpy(dest, diff, copy);
- dest += copy;
- diff += copy;
- }
-}
-
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size */
-/* is a word. */
-/*****************************************************************************/
-void Anim::unDiffByteWord(uint16 *dest, uint16 *diff) {
- uint16 skip, copy;
-
- while (1) {
- skip = ((byte *)diff)[0];
- copy = ((byte *)diff)[1];
-
- diff++;
-
- if (skip == 255) {
- if (copy == 0) {
- skip = READ_LE_UINT16(diff);
- diff++;
- copy = READ_LE_UINT16(diff);
- diff++;
- } else if (copy == 255)
- return;
- }
-
- dest += skip;
-
- while (copy > 3) {
- *dest = READ_LE_UINT16(diff);
- dest++;
- diff++;
-
- *dest = READ_LE_UINT16(diff);
- dest++;
- diff++;
-
- *dest = READ_LE_UINT16(diff);
- dest++;
- diff++;
-
- *dest = READ_LE_UINT16(diff);
- dest++;
- diff++;
-
- copy -= 4;
- }
-
- while (copy) {
- *dest = READ_LE_UINT16(diff);
- dest++;
- diff++;
- copy--;
- }
- }
-}
-
-/*------------------------- unDiff Vertical Memory --------------------------*/
-
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size */
-/* is a byte. */
-/*****************************************************************************/
-void Anim::VUnDiffByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
- byte *curPtr;
- uint16 skip, copy;
- uint16 counter = 0;
-
-
- while (counter < _dataBytesPerRow) {
- curPtr = dest + counter;
-
- for (;;) {
- skip = *diff;
- diff++;
- copy = *diff;
- diff++;
-
- if (skip == 255) {
- counter += copy;
- break;
- }
-
- else {
- curPtr += (skip * bytesPerRow);
-
- while (copy) {
- copy--;
- *curPtr = *diff;
- curPtr += bytesPerRow;
- diff++;
- }
- }
- }
- }
-}
-
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size */
-/* is a word. */
-/*****************************************************************************/
-void Anim::VUnDiffByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
- uint16 *curPtr;
- uint16 skip, copy;
- uint16 counter = 0;
-
- uint16 wordsPerRow = bytesPerRow / 2;
-
- while (counter < (_dataBytesPerRow >> 1)) {
- curPtr = dest + counter;
-
- for (;;) {
- skip = ((byte *)diff)[0];
- copy = ((byte *)diff)[1];
-
- diff++;
-
-
- if (skip == 255) {
- counter += copy;
- break;
- }
-
- else {
- curPtr += (skip * wordsPerRow);
-
- while (copy) {
- *curPtr = *diff; //swapUShort(*diff);
- curPtr += wordsPerRow;
- diff++;
- copy--;
- }
- }
- }
- }
-}
-
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size */
-/* is a long. */
-/*****************************************************************************/
-void Anim::VUnDiffByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow) {
- uint32 *_curPtr;
- uint16 skip, copy;
-
- uint16 counter = 0;
- byte *diff1 = (byte *)diff;
-
- uint16 longsperrow = bytesPerRow / 4;
-
- while (counter < (_dataBytesPerRow >> 2)) {
- _curPtr = dest + counter;
-
- for (;;) {
- skip = *diff1;
- diff1++;
-
- copy = *diff1;
- diff1++;
-
-
- if (skip == 255) {
- counter += copy;
- break;
- }
-
- else {
- _curPtr += (skip * longsperrow);
-
- while (copy) {
- *_curPtr = *(uint32 *)diff1; //swapULong(*diff);
- _curPtr += longsperrow;
- diff1 += 4;
- copy--;
- }
- }
- }
- }
-}
-
-/*****************************************************************************/
-/* Runlength decodes a chunk of memory. */
-/*****************************************************************************/
-void Anim::runLengthDecode(byte *dest, byte *source) {
- int8 num;
- int16 count;
-
- while (1) {
- num = (int8)*source;
- source++;
-
- if (num == 127) {
- return;
- } else if (num > '\0') {
- memcpy(dest, source, num);
- source += num;
- dest += num;
- } else {
- count = (int16)(-num);
- num = *source;
- source++;
-
- while (count) {
- *dest = num;
- dest++;
- count--;
- }
- }
- }
-}
-
-/*****************************************************************************/
-/* Does a vertical run length decode. */
-/*****************************************************************************/
-void Anim::VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow) {
- int8 num;
- int16 count;
- byte *top = dest;
-
- for (uint16 i = 0; i < _dataBytesPerRow; i++) {
- dest = top;
- dest += i;
-
- num = (int8)*source;
- source++;
-
- while (num != 127) {
- if (num > '\0') {
- while (num) {
- *dest = *source;
- source++;
- dest += bytesPerRow;
- num--;
- }
- } else {
- count = (int16)(-num);
- num = (int8)*source;
- source++;
-
- while (count) {
- *dest = num;
- dest += bytesPerRow;
- count--;
- }
- }
-
- num = *source;
- source++;
- }
- }
-}
-
-/*****************************************************************************/
-/* Does the undiffing between the bitmaps. */
-/*****************************************************************************/
-void Anim::unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesPerRow, bool isV) {
- diffData++;
- byte bufType = *diffData;
- diffData++;
-
- if (isV) {
- if (bufType == 0)
- VUnDiffByteByte(newBuf, diffData, bytesPerRow);
- else if (bufType == 1)
- VUnDiffByteWord((uint16 *)newBuf, (uint16 *)diffData, bytesPerRow);
- else if (bufType == 3)
- VUnDiffByteLong((uint32 *)newBuf, (uint32 *)diffData, bytesPerRow);
- } else {
- if (bufType == 0)
- unDiffByteByte(newBuf, diffData);
- else if (bufType == 1)
- unDiffByteWord((uint16 *)newBuf, (uint16 *)diffData);
- }
-}
-
void Anim::readBlock(void *Buffer, uint32 Size, byte **File) {
memcpy(Buffer, *File, (size_t)Size);
(*File) += Size;
@@ -465,26 +160,26 @@ void Anim::diffNextFrame() {
case 11L:
_diffFile += 4;
- runLengthDecode(DrawBitMap->_planes[_curBit], _diffFile);
+ _vm->_utils->runLengthDecode(DrawBitMap->_planes[_curBit], _diffFile);
_curBit++;
_diffFile += _size - 4;
break;
case 12L:
_diffFile += 4;
- VRunLengthDecode(DrawBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow);
+ _vm->_utils->VRunLengthDecode(DrawBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow);
_curBit++;
_diffFile += _size - 4;
break;
case 20L:
- unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap._planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, false);
+ _vm->_utils->unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap._planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, false);
_curBit++;
_diffFile += _size;
break;
case 21L:
- unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap._planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, true);
+ _vm->_utils->unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap._planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, true);
_curBit++;
_diffFile += _size;
break;
@@ -615,7 +310,7 @@ void Anim::playDiff(byte *buffer) {
_continuous = CONTINUOUS & _headerdata._flags;
_diffWidth = _headerdata._width;
_diffHeight = _headerdata._height;
- _dataBytesPerRow = _diffWidth;
+ _vm->_utils->setBytesPerRow(_diffWidth);
_numChunks = (((int32) _diffWidth) * _diffHeight) / 0x10000;