[Scummvm-cvs-logs] SF.net SVN: scummvm:[41299] scummvm/trunk/engines/gob

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sat Jun 6 22:03:21 CEST 2009


Revision: 41299
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41299&view=rev
Author:   fingolfin
Date:     2009-06-06 20:03:13 +0000 (Sat, 06 Jun 2009)

Log Message:
-----------
GOB: Got rid of class ReferenceCounter; changed SurfaceDesc::Ptr to SurfaceDescPtr (a Common::SharedPtr); and changed many SurfaceDesc pointers to references

Modified Paths:
--------------
    scummvm/trunk/engines/gob/demos/demoplayer.cpp
    scummvm/trunk/engines/gob/draw.cpp
    scummvm/trunk/engines/gob/draw.h
    scummvm/trunk/engines/gob/draw_v1.cpp
    scummvm/trunk/engines/gob/draw_v2.cpp
    scummvm/trunk/engines/gob/driver_vga.cpp
    scummvm/trunk/engines/gob/driver_vga.h
    scummvm/trunk/engines/gob/game.cpp
    scummvm/trunk/engines/gob/game_v1.cpp
    scummvm/trunk/engines/gob/game_v2.cpp
    scummvm/trunk/engines/gob/global.cpp
    scummvm/trunk/engines/gob/global.h
    scummvm/trunk/engines/gob/gob.cpp
    scummvm/trunk/engines/gob/goblin.cpp
    scummvm/trunk/engines/gob/helper.h
    scummvm/trunk/engines/gob/init.cpp
    scummvm/trunk/engines/gob/init_v2.cpp
    scummvm/trunk/engines/gob/inter_bargon.cpp
    scummvm/trunk/engines/gob/inter_v1.cpp
    scummvm/trunk/engines/gob/inter_v2.cpp
    scummvm/trunk/engines/gob/inter_v3.cpp
    scummvm/trunk/engines/gob/inter_v4.cpp
    scummvm/trunk/engines/gob/inter_v5.cpp
    scummvm/trunk/engines/gob/inter_v6.cpp
    scummvm/trunk/engines/gob/mult.cpp
    scummvm/trunk/engines/gob/mult.h
    scummvm/trunk/engines/gob/mult_v1.cpp
    scummvm/trunk/engines/gob/mult_v2.cpp
    scummvm/trunk/engines/gob/save/savefile.cpp
    scummvm/trunk/engines/gob/save/savefile.h
    scummvm/trunk/engines/gob/save/savehandler.cpp
    scummvm/trunk/engines/gob/save/savehandler.h
    scummvm/trunk/engines/gob/scenery.cpp
    scummvm/trunk/engines/gob/video.cpp
    scummvm/trunk/engines/gob/video.h
    scummvm/trunk/engines/gob/video_v1.cpp
    scummvm/trunk/engines/gob/video_v2.cpp
    scummvm/trunk/engines/gob/video_v6.cpp
    scummvm/trunk/engines/gob/videoplayer.cpp

Modified: scummvm/trunk/engines/gob/demos/demoplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/demos/demoplayer.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/demos/demoplayer.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -200,7 +200,7 @@
 			int16 wD = (state.left * 2) + (w * 2);
 			int16 hD = (state.top * 2) + (h * 2);
 
