diff options
-rw-r--r-- | scumm/akos.cpp | 162 | ||||
-rw-r--r-- | scumm/bomp.cpp | 50 | ||||
-rw-r--r-- | scumm/charset.cpp | 28 | ||||
-rw-r--r-- | scumm/costume.cpp | 67 | ||||
-rw-r--r-- | scumm/gfx.cpp | 14 | ||||
-rw-r--r-- | scumm/gfx.h | 3 | ||||
-rw-r--r-- | scumm/object.cpp | 49 | ||||
-rw-r--r-- | scumm/script_v8.cpp | 9 |
8 files changed, 189 insertions, 193 deletions
diff --git a/scumm/akos.cpp b/scumm/akos.cpp index c47c1a9fd0..03e4fcd436 100644 --- a/scumm/akos.cpp +++ b/scumm/akos.cpp @@ -536,8 +536,8 @@ byte AkosRenderer::codec1(int xmoveCur, int ymoveCur) { bool use_scaling; int i, j; int skip = 0, startScaleIndexX, startScaleIndexY; - int cur_x, x_right, x_left; - int cur_y, y_top, y_bottom; + Common::Rect rect; + int cur_x, cur_y; int step; byte drawFlag = 1; @@ -586,16 +586,16 @@ byte AkosRenderer::codec1(int xmoveCur, int ymoveCur) { cur_x -= v1.scaleXstep; } - x_left = x_right = cur_x; + rect.left = rect.right = cur_x; j = startScaleIndexX; for (i = 0, skip = 0; i < _width; i++) { - if (x_right < 0) { + if (rect.right < 0) { skip++; startScaleIndexX = j; } if (v1.scaletable[j++] < _scaleX) - x_right++; + rect.right++; } } else { /* No mirror */ @@ -607,16 +607,16 @@ byte AkosRenderer::codec1(int xmoveCur, int ymoveCur) { cur_x += v1.scaleXstep; } - x_left = x_right = cur_x; + rect.left = rect.right = cur_x; j = startScaleIndexX; for (i = 0, skip = 0; i < _width; i++) { - if (x_left >= (int)_outwidth) { + if (rect.left >= (int)_outwidth) { startScaleIndexX = j; skip++; } if (v1.scaletable[j--] < _scaleX) - x_left--; + rect.left--; } } @@ -635,11 +635,11 @@ byte AkosRenderer::codec1(int xmoveCur, int ymoveCur) { cur_y -= step; } - y_top = y_bottom = cur_y; + rect.top = rect.bottom = cur_y; startScaleIndexY = 0x180 - ymoveCur; for (i = 0; i < _height; i++) { if (v1.scaletable[startScaleIndexY++] < _scaleY) - y_bottom++; + rect.bottom++; } startScaleIndexY = 0x180 - ymoveCur; @@ -651,15 +651,15 @@ byte AkosRenderer::codec1(int xmoveCur, int ymoveCur) { cur_y += ymoveCur; if (_mirror) { - x_left = cur_x; - x_right = cur_x + _width; + rect.left = cur_x; + rect.right = cur_x + _width; } else { - x_right = cur_x; - x_left = cur_x - _width; + rect.right = cur_x; + rect.left = cur_x - _width; } - y_top = cur_y; - y_bottom = cur_y + _height; + rect.top = cur_y; + rect.bottom = cur_y + _height; startScaleIndexX = 0x180; startScaleIndexY = 0x180; @@ -671,15 +671,15 @@ byte AkosRenderer::codec1(int xmoveCur, int ymoveCur) { v1.scaleXstep = _mirror ? 1 : -1; if (_actorHitMode) { - if (_actorHitX < x_left || _actorHitX >= x_right || _actorHitY < y_top || _actorHitY >= y_bottom) + if (_actorHitX < rect.left || _actorHitX >= rect.right || _actorHitY < rect.top || _actorHitY >= rect.bottom) return 0; } else - _vm->markRectAsDirty(kMainVirtScreen, x_left, x_right, y_top, y_bottom, _actorID); + _vm->markRectAsDirty(kMainVirtScreen, rect.left, rect.right, rect.top, rect.bottom, _actorID); - if (y_top >= (int)_outheight || y_bottom <= 0) + if (rect.top >= (int)_outheight || rect.bottom <= 0) return 0; - if (x_left >= (int)_outwidth || x_right <= 0) + if (rect.left >= (int)_outwidth || rect.right <= 0) return 0; v1.replen = 0; @@ -692,7 +692,7 @@ byte AkosRenderer::codec1(int xmoveCur, int ymoveCur) { codec1_ignorePakCols(skip); cur_x = 0; } else { - skip = x_right - _outwidth; + skip = rect.right - _outwidth; if (skip <= 0) { drawFlag = 2; } else { @@ -701,13 +701,13 @@ byte AkosRenderer::codec1(int xmoveCur, int ymoveCur) { } } else { if (!use_scaling) - skip = x_right - _outwidth + 1; + skip = rect.right - _outwidth + 1; if (skip > 0) { v1.skip_width -= skip; codec1_ignorePakCols(skip); cur_x = _outwidth - 1; } else { - skip = -1 - x_left; + skip = -1 - rect.left; if (skip <= 0) { drawFlag = 2; } else { @@ -722,16 +722,16 @@ byte AkosRenderer::codec1(int xmoveCur, int ymoveCur) { if (v1.skip_width <= 0 || _height <= 0) return 0; - if ((uint) y_top > _outheight) - y_top = 0; + if ((uint) rect.top > _outheight) + rect.top = 0; - if ((uint) y_bottom > _outheight) - y_bottom = _outheight; + if ((uint) rect.bottom > _outheight) + rect.bottom = _outheight; - if (_draw_top > y_top) - _draw_top = y_top; - if (_draw_bottom < y_bottom) - _draw_bottom = y_bottom; + if (_draw_top > rect.top) + _draw_top = rect.top; + if (_draw_bottom < rect.bottom) + _draw_bottom = rect.bottom; v1.destptr = _outptr + v1.y * _outwidth + v1.x; @@ -745,7 +745,8 @@ byte AkosRenderer::codec1(int xmoveCur, int ymoveCur) { byte AkosRenderer::codec5(int xmoveCur, int ymoveCur) { - int32 clip_left, clip_right, clip_top, clip_bottom, maxw, maxh; + Common::Rect clip; + int32 maxw, maxh; if (_actorHitMode) { warning("codec5: _actorHitMode not yet implemented"); @@ -753,42 +754,42 @@ byte AkosRenderer::codec5(int xmoveCur, int ymoveCur) { } if (!_mirror) { - clip_left = (_actorX - xmoveCur - _width) + 1; + clip.left = (_actorX - xmoveCur - _width) + 1; } else { - clip_left = _actorX + xmoveCur - 1; + clip.left = _actorX + xmoveCur - 1; } - clip_top = _actorY + ymoveCur; - clip_right = (clip_left + _width) - 1; - clip_bottom = (clip_top + _height) - 1; + clip.top = _actorY + ymoveCur; + clip.right = (clip.left + _width) - 1; + clip.bottom = (clip.top + _height) - 1; maxw = _outwidth - 1; maxh = _outheight - 1; - _vm->markRectAsDirty(kMainVirtScreen, clip_left, clip_right + 1, clip_top, clip_bottom + 1, _actorID); + _vm->markRectAsDirty(kMainVirtScreen, clip.left, clip.right + 1, clip.top, clip.bottom + 1, _actorID); - if (clip_top < 0) { - clip_top = 0; + if (clip.top < 0) { + clip.top = 0; } - if (clip_bottom > maxh) { - clip_bottom = maxh; + if (clip.bottom > maxh) { + clip.bottom = maxh; } - if (clip_left < 0) { - clip_left = 0; + if (clip.left < 0) { + clip.left = 0; } - if (clip_right > maxw) { - clip_right = maxw; + if (clip.right > maxw) { + clip.right = maxw; } - if ((clip_left >= clip_right) || (clip_top >= clip_bottom)) + if ((clip.left >= clip.right) || (clip.top >= clip.bottom)) return 0; - if (_draw_top > clip_top) - _draw_top = clip_top; - if (_draw_bottom < clip_bottom) - _draw_bottom = clip_bottom + 1; + if (_draw_top > clip.top) + _draw_top = clip.top; + if (_draw_bottom < clip.bottom) + _draw_bottom = clip.bottom + 1; BompDrawData bdd; @@ -955,7 +956,8 @@ void AkosRenderer::akos16DecompressMask(byte *dest, int32 pitch, const byte *src } byte AkosRenderer::codec16(int xmoveCur, int ymoveCur) { - int32 clip_left, clip_right, clip_top, clip_bottom, maxw, maxh; + Common::Rect clip; + int32 maxw, maxh; int32 skip_x, skip_y, cur_x, cur_y; const byte transparency = (_vm->_features & GF_HUMONGOUS) ? 0 : 255; @@ -965,14 +967,14 @@ byte AkosRenderer::codec16(int xmoveCur, int ymoveCur) { } if (!_mirror) { - clip_left = (_actorX - xmoveCur - _width) + 1; + clip.left = (_actorX - xmoveCur - _width) + 1; } else { - clip_left = _actorX + xmoveCur; + clip.left = _actorX + xmoveCur; } - clip_top = ymoveCur + _actorY; - clip_right = (clip_left + _width) - 1; - clip_bottom = (clip_top + _height) - 1; + clip.top = ymoveCur + _actorY; + clip.right = (clip.left + _width) - 1; + clip.bottom = (clip.top + _height) - 1; maxw = _outwidth - 1; maxh = _outheight - 1; @@ -981,39 +983,39 @@ byte AkosRenderer::codec16(int xmoveCur, int ymoveCur) { cur_x = _width - 1; cur_y = _height - 1; - _vm->markRectAsDirty(kMainVirtScreen, clip_left, clip_right + 1, clip_top, clip_bottom + 1, _actorID); + _vm->markRectAsDirty(kMainVirtScreen, clip.left, clip.right + 1, clip.top, clip.bottom + 1, _actorID); - if (clip_left < 0) { - skip_x = -clip_left; - clip_left = 0; + if (clip.left < 0) { + skip_x = -clip.left; + clip.left = 0; } - if (clip_right > maxw) { - cur_x -= clip_right - maxw; - clip_right = maxw; + if (clip.right > maxw) { + cur_x -= clip.right - maxw; + clip.right = maxw; } - if (clip_top < 0) { - skip_y -= clip_top; - clip_top = 0; + if (clip.top < 0) { + skip_y -= clip.top; + clip.top = 0; } - if (clip_bottom > maxh) { - cur_y -= clip_bottom - maxh; - clip_bottom = maxh; + if (clip.bottom > maxh) { + cur_y -= clip.bottom - maxh; + clip.bottom = maxh; } - if ((clip_left >= clip_right) || (clip_top >= clip_bottom)) + if ((clip.left >= clip.right) || (clip.top >= clip.bottom)) return 0; - if (_draw_top > clip_top) - _draw_top = clip_top; - if (_draw_bottom < clip_bottom) - _draw_bottom = clip_bottom + 1; + if (_draw_top > clip.top) + _draw_top = clip.top; + if (_draw_bottom < clip.bottom) + _draw_bottom = clip.bottom + 1; int32 width_unk, height_unk; - height_unk = clip_top; + height_unk = clip.top; int32 pitch = _outwidth; int32 dir; @@ -1024,10 +1026,10 @@ byte AkosRenderer::codec16(int xmoveCur, int ymoveCur) { int tmp_skip_x = skip_x; skip_x = _width - 1 - cur_x; cur_x = _width - 1 - tmp_skip_x; - width_unk = clip_right; + width_unk = clip.right; } else { dir = 1; - width_unk = clip_left; + width_unk = clip.left; } int32 out_height; @@ -1052,8 +1054,8 @@ byte AkosRenderer::codec16(int xmoveCur, int ymoveCur) { if (_zbuf == 0) { akos16Decompress(dest, pitch, _srcptr, cur_x, out_height, dir, numskip_before, numskip_after, transparency); } else { - byte *ptr = _vm->getMaskBuffer(clip_left, clip_top, _zbuf); - akos16DecompressMask(dest, pitch, _srcptr, cur_x, out_height, dir, numskip_before, numskip_after, transparency, ptr, clip_left / 8); + byte *ptr = _vm->getMaskBuffer(clip.left, clip.top, _zbuf); + akos16DecompressMask(dest, pitch, _srcptr, cur_x, out_height, dir, numskip_before, numskip_after, transparency, ptr, clip.left / 8); } return 0; diff --git a/scumm/bomp.cpp b/scumm/bomp.cpp index cd5094bcae..f69a31ff24 100644 --- a/scumm/bomp.cpp +++ b/scumm/bomp.cpp @@ -200,7 +200,7 @@ void ScummEngine::drawBomp(const BompDrawData &bd, bool mirror) { byte maskbit; byte *mask = 0; byte *charset_mask; - int clip_left, clip_right, clip_top, clip_bottom; + Common::Rect clip; byte *scalingYPtr = bd.scalingYPtr; byte skip_y_bits = 0x80; byte skip_y_new = 0; @@ -208,38 +208,38 @@ void ScummEngine::drawBomp(const BompDrawData &bd, bool mirror) { if (bd.x < 0) { - clip_left = -bd.x; + clip.left = -bd.x; } else { - clip_left = 0; + clip.left = 0; } if (bd.y < 0) { - clip_top = -bd.y; + clip.top = -bd.y; } else { - clip_top = 0; + clip.top = 0; } - clip_right = bd.srcwidth; - if (clip_right > bd.outwidth - bd.x) { - clip_right = bd.outwidth - bd.x; + clip.right = bd.srcwidth; + if (clip.right > bd.outwidth - bd.x) { + clip.right = bd.outwidth - bd.x; } - clip_bottom = bd.srcheight; - if (clip_bottom > bd.outheight - bd.y) { - clip_bottom = bd.outheight - bd.y; + clip.bottom = bd.srcheight; + if (clip.bottom > bd.outheight - bd.y) { + clip.bottom = bd.outheight - bd.y; } src = bd.dataptr; - dst = bd.out + bd.y * bd.outwidth + bd.x + clip_left; + dst = bd.out + bd.y * bd.outwidth + bd.x + clip.left; - maskbit = revBitMask[(bd.x + clip_left) & 7]; + maskbit = revBitMask[(bd.x + clip.left) & 7]; // Always mask against the charset mask - charset_mask = getMaskBuffer(bd.x + clip_left, bd.y, 0); + charset_mask = getMaskBuffer(bd.x + clip.left, bd.y, 0); // Also mask against any additionally imposed mask if (bd.maskPtr) { - mask = bd.maskPtr + (bd.y * gdi._numStrips) + ((bd.x + clip_left) / 8); + mask = bd.maskPtr + (bd.y * gdi._numStrips) + ((bd.x + clip.left) / 8); } // Setup vertical scaling @@ -249,20 +249,20 @@ void ScummEngine::drawBomp(const BompDrawData &bd, bool mirror) { skip_y_new = *scalingYPtr++; skip_y_bits = 0x80; - if (clip_bottom > bd.scaleBottom) { - clip_bottom = bd.scaleBottom; + if (clip.bottom > bd.scaleBottom) { + clip.bottom = bd.scaleBottom; } } // Setup horizontal scaling if (bd.scale_x != 255) { assert(bd.scalingXPtr); - if (clip_right > bd.scaleRight) { - clip_right = bd.scaleRight; + if (clip.right > bd.scaleRight) { + clip.right = bd.scaleRight; } } - const int width = clip_right - clip_left; + const int width = clip.right - clip.left; if (width <= 0) return; @@ -270,10 +270,10 @@ void ScummEngine::drawBomp(const BompDrawData &bd, bool mirror) { int pos_y = 0; byte line_buffer[1024]; - byte *line_ptr = line_buffer + clip_left; + byte *line_ptr = line_buffer + clip.left; // Loop over all lines - while (pos_y < clip_bottom) { + while (pos_y < clip.bottom) { // Decode a single (bomp encoded) line, reversed if we are in mirror mode if (mirror) bompDecodeLineReverse(line_buffer, src + 2, bd.srcwidth); @@ -303,9 +303,9 @@ void ScummEngine::drawBomp(const BompDrawData &bd, bool mirror) { bompScaleFuncX(line_buffer, bd.scalingXPtr, 0x80, bd.srcwidth); } - // The first clip_top lines are to be clipped, i.e. not drawn - if (clip_top > 0) { - clip_top--; + // The first clip.top lines are to be clipped, i.e. not drawn + if (clip.top > 0) { + clip.top--; } else { // Replace the parts of the line which are masked with the transparency color if (bd.maskPtr) diff --git a/scumm/charset.cpp b/scumm/charset.cpp index bca2e5c64f..590e221b4e 100644 --- a/scumm/charset.cpp +++ b/scumm/charset.cpp @@ -1264,24 +1264,24 @@ int CharsetRendererNut::getFontHeight() { } void CharsetRendererNut::printChar(int chr) { - int shadow_left, shadow_right, shadow_top, shadow_bottom; + Common::Rect shadow; assert(_current); if (chr == '@') return; - shadow_left = _left - 1; - shadow_top = _top - 1; + shadow.left = _left - 1; + shadow.top = _top - 1; // Note that the character is drawn with a shadow, so it is slightly // larger than the advertised dimensions. See drawShadowChar() for // details. if (_firstChar) { - _str.left = shadow_left; - _str.top = shadow_top; - _str.right = shadow_left; - _str.bottom = shadow_top; + _str.left = shadow.left; + _str.top = shadow.top; + _str.right = shadow.left; + _str.bottom = shadow.top; _firstChar = false; } @@ -1291,23 +1291,23 @@ void CharsetRendererNut::printChar(int chr) { if (chr >= 256 && _vm->_CJKMode) width = 16; - shadow_right = _left + width + 2; - shadow_bottom = _top + height + 2; + shadow.right = _left + width + 2; + shadow.bottom = _top + height + 2; _hasMask = true; _current->drawShadowChar(chr, _left, _top - _vm->_screenTop, _color, !_ignoreCharsetMask); - _vm->markRectAsDirty(kMainVirtScreen, shadow_left, shadow_right, shadow_top, shadow_bottom, 0); + _vm->markRectAsDirty(kMainVirtScreen, shadow.left, shadow.right, shadow.top, shadow.bottom, 0); if (_str.left > _left) _str.left = _left; _left += width; - if (_str.right < shadow_right ) - _str.right = shadow_right; + if (_str.right < shadow.right ) + _str.right = shadow.right; - if (_str.bottom < shadow_bottom) - _str.bottom = shadow_bottom; + if (_str.bottom < shadow.bottom) + _str.bottom = shadow.bottom; } } // End of namespace Scumm diff --git a/scumm/costume.cpp b/scumm/costume.cpp index 285725b968..1f5e28b9c9 100644 --- a/scumm/costume.cpp +++ b/scumm/costume.cpp @@ -77,8 +77,7 @@ byte CostumeRenderer::mainRoutine(int xmoveCur, int ymoveCur) { byte startScaleIndexX; byte newAmiCost; int ex1, ex2; - int y_top, y_bottom; - int x_left, x_right; + Common::Rect rect; int step; newAmiCost = (_vm->_version == 5) && (_vm->_features & GF_AMIGA); @@ -128,16 +127,16 @@ byte CostumeRenderer::mainRoutine(int xmoveCur, int ymoveCur) { if (cost_scaleTable[_scaleIndexX++] < _scaleX) v1.x -= v1.scaleXstep; } - x_right = x_left = v1.x; + rect.right = rect.left = v1.x; _scaleIndexX = startScaleIndexX; for (i = 0; i < _width; i++) { - if (x_right < 0) { + if (rect.right < 0) { skip++; startScaleIndexX = _scaleIndexX; } scal = cost_scaleTable[_scaleIndexX++]; if (scal < _scaleX) - x_right++; + rect.right++; } } else { startScaleIndexX = _scaleIndexX = xmoveCur + 128; @@ -146,16 +145,16 @@ byte CostumeRenderer::mainRoutine(int xmoveCur, int ymoveCur) { if (scal < _scaleX) v1.x += v1.scaleXstep; } - x_right = x_left = v1.x; + rect.right = rect.left = v1.x; _scaleIndexX = startScaleIndexX; for (i = 0; i < _width; i++) { - if (x_left >= (int)_outwidth) { + if (rect.left >= (int)_outwidth) { skip++; startScaleIndexX = _scaleIndexX; } scal = cost_scaleTable[_scaleIndexX--]; if (scal < _scaleX) - x_left--; + rect.left--; } } _scaleIndexX = startScaleIndexX; @@ -173,12 +172,12 @@ byte CostumeRenderer::mainRoutine(int xmoveCur, int ymoveCur) { if (scal < _scaleY) v1.y -= step; } - y_top = y_bottom = v1.y; + rect.top = rect.bottom = v1.y; _scaleIndexY = 128 - ymoveCur; for (i = 0; i < _height; i++) { scal = cost_scaleTable[_scaleIndexY++]; if (scal < _scaleY) - y_bottom++; + rect.bottom++; } _scaleIndexY = 128 - ymoveCur; } else { @@ -187,14 +186,14 @@ byte CostumeRenderer::mainRoutine(int xmoveCur, int ymoveCur) { v1.x += xmoveCur; v1.y += ymoveCur; if (_mirror) { - x_left = v1.x; - x_right = v1.x + _width; + rect.left = v1.x; + rect.right = v1.x + _width; } else { - x_left = v1.x - _width; - x_right = v1.x; + rect.left = v1.x - _width; + rect.right = v1.x; } - y_top = v1.y; - y_bottom = y_top + _height; + rect.top = v1.y; + rect.bottom = rect.top + _height; } v1.skip_width = _width; @@ -202,14 +201,14 @@ byte CostumeRenderer::mainRoutine(int xmoveCur, int ymoveCur) { if (_vm->_version == 1) //HACK: it fix gfx glitches leaved by actor costume in V1 games, when actor moving to left - _vm->markRectAsDirty(kMainVirtScreen, x_left, x_right + 8, y_top, y_bottom, _actorID); + _vm->markRectAsDirty(kMainVirtScreen, rect.left, rect.right + 8, rect.top, rect.bottom, _actorID); else - _vm->markRectAsDirty(kMainVirtScreen, x_left, x_right + 1, y_top, y_bottom, _actorID); + _vm->markRectAsDirty(kMainVirtScreen, rect.left, rect.right + 1, rect.top, rect.bottom, _actorID); - if (y_top >= (int)_outheight || y_bottom <= 0) + if (rect.top >= (int)_outheight || rect.bottom <= 0) return 0; - if (x_left >= (int)_outwidth || x_right <= 0) + if (rect.left >= (int)_outwidth || rect.right <= 0) return 0; v1.replen = 0; @@ -224,7 +223,7 @@ byte CostumeRenderer::mainRoutine(int xmoveCur, int ymoveCur) { v1.x = 0; } } else { - skip = x_right - _outwidth; + skip = rect.right - _outwidth; if (skip <= 0) { drawFlag = 2; } else { @@ -233,7 +232,7 @@ byte CostumeRenderer::mainRoutine(int xmoveCur, int ymoveCur) { } } else { if (!use_scaling) - skip = x_right - _outwidth; + skip = rect.right - _outwidth; if (skip > 0) { if (!newAmiCost && _loaded._format != 0x57) { v1.skip_width -= skip; @@ -241,7 +240,7 @@ byte CostumeRenderer::mainRoutine(int xmoveCur, int ymoveCur) { v1.x = _outwidth - 1; } } else { - skip = -1 - x_left; + skip = -1 - rect.left; if (skip <= 0) drawFlag = 2; else @@ -252,21 +251,21 @@ byte CostumeRenderer::mainRoutine(int xmoveCur, int ymoveCur) { if (v1.skip_width <= 0) return 0; - if (x_left < 0) - x_left = 0; + if (rect.left < 0) + rect.left = 0; - if ((uint) y_top > _outheight) - y_top = 0; + if ((uint) rect.top > _outheight) + rect.top = 0; - if ((uint) y_bottom > _outheight) - y_bottom = _outheight; + if ((uint) rect.bottom > _outheight) + rect.bottom = _outheight; - if (_draw_top > y_top) - _draw_top = y_top; - if (_draw_bottom < y_bottom) - _draw_bottom = y_bottom; + if (_draw_top > rect.top) + _draw_top = rect.top; + if (_draw_bottom < rect.bottom) + _draw_bottom = rect.bottom; - if (_height + y_top >= 256) { + if (_height + rect.top >= 256) { CHECK_HEAP return 2; } diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index a3bc45153a..38555aa8ee 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -571,7 +571,9 @@ void ScummEngine::restoreBG(Common::Rect rect, byte backColor) { return; topline = vs->topline; - height = topline + vs->height; + + rect.top -= topline; + rect.bottom -= topline; if (rect.left < 0) rect.left = 0; @@ -581,12 +583,12 @@ void ScummEngine::restoreBG(Common::Rect rect, byte backColor) { return; if (rect.right > vs->width) rect.right = vs->width; - if (rect.bottom >= height) - rect.bottom = height; + if (rect.bottom >= vs->height) + rect.bottom = vs->height; - markRectAsDirty(vs->number, rect.left, rect.right, rect.top - topline, rect.bottom - topline, USAGE_BIT_RESTORED); + markRectAsDirty(vs->number, rect.left, rect.right, rect.top, rect.bottom, USAGE_BIT_RESTORED); - int offset = (rect.top - topline) * vs->width + vs->xstart + rect.left; + int offset = (rect.top) * vs->width + vs->xstart + rect.left; backbuff = vs->screenPtr + offset; height = rect.height(); @@ -608,7 +610,7 @@ void ScummEngine::restoreBG(Common::Rect rect, byte backColor) { if (rect.right & 0x07) mask_width++; - mask = getMaskBuffer(rect.left, rect.top, 0); + mask = getMaskBuffer(rect.left, rect.top + topline, 0); if (vs->number == kMainVirtScreen) mask += vs->topline * gdi._numStrips; diff --git a/scumm/gfx.h b/scumm/gfx.h index c14ca1b3e1..9c0019187a 100644 --- a/scumm/gfx.h +++ b/scumm/gfx.h @@ -180,8 +180,7 @@ struct ColorCycle { /** BlastObjects to draw */ struct BlastObject { uint16 number; - int16 posX, posY; - uint16 width, height; + Common::Rect rect; uint16 scaleX, scaleY; uint16 image; uint16 mode; diff --git a/scumm/object.cpp b/scumm/object.cpp index 226d80da07..7cddf18d32 100644 --- a/scumm/object.cpp +++ b/scumm/object.cpp @@ -1412,19 +1412,19 @@ void ScummEngine::enqueueObject(int objectNumber, int objectX, int objectY, int eo = &_blastObjectQueue[_blastObjectQueuePos++]; eo->number = objectNumber; - eo->posX = objectX + (camera._cur.x & 7); - eo->posY = objectY + _screenTop; + eo->rect.left = objectX + (camera._cur.x & 7); + eo->rect.top = objectY + _screenTop; if (objectWidth == 0) { od = &_objs[idx]; - eo->width = od->width; + eo->rect.right = eo->rect.left + od->width; } else { - eo->width = objectWidth; + eo->rect.right = eo->rect.left + objectWidth; } if (objectHeight == 0) { od = &_objs[idx]; - eo->height = od->height; + eo->rect.bottom = eo->rect.top + od->height; } else { - eo->height = objectHeight; + eo->rect.bottom = eo->rect.top + objectHeight; } eo->scaleX = scaleX; @@ -1492,8 +1492,8 @@ void ScummEngine::drawBlastObject(BlastObject *eo) { } else { bdd.dataptr = bomp + 10; // Why this? See also useBompCursor } - bdd.x = eo->posX; - bdd.y = eo->posY; + bdd.x = eo->rect.left; + bdd.y = eo->rect.top; bdd.scale_x = (byte)eo->scaleX; bdd.scale_y = (byte)eo->scaleY; @@ -1533,29 +1533,26 @@ void ScummEngine::removeBlastObjects() { void ScummEngine::removeBlastObject(BlastObject *eo) { VirtScreen *vs = &virtscr[0]; - int top, bottom, left, right; + Common::Rect r; int left_strip, right_strip; int i; - top = eo->posY; - bottom = eo->posY + eo->height; - left = eo->posX; - right = eo->posX + eo->width; + r = eo->rect; - if (bottom < 0 || right < 0 || top > vs->height || left > vs->width) + if (r.bottom < 0 || r.right < 0 || r.top > vs->height || r.left > vs->width) return; - if (top < 0) - top = 0; - if (bottom > vs->height) - bottom = vs->height; - if (left < 0) - left = 0; - if (right > vs->width) - right = vs->width; + if (r.top < 0) + r.top = 0; + if (r.bottom > vs->height) + r.bottom = vs->height; + if (r.left < 0) + r.left = 0; + if (r.right > vs->width) + r.right = vs->width; - left_strip = left / 8; - right_strip = (right - 1) / 8; + left_strip = r.left / 8; + right_strip = (r.right - 1) / 8; if (left_strip < 0) left_strip = 0; @@ -1567,9 +1564,9 @@ void ScummEngine::removeBlastObject(BlastObject *eo) { right_strip = 200; } for (i = left_strip; i <= right_strip; i++) - gdi.resetBackground(top, bottom, i); + gdi.resetBackground(r.top, r.bottom, i); - markRectAsDirty(kMainVirtScreen, left, right, top, bottom, USAGE_BIT_RESTORED); + markRectAsDirty(kMainVirtScreen, r.left, r.right, r.top, r.bottom, USAGE_BIT_RESTORED); } int ScummEngine::findLocalObjectSlot() { diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp index 2d6ffc9ab0..7afb48fa32 100644 --- a/scumm/script_v8.cpp +++ b/scumm/script_v8.cpp @@ -1413,12 +1413,9 @@ void ScummEngine_v8::o8_kernelGetFunctions() { for (int i = _blastObjectQueuePos - 1; i >= 0; i--) { eo = &_blastObjectQueue[i]; - if (eo->posX <= x && eo->width + eo->posX > x && - eo->posY <= y && eo->height + eo->posY > y) { - if (!getClass(eo->number, kObjectClassUntouchable)) { - push(eo->number); - return; - } + if (eo->rect.contains(x, y) && !getClass(eo->number, kObjectClassUntouchable)) { + push(eo->number); + return; } } push(0); |