diff options
author | Johannes Schickel | 2013-08-02 22:23:00 +0200 |
---|---|---|
committer | Johannes Schickel | 2013-08-03 02:52:31 +0200 |
commit | c05cb7f3bbcf4d64d4a938e0eb42065d8f3d3038 (patch) | |
tree | 1a2b4f8a216de2f2f742a9c9ef68b46c51603883 /engines | |
parent | 4790a4abd5c157254cab069bc34aa8ef8347f668 (diff) | |
download | scummvm-rg350-c05cb7f3bbcf4d64d4a938e0eb42065d8f3d3038.tar.gz scummvm-rg350-c05cb7f3bbcf4d64d4a938e0eb42065d8f3d3038.tar.bz2 scummvm-rg350-c05cb7f3bbcf4d64d4a938e0eb42065d8f3d3038.zip |
SCUMM: Prefer getBasePtr over direct Surface::pixels access.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/scumm/akos.cpp | 6 | ||||
-rw-r--r-- | engines/scumm/base-costume.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/bomp.cpp | 5 | ||||
-rw-r--r-- | engines/scumm/charset.cpp | 9 | ||||
-rw-r--r-- | engines/scumm/costume.cpp | 6 | ||||
-rw-r--r-- | engines/scumm/cursor.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/debugger.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/gfx.cpp | 14 | ||||
-rw-r--r-- | engines/scumm/gfx_towns.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/he/animation_he.cpp | 4 | ||||
-rw-r--r-- | engines/scumm/nut_renderer.cpp | 10 |
11 files changed, 35 insertions, 27 deletions
diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp index b6acf01050..481c4af432 100644 --- a/engines/scumm/akos.cpp +++ b/engines/scumm/akos.cpp @@ -994,7 +994,7 @@ byte AkosRenderer::codec1(int xmoveCur, int ymoveCur) { if (_draw_bottom < rect.bottom) _draw_bottom = rect.bottom; - v1.destptr = (byte *)_out.pixels + v1.y * _out.pitch + v1.x * _vm->_bytesPerPixel; + v1.destptr = (byte *)_out.getBasePtr(v1.x, v1.y); codec1_genericDecode(v1); @@ -1288,7 +1288,7 @@ byte AkosRenderer::codec16(int xmoveCur, int ymoveCur) { int32 numskip_before = skip_x + (skip_y * _width); int32 numskip_after = _width - cur_x; - byte *dst = (byte *)_out.pixels + height_unk * _out.pitch + width_unk * _vm->_bytesPerPixel; + byte *dst = (byte *)_out.getBasePtr(width_unk, height_unk); akos16Decompress(dst, _out.pitch, _srcptr, cur_x, out_height, dir, numskip_before, numskip_after, transparency, clip.left, clip.top, _zbuf); return 0; @@ -1358,7 +1358,7 @@ byte AkosRenderer::codec32(int xmoveCur, int ymoveCur) { palPtr = _vm->_hePalettes + _vm->_hePaletteSlot + 768; } - byte *dstPtr = (byte *)_out.pixels + dst.top * _out.pitch + dst.left * _vm->_bytesPerPixel; + byte *dstPtr = (byte *)_out.getBasePtr(dst.left, dst.top); if (_shadow_mode == 3) { Wiz::decompressWizImage<kWizXMap>(dstPtr, _out.pitch, kDstScreen, _srcptr, src, 0, palPtr, xmap, _vm->_bytesPerPixel); } else { diff --git a/engines/scumm/base-costume.cpp b/engines/scumm/base-costume.cpp index 46c68c81b0..ff9058538b 100644 --- a/engines/scumm/base-costume.cpp +++ b/engines/scumm/base-costume.cpp @@ -38,7 +38,7 @@ byte BaseCostumeRenderer::drawCostume(const VirtScreen &vs, int numStrips, const _actorX += _vm->_virtscr[kMainVirtScreen].xstart & 7; _out.w = _out.pitch / _vm->_bytesPerPixel; - _out.pixels = (byte *)_out.pixels - (_vm->_virtscr[kMainVirtScreen].xstart & 7); + _out.pixels = (byte *)_out.getBasePtr(-(_vm->_virtscr[kMainVirtScreen].xstart & 7), 0); _numStrips = numStrips; diff --git a/engines/scumm/bomp.cpp b/engines/scumm/bomp.cpp index 845cf70722..5b87f3042c 100644 --- a/engines/scumm/bomp.cpp +++ b/engines/scumm/bomp.cpp @@ -231,7 +231,10 @@ void drawBomp(const BompDrawData &bd) { } src = bd.src; - dst = (byte *)bd.dst.pixels + bd.y * bd.dst.pitch + (bd.x + clip.left); + // FIXME: This gets passed a const destination Surface. Intuitively this + // should never get written to. But sadly it does... For now we simply + // cast the const qualifier away. + dst = (byte *)const_cast<void *>(bd.dst.getBasePtr((bd.x + clip.left), bd.y)); const byte maskbit = revBitMask((bd.x + clip.left) & 7); diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp index 9ae75b6683..6e289b2afc 100644 --- a/engines/scumm/charset.cpp +++ b/engines/scumm/charset.cpp @@ -799,7 +799,7 @@ void CharsetRendererClassic::printCharIntern(bool is2byte, const byte *charPtr, if (ignoreCharsetMask || !vs->hasTwoBuffers) { dstPtr = vs->getPixels(0, 0); } else { - dstPtr = (byte *)_vm->_textSurface.pixels; + dstPtr = (byte *)_vm->_textSurface.getBasePtr(0, 0); } if (_blitAlso && vs->hasTwoBuffers) { @@ -829,7 +829,7 @@ void CharsetRendererClassic::printCharIntern(bool is2byte, const byte *charPtr, dstPtr = vs->getPixels(_left, drawTop); } else { dstSurface = _vm->_textSurface; - dstPtr = (byte *)_vm->_textSurface.pixels + (_top - _vm->_screenTop) * _vm->_textSurface.pitch * _vm->_textSurfaceMultiplier + _left * _vm->_textSurfaceMultiplier; + dstPtr = (byte *)_vm->_textSurface.getBasePtr(_left * _vm->_textSurfaceMultiplier, (_top - _vm->_screenTop) * _vm->_textSurfaceMultiplier); } if (_blitAlso && vs->hasTwoBuffers) { @@ -907,7 +907,7 @@ bool CharsetRendererClassic::prepareDraw(uint16 chr) { void CharsetRendererClassic::drawChar(int chr, Graphics::Surface &s, int x, int y) { if (!prepareDraw(chr)) return; - byte *dst = (byte *)s.pixels + y * s.pitch + x; + byte *dst = (byte *)s.getBasePtr(x, y); drawBitsN(s, dst, _charPtr, *_fontPtr, y, _width, _height); } @@ -1242,7 +1242,6 @@ void CharsetRendererNut::printChar(int chr, bool ignoreCharsetMask) { if (ignoreCharsetMask) { VirtScreen *vs = &_vm->_virtscr[kMainVirtScreen]; s = *vs; - s.pixels = vs->getPixels(0, 0); } else { s = _vm->_textSurface; drawTop -= _vm->_screenTop; @@ -1401,7 +1400,7 @@ void CharsetRendererTownsClassic::drawBitsN(const Graphics::Surface&, byte *dst, } bool scale2x = (_vm->_textSurfaceMultiplier == 2); - dst = (byte *)_vm->_textSurface.pixels + (_top - _vm->_screenTop) * _vm->_textSurface.pitch * _vm->_textSurfaceMultiplier + _left * _vm->_textSurfaceMultiplier; + dst = (byte *)_vm->_textSurface.getBasePtr(_left * _vm->_textSurfaceMultiplier, (_top - _vm->_screenTop) * _vm->_textSurfaceMultiplier); int y, x; int color; diff --git a/engines/scumm/costume.cpp b/engines/scumm/costume.cpp index 4ebdd00fdc..85c60f9a40 100644 --- a/engines/scumm/costume.cpp +++ b/engines/scumm/costume.cpp @@ -293,7 +293,7 @@ byte ClassicCostumeRenderer::mainRoutine(int xmoveCur, int ymoveCur) { return 2; } - v1.destptr = (byte *)_out.pixels + v1.y * _out.pitch + v1.x * _vm->_bytesPerPixel; + v1.destptr = (byte *)_out.getBasePtr(v1.x, v1.y); v1.mask_ptr = _vm->getMaskBuffer(0, v1.y, _zbuf); @@ -826,7 +826,7 @@ byte NESCostumeRenderer::drawLimb(const Actor *a, int limb) { int my = _actorY + y + ty; int mx = _actorX + x + tx; if (!(_zbuf && (maskBuf[my * _numStrips + mx / 8] & revBitMask(mx & 7)))) - *((byte *)_out.pixels + my * _out.pitch + mx) = palette[c]; + *((byte *)_out.getBasePtr(mx, my)) = palette[c]; } } } @@ -1238,7 +1238,7 @@ byte V0CostumeRenderer::drawLimb(const Actor *a, int limb) { int destY = ypos + y; if (destY >= 0 && destY < _out.h && destX >= 0 && destX < _out.w) { - byte *dst = (byte *)_out.pixels + destY * _out.pitch + destX; + byte *dst = (byte *)_out.getBasePtr(destX, destY); byte *mask = _vm->getMaskBuffer(0, destY, _zbuf); if (a0->_limb_flipped[limb]) { LINE(0, 0); LINE(2, 2); LINE(4, 4); LINE(6, 6); diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 269ae9e10a..3eb7246b3a 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -139,7 +139,7 @@ void ScummEngine_v6::grabCursor(int x, int y, int w, int h) { return; } - setCursorFromBuffer((byte *)vs->pixels + (y - vs->topline) * vs->pitch + x, w, h, vs->pitch); + setCursorFromBuffer((byte *)vs->getBasePtr(x, y - vs->topline), w, h, vs->pitch); } void ScummEngine_v6::setDefaultCursor() { diff --git a/engines/scumm/debugger.cpp b/engines/scumm/debugger.cpp index 9b6dd1e687..5e5719d6bc 100644 --- a/engines/scumm/debugger.cpp +++ b/engines/scumm/debugger.cpp @@ -641,7 +641,7 @@ static void hlineColor(ScummEngine *scumm, int x1, int x2, int y, byte color) { x2 = right - 1; - ptr = (byte *)vs->pixels + x1 + y * vs->pitch; + ptr = (byte *)vs->getBasePtr(y, x1); while (x1++ <= x2) { *ptr++ = color; diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index 50ff0b3988..41899da0a3 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -422,7 +422,7 @@ void ScummEngine::initVirtScreen(VirtScreenNumber slot, int top, int width, int _res->createResource(rtBuffer, slot + 1, size); vs->pixels = getResourceAddress(rtBuffer, slot + 1); - memset(vs->pixels, 0, size); // reset background + memset(vs->getPixels(0, 0), 0, size); // reset background if (twobufs) { vs->backBuf = _res->createResource(rtBuffer, slot + 5, size); @@ -612,7 +612,7 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i // Some paranoia checks assert(top >= 0 && bottom <= vs->h); assert(x >= 0 && width <= vs->pitch); - assert(_textSurface.pixels); + assert(_textSurface.getBasePtr(0, 0)); // Perform some clipping if (width > vs->w - x) @@ -1135,7 +1135,7 @@ void ScummEngine::clearTextSurface() { _townsScreen->fillLayerRect(1, 0, 0, _textSurface.w, _textSurface.h, 0); #endif - fill((byte *)_textSurface.pixels, _textSurface.pitch, + fill((byte *)_textSurface.getBasePtr(0, 0), _textSurface.pitch, #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE _game.platform == Common::kPlatformFMTowns ? 0 : #endif @@ -1590,7 +1590,7 @@ void GdiV2::prepareDrawBitmap(const byte *ptr, VirtScreen *vs, if (vs->hasTwoBuffers) dst = vs->backBuf + y * vs->pitch + x * 8; else - dst = (byte *)vs->pixels + y * vs->pitch + x * 8; + dst = (byte *)vs->getPixels(x * 8, y); mask_ptr = getMaskBuffer(x, y, 1); @@ -1827,7 +1827,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, const int y, const if (vs->hasTwoBuffers) dstPtr = vs->backBuf + y * vs->pitch + (x * 8 * vs->format.bytesPerPixel); else - dstPtr = (byte *)vs->pixels + y * vs->pitch + (x * 8 * vs->format.bytesPerPixel); + dstPtr = (byte *)vs->getPixels(x * 8, y); transpStrip = drawStrip(dstPtr, vs, x, y, width, height, stripnr, smap_ptr); @@ -1836,7 +1836,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, const int y, const transpStrip = true; if (vs->hasTwoBuffers) { - byte *frontBuf = (byte *)vs->pixels + y * vs->pitch + (x * 8 * vs->format.bytesPerPixel); + byte *frontBuf = (byte *)vs->getPixels(x * 8, y); if (lightsOn) copy8Col(frontBuf, vs->pitch, dstPtr, height, vs->format.bytesPerPixel); else @@ -2262,7 +2262,7 @@ void Gdi::resetBackground(int top, int bottom, int strip) { vs->bdirty[strip] = bottom; bgbak_ptr = (byte *)vs->backBuf + top * vs->pitch + (strip + vs->xstart/8) * 8 * vs->format.bytesPerPixel; - backbuff_ptr = (byte *)vs->pixels + top * vs->pitch + (strip + vs->xstart/8) * 8 * vs->format.bytesPerPixel; + backbuff_ptr = (byte *)vs->getPixels((strip + vs->xstart/8) * 8, top); numLinesToProcess = bottom - top; if (numLinesToProcess) { diff --git a/engines/scumm/gfx_towns.cpp b/engines/scumm/gfx_towns.cpp index f86a4e56d5..a803b6e511 100644 --- a/engines/scumm/gfx_towns.cpp +++ b/engines/scumm/gfx_towns.cpp @@ -34,7 +34,7 @@ void ScummEngine::towns_drawStripToScreen(VirtScreen *vs, int dstX, int dstY, in if (width <= 0 || height <= 0) return; - assert(_textSurface.pixels); + assert(_textSurface.getBasePtr(0, 0)); int m = _textSurfaceMultiplier; diff --git a/engines/scumm/he/animation_he.cpp b/engines/scumm/he/animation_he.cpp index be17a3b305..7ae5547702 100644 --- a/engines/scumm/he/animation_he.cpp +++ b/engines/scumm/he/animation_he.cpp @@ -90,7 +90,7 @@ void MoviePlayer::copyFrameToBuffer(byte *dst, int dstType, uint x, uint y, uint if (!surface) return; - byte *src = (byte *)surface->pixels; + const byte *src = (const byte *)surface->getBasePtr(0, 0); if (_video->hasDirtyPalette()) _vm->setPaletteFromPtr(_video->getPalette(), 256); @@ -119,7 +119,7 @@ void MoviePlayer::copyFrameToBuffer(byte *dst, int dstType, uint x, uint y, uint dst += y * pitch + x * 2; do { for (uint i = 0; i < w; i++) { - uint16 color = *((uint16 *)src + i); + uint16 color = *((const uint16 *)src + i); switch (dstType) { case kDstScreen: WRITE_UINT16(dst + i * 2, color); diff --git a/engines/scumm/nut_renderer.cpp b/engines/scumm/nut_renderer.cpp index 048b29d68b..d9f0b412e1 100644 --- a/engines/scumm/nut_renderer.cpp +++ b/engines/scumm/nut_renderer.cpp @@ -357,7 +357,10 @@ void NutRenderer::drawFrame(byte *dst, int c, int x, int y) { } void NutRenderer::drawChar(const Graphics::Surface &s, byte c, int x, int y, byte color) { - byte *dst = (byte *)s.pixels + y * s.pitch + x; + // FIXME: This gets passed a const destination Surface. Intuitively this + // should never get written to. But sadly it does... For now we simply + // cast the const qualifier away. + byte *dst = (byte *)const_cast<void *>(s.getBasePtr(x, y)); const int width = MIN((int)_chars[c].width, s.w - x); const int height = MIN((int)_chars[c].height, s.h - y); const byte *src = unpackChar(c); @@ -391,7 +394,10 @@ void NutRenderer::drawChar(const Graphics::Surface &s, byte c, int x, int y, byt } void NutRenderer::draw2byte(const Graphics::Surface &s, int c, int x, int y, byte color) { - byte *dst = (byte *)s.pixels + y * s.pitch + x; + // FIXME: This gets passed a const destination Surface. Intuitively this + // should never get written to. But sadly it does... For now we simply + // cast the const qualifier away. + byte *dst = (byte *)const_cast<void *>(s.getBasePtr(x, y)); const int width = _vm->_2byteWidth; const int height = MIN(_vm->_2byteHeight, s.h - y); const byte *src = _vm->get2byteCharPtr(c); |