aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/aniobject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/gob/aniobject.cpp')
-rw-r--r--engines/gob/aniobject.cpp73
1 files changed, 19 insertions, 54 deletions
diff --git a/engines/gob/aniobject.cpp b/engines/gob/aniobject.cpp
index 8d739fb3a4..8d3a6897bf 100644
--- a/engines/gob/aniobject.cpp
+++ b/engines/gob/aniobject.cpp
@@ -28,23 +28,20 @@
namespace Gob {
ANIObject::ANIObject(const ANIFile &ani) : _ani(&ani), _cmp(0),
- _visible(false), _paused(false), _mode(kModeContinuous),
- _x(0), _y(0), _background(0), _drawn(false) {
+ _visible(false), _paused(false), _mode(kModeContinuous), _x(0), _y(0) {
setAnimation(0);
setPosition();
}
ANIObject::ANIObject(const CMPFile &cmp) : _ani(0), _cmp(&cmp),
- _visible(false), _paused(false), _mode(kModeContinuous),
- _x(0), _y(0), _background(0), _drawn(false) {
+ _visible(false), _paused(false), _mode(kModeContinuous), _x(0), _y(0) {
setAnimation(0);
setPosition();
}
ANIObject::~ANIObject() {
- delete _background;
}
void ANIObject::setVisible(bool visible) {
@@ -188,46 +185,36 @@ bool ANIObject::draw(Surface &dest, int16 &left, int16 &top,
bool ANIObject::drawCMP(Surface &dest, int16 &left, int16 &top,
int16 &right, int16 &bottom) {
- if (!_background) {
+ if (!hasBuffer()) {
uint16 width, height;
_cmp->getMaxSize(width, height);
- _background = new Surface(width, height, dest.getBPP());
+ resizeBuffer(width, height);
}
- const uint16 cR = _cmp->getWidth (_animation) - 1;
- const uint16 cB = _cmp->getHeight(_animation) - 1;
+ left = _x;
+ top = _y;
+ right = _x + _cmp->getWidth (_animation) - 1;
+ bottom = _y + _cmp->getHeight(_animation) - 1;
- _backgroundLeft = CLIP<int16>( + _x, 0, dest.getWidth () - 1);
- _backgroundTop = CLIP<int16>( + _y, 0, dest.getHeight() - 1);
- _backgroundRight = CLIP<int16>(cR + _x, 0, dest.getWidth () - 1);
- _backgroundBottom = CLIP<int16>(cB + _y, 0, dest.getHeight() - 1);
-
- _background->blit(dest, _backgroundLeft , _backgroundTop,
- _backgroundRight, _backgroundBottom, 0, 0);
+ if (!saveScreen(dest, left, top, right, bottom))
+ return false;
_cmp->draw(dest, _animation, _x, _y, 0);
- _drawn = true;
-
- left = _backgroundLeft;
- top = _backgroundTop;
- right = _backgroundRight;
- bottom = _backgroundBottom;
-
return true;
}
bool ANIObject::drawANI(Surface &dest, int16 &left, int16 &top,
int16 &right, int16 &bottom) {
- if (!_background) {
+ if (!hasBuffer()) {
uint16 width, height;
_ani->getMaxSize(width, height);
- _background = new Surface(width, height, dest.getBPP());
+ resizeBuffer(width, height);
}
const ANIFile::Animation &animation = _ani->getAnimationInfo(_animation);
@@ -236,45 +223,23 @@ bool ANIObject::drawANI(Surface &dest, int16 &left, int16 &top,
const ANIFile::FrameArea &area = animation.frameAreas[_frame];
- _backgroundLeft = CLIP<int16>(area.left + _x, 0, dest.getWidth () - 1);
- _backgroundTop = CLIP<int16>(area.top + _y, 0, dest.getHeight() - 1);
- _backgroundRight = CLIP<int16>(area.right + _x, 0, dest.getWidth () - 1);
- _backgroundBottom = CLIP<int16>(area.bottom + _y, 0, dest.getHeight() - 1);
+ left = _x + area.left;
+ top = _y + area.top;
+ right = _x + area.right;
+ bottom = _y + area.bottom;
- _background->blit(dest, _backgroundLeft , _backgroundTop,
- _backgroundRight, _backgroundBottom, 0, 0);
+ if (!saveScreen(dest, left, top, right, bottom))
+ return false;
_ani->draw(dest, _animation, _frame, _x, _y);
- _drawn = true;
-
- left = _backgroundLeft;
- top = _backgroundTop;
- right = _backgroundRight;
- bottom = _backgroundBottom;
-
return true;
}
bool ANIObject::clear(Surface &dest, int16 &left, int16 &top,
int16 &right, int16 &bottom) {
- if (!_drawn)
- return false;
-
- const int16 bgRight = _backgroundRight - _backgroundLeft;
- const int16 bgBottom = _backgroundBottom - _backgroundTop;
-
- dest.blit(*_background, 0, 0, bgRight, bgBottom, _backgroundLeft, _backgroundTop);
-
- _drawn = false;
-
- left = _backgroundLeft;
- top = _backgroundTop;
- right = _backgroundRight;
- bottom = _backgroundBottom;
-
- return true;
+ return restoreScreen(dest, left, top, right, bottom);
}
void ANIObject::advance() {