diff options
author | Paul Gilbert | 2010-06-10 10:20:25 +0000 |
---|---|---|
committer | Paul Gilbert | 2010-06-10 10:20:25 +0000 |
commit | 4d8734284701153f10e9a2691d9b3cf5fd51e069 (patch) | |
tree | 759a5cfecdb8993e8689ab45672f25ba779ee4e2 /engines/m4 | |
parent | 8a5762c52db029386135ed7dd83f69fe5d34509c (diff) | |
download | scummvm-rg350-4d8734284701153f10e9a2691d9b3cf5fd51e069.tar.gz scummvm-rg350-4d8734284701153f10e9a2691d9b3cf5fd51e069.tar.bz2 scummvm-rg350-4d8734284701153f10e9a2691d9b3cf5fd51e069.zip |
Added extra code and support methods for properly clearing up backgrounds and used sprites when an animation sequence ends
svn-id: r49566
Diffstat (limited to 'engines/m4')
-rw-r--r-- | engines/m4/graphics.cpp | 45 | ||||
-rw-r--r-- | engines/m4/graphics.h | 1 | ||||
-rw-r--r-- | engines/m4/mads_anim.cpp | 5 | ||||
-rw-r--r-- | engines/m4/mads_views.cpp | 8 | ||||
-rw-r--r-- | engines/m4/mads_views.h | 1 |
5 files changed, 45 insertions, 15 deletions
diff --git a/engines/m4/graphics.cpp b/engines/m4/graphics.cpp index 8624f18da1..f332c8b06c 100644 --- a/engines/m4/graphics.cpp +++ b/engines/m4/graphics.cpp @@ -331,6 +331,16 @@ void M4Surface::clear() { Common::set_to((byte *)pixels, (byte *)pixels + w * h, _vm->_palette->BLACK); } +void M4Surface::reset() { + ::free(pixels); + pixels = NULL; + if (_rgbList) { + _vm->_palette->deleteRange(_rgbList); + delete _rgbList; + _rgbList = NULL; + } +} + void M4Surface::frameRect(const Common::Rect &r, uint8 color) { Graphics::Surface::frameRect(r, color); } @@ -412,6 +422,11 @@ void M4Surface::copyFrom(M4Surface *src, int destX, int destY, int depth, M4Surf if (!copyRect.isValidRect()) return; + if (scale != 100) { + destX -= (src->width() * scale / 100) / 2; + destY -= (src->height() * scale / 100); + } + // Copy the specified area byte *data = src->getBasePtr(); @@ -435,27 +450,31 @@ void M4Surface::copyFrom(M4Surface *src, int destX, int destY, int depth, M4Surf } } else { // Scaled variation - for (int rowCtr = 0; rowCtr < copyRect.height(); ++rowCtr) { - int currX = -1; + int currY = -1; + + for (int rowCtr = 0, yTotal = 0; rowCtr < copyRect.height(); ++rowCtr, yTotal += scale, + srcPtr += src->width(), depthsPtr += depthsSurface->width()) { + int srcY = yTotal / 100; + if (srcY == currY) + continue; + currY = srcY; // Loop through the source pixels - for (int xCtr = 0, xTotal = 0; xCtr < copyRect.width(); ++xCtr, xTotal += (100 - scale)) { + int currX = -1; + byte *destP = destPtr; + for (int xCtr = 0, xTotal = 0; xCtr < copyRect.width(); ++xCtr, xTotal += scale) { int srcX = xTotal / 100; + if (srcX == currX) + continue; + currX = srcX; - if (srcX != currX) { - currX = srcX; - - if ((depthsPtr[currX] > depth) && (srcPtr[xCtr] != transparentColour)) - destPtr[currX] = srcPtr[xCtr]; - } + if ((depthsPtr[currX] > depth) && (srcPtr[xCtr] != transparentColour)) + *destP++ = srcPtr[xCtr]; } - srcPtr += src->width(); - depthsPtr += depthsSurface->width(); destPtr += width(); } } - src->freeData(); depthsSurface->freeData(); } @@ -471,8 +490,6 @@ void M4Surface::loadBackgroundRiddle(const char *sceneName) { } void M4Surface::loadBackground(int sceneNumber, RGBList **palData) { - clear(); // clear previous scene - if (_vm->isM4() || (_vm->getGameType() == GType_RexNebular)) { char resourceName[20]; Common::SeekableReadStream *stream; diff --git a/engines/m4/graphics.h b/engines/m4/graphics.h index 8c4b9ac072..6901b72e87 100644 --- a/engines/m4/graphics.h +++ b/engines/m4/graphics.h @@ -154,6 +154,7 @@ public: } void freeData(); void clear(); + void reset(); void frameRect(const Common::Rect &r, uint8 color); void fillRect(const Common::Rect &r, uint8 color); void copyFrom(M4Surface *src, const Common::Rect &srcBounds, int destX, int destY, diff --git a/engines/m4/mads_anim.cpp b/engines/m4/mads_anim.cpp index e1dbbaf106..eac6d1b4aa 100644 --- a/engines/m4/mads_anim.cpp +++ b/engines/m4/mads_anim.cpp @@ -524,6 +524,11 @@ void AnimviewView::updateState() { delete _activeAnimation; _activeAnimation = NULL; + // Clear up current background and sprites + _backgroundSurface.reset(); + clearLists(); + + // Check if script is finished if (_script->eos() || _script->err()) { scriptDone(); return; diff --git a/engines/m4/mads_views.cpp b/engines/m4/mads_views.cpp index c7b4f76a00..98b04e9f2d 100644 --- a/engines/m4/mads_views.cpp +++ b/engines/m4/mads_views.cpp @@ -192,7 +192,7 @@ void MadsSpriteSlots::drawForeground(View *view, int yOffset) { assert(slot.spriteListIndex < (int)_sprites.size()); SpriteAsset &spriteSet = *_sprites[slot.spriteListIndex]; - if (slot.scale < 100) { + if ((slot.scale < 100) && (slot.scale != -1)) { // Minimalised drawing assert(slot.spriteListIndex < (int)_sprites.size()); M4Sprite *spr = spriteSet.getFrame((slot.frameNumber & 0x7fff) - 1); @@ -1222,4 +1222,10 @@ void MadsView::refresh() { _textDisplay.cleanUp(); } +void MadsView::clearLists() { + _textDisplay.clear(); + _kernelMessages.clear(); + _spriteSlots.clear(); +} + } // End of namespace M4 diff --git a/engines/m4/mads_views.h b/engines/m4/mads_views.h index 29adb7048a..85bfe9e552 100644 --- a/engines/m4/mads_views.h +++ b/engines/m4/mads_views.h @@ -404,6 +404,7 @@ public: ~MadsView(); void refresh(); + void clearLists(); }; } |