diff options
author | Filippos Karapetis | 2015-12-04 02:11:54 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-12-23 21:33:49 +0100 |
commit | d50e9f35415240c7f848a12e1a5b35a0bd314fe1 (patch) | |
tree | 33dabbd256a4830e340e95ade01a27d4a9d8bc7d /engines | |
parent | 021cb4c526b8dbe8b33b3ae03703be36893410da (diff) | |
download | scummvm-rg350-d50e9f35415240c7f848a12e1a5b35a0bd314fe1.tar.gz scummvm-rg350-d50e9f35415240c7f848a12e1a5b35a0bd314fe1.tar.bz2 scummvm-rg350-d50e9f35415240c7f848a12e1a5b35a0bd314fe1.zip |
LAB: Remove dead code
In all cases, dx and dy are always positive
Diffstat (limited to 'engines')
-rw-r--r-- | engines/lab/image.cpp | 106 | ||||
-rw-r--r-- | engines/lab/vga.cpp | 94 |
2 files changed, 48 insertions, 152 deletions
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp index 3f5801fa1c..1d8b9d61f5 100644 --- a/engines/lab/image.cpp +++ b/engines/lab/image.cpp @@ -53,32 +53,18 @@ Image::Image(Common::File *s) { /* Draws an image to the screen. */ /*****************************************************************************/ void Image::drawImage(uint16 x, uint16 y) { - int sx = 0, sy = 0; - int dx = x, dy = y; int w = _width; int h = _height; - if (dx < 0) { - sx -= dx; - w += dx; - dx = 0; - } - - if (dy < 0) { - sy -= dy; - w += dy; - dy = 0; - } - - if (dx + w > g_lab->_screenWidth) - w = g_lab->_screenWidth - dx; + if (x + w > g_lab->_screenWidth) + w = g_lab->_screenWidth - x; - if (dy + h > g_lab->_screenHeight) - h = g_lab->_screenHeight - dy; + if (y + h > g_lab->_screenHeight) + h = g_lab->_screenHeight - y; if ((w > 0) && (h > 0)) { - byte *s = _imageData + sy * _width + sx; - byte *d = g_lab->getCurrentDrawingBuffer() + dy * g_lab->_screenWidth + dx; + byte *s = _imageData; + byte *d = g_lab->getCurrentDrawingBuffer() + y * g_lab->_screenWidth + x; while (h-- > 0) { memcpy(d, s, w); @@ -92,32 +78,18 @@ void Image::drawImage(uint16 x, uint16 y) { /* Draws an image to the screen. */ /*****************************************************************************/ void Image::drawMaskImage(uint16 x, uint16 y) { - int sx = 0, sy = 0; - int dx = x, dy = y; int w = _width; int h = _height; - if (dx < 0) { - sx -= dx; - w += dx; - dx = 0; - } - - if (dy < 0) { - sy -= dy; - w += dy; - dy = 0; - } - - if (dx + w > g_lab->_screenWidth) - w = g_lab->_screenWidth - dx; + if (x + w > g_lab->_screenWidth) + w = g_lab->_screenWidth - x; - if (dy + h > g_lab->_screenHeight) - h = g_lab->_screenHeight - dy; + if (y + h > g_lab->_screenHeight) + h = g_lab->_screenHeight - y; if ((w > 0) && (h > 0)) { - byte *s = _imageData + sy * _width + sx; - byte *d = g_lab->getCurrentDrawingBuffer() + dy * g_lab->_screenWidth + dx; + byte *s = _imageData; + byte *d = g_lab->getCurrentDrawingBuffer() + y * g_lab->_screenWidth + x; while (h-- > 0) { byte *ss = s; @@ -141,32 +113,18 @@ void Image::drawMaskImage(uint16 x, uint16 y) { /* Reads an image from the screen. */ /*****************************************************************************/ void Image::readScreenImage(uint16 x, uint16 y) { - int sx = 0, sy = 0; - int dx = x, dy = y; int w = _width; int h = _height; - if (dx < 0) { - sx -= dx; - w += dx; - dx = 0; - } - - if (dy < 0) { - sy -= dy; - w += dy; - dy = 0; - } - - if (dx + w > g_lab->_screenWidth) - w = g_lab->_screenWidth - dx; + if (x + w > g_lab->_screenWidth) + w = g_lab->_screenWidth - x; - if (dy + h > g_lab->_screenHeight) - h = g_lab->_screenHeight - dy; + if (y + h > g_lab->_screenHeight) + h = g_lab->_screenHeight - y; if ((w > 0) && (h > 0)) { - byte *s = _imageData + sy * _width + sx; - byte *d = g_lab->getCurrentDrawingBuffer() + dy * g_lab->_screenWidth + dx; + byte *s = _imageData; + byte *d = g_lab->getCurrentDrawingBuffer() + y * g_lab->_screenWidth + x; while (h-- > 0) { memcpy(s, d, w); @@ -184,34 +142,18 @@ 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 sx = xs; - int sy = ys; - int dx = xd; - int dy = yd; int w = width; int h = height; - if (dx < 0) { - sx -= dx; - w += dx; - dx = 0; - } - - if (dy < 0) { - sy -= dy; - w += dy; - dy = 0; - } - - if (dx + w > imDest->_width) - w = imDest->_width - dx; + if (xd + w > imDest->_width) + w = imDest->_width - xd; - if (dy + h > imDest->_height) - h = imDest->_height - dy; + if (yd + h > imDest->_height) + h = imDest->_height - yd; if (w > 0 && h > 0) { - byte *s = _imageData + sy * _width + sx; - byte *d = imDest->_imageData + dy * imDest->_width + dx; + byte *s = _imageData + ys * _width + xs; + byte *d = imDest->_imageData + yd * imDest->_width + xd; while (h-- > 0) { memcpy(d, s, w); diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp index 0248bb823c..727914025a 100644 --- a/engines/lab/vga.cpp +++ b/engines/lab/vga.cpp @@ -144,25 +144,14 @@ void LabEngine::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y1 = temp; } - if (dx > 0) { - im._width = x2 - x1 + 1 - dx; - im._height = y2 - y1 + 1; + im._width = x2 - x1 + 1 - dx; + im._height = y2 - y1 + 1; - im.readScreenImage(x1, y1); - im.drawImage(x1 + dx, y1); + im.readScreenImage(x1, y1); + im.drawImage(x1 + dx, y1); - setAPen(0); - rectFill(x1, y1, x1 + dx - 1, y2); - } else if (dx < 0) { - im._width = x2 - x1 + 1 + dx; - im._height = y2 - y1 + 1; - - im.readScreenImage(x1 - dx, y1); - im.drawImage(x1, y1); - - setAPen(0); - rectFill(x2 + dx + 1, y1, x2, y2); - } + setAPen(0); + rectFill(x1, y1, x1 + dx - 1, y2); } /*****************************************************************************/ @@ -186,25 +175,14 @@ void LabEngine::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y1 = temp; } - if (dy > 0) { - im._width = x2 - x1 + 1; - im._height = y2 - y1 + 1 - dy; - - im.readScreenImage(x1, y1); - im.drawImage(x1, y1 + dy); + im._width = x2 - x1 + 1; + im._height = y2 - y1 + 1 - dy; - setAPen(0); - rectFill(x1, y1, x2, y1 + dy - 1); - } else if (dy < 0) { - im._width = x2 - x1 + 1; - im._height = y2 - y1 + 1 + dy; + im.readScreenImage(x1, y1); + im.drawImage(x1, y1 + dy); - im.readScreenImage(x1, y1 - dy); - im.drawImage(x1, y1); - - setAPen(0); - rectFill(x1, y2 + dy + 1, x2, y2); - } + setAPen(0); + rectFill(x1, y1, x2, y1 + dy - 1); } /*****************************************************************************/ @@ -218,29 +196,17 @@ void LabEngine::setAPen(byte pennum) { /* Fills in a rectangle. */ /*****************************************************************************/ void LabEngine::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) { - int dx = x1; - int dy = y1; int w = x2 - x1 + 1; int h = y2 - y1 + 1; - if (dx < 0) { - w += dx; - dx = 0; - } - - if (dy < 0) { - w += dy; - dy = 0; - } - - if (dx + w > _screenWidth) - w = _screenWidth - dx; + if (x1 + w > _screenWidth) + w = _screenWidth - x1; - if (dy + h > _screenHeight) - h = _screenHeight - dy; + if (y1 + h > _screenHeight) + h = _screenHeight - y1; if ((w > 0) && (h > 0)) { - char *d = (char *)getCurrentDrawingBuffer() + dy * _screenWidth + dx; + char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1; while (h-- > 0) { char *dd = d; @@ -273,35 +239,23 @@ void LabEngine::drawHLine(uint16 x1, uint16 y, uint16 x2) { /* Overlays a region on the screen using the desired pen color. */ /*****************************************************************************/ void LabEngine::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) { - int dx = x1; - int dy = y1; int w = x2 - x1 + 1; int h = y2 - y1 + 1; - if (dx < 0) { - w += dx; - dx = 0; - } - - if (dy < 0) { - w += dy; - dy = 0; - } - - if (dx + w > _screenWidth) - w = _screenWidth - dx; + if (x1 + w > _screenWidth) + w = _screenWidth - x1; - if (dy + h > _screenHeight) - h = _screenHeight - dy; + if (y1 + h > _screenHeight) + h = _screenHeight - y1; if ((w > 0) && (h > 0)) { - char *d = (char *)getCurrentDrawingBuffer() + dy * _screenWidth + dx; + char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1; while (h-- > 0) { char *dd = d; int ww = w; - if (dy & 1) { + if (y1 & 1) { dd++; ww--; } @@ -313,7 +267,7 @@ void LabEngine::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, ui } d += _screenWidth; - dy++; + y1++; } } } |