diff options
| author | Max Horn | 2003-05-15 23:44:46 +0000 |
|---|---|---|
| committer | Max Horn | 2003-05-15 23:44:46 +0000 |
| commit | 27c093a3a660fb259198961203d01a2694c8d414 (patch) | |
| tree | a9089bab75c79d37140be962b665500a8710942c | |
| parent | 9f6b1bf3a1fbae4497a8c68cb2aec9d3c6f819cd (diff) | |
| download | scummvm-rg350-27c093a3a660fb259198961203d01a2694c8d414.tar.gz scummvm-rg350-27c093a3a660fb259198961203d01a2694c8d414.tar.bz2 scummvm-rg350-27c093a3a660fb259198961203d01a2694c8d414.zip | |
fixed / cleaned up drawBox
svn-id: r7553
| -rw-r--r-- | scumm/script.cpp | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/scumm/script.cpp b/scumm/script.cpp index 4e7c21495e..cf909f30bd 100644 --- a/scumm/script.cpp +++ b/scumm/script.cpp @@ -498,16 +498,13 @@ int Scumm::pop() { } void Scumm::drawBox(int x, int y, int x2, int y2, int color) { - int top, bottom, count; + int width, height; VirtScreen *vs; byte *backbuff, *bgbuff; if ((vs = findVirtScreen(y)) == NULL) return; - top = vs->topline; - bottom = top + vs->height; - if (x > x2) SWAP(x, x2); @@ -517,34 +514,46 @@ void Scumm::drawBox(int x, int y, int x2, int y2, int color) { x2++; y2++; - if (x > _screenWidth - 1) - return; + // Adjust for the topline of the VirtScreen + y -= vs->topline; + y2 -= vs->topline; + + // Clip the coordinates if (x < 0) x = 0; + else if (x >= vs->width) + return; + + if (x2 < 0) + return; + else if (x2 > vs->width) + x2 = vs->width; + if (y < 0) y = 0; - if (x2 < 0) + else if (y > vs->height) return; - if (x2 > _screenWidth - 1) - x2 = _screenWidth - 1; - if (y2 > bottom - 1) - y2 = bottom - 1; - updateDirtyRect(vs->number, x, x2, y - top, y2 - top, 0); + if (y2 < 0) + return; + else if (y2 > vs->height) + y2 = vs->height; + + updateDirtyRect(vs->number, x, x2, y, y2, 0); - backbuff = vs->screenPtr + vs->xstart + (y - top) * _screenWidth + x; + backbuff = vs->screenPtr + vs->xstart + y * _screenWidth + x; + width = x2 - x; + height = y2 - y; if (color == -1) { if (vs->number != 0) error("can only copy bg to main window"); - bgbuff = getResourceAddress(rtBuffer, vs->number + 5) + vs->xstart + (y - top) * _screenWidth + x; - blit(backbuff, bgbuff, x2 - x, y2 - y); + bgbuff = getResourceAddress(rtBuffer, vs->number + 5) + vs->xstart + y * _screenWidth + x; + blit(backbuff, bgbuff, width, height); } else { - count = y2 - y; - while (count) { - memset(backbuff, color, x2 - x); + while (height--) { + memset(backbuff, color, width); backbuff += _screenWidth; - count--; } } } |
