From 9d7f7fc4b625918340ad3a081e44526a583e0ee0 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 17 Apr 2011 16:30:59 +0200 Subject: SCUMM: Prefer Surface::create taking a PixelFormat over the one taking a byte depth. --- engines/scumm/scumm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/scumm') diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 5aea36ef66..33343aef81 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -1222,7 +1222,7 @@ void ScummEngine::setupScumm() { setupCharsetRenderer(); // Create and clear the text surface - _textSurface.create(_screenWidth * _textSurfaceMultiplier, _screenHeight * _textSurfaceMultiplier, 1); + _textSurface.create(_screenWidth * _textSurfaceMultiplier, _screenHeight * _textSurfaceMultiplier, Graphics::PixelFormat::createFormatCLUT8()); clearTextSurface(); // Create the costume renderer -- cgit v1.2.3 From b0bd8fa7956ca78b65d2e5690b8dda2f842585c0 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 17 Apr 2011 17:29:09 +0200 Subject: SCUMM: Prefer Surface::format over Surface::bytesPerPixel. --- engines/scumm/charset.cpp | 16 ++++---- engines/scumm/cursor.cpp | 1 + engines/scumm/gfx.cpp | 90 +++++++++++++++++++++++---------------------- engines/scumm/gfx.h | 4 +- engines/scumm/gfx_towns.cpp | 2 +- 5 files changed, 58 insertions(+), 55 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp index 861e448221..0246a255f9 100644 --- a/engines/scumm/charset.cpp +++ b/engines/scumm/charset.cpp @@ -777,7 +777,7 @@ void CharsetRendererV3::printChar(int chr, bool ignoreCharsetMask) { (ignoreCharsetMask || !vs->hasTwoBuffers)) { dst = vs->getPixels(_left, drawTop); if (charPtr) - drawBits1(*vs, dst, charPtr, drawTop, origWidth, origHeight, vs->bytesPerPixel); + drawBits1(*vs, dst, charPtr, drawTop, origWidth, origHeight, vs->format.bytesPerPixel); #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE else if (_vm->_cjkFont) _vm->_cjkFont->drawChar(vs, chr, _left, drawTop, _color, _shadowColor); @@ -785,7 +785,7 @@ void CharsetRendererV3::printChar(int chr, bool ignoreCharsetMask) { } else { dst = (byte *)_vm->_textSurface.getBasePtr(_left * _vm->_textSurfaceMultiplier, _top * _vm->_textSurfaceMultiplier); if (charPtr) - drawBits1(_vm->_textSurface, dst, charPtr, drawTop, origWidth, origHeight, _vm->_textSurface.bytesPerPixel, (_vm->_textSurfaceMultiplier == 2 && !is2byte)); + drawBits1(_vm->_textSurface, dst, charPtr, drawTop, origWidth, origHeight, _vm->_textSurface.format.bytesPerPixel, (_vm->_textSurfaceMultiplier == 2 && !is2byte)); #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE else if (_vm->_cjkFont) _vm->_cjkFont->drawChar(_vm->_textSurface, chr, _left * _vm->_textSurfaceMultiplier, _top * _vm->_textSurfaceMultiplier, _color, _shadowColor); @@ -834,7 +834,7 @@ void CharsetRendererV3::drawChar(int chr, Graphics::Surface &s, int x, int y) { height = 8; } dst = (byte *)s.pixels + y * s.pitch + x; - drawBits1(s, dst, charPtr, y, width, height, s.bytesPerPixel); + drawBits1(s, dst, charPtr, y, width, height, s.format.bytesPerPixel); } void CharsetRenderer::translateColor() { @@ -1096,7 +1096,7 @@ void CharsetRendererClassic::printCharIntern(bool is2byte, const byte *charPtr, } else #endif if (is2byte) { - drawBits1(dstSurface, dstPtr, charPtr, drawTop, origWidth, origHeight, dstSurface.bytesPerPixel); + drawBits1(dstSurface, dstPtr, charPtr, drawTop, origWidth, origHeight, dstSurface.format.bytesPerPixel); } else { drawBitsN(dstSurface, dstPtr, charPtr, *_fontPtr, drawTop, origWidth, origHeight, _vm->_textSurfaceMultiplier == 2); } @@ -1173,7 +1173,7 @@ void CharsetRendererClassic::drawChar(int chr, Graphics::Surface &s, int x, int dst = (byte *)s.pixels + y * s.pitch + x; if (is2byte) { - drawBits1(s, dst, charPtr, y, width, height, s.bytesPerPixel); + drawBits1(s, dst, charPtr, y, width, height, s.format.bytesPerPixel); } else { drawBitsN(s, dst, charPtr, *_fontPtr, y, width, height); } @@ -1519,10 +1519,10 @@ void CharsetRendererNES::printChar(int chr, bool ignoreCharsetMask) { if (ignoreCharsetMask || !vs->hasTwoBuffers) { dst = vs->getPixels(_left, drawTop); - drawBits1(*vs, dst, charPtr, drawTop, origWidth, origHeight, vs->bytesPerPixel); + drawBits1(*vs, dst, charPtr, drawTop, origWidth, origHeight, vs->format.bytesPerPixel); } else { dst = (byte *)_vm->_textSurface.pixels + _top * _vm->_textSurface.pitch + _left; - drawBits1(_vm->_textSurface, dst, charPtr, drawTop, origWidth, origHeight, _vm->_textSurface.bytesPerPixel); + drawBits1(_vm->_textSurface, dst, charPtr, drawTop, origWidth, origHeight, _vm->_textSurface.format.bytesPerPixel); } if (_str.left > _left) @@ -1552,7 +1552,7 @@ void CharsetRendererNES::drawChar(int chr, Graphics::Surface &s, int x, int y) { height = 8; dst = (byte *)s.pixels + y * s.pitch + x; - drawBits1(s, dst, charPtr, y, width, height, s.bytesPerPixel); + drawBits1(s, dst, charPtr, y, width, height, s.format.bytesPerPixel); } void CharsetRendererNES::drawBits1(const Graphics::Surface &s, byte *dst, const byte *src, int drawTop, int width, int height, uint8 bitDepth, bool scalex) { diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index bb3c4bcc02..7380cfe2ea 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -386,6 +386,7 @@ void ScummEngine_v5::redefineBuiltinCursorFromChar(int index, int chr) { // s.h = 17 for FM-TOWNS Loom Japanese. Fixes bug #1166917 assert(s.w <= 16 && s.h <= 17); s.bytesPerPixel = 1; + s.format = Graphics::PixelFormat::createFormatCLUT8(); _charset->drawChar(chr, s, 0, 0); diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index a6a97ec426..876d6bf8ff 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -385,8 +385,10 @@ void ScummEngine::initVirtScreen(VirtScreenNumber slot, int top, int width, int vs->hasTwoBuffers = twobufs; vs->xstart = 0; vs->backBuf = NULL; - vs->bytesPerPixel = (_game.features & GF_16BIT_COLOR) ? 2 : 1; - vs->pitch = width * vs->bytesPerPixel; + // TODO: This should really rather setup the correct format instead of + // only setting the bytes per pixel. + vs->bytesPerPixel = vs->format.bytesPerPixel = (_game.features & GF_16BIT_COLOR) ? 2 : 1; + vs->pitch = width * vs->format.bytesPerPixel; if (_game.version >= 7) { // Increase the pitch by one; needed to accomodate the extra screen @@ -622,7 +624,7 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i int m = _textSurfaceMultiplier; int vsPitch; int pitch = vs->pitch; - vsPitch = vs->pitch - width * vs->bytesPerPixel; + vsPitch = vs->pitch - width * vs->format.bytesPerPixel; if (_game.version < 7) { @@ -667,7 +669,7 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i } else { WRITE_UINT16(dstPtr, _16BitPalette[tmp]); dstPtr += 2; } - srcPtr += vs->bytesPerPixel; + srcPtr += vs->format.bytesPerPixel; } srcPtr += vsPitch; textPtr += _textSurface.pitch - width * m; @@ -706,7 +708,7 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i } #endif src = _compositeBuf; - pitch = width * vs->bytesPerPixel; + pitch = width * vs->format.bytesPerPixel; if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { ditherHerc(_compositeBuf, _herculesBuf, width, &x, &y, &width, &height); @@ -1036,17 +1038,17 @@ void ScummEngine::restoreBackground(Common::Rect rect, byte backColor) { return; if (vs->hasTwoBuffers && _currentRoom != 0 && isLightOn()) { - blit(screenBuf, vs->pitch, vs->getBackPixels(rect.left, rect.top), vs->pitch, width, height, vs->bytesPerPixel); + blit(screenBuf, vs->pitch, vs->getBackPixels(rect.left, rect.top), vs->pitch, width, height, vs->format.bytesPerPixel); if (vs->number == kMainVirtScreen && _charset->_hasMask) { #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE if (_game.platform == Common::kPlatformFMTowns) { byte *mask = (byte *)_textSurface.getBasePtr(rect.left * _textSurfaceMultiplier, (rect.top + vs->topline) * _textSurfaceMultiplier); - fill(mask, _textSurface.pitch, 0, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.bytesPerPixel); + fill(mask, _textSurface.pitch, 0, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.format.bytesPerPixel); } else #endif { byte *mask = (byte *)_textSurface.getBasePtr(rect.left, rect.top - _screenTop); - fill(mask, _textSurface.pitch, CHARSET_MASK_TRANSPARENCY, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.bytesPerPixel); + fill(mask, _textSurface.pitch, CHARSET_MASK_TRANSPARENCY, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.format.bytesPerPixel); } } } else { @@ -1054,14 +1056,14 @@ void ScummEngine::restoreBackground(Common::Rect rect, byte backColor) { if (_game.platform == Common::kPlatformFMTowns) { backColor |= (backColor << 4); byte *mask = (byte *)_textSurface.getBasePtr(rect.left * _textSurfaceMultiplier, (rect.top + vs->topline) * _textSurfaceMultiplier); - fill(mask, _textSurface.pitch, backColor, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.bytesPerPixel); + fill(mask, _textSurface.pitch, backColor, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.format.bytesPerPixel); } #endif if (_game.features & GF_16BIT_COLOR) - fill(screenBuf, vs->pitch, _16BitPalette[backColor], width, height, vs->bytesPerPixel); + fill(screenBuf, vs->pitch, _16BitPalette[backColor], width, height, vs->format.bytesPerPixel); else - fill(screenBuf, vs->pitch, backColor, width, height, vs->bytesPerPixel); + fill(screenBuf, vs->pitch, backColor, width, height, vs->format.bytesPerPixel); } } @@ -1090,7 +1092,7 @@ void ScummEngine::restoreCharsetBg() { if (vs->number != kMainVirtScreen) { // Restore from back buffer const byte *backBuf = vs->getBackPixels(0, 0); - blit(screenBuf, vs->pitch, backBuf, vs->pitch, vs->w, vs->h, vs->bytesPerPixel); + blit(screenBuf, vs->pitch, backBuf, vs->pitch, vs->w, vs->h, vs->format.bytesPerPixel); } } else { // Clear area @@ -1118,7 +1120,7 @@ void ScummEngine::clearTextSurface() { #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE _game.platform == Common::kPlatformFMTowns ? 0 : #endif - CHARSET_MASK_TRANSPARENCY, _textSurface.w, _textSurface.h, _textSurface.bytesPerPixel); + CHARSET_MASK_TRANSPARENCY, _textSurface.w, _textSurface.h, _textSurface.format.bytesPerPixel); } byte *ScummEngine::getMaskBuffer(int x, int y, int z) { @@ -1291,56 +1293,56 @@ void ScummEngine::drawBox(int x, int y, int x2, int y2, int color) { if (vs->number != kMainVirtScreen) error("can only copy bg to main window"); - blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height, vs->bytesPerPixel); + blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height, vs->format.bytesPerPixel); if (_charset->_hasMask) { byte *mask = (byte *)_textSurface.getBasePtr(x * _textSurfaceMultiplier, (y - _screenTop) * _textSurfaceMultiplier); - fill(mask, _textSurface.pitch, CHARSET_MASK_TRANSPARENCY, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.bytesPerPixel); + fill(mask, _textSurface.pitch, CHARSET_MASK_TRANSPARENCY, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.format.bytesPerPixel); } } } else if (_game.heversion >= 72) { // Flags are used for different methods in HE games uint32 flags = color; if ((flags & 0x2000) || (flags & 0x4000000)) { - blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height, vs->bytesPerPixel); + blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height, vs->format.bytesPerPixel); } else if ((flags & 0x4000) || (flags & 0x2000000)) { - blit(bgbuff, vs->pitch, backbuff, vs->pitch, width, height, vs->bytesPerPixel); + blit(bgbuff, vs->pitch, backbuff, vs->pitch, width, height, vs->format.bytesPerPixel); } else if ((flags & 0x8000) || (flags & 0x1000000)) { flags &= (flags & 0x1000000) ? 0xFFFFFF : 0x7FFF; - fill(backbuff, vs->pitch, flags, width, height, vs->bytesPerPixel); - fill(bgbuff, vs->pitch, flags, width, height, vs->bytesPerPixel); + fill(backbuff, vs->pitch, flags, width, height, vs->format.bytesPerPixel); + fill(bgbuff, vs->pitch, flags, width, height, vs->format.bytesPerPixel); } else { - fill(backbuff, vs->pitch, flags, width, height, vs->bytesPerPixel); + fill(backbuff, vs->pitch, flags, width, height, vs->format.bytesPerPixel); } } else if (_game.heversion >= 60) { // Flags are used for different methods in HE games uint16 flags = color; if (flags & 0x2000) { - blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height, vs->bytesPerPixel); + blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height, vs->format.bytesPerPixel); } else if (flags & 0x4000) { - blit(bgbuff, vs->pitch, backbuff, vs->pitch, width, height, vs->bytesPerPixel); + blit(bgbuff, vs->pitch, backbuff, vs->pitch, width, height, vs->format.bytesPerPixel); } else if (flags & 0x8000) { flags &= 0x7FFF; - fill(backbuff, vs->pitch, flags, width, height, vs->bytesPerPixel); - fill(bgbuff, vs->pitch, flags, width, height, vs->bytesPerPixel); + fill(backbuff, vs->pitch, flags, width, height, vs->format.bytesPerPixel); + fill(bgbuff, vs->pitch, flags, width, height, vs->format.bytesPerPixel); } else { - fill(backbuff, vs->pitch, flags, width, height, vs->bytesPerPixel); + fill(backbuff, vs->pitch, flags, width, height, vs->format.bytesPerPixel); } } else { if (_game.features & GF_16BIT_COLOR) { - fill(backbuff, vs->pitch, _16BitPalette[color], width, height, vs->bytesPerPixel); + fill(backbuff, vs->pitch, _16BitPalette[color], width, height, vs->format.bytesPerPixel); } else { #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE if (_game.platform == Common::kPlatformFMTowns) { color = ((color & 0x0f) << 4) | (color & 0x0f); byte *mask = (byte *)_textSurface.getBasePtr(x * _textSurfaceMultiplier, (y - _screenTop + vs->topline) * _textSurfaceMultiplier); - fill(mask, _textSurface.pitch, color, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.bytesPerPixel); + fill(mask, _textSurface.pitch, color, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.format.bytesPerPixel); if (_game.id == GID_MONKEY2 || _game.id == GID_INDY4 || ((_game.id == GID_INDY3 || _game.id == GID_ZAK) && vs->number != kTextVirtScreen) || (_game.id == GID_LOOM && vs->number == kMainVirtScreen)) return; } #endif - fill(backbuff, vs->pitch, color, width, height, vs->bytesPerPixel); + fill(backbuff, vs->pitch, color, width, height, vs->format.bytesPerPixel); } } } @@ -1379,7 +1381,7 @@ void ScummEngine_v5::drawFlashlight() { _flashlight.y, _flashlight.y + _flashlight.h, USAGE_BIT_DIRTY); if (_flashlight.buffer) { - fill(_flashlight.buffer, vs->pitch, 0, _flashlight.w, _flashlight.h, vs->bytesPerPixel); + fill(_flashlight.buffer, vs->pitch, 0, _flashlight.w, _flashlight.h, vs->format.bytesPerPixel); } _flashlight.isDrawn = false; } @@ -1426,20 +1428,20 @@ void ScummEngine_v5::drawFlashlight() { _flashlight.buffer = vs->getPixels(_flashlight.x, _flashlight.y); bgbak = vs->getBackPixels(_flashlight.x, _flashlight.y); - blit(_flashlight.buffer, vs->pitch, bgbak, vs->pitch, _flashlight.w, _flashlight.h, vs->bytesPerPixel); + blit(_flashlight.buffer, vs->pitch, bgbak, vs->pitch, _flashlight.w, _flashlight.h, vs->format.bytesPerPixel); // Round the corners. To do so, we simply hard-code a set of nicely // rounded corners. static const int corner_data[] = { 8, 6, 4, 3, 2, 2, 1, 1 }; int minrow = 0; - int maxcol = (_flashlight.w - 1) * vs->bytesPerPixel; + int maxcol = (_flashlight.w - 1) * vs->format.bytesPerPixel; int maxrow = (_flashlight.h - 1) * vs->pitch; for (i = 0; i < 8; i++, minrow += vs->pitch, maxrow -= vs->pitch) { int d = corner_data[i]; for (j = 0; j < d; j++) { - if (vs->bytesPerPixel == 2) { + if (vs->format.bytesPerPixel == 2) { WRITE_UINT16(&_flashlight.buffer[minrow + 2 * j], 0); WRITE_UINT16(&_flashlight.buffer[minrow + maxcol - 2 * j], 0); WRITE_UINT16(&_flashlight.buffer[maxrow + 2 * j], 0); @@ -1755,7 +1757,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, const int y, const } #endif - _vertStripNextInc = height * vs->pitch - 1 * vs->bytesPerPixel; + _vertStripNextInc = height * vs->pitch - 1 * vs->format.bytesPerPixel; _objectMode = (flag & dbObjectMode) == dbObjectMode; prepareDrawBitmap(ptr, vs, x, y, width, height, stripnr, numstrip); @@ -1788,9 +1790,9 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, const int y, const // In the case of a double buffered virtual screen, we draw to // the backbuffer, otherwise to the primary surface memory. if (vs->hasTwoBuffers) - dstPtr = vs->backBuf + y * vs->pitch + (x * 8 * vs->bytesPerPixel); + dstPtr = vs->backBuf + y * vs->pitch + (x * 8 * vs->format.bytesPerPixel); else - dstPtr = (byte *)vs->pixels + y * vs->pitch + (x * 8 * vs->bytesPerPixel); + dstPtr = (byte *)vs->pixels + y * vs->pitch + (x * 8 * vs->format.bytesPerPixel); transpStrip = drawStrip(dstPtr, vs, x, y, width, height, stripnr, smap_ptr); @@ -1799,11 +1801,11 @@ 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->bytesPerPixel); + byte *frontBuf = (byte *)vs->pixels + y * vs->pitch + (x * 8 * vs->format.bytesPerPixel); if (lightsOn) - copy8Col(frontBuf, vs->pitch, dstPtr, height, vs->bytesPerPixel); + copy8Col(frontBuf, vs->pitch, dstPtr, height, vs->format.bytesPerPixel); else - clear8Col(frontBuf, vs->pitch, height, vs->bytesPerPixel); + clear8Col(frontBuf, vs->pitch, height, vs->format.bytesPerPixel); } decodeMask(x, y, width, height, stripnr, numzbuf, zplane_list, transpStrip, flag, tmsk_ptr); @@ -2039,7 +2041,7 @@ void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs) { drawStripHE(dst, vs->pitch, bmap_ptr, vs->w, vs->h, true); break; case 150: - fill(dst, vs->pitch, *bmap_ptr, vs->w, vs->h, vs->bytesPerPixel); + fill(dst, vs->pitch, *bmap_ptr, vs->w, vs->h, vs->format.bytesPerPixel); break; default: // Alternative russian freddi3 uses badly formatted bitmaps @@ -2150,7 +2152,7 @@ void ScummEngine_v70he::restoreBackgroundHE(Common::Rect rect, int dirtybit) { assert(rw <= _screenWidth && rw > 0); assert(rh <= _screenHeight && rh > 0); - blit(dst, _virtscr[kMainVirtScreen].pitch, src, _virtscr[kMainVirtScreen].pitch, rw, rh, vs->bytesPerPixel); + blit(dst, _virtscr[kMainVirtScreen].pitch, src, _virtscr[kMainVirtScreen].pitch, rw, rh, vs->format.bytesPerPixel); markRectAsDirty(kMainVirtScreen, rect, dirtybit); } #endif @@ -2180,15 +2182,15 @@ void Gdi::resetBackground(int top, int bottom, int strip) { if (bottom > vs->bdirty[strip]) vs->bdirty[strip] = bottom; - bgbak_ptr = (byte *)vs->backBuf + top * vs->pitch + (strip + vs->xstart/8) * 8 * vs->bytesPerPixel; - backbuff_ptr = (byte *)vs->pixels + top * vs->pitch + (strip + vs->xstart/8) * 8 * vs->bytesPerPixel; + 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; numLinesToProcess = bottom - top; if (numLinesToProcess) { if (_vm->isLightOn()) { - copy8Col(backbuff_ptr, vs->pitch, bgbak_ptr, numLinesToProcess, vs->bytesPerPixel); + copy8Col(backbuff_ptr, vs->pitch, bgbak_ptr, numLinesToProcess, vs->format.bytesPerPixel); } else { - clear8Col(backbuff_ptr, vs->pitch, numLinesToProcess, vs->bytesPerPixel); + clear8Col(backbuff_ptr, vs->pitch, numLinesToProcess, vs->format.bytesPerPixel); } } } diff --git a/engines/scumm/gfx.h b/engines/scumm/gfx.h index c6062ef9be..3f69d75efd 100644 --- a/engines/scumm/gfx.h +++ b/engines/scumm/gfx.h @@ -158,11 +158,11 @@ struct VirtScreen : Graphics::Surface { } byte *getPixels(int x, int y) const { - return (byte *)pixels + y * pitch + (xstart + x) * bytesPerPixel; + return (byte *)pixels + y * pitch + (xstart + x) * format.bytesPerPixel; } byte *getBackPixels(int x, int y) const { - return (byte *)backBuf + y * pitch + (xstart + x) * bytesPerPixel; + return (byte *)backBuf + y * pitch + (xstart + x) * format.bytesPerPixel; } }; diff --git a/engines/scumm/gfx_towns.cpp b/engines/scumm/gfx_towns.cpp index abf2da63a6..78c7ef23f1 100644 --- a/engines/scumm/gfx_towns.cpp +++ b/engines/scumm/gfx_towns.cpp @@ -48,7 +48,7 @@ void ScummEngine::towns_drawStripToScreen(VirtScreen *vs, int dstX, int dstY, in int dp1 = _townsScreen->getLayerPitch(0) - width * _townsScreen->getLayerBpp(0); int dp2 = _townsScreen->getLayerPitch(1) - width * m * _townsScreen->getLayerBpp(1); - int sp1 = vs->pitch - (width * vs->bytesPerPixel); + int sp1 = vs->pitch - (width * vs->format.bytesPerPixel); int sp2 = _textSurface.pitch - width * m; if (vs->number == kMainVirtScreen || _game.id == GID_INDY3 || _game.id == GID_ZAK) { -- cgit v1.2.3 From da734a4af024a72ee155bc25d6e45f994de6b060 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 17 Apr 2011 21:27:34 +0200 Subject: ALL/GRAPHICS: Remove Surface::bytesPerPixel. --- engines/scumm/cursor.cpp | 1 - engines/scumm/gfx.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 7380cfe2ea..820605924c 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -385,7 +385,6 @@ void ScummEngine_v5::redefineBuiltinCursorFromChar(int index, int chr) { s.pitch = s.w; // s.h = 17 for FM-TOWNS Loom Japanese. Fixes bug #1166917 assert(s.w <= 16 && s.h <= 17); - s.bytesPerPixel = 1; s.format = Graphics::PixelFormat::createFormatCLUT8(); _charset->drawChar(chr, s, 0, 0); diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index 876d6bf8ff..0472e16928 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -387,7 +387,7 @@ void ScummEngine::initVirtScreen(VirtScreenNumber slot, int top, int width, int vs->backBuf = NULL; // TODO: This should really rather setup the correct format instead of // only setting the bytes per pixel. - vs->bytesPerPixel = vs->format.bytesPerPixel = (_game.features & GF_16BIT_COLOR) ? 2 : 1; + vs->format.bytesPerPixel = (_game.features & GF_16BIT_COLOR) ? 2 : 1; vs->pitch = width * vs->format.bytesPerPixel; if (_game.version >= 7) { -- cgit v1.2.3 From 53d982b24f9cec69e6ce35ccaab7ad1a62556c5b Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 18 Apr 2011 15:48:46 +0200 Subject: SCUMM: Setup proper pixel format for virtual screen surfaces. Thanks to Max for notifying me that SCUMM seems always to use RGB555. --- engines/scumm/gfx.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index 0472e16928..b509bb9676 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -385,9 +385,10 @@ void ScummEngine::initVirtScreen(VirtScreenNumber slot, int top, int width, int vs->hasTwoBuffers = twobufs; vs->xstart = 0; vs->backBuf = NULL; - // TODO: This should really rather setup the correct format instead of - // only setting the bytes per pixel. - vs->format.bytesPerPixel = (_game.features & GF_16BIT_COLOR) ? 2 : 1; + if (_game.features & GF_16BIT_COLOR) + vs->format = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); + else + vs->format = Graphics::PixelFormat::createFormatCLUT8(); vs->pitch = width * vs->format.bytesPerPixel; if (_game.version >= 7) { -- cgit v1.2.3