aboutsummaryrefslogtreecommitdiff
path: root/engines/cge2/vga13h.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2014-06-13 23:22:44 -0400
committerPaul Gilbert2014-06-13 23:22:44 -0400
commit28717ff056015d3aafdb1c91b7535cdc82a235cf (patch)
tree90f757ff6bda08519e98712e8f03fdc0a1b8bda8 /engines/cge2/vga13h.cpp
parenta2c3a11708840f7b21d971241ad2b1fa70d74025 (diff)
downloadscummvm-rg350-28717ff056015d3aafdb1c91b7535cdc82a235cf.tar.gz
scummvm-rg350-28717ff056015d3aafdb1c91b7535cdc82a235cf.tar.bz2
scummvm-rg350-28717ff056015d3aafdb1c91b7535cdc82a235cf.zip
CGE2: Fix vertical screen clipping in Bitmap::show and Bitmap::hide
Diffstat (limited to 'engines/cge2/vga13h.cpp')
-rw-r--r--engines/cge2/vga13h.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/engines/cge2/vga13h.cpp b/engines/cge2/vga13h.cpp
index 71e472f766..302d12938f 100644
--- a/engines/cge2/vga13h.cpp
+++ b/engines/cge2/vga13h.cpp
@@ -1064,8 +1064,11 @@ void Bitmap::show(int16 x, int16 y) {
xLatPos(pos);
x = pos.x;
y = pos.y;
+
+ // TODO: This doesn't currently support left/right side clipping
const byte *srcP = (const byte *)_v;
- byte *destEndP = (byte *)_vm->_vga->_page[1]->getBasePtr(0, kScrHeight);
+ byte *screenStartP = (byte *)_vm->_vga->_page[1]->getPixels();
+ byte *screenEndP = (byte *)_vm->_vga->_page[1]->getBasePtr(0, kScrHeight);
// Loop through processing data for each plane. The game originally ran in plane mapped mode, where a
// given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data
@@ -1084,8 +1087,6 @@ void Bitmap::show(int16 x, int16 y) {
break;
}
- assert(destP < destEndP);
-
// Handle a set of pixels
while (count-- > 0) {
// Transfer operation
@@ -1095,11 +1096,14 @@ void Bitmap::show(int16 x, int16 y) {
break;
case 2:
// REPEAT
- *destP = *srcP;
+ if (destP >= screenStartP && destP < screenEndP)
+ *destP = *srcP;
break;
case 3:
// COPY
- *destP = *srcP++;
+ if (destP >= screenStartP && destP < screenEndP)
+ *destP = *srcP;
+ srcP++;
break;
}
@@ -1120,10 +1124,12 @@ void Bitmap::hide(int16 x, int16 y) {
x = pos.x;
y = pos.y;
for (int yp = y; yp < y + _h; yp++) {
- const byte *srcP = (const byte *)_vm->_vga->_page[2]->getBasePtr(x, yp);
- byte *destP = (byte *)_vm->_vga->_page[1]->getBasePtr(x, yp);
+ if (yp >= 0 && yp < kScrHeight) {
+ const byte *srcP = (const byte *)_vm->_vga->_page[2]->getBasePtr(x, yp);
+ byte *destP = (byte *)_vm->_vga->_page[1]->getBasePtr(x, yp);
- Common::copy(srcP, srcP + _w, destP);
+ Common::copy(srcP, srcP + _w, destP);
+ }
}
}