diff options
-rw-r--r-- | engines/zvision/rlf_animation.cpp | 30 | ||||
-rw-r--r-- | engines/zvision/rlf_animation.h | 2 |
2 files changed, 6 insertions, 26 deletions
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp index 77c1a50266..90b39dc757 100644 --- a/engines/zvision/rlf_animation.cpp +++ b/engines/zvision/rlf_animation.cpp @@ -158,34 +158,25 @@ const uint16 *RlfAnimation::getFrameData(uint frameNumber) { assert(frameNumber < _frameCount); // Since this method is so expensive, first check to see if we can use - // getNextFrame() or getPreviousFrame() since they are cheap. + // getNextFrame() it's cheap. if ((int)frameNumber == _currentFrame) { return _currentFrameBuffer; } else if (_currentFrame + 1 == (int)frameNumber) { return getNextFrame(); - } else if (_currentFrame - 1 == (int)frameNumber) { - return getPreviousFrame(); } int closestFrame = _currentFrame; - int distance = ABS(_currentFrame - (int)frameNumber); + int distance = (int)frameNumber - _currentFrame; for (Common::List<uint>::const_iterator iter = _completeFrames.begin(); iter != _completeFrames.end(); iter++) { - int newDistance = ABS((int)(*iter) - (int)frameNumber); - if (closestFrame == -1 || newDistance < distance) { + int newDistance = (int)frameNumber - (int)(*iter); + if (newDistance > 0 && (closestFrame == -1 || newDistance < distance)) { closestFrame = (*iter); distance = newDistance; } } - bool forwards = (int)frameNumber > closestFrame; - if (forwards) { - for (uint i = closestFrame; i <= frameNumber; i++) { - applyFrameToCurrent(i); - } - } else { - for (uint i = closestFrame; i >= frameNumber; i--) { - applyFrameToCurrent(i); - } + for (uint i = closestFrame; i <= frameNumber; i++) { + applyFrameToCurrent(i); } _currentFrame = frameNumber; @@ -205,15 +196,6 @@ const uint16 *RlfAnimation::getNextFrame() { return _currentFrameBuffer; } -const uint16 *RlfAnimation::getPreviousFrame() { - assert(!_stream); - assert(_currentFrame - 1 >= 0); - - applyFrameToCurrent(_currentFrame - 1); - _currentFrame--; - return _currentFrameBuffer; -} - void RlfAnimation::applyFrameToCurrent(uint frameNumber) { if (_frames[frameNumber].type == Masked) { decodeMaskedRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer, _frames[frameNumber].encodedSize, _frameBufferByteSize); diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h index d49e6a9395..5091185a36 100644 --- a/engines/zvision/rlf_animation.h +++ b/engines/zvision/rlf_animation.h @@ -74,9 +74,7 @@ public: uint32 frameTime() { return _frameTime; } const uint16 *getFrameData(uint frameNumber); - const uint16 *getNextFrame(); - const uint16 *getPreviousFrame(); bool endOfAnimation() { return _currentFrame == (int)_frameCount - 1; } |