[Scummvm-cvs-logs] SF.net SVN: scummvm:[54468] scummvm/trunk/engines/mohawk

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Thu Nov 25 03:59:57 CET 2010


Revision: 54468
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54468&view=rev
Author:   mthreepwood
Date:     2010-11-25 02:59:56 +0000 (Thu, 25 Nov 2010)

Log Message:
-----------
MOHAWK: Cleanup image surface handling

- Renamed ImageData to MohawkSurface
- Added offset x/y fields to MohawkSurface
- The image cache now stores MohawkSurface pointers
- Switched Living Books to 8bpp mode (it requires that in the end anyway)

Modified Paths:
--------------
    scummvm/trunk/engines/mohawk/bitmap.cpp
    scummvm/trunk/engines/mohawk/bitmap.h
    scummvm/trunk/engines/mohawk/graphics.cpp
    scummvm/trunk/engines/mohawk/graphics.h
    scummvm/trunk/engines/mohawk/livingbooks.cpp

Modified: scummvm/trunk/engines/mohawk/bitmap.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/bitmap.cpp	2010-11-25 02:35:18 UTC (rev 54467)
+++ scummvm/trunk/engines/mohawk/bitmap.cpp	2010-11-25 02:59:56 UTC (rev 54468)
@@ -58,7 +58,7 @@
 MohawkBitmap::~MohawkBitmap() {
 }
 