-			_vm->_video->drawSpriteDouble(_vm->_draw->_spritesArray[0], _vm->_draw->_frontSurface,
+			_vm->_video->drawSpriteDouble(*_vm->_draw->_spritesArray[0], *_vm->_draw->_frontSurface,
 					state.left, state.top, state.right, state.bottom, state.left, state.top, 0);
 			_vm->_draw->dirtiedRect(_vm->_draw->_frontSurface,
 					state.left * 2, state.top * 2, wD, hD);

Modified: scummvm/trunk/engines/gob/draw.cpp
===================================================================
--- scummvm/trunk/engines/gob/draw.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/draw.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -62,9 +62,6 @@
 	for (int i = 0; i < 8; i++)
 		_fonts[i] = 0;
 
-	for (int i = 0; i < SPRITES_COUNT; i++)
-		_spritesArray[i] = 0;
-
 	_invalidatedCount = 0;
 	for (int i = 0; i < 30; i++) {
 		_invalidatedTops[i] = 0;
@@ -78,9 +75,6 @@
 	_paletteCleared = false;
 	_applyPal = false;
 
-	_backSurface = 0;
-	_frontSurface = 0;
-
 	for (int i = 0; i < 18; i++)
 		_unusedPalette1[i] = 0;
 	for (int i = 0; i < 16; i++)
@@ -109,10 +103,6 @@
 	_cursorHotspotXVar = -1;
 	_cursorHotspotYVar = -1;
 
-	_cursorSprites = 0;
-	_cursorSpritesBack = 0;
-	_scummvmCursor = 0;
-
 	_cursorAnim = 0;
 	for (int i = 0; i < 40; i++) {
 		_cursorAnimLow[i] = 0;
@@ -265,7 +255,7 @@
 
 	_vm->_video->_doRangeClamp = false;
 	for (int i = 0; i < _invalidatedCount; i++) {
-		_vm->_video->drawSprite(_backSurface, _frontSurface,
+		_vm->_video->drawSprite(*_backSurface, *_frontSurface,
 		    _invalidatedLefts[i], _invalidatedTops[i],
 		    _invalidatedRights[i], _invalidatedBottoms[i],
 		    _invalidatedLefts[i], _invalidatedTops[i], 0);
@@ -302,7 +292,7 @@
 	dirtiedRect(_spritesArray[surface], left, top, right, bottom);
 }
 
-void Draw::dirtiedRect(SurfaceDesc::Ptr surface,
+void Draw::dirtiedRect(SurfaceDescPtr surface,
 		int16 left, int16 top, int16 right, int16 bottom) {
 
 	if (surface == _backSurface)
@@ -316,7 +306,7 @@
 
 	_spritesArray[index] =
 		_vm->_video->initSurfDesc(_vm->_global->_videoMode, width, height, flags);
-	_vm->_video->clearSurf(_spritesArray[index]);
+	_vm->_video->clearSurf(*_spritesArray[index]);
 }
 
 void Draw::adjustCoords(char adjust, int16 *coord1, int16 *coord2) {
@@ -379,7 +369,7 @@
 }
 
 void Draw::drawString(const char *str, int16 x, int16 y, int16 color1, int16 color2,
-		int16 transp, SurfaceDesc *dest, Video::FontDesc *font) {
+		int16 transp, SurfaceDesc &dest, Video::FontDesc *font) {
 
 	while (*str != '\0') {
 		_vm->_video->drawLetter(*str, x, y, font, transp, color1, color2, dest);
@@ -447,7 +437,7 @@
 }
 
 void Draw::forceBlit(bool backwards) {
-	if ((_frontSurface == 0) || (_backSurface == 0))
+	if (!_frontSurface || !_backSurface)
 		return;
 	if (_frontSurface == _backSurface)
 		return;
@@ -457,12 +447,12 @@
 		return;
 
 	if (!backwards) {
-		_vm->_video->drawSprite(_backSurface, _frontSurface, 0, 0,
+		_vm->_video->drawSprite(*_backSurface, *_frontSurface, 0, 0,
 				_backSurface->getWidth() - 1, _backSurface->getHeight() - 1,
 				0, 0, 0);
 		_vm->_video->dirtyRectsAll();
 	} else
-		_vm->_video->drawSprite(_frontSurface, _backSurface, 0, 0,
+		_vm->_video->drawSprite(*_frontSurface, *_backSurface, 0, 0,
 				_frontSurface->getWidth() - 1, _frontSurface->getHeight() - 1,
 				0, 0, 0);
 
@@ -511,7 +501,7 @@
 	-0x0A03, -0x08E8, -0x07CC, -0x06B0, -0x0593, -0x0476, -0x0359, -0x023B, -0x011D
 };
 
-void Draw::wobble(SurfaceDesc *surfDesc) {
+void Draw::wobble(SurfaceDesc &surfDesc) {
 	int16 amplitude = 32;
 	uint16 curFrame = 0;
 	uint16 frameWobble = 0;
@@ -535,7 +525,7 @@
 			amplitude--;
 
 		for (uint16 y = 0; y < _vm->_height; y++)
-			_vm->_video->drawSprite(surfDesc, _frontSurface,
+			_vm->_video->drawSprite(surfDesc, *_frontSurface,
 					0, y, _vm->_width - 1, y, offsets[y], y, 0);
 
 		_vm->_palAnim->fadeStep(0);
@@ -543,7 +533,7 @@
 		_vm->_video->waitRetrace();
 	}
 
-	_vm->_video->drawSprite(surfDesc, _frontSurface,
+	_vm->_video->drawSprite(surfDesc, *_frontSurface,
 			0, 0, _vm->_width - 1, _vm->_height - 1, 0, 0, 0);
 
 	_applyPal = false;

Modified: scummvm/trunk/engines/gob/draw.h
===================================================================
--- scummvm/trunk/engines/gob/draw.h	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/draw.h	2009-06-06 20:03:13 UTC (rev 41299)
@@ -78,7 +78,7 @@
 	FontToSprite _fontToSprite[4];
 	Video::FontDesc *_fonts[8];
 
-	SurfaceDesc::Ptr _spritesArray[SPRITES_COUNT];
+	SurfaceDescPtr _spritesArray[SPRITES_COUNT];
 
 	int16 _invalidatedCount;
 	int16 _invalidatedTops[30];
@@ -92,8 +92,8 @@
 	bool _paletteCleared;
 	bool _applyPal;
 
-	SurfaceDesc::Ptr _backSurface;
-	SurfaceDesc::Ptr _frontSurface;
+	SurfaceDescPtr _backSurface;
+	SurfaceDescPtr _frontSurface;
 
 	int16 _unusedPalette1[18];
 	int16 _unusedPalette2[16];
@@ -117,9 +117,9 @@
 	int16 _cursorHotspotXVar;
 	int16 _cursorHotspotYVar;
 
-	SurfaceDesc::Ptr _cursorSprites;
-	SurfaceDesc::Ptr _cursorSpritesBack;
-	SurfaceDesc::Ptr _scummvmCursor;
+	SurfaceDescPtr _cursorSprites;
+	SurfaceDescPtr _cursorSpritesBack;
+	SurfaceDescPtr _scummvmCursor;
 
 	int16 _cursorAnim;
 	int8 _cursorAnimLow[40];
@@ -139,12 +139,12 @@
 	void clearPalette();
 
 	void dirtiedRect(int16 surface, int16 left, int16 top, int16 right, int16 bottom);
-	void dirtiedRect(SurfaceDesc::Ptr surface, int16 left, int16 top, int16 right, int16 bottom);
+	void dirtiedRect(SurfaceDescPtr surface, int16 left, int16 top, int16 right, int16 bottom);
 
 	void initSpriteSurf(int16 index, int16 width, int16 height, int16 flags);
 	void freeSprite(int16 index) {
 		assert(index < SPRITES_COUNT);
-		_spritesArray[index] = 0;
+		_spritesArray[index].reset();
 	}
 	void adjustCoords(char adjust, int16 *coord1, int16 *coord2);
 	void adjustCoords(char adjust, uint16 *coord1, uint16 *coord2) {
@@ -152,14 +152,14 @@
 	}
 	int stringLength(const char *str, int16 fontIndex);
 	void drawString(const char *str, int16 x, int16 y, int16 color1, int16 color2,
-			int16 transp, SurfaceDesc *dest, Video::FontDesc *font);
+			int16 transp, SurfaceDesc &dest, Video::FontDesc *font);
 	void printTextCentered(int16 id, int16 left, int16 top, int16 right,
 			int16 bottom, const char *str, int16 fontIndex, int16 color);
 	int32 getSpriteRectSize(int16 index);
 	void forceBlit(bool backwards = false);
 
 	static const int16 _wobbleTable[360];
-	void wobble(SurfaceDesc *surfDesc);
+	void wobble(SurfaceDesc &surfDesc);
 
 	virtual void initScreen() = 0;
 	virtual void closeScreen() = 0;

Modified: scummvm/trunk/engines/gob/draw_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/draw_v1.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/draw_v1.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -131,8 +131,8 @@
 			newY -= hotspotY = (uint16) VAR(_cursorIndex + _cursorHotspotYVar);
 		}
 
-		_vm->_video->clearSurf(_scummvmCursor);
-		_vm->_video->drawSprite(_cursorSprites, _scummvmCursor,
+		_vm->_video->clearSurf(*_scummvmCursor);
+		_vm->_video->drawSprite(*_cursorSprites, *_scummvmCursor,
 				cursorIndex * _cursorWidth, 0,
 				(cursorIndex + 1) * _cursorWidth - 1,
 				_cursorHeight - 1, 0, 0, 0);
@@ -354,8 +354,8 @@
 
 	switch (operation) {
 	case DRAW_BLITSURF:
-		_vm->_video->drawSprite(_spritesArray[_sourceSurface],
-		    _spritesArray[_destSurface],
+		_vm->_video->drawSprite(*_spritesArray[_sourceSurface],
+		    *_spritesArray[_destSurface],
 		    _spriteLeft, _spriteTop,
 		    _spriteLeft + _spriteRight - 1,
 		    _spriteTop + _spriteBottom - 1,
@@ -367,13 +367,13 @@
 
 	case DRAW_PUTPIXEL:
 		_vm->_video->putPixel(_destSpriteX, _destSpriteY,
-		    _frontColor, _spritesArray[_destSurface]);
+		    _frontColor, *_spritesArray[_destSurface]);
 
 		dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _destSpriteX, _destSpriteY);
 		break;
 
 	case DRAW_FILLRECT:
-		_vm->_video->fillRect(_spritesArray[_destSurface],
+		_vm->_video->fillRect(*_spritesArray[_destSurface],
 		    _destSpriteX, _destSpriteY,
 		    _destSpriteX + _spriteRight - 1,
 		    _destSpriteY + _spriteBottom - 1, _backColor);
@@ -383,7 +383,7 @@
 		break;
 
 	case DRAW_DRAWLINE:
-		_vm->_video->drawLine(_spritesArray[_destSurface],
+		_vm->_video->drawLine(*_spritesArray[_destSurface],
 		    _destSpriteX, _destSpriteY,
 		    _spriteRight, _spriteBottom, _frontColor);
 
@@ -403,7 +403,7 @@
 			_vm->_video->drawPackedSprite(dataBuf,
 					_spriteRight, _spriteBottom,
 					_destSpriteX, _destSpriteY,
-					_transparency, _spritesArray[_destSurface]);
+					_transparency, *_spritesArray[_destSurface]);
 			dirtiedRect(_destSurface, _destSpriteX, _destSpriteY,
 					_destSpriteX + _spriteRight - 1, _destSpriteY + _spriteBottom - 1);
 			delete[] dataBuf;
@@ -416,7 +416,7 @@
 		_vm->_video->drawPackedSprite(dataBuf,
 		    _spriteRight, _spriteBottom,
 		    _destSpriteX, _destSpriteY,
-		    _transparency, _spritesArray[_destSurface]);
+		    _transparency, *_spritesArray[_destSurface]);
 
 		dirtiedRect(_destSurface, _destSpriteX, _destSpriteY,
 				_destSpriteX + _spriteRight - 1, _destSpriteY + _spriteBottom - 1);
@@ -434,26 +434,26 @@
 			    _fonts[_fontIndex],
 			    _transparency,
 			    _frontColor, _backColor,
-			    _spritesArray[_destSurface]);
+			    *_spritesArray[_destSurface]);
 
 			_destSpriteX += _fonts[_fontIndex]->itemWidth;
 		}
 		break;
 
 	case DRAW_DRAWBAR:
-		_vm->_video->drawLine(_spritesArray[_destSurface],
+		_vm->_video->drawLine(*_spritesArray[_destSurface],
 		    _destSpriteX, _spriteBottom,
 		    _spriteRight, _spriteBottom, _frontColor);
 
-		_vm->_video->drawLine(_spritesArray[_destSurface],
+		_vm->_video->drawLine(*_spritesArray[_destSurface],
 		    _destSpriteX, _destSpriteY,
 		    _destSpriteX, _spriteBottom, _frontColor);
 
-		_vm->_video->drawLine(_spritesArray[_destSurface],
+		_vm->_video->drawLine(*_spritesArray[_destSurface],
 		    _spriteRight, _destSpriteY,
 		    _spriteRight, _spriteBottom, _frontColor);
 
-		_vm->_video->drawLine(_spritesArray[_destSurface],
+		_vm->_video->drawLine(*_spritesArray[_destSurface],
 		    _destSpriteX, _destSpriteY,
 		    _spriteRight, _destSpriteY, _frontColor);
 
@@ -462,7 +462,7 @@
 
 	case DRAW_CLEARRECT:
 		if (_backColor < 16) {
-			_vm->_video->fillRect(_spritesArray[_destSurface],
+			_vm->_video->fillRect(*_spritesArray[_destSurface],
 			    _destSpriteX, _destSpriteY,
 			    _spriteRight, _spriteBottom,
 			    _backColor);
@@ -471,7 +471,7 @@
 		break;
 
 	case DRAW_FILLRECTABS:
-		_vm->_video->fillRect(_spritesArray[_destSurface],
+		_vm->_video->fillRect(*_spritesArray[_destSurface],
 		    _destSpriteX, _destSpriteY,
 		    _spriteRight, _spriteBottom, _backColor);
 
@@ -488,7 +488,7 @@
 			    _fonts[_fontIndex],
 			    _transparency,
 			    _frontColor, _backColor,
-			    _spritesArray[_destSurface]);
+			    *_spritesArray[_destSurface]);
 			break;
 		}
 
@@ -506,8 +506,8 @@
 				_destSpriteX + _fontToSprite[_fontIndex].width,
 				_destSpriteY + _fontToSprite[_fontIndex].height);
 
-		_vm->_video->drawSprite(_spritesArray[(int16)_fontToSprite[_fontIndex].sprite],
-		    _spritesArray[_destSurface], x, y,
+		_vm->_video->drawSprite(*_spritesArray[(int16)_fontToSprite[_fontIndex].sprite],
+		    *_spritesArray[_destSurface], x, y,
 		    x + _fontToSprite[_fontIndex].width,
 		    y + _fontToSprite[_fontIndex].height,
 		    _destSpriteX, _destSpriteY, _transparency);

Modified: scummvm/trunk/engines/gob/draw_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/draw_v2.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/draw_v2.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -48,7 +48,7 @@
 
 	initSpriteSurf(21, _vm->_video->_surfWidth, _vm->_video->_surfHeight, 0);
 	_backSurface = _spritesArray[21];
-	_vm->_video->clearSurf(_backSurface);
+	_vm->_video->clearSurf(*_backSurface);
 
 	if (!_spritesArray[23]) {
 		initSpriteSurf(23, 32, 16, 2);
@@ -162,8 +162,8 @@
 			newY -= hotspotY = (uint16) VAR(_cursorIndex + _cursorHotspotYVar);
 		}
 
-		_vm->_video->clearSurf(_scummvmCursor);
-		_vm->_video->drawSprite(_cursorSprites, _scummvmCursor,
+		_vm->_video->clearSurf(*_scummvmCursor);
+		_vm->_video->drawSprite(*_cursorSprites, *_scummvmCursor,
 				cursorIndex * _cursorWidth, 0,
 				(cursorIndex + 1) * _cursorWidth - 1,
 				_cursorHeight - 1, 0, 0, 0);
@@ -614,7 +614,7 @@
 	byte *dataBuf;
 	int16 len;
 	int16 x, y;
-	SurfaceDesc *sourceSurf, *destSurf;
+	SurfaceDescPtr sourceSurf, destSurf;
 	bool deltaVeto;
 	int16 left;
 	int16 ratio;
@@ -711,8 +711,8 @@
 		if (!sourceSurf || !destSurf)
 			break;
 
-		_vm->_video->drawSprite(_spritesArray[_sourceSurface],
-				_spritesArray[_destSurface],
+		_vm->_video->drawSprite(*_spritesArray[_sourceSurface],
+				*_spritesArray[_destSurface],
 				_spriteLeft, spriteTop,
 				_spriteLeft + _spriteRight - 1,
 				_spriteTop + _spriteBottom - 1,
@@ -724,13 +724,13 @@
 
 	case DRAW_PUTPIXEL:
 		_vm->_video->putPixel(_destSpriteX, _destSpriteY, _frontColor,
-		                      _spritesArray[_destSurface]);
+		                      *_spritesArray[_destSurface]);
 
 		dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _destSpriteX, _destSpriteY);
 		break;
 
 	case DRAW_FILLRECT:
-		_vm->_video->fillRect(_spritesArray[_destSurface], destSpriteX,
+		_vm->_video->fillRect(*_spritesArray[_destSurface], destSpriteX,
 				_destSpriteY, _destSpriteX + _spriteRight - 1,
 				_destSpriteY + _spriteBottom - 1, _backColor);
 
@@ -739,7 +739,7 @@
 		break;
 
 	case DRAW_DRAWLINE:
-		_vm->_video->drawLine(_spritesArray[_destSurface],
+		_vm->_video->drawLine(*_spritesArray[_destSurface],
 		    _destSpriteX, _destSpriteY,
 		    _spriteRight, _spriteBottom, _frontColor);
 
@@ -747,7 +747,7 @@
 		break;
 
 	case DRAW_INVALIDATE:
-		_vm->_video->drawCircle(_spritesArray[_destSurface], _destSpriteX,
+		_vm->_video->drawCircle(*_spritesArray[_destSurface], _destSpriteX,
 				_destSpriteY, _spriteRight, _frontColor);
 
 		dirtiedRect(_destSurface, _destSpriteX - _spriteRight, _destSpriteY - _spriteBottom,
@@ -770,7 +770,7 @@
 
 			_vm->_video->drawPackedSprite(dataBuf,
 					_spriteRight, _spriteBottom, _destSpriteX, _destSpriteY,
-					_transparency, _spritesArray[_destSurface]);
+					_transparency, *_spritesArray[_destSurface]);
 
 			dirtiedRect(_destSurface, _destSpriteX, _destSpriteY,
 					_destSpriteX + _spriteRight - 1, _destSpriteY + _spriteBottom - 1);
@@ -786,7 +786,7 @@
 		_vm->_video->drawPackedSprite(dataBuf,
 		    _spriteRight, _spriteBottom,
 		    _destSpriteX, _destSpriteY,
-		    _transparency, _spritesArray[_destSurface]);
+		    _transparency, *_spritesArray[_destSurface]);
 
 		dirtiedRect(_destSurface, _destSpriteX, _destSpriteY,
 				_destSpriteX + _spriteRight - 1, _destSpriteY + _spriteBottom - 1);
@@ -807,11 +807,11 @@
 					for (int i = 0; i < len; i++, dataBuf += 2) {
 						_vm->_video->drawLetter(READ_LE_UINT16(dataBuf), _destSpriteX,
 								_destSpriteY, _fonts[_fontIndex], _transparency, _frontColor,
-								_backColor, _spritesArray[_destSurface]);
+								_backColor, *_spritesArray[_destSurface]);
 					}
 				} else {
 					drawString(_textToPrint, _destSpriteX, _destSpriteY, _frontColor,
-							_backColor, _transparency, _spritesArray[_destSurface],
+							_backColor, _transparency, *_spritesArray[_destSurface],
 							_fonts[_fontIndex]);
 					_destSpriteX += len * _fonts[_fontIndex]->itemWidth;
 				}
@@ -820,7 +820,7 @@
 					if ((someHandle < 0) || (_textToPrint[i] != ' ')) {
 						_vm->_video->drawLetter(_textToPrint[i], _destSpriteX,
 								_destSpriteY, _fonts[_fontIndex], _transparency,
-								_frontColor, _backColor, _spritesArray[_destSurface]);
+								_frontColor, _backColor, *_spritesArray[_destSurface]);
 						_destSpriteX += *(_fonts[_fontIndex]->extraData +
 								(_textToPrint[i] - _fonts[_fontIndex]->startItem));
 					}
@@ -839,8 +839,8 @@
 					* _fontToSprite[_fontIndex].height;
 				x = ((_textToPrint[i] - _fontToSprite[_fontIndex].base) % ratio)
 					* _fontToSprite[_fontIndex].width;
-				_vm->_video->drawSprite(_spritesArray[_fontToSprite[_fontIndex].sprite],
-						_spritesArray[_destSurface], x, y,
+				_vm->_video->drawSprite(*_spritesArray[_fontToSprite[_fontIndex].sprite],
+						*_spritesArray[_destSurface], x, y,
 						x + _fontToSprite[_fontIndex].width - 1,
 						y + _fontToSprite[_fontIndex].height - 1,
 						_destSpriteX, _destSpriteY, _transparency);
@@ -854,35 +854,35 @@
 
 	case DRAW_DRAWBAR:
 		if (_needAdjust != 2) {
-			_vm->_video->fillRect(_spritesArray[_destSurface],
+			_vm->_video->fillRect(*_spritesArray[_destSurface],
 					_destSpriteX, _spriteBottom - 1,
 					_spriteRight, _spriteBottom, _frontColor);
 
-			_vm->_video->fillRect(_spritesArray[_destSurface],
+			_vm->_video->fillRect(*_spritesArray[_destSurface],
 					_destSpriteX, _destSpriteY,
 					_destSpriteX + 1, _spriteBottom, _frontColor);
 
-			_vm->_video->fillRect(_spritesArray[_destSurface],
+			_vm->_video->fillRect(*_spritesArray[_destSurface],
 					_spriteRight - 1, _destSpriteY,
 					_spriteRight, _spriteBottom, _frontColor);
 
-			_vm->_video->fillRect(_spritesArray[_destSurface],
+			_vm->_video->fillRect(*_spritesArray[_destSurface],
 					_destSpriteX, _destSpriteY,
 					_spriteRight, _destSpriteY + 1, _frontColor);
 		} else {
-			_vm->_video->drawLine(_spritesArray[_destSurface],
+			_vm->_video->drawLine(*_spritesArray[_destSurface],
 					_destSpriteX, _spriteBottom,
 					_spriteRight, _spriteBottom, _frontColor);
 
-			_vm->_video->drawLine(_spritesArray[_destSurface],
+			_vm->_video->drawLine(*_spritesArray[_destSurface],
 					_destSpriteX, _destSpriteY,
 					_destSpriteX, _spriteBottom, _frontColor);
 
-			_vm->_video->drawLine(_spritesArray[_destSurface],
+			_vm->_video->drawLine(*_spritesArray[_destSurface],
 					_spriteRight, _destSpriteY,
 					_spriteRight, _spriteBottom, _frontColor);
 
-			_vm->_video->drawLine(_spritesArray[_destSurface],
+			_vm->_video->drawLine(*_spritesArray[_destSurface],
 					_destSpriteX, _destSpriteY,
 					_spriteRight, _destSpriteY, _frontColor);
 		}
@@ -892,7 +892,7 @@
 
 	case DRAW_CLEARRECT:
 		if ((_backColor != 16) && (_backColor != 144)) {
-			_vm->_video->fillRect(_spritesArray[_destSurface],
+			_vm->_video->fillRect(*_spritesArray[_destSurface],
 			    _destSpriteX, _destSpriteY,
 			    _spriteRight, _spriteBottom,
 			    _backColor);
@@ -902,7 +902,7 @@
 		break;
 
 	case DRAW_FILLRECTABS:
-		_vm->_video->fillRect(_spritesArray[_destSurface],
+		_vm->_video->fillRect(*_spritesArray[_destSurface],
 		    _destSpriteX, _destSpriteY,
 		    _spriteRight, _spriteBottom, _backColor);
 

Modified: scummvm/trunk/engines/gob/driver_vga.cpp
===================================================================
--- scummvm/trunk/engines/gob/driver_vga.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/driver_vga.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -38,26 +38,26 @@
 		dest->getVidMem()[(y * dest->getWidth()) + x] = color;
 }
 
-void VGAVideoDriver::putPixel(int16 x, int16 y, byte color, SurfaceDesc *dest) {
-	if ((x >= 0) && (x < dest->getWidth()) &&
-	    (y >= 0) && (y < dest->getHeight()))
-		dest->getVidMem()[(y * dest->getWidth()) + x] = color;
+void VGAVideoDriver::putPixel(int16 x, int16 y, byte color, SurfaceDesc &dest) {
+	if ((x >= 0) && (x < dest.getWidth()) &&
+	    (y >= 0) && (y < dest.getHeight()))
+		dest.getVidMem()[(y * dest.getWidth()) + x] = color;
 }
 
-void VGAVideoDriver::drawLine(SurfaceDesc *dest, int16 x0, int16 y0, int16 x1,
+void VGAVideoDriver::drawLine(SurfaceDesc &dest, int16 x0, int16 y0, int16 x1,
 		int16 y1, byte color) {
 
-	Graphics::drawLine(x0, y0, x1, y1, color, &plotPixel, dest);
+	Graphics::drawLine(x0, y0, x1, y1, color, &plotPixel, &dest);
 }
 
-void VGAVideoDriver::fillRect(SurfaceDesc *dest, int16 left, int16 top,
+void VGAVideoDriver::fillRect(SurfaceDesc &dest, int16 left, int16 top,
 		int16 right, int16 bottom, byte color) {
 
-	if ((left >= dest->getWidth()) || (right >= dest->getWidth()) ||
-	    (top >= dest->getHeight()) || (bottom >= dest->getHeight()))
+	if ((left >= dest.getWidth()) || (right >= dest.getWidth()) ||
+	    (top >= dest.getHeight()) || (bottom >= dest.getHeight()))
 		return;
 
-	byte *pos = dest->getVidMem() + (top * dest->getWidth()) + left;
+	byte *pos = dest.getVidMem() + (top * dest.getWidth()) + left;
 	int16 width = (right - left) + 1;
 	int16 height = (bottom - top) + 1;
 
@@ -65,19 +65,19 @@
 		for (int16 i = 0; i < width; ++i)
 			pos[i] = color;
 
-		pos += dest->getWidth();
+		pos += dest.getWidth();
 	}
 }
 
 void VGAVideoDriver::drawLetter(unsigned char item, int16 x, int16 y,
 		Video::FontDesc *fontDesc, byte color1, byte color2,
-		byte transp, SurfaceDesc *dest) {
+		byte transp, SurfaceDesc &dest) {
 	byte *src, *dst;
 	uint16 data;
 
 	src = fontDesc->dataPtr +
 		(item - fontDesc->startItem) * (fontDesc->itemSize & 0xFF);
-	dst = dest->getVidMem() + x + dest->getWidth() * y;
+	dst = dest.getVidMem() + x + dest.getWidth() * y;
 
 	int nWidth = fontDesc->itemWidth;
 
@@ -106,26 +106,26 @@
 
 		}
 
-		dst += dest->getWidth() - fontDesc->itemWidth;
+		dst += dest.getWidth() - fontDesc->itemWidth;
 	}
 }
 
-void VGAVideoDriver::drawSprite(SurfaceDesc *source, SurfaceDesc *dest,
+void VGAVideoDriver::drawSprite(SurfaceDesc &source, SurfaceDesc &dest,
 		int16 left, int16 top, int16 right, int16 bottom,
 		int16 x, int16 y, int16 transp) {
 
-	if ((x >= dest->getWidth()) || (x < 0) ||
-	    (y >= dest->getHeight()) || (y < 0))
+	if ((x >= dest.getWidth()) || (x < 0) ||
+	    (y >= dest.getHeight()) || (y < 0))
 		return;
 
-	int16 width = MIN((right - left) + 1, (int) dest->getWidth());
-	int16 height = MIN((bottom - top) + 1, (int) dest->getHeight());
+	int16 width = MIN((right - left) + 1, (int) dest.getWidth());
+	int16 height = MIN((bottom - top) + 1, (int) dest.getHeight());
 
 	if ((width < 1) || (height < 1))
 		return;
 
-	const byte *srcPos = source->getVidMem() + (top * source->getWidth()) + left;
-	byte *destPos = dest->getVidMem() + (y * dest->getWidth()) + x;
+	const byte *srcPos = source.getVidMem() + (top * source.getWidth()) + left;
+	byte *destPos = dest.getVidMem() + (y * dest.getWidth()) + x;
 
 	uint32 size = width * height;
 
@@ -137,8 +137,8 @@
 					destPos[i] = srcPos[i];
 			}
 
-			srcPos += source->getWidth();
-			destPos += dest->getWidth();
+			srcPos += source.getWidth();
+			destPos += dest.getWidth();
 		}
 
 	} else if (((srcPos  >= destPos) && (srcPos  <= (destPos + size))) ||
@@ -147,8 +147,8 @@
 		while (height--) {
 			memmove(destPos, srcPos, width);
 
-			srcPos += source->getWidth();
-			destPos += dest->getWidth();
+			srcPos += source.getWidth();
+			destPos += dest.getWidth();
 		}
 
 	} else {
@@ -156,29 +156,29 @@
 		while (height--) {
 			memcpy(destPos, srcPos, width);
 
-			srcPos += source->getWidth();
-			destPos += dest->getWidth();
+			srcPos += source.getWidth();
+			destPos += dest.getWidth();
 		}
 
 	}
 }
 
-void VGAVideoDriver::drawSpriteDouble(SurfaceDesc *source, SurfaceDesc *dest,
+void VGAVideoDriver::drawSpriteDouble(SurfaceDesc &source, SurfaceDesc &dest,
 		int16 left, int16 top, int16 right, int16 bottom,
 		int16 x, int16 y, int16 transp) {
 
-	if ((x >= dest->getWidth()) || (x < 0) ||
-	    (y >= dest->getHeight()) || (y < 0))
+	if ((x >= dest.getWidth()) || (x < 0) ||
+	    (y >= dest.getHeight()) || (y < 0))
 		return;
 
-	int16 width = MIN<int>((right - left) + 1, dest->getWidth() / 2);
-	int16 height = MIN<int>((bottom - top) + 1, dest->getHeight() / 2);
+	int16 width = MIN<int>((right - left) + 1, dest.getWidth() / 2);
+	int16 height = MIN<int>((bottom - top) + 1, dest.getHeight() / 2);
 
 	if ((width < 1) || (height < 1))
 		return;
 
-	const byte *srcPos = source->getVidMem() + (top * source->getWidth()) + left;
-	byte *destPos = dest->getVidMem() + ((y * 2) * dest->getWidth()) + (x * 2);
+	const byte *srcPos = source.getVidMem() + (top * source.getWidth()) + left;
+	byte *destPos = dest.getVidMem() + ((y * 2) * dest.getWidth()) + (x * 2);
 
 	while (height--) {
 		const byte *srcBak = srcPos;
@@ -193,19 +193,19 @@
 				}
 			}
 
-			destPos += dest->getWidth();
+			destPos += dest.getWidth();
 		}
 
-		srcPos = srcBak + source->getWidth();
+		srcPos = srcBak + source.getWidth();
 	}
 }
 
 void VGAVideoDriver::drawPackedSprite(byte *sprBuf, int16 width, int16 height,
-		int16 x, int16 y, byte transp, SurfaceDesc *dest) {
+		int16 x, int16 y, byte transp, SurfaceDesc &dest) {
 	int destRight = x + width;
 	int destBottom = y + height;
 
-	byte *dst = dest->getVidMem() + x + dest->getWidth() * y;
+	byte *dst = dest.getVidMem() + x + dest.getWidth() * y;
 
 	int curx = x;
 	int cury = y;
@@ -223,14 +223,14 @@
 		val >>= 4;
 
 		for (unsigned int i = 0; i < repeat; ++i) {
-			if (curx < dest->getWidth() && cury < dest->getHeight())
+			if (curx < dest.getWidth() && cury < dest.getHeight())
 				if (!transp || val)
 					*dst = val;
 
 			dst++;
 			curx++;
 			if (curx == destRight) {
-				dst += dest->getWidth() + x - curx;
+				dst += dest.getWidth() + x - curx;
 				curx = x;
 				cury++;
 				if (cury == destBottom)

Modified: scummvm/trunk/engines/gob/driver_vga.h
===================================================================
--- scummvm/trunk/engines/gob/driver_vga.h	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/driver_vga.h	2009-06-06 20:03:13 UTC (rev 41299)
@@ -35,20 +35,20 @@
 	VGAVideoDriver() {}
 	virtual ~VGAVideoDriver() {}
 
-	void putPixel(int16 x, int16 y, byte color, SurfaceDesc *dest);
-	void drawLine(SurfaceDesc *dest, int16 x0, int16 y0,
+	void putPixel(int16 x, int16 y, byte color, SurfaceDesc &dest);
+	void drawLine(SurfaceDesc &dest, int16 x0, int16 y0,
 			int16 x1, int16 y1, byte color);
-	void fillRect(SurfaceDesc *dest, int16 left, int16 top,
+	void fillRect(SurfaceDesc &dest, int16 left, int16 top,
 			int16 right, int16 bottom, byte color);
 	void drawLetter(unsigned char item, int16 x, int16 y,
 			Video::FontDesc *fontDesc, byte color1, byte color2,
-			byte transp, SurfaceDesc *dest);
-	void drawSprite(SurfaceDesc *source, SurfaceDesc *dest, int16 left,
+			byte transp, SurfaceDesc &dest);
+	void drawSprite(SurfaceDesc &source, SurfaceDesc &dest, int16 left,
 			int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp);
-	void drawSpriteDouble(SurfaceDesc *source, SurfaceDesc *dest, int16 left,
+	void drawSpriteDouble(SurfaceDesc &source, SurfaceDesc &dest, int16 left,
 			int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp);
 	void drawPackedSprite(byte *sprBuf, int16 width, int16 height,
-			int16 x, int16 y, byte transp, SurfaceDesc *dest);
+			int16 x, int16 y, byte transp, SurfaceDesc &dest);
 };
 
 }

Modified: scummvm/trunk/engines/gob/game.cpp
===================================================================
--- scummvm/trunk/engines/gob/game.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/game.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -526,7 +526,7 @@
 
 	for (int i = 0; i < SPRITES_COUNT; i++)
 		_vm->_draw->freeSprite(i);
-	_vm->_draw->_scummvmCursor = 0;
+	_vm->_draw->_scummvmCursor.reset();
 }
 
 // flagbits: 0 = freeInterVariables, 1 = skipPlay

Modified: scummvm/trunk/engines/gob/game_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/game_v1.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/game_v1.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -549,9 +549,9 @@
 	_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
 
 	_vm->_draw->initScreen();
-	_vm->_video->fillRect(_vm->_draw->_backSurface, 0, 0, 319, 199, 1);
+	_vm->_video->fillRect(*_vm->_draw->_backSurface, 0, 0, 319, 199, 1);
 	_vm->_draw->_frontSurface = _vm->_global->_primarySurfDesc;
-	_vm->_video->fillRect(_vm->_draw->_frontSurface, 0, 0, 319, 199, 1);
+	_vm->_video->fillRect(*_vm->_draw->_frontSurface, 0, 0, 319, 199, 1);
 
 	_vm->_util->setMousePos(152, 92);
 	_vm->_draw->_cursorX = _vm->_global->_inter_mouseX = 152;

Modified: scummvm/trunk/engines/gob/game_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/game_v2.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/game_v2.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -571,7 +571,7 @@
 	_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
 
 	_vm->_draw->initScreen();
-	_vm->_video->fillRect(_vm->_draw->_frontSurface, 0, 0,
+	_vm->_video->fillRect(*_vm->_draw->_frontSurface, 0, 0,
 			_vm->_video->_surfWidth - 1, _vm->_video->_surfHeight - 1, 1);
 
 	_vm->_util->setMousePos(152, 92);

Modified: scummvm/trunk/engines/gob/global.cpp
===================================================================
--- scummvm/trunk/engines/gob/global.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/global.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -112,8 +112,6 @@
 	_setAllPalette = false;
 	_dontSetPalette = false;
 
-	_primarySurfDesc = 0;
-
 	_debugFlag = 0;
 	_inVM = 0;
 

Modified: scummvm/trunk/engines/gob/global.h
===================================================================
--- scummvm/trunk/engines/gob/global.h	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/global.h	2009-06-06 20:03:13 UTC (rev 41299)
@@ -112,7 +112,7 @@
 	bool _setAllPalette;
 	bool _dontSetPalette;
 
-	SurfaceDesc::Ptr _primarySurfDesc;
+	SurfaceDescPtr _primarySurfDesc;
 
 	int16 _debugFlag;
 	int16 _inVM;

Modified: scummvm/trunk/engines/gob/gob.cpp
===================================================================
--- scummvm/trunk/engines/gob/gob.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/gob.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -479,14 +479,14 @@
 		_global->_mouseMaxX = 640;
 		_global->_mouseMaxY = 480;
 		_mode = 0x18;
-		_global->_primarySurfDesc = new SurfaceDesc(0x18, 640, 480);
+		_global->_primarySurfDesc = SurfaceDescPtr(new SurfaceDesc(0x18, 640, 480));
 	} else {
 		_video->_surfWidth = _width = 320;
 		_video->_surfHeight = _video->_splitHeight1 = _height = 200;
 		_global->_mouseMaxX = 320;
 		_global->_mouseMaxY = 200;
 		_mode = 0x14;
-		_global->_primarySurfDesc = new SurfaceDesc(0x14, 320, 200);
+		_global->_primarySurfDesc = SurfaceDescPtr(new SurfaceDesc(0x14, 320, 200));
 	}
 
 	return true;

Modified: scummvm/trunk/engines/gob/goblin.cpp
===================================================================
--- scummvm/trunk/engines/gob/goblin.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/goblin.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -233,7 +233,7 @@
 		if (objDesc->toRedraw == 0)
 			continue;
 
-		_vm->_video->drawSprite(_vm->_mult->_animSurf, _vm->_draw->_backSurface,
+		_vm->_video->drawSprite(*_vm->_mult->_animSurf, *_vm->_draw->_backSurface,
 		    objDesc->left, objDesc->top, objDesc->right,
 		    objDesc->bottom, objDesc->left, objDesc->top, 0);
 

Modified: scummvm/trunk/engines/gob/helper.h
===================================================================
--- scummvm/trunk/engines/gob/helper.h	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/helper.h	2009-06-06 20:03:13 UTC (rev 41299)
@@ -35,58 +35,6 @@
 	return dest;
 }
 
-/** A "smart" reference counting templated class. */
-template<typename T>
-class ReferenceCounter {
-public:
-	class Ptr {
-	public:
-		bool operator==(const Ptr &p) const { return _p == p._p; }
-		bool operator==(const ReferenceCounter *p) const { return _p == p; }
-
-		T *operator-> () { return _p; }
-		T &operator* () { return *_p; }
-		operator T*() { return _p; }
-
-		Ptr(T *p) : _p(p) { ++_p->_references; }
-		Ptr() : _p(0) { }
-
-		~Ptr() {
-			if (_p && (--_p->_references == 0))
-				delete _p;
-		}
-
-		Ptr(const Ptr &p) : _p(p._p) { ++_p->_references; }
-
-		Ptr &operator= (const Ptr &p) {
-			++p._p->_references;
-			if (_p && (--_p->_references == 0))
-				delete _p;
-			_p = p._p;
-			return *this;
-		}
-		Ptr *operator= (const Ptr *p) {
-			if (p)
-				++p->_p->_references;
-			if (_p && (--_p->_references == 0))
-				delete _p;
-
-			_p = p ? p->_p : 0;
-			return this;
-		}
-
-	private:
-		T *_p;
-	};
-
-	ReferenceCounter() : _references(0) { }
-	virtual ~ReferenceCounter() {}
-
-private:
-	unsigned _references;
-	friend class Ptr;
-};
-
 } // End of namespace Gob
 
 #endif // GOB_HELPER_H

Modified: scummvm/trunk/engines/gob/init.cpp
===================================================================
--- scummvm/trunk/engines/gob/init.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/init.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -50,7 +50,7 @@
 
 void Init::cleanup() {
 	_vm->_video->freeDriver();
-	_vm->_global->_primarySurfDesc = 0;
+	_vm->_global->_primarySurfDesc.reset();
 
 	_vm->_sound->speakerOff();
 	_vm->_sound->blasterStop(0);
@@ -213,7 +213,7 @@
 				_vm->_dataIO->closeData(imdHandle);
 				sprBuf = _vm->_dataIO->getData("coktel.ims");
 				_vm->_video->drawPackedSprite(sprBuf, 320, 200, 0, 0, 0,
-						_vm->_draw->_frontSurface);
+						*_vm->_draw->_frontSurface);
 				_vm->_palAnim->fade(_palDesc, 0, 0);
 				_vm->_util->delay(500);
 

Modified: scummvm/trunk/engines/gob/init_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/init_v2.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/init_v2.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -42,7 +42,7 @@
 
 	_vm->_draw->_frontSurface = _vm->_global->_primarySurfDesc;
 	_vm->_video->initSurfDesc(_vm->_global->_videoMode,
-			_vm->_video->_surfWidth, _vm->_video->_surfHeight, 0x80);
+			_vm->_video->_surfWidth, _vm->_video->_surfHeight, PRIMARY_SURFACE);
 
 	_vm->_global->_mousePresent = 1;
 

Modified: scummvm/trunk/engines/gob/inter_bargon.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_bargon.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/inter_bargon.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -734,16 +734,16 @@
 	int16 mouseX;
 	int16 mouseY;
 	int16 buttons;
-	SurfaceDesc *surface;
+	SurfaceDescPtr surface;
 	SoundDesc samples[4];
 	int16 comp[5] = { 0, 1, 2, 3, -1 };
 	static const char *sndFiles[] = {"1INTROII.snd", "2INTROII.snd", "1INTRO3.snd", "2INTRO3.snd"};
 
 	surface = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 320, 200, 0);
-	_vm->_video->drawPackedSprite("2ille.ims", surface);
-	_vm->_video->drawSprite(surface, _vm->_draw->_frontSurface, 0, 0, 319, 199, 0, 0, 0);
-	_vm->_video->drawPackedSprite("2ille4.ims", surface);
-	_vm->_video->drawSprite(surface, _vm->_draw->_frontSurface, 0, 0, 319, 199, 320, 0, 0);
+	_vm->_video->drawPackedSprite("2ille.ims", *surface);
+	_vm->_video->drawSprite(*surface, *_vm->_draw->_frontSurface, 0, 0, 319, 199, 0, 0, 0);
+	_vm->_video->drawPackedSprite("2ille4.ims", *surface);
+	_vm->_video->drawSprite(*surface, *_vm->_draw->_frontSurface, 0, 0, 319, 199, 320, 0, 0);
 	_vm->_util->setScrollOffset(320, 0);
 	_vm->_video->dirtyRectsAll();
 	_vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0);
@@ -754,7 +754,7 @@
 		if ((_vm->_game->checkKeys(&mouseX, &mouseY, &buttons, 0) == 0x11B) ||
 				_vm->shouldQuit()) {
 			_vm->_palAnim->fade(0, -2, 0);
-			_vm->_video->clearSurf(_vm->_draw->_frontSurface);
+			_vm->_video->clearSurf(*_vm->_draw->_frontSurface);
 			memset((char *) _vm->_draw->_vgaPalette, 0, 768);
 			WRITE_VAR(4, buttons);
 			WRITE_VAR(0, 0x11B);
@@ -766,7 +766,7 @@
 		_vm->_util->setScrollOffset(0, 0);
 		_vm->_video->dirtyRectsAll();
 	}
-	surface = 0;
+	surface.reset();
 	if (VAR(57) == ((uint32) -1))
 		return;
 
@@ -775,7 +775,7 @@
 	_vm->_sound->blasterPlayComposition(comp, 0, samples, 4);
 	_vm->_sound->blasterWaitEndPlay(true, false);
 	_vm->_palAnim->fade(0, 0, 0);
-	_vm->_video->clearSurf(_vm->_draw->_frontSurface);
+	_vm->_video->clearSurf(*_vm->_draw->_frontSurface);
 }
 
 void Inter_Bargon::oBargon_intro3(OpGobParams &params) {
@@ -806,8 +806,8 @@
 				_vm->shouldQuit()) {
 			_vm->_sound->blasterStop(10);
 			_vm->_palAnim->fade(0, -2, 0);
-			_vm->_video->clearSurf(_vm->_draw->_frontSurface);
-			memset((char *) _vm->_draw->_vgaPalette, 0, 768);
+			_vm->_video->clearSurf(*_vm->_draw->_frontSurface);
+			memset(_vm->_draw->_vgaPalette, 0, 768);
 			WRITE_VAR(4, buttons);
 			WRITE_VAR(0, 0x11B);
 			WRITE_VAR(57, (uint32) -1);

Modified: scummvm/trunk/engines/gob/inter_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v1.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/inter_v1.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -808,9 +808,9 @@
 	    (_vm->_draw->_cursorSprites->getWidth() != (width * count))) {
 
 		_vm->_draw->freeSprite(23);
-		_vm->_draw->_cursorSprites = 0;
-		_vm->_draw->_cursorSpritesBack = 0;
-		_vm->_draw->_scummvmCursor = 0;
+		_vm->_draw->_cursorSprites.reset();
+		_vm->_draw->_cursorSpritesBack.reset();
+		_vm->_draw->_scummvmCursor.reset();
 
 		_vm->_draw->_cursorWidth = width;
 		_vm->_draw->_cursorHeight = height;
@@ -963,7 +963,7 @@
 	    ((oldAnimWidth != _vm->_mult->_animWidth) ||
 			 (oldAnimHeight != _vm->_mult->_animHeight))) {
 		_vm->_draw->freeSprite(22);
-		_vm->_mult->_animSurf = 0;
+		_vm->_mult->_animSurf.reset();
 	}
 
 	if (!_vm->_mult->_animSurf) {
@@ -972,7 +972,7 @@
 		_vm->_mult->_animSurf = _vm->_draw->_spritesArray[22];
 	}
 
-	_vm->_video->drawSprite(_vm->_draw->_backSurface, _vm->_mult->_animSurf,
+	_vm->_video->drawSprite(*_vm->_draw->_backSurface, *_vm->_mult->_animSurf,
 	    _vm->_mult->_animLeft, _vm->_mult->_animTop,
 	    _vm->_mult->_animLeft + _vm->_mult->_animWidth - 1,
 	    _vm->_mult->_animTop + _vm->_mult->_animHeight - 1, 0, 0, 0);
@@ -1177,13 +1177,13 @@
 
 	dataBuf = _vm->_game->loadTotResource(id, 0, &width, &height);
 
-	_vm->_video->fillRect(_vm->_draw->_cursorSprites,
+	_vm->_video->fillRect(*_vm->_draw->_cursorSprites,
 			index * _vm->_draw->_cursorWidth, 0,
 			index * _vm->_draw->_cursorWidth + _vm->_draw->_cursorWidth - 1,
 			_vm->_draw->_cursorHeight - 1, 0);
 
 	_vm->_video->drawPackedSprite(dataBuf, width, height,
-			index * _vm->_draw->_cursorWidth, 0, 0, _vm->_draw->_cursorSprites);
+			index * _vm->_draw->_cursorWidth, 0, 0, *_vm->_draw->_cursorSprites);
 	_vm->_draw->_cursorAnimLow[index] = 0;
 
 	return false;
@@ -1531,7 +1531,7 @@
 			}
 		}
 		if (!allZero) {
-			_vm->_video->clearSurf(_vm->_draw->_frontSurface);
+			_vm->_video->clearSurf(*_vm->_draw->_frontSurface);
 			_vm->_draw->_noInvalidated57 = true;
 			_vm->_global->_inter_execPtr += 18;
 			return false;

Modified: scummvm/trunk/engines/gob/inter_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v2.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/inter_v2.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -907,12 +907,12 @@
 	    ((oldAnimWidth != _vm->_mult->_animWidth) ||
 			 (oldAnimHeight != _vm->_mult->_animHeight))) {
 		_vm->_draw->freeSprite(22);
-		_vm->_mult->_animSurf = 0;
+		_vm->_mult->_animSurf.reset();
 	}
 
 	_vm->_draw->adjustCoords(0,
 			&_vm->_mult->_animWidth, &_vm->_mult->_animHeight);
-	if (_vm->_mult->_animSurf == 0) {
+	if (!_vm->_mult->_animSurf) {
 		_vm->_draw->initSpriteSurf(22, _vm->_mult->_animWidth,
 				_vm->_mult->_animHeight, 0);
 		_vm->_mult->_animSurf = _vm->_draw->_spritesArray[22];

Modified: scummvm/trunk/engines/gob/inter_v3.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v3.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/inter_v3.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -894,7 +894,7 @@
 }
 
 void Inter_v3::o3_wobble(OpGobParams &params) {
-	_vm->_draw->wobble(_vm->_draw->_backSurface);
+	_vm->_draw->wobble(*_vm->_draw->_backSurface);
 }
 
 } // End of namespace Gob

Modified: scummvm/trunk/engines/gob/inter_v4.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v4.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/inter_v4.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -772,9 +772,9 @@
 	memset(_vm->_global->_greenPalette, 0, 256);
 	memset(_vm->_global->_bluePalette, 0, 256);
 
-	_vm->_video->_splitSurf = 0;
-	_vm->_draw->_spritesArray[24] = 0;
-	_vm->_draw->_spritesArray[25] = 0;
+	_vm->_video->_splitSurf.reset();
+	_vm->_draw->_spritesArray[24].reset();
+	_vm->_draw->_spritesArray[25].reset();
 
 	_vm->_global->_videoMode = videoMode;
 	_vm->_video->initPrimary(videoMode);
@@ -791,8 +791,8 @@
 	_vm->_util->setScrollOffset();
 
 	if (offY > 0) {
-		_vm->_draw->_spritesArray[24] = new SurfaceDesc(videoMode, _vm->_width, offY);
-		_vm->_draw->_spritesArray[25] = new SurfaceDesc(videoMode, _vm->_width, offY);
+		_vm->_draw->_spritesArray[24] = SurfaceDescPtr(new SurfaceDesc(videoMode, _vm->_width, offY));
+		_vm->_draw->_spritesArray[25] = SurfaceDescPtr(new SurfaceDesc(videoMode, _vm->_width, offY));
 		_vm->_video->_splitSurf = _vm->_draw->_spritesArray[25];
 	}
 }

Modified: scummvm/trunk/engines/gob/inter_v5.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v5.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/inter_v5.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -754,9 +754,9 @@
 	memset(_vm->_global->_greenPalette, 0, 256);
 	memset(_vm->_global->_bluePalette, 0, 256);
 
-	_vm->_video->_splitSurf = 0;
-	_vm->_draw->_spritesArray[24] = 0;
-	_vm->_draw->_spritesArray[25] = 0;
+	_vm->_video->_splitSurf.reset();
+	_vm->_draw->_spritesArray[24].reset();
+	_vm->_draw->_spritesArray[25].reset();
 
 	_vm->_global->_videoMode = videoMode;
 	_vm->_video->initPrimary(videoMode);
@@ -773,8 +773,8 @@
 	_vm->_util->setScrollOffset();
 
 	if (offY > 0) {
-		_vm->_draw->_spritesArray[24] = new SurfaceDesc(videoMode, _vm->_width, offY);
-		_vm->_draw->_spritesArray[25] = new SurfaceDesc(videoMode, _vm->_width, offY);
+		_vm->_draw->_spritesArray[24] = SurfaceDescPtr(new SurfaceDesc(videoMode, _vm->_width, offY));
+		_vm->_draw->_spritesArray[25] = SurfaceDescPtr(new SurfaceDesc(videoMode, _vm->_width, offY));
 		_vm->_video->_splitSurf = _vm->_draw->_spritesArray[25];
 	}
 }
@@ -851,7 +851,7 @@
 
 	Video::FontDesc *font;
 	if ((font = _vm->_util->loadFont("SPEED.LET"))) {
-		_vm->_draw->drawString("100 %", 402, 89, 112, 144, 0, _vm->_draw->_backSurface, font);
+		_vm->_draw->drawString("100 %", 402, 89, 112, 144, 0, *_vm->_draw->_backSurface, font);
 		_vm->_draw->forceBlit();
 
 		delete font;
@@ -865,7 +865,7 @@
 
 	Video::FontDesc *font;
 	if ((font = _vm->_util->loadFont("SPEED.LET"))) {
-		_vm->_draw->drawString("100 %", 402, 168, 112, 144, 0, _vm->_draw->_backSurface, font);
+		_vm->_draw->drawString("100 %", 402, 168, 112, 144, 0, *_vm->_draw->_backSurface, font);
 		_vm->_draw->forceBlit();
 
 		delete font;
@@ -879,7 +879,7 @@
 
 	Video::FontDesc *font;
 	if ((font = _vm->_util->loadFont("SPEED.LET"))) {
-		_vm->_draw->drawString("100 %", 402, 248, 112, 144, 0, _vm->_draw->_backSurface, font);
+		_vm->_draw->drawString("100 %", 402, 248, 112, 144, 0, *_vm->_draw->_backSurface, font);
 		_vm->_draw->forceBlit();
 
 		delete font;
@@ -893,7 +893,7 @@
 
 	Video::FontDesc *font;
 	if ((font = _vm->_util->loadFont("SPEED.LET"))) {
-		_vm->_draw->drawString("100 %", 402, 326, 112, 144, 0, _vm->_draw->_backSurface, font);
+		_vm->_draw->drawString("100 %", 402, 326, 112, 144, 0, *_vm->_draw->_backSurface, font);
 		_vm->_draw->forceBlit();
 
 		delete font;
@@ -907,7 +907,7 @@
 
 	Video::FontDesc *font;
 	if ((font = _vm->_util->loadFont("SPEED.LET"))) {
-		_vm->_draw->drawString("100 %", 402, 405, 112, 144, 0, _vm->_draw->_backSurface, font);
+		_vm->_draw->drawString("100 %", 402, 405, 112, 144, 0, *_vm->_draw->_backSurface, font);
 		_vm->_draw->forceBlit();
 
 		delete font;

Modified: scummvm/trunk/engines/gob/inter_v6.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v6.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/inter_v6.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -828,13 +828,13 @@
 	int16 width, height;
 	byte *dataBuf = _vm->_game->loadTotResource(id, 0, &width, &height);
 
-	_vm->_video->fillRect(_vm->_draw->_cursorSprites,
+	_vm->_video->fillRect(*_vm->_draw->_cursorSprites,
 			index * _vm->_draw->_cursorWidth, 0,
 			index * _vm->_draw->_cursorWidth + _vm->_draw->_cursorWidth - 1,
 			_vm->_draw->_cursorHeight - 1, 0);
 
 	_vm->_video->drawPackedSprite(dataBuf, width, height,
-			index * _vm->_draw->_cursorWidth, 0, 0, _vm->_draw->_cursorSprites);
+			index * _vm->_draw->_cursorWidth, 0, 0, *_vm->_draw->_cursorSprites);
 	_vm->_draw->_cursorAnimLow[index] = 0;
 
 	return false;

Modified: scummvm/trunk/engines/gob/mult.cpp
===================================================================
--- scummvm/trunk/engines/gob/mult.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/mult.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -85,7 +85,6 @@
 	_palFadingGreen = 0;
 	_palFadingBlue = 0;
 
-	_animSurf = 0;
 	_animLeft = 0;
 	_animTop = 0;
 	_animWidth = 0;
@@ -111,7 +110,7 @@
 
 void Mult::initAll(void) {
 	_objects = 0;
-	_animSurf = 0;
+	_animSurf.reset();
 	_renderData = 0;
 
 	_vm->_scenery->init();
@@ -145,7 +144,7 @@
 	_renderObjs = 0;
 	_orderArray = 0;
 
-	_animSurf = 0;
+	_animSurf.reset();
 	_vm->_draw->freeSprite(22);
 }
 
@@ -237,7 +236,7 @@
 			_animArrayData = 0;
 			_orderArray = 0;
 
-			_animSurf = 0;
+			_animSurf.reset();
 			_vm->_draw->freeSprite(22);
 
 			_animDataAllocated = false;

Modified: scummvm/trunk/engines/gob/mult.h
===================================================================
--- scummvm/trunk/engines/gob/mult.h	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/mult.h	2009-06-06 20:03:13 UTC (rev 41299)
@@ -232,7 +232,7 @@
 
 	int8 *_orderArray;
 
-	SurfaceDesc::Ptr _animSurf;
+	SurfaceDescPtr _animSurf;
 	int16 _animLeft;
 	int16 _animTop;
 	int16 _animWidth;

Modified: scummvm/trunk/engines/gob/mult_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/mult_v1.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/mult_v1.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -234,7 +234,7 @@
 		_animArrayY = 0;
 		_animArrayData = 0;
 
-		_animSurf = 0;
+		_animSurf.reset();
 		_vm->_draw->freeSprite(22);
 
 		_animDataAllocated = false;
@@ -319,8 +319,8 @@
 				320, 200, 0);
 		_vm->_draw->_spritesArray[22] = _animSurf;
 
-		_vm->_video->drawSprite(_vm->_draw->_backSurface,
-			_animSurf, 0, 0, 319, 199, 0, 0, 0);
+		_vm->_video->drawSprite(*_vm->_draw->_backSurface,
+			*_animSurf, 0, 0, 319, 199, 0, 0, 0);
 
 		_animDataAllocated = true;
 	} else
@@ -349,7 +349,7 @@
 
 		_vm->_scenery->_curStatic = _multData->staticIndices[_vm->_scenery->_curStatic];
 		_vm->_scenery->renderStatic(_vm->_scenery->_curStatic, _vm->_scenery->_curStaticLayer);
-		_vm->_video->drawSprite(_vm->_draw->_backSurface, _animSurf,
+		_vm->_video->drawSprite(*_vm->_draw->_backSurface, *_animSurf,
 		    0, 0, 319, 199, 0, 0, 0);
 	}
 }

Modified: scummvm/trunk/engines/gob/mult_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/mult_v2.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/mult_v2.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -565,8 +565,8 @@
 		_vm->_draw->initSpriteSurf(22, width, height, 0);
 		_animSurf = _vm->_draw->_spritesArray[22];
 
-		_vm->_video->drawSprite(_vm->_draw->_spritesArray[21],
-				_vm->_draw->_spritesArray[22], 0, 0,
+		_vm->_video->drawSprite(*_vm->_draw->_spritesArray[21],
+				*_vm->_draw->_spritesArray[22], 0, 0,
 				_vm->_video->_surfWidth, _vm->_video->_surfHeight, 0, 0, 0);
 
 		for (_counter = 0; _counter < _objCount; _counter++)
@@ -622,8 +622,8 @@
 			_vm->_scenery->_curStatic = -1;
 		}
 
-		_vm->_video->drawSprite(_vm->_draw->_spritesArray[21],
-				_vm->_draw->_spritesArray[22], 0, 0,
+		_vm->_video->drawSprite(*_vm->_draw->_spritesArray[21],
+				*_vm->_draw->_spritesArray[22], 0, 0,
 				_vm->_video->_surfWidth, _vm->_video->_surfHeight, 0, 0, 0);
 	}
 }

Modified: scummvm/trunk/engines/gob/save/savefile.cpp
===================================================================
--- scummvm/trunk/engines/gob/save/savefile.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/save/savefile.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -331,17 +331,14 @@
 	return true;
 }
 
-bool SavePartSprite::readSprite(const SurfaceDesc *sprite) {
-	if (!sprite)
-		return false;
-
+bool SavePartSprite::readSprite(const SurfaceDesc &sprite) {
 	// The sprite's dimensions have to fit
-	if (((uint32) sprite->getWidth()) != _width)
+	if (((uint32)sprite.getWidth()) != _width)
 		return false;
-	if (((uint32) sprite->getHeight()) != _height)
+	if (((uint32)sprite.getHeight()) != _height)
 		return false;
 
-	memcpy(_dataSprite, sprite->getVidMem(), _width * _height);
+	memcpy(_dataSprite, sprite.getVidMem(), _width * _height);
 
 	return true;
 }
@@ -360,17 +357,14 @@
 	return true;
 }
 
-bool SavePartSprite::writeSprite(SurfaceDesc *sprite) const {
-	if (!sprite)
-		return false;
-
+bool SavePartSprite::writeSprite(SurfaceDesc &sprite) const {
 	// The sprite's dimensions have to fit
-	if (((uint32) sprite->getWidth()) != _width)
+	if (((uint32)sprite.getWidth()) != _width)
 		return false;
-	if (((uint32) sprite->getHeight()) != _height)
+	if (((uint32)sprite.getHeight()) != _height)
 		return false;
 
-	memcpy(sprite->getVidMem(), _dataSprite, _width * _height);
+	memcpy(sprite.getVidMem(), _dataSprite, _width * _height);
 
 	return true;
 }

Modified: scummvm/trunk/engines/gob/save/savefile.h
===================================================================
--- scummvm/trunk/engines/gob/save/savefile.h	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/save/savefile.h	2009-06-06 20:03:13 UTC (rev 41299)
@@ -162,7 +162,7 @@
 	/** Read a palette into the part. */
 	bool readPalette(const byte *palette);
 	/** Read a sprite into the part. */
-	bool readSprite(const SurfaceDesc *sprite);
+	bool readSprite(const SurfaceDesc &sprite);
 	
 	/** Read size bytes of raw data into the sprite. */
 	bool readSpriteRaw(const byte *data, uint32 size);
@@ -170,7 +170,7 @@
 	/** Write a palette out of the part. */
 	bool writePalette(byte *palette) const;
 	/** Write a sprite out of the part. */
-	bool writeSprite(SurfaceDesc *sprite) const;
+	bool writeSprite(SurfaceDesc &sprite) const;
 
 private:
 	uint32 _width;

Modified: scummvm/trunk/engines/gob/save/savehandler.cpp
===================================================================
--- scummvm/trunk/engines/gob/save/savehandler.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/save/savehandler.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -242,14 +242,14 @@
 	if ((index < 0) || (index >= SPRITES_COUNT))
 		return false;
 
-	SurfaceDesc *sprite = _vm->_draw->_spritesArray[index];
+	SurfaceDescPtr sprite = _vm->_draw->_spritesArray[index];
 
 	// Target sprite exists?
 	if (!sprite)
 		return false;
 
 	// Load the sprite
-	if (!_sprite->writeSprite(sprite))
+	if (!_sprite->writeSprite(*sprite))
 		return false;
 
 	// Handle palette
@@ -272,13 +272,13 @@
 }
 
 bool TempSpriteHandler::save(int16 dataVar, int32 size, int32 offset) {
-	SurfaceDesc *sprite;
+	SurfaceDescPtr sprite;
 
 	if (!createSprite(dataVar, size, offset, &sprite))
 		return false;
 
 	// Save the sprite
-	if (!_sprite->readSprite(sprite))
+	if (!_sprite->readSprite(*sprite))
 		return false;
 
 	// Handle palette
@@ -291,7 +291,7 @@
 }
 
 bool TempSpriteHandler::createSprite(int16 dataVar, int32 size,
-		int32 offset, SurfaceDesc **sprite) {
+		int32 offset, SurfaceDescPtr *sprite) {
 
 	delete _sprite;
 	_sprite = 0;
@@ -305,7 +305,7 @@
 	if ((index < 0) || (index >= SPRITES_COUNT))
 		return false;
 
-	SurfaceDesc *sprt = _vm->_draw->_spritesArray[index];
+	SurfaceDescPtr sprt = _vm->_draw->_spritesArray[index];
 
 	// Sprite exists?
 	if (!sprt)

Modified: scummvm/trunk/engines/gob/save/savehandler.h
===================================================================
--- scummvm/trunk/engines/gob/save/savehandler.h	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/save/savehandler.h	2009-06-06 20:03:13 UTC (rev 41299)
@@ -27,11 +27,11 @@
 #define GOB_SAVE_SAVEHANDLER_H
 
 #include "common/savefile.h"
+#include "engines/gob/video.h"	// for SurfaceDescPtr
 
 namespace Gob {
 
 class GobEngine;
-class SurfaceDesc;
 class SavePartInfo;
 class SavePartVars;
 class SavePartSprite;
@@ -139,7 +139,7 @@
 
 	/** Create a fitting sprite. */
 	bool createSprite(int16 dataVar, int32 size,
-			int32 offset, SurfaceDesc **sprite = 0);
+			int32 offset, SurfaceDescPtr *sprite = 0);
 
 protected:
 	SavePartSprite *_sprite;

Modified: scummvm/trunk/engines/gob/scenery.cpp
===================================================================
--- scummvm/trunk/engines/gob/scenery.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/scenery.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -192,7 +192,7 @@
 			_spriteResId[sprIndex] = sprResId;
 			_vm->_draw->initSpriteSurf(sprIndex, width, height, 2);
 
-			_vm->_video->clearSurf(_vm->_draw->_spritesArray[sprIndex]);
+			_vm->_video->clearSurf(*_vm->_draw->_spritesArray[sprIndex]);
 			_vm->_draw->_destSurface = sprIndex;
 			_vm->_draw->_spriteLeft = sprResId;
 			_vm->_draw->_transparency = 0;
@@ -517,7 +517,7 @@
 			_animPictToSprite[7 * sceneryIndex + i] = sprIndex;
 			_spriteRefs[sprIndex]++;
 		} else {
-			for (sprIndex = 19; _vm->_draw->_spritesArray[sprIndex] != 0;
+			for (sprIndex = 19; _vm->_draw->_spritesArray[sprIndex];
 				sprIndex--)
 				;
 
@@ -526,7 +526,7 @@
 			_spriteResId[sprIndex] = sprResId;
 			_vm->_draw->initSpriteSurf(sprIndex, width, height, 2);
 
-			_vm->_video->clearSurf(_vm->_draw->_spritesArray[sprIndex]);
+			_vm->_video->clearSurf(*_vm->_draw->_spritesArray[sprIndex]);
 			_vm->_draw->_destSurface = sprIndex;
 			_vm->_draw->_spriteLeft = sprResId;
 			_vm->_draw->_transparency = 0;

Modified: scummvm/trunk/engines/gob/video.cpp
===================================================================
--- scummvm/trunk/engines/gob/video.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/video.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -96,7 +96,6 @@
 	_scrollOffsetX = 0;
 	_scrollOffsetY = 0;
 
-	_splitSurf = 0;
 	_splitHeight1 = 200;
 	_splitHeight2 = 0;
 	_splitStart = 0;
@@ -148,9 +147,8 @@
 	}
 }
 
-SurfaceDesc *Video::initSurfDesc(int16 vidMode, int16 width, int16 height,
-		int16 flags) {
-	SurfaceDesc *descPtr = 0;
+SurfaceDescPtr Video::initSurfDesc(int16 vidMode, int16 width, int16 height, int16 flags) {
+	SurfaceDescPtr descPtr;
 
 	if (flags & PRIMARY_SURFACE)
 		assert((width == _surfWidth) && (height == _surfHeight));
@@ -170,7 +168,7 @@
 		if (!(flags & SCUMMVM_CURSOR))
 			width = (width + 7) & 0xFFF8;
 
-		descPtr = new SurfaceDesc(vidMode, width, height);
+		descPtr = SurfaceDescPtr(new SurfaceDesc(vidMode, width, height));
 	}
 	return descPtr;
 }
@@ -241,15 +239,15 @@
 	_lastSparse = timeKey;
 }
 
-void Video::putPixel(int16 x, int16 y, int16 color, SurfaceDesc *dest) {
-	if ((x >= dest->getWidth()) || (x < 0) ||
-	    (y >= dest->getHeight()) || (y < 0))
+void Video::putPixel(int16 x, int16 y, int16 color, SurfaceDesc &dest) {
+	if ((x >= dest.getWidth()) || (x < 0) ||
+	    (y >= dest.getHeight()) || (y < 0))
 		return;
 
 	_videoDriver->putPixel(x, y, color, dest);
 }
 
-void Video::fillRect(SurfaceDesc *dest, int16 left, int16 top, int16 right,
+void Video::fillRect(SurfaceDesc &dest, int16 left, int16 top, int16 right,
 		int16 bottom, int16 color) {
 
 	if (_doRangeClamp) {
@@ -258,20 +256,20 @@
 		if (top > bottom)
 			SWAP(top, bottom);
 
-		if ((left >= dest->getWidth()) || (right < 0) ||
-		    (top >= dest->getHeight()) || (bottom < 0))
+		if ((left >= dest.getWidth()) || (right < 0) ||
+		    (top >= dest.getHeight()) || (bottom < 0))
 			return;
 
-		left = CLIP(left, (int16) 0, (int16) (dest->getWidth() - 1));
-		top = CLIP(top, (int16) 0, (int16) (dest->getHeight() - 1));
-		right = CLIP(right, (int16) 0, (int16) (dest->getWidth() - 1));
-		bottom = CLIP(bottom, (int16) 0, (int16) (dest->getHeight() - 1));
+		left = CLIP(left, (int16)0, (int16)(dest.getWidth() - 1));
+		top = CLIP(top, (int16)0, (int16)(dest.getHeight() - 1));
+		right = CLIP(right, (int16)0, (int16)(dest.getWidth() - 1));
+		bottom = CLIP(bottom, (int16)0, (int16)(dest.getHeight() - 1));
 	}
 
 	_videoDriver->fillRect(dest, left, top, right, bottom, color);
 }
 
-void Video::drawLine(SurfaceDesc *dest, int16 x0, int16 y0, int16 x1,
+void Video::drawLine(SurfaceDesc &dest, int16 x0, int16 y0, int16 x1,
 		int16 y1, int16 color) {
 
 	if ((x0 == x1) || (y0 == y1))
@@ -286,7 +284,7 @@
  * version found in the Wikipedia article about the
  * "Bresenham's line algorithm" instead
  */
-void Video::drawCircle(SurfaceDesc *dest, int16 x0, int16 y0,
+void Video::drawCircle(SurfaceDesc &dest, int16 x0, int16 y0,
 		int16 radius, int16 color) {
 	int16 f = 1 - radius;
 	int16 ddFx = 0;
@@ -319,11 +317,11 @@
 	}
 }
 
-void Video::clearSurf(SurfaceDesc *dest) {
-	Video::fillRect(dest, 0, 0, dest->getWidth() - 1, dest->getHeight() - 1, 0);
+void Video::clearSurf(SurfaceDesc &dest) {
+	Video::fillRect(dest, 0, 0, dest.getWidth() - 1, dest.getHeight() - 1, 0);
 }
 
-void Video::drawSprite(SurfaceDesc *source, SurfaceDesc *dest,
+void Video::drawSprite(SurfaceDesc &source, SurfaceDesc &dest,
 	    int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp) {
 	int16 destRight;
 	int16 destBottom;
@@ -334,8 +332,8 @@
 		if (top > bottom)
 			SWAP(top, bottom);
 
-		if ((left >= source->getWidth()) || (right < 0) ||
-		    (top >= source->getHeight()) || (bottom < 0))
+		if ((left >= source.getWidth()) || (right < 0) ||
+		    (top >= source.getHeight()) || (bottom < 0))
 			return;
 
 		if (left < 0) {
@@ -346,12 +344,12 @@
 			y -= top;
 			top = 0;
 		}
-		right = CLIP(right, (int16) 0, (int16) (source->getWidth() - 1));
-		bottom = CLIP(bottom, (int16) 0, (int16) (source->getHeight() - 1));
-		if (right - left >= source->getWidth())
-			right = left + source->getWidth() - 1;
-		if (bottom - top >= source->getHeight())
-			bottom = top + source->getHeight() - 1;
+		right = CLIP(right, (int16)0, (int16)(source.getWidth() - 1));
+		bottom = CLIP(bottom, (int16)0, (int16)(source.getHeight() - 1));
+		if (right - left >= source.getWidth())
+			right = left + source.getWidth() - 1;
+		if (bottom - top >= source.getHeight())
+			bottom = top + source.getHeight() - 1;
 
 		if (x < 0) {
 			left -= x;
@@ -361,30 +359,30 @@
 			top -= y;
 			y = 0;
 		}
-		if ((x >= dest->getWidth()) || (left > right) ||
-		    (y >= dest->getHeight()) || (top > bottom))
+		if ((x >= dest.getWidth()) || (left > right) ||
+		    (y >= dest.getHeight()) || (top > bottom))
 			return;
 
 		destRight = x + right - left;
 		destBottom = y + bottom - top;
-		if (destRight >= dest->getWidth())
-			right -= destRight - dest->getWidth() + 1;
+		if (destRight >= dest.getWidth())
+			right -= destRight - dest.getWidth() + 1;
 
-		if (destBottom >= dest->getHeight())
-			bottom -= destBottom - dest->getHeight() + 1;
+		if (destBottom >= dest.getHeight())
+			bottom -= destBottom - dest.getHeight() + 1;
 	}
 
 	_videoDriver->drawSprite(source, dest, left, top, right, bottom, x, y, transp);
 }
 
-void Video::drawSpriteDouble(SurfaceDesc *source, SurfaceDesc *dest,
+void Video::drawSpriteDouble(SurfaceDesc &source, SurfaceDesc &dest,
 	    int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp) {
 
 	_videoDriver->drawSpriteDouble(source, dest, left, top, right, bottom, x, y, transp);
 }
 
 void Video::drawLetter(int16 item, int16 x, int16 y, FontDesc *fontDesc,
-		int16 color1, int16 color2, int16 transp, SurfaceDesc *dest) {
+		int16 color1, int16 color2, int16 transp, SurfaceDesc &dest) {
 	byte *dataPtr;
 	byte *itemData;
 	int16 itemSize;
@@ -417,25 +415,25 @@
 		item = 0;
 	}
 
-	_videoDriver->drawLetter((unsigned char) item, x, y, fontDesc, color1, color2, transp, dest);
+	_videoDriver->drawLetter((unsigned char)item, x, y, fontDesc, color1, color2, transp, dest);
 }
 
 void Video::drawPackedSprite(byte *sprBuf, int16 width, int16 height,
-		int16 x, int16 y, int16 transp, SurfaceDesc *dest) {
+		int16 x, int16 y, int16 transp, SurfaceDesc &dest) {
 
 	if (spriteUncompressor(sprBuf, width, height, x, y, transp, dest))
 		return;
 
-	_vm->validateVideoMode(dest->_vidMode);
+	_vm->validateVideoMode(dest._vidMode);
 
 	_videoDriver->drawPackedSprite(sprBuf, width, height, x, y, transp, dest);
 }
 
-void Video::drawPackedSprite(const char *path, SurfaceDesc *dest, int width) {
+void Video::drawPackedSprite(const char *path, SurfaceDesc &dest, int width) {
 	byte *data;
 
 	data = _vm->_dataIO->getData(path);
-	drawPackedSprite(data, width, dest->getHeight(), 0, 0, 0, dest);
+	drawPackedSprite(data, width, dest.getHeight(), 0, 0, 0, dest);
 	delete[] data;
 }
 

Modified: scummvm/trunk/engines/gob/video.h
===================================================================
--- scummvm/trunk/engines/gob/video.h	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/video.h	2009-06-06 20:03:13 UTC (rev 41299)
@@ -28,9 +28,9 @@
 
 #include "common/list.h"
 #include "common/rect.h"
+#include "common/ptr.h"
 
 #include "gob/gob.h"
-#include "gob/helper.h"
 
 namespace Graphics {
 	class PaletteLUT;
@@ -39,9 +39,9 @@
 namespace Gob {
 
 // Some Surfaces are simultaneous in Draw::spritesArray and discrete
-// variables, so it's a references counting class that cleans
-// up its own mess
-class SurfaceDesc : public ReferenceCounter<SurfaceDesc> {
+// variables, so if in doubt you should use a SurfaceDescPtr shared
+// pointer object to refer to any SurfaceDesc.
+class SurfaceDesc {
 public:
 	int16 _vidMode;
 
@@ -66,6 +66,9 @@
 	bool _ownVidMem;
 };
 
+typedef Common::SharedPtr<SurfaceDesc> SurfaceDescPtr;
+
+
 class Video {
 public:
 	struct FontDesc {
@@ -117,7 +120,7 @@
 	int16 _scrollOffsetX;
 	int16 _scrollOffsetY;
 
-	SurfaceDesc::Ptr _splitSurf;
+	SurfaceDescPtr _splitSurf;
 	int16 _splitHeight1;
 	int16 _splitHeight2;
 	int16 _splitStart;
@@ -129,7 +132,7 @@
 
 	void freeDriver();
 	void initPrimary(int16 mode);
-	SurfaceDesc *initSurfDesc(int16 vidMode, int16 width,
+	SurfaceDescPtr initSurfDesc(int16 vidMode, int16 width,
 			int16 height, int16 flags);
 
 	void setSize(bool defaultTo1XScaler);
@@ -139,24 +142,24 @@
 	void waitRetrace(bool mouse = true);
 	void sparseRetrace(int max);
 
-	void putPixel(int16 x, int16 y, int16 color, SurfaceDesc *dest);
-	virtual void fillRect(SurfaceDesc *dest, int16 left, int16 top,
+	void putPixel(int16 x, int16 y, int16 color, SurfaceDesc &dest);
+	virtual void fillRect(SurfaceDesc &dest, int16 left, int16 top,
 			int16 right, int16 bottom, int16 color);
-	void drawLine(SurfaceDesc *dest, int16 x0, int16 y0, int16 x1, int16 y1,
+	void drawLine(SurfaceDesc &dest, int16 x0, int16 y0, int16 x1, int16 y1,
 				  int16 color);
-	void drawCircle(SurfaceDesc *dest, int16 x0, int16 y0,
+	void drawCircle(SurfaceDesc &dest, int16 x0, int16 y0,
 			int16 radius, int16 color);
-	void clearSurf(SurfaceDesc *dest);
-	void drawSprite(SurfaceDesc *source, SurfaceDesc *dest,
+	void clearSurf(SurfaceDesc &dest);
+	void drawSprite(SurfaceDesc &source, SurfaceDesc &dest,
 			int16 left, int16 top, int16 right, int16 bottom,
 			int16 x, int16 y, int16 transp);
-	void drawSpriteDouble(SurfaceDesc *source, SurfaceDesc *dest,
+	void drawSpriteDouble(SurfaceDesc &source, SurfaceDesc &dest,
 	    int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp);
 	void drawLetter(int16 item, int16 x, int16 y, FontDesc *fontDesc,
-			int16 color1, int16 color2, int16 transp, SurfaceDesc *dest);
+			int16 color1, int16 color2, int16 transp, SurfaceDesc &dest);
 	void drawPackedSprite(byte *sprBuf, int16 width, int16 height,
-			int16 x, int16 y, int16 transp, SurfaceDesc *dest);
-	void drawPackedSprite(const char *path, SurfaceDesc *dest,
+			int16 x, int16 y, int16 transp, SurfaceDesc &dest);
+	void drawPackedSprite(const char *path, SurfaceDesc &dest,
 			int width = 320);
 
 	void setPalColor(byte *pal, byte red, byte green, byte blue) {
@@ -181,7 +184,7 @@
 
 	virtual char spriteUncompressor(byte *sprBuf, int16 srcWidth,
 			int16 srcHeight, int16 x, int16 y, int16 transp,
-			SurfaceDesc *destDesc) = 0;
+			SurfaceDesc &destDesc) = 0;
 
 	virtual void init() {}
 
@@ -210,7 +213,7 @@
 class Video_v1 : public Video {
 public:
 	virtual char spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight,
-			int16 x, int16 y, int16 transp, SurfaceDesc *destDesc);
+			int16 x, int16 y, int16 transp, SurfaceDesc &destDesc);
 
 	Video_v1(GobEngine *vm);
 	virtual ~Video_v1() {}
@@ -219,7 +222,7 @@
 class Video_v2 : public Video_v1 {
 public:
 	virtual char spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight,
-			int16 x, int16 y, int16 transp, SurfaceDesc *destDesc);
+			int16 x, int16 y, int16 transp, SurfaceDesc &destDesc);
 
 	Video_v2(GobEngine *vm);
 	virtual ~Video_v2() {}
@@ -228,9 +231,9 @@
 class Video_v6 : public Video_v2 {
 public:
 	virtual char spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight,
-			int16 x, int16 y, int16 transp, SurfaceDesc *destDesc);
+			int16 x, int16 y, int16 transp, SurfaceDesc &destDesc);
 
-	virtual void fillRect(SurfaceDesc *dest, int16 left, int16 top,
+	virtual void fillRect(SurfaceDesc &dest, int16 left, int16 top,
 			int16 right, int16 bottom, int16 color);
 
 	virtual void init();
@@ -245,13 +248,13 @@
 
 	void buildPalLUT();
 
-	void shadeRect(SurfaceDesc *dest,
+	void shadeRect(SurfaceDesc &dest,
 			int16 left, int16 top, int16 right, int16 bottom, byte color, byte strength);
 
-	void drawPacked(const byte *sprBuf, int16 x, int16 y, SurfaceDesc *surfDesc);
-	void drawYUVData(const byte *srcData, SurfaceDesc *destDesc,
+	void drawPacked(const byte *sprBuf, int16 x, int16 y, SurfaceDesc &surfDesc);
+	void drawYUVData(const byte *srcData, SurfaceDesc &destDesc,
 			int16 width, int16 height, int16 x, int16 y);
-	void drawYUV(SurfaceDesc *destDesc, int16 x, int16 y,
+	void drawYUV(SurfaceDesc &destDesc, int16 x, int16 y,
 			int16 dataWidth, int16 dataHeight, int16 width, int16 height,
 			const byte *dataY, const byte *dataU, const byte *dataV);
 };
@@ -260,13 +263,13 @@
 public:
 	VideoDriver() {}
 	virtual ~VideoDriver() {}
-	virtual void drawSprite(SurfaceDesc *source, SurfaceDesc *dest, int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp) = 0;
-	virtual void drawSpriteDouble(SurfaceDesc *source, SurfaceDesc *dest, int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp) = 0;
-	virtual void fillRect(SurfaceDesc *dest, int16 left, int16 top, int16 right, int16 bottom, byte color) = 0;
-	virtual void putPixel(int16 x, int16 y, byte color, SurfaceDesc *dest) = 0;
-	virtual void drawLetter(unsigned char item, int16 x, int16 y, Video::FontDesc *fontDesc, byte color1, byte color2, byte transp, SurfaceDesc *dest) = 0;
-	virtual void drawLine(SurfaceDesc *dest, int16 x0, int16 y0, int16 x1, int16 y1, byte color) = 0;
-	virtual void drawPackedSprite(byte *sprBuf, int16 width, int16 height, int16 x, int16 y, byte transp, SurfaceDesc *dest) = 0;
+	virtual void drawSprite(SurfaceDesc &source, SurfaceDesc &dest, int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp) = 0;
+	virtual void drawSpriteDouble(SurfaceDesc &source, SurfaceDesc &dest, int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp) = 0;
+	virtual void fillRect(SurfaceDesc &dest, int16 left, int16 top, int16 right, int16 bottom, byte color) = 0;
+	virtual void putPixel(int16 x, int16 y, byte color, SurfaceDesc &dest) = 0;
+	virtual void drawLetter(unsigned char item, int16 x, int16 y, Video::FontDesc *fontDesc, byte color1, byte color2, byte transp, SurfaceDesc &dest) = 0;
+	virtual void drawLine(SurfaceDesc &dest, int16 x0, int16 y0, int16 x1, int16 y1, byte color) = 0;
+	virtual void drawPackedSprite(byte *sprBuf, int16 width, int16 height, int16 x, int16 y, byte transp, SurfaceDesc &dest) = 0;
 };
 
 } // End of namespace Gob

Modified: scummvm/trunk/engines/gob/video_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/video_v1.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/video_v1.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -34,7 +34,7 @@
 }
 
 char Video_v1::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight,
-	    int16 x, int16 y, int16 transp, SurfaceDesc *destDesc) {
+	    int16 x, int16 y, int16 transp, SurfaceDesc &destDesc) {
 	byte *memBuffer;
 	byte *srcPtr, *destPtr, *linePtr;
 	byte temp;
@@ -46,11 +46,8 @@
 	int16 bufPos;
 	int16 strLen;
 
-	if (!destDesc)
-		return 1;
+	_vm->validateVideoMode(destDesc._vidMode);
 
-	_vm->validateVideoMode(destDesc->_vidMode);
-
 	if (sprBuf[0] != 1)
 		return 0;
 
@@ -59,7 +56,7 @@
 
 	if (sprBuf[2] == 2) {
 		SurfaceDesc sourceDesc(0x13, srcWidth, srcHeight, sprBuf + 3);
-		Video::drawSprite(&sourceDesc, destDesc, 0, 0, srcWidth - 1,
+		Video::drawSprite(sourceDesc, destDesc, 0, 0, srcWidth - 1,
 		    srcHeight - 1, x, y, transp);
 		return 1;
 	} else {
@@ -69,7 +66,7 @@
 		srcPtr = sprBuf + 3;
 		sourceLeft = READ_LE_UINT16(srcPtr);
 
-		destPtr = destDesc->getVidMem() + destDesc->getWidth() * y + x;
+		destPtr = destDesc.getVidMem() + destDesc.getWidth() * y + x;
 
 		curWidth = 0;
 		curHeight = 0;
@@ -96,7 +93,7 @@
 				curWidth++;
 				if (curWidth >= srcWidth) {
 					curWidth = 0;
-					linePtr += destDesc->getWidth();
+					linePtr += destDesc.getWidth();
 					destPtr = linePtr;
 					curHeight++;
 					if (curHeight >= srcHeight)
@@ -125,7 +122,7 @@
 					curWidth++;
 					if (curWidth >= srcWidth) {
 						curWidth = 0;
-						linePtr += destDesc->getWidth();
+						linePtr += destDesc.getWidth();
 						destPtr = linePtr;
 						curHeight++;
 						if (curHeight >= srcHeight) {

Modified: scummvm/trunk/engines/gob/video_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/video_v2.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/video_v2.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -34,7 +34,7 @@
 }
 
 char Video_v2::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight,
-	    int16 x, int16 y, int16 transp, SurfaceDesc *destDesc) {
+	    int16 x, int16 y, int16 transp, SurfaceDesc &destDesc) {
 	byte *memBuffer;
 	byte *srcPtr, *destPtr, *linePtr;
 	byte temp;
@@ -47,11 +47,8 @@
 	int16 strLen;
 	int16 lenCmd;
 
-	if (!destDesc)
-		return 1;
+	_vm->validateVideoMode(destDesc._vidMode);
 
-	_vm->validateVideoMode(destDesc->_vidMode);
-
 	if (sprBuf[0] != 1)
 		return 0;
 
@@ -60,7 +57,7 @@
 
 	if (sprBuf[2] == 2) {
 		SurfaceDesc sourceDesc(0x13, srcWidth, srcHeight, sprBuf + 3);
-		Video::drawSprite(&sourceDesc, destDesc, 0, 0, srcWidth - 1,
+		Video::drawSprite(sourceDesc, destDesc, 0, 0, srcWidth - 1,
 		    srcHeight - 1, x, y, transp);
 		return 1;
 	} else if (sprBuf[2] == 1) {
@@ -70,7 +67,7 @@
 		srcPtr = sprBuf + 3;
 		sourceLeft = READ_LE_UINT32(srcPtr);
 
-		destPtr = destDesc->getVidMem() + destDesc->getWidth() * y + x;
+		destPtr = destDesc.getVidMem() + destDesc.getWidth() * y + x;
 
 		curWidth = 0;
 		curHeight = 0;
@@ -104,7 +101,7 @@
 				curWidth++;
 				if (curWidth >= srcWidth) {
 					curWidth = 0;
-					linePtr += destDesc->getWidth();
+					linePtr += destDesc.getWidth();
 					destPtr = linePtr;
 					curHeight++;
 					if (curHeight >= srcHeight)
@@ -133,7 +130,7 @@
 					curWidth++;
 					if (curWidth >= srcWidth) {
 						curWidth = 0;
-						linePtr += destDesc->getWidth();
+						linePtr += destDesc.getWidth();
 						destPtr = linePtr;
 						curHeight++;
 						if (curHeight >= srcHeight) {

Modified: scummvm/trunk/engines/gob/video_v6.cpp
===================================================================
--- scummvm/trunk/engines/gob/video_v6.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/video_v6.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -76,12 +76,9 @@
 }
 
 char Video_v6::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight,
-	    int16 x, int16 y, int16 transp, SurfaceDesc *destDesc) {
-	if (!destDesc)
-		return 1;
+	    int16 x, int16 y, int16 transp, SurfaceDesc &destDesc) {
+	_vm->validateVideoMode(destDesc._vidMode);
 
-	_vm->validateVideoMode(destDesc->_vidMode);
-
 	if ((sprBuf[0] == 1) && (sprBuf[1] == 3)) {
 		drawPacked(sprBuf, x, y, destDesc);
 		return 1;
@@ -92,7 +89,7 @@
 	return 1;
 }
 
-void Video_v6::fillRect(SurfaceDesc *dest,
+void Video_v6::fillRect(SurfaceDesc &dest,
 		int16 left, int16 top, int16 right, int16 bottom, int16 color) {
 
 	if (!(color & 0xFF00)) {
@@ -111,27 +108,27 @@
 		if (top > bottom)
 			SWAP(top, bottom);
 
-		if ((left >= dest->getWidth()) || (right < 0) ||
-		    (top >= dest->getHeight()) || (bottom < 0))
+		if ((left >= dest.getWidth()) || (right < 0) ||
+		    (top >= dest.getHeight()) || (bottom < 0))
 			return;
 
-		left = CLIP(left, (int16) 0, (int16) (dest->getWidth() - 1));
-		top = CLIP(top, (int16) 0, (int16) (dest->getHeight() - 1));
-		right = CLIP(right, (int16) 0, (int16) (dest->getWidth() - 1));
-		bottom = CLIP(bottom, (int16) 0, (int16) (dest->getHeight() - 1));
+		left = CLIP(left, (int16)0, (int16)(dest.getWidth() - 1));
+		top = CLIP(top, (int16)0, (int16)(dest.getHeight() - 1));
+		right = CLIP(right, (int16)0, (int16)(dest.getWidth() - 1));
+		bottom = CLIP(bottom, (int16)0, (int16)(dest.getHeight() - 1));
 	}
 
 	byte strength = 16 - (((uint16) color) >> 12);
 	shadeRect(dest, left, top, right, bottom, color, strength);
 }
 
-void Video_v6::shadeRect(SurfaceDesc *dest,
+void Video_v6::shadeRect(SurfaceDesc &dest,
 		int16 left, int16 top, int16 right, int16 bottom, byte color, byte strength) {
 
 	int width  = right  - left + 1;
 	int height = bottom - top  + 1;
-	int dWidth = dest->getWidth();
-	byte *vidMem = dest->getVidMem() + dWidth * top + left;
+	int dWidth = dest.getWidth();
+	byte *vidMem = dest.getVidMem() + dWidth * top + left;
 
 	byte sY, sU, sV;
 	_palLUT->getEntry(color, sY, sU, sV);
@@ -166,7 +163,7 @@
 	delete dither;
 }
 
-void Video_v6::drawPacked(const byte *sprBuf, int16 x, int16 y, SurfaceDesc *surfDesc) {
+void Video_v6::drawPacked(const byte *sprBuf, int16 x, int16 y, SurfaceDesc &surfDesc) {
 	const byte *data = sprBuf + 2;
 
 	int16 width = READ_LE_UINT16(data);
@@ -192,7 +189,7 @@
 	delete[] uncBuf;
 }
 
-void Video_v6::drawYUVData(const byte *srcData, SurfaceDesc *destDesc,
+void Video_v6::drawYUVData(const byte *srcData, SurfaceDesc &destDesc,
 		int16 width, int16 height, int16 x, int16 y) {
 
 	int16 dataWidth = width;
@@ -211,16 +208,16 @@
 
 }
 
-void Video_v6::drawYUV(SurfaceDesc *destDesc, int16 x, int16 y,
+void Video_v6::drawYUV(SurfaceDesc &destDesc, int16 x, int16 y,
 		int16 dataWidth, int16 dataHeight, int16 width, int16 height,
 		const byte *dataY, const byte *dataU, const byte *dataV) {
 
-	byte *vidMem = destDesc->getVidMem() + y * destDesc->getWidth() + x;
+	byte *vidMem = destDesc.getVidMem() + y * destDesc.getWidth() + x;
 
-	if ((x + width - 1) >= destDesc->getWidth())
-		width = destDesc->getWidth() - x;
-	if ((y + height - 1) >= destDesc->getHeight())
-		height = destDesc->getHeight() - y;
+	if ((x + width - 1) >= destDesc.getWidth())
+		width = destDesc.getWidth() - x;
+	if ((y + height - 1) >= destDesc.getHeight())
+		height = destDesc.getHeight() - y;
 
 	Graphics::SierraLight *dither =
 		new Graphics::SierraLight(width, _palLUT);
@@ -240,7 +237,7 @@
 		}
 
 		dither->nextLine();
-		vidMem += destDesc->getWidth();
+		vidMem += destDesc.getWidth();
 	}
 
 	delete dither;

Modified: scummvm/trunk/engines/gob/videoplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/videoplayer.cpp	2009-06-06 19:50:54 UTC (rev 41298)
+++ scummvm/trunk/engines/gob/videoplayer.cpp	2009-06-06 20:03:13 UTC (rev 41299)
@@ -256,7 +256,7 @@
 		_ownSurf = false;
 
 		if (!(flags & kFlagNoVideo)) {
-			SurfaceDesc::Ptr surf;
+			SurfaceDescPtr surf;
 
 			if (flags & kFlagOtherSurface) {
 				_ownSurf = true;


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