diff options
author | Max Horn | 2003-05-15 22:30:32 +0000 |
---|---|---|
committer | Max Horn | 2003-05-15 22:30:32 +0000 |
commit | f4c7f3774318668a18814ebaac9922ad5f86062f (patch) | |
tree | 586bade6ba164ed8e11aae635f43cb53dfdfba1d | |
parent | 050358bc7fcaab2ba2821b0fd5b28e02bac2a0e6 (diff) | |
download | scummvm-rg350-f4c7f3774318668a18814ebaac9922ad5f86062f.tar.gz scummvm-rg350-f4c7f3774318668a18814ebaac9922ad5f86062f.tar.bz2 scummvm-rg350-f4c7f3774318668a18814ebaac9922ad5f86062f.zip |
Make use of ScummVM::Rect
svn-id: r7546
-rw-r--r-- | scumm/charset.cpp | 70 | ||||
-rw-r--r-- | scumm/charset.h | 3 | ||||
-rw-r--r-- | scumm/gfx.cpp | 54 | ||||
-rw-r--r-- | scumm/gfx.h | 2 | ||||
-rw-r--r-- | scumm/saveload.cpp | 2 | ||||
-rw-r--r-- | scumm/script_v8.cpp | 7 | ||||
-rw-r--r-- | scumm/scumm.h | 4 | ||||
-rw-r--r-- | scumm/string.cpp | 46 | ||||
-rw-r--r-- | scumm/verbs.cpp | 16 |
9 files changed, 97 insertions, 107 deletions
diff --git a/scumm/charset.cpp b/scumm/charset.cpp index 98e7346ae9..45d4188f6b 100644 --- a/scumm/charset.cpp +++ b/scumm/charset.cpp @@ -378,10 +378,10 @@ void CharsetRendererV3::printChar(int chr) { return; if (_firstChar) { - _strLeft = _left; - _strTop = _top; - _strRight = _left; - _strBottom = _top; + _str.left = _left; + _str.top = _top; + _str.right = _left; + _str.bottom = _top; _firstChar = false; } @@ -435,19 +435,19 @@ void CharsetRendererV3::printChar(int chr) { mask_ptr += _vm->gdi._numStrips; } - if (_strLeft > _left) - _strLeft = _left; + if (_str.left > _left) + _str.left = _left; _left += getCharWidth(chr); - if (_strRight < _left) { - _strRight = _left; + if (_str.right < _left) { + _str.right = _left; if (_dropShadow) - _strRight++; + _str.right++; } - if (_strBottom < _top + h) - _strBottom = _top + h; + if (_str.bottom < _top + h) + _str.bottom = _top + h; } void CharsetRendererClassic::printChar(int chr) { @@ -479,10 +479,10 @@ void CharsetRendererClassic::printChar(int chr) { width = _charPtr[0]; height = _charPtr[1]; if (_firstChar) { - _strLeft = 0; - _strTop = 0; - _strRight = 0; - _strBottom = 0; + _str.left = 0; + _str.top = 0; + _str.right = 0; + _str.bottom = 0; } if (_disableOffsX) { @@ -511,18 +511,18 @@ void CharsetRendererClassic::printChar(int chr) { _disableOffsX = false; if (_firstChar) { - _strLeft = _left; - _strTop = _top; - _strRight = _left; - _strBottom = _top; + _str.left = _left; + _str.top = _top; + _str.right = _left; + _str.bottom = _top; _firstChar = false; } - if (_left < _strLeft) - _strLeft = _left; + if (_left < _str.left) + _str.left = _left; - if (_top < _strTop) - _strTop = _top; + if (_top < _str.top) + _str.top = _top; int drawTop = _top - vs->topline; if (drawTop < 0) @@ -556,11 +556,11 @@ void CharsetRendererClassic::printChar(int chr) { } _left += width; - if (_left > _strRight) - _strRight = _left; + if (_left > _str.right) + _str.right = _left; - if (_top + height > _strBottom) - _strBottom = _top + height; + if (_top + height > _str.bottom) + _str.bottom = _top + height; _top -= offsY; } @@ -656,10 +656,10 @@ void CharsetRendererNut::printChar(int chr) { return; if (_firstChar) { - _strLeft = _left; - _strTop = _top; - _strRight = _left; - _strBottom = _top; + _str.left = _left; + _str.top = _top; + _str.right = _left; + _str.bottom = _top; _firstChar = false; } @@ -671,10 +671,10 @@ void CharsetRendererNut::printChar(int chr) { _vm->updateDirtyRect(0, _left, _left + width, _top, _top + height, 0); _left += width; - if (_left > _strRight) - _strRight = _left; + if (_left > _str.right) + _str.right = _left; - if (_top + height > _strBottom) - _strBottom = _top + height; + if (_top + height > _str.bottom) + _str.bottom = _top + height; } diff --git a/scumm/charset.h b/scumm/charset.h index 22d99163be..0c63c0b5b2 100644 --- a/scumm/charset.h +++ b/scumm/charset.h @@ -21,6 +21,7 @@ #ifndef CHARSET_H #define CHARSET_H +#include "common/rect.h" #include "common/scummsys.h" class Scumm; @@ -29,7 +30,7 @@ struct VirtScreen; class CharsetRenderer { public: - int _strLeft, _strRight, _strTop, _strBottom; + ScummVM::Rect _str; int _nextLeft, _nextTop; int _top; diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index a032156e17..a45f9fae1c 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -727,11 +727,11 @@ void Scumm::redrawBGStrip(int start, int num) { } void Scumm::restoreCharsetBg() { - if (gdi._mask_left != -1) { - restoreBG(gdi._mask_left, gdi._mask_top, gdi._mask_right, gdi._mask_bottom); + if (gdi._mask.left != -1) { + restoreBG(gdi._mask); _charset->_hasMask = false; - gdi._mask_left = -1; - _charset->_strLeft = -1; + gdi._mask.left = -1; + _charset->_str.left = -1; _charset->_left = -1; } @@ -739,42 +739,42 @@ void Scumm::restoreCharsetBg() { _charset->_nextTop = _string[0].ypos; } -void Scumm::restoreBG(int left, int top, int right, int bottom, byte backColor) { +void Scumm::restoreBG(ScummVM::Rect rect, byte backColor) { VirtScreen *vs; int topline, height, width; byte *backbuff, *bgbak; bool lightsOn; - if (left == right || top == bottom) + if (rect.left == rect.right || rect.top == rect.bottom) return; - if (top < 0) - top = 0; + if (rect.top < 0) + rect.top = 0; - if ((vs = findVirtScreen(top)) == NULL) + if ((vs = findVirtScreen(rect.top)) == NULL) return; topline = vs->topline; height = topline + vs->height; - if (left < 0) - left = 0; - if (right < 0) - right = 0; - if (left > _screenWidth) + if (rect.left < 0) + rect.left = 0; + if (rect.right < 0) + rect.right = 0; + if (rect.left > _screenWidth) return; - if (right > _screenWidth) - right = _screenWidth; - if (bottom >= height) - bottom = height; + if (rect.right > _screenWidth) + rect.right = _screenWidth; + if (rect.bottom >= height) + rect.bottom = height; - updateDirtyRect(vs->number, left, right, top - topline, bottom - topline, USAGE_BIT_RESTORED); + updateDirtyRect(vs->number, rect.left, rect.right, rect.top - topline, rect.bottom - topline, USAGE_BIT_RESTORED); - int offset = (top - topline) * _screenWidth + vs->xstart + left; + int offset = (rect.top - topline) * _screenWidth + vs->xstart + rect.left; backbuff = vs->screenPtr + offset; bgbak = getResourceAddress(rtBuffer, vs->number + 5) + offset; - height = bottom - top; - width = right - left; + height = rect.height(); + width = rect.width(); // Check whether lights are turned on or not lightsOn = (_features & GF_AFTER_V6) || (vs->number != 0) || (VAR(VAR_CURRENT_LIGHTS) & LIGHTMODE_screen); @@ -788,7 +788,7 @@ void Scumm::restoreBG(int left, int top, int right, int bottom, byte backColor) if (width & 0x07) mask_width++; - mask = getResourceAddress(rtBuffer, 9) + top * gdi._numStrips + (left >> 3) + _screenStartStrip; + mask = getResourceAddress(rtBuffer, 9) + rect.top * gdi._numStrips + (rect.left >> 3) + _screenStartStrip; if (vs->number == 0) mask += vs->topline * gdi._numStrips; @@ -813,10 +813,10 @@ bool Scumm::hasCharsetMask(int left, int top, int right, int bottom) { // would mean that the rects are touching on their borders, but not // actually overlapping. return _charset->_hasMask - && top <= gdi._mask_bottom - && left <= gdi._mask_right - && bottom >= gdi._mask_top - && right >= gdi._mask_left; + && top <= gdi._mask.bottom + && left <= gdi._mask.right + && bottom >= gdi._mask.top + && right >= gdi._mask.left; /* if (!_charset->_hasMask || top > gdi._mask_bottom || left > gdi._mask_right || bottom < gdi._mask_top || right < gdi._mask_left) diff --git a/scumm/gfx.h b/scumm/gfx.h index 23a6d0c473..1f6e93ff16 100644 --- a/scumm/gfx.h +++ b/scumm/gfx.h @@ -117,7 +117,7 @@ public: int _numZBuffer; int _imgBufOffs[8]; int32 _numStrips; - int16 _mask_top, _mask_bottom, _mask_right, _mask_left; + ScummVM::Rect _mask; protected: byte *_readPtr; diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp index 5c624646ba..81a48e7f49 100644 --- a/scumm/saveload.cpp +++ b/scumm/saveload.cpp @@ -161,7 +161,7 @@ bool Scumm::loadState(int slot, bool compat, SaveFileManager *mgr) { sb = _screenB; sh = _screenH; - gdi._mask_left = -1; + gdi._mask.left = -1; initScreens(0, 0, _screenWidth, _screenHeight); diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp index 02b02a0927..0f01bc3c1f 100644 --- a/scumm/script_v8.cpp +++ b/scumm/script_v8.cpp @@ -611,10 +611,7 @@ void Scumm::drawBlastTexts() { } } while (c); - _blastTextQueue[i].left = _charset->_strLeft; - _blastTextQueue[i].right = _charset->_strRight; - _blastTextQueue[i].top = _charset->_strTop; - _blastTextQueue[i].bottom = _charset->_strBottom; + _blastTextQueue[i].rect = _charset->_str; } _charset->_ignoreCharsetMask = false; } @@ -623,7 +620,7 @@ void Scumm::removeBlastTexts() { int i; for (i = 0; i < _blastTextQueuePos; i++) { - restoreBG(_blastTextQueue[i].left, _blastTextQueue[i].top, _blastTextQueue[i].right, _blastTextQueue[i].bottom); + restoreBG(_blastTextQueue[i].rect); } _blastTextQueuePos = 0; } diff --git a/scumm/scumm.h b/scumm/scumm.h index 11ee57a683..e7199171f7 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -105,7 +105,7 @@ struct NestedScript { struct BlastText { int16 xpos, ypos; - int16 left, right, top, bottom; + ScummVM::Rect rect; byte color; byte charset; bool center; @@ -789,7 +789,7 @@ public: void drawRoomObject(int i, int arg); void drawBox(int x, int y, int x2, int y2, int color); - void restoreBG(int left, int top, int right, int bottom, byte backColor = 0); + void restoreBG(ScummVM::Rect rect, byte backColor = 0); void redrawBGStrip(int start, int num); void redrawBGAreas(); diff --git a/scumm/string.cpp b/scumm/string.cpp index c1d7beb922..6531f86fe5 100644 --- a/scumm/string.cpp +++ b/scumm/string.cpp @@ -146,10 +146,7 @@ void Scumm::CHARSET_1() { _charsetColorMap[i] = _charsetData[_charset->getCurID()][i]; if (_keepText) { - _charset->_strLeft = gdi._mask_left; - _charset->_strRight = gdi._mask_right; - _charset->_strTop = gdi._mask_top; - _charset->_strBottom = gdi._mask_bottom; + _charset->_str = gdi._mask; } if (_talkDelay) @@ -185,12 +182,12 @@ void Scumm::CHARSET_1() { if (!_keepText) { if ((_features & GF_AFTER_V2 || _features & GF_AFTER_V3) && _gameId != GID_LOOM) { - gdi._mask_left = _string[0].xpos; - gdi._mask_top = _string[0].ypos; - gdi._mask_bottom = _string[0].ypos + 8; - gdi._mask_right = _screenWidth; + gdi._mask.left = _string[0].xpos; + gdi._mask.top = _string[0].ypos; + gdi._mask.bottom = _string[0].ypos + 8; + gdi._mask.right = _screenWidth; if (_string[0].ypos <= 16) // If we are cleaning the text line, clean 2 lines. - gdi._mask_bottom = 16; + gdi._mask.bottom = 16; } restoreCharsetBg(); } @@ -333,10 +330,7 @@ void Scumm::CHARSET_1() { _charsetBufPos = buffer - _charsetBuffer; - gdi._mask_left = _charset->_strLeft; - gdi._mask_right = _charset->_strRight; - gdi._mask_top = _charset->_strTop; - gdi._mask_bottom = _charset->_strBottom; + gdi._mask = _charset->_str; } void Scumm::drawDescString(byte *msg) { @@ -366,7 +360,7 @@ void Scumm::drawDescString(byte *msg) { _talkDelay = 1; if (_string[0].ypos + _charset->getFontHeight() > 0) - restoreBG(0, _string[0].ypos, _screenWidth - 1, _string[0].ypos + _charset->getFontHeight()); + restoreBG(ScummVM::Rect(0, _string[0].ypos, _screenWidth - 1, _string[0].ypos + _charset->getFontHeight())); _charset->_nextLeft = _string[0].xpos; _charset->_nextTop = _string[0].ypos; @@ -385,10 +379,8 @@ void Scumm::drawDescString(byte *msg) { // hack: more 8 pixels at width and height while redraw // for proper description redraw while scrolling room - gdi._mask_left = _charset->_strLeft - 8; - gdi._mask_right = _charset->_strRight + 8; - gdi._mask_top = _charset->_strTop - 8; - gdi._mask_bottom = _charset->_strBottom + 8; + gdi._mask = _charset->_str; + gdi._mask.grow(8); } void Scumm::drawString(int a) { @@ -497,7 +489,7 @@ void Scumm::drawString(int a) { } - _string[a].xpos = _charset->_strRight + 8; // Indy3: Fixes Grail Diary text positioning + _string[a].xpos = _charset->_str.right + 8; // Indy3: Fixes Grail Diary text positioning if (_features & GF_AFTER_V7) { _charset->_hasMask = true; @@ -505,14 +497,14 @@ void Scumm::drawString(int a) { // to -1 to mark it as invalid. Hence this comparision will always leave it at -1, // which implies that if the mask was marked invalid, it will always stay so. // That seems odd and not at all to be the intended thing... or is it? - if (_charset->_strLeft < gdi._mask_left) - gdi._mask_left = _charset->_strLeft; - if (_charset->_strRight > gdi._mask_right) - gdi._mask_right = _charset->_strRight; - if (_charset->_strTop < gdi._mask_top) - gdi._mask_top = _charset->_strTop; - if (_charset->_strBottom > gdi._mask_bottom) - gdi._mask_bottom = _charset->_strBottom; + if (_charset->_str.left < gdi._mask.left) + gdi._mask.left = _charset->_str.left; + if (_charset->_str.right > gdi._mask.right) + gdi._mask.right = _charset->_str.right; + if (_charset->_str.top < gdi._mask.top) + gdi._mask.top = _charset->_str.top; + if (_charset->_str.bottom > gdi._mask.bottom) + gdi._mask.bottom = _charset->_str.bottom; } } diff --git a/scumm/verbs.cpp b/scumm/verbs.cpp index c9f524f92d..266049705f 100644 --- a/scumm/verbs.cpp +++ b/scumm/verbs.cpp @@ -184,13 +184,13 @@ void Scumm::drawVerb(int verb, int mode) { drawString(4); _charset->_center = tmp; - vs->right = _charset->_strRight; - vs->bottom = _charset->_strBottom; - vs->oldleft = _charset->_strLeft; - vs->oldright = _charset->_strRight; - vs->oldtop = _charset->_strTop; - vs->oldbottom = _charset->_strBottom; - _charset->_strLeft = _charset->_strRight; + vs->right = _charset->_str.right; + vs->bottom = _charset->_str.bottom; + vs->oldleft = _charset->_str.left; + vs->oldright = _charset->_str.right; + vs->oldtop = _charset->_str.top; + vs->oldbottom = _charset->_str.bottom; + _charset->_str.left = _charset->_str.right; } else { restoreVerbBG(verb); } @@ -202,7 +202,7 @@ void Scumm::restoreVerbBG(int verb) { vs = &_verbs[verb]; if (vs->oldleft != -1) { - restoreBG(vs->oldleft, vs->oldtop, vs->oldright, vs->oldbottom, vs->bkcolor); + restoreBG(ScummVM::Rect(vs->oldleft, vs->oldtop, vs->oldright, vs->oldbottom), vs->bkcolor); vs->oldleft = -1; } } |