diff options
author | Max Horn | 2003-06-01 17:29:45 +0000 |
---|---|---|
committer | Max Horn | 2003-06-01 17:29:45 +0000 |
commit | 393e749785ffe11c6d5cbac3a74568950bcc07a1 (patch) | |
tree | 805d4f718978bd9ef4d0a97e676542c97a5d33f6 /scumm | |
parent | 16b47e4f9537fcccd8b25ec8f561ef62b29287b6 (diff) | |
download | scummvm-rg350-393e749785ffe11c6d5cbac3a74568950bcc07a1.tar.gz scummvm-rg350-393e749785ffe11c6d5cbac3a74568950bcc07a1.tar.bz2 scummvm-rg350-393e749785ffe11c6d5cbac3a74568950bcc07a1.zip |
charset masking fixes, mostly for The Dig (hey I think I finally almost understand that part of the code :-)
svn-id: r8248
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/gfx.cpp | 23 | ||||
-rw-r--r-- | scumm/saveload.cpp | 4 | ||||
-rw-r--r-- | scumm/string.cpp | 24 |
3 files changed, 20 insertions, 31 deletions
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index e468636f59..0d69ea166b 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -447,6 +447,8 @@ void Gdi::drawStripToScreen(VirtScreen *vs, int x, int w, int t, int b) { void Gdi::clearCharsetMask() { memset(_vm->getResourceAddress(rtBuffer, 9), 0, _imgBufOffs[1]); + _mask.top = _mask.left = 32767; + _mask.right = _mask.bottom = 0; } /** @@ -763,10 +765,11 @@ void Scumm::redrawBGStrip(int start, int num) { } void Scumm::restoreCharsetBg() { - if (gdi._mask.left != -1) { + if (_charset->_hasMask) { restoreBG(gdi._mask); _charset->_hasMask = false; - gdi._mask.left = -1; + gdi._mask.top = gdi._mask.left = 32767; + gdi._mask.right = gdi._mask.bottom = 0; _charset->_str.left = -1; _charset->_left = -1; } @@ -781,7 +784,7 @@ void Scumm::restoreBG(ScummVM::Rect rect, byte backColor) { byte *backbuff, *bgbak; bool lightsOn; - if (rect.left == rect.right || rect.top == rect.bottom) + if (rect.left >= rect.right || rect.top >= rect.bottom) return; if (rect.top < 0) rect.top = 0; @@ -846,17 +849,9 @@ void Scumm::restoreBG(ScummVM::Rect rect, byte backColor) { } bool Scumm::hasCharsetMask(int left, int top, int right, int bottom) { - // FIXME: I wonder if the <= / >= here shouldn't be replaced by < / > - // After all, right/bottom are not actually part of the rects. - // That is, the pixels part of the rect range from x = left .. right-1 - // and y = top .. bottom-1. The 'equal' / '=' cases in the check - // 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; + ScummVM::Rect rect(left, top, right, bottom); + + return _charset->_hasMask && rect.intersects(gdi._mask); } byte *Scumm::getMaskBuffer(int x, int y, int z) { diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp index 791c161411..d22d6347b4 100644 --- a/scumm/saveload.cpp +++ b/scumm/saveload.cpp @@ -146,7 +146,9 @@ bool Scumm::loadState(int slot, bool compat, SaveFileManager *mgr) { sb = _screenB; sh = _screenH; - gdi._mask.left = -1; + gdi._mask.top = gdi._mask.left = 32767; + gdi._mask.right = gdi._mask.bottom = 0; + _charset->_hasMask = false; initScreens(0, 0, _screenWidth, _screenHeight); diff --git a/scumm/string.cpp b/scumm/string.cpp index b96eaec65b..4724394d38 100644 --- a/scumm/string.cpp +++ b/scumm/string.cpp @@ -183,6 +183,7 @@ void Scumm::CHARSET_1() { if (!_keepText) { if ((_features & GF_AFTER_V2 || _features & GF_AFTER_V3) && _gameId != GID_LOOM) { + _charset->_hasMask = true; gdi._mask.left = _string[0].xpos; gdi._mask.top = _string[0].ypos; gdi._mask.bottom = _string[0].ypos + 8; @@ -331,7 +332,8 @@ void Scumm::CHARSET_1() { _charsetBufPos = buffer - _charsetBuffer; - gdi._mask = _charset->_str; + _charset->_hasMask = true; + gdi._mask.extend(_charset->_str); } void Scumm::drawDescString(const byte *msg) { @@ -380,8 +382,9 @@ void Scumm::drawDescString(const byte *msg) { // hack: more 8 pixels at width and height while redraw // for proper description redraw while scrolling room - gdi._mask = _charset->_str; - gdi._mask.grow(8); + ScummVM::Rect r(_charset->_str); + r.grow(8); + gdi._mask.extend(r); } void Scumm::drawString(int a) { @@ -494,19 +497,8 @@ void Scumm::drawString(int a) { if (_features & GF_AFTER_V7) { _charset->_hasMask = true; - // FIXME - how is this supposed to ever work, since gdi._mask_left is by default set - // 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->_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; - } + gdi._mask.extend(_charset->_str); + } } const byte *Scumm::addMessageToStack(const byte *msg) { |