-ImageData *MohawkBitmap::decodeImage(Common::SeekableReadStream *stream) {
+MohawkSurface *MohawkBitmap::decodeImage(Common::SeekableReadStream *stream) {
 	_data = stream;
 	_header.colorTable.palette = NULL;
 
@@ -95,7 +95,7 @@
 	drawImage(surface);
 	delete _data;
 
-	return new ImageData(surface, _header.colorTable.palette);
+	return new MohawkSurface(surface, _header.colorTable.palette);
 }
 
 Graphics::Surface *MohawkBitmap::createSurface(uint16 width, uint16 height) {
@@ -591,7 +591,7 @@
 // Myst Bitmap Decoder
 //////////////////////////////////////////
 
-ImageData* MystBitmap::decodeImage(Common::SeekableReadStream* stream) {
+MohawkSurface *MystBitmap::decodeImage(Common::SeekableReadStream* stream) {
 	uint32 uncompressedSize = stream->readUint32LE();
 	Common::SeekableReadStream* bmpStream = decompressLZ(stream, uncompressedSize);
 	delete stream;
@@ -683,10 +683,10 @@
 
 	delete bmpStream;
 
-	return new ImageData(surface, palData);
+	return new MohawkSurface(surface, palData);
 }
 
-ImageData *OldMohawkBitmap::decodeImage(Common::SeekableReadStream *stream) {
+MohawkSurface *OldMohawkBitmap::decodeImage(Common::SeekableReadStream *stream) {
 	Common::SeekableSubReadStreamEndian *endianStream = (Common::SeekableSubReadStreamEndian *)stream;
 
 	// 12 bytes header for the image
@@ -694,11 +694,11 @@
 	_header.bytesPerRow = endianStream->readUint16();
 	_header.width = endianStream->readUint16();
 	_header.height = endianStream->readUint16();
-	uint16 unknown0 = endianStream->readUint16(); // TODO
-	uint16 unknown1 = endianStream->readUint16(); // TODO
+	int offsetX = endianStream->readSint16();
+	int offsetY = endianStream->readSint16();
 
 	debug(2, "Decoding Old Mohawk Bitmap (%dx%d, %d bytesPerRow, %04x Format)", _header.width, _header.height, _header.bytesPerRow, _header.format);
-	debug(2, "Unknowns %04x, %04x", unknown0, unknown1); // TODO
+	debug(2, "Offset X = %d, Y = %d", offsetX, offsetY);
 
 	if ((_header.format & 0xf0) != kOldPackLZ)
 		error("tried to decode non-LZ encoded OldMohawkBitmap");
@@ -732,7 +732,12 @@
 
 	delete _data;
 	delete stream;
-	return new ImageData(surface);
+
+	MohawkSurface *mhkSurface = new MohawkSurface(surface);
+	mhkSurface->setOffsetX(offsetX);
+	mhkSurface->setOffsetY(offsetY);
+
+	return mhkSurface;
 }
 
 } // End of namespace Mohawk

Modified: scummvm/trunk/engines/mohawk/bitmap.h
===================================================================
--- scummvm/trunk/engines/mohawk/bitmap.h	2010-11-25 02:35:18 UTC (rev 54467)
+++ scummvm/trunk/engines/mohawk/bitmap.h	2010-11-25 02:59:56 UTC (rev 54468)
@@ -34,7 +34,7 @@
 
 namespace Mohawk {
 
-class ImageData;
+class MohawkSurface;
 
 enum BitmapFormat {
 	kBitsPerPixel1 = 0x0000,
@@ -84,7 +84,7 @@
 	MohawkBitmap();
 	virtual ~MohawkBitmap();
 
-	virtual ImageData *decodeImage(Common::SeekableReadStream *stream);
+	virtual MohawkSurface *decodeImage(Common::SeekableReadStream *stream);
 
 protected:
 	BitmapHeader _header;
@@ -147,7 +147,7 @@
 	MystBitmap() : MohawkBitmap() {}
 	~MystBitmap() {}
 
-	ImageData *decodeImage(Common::SeekableReadStream *stream);
+	MohawkSurface *decodeImage(Common::SeekableReadStream *stream);
 
 protected:
 	byte getBitsPerPixel() { return _info.bitsPerPixel; }
@@ -181,7 +181,7 @@
 	OldMohawkBitmap() : MohawkBitmap() {}
 	~OldMohawkBitmap() {}
 
-	ImageData *decodeImage(Common::SeekableReadStream *stream);
+	MohawkSurface *decodeImage(Common::SeekableReadStream *stream);
 
 protected:
 	byte getBitsPerPixel() { return 8; }

Modified: scummvm/trunk/engines/mohawk/graphics.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/graphics.cpp	2010-11-25 02:35:18 UTC (rev 54467)
+++ scummvm/trunk/engines/mohawk/graphics.cpp	2010-11-25 02:59:56 UTC (rev 54468)
@@ -37,6 +37,59 @@
 
 namespace Mohawk {
 
+MohawkSurface::MohawkSurface() : _surface(0), _palette(0) {
+	_offsetX = 0;
+	_offsetY = 0;
+}
+
+MohawkSurface::MohawkSurface(Graphics::Surface *surface, byte *palette, int offsetX, int offsetY) : _palette(palette), _offsetX(offsetX), _offsetY(offsetY) {
+	assert(surface);
+
+	_surface = surface;
+}
+
+MohawkSurface::~MohawkSurface() {
+	free(_palette);
+
+	if (_surface) {
+		_surface->free();
+		delete _surface;
+	}
+}
+
+void MohawkSurface::convertToTrueColor() {
+	assert(_surface);
+
+	if (_surface->bytesPerPixel > 1)
+		return;
+
+	assert(_palette);
+
+	Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
+	Graphics::Surface *surface = new Graphics::Surface();
+	surface->create(_surface->w, _surface->h, pixelFormat.bytesPerPixel);
+
+	for (uint16 i = 0; i < _surface->h; i++) {
+		for (uint16 j = 0; j < _surface->w; j++) {
+			byte palIndex = *((byte *)_surface->pixels + i * _surface->pitch + j);
+			byte r = _palette[palIndex * 4];
+			byte g = _palette[palIndex * 4 + 1];
+			byte b = _palette[palIndex * 4 + 2];
+			if (pixelFormat.bytesPerPixel == 2)
+				*((uint16 *)surface->getBasePtr(j, i)) = pixelFormat.RGBToColor(r, g, b);
+			else
+				*((uint32 *)surface->getBasePtr(j, i)) = pixelFormat.RGBToColor(r, g, b);
+		}
+	}
+
+	// Free everything and set the new surface as the converted surface
+	_surface->free();
+	delete _surface;
+	free(_palette);
+	_palette = 0;
+	_surface = surface;
+}
+
 GraphicsManager::GraphicsManager() {
 }
 
@@ -45,15 +98,13 @@
 }
 
 void GraphicsManager::clearCache() {
-	for (Common::HashMap<uint16, Graphics::Surface *>::iterator it = _cache.begin(); it != _cache.end(); it++) {
-		it->_value->free();
+	for (Common::HashMap<uint16, MohawkSurface*>::iterator it = _cache.begin(); it != _cache.end(); it++)
 		delete it->_value;
-	}
 
 	_cache.clear();
 }
 
-Graphics::Surface *GraphicsManager::findImage(uint16 id) {
+MohawkSurface *GraphicsManager::findImage(uint16 id) {
 	if (!_cache.contains(id))
 		_cache[id] = decodeImage(id);
 
@@ -65,32 +116,6 @@
 	return _cache[id];
 }
 
-Graphics::Surface *ImageData::getSurface() {
-	Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
-	Graphics::Surface *surface = new Graphics::Surface();
-	surface->create(_surface->w, _surface->h, pixelFormat.bytesPerPixel);
-
-	if (_surface->bytesPerPixel == 1) {
-		assert(_palette);
-
-		for (uint16 i = 0; i < _surface->h; i++) {
-			for (uint16 j = 0; j < _surface->w; j++) {
-				byte palIndex = *((byte *)_surface->pixels + i * _surface->pitch + j);
-				byte r = _palette[palIndex * 4];
-				byte g = _palette[palIndex * 4 + 1];
-				byte b = _palette[palIndex * 4 + 2];
-				if (pixelFormat.bytesPerPixel == 2)
-					*((uint16 *)surface->getBasePtr(j, i)) = pixelFormat.RGBToColor(r, g, b);
-				else
-					*((uint32 *)surface->getBasePtr(j, i)) = pixelFormat.RGBToColor(r, g, b);
-			}
-		}
-	} else
-		memcpy(surface->pixels, _surface->pixels, _surface->w * _surface->h * _surface->bytesPerPixel);
-
-	return surface;
-}
-
 MystGraphics::MystGraphics(MohawkEngine_Myst* vm) : GraphicsManager(), _vm(vm) {
 	_bmpDecoder = new MystBitmap();
 
@@ -170,8 +195,8 @@
 	}
 }
 
-Graphics::Surface *MystGraphics::decodeImage(uint16 id) {
-	Graphics::Surface *surface = 0;
+MohawkSurface *MystGraphics::decodeImage(uint16 id) {
+	MohawkSurface *mhkSurface = 0;
 
 	// Myst ME uses JPEG/PICT images instead of compressed Windows Bitmaps for room images,
 	// though there are a few weird ones that use that format. For further nonsense with images,
@@ -181,11 +206,12 @@
 		for (uint32 i = 0; i < _pictureFile.pictureCount; i++)
 			if (_pictureFile.entries[i].id == id) {
 				if (_pictureFile.entries[i].type == 0) {
-					Graphics::Surface *jpegSurface = _jpegDecoder->decodeImage(new Common::SeekableSubReadStream(&_pictureFile.picFile, _pictureFile.entries[i].offset, _pictureFile.entries[i].offset + _pictureFile.entries[i].size));
-					surface->copyFrom(*jpegSurface);
-				} else if (_pictureFile.entries[i].type == 1)
-					surface = _pictDecoder->decodeImage(new Common::SeekableSubReadStream(&_pictureFile.picFile, _pictureFile.entries[i].offset, _pictureFile.entries[i].offset + _pictureFile.entries[i].size));
-				else
+					Graphics::Surface *surface = new Graphics::Surface();
+					surface->copyFrom(*_jpegDecoder->decodeImage(new Common::SeekableSubReadStream(&_pictureFile.picFile, _pictureFile.entries[i].offset, _pictureFile.entries[i].offset + _pictureFile.entries[i].size)));
+					mhkSurface = new MohawkSurface(surface);
+				} else if (_pictureFile.entries[i].type == 1) {
+					mhkSurface = new MohawkSurface(_pictDecoder->decodeImage(new Common::SeekableSubReadStream(&_pictureFile.picFile, _pictureFile.entries[i].offset, _pictureFile.entries[i].offset + _pictureFile.entries[i].size)));
+				} else
 					error ("Unknown Picture File type %d", _pictureFile.entries[i].type);
 				break;
 			}
@@ -196,7 +222,7 @@
 	// ME it's most likely a PICT, and if it's original it's definitely a WDIB. However,
 	// Myst ME throws us another curve ball in that PICT resources can contain WDIB's instead
 	// of PICT's.
-	if (!surface) {
+	if (!mhkSurface) {
 		bool isPict = false;
 		Common::SeekableReadStream *dataStream = NULL;
 
@@ -215,16 +241,15 @@
 			dataStream = _vm->getResource(ID_WDIB, id);
 
 		if (isPict)
-			surface = _pictDecoder->decodeImage(dataStream);
+			mhkSurface = new MohawkSurface(_pictDecoder->decodeImage(dataStream));
 		else {
-			ImageData *imageData = _bmpDecoder->decodeImage(dataStream);
-			surface = imageData->getSurface();
-			delete imageData;
+			mhkSurface = _bmpDecoder->decodeImage(dataStream);
+			mhkSurface->convertToTrueColor();
 		}
 	}
 
-	assert(surface);
-	return surface;
+	assert(mhkSurface);
+	return mhkSurface;
 }
 
 void MystGraphics::copyImageSectionToScreen(uint16 image, Common::Rect src, Common::Rect dest) {
@@ -235,7 +260,7 @@
 	dest.right = CLIP<int>(dest.right, 0, _vm->_system->getWidth());
 	dest.bottom = CLIP<int>(dest.bottom, 0, _vm->_system->getHeight());
 
-	Graphics::Surface *surface = findImage(image);
+	Graphics::Surface *surface = findImage(image)->getSurface();
 
 	debug(3, "Image Blit:");
 	debug(3, "src.x: %d", src.left);
@@ -283,21 +308,22 @@
 
 void MystGraphics::changeCursor(uint16 cursor) {
 	// Both Myst and Myst ME use the "MystBitmap" format for cursor images.
-	ImageData *data = _bmpDecoder->decodeImage(_vm->getResource(ID_WDIB, cursor));
+	MohawkSurface *mhkSurface = _bmpDecoder->decodeImage(_vm->getResource(ID_WDIB, cursor));
+	Graphics::Surface *surface = mhkSurface->getSurface();
 	Common::SeekableReadStream *clrcStream = _vm->getResource(ID_CLRC, cursor);
 	uint16 hotspotX = clrcStream->readUint16LE();
 	uint16 hotspotY = clrcStream->readUint16LE();
 	delete clrcStream;
 
 	// Myst ME stores some cursors as 24bpp images instead of 8bpp
-	if (data->_surface->bytesPerPixel == 1) {
-		CursorMan.replaceCursor((byte *)data->_surface->pixels, data->_surface->w, data->_surface->h, hotspotX, hotspotY, 0);
-		CursorMan.replaceCursorPalette(data->_palette, 0, 256);
+	if (surface->bytesPerPixel == 1) {
+		CursorMan.replaceCursor((byte *)surface->pixels, surface->w, surface->h, hotspotX, hotspotY, 0);
+		CursorMan.replaceCursorPalette(mhkSurface->getPalette(), 0, 256);
 	} else
-		CursorMan.replaceCursor((byte *)data->_surface->pixels, data->_surface->w, data->_surface->h, hotspotX, hotspotY, _pixelFormat.RGBToColor(255, 255, 255), 1, &_pixelFormat);
+		CursorMan.replaceCursor((byte *)surface->pixels, surface->w, surface->h, hotspotX, hotspotY, _pixelFormat.RGBToColor(255, 255, 255), 1, &_pixelFormat);
 
 	_vm->_needsUpdate = true;
-	delete data;
+	delete mhkSurface;
 }
 
 void MystGraphics::drawRect(Common::Rect rect, bool active) {
@@ -342,15 +368,14 @@
 	delete _bitmapDecoder;
 }
 
-Graphics::Surface *RivenGraphics::decodeImage(uint16 id) {
-	ImageData *imageData = _bitmapDecoder->decodeImage(_vm->getResource(ID_TBMP, id));
-	Graphics::Surface *surface = imageData->getSurface();
-	delete imageData;
+MohawkSurface *RivenGraphics::decodeImage(uint16 id) {
+	MohawkSurface *surface = _bitmapDecoder->decodeImage(_vm->getResource(ID_TBMP, id));
+	surface->convertToTrueColor();
 	return surface;
 }
 
 void RivenGraphics::copyImageToScreen(uint16 image, uint32 left, uint32 top, uint32 right, uint32 bottom) {
-	Graphics::Surface *surface = findImage(image);
+	Graphics::Surface *surface = findImage(image)->getSurface();
 
 	// Clip the width to fit on the screen. Fixes some images.
 	if (left + surface->w > 608)
@@ -723,14 +748,13 @@
 }
 
 void RivenGraphics::drawInventoryImage(uint16 id, const Common::Rect *rect) {
-	ImageData *imageData = _bitmapDecoder->decodeImage(_vm->getExtrasResource(ID_TBMP, id));
-	Graphics::Surface *surface = imageData->getSurface();
-	delete imageData;
+	MohawkSurface *mhkSurface = _bitmapDecoder->decodeImage(_vm->getExtrasResource(ID_TBMP, id));
+	mhkSurface->convertToTrueColor();
+	Graphics::Surface *surface = mhkSurface->getSurface();
 
 	_vm->_system->copyRectToScreen((byte *)surface->pixels, surface->pitch, rect->left, rect->top, surface->w, surface->h);
 
-	surface->free();
-	delete surface;
+	delete mhkSurface;
 }
 
 void RivenGraphics::drawRect(Common::Rect rect, bool active) {
@@ -747,7 +771,7 @@
 
 void RivenGraphics::drawImageRect(uint16 id, Common::Rect srcRect, Common::Rect dstRect) {
 	// Draw tBMP id from srcRect to dstRect
-	Graphics::Surface *surface = findImage(id);
+	Graphics::Surface *surface = findImage(id)->getSurface();
 
 	assert(srcRect.width() == dstRect.width() && srcRect.height() == dstRect.height());
 
@@ -758,50 +782,36 @@
 }
 
 void RivenGraphics::drawExtrasImage(uint16 id, Common::Rect dstRect) {
-	ImageData *imageData = _bitmapDecoder->decodeImage(_vm->getExtrasResource(ID_TBMP, id));
-	Graphics::Surface *surface = imageData->getSurface();
-	delete imageData;
+	MohawkSurface *mhkSurface = _bitmapDecoder->decodeImage(_vm->getExtrasResource(ID_TBMP, id));
+	mhkSurface->convertToTrueColor();
+	Graphics::Surface *surface = mhkSurface->getSurface();
 
 	assert(dstRect.width() == surface->w);
 
 	for (uint16 i = 0; i < surface->h; i++)
 		memcpy(_mainScreen->getBasePtr(dstRect.left, i + dstRect.top), surface->getBasePtr(0, i), surface->pitch);
 
-	surface->free();
-	delete surface;
-
+	delete mhkSurface;
 	_dirtyScreen = true;
 }
 
 LBGraphics::LBGraphics(MohawkEngine_LivingBooks *vm) : GraphicsManager(), _vm(vm) {
 	_bmpDecoder = (_vm->getGameType() == GType_LIVINGBOOKSV1) ? new OldMohawkBitmap() : new MohawkBitmap();
-	_palette = new byte[256 * 4];
-	memset(_palette, 0, 256 * 4);
 }
 
 LBGraphics::~LBGraphics() {
 	delete _bmpDecoder;
-	delete[] _palette;
 }
 
-Graphics::Surface *LBGraphics::decodeImage(uint16 id) {
-	ImageData *imageData;
-
+MohawkSurface *LBGraphics::decodeImage(uint16 id) {
 	if (_vm->getGameType() == GType_LIVINGBOOKSV1)
-		imageData = _bmpDecoder->decodeImage(_vm->wrapStreamEndian(ID_BMAP, id));
-	else
-		imageData = _bmpDecoder->decodeImage(_vm->getResource(ID_TBMP, id));
+		return _bmpDecoder->decodeImage(_vm->wrapStreamEndian(ID_BMAP, id));
 
-	imageData->_palette = _palette;
-	Graphics::Surface *surface = imageData->getSurface();
-	imageData->_palette = NULL; // Unset the palette so it doesn't get deleted
-	delete imageData;
-
-	return surface;
+	return _bmpDecoder->decodeImage(_vm->getResource(ID_TBMP, id));
 }
 
 void LBGraphics::copyImageToScreen(uint16 image, uint16 left, uint16 top) {
-	Graphics::Surface *surface = findImage(image);
+	Graphics::Surface *surface = findImage(image)->getSurface();
 
 	uint16 width = MIN<int>(surface->w, _vm->_system->getWidth());
 	uint16 height = MIN<int>(surface->h, _vm->_system->getHeight());
@@ -814,32 +824,39 @@
 void LBGraphics::setPalette(uint16 id) {
 	// Old Living Books games use the old CTBL-style palette format while newer
 	// games use the better tPAL format which can store partial palettes.
-
 	if (_vm->getGameType() == GType_LIVINGBOOKSV1) {
 		Common::SeekableSubReadStreamEndian *ctblStream = _vm->wrapStreamEndian(ID_CTBL, id);
 		uint16 colorCount = ctblStream->readUint16();
+		byte *palette = new byte[colorCount * 4];
 
 		for (uint16 i = 0; i < colorCount; i++) {
-			_palette[i * 4] = ctblStream->readByte();
-			_palette[i * 4 + 1] = ctblStream->readByte();
-			_palette[i * 4 + 2] = ctblStream->readByte();
-			_palette[i * 4 + 3] = ctblStream->readByte();
+			palette[i * 4] = ctblStream->readByte();
+			palette[i * 4 + 1] = ctblStream->readByte();
+			palette[i * 4 + 2] = ctblStream->readByte();
+			palette[i * 4 + 3] = ctblStream->readByte();
 		}
 
 		delete ctblStream;
+
+		_vm->_system->setPalette(palette, 0, colorCount);
+		delete[] palette;
 	} else {
 		Common::SeekableReadStream *tpalStream = _vm->getResource(ID_TPAL, id);
 		uint16 colorStart = tpalStream->readUint16BE();
 		uint16 colorCount = tpalStream->readUint16BE();
+		byte *palette = new byte[colorCount * 4];
 
-		for (uint16 i = colorStart; i < colorStart + colorCount; i++) {
-			_palette[i * 4] = tpalStream->readByte();
-			_palette[i * 4 + 1] = tpalStream->readByte();
-			_palette[i * 4 + 2] = tpalStream->readByte();
-			_palette[i * 4 + 3] = tpalStream->readByte();
+		for (uint16 i = 0; i < colorCount; i++) {
+			palette[i * 4] = tpalStream->readByte();
+			palette[i * 4 + 1] = tpalStream->readByte();
+			palette[i * 4 + 2] = tpalStream->readByte();
+			palette[i * 4 + 3] = tpalStream->readByte();
 		}
 
 		delete tpalStream;
+
+		_vm->_system->setPalette(palette, colorStart, colorCount);
+		delete[] palette;
 	}
 }
 

Modified: scummvm/trunk/engines/mohawk/graphics.h
===================================================================
--- scummvm/trunk/engines/mohawk/graphics.h	2010-11-25 02:35:18 UTC (rev 54467)
+++ scummvm/trunk/engines/mohawk/graphics.h	2010-11-25 02:59:56 UTC (rev 54468)
@@ -68,27 +68,32 @@
 	kMystZipModeCursor = 999				// Zip Mode cursor
 };
 
-// A simple struct to hold necessary image info
-class ImageData {
+class MohawkSurface {
 public:
-	ImageData() : _surface(0), _palette(0) {}
-	ImageData(Graphics::Surface *surface, byte *palette = NULL) : _surface(surface), _palette(palette) {}
-	~ImageData() {
-		if (_palette)
-			free(_palette);
-		if (_surface) {
-			_surface->free();
-			delete _surface;
-		}
-	}
+	MohawkSurface();
+	MohawkSurface(Graphics::Surface *surface, byte *palette = NULL, int offsetX = 0, int offsetY = 0);
+	~MohawkSurface();
 
-	// getSurface() will convert to the current screen format, if it's not already
-	// in that format. Makes it easy to support both 8bpp and 24bpp images.
-	Graphics::Surface *getSurface();
+	// getSurface() returns the surface in the current format
+	// This will be the initial format unless convertToTrueColor() is called
+	Graphics::Surface *getSurface() const { return _surface; }
+	byte *getPalette() const { return _palette; }
 
-	// These are still public in case the 8bpp surface needs to be accessed
+	// Convert the 8bpp image to the current screen format
+	// Does nothing if _surface is already >8bpp
+	void convertToTrueColor();
+
+	// Functions for OldMohawkBitmap offsets
+	// They both default to 0
+	int getOffsetX() const { return _offsetX; }
+	int getOffsetY() const { return _offsetY; }
+	void setOffsetX(int x) { _offsetX = x; }
+	void setOffsetY(int y) { _offsetY = y; }
+
+private:
 	Graphics::Surface *_surface;
 	byte *_palette;
+	int _offsetX, _offsetY;
 };
 
 class GraphicsManager {
@@ -102,14 +107,14 @@
 protected:
 	// findImage will search the cache to find the image.
 	// If not found, it will call decodeImage to get a new one.
-	Graphics::Surface *findImage(uint16 id);
+	MohawkSurface *findImage(uint16 id);
 
 	// decodeImage will always return a new image.
-	virtual Graphics::Surface *decodeImage(uint16 id) = 0;
+	virtual MohawkSurface *decodeImage(uint16 id) = 0;
 
 private:
 	// An image cache that stores images until clearCache() is called
-	Common::HashMap<uint16, Graphics::Surface *> _cache;
+	Common::HashMap<uint16, MohawkSurface*> _cache;
 };
 
 class MystGraphics : public GraphicsManager {
@@ -128,7 +133,7 @@
 	void drawRect(Common::Rect rect, bool active);
 
 protected:
-	Graphics::Surface *decodeImage(uint16 id);
+	MohawkSurface *decodeImage(uint16 id);
 
 private:
 	MohawkEngine_Myst *_vm;
@@ -196,7 +201,7 @@
 	void hideInventory();
 
 protected:
-	Graphics::Surface *decodeImage(uint16 id);
+	MohawkSurface *decodeImage(uint16 id);
 
 private:
 	MohawkEngine_Riven *_vm;
@@ -229,12 +234,11 @@
 	void setPalette(uint16 id);
 
 protected:
-	Graphics::Surface *decodeImage(uint16 id);
+	MohawkSurface *decodeImage(uint16 id);
 
 private:
 	MohawkBitmap *_bmpDecoder;
 	MohawkEngine_LivingBooks *_vm;
-	byte *_palette;
 };
 
 } // End of namespace Mohawk

Modified: scummvm/trunk/engines/mohawk/livingbooks.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/livingbooks.cpp	2010-11-25 02:35:18 UTC (rev 54467)
+++ scummvm/trunk/engines/mohawk/livingbooks.cpp	2010-11-25 02:59:56 UTC (rev 54468)
@@ -63,7 +63,7 @@
 	debug("Setting screen size to %dx%d", _screenWidth, _screenHeight);
 
 	// TODO: Eventually move this to a LivingBooksGraphics class or similar
-	initGraphics(_screenWidth, _screenHeight, true, NULL);
+	initGraphics(_screenWidth, _screenHeight, true);
 
 	loadIntro();
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list