mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-03 16:58:26 +00:00
Added extra code and support methods for properly clearing up backgrounds and used sprites when an animation sequence ends
svn-id: r49566
This commit is contained in:
parent
8a5762c52d
commit
4d87342847
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -404,6 +404,7 @@ public:
|
||||
~MadsView();
|
||||
|
||||
void refresh();
|
||||
void clearLists();
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user