aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/lab/graphics.cpp6
-rw-r--r--engines/lab/image.cpp118
-rw-r--r--engines/lab/image.h2
-rw-r--r--engines/lab/lab.cpp2
-rw-r--r--engines/lab/special.cpp6
5 files changed, 53 insertions, 81 deletions
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 614b74431b..88b53ce3b5 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -706,7 +706,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
imDest._imageData = _vm->getCurrentDrawingBuffer();
- imSource.bltBitMap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 2);
+ imSource.blitBitmap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 2, false);
_vm->overlayRect(0, 0, curY, _vm->_screenWidth - 1, curY + 1);
curY += 4;
linesdone++;
@@ -726,9 +726,9 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
imDest._imageData = _vm->getCurrentDrawingBuffer();
if (curY == lastY)
- imSource.bltBitMap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 1);
+ imSource.blitBitmap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 1, false);
else
- imSource.bltBitMap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 2);
+ imSource.blitBitmap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 2, false);
curY += 4;
linesdone++;
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index 1d8b9d61f5..45377aceda 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -50,26 +50,48 @@ Image::Image(Common::File *s) {
}
/*****************************************************************************/
-/* Draws an image to the screen. */
+/* Blits a piece of one image to another. */
/*****************************************************************************/
-void Image::drawImage(uint16 x, uint16 y) {
- int w = _width;
- int h = _height;
+void Image::blitBitmap(uint16 xs, uint16 ys, Image *imDest,
+ uint16 xd, uint16 yd, uint16 width, uint16 height, byte masked) {
+ int w = width;
+ int h = height;
+ int destWidth = (imDest) ? imDest->_width : g_lab->_screenWidth;
+ int destHeight = (imDest) ? imDest->_height : g_lab->_screenHeight;
+ byte *destBuffer = (imDest) ? imDest->_imageData : g_lab->getCurrentDrawingBuffer();
- if (x + w > g_lab->_screenWidth)
- w = g_lab->_screenWidth - x;
+ if (xd + w > destWidth)
+ w = destWidth - xd;
- if (y + h > g_lab->_screenHeight)
- h = g_lab->_screenHeight - y;
+ if (yd + h > destHeight)
+ h = destHeight - yd;
- if ((w > 0) && (h > 0)) {
- byte *s = _imageData;
- byte *d = g_lab->getCurrentDrawingBuffer() + y * g_lab->_screenWidth + x;
+ if (w > 0 && h > 0) {
+ byte *s = _imageData + ys * _width + xs;
+ byte *d = destBuffer + yd * destWidth + xd;
- while (h-- > 0) {
- memcpy(d, s, w);
- s += _width;
- d += g_lab->_screenWidth;
+ if (!masked) {
+ while (h-- > 0) {
+ memcpy(d, s, w);
+ s += _width;
+ d += destWidth;
+ }
+ } else {
+ while (h-- > 0) {
+ byte *ss = s;
+ byte *dd = d;
+ int ww = w;
+
+ while (ww-- > 0) {
+ byte c = *ss++;
+
+ if (c) *dd++ = c - 1;
+ else dd++;
+ }
+
+ s += _width;
+ d += destWidth;
+ }
}
}
}
@@ -77,36 +99,15 @@ void Image::drawImage(uint16 x, uint16 y) {
/*****************************************************************************/
/* Draws an image to the screen. */
/*****************************************************************************/
-void Image::drawMaskImage(uint16 x, uint16 y) {
- int w = _width;
- int h = _height;
-
- if (x + w > g_lab->_screenWidth)
- w = g_lab->_screenWidth - x;
-
- if (y + h > g_lab->_screenHeight)
- h = g_lab->_screenHeight - y;
-
- if ((w > 0) && (h > 0)) {
- byte *s = _imageData;
- byte *d = g_lab->getCurrentDrawingBuffer() + y * g_lab->_screenWidth + x;
-
- while (h-- > 0) {
- byte *ss = s;
- byte *dd = d;
- int ww = w;
-
- while (ww-- > 0) {
- byte c = *ss++;
-
- if (c) *dd++ = c - 1;
- else dd++;
- }
+void Image::drawImage(uint16 x, uint16 y) {
+ blitBitmap(0, 0, NULL, x, y, _width, _height, false);
+}
- s += _width;
- d += g_lab->_screenWidth;
- }
- }
+/*****************************************************************************/
+/* Draws an image to the screen with transparency. */
+/*****************************************************************************/
+void Image::drawMaskImage(uint16 x, uint16 y) {
+ blitBitmap(0, 0, NULL, x, y, _width, _height, true);
}
/*****************************************************************************/
@@ -134,33 +135,4 @@ void Image::readScreenImage(uint16 x, uint16 y) {
}
}
-/*****************************************************************************/
-/* Blits a piece of one image to another. */
-/* NOTE: for our purposes, assumes that ImDest is to be in VGA memory. */
-/*****************************************************************************/
-void Image::bltBitMap(uint16 xs, uint16 ys, Image *imDest,
- uint16 xd, uint16 yd, uint16 width, uint16 height) {
- // I think the old code assumed that the source image data was valid for the given box.
- // I will proceed on that assumption.
- int w = width;
- int h = height;
-
- if (xd + w > imDest->_width)
- w = imDest->_width - xd;
-
- if (yd + h > imDest->_height)
- h = imDest->_height - yd;
-
- if (w > 0 && h > 0) {
- byte *s = _imageData + ys * _width + xs;
- byte *d = imDest->_imageData + yd * imDest->_width + xd;
-
- while (h-- > 0) {
- memcpy(d, s, w);
- s += _width;
- d += imDest->_width;
- }
- }
-}
-
} // End of namespace Lab
diff --git a/engines/lab/image.h b/engines/lab/image.h
index 8f4d0f844f..f443f4c1c3 100644
--- a/engines/lab/image.h
+++ b/engines/lab/image.h
@@ -46,7 +46,7 @@ public:
void drawImage(uint16 x, uint16 y);
void drawMaskImage(uint16 x, uint16 y);
void readScreenImage(uint16 x, uint16 y);
- void bltBitMap(uint16 xs, uint16 ys, Image *ImDest, uint16 xd, uint16 yd, uint16 width, uint16 height);
+ void blitBitmap(uint16 xs, uint16 ys, Image *ImDest, uint16 xd, uint16 yd, uint16 width, uint16 height, byte masked);
};
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 4a14ba63d0..2cd237c99d 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -482,7 +482,7 @@ void LabEngine::changeCombination(uint16 number) {
scrollDisplayY(2, _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), _graphics->VGAScaleX(COMBINATION_X[number]) + (Images[combnum])->_width - 1, _graphics->VGAScaleY(65) + (Images[combnum])->_height);
- Images[combnum]->bltBitMap(0, (Images[combnum])->_height - (2 * i), &(display), _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), (Images[combnum])->_width, 2);
+ Images[combnum]->blitBitmap(0, (Images[combnum])->_height - (2 * i), &(display), _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), (Images[combnum])->_width, 2, false);
}
for (uint16 i = 0; i < 6; i++)
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 855093edec..69a8aaedaf 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -273,14 +273,14 @@ static void turnPage(bool FromLeft) {
g_lab->_music->updateMusic();
g_lab->waitTOF();
ScreenImage._imageData = g_lab->getCurrentDrawingBuffer();
- JBackImage.bltBitMap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight);
+ JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight, false);
}
} else {
for (int i = (g_lab->_screenWidth - 8); i > 0; i -= 8) {
g_lab->_music->updateMusic();
g_lab->waitTOF();
ScreenImage._imageData = g_lab->getCurrentDrawingBuffer();
- JBackImage.bltBitMap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight);
+ JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight, false);
}
}
}
@@ -302,7 +302,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
ScreenImage._imageData = getCurrentDrawingBuffer();
if (wipenum == 0)
- JBackImage.bltBitMap(0, 0, &ScreenImage, 0, 0, _screenWidth, _screenHeight);
+ JBackImage.blitBitmap(0, 0, &ScreenImage, 0, 0, _screenWidth, _screenHeight, false);
else
turnPage((bool)(wipenum == 1));