From fedd4d7809f3ef7f9ec446c62bbbf681a87c578e Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 17 Apr 2011 16:30:02 +0200 Subject: MOHAWK: Prefer Surface::create taking a PixelFormat over the one taking a byte depth. --- engines/mohawk/bitmap.cpp | 8 ++++++-- engines/mohawk/graphics.cpp | 6 +++--- engines/mohawk/video.cpp | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'engines/mohawk') diff --git a/engines/mohawk/bitmap.cpp b/engines/mohawk/bitmap.cpp index c8111fa91b..63b29053b0 100644 --- a/engines/mohawk/bitmap.cpp +++ b/engines/mohawk/bitmap.cpp @@ -135,8 +135,12 @@ Common::Array MohawkBitmap::decodeImages(Common::SeekableReadSt Graphics::Surface *MohawkBitmap::createSurface(uint16 width, uint16 height) { Graphics::Surface *surface = new Graphics::Surface(); - byte bytesPerPixel = (getBitsPerPixel() <= 8) ? 1 : g_system->getScreenFormat().bytesPerPixel; - surface->create(width, height, bytesPerPixel); + Graphics::PixelFormat format; + if (getBitsPerPixel() <= 8) + format = Graphics::PixelFormat::createFormatCLUT8(); + else + format = g_system->getScreenFormat(); + surface->create(width, height, format); return surface; } diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp index 81d2b6f019..06dc16b171 100644 --- a/engines/mohawk/graphics.cpp +++ b/engines/mohawk/graphics.cpp @@ -77,7 +77,7 @@ void MohawkSurface::convertToTrueColor() { Graphics::PixelFormat pixelFormat = g_system->getScreenFormat(); Graphics::Surface *surface = new Graphics::Surface(); - surface->create(_surface->w, _surface->h, pixelFormat.bytesPerPixel); + surface->create(_surface->w, _surface->h, pixelFormat); for (uint16 i = 0; i < _surface->h; i++) { for (uint16 j = 0; j < _surface->w; j++) { @@ -292,7 +292,7 @@ MystGraphics::MystGraphics(MohawkEngine_Myst* vm) : GraphicsManager(), _vm(vm) { // Initialize our buffer _backBuffer = new Graphics::Surface(); - _backBuffer->create(_vm->_system->getWidth(), _vm->_system->getHeight(), _pixelFormat.bytesPerPixel); + _backBuffer->create(_vm->_system->getWidth(), _vm->_system->getHeight(), _pixelFormat); } MystGraphics::~MystGraphics() { @@ -646,7 +646,7 @@ RivenGraphics::RivenGraphics(MohawkEngine_Riven* vm) : GraphicsManager(), _vm(vm // The actual game graphics only take up the first 392 rows. The inventory // occupies the rest of the screen and we don't use the buffer to hold that. _mainScreen = new Graphics::Surface(); - _mainScreen->create(608, 392, _pixelFormat.bytesPerPixel); + _mainScreen->create(608, 392, _pixelFormat); _updatesEnabled = true; _scheduledTransition = -1; // no transition diff --git a/engines/mohawk/video.cpp b/engines/mohawk/video.cpp index f481b5ceb2..fc617722bc 100644 --- a/engines/mohawk/video.cpp +++ b/engines/mohawk/video.cpp @@ -228,7 +228,7 @@ bool VideoManager::updateMovies() { const byte *palette = _videoStreams[i]->getPalette(); assert(palette); - convertedFrame->create(frame->w, frame->h, pixelFormat.bytesPerPixel); + convertedFrame->create(frame->w, frame->h, pixelFormat); for (uint16 j = 0; j < frame->h; j++) { for (uint16 k = 0; k < frame->w; k++) { -- cgit v1.2.3 From ca240b4936b736b8042f9868c7dfca7b9de2d92f Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 17 Apr 2011 17:28:16 +0200 Subject: MOHAWK: Do not access Surface::bytesPerPixel anymore. --- engines/mohawk/bitmap.cpp | 6 +++--- engines/mohawk/cursors.cpp | 2 +- engines/mohawk/graphics.cpp | 8 ++++---- engines/mohawk/video.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'engines/mohawk') diff --git a/engines/mohawk/bitmap.cpp b/engines/mohawk/bitmap.cpp index 63b29053b0..0e14947133 100644 --- a/engines/mohawk/bitmap.cpp +++ b/engines/mohawk/bitmap.cpp @@ -573,7 +573,7 @@ void MohawkBitmap::drawRaw(Graphics::Surface *surface) { byte b = _data->readByte(); byte g = _data->readByte(); byte r = _data->readByte(); - if (surface->bytesPerPixel == 2) + if (surface->format.bytesPerPixel == 2) *((uint16 *)surface->getBasePtr(x, y)) = pixelFormat.RGBToColor(r, g, b); else *((uint32 *)surface->getBasePtr(x, y)) = pixelFormat.RGBToColor(r, g, b); @@ -861,7 +861,7 @@ MohawkSurface *DOSBitmap::decodeImage(Common::SeekableReadStream *stream) { } void DOSBitmap::expandMonochromePlane(Graphics::Surface *surface, Common::SeekableReadStream *rawStream) { - assert(surface->bytesPerPixel == 1); + assert(surface->format.bytesPerPixel == 1); byte *dst = (byte *)surface->pixels; @@ -887,7 +887,7 @@ void DOSBitmap::expandMonochromePlane(Graphics::Surface *surface, Common::Seekab *(dst + j * 4 + dstPixel) = (*(dst + j * 4 + dstPixel) >> 1) | (((temp >> srcBit) & 1) << 3) void DOSBitmap::expandEGAPlanes(Graphics::Surface *surface, Common::SeekableReadStream *rawStream) { - assert(surface->bytesPerPixel == 1); + assert(surface->format.bytesPerPixel == 1); // Note that the image is in EGA planar form and not just standard 4bpp // This seems to contradict the PoP specs which seem to do diff --git a/engines/mohawk/cursors.cpp b/engines/mohawk/cursors.cpp index b4969f990a..66669e35c9 100644 --- a/engines/mohawk/cursors.cpp +++ b/engines/mohawk/cursors.cpp @@ -148,7 +148,7 @@ void MystCursorManager::setCursor(uint16 id) { delete clrcStream; // Myst ME stores some cursors as 24bpp images instead of 8bpp - if (surface->bytesPerPixel == 1) { + if (surface->format.bytesPerPixel == 1) { CursorMan.replaceCursor((byte *)surface->pixels, surface->w, surface->h, hotspotX, hotspotY, 0); CursorMan.replaceCursorPalette(mhkSurface->getPalette(), 0, 256); } else { diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp index 06dc16b171..2da7cc3e94 100644 --- a/engines/mohawk/graphics.cpp +++ b/engines/mohawk/graphics.cpp @@ -70,7 +70,7 @@ MohawkSurface::~MohawkSurface() { void MohawkSurface::convertToTrueColor() { assert(_surface); - if (_surface->bytesPerPixel > 1) + if (_surface->format.bytesPerPixel > 1) return; assert(_palette); @@ -486,7 +486,7 @@ void MystGraphics::copyImageSectionToBackBuffer(uint16 image, Common::Rect src, debug(3, "\theight: %d", height); for (uint16 i = 0; i < height; i++) - memcpy(_backBuffer->getBasePtr(dest.left, i + dest.top), surface->getBasePtr(src.left, top + i), width * surface->bytesPerPixel); + memcpy(_backBuffer->getBasePtr(dest.left, i + dest.top), surface->getBasePtr(src.left, top + i), width * surface->format.bytesPerPixel); } void MystGraphics::copyImageToScreen(uint16 image, Common::Rect dest) { @@ -677,7 +677,7 @@ void RivenGraphics::copyImageToScreen(uint16 image, uint32 left, uint32 top, uin surface->w = 608 - left; for (uint16 i = 0; i < surface->h; i++) - memcpy(_mainScreen->getBasePtr(left, i + top), surface->getBasePtr(0, i), surface->w * surface->bytesPerPixel); + memcpy(_mainScreen->getBasePtr(left, i + top), surface->getBasePtr(0, i), surface->w * surface->format.bytesPerPixel); _dirtyScreen = true; } @@ -972,7 +972,7 @@ void RivenGraphics::drawImageRect(uint16 id, Common::Rect srcRect, Common::Rect assert(srcRect.width() == dstRect.width() && srcRect.height() == dstRect.height()); for (uint16 i = 0; i < srcRect.height(); i++) - memcpy(_mainScreen->getBasePtr(dstRect.left, i + dstRect.top), surface->getBasePtr(srcRect.left, i + srcRect.top), srcRect.width() * surface->bytesPerPixel); + memcpy(_mainScreen->getBasePtr(dstRect.left, i + dstRect.top), surface->getBasePtr(srcRect.left, i + srcRect.top), srcRect.width() * surface->format.bytesPerPixel); _dirtyScreen = true; } diff --git a/engines/mohawk/video.cpp b/engines/mohawk/video.cpp index fc617722bc..3188619d9c 100644 --- a/engines/mohawk/video.cpp +++ b/engines/mohawk/video.cpp @@ -219,7 +219,7 @@ bool VideoManager::updateMovies() { // Convert from 8bpp to the current screen format if necessary Graphics::PixelFormat pixelFormat = _vm->_system->getScreenFormat(); - if (frame->bytesPerPixel == 1) { + if (frame->format.bytesPerPixel == 1) { if (pixelFormat.bytesPerPixel == 1) { if (_videoStreams[i]->hasDirtyPalette()) _videoStreams[i]->setSystemPalette(); -- cgit v1.2.3