diff options
author | Max Horn | 2003-06-01 14:30:26 +0000 |
---|---|---|
committer | Max Horn | 2003-06-01 14:30:26 +0000 |
commit | cb5fb5d40381d76d6438a6eff882918de0d637a8 (patch) | |
tree | 69a7adb05844df85b24860857e967e0214e9ddba | |
parent | 2591a4f018e3b884427f18f3fe1710b7f1c6fd1e (diff) | |
download | scummvm-rg350-cb5fb5d40381d76d6438a6eff882918de0d637a8.tar.gz scummvm-rg350-cb5fb5d40381d76d6438a6eff882918de0d637a8.tar.bz2 scummvm-rg350-cb5fb5d40381d76d6438a6eff882918de0d637a8.zip |
added a getMaskBuffer method (makes it easier to read some of the code); merged setVirtscreenDirty() into updateDirtyRect(); made setDirtyRange a method of struct VirtScreen
svn-id: r8241
-rw-r--r-- | scumm/akos.cpp | 7 | ||||
-rw-r--r-- | scumm/bomp.cpp | 6 | ||||
-rw-r--r-- | scumm/camera.cpp | 1 | ||||
-rw-r--r-- | scumm/charset.cpp | 6 | ||||
-rw-r--r-- | scumm/costume.cpp | 2 | ||||
-rw-r--r-- | scumm/debugger.cpp | 2 | ||||
-rw-r--r-- | scumm/gfx.cpp | 69 | ||||
-rw-r--r-- | scumm/gfx.h | 7 | ||||
-rw-r--r-- | scumm/nut_renderer.cpp | 3 | ||||
-rw-r--r-- | scumm/scumm.h | 7 |
10 files changed, 36 insertions, 74 deletions
diff --git a/scumm/akos.cpp b/scumm/akos.cpp index 83192077f7..c2fb9c06bb 100644 --- a/scumm/akos.cpp +++ b/scumm/akos.cpp @@ -702,7 +702,7 @@ byte AkosRenderer::codec1(int xmoveCur, int ymoveCur) { v1.destptr = _outptr + v1.y * _outwidth + v1.x; - v1.mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + v1.y * _numStrips + _vm->_screenStartStrip; + v1.mask_ptr = _vm->getMaskBuffer(0, v1.y, 0); v1.imgbufoffs = _vm->gdi._imgBufOffs[_zbuf]; codec1_genericDecode(); @@ -777,7 +777,7 @@ byte AkosRenderer::codec5(int xmoveCur, int ymoveCur) { bdd.y = _actorY + ymoveCur; if (_zbuf != 0) { - bdd.maskPtr = _vm->getResourceAddress(rtBuffer, 9) + _vm->gdi._imgBufOffs[_zbuf]; + bdd.maskPtr = _vm->getMaskBuffer(0, 0, _zbuf); _vm->drawBomp(bdd, !_mirror); } else { _vm->drawBomp(bdd, !_mirror); @@ -1009,8 +1009,7 @@ 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->_screenStartStrip + _vm->getResourceAddress(rtBuffer, 9) + _vm->gdi._imgBufOffs[_zbuf]; - ptr += _numStrips * clip_top + (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); } diff --git a/scumm/bomp.cpp b/scumm/bomp.cpp index 8679b16a0e..1a02ba3995 100644 --- a/scumm/bomp.cpp +++ b/scumm/bomp.cpp @@ -198,7 +198,6 @@ void Scumm::drawBomp(const BompDrawData &bd, bool mirror) { byte *dst; byte maskbit; byte *mask = 0; - int mask_offset; byte *charset_mask; int clip_left, clip_right, clip_top, clip_bottom; byte *scalingYPtr = bd.scalingYPtr; @@ -232,15 +231,14 @@ void Scumm::drawBomp(const BompDrawData &bd, bool mirror) { src = bd.dataptr; dst = bd.out + bd.y * bd.outwidth + bd.x + clip_left; - mask_offset = _screenStartStrip + (bd.y * gdi._numStrips) + ((bd.x + clip_left) >> 3); maskbit = revBitMask[(bd.x + clip_left) & 7]; // Always mask against the charset mask - charset_mask = getResourceAddress(rtBuffer, 9) + mask_offset; + charset_mask = getMaskBuffer(bd.x + clip_left, bd.y, 0); // Also mask against any additionally imposed mask if (bd.maskPtr) { - mask = bd.maskPtr + mask_offset; + mask = bd.maskPtr + (bd.y * gdi._numStrips) + ((bd.x + clip_left) >> 3); } // Setup vertical scaling diff --git a/scumm/camera.cpp b/scumm/camera.cpp index 90119cb90d..4f027e3a75 100644 --- a/scumm/camera.cpp +++ b/scumm/camera.cpp @@ -54,6 +54,7 @@ void Scumm::setCameraAt(int pos_x, int pos_y) { runScript(VAR(VAR_SCROLL_SCRIPT), 0, 0, 0); } + // If the camera moved and text is visible, remove it if (camera._cur.x != camera._last.x && _charset->_hasMask) stopTalk(); } diff --git a/scumm/charset.cpp b/scumm/charset.cpp index 09aba8d1e4..85af1e0b84 100644 --- a/scumm/charset.cpp +++ b/scumm/charset.cpp @@ -560,7 +560,7 @@ void CharsetRendererV3::printChar(int chr) { char_ptr = _fontPtr + chr * 8; dest_ptr = vs->screenPtr + vs->xstart + (_top - vs->topline) * _vm->_screenWidth + _left; - mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + _vm->_screenStartStrip + (_top - vs->topline) * _vm->gdi._numStrips + _left / 8; + mask_ptr = _vm->getMaskBuffer(_left, _top - vs->topline, 0); useMask = (vs->number == 0 && !_ignoreCharsetMask); _vm->updateDirtyRect(vs->number, _left, _left + w, _top - vs->topline, _top - vs->topline + h, 0); @@ -711,9 +711,7 @@ void CharsetRendererClassic::printChar(int chr) { _charPtr += 4; - byte *mask = _vm->getResourceAddress(rtBuffer, 9) - + drawTop * _vm->gdi._numStrips + _left / 8 + _vm->_screenStartStrip; - + byte *mask = _vm->getMaskBuffer(_left, drawTop, 0); byte *dst = vs->screenPtr + vs->xstart + drawTop * _vm->_screenWidth + _left; if (_blitAlso) { diff --git a/scumm/costume.cpp b/scumm/costume.cpp index c411796ccf..8df7a9e7ae 100644 --- a/scumm/costume.cpp +++ b/scumm/costume.cpp @@ -247,7 +247,7 @@ byte CostumeRenderer::mainRoutine(int xmoveCur, int ymoveCur) { v1.destptr = _outptr + v1.y * _outwidth + v1.x; - v1.mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + v1.y * _numStrips + _vm->_screenStartStrip; + v1.mask_ptr = _vm->getMaskBuffer(0, v1.y, 0); v1.imgbufoffs = _vm->gdi._imgBufOffs[_zbuf]; CHECK_HEAP diff --git a/scumm/debugger.cpp b/scumm/debugger.cpp index f4ce0a18c9..d55a4e764e 100644 --- a/scumm/debugger.cpp +++ b/scumm/debugger.cpp @@ -895,7 +895,7 @@ void ScummDebugger::drawBox(int box) { VirtScreen *vs = _s->findVirtScreen(coords.ul.y); if (vs != NULL) - _s->setVirtscreenDirty(vs, 0, 0, _s->_screenWidth, _s->_screenHeight); + _s->updateDirtyRect(vs->number, 0, _s->_screenWidth, 0, _s->_screenHeight, 0); _s->drawDirtyScreenParts(); _s->_system->update_screen(); } diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index fc35781d74..e468636f59 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -188,7 +188,7 @@ void Scumm::getGraphicsPerformance() { VAR(VAR_PERFORMANCE_1) = 0; for (i = 10; i != 0; i--) { - setDirtyRange(0, 0, _screenHeight); //ender + virtscr[0].setDirtyRange(0, _screenHeight); //ender drawDirtyScreenParts(); } @@ -266,7 +266,7 @@ void Scumm::initVirtScreen(int slot, int number, int top, int width, int height, } if (slot != 3) { - setDirtyRange(slot, 0, height); + virtscr[slot].setDirtyRange(0, height); } } @@ -317,12 +317,9 @@ void Scumm::updateDirtyRect(int virt, int left, int right, int top, int bottom, setGfxUsageBit(lp, dirtybit); } - setVirtscreenDirty(vs, left, top, right, bottom); -} - -void Scumm::setVirtscreenDirty(VirtScreen *vs, int left, int top, int right, int bottom) { - int lp = left >> 3; - int rp = right >> 3; + // The following code used to be in the seperate method setVirtscreenDirty + lp = left >> 3; + rp = right >> 3; if ((lp >= gdi._numStrips) || (rp < 0)) return; @@ -340,15 +337,6 @@ void Scumm::setVirtscreenDirty(VirtScreen *vs, int left, int top, int right, int } } -void Scumm::setDirtyRange(int slot, int top, int bottom) { - int i; - VirtScreen *vs = &virtscr[slot]; - for (i = 0; i < gdi._numStrips; i++) { - vs->tdirty[i] = top; - vs->bdirty[i] = bottom; - } -} - void Scumm::drawDirtyScreenParts() { int i; VirtScreen *vs; @@ -477,10 +465,10 @@ void Gdi::resetBackground(int top, int bottom, int strip) { if (bottom > vs->bdirty[strip]) vs->bdirty[strip] = bottom; - offs = (top * _numStrips + _vm->_screenStartStrip + strip); - byte *mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + offs; - bgbak_ptr = _vm->getResourceAddress(rtBuffer, 5) + (offs << 3); - backbuff_ptr = vs->screenPtr + (offs << 3); + offs = (top * _numStrips + _vm->_screenStartStrip + strip) << 3; + byte *mask_ptr = _vm->getMaskBuffer(strip * 8, top, 0); + bgbak_ptr = _vm->getResourceAddress(rtBuffer, 5) + offs; + backbuff_ptr = vs->screenPtr + offs; numLinesToProcess = bottom - top; if (numLinesToProcess) { @@ -840,7 +828,7 @@ void Scumm::restoreBG(ScummVM::Rect rect, byte backColor) { if (rect.right & 0x07) mask_width++; - mask = getResourceAddress(rtBuffer, 9) + rect.top * gdi._numStrips + (rect.left >> 3) + _screenStartStrip; + mask = getMaskBuffer(rect.left, rect.top, 0); if (vs->number == 0) mask += vs->topline * gdi._numStrips; @@ -871,35 +859,12 @@ bool Scumm::hasCharsetMask(int left, int top, int right, int bottom) { && right >= gdi._mask.left; } -bool Scumm::isMaskActiveAt(int l, int t, int r, int b, byte *mem) { - int w, h, i; - - l >>= 3; - if (l < 0) - l = 0; - if (t < 0) - t = 0; - - r >>= 3; - if (r > gdi._numStrips - 1) - r = gdi._numStrips - 1; - - mem += l + t * gdi._numStrips; - - w = r - l; - h = b - t + 1; - - do { - for (i = 0; i <= w; i++) - if (mem[i]) { - return true; - } - mem += gdi._numStrips; - } while (--h); - - return false; +byte *Scumm::getMaskBuffer(int x, int y, int z) { + return getResourceAddress(rtBuffer, 9) + + _screenStartStrip + (x / 8) + y * gdi._numStrips + gdi._imgBufOffs[z]; } + #pragma mark - #pragma mark --- Image drawing --- #pragma mark - @@ -1237,7 +1202,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int wi #if 0 // HACK: blit mask(s) onto normal screen. Useful to debug masking for (i = 0; i < numzbuf; i++) { - mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + y * _numStrips + x + _imgBufOffs[i]; + mask_ptr = _vm->getMaskBuffer(x, y, i); byte *dst = backbuff_ptr; byte *dst2 = bgbak_ptr; for (int h = 0; h < height; h++) { @@ -2026,7 +1991,7 @@ void Scumm::fadeIn(int effect) { void Scumm::fadeOut(int effect) { VirtScreen *vs; - setDirtyRange(0, 0, 0); + virtscr[0].setDirtyRange(0, 0); if (!(_features & GF_AFTER_V7)) camera._last.x = camera._cur.x; @@ -2049,7 +2014,7 @@ void Scumm::fadeOut(int effect) { break; case 129: // Just blit screen 0 to the display (i.e. display will be black) - setDirtyRange(0, 0, vs->height); + virtscr[0].setDirtyRange(0, vs->height); updateDirtyScreen(0); break; case 134: diff --git a/scumm/gfx.h b/scumm/gfx.h index c07e65d010..fc56a6789a 100644 --- a/scumm/gfx.h +++ b/scumm/gfx.h @@ -53,6 +53,13 @@ struct VirtScreen { /** Virtual screen areas */ uint16 bdirty[80]; byte *screenPtr; byte *backBuf; + + void setDirtyRange(int top, int bottom) { + for (int i = 0; i < 80; i++) { + tdirty[i] = top; + bdirty[i] = bottom; + } + } }; struct ColorCycle { /** Palette cycles */ diff --git a/scumm/nut_renderer.cpp b/scumm/nut_renderer.cpp index e41163749c..c8c0d92a18 100644 --- a/scumm/nut_renderer.cpp +++ b/scumm/nut_renderer.cpp @@ -197,8 +197,7 @@ void NutRenderer::drawChar(byte c, int32 x, int32 y, byte color, bool useMask) { color = cTable[i]; dst = _vm->virtscr[0].screenPtr + y * _vm->_screenWidth + x + _vm->virtscr[0].xstart; - mask = _vm->getResourceAddress(rtBuffer, 9) - + (y * _vm->_screenWidth + x) / 8 + _vm->_screenStartStrip; + mask = _vm->getMaskBuffer(x, y, 0); src = _tmpCodecBuffer; diff --git a/scumm/scumm.h b/scumm/scumm.h index bbcdf4e140..746c1ea18e 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -868,17 +868,12 @@ protected: public: void updateDirtyRect(int virt, int left, int right, int top, int bottom, int dirtybit); protected: - void setDirtyRange(int slot, int a, int height); void drawDirtyScreenParts(); void updateDirtyScreen(int slot); public: VirtScreen *findVirtScreen(int y); -protected: - void setVirtscreenDirty(VirtScreen *vs, int left, int top, int right, int bottom); - -public: - bool isMaskActiveAt(int l, int t, int r, int b, byte *mem); + byte *getMaskBuffer(int x, int y, int z); protected: void drawFlashlight(); |