aboutsummaryrefslogtreecommitdiff
path: root/engines/toon/anim.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/toon/anim.cpp')
-rw-r--r--engines/toon/anim.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/engines/toon/anim.cpp b/engines/toon/anim.cpp
index 2e63d89f37..856acbd986 100644
--- a/engines/toon/anim.cpp
+++ b/engines/toon/anim.cpp
@@ -23,6 +23,9 @@
*
*/
+#include "common/debug.h"
+#include "common/rect.h"
+
#include "toon/anim.h"
#include "toon/toon.h"
#include "toon/tools.h"
@@ -99,7 +102,7 @@ bool Animation::loadAnimation(Common::String file) {
_frames[e]._data = new uint8[decompressedSize];
if (compressedSize < decompressedSize) {
decompressLZSS(imageData, _frames[e]._data, decompressedSize);
- } else {
+ } else {
memcpy(_frames[e]._data, imageData, compressedSize);
}
}
@@ -151,6 +154,8 @@ void Animation::drawFrame(Graphics::Surface &surface, int32 frame, int32 xx, int
int32 offsX = 0;
int32 offsY = 0;
+ _vm->addDirtyRect(xx + _x1 + _frames[frame]._x1, yy + _y1 + _frames[frame]._y1, xx + rectX + _x1 + _frames[frame]._x1 , yy + rectY + _y1 + _frames[frame]._y1);
+
if (xx + _x1 + _frames[frame]._x1 < 0) {
offsX = -(xx + _x1 + _frames[frame]._x1);
}
@@ -212,14 +217,14 @@ void Animation::drawFrameWithMaskAndScale(Graphics::Surface &surface, int32 fram
int32 finalWidth = rectX * scale / 1024;
int32 finalHeight = rectY * scale / 1024;
- // compute final x1,y1,x2,y2
+ // compute final x1, y1, x2, y2
int32 xx1 = xx + _x1 + _frames[frame]._x1 * scale / 1024;
int32 yy1 = yy + _y1 + _frames[frame]._y1 * scale / 1024;
int32 xx2 = xx1 + finalWidth;
int32 yy2 = yy1 + finalHeight;
int32 w = _frames[frame]._x2 - _frames[frame]._x1;
-// Strangerke - Commented (not used)
-// int32 h = _frames[frame]._y2 - _frames[frame]._y1;
+
+ _vm->addDirtyRect(xx1, yy1, xx2, yy2);
int32 destPitch = surface.pitch;
int32 destPitchMask = mask->getWidth();
@@ -442,7 +447,6 @@ AnimationInstance::AnimationInstance(ToonEngine *vm, AnimationInstanceType type)
_layerZ = 0;
}
-
void AnimationInstance::render() {
debugC(5, kDebugAnim, "render()");
if (_visible && _animation) {
@@ -574,7 +578,7 @@ void AnimationInstance::getRect(int32 *x1, int32 *y1, int32 *x2, int32 *y2) cons
int32 finalWidth = rectX * _scale / 1024;
int32 finalHeight = rectY * _scale / 1024;
- // compute final x1,y1,x2,y2
+ // compute final x1, y1, x2, y2
*x1 = _x + _animation->_x1 + _animation->_frames[_currentFrame]._x1 * _scale / 1024;
*y1 = _y + _animation->_y1 + _animation->_frames[_currentFrame]._y1 * _scale / 1024;
*x2 = *x1 + finalWidth;
@@ -604,7 +608,7 @@ void AnimationInstance::setZ(int32 z, bool relative) {
void AnimationInstance::setLayerZ(int32 z) {
_layerZ = z;
- if (_vm->getAnimationManager()->hasInstance(this))
+ if (_vm->getAnimationManager()->hasInstance(this))
_vm->getAnimationManager()->updateInstance(this);
}
@@ -665,8 +669,6 @@ void AnimationInstance::load(Common::ReadStream *stream) {
_useMask = stream->readSint32LE();
}
-
-
void AnimationInstance::setLooping(bool enable) {
debugC(6, kDebugAnim, "setLooping(%d)", (enable) ? 1 : 0);
_looping = enable;
@@ -682,7 +684,7 @@ AnimationManager::AnimationManager(ToonEngine *vm) : _vm(vm) {
bool AnimationManager::hasInstance(AnimationInstance* instance) {
for (uint32 i = 0; i < _instances.size(); i++) {
- if(_instances[i] == instance)
+ if(_instances[i] == instance)
return true;
}
return false;
@@ -698,12 +700,12 @@ void AnimationManager::addInstance(AnimationInstance *instance) {
// if the instance already exists, we skip the add
for (uint32 i = 0; i < _instances.size(); i++) {
- if(_instances[i] == instance)
+ if(_instances[i] == instance)
return;
}
-
+
int found = -1;
-
+
// here we now do an ordered insert (closer to the original game)
for (uint32 i = 0; i < _instances.size(); i++) {
if (_instances[i]->getLayerZ() >= instance->getLayerZ()) {
@@ -717,7 +719,6 @@ void AnimationManager::addInstance(AnimationInstance *instance) {
} else {
_instances.insert_at(found, instance);
}
-
}
void AnimationManager::removeInstance(AnimationInstance *instance) {