aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
Diffstat (limited to 'scumm')
-rw-r--r--scumm/gfx.cpp29
-rw-r--r--scumm/gfx.h2
2 files changed, 28 insertions, 3 deletions
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp
index 790faffce2..dec67688c5 100644
--- a/scumm/gfx.cpp
+++ b/scumm/gfx.cpp
@@ -1569,11 +1569,36 @@ void Gdi::drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y,
}
}
-void Gdi::copyVirtScreenBuffers(const Common::Rect &rect) {
+void Gdi::copyVirtScreenBuffers(Common::Rect rect) {
+ byte *src, *dst;
+ VirtScreen *vs = &_vm->virtscr[0];
+
+ debug(1,"copyVirtScreenBuffers: Left %d Right %d Top %d Bottom %d", rect.left, rect.right, rect.top, rect.bottom);
+
+ if (rect.top > vs->h || rect.bottom < 0)
+ return;
+
+ if (rect.left > vs->w || rect.right < 0)
+ return;
+
+ rect.left = MAX(0, (int)rect.left);
+ rect.left = MIN((int)rect.left, (int)vs->w - 1);
+
+ rect.right = MAX(0, (int)rect.right);
+ rect.right = MIN((int)rect.right, (int)vs->w);
+
+ rect.top = MAX(0, (int)rect.top);
+ rect.top = MIN((int)rect.top, (int)vs->h - 1);
+
+ rect.bottom = MAX(0, (int)rect.bottom);
+ rect.bottom = MIN((int)rect.bottom, (int)vs->h);
+
const int rw = rect.width();
const int rh = rect.height();
- byte *src, *dst;
+ if (rw == 0 || rh == 0)
+ return;
+
src = _vm->virtscr[0].getBackPixels(rect.left, rect.top);
dst = _vm->virtscr[0].getPixels(rect.left, rect.top);
diff --git a/scumm/gfx.h b/scumm/gfx.h
index 6bac0b54fa..a715d94651 100644
--- a/scumm/gfx.h
+++ b/scumm/gfx.h
@@ -279,7 +279,7 @@ public:
void drawBMAPBg(const byte *ptr, VirtScreen *vs, int startstrip);
void drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y, int w, int h);
- void copyVirtScreenBuffers(const Common::Rect &rect);
+ void copyVirtScreenBuffers(Common::Rect rect);
void disableZBuffer() { _zbufferDisabled = true; }
void enableZBuffer() { _zbufferDisabled = false; }