aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/driver_vga.cpp
diff options
context:
space:
mode:
authorSven Hesse2008-05-26 21:07:49 +0000
committerSven Hesse2008-05-26 21:07:49 +0000
commit9eed36cc4f8877fa5dbb2e4053112adba327d6bf (patch)
treea21cb07719885e710c7b399525f8b3f111e6be2a /engines/gob/driver_vga.cpp
parentc13fda76d6245d39aef10283624566a6e2f40344 (diff)
downloadscummvm-rg350-9eed36cc4f8877fa5dbb2e4053112adba327d6bf.tar.gz
scummvm-rg350-9eed36cc4f8877fa5dbb2e4053112adba327d6bf.tar.bz2
scummvm-rg350-9eed36cc4f8877fa5dbb2e4053112adba327d6bf.zip
Use memmove when source and destination sprite areas overlap in drawSprite()
svn-id: r32305
Diffstat (limited to 'engines/gob/driver_vga.cpp')
-rw-r--r--engines/gob/driver_vga.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/engines/gob/driver_vga.cpp b/engines/gob/driver_vga.cpp
index c4861ca146..f68ce47783 100644
--- a/engines/gob/driver_vga.cpp
+++ b/engines/gob/driver_vga.cpp
@@ -109,10 +109,16 @@ void VGAVideoDriver::drawSprite(SurfaceDesc *source, SurfaceDesc *dest,
int16 width = MIN((right - left) + 1, (int) dest->getWidth());
int16 height = MIN((bottom - top) + 1, (int) dest->getHeight());
+ if ((width < 1) || (height < 1))
+ return;
+
byte *srcPos = source->getVidMem() + (top * source->getWidth()) + left;
byte *destPos = dest->getVidMem() + (y * dest->getWidth()) + x;
+ uint32 size = width * height;
+
if (transp) {
+
while (height--) {
for (int16 i = 0; i < width; ++i) {
if (srcPos[i])
@@ -122,13 +128,26 @@ void VGAVideoDriver::drawSprite(SurfaceDesc *source, SurfaceDesc *dest,
srcPos += source->getWidth();
destPos += dest->getWidth();
}
+
+ } else if (((srcPos >= destPos) && (srcPos <= (destPos + size))) ||
+ ((destPos >= srcPos) && (destPos <= (srcPos + size)))) {
+
+ while (height--) {
+ memmove(destPos, srcPos, width);
+
+ srcPos += source->getWidth();
+ destPos += dest->getWidth();
+ }
+
} else {
+
while (height--) {
memcpy(destPos, srcPos, width);
srcPos += source->getWidth();
destPos += dest->getWidth();
}
+
}
}