diff options
author | Strangerke | 2015-12-10 07:04:17 +0100 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-12-23 21:33:59 +0100 |
commit | f59ceebad92a3a04ad8e22535ce45eb6b0a34d31 (patch) | |
tree | 009209ee00c302710b90723e953e027ba2085212 /engines | |
parent | e7a0e05301b0f08c0c3271d20fd24a2a4d0f2e71 (diff) | |
download | scummvm-rg350-f59ceebad92a3a04ad8e22535ce45eb6b0a34d31.tar.gz scummvm-rg350-f59ceebad92a3a04ad8e22535ce45eb6b0a34d31.tar.bz2 scummvm-rg350-f59ceebad92a3a04ad8e22535ce45eb6b0a34d31.zip |
LAB: Move readBlock to the utility class
Diffstat (limited to 'engines')
-rw-r--r-- | engines/lab/anim.cpp | 63 | ||||
-rw-r--r-- | engines/lab/anim.h | 2 | ||||
-rw-r--r-- | engines/lab/utils.cpp | 30 | ||||
-rw-r--r-- | engines/lab/utils.h | 1 |
4 files changed, 47 insertions, 49 deletions
diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp index f60c1e1be7..563b5fe597 100644 --- a/engines/lab/anim.cpp +++ b/engines/lab/anim.cpp @@ -77,11 +77,6 @@ Anim::Anim(LabEngine *vm) : _vm(vm) { _diffPalette[i] = 0; } -void Anim::readBlock(void *Buffer, uint32 Size, byte **File) { - memcpy(Buffer, *File, (size_t)Size); - (*File) += Size; -} - void Anim::diffNextFrame(bool onlyDiffData) { if (_header == 65535) // Already done. @@ -145,59 +140,58 @@ void Anim::diffNextFrame(bool onlyDiffData) { _diffFile += 4; switch (_header) { - case 8L: - readBlock(_diffPalette, _size, &_diffFile); + case 8: + _vm->_utils->readBlock(_diffPalette, _size, &_diffFile); _isPal = true; break; - case 10L: + case 10: _rawDiffBM._planes[_curBit] = _diffFile; if (onlyDiffData) _diffFile += _size; - else { - readBlock(DrawBitMap->_planes[_curBit], _size, &_diffFile); - } + else + _vm->_utils->readBlock(DrawBitMap->_planes[_curBit], _size, &_diffFile); _curBit++; break; - case 11L: + case 11: _diffFile += 4; _vm->_utils->runLengthDecode(DrawBitMap->_planes[_curBit], _diffFile); _curBit++; _diffFile += _size - 4; break; - case 12L: + case 12: _diffFile += 4; _vm->_utils->VRunLengthDecode(DrawBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow); _curBit++; _diffFile += _size - 4; break; - case 20L: + case 20: _vm->_utils->unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, false); _curBit++; _diffFile += _size; break; - case 21L: + case 21: _vm->_utils->unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, true); _curBit++; _diffFile += _size; break; - case 25L: + case 25: _curBit++; break; - case 26L: + case 26: _curBit++; break; - case 30L: - case 31L: + case 30: + case 31: if (_waitForEffect) { while (_vm->_music->isSoundEffectActive()) { _vm->_music->updateMusic(); @@ -205,8 +199,7 @@ void Anim::diffNextFrame(bool onlyDiffData) { } } - _size -= 8L; - + _size -= 8; _diffFile += 4; _sampleSpeed = READ_LE_UINT16(_diffFile); @@ -215,7 +208,8 @@ void Anim::diffNextFrame(bool onlyDiffData) { _vm->_music->playSoundEffect(_sampleSpeed, _size, _diffFile); _diffFile += _size; break; - case 65535L: + + case 65535: if ((_frameNum == 1) || _playOnce || _stopPlayingEnd) { bool didTOF = false; @@ -262,12 +256,13 @@ void Anim::stopDiff() { * Stops an animation from running. */ void Anim::stopDiffEnd() { - if (_isPlaying) { - _stopPlayingEnd = true; - while (_isPlaying) { - _vm->_music->updateMusic(); - diffNextFrame(); - } + if (!_isPlaying) + return; + + _stopPlayingEnd = true; + while (_isPlaying) { + _vm->_music->updateMusic(); + diffNextFrame(); } } @@ -276,9 +271,9 @@ void Anim::stopDiffEnd() { */ void Anim::readDiff(byte *buffer, bool playOnce, bool onlyDiffData) { _playOnce = playOnce; - _waitSec = 0L; - _waitMicros = 0L; - _delayMicros = 0L; + _waitSec = 0; + _waitMicros = 0; + _delayMicros = 0; _header = 0; _curBit = 0; _frameNum = 0; @@ -342,9 +337,8 @@ void Anim::readDiff(byte *buffer, bool playOnce, bool onlyDiffData) { if ((uint32)(_numChunks * 0x10000) < (uint32)(((int32)_diffWidth) * _diffHeight)) _numChunks++; - } else { + } else return; - } for (_header = 0; _header < 8; _header++) _rawDiffBM._planes[_header] = NULL; @@ -355,8 +349,7 @@ void Anim::readDiff(byte *buffer, bool playOnce, bool onlyDiffData) { if (_playOnce) { while (_header != 65535) diffNextFrame(onlyDiffData); - } - else + } else diffNextFrame(onlyDiffData); } diff --git a/engines/lab/anim.h b/engines/lab/anim.h index 207b3e3e8a..7669dc58da 100644 --- a/engines/lab/anim.h +++ b/engines/lab/anim.h @@ -83,8 +83,6 @@ private: uint32 _diffHeight; BitMap *DrawBitMap; - void readBlock(void *Buffer, uint32 Size, byte **File); - public: Anim(LabEngine *vm); diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp index a9429de4c2..f9a6656174 100644 --- a/engines/lab/utils.cpp +++ b/engines/lab/utils.cpp @@ -60,6 +60,21 @@ uint16 Utils::scaleY(uint16 y) { return ((y * 10) / 24); } + +uint16 Utils::mapScaleX(uint16 x) { + if (_vm->_isHiRes) + return (x - 45); + else + return ((x - 45) >> 1); +} + +uint16 Utils::mapScaleY(uint16 y) { + if (_vm->_isHiRes) + return y; + else + return ((y - 35) >> 1) - (y >> 6); +} + /** * Scales the VGA coords to SVGA if necessary; otherwise, returns VGA coords. */ @@ -422,18 +437,9 @@ uint16 Utils::getRandom(uint16 max) { return ((micros + secs) % max); } -uint16 Utils::mapScaleX(uint16 x) { - if (_vm->_isHiRes) - return (x - 45); - else - return ((x - 45) >> 1); -} - -uint16 Utils::mapScaleY(uint16 y) { - if (_vm->_isHiRes) - return y; - else - return ((y - 35) >> 1) - (y >> 6); +void Utils::readBlock(void *Buffer, uint32 Size, byte **File) { + memcpy(Buffer, *File, (size_t)Size); + (*File) += Size; } } // End of namespace Lab diff --git a/engines/lab/utils.h b/engines/lab/utils.h index ac036adf2d..ea6f378957 100644 --- a/engines/lab/utils.h +++ b/engines/lab/utils.h @@ -60,6 +60,7 @@ public: void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow); void setBytesPerRow(int num); uint16 getRandom(uint16 max); + void readBlock(void *Buffer, uint32 Size, byte **File); }; |