[Scummvm-cvs-logs] SF.net SVN: scummvm:[46280] scummvm/trunk/engines/m4

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Dec 7 19:22:18 CET 2009


Revision: 46280
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46280&view=rev
Author:   fingolfin
Date:     2009-12-07 18:22:18 +0000 (Mon, 07 Dec 2009)

Log Message:
-----------
M4: Make M4Surface member w, h, pixels protected; some cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/m4/actor.cpp
    scummvm/trunk/engines/m4/animation.cpp
    scummvm/trunk/engines/m4/console.cpp
    scummvm/trunk/engines/m4/events.cpp
    scummvm/trunk/engines/m4/graphics.h
    scummvm/trunk/engines/m4/m4_menus.cpp
    scummvm/trunk/engines/m4/mads_anim.cpp
    scummvm/trunk/engines/m4/mads_menus.cpp
    scummvm/trunk/engines/m4/rails.cpp
    scummvm/trunk/engines/m4/scene.cpp
    scummvm/trunk/engines/m4/viewmgr.cpp
    scummvm/trunk/engines/m4/ws_sequence.cpp

Modified: scummvm/trunk/engines/m4/actor.cpp
===================================================================
--- scummvm/trunk/engines/m4/actor.cpp	2009-12-07 18:20:20 UTC (rev 46279)
+++ scummvm/trunk/engines/m4/actor.cpp	2009-12-07 18:22:18 UTC (rev 46280)
@@ -44,8 +44,8 @@
 	unloadWalkers();
 }
 
-int Actor::getWalkerWidth() { return _walkerSprites[kFacingSouth]->getFrame(0)->w; }
-int Actor::getWalkerHeight() { return _walkerSprites[kFacingSouth]->getFrame(0)->h; }
+int Actor::getWalkerWidth() { return _walkerSprites[kFacingSouth]->getFrame(0)->width(); }
+int Actor::getWalkerHeight() { return _walkerSprites[kFacingSouth]->getFrame(0)->height(); }
 
 void Actor::placeWalkerSpriteAt(int spriteNum, int x, int y) {
 	if (_direction < 1 || _direction > 9) {
@@ -55,8 +55,8 @@
 	SpriteInfo info;
 	info.sprite = _walkerSprites[_direction]->getFrame(spriteNum);
 	info.hotX = info.hotY = 0;
-	info.width = info.sprite->w;
-	info.height = info.sprite->h;
+	info.width = info.sprite->width();
+	info.height = info.sprite->height();
 	info.scaleX = info.scaleY = _scaling;
 	info.palette = _walkerSprites[_direction]->getPalette();
 	info.inverseColorTable = _vm->_scene->getInverseColorTable();

Modified: scummvm/trunk/engines/m4/animation.cpp
===================================================================
--- scummvm/trunk/engines/m4/animation.cpp	2009-12-07 18:20:20 UTC (rev 46279)
+++ scummvm/trunk/engines/m4/animation.cpp	2009-12-07 18:22:18 UTC (rev 46280)
@@ -176,7 +176,7 @@
 		M4Sprite *spr = _spriteSeries->getFrame(seriesFrameIndex);
 
 		// FIXME: We assume that the transparent color is the color of the top left pixel
-		byte *transparentColor = (byte *)spr->pixels;
+		byte *transparentColor = spr->getBasePtr(0, 0);
 
 		// FIXME: correct x, y
 		spr->copyTo(bg, frame->x, frame->y, (int)*transparentColor);

Modified: scummvm/trunk/engines/m4/console.cpp
===================================================================
--- scummvm/trunk/engines/m4/console.cpp	2009-12-07 18:20:20 UTC (rev 46279)
+++ scummvm/trunk/engines/m4/console.cpp	2009-12-07 18:22:18 UTC (rev 46280)
@@ -224,7 +224,7 @@
 				break;
 
 			// FIXME: We assume that the transparent color is the color of the top left pixel
-			byte *transparentColor = (byte *)spr->pixels;
+			byte *transparentColor = spr->getBasePtr(0, 0);
 
 			spr->copyTo(bg, x, y, (int)*transparentColor);
 

Modified: scummvm/trunk/engines/m4/events.cpp
===================================================================
--- scummvm/trunk/engines/m4/events.cpp	2009-12-07 18:20:20 UTC (rev 46279)
+++ scummvm/trunk/engines/m4/events.cpp	2009-12-07 18:22:18 UTC (rev 46280)
@@ -240,7 +240,7 @@
 	_cursor = _cursorSprites->getFrame(cursorIndex);
 
 	// Set the cursor to the sprite
-	CursorMan.replaceCursor((const byte *)_cursor->getBasePtr(), _cursor->w, _cursor->h, _cursor->xOffset, _cursor->yOffset, 0);
+	CursorMan.replaceCursor((const byte *)_cursor->getBasePtr(), _cursor->width(), _cursor->height(), _cursor->xOffset, _cursor->yOffset, 0);
 
 	return true;
 }

Modified: scummvm/trunk/engines/m4/graphics.h
===================================================================
--- scummvm/trunk/engines/m4/graphics.h	2009-12-07 18:20:20 UTC (rev 46279)
+++ scummvm/trunk/engines/m4/graphics.h	2009-12-07 18:22:18 UTC (rev 46280)
@@ -83,7 +83,7 @@
 	RGB8 *palette;
 };
 
-class M4Surface : public Graphics::Surface {
+class M4Surface : protected Graphics::Surface {
 private:
 	byte _color;
 	bool _isScreen;
@@ -96,7 +96,10 @@
 		create(g_system->getWidth(), g_system->getHeight(), 1);
 		_isScreen = isScreen;
 	}
-	M4Surface(int Width, int Height) { create(Width, Height, 1); _isScreen = false; }
+	M4Surface(int width_, int height_) {
+		create(width_, height_, 1);
+		_isScreen = false;
+	}
 
 	// loads a .COD file into the M4Surface
 	// TODO: maybe move this to the rail system? check where it makes sense
@@ -110,7 +113,7 @@
 	void madsloadInterface(int index, RGBList **palData);
 
 	void setColor(byte value) { _color = value; }
-	byte getColor() { return _color; }
+	inline byte getColor() const { return _color; }
 	void vLine(int x, int y1, int y2);
 	void hLine(int x1, int x2, int y);
 	void vLineXor(int x, int y1, int y2);
@@ -122,8 +125,8 @@
 	void drawSprite(int x, int y, SpriteInfo &info, const Common::Rect &clipRect);
 
 	// Surface methods
-	int width() { return w; }
-	int height() { return h; }
+	inline int width() const { return w; }
+	inline int height() const { return h; }
 	void setSize(int sizeX, int sizeY) { create(sizeX, sizeY, 1); }
 	inline byte *getBasePtr() {
 		return (byte *)pixels;
@@ -149,13 +152,13 @@
 	}
 
 	// copyTo methods
-	void copyTo(M4Surface *dest, int transparentColor = -1) {
+	inline void copyTo(M4Surface *dest, int transparentColor = -1) {
 		dest->copyFrom(this, Common::Rect(width(), height()), 0, 0, transparentColor);
 	}
-	void copyTo(M4Surface *dest, int x, int y, int transparentColor = -1) {
+	inline void copyTo(M4Surface *dest, int x, int y, int transparentColor = -1) {
 		dest->copyFrom(this, Common::Rect(width(), height()), x, y, transparentColor);
 	}
-	void copyTo(M4Surface *dest, const Common::Rect &srcBounds, int destX, int destY,
+	inline void copyTo(M4Surface *dest, const Common::Rect &srcBounds, int destX, int destY,
 				int transparentColor = -1) {
 		dest->copyFrom(this, srcBounds, destX, destY, transparentColor);
 	}

Modified: scummvm/trunk/engines/m4/m4_menus.cpp
===================================================================
--- scummvm/trunk/engines/m4/m4_menus.cpp	2009-12-07 18:20:20 UTC (rev 46279)
+++ scummvm/trunk/engines/m4/m4_menus.cpp	2009-12-07 18:22:18 UTC (rev 46280)
@@ -472,8 +472,8 @@
 	// Translate the scene data
 
 	_vm->_scene->onRefresh(NULL, &srcSurface);
-	byte *srcP = (byte *)srcSurface.pixels;
-	byte *destP = (byte *)result->pixels;
+	byte *srcP = srcSurface.getBasePtr(0, 0);
+	byte *destP = result->getBasePtr(0, 0);
 
 	for (int yCtr = 0; yCtr < _vm->_scene->height() / 3; ++yCtr, srcP += g_system->getWidth() * 3) {
 		byte *src0P = srcP;
@@ -499,12 +499,12 @@
 	// averaged, simply take the top left pixel of every 3x3 pixel block
 
 	_vm->_interfaceView->onRefresh(NULL, &srcSurface);
-	destP = (byte *)result->pixels + (_vm->_screen->width() / 3) * (_vm->_interfaceView->bounds().top / 3);
+	destP = result->getBasePtr(0, 0) + (_vm->_screen->width() / 3) * (_vm->_interfaceView->bounds().top / 3);
 
 	int yStart = _vm->_interfaceView->bounds().top;
 	int yEnd = MIN(_vm->_screen->height() - 1, (int) _vm->_interfaceView->bounds().bottom - 1);
 	for (int yCtr = yStart; yCtr <= yEnd; yCtr += 3) {
-		srcP = (byte *)srcSurface.pixels + (yCtr * _vm->_screen->width());
+		srcP = (byte *)srcSurface.getBasePtr(0, yCtr) + (yCtr * _vm->_screen->width());
 
 		for (int xCtr = 0; xCtr < result->width(); ++xCtr, srcP += 3)
 			*destP++ = *srcP;

Modified: scummvm/trunk/engines/m4/mads_anim.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_anim.cpp	2009-12-07 18:20:20 UTC (rev 46279)
+++ scummvm/trunk/engines/m4/mads_anim.cpp	2009-12-07 18:22:18 UTC (rev 46280)
@@ -206,13 +206,13 @@
 				Common::copy(srcP, srcP + _bgSurface.width(), destP);
 			}
 
-			Common::copy(linesTemp, linesTemp + _panY * _bgSurface.width(), (byte *)_bgSurface.pixels);
+			Common::copy(linesTemp, linesTemp + _panY * _bgSurface.width(), _bgSurface.getBasePtr(0, 0));
 			delete[] linesTemp;
 		}
 	}
 
 	// Scroll the text surface up by one row
-	byte *pixelsP = (byte *)_textSurface.pixels;
+	byte *pixelsP = _textSurface.getBasePtr(0, 0);
 	Common::copy(pixelsP + width(),  pixelsP + _textSurface.width() * _textSurface.height(), pixelsP);
 	pixelsP = _textSurface.getBasePtr(0, _textSurface.height() - 1);
 	Common::set_to(pixelsP, pixelsP + _textSurface.width(), _vm->_palette->BLACK);

Modified: scummvm/trunk/engines/m4/mads_menus.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_menus.cpp	2009-12-07 18:20:20 UTC (rev 46279)
+++ scummvm/trunk/engines/m4/mads_menus.cpp	2009-12-07 18:22:18 UTC (rev 46280)
@@ -529,7 +529,7 @@
 
 	spr = _menuItem->getFrame(1);
 	// FIXME: We assume that the transparent color is the color of the top left pixel
-	byte *transparentColor = (byte *)spr->pixels;
+	byte *transparentColor = spr->getBasePtr(0, 0);
 	spr->copyTo(this, spr->xOffset - 140, spr->yOffset - spr->height(), (int)*transparentColor);
 
 	_vm->_mouse->cursorOn();

Modified: scummvm/trunk/engines/m4/rails.cpp
===================================================================
--- scummvm/trunk/engines/m4/rails.cpp	2009-12-07 18:20:20 UTC (rev 46279)
+++ scummvm/trunk/engines/m4/rails.cpp	2009-12-07 18:22:18 UTC (rev 46280)
@@ -79,7 +79,7 @@
 		return;
 	else {
 	   M4Surface *codes = isWalkableData->codes;
-	   if (x >= 0 && x < codes->w && y >= 0 && y < codes->h) {
+	   if (x >= 0 && x < codes->width() && y >= 0 && y < codes->height()) {
 			isWalkableData->result = !((*((uint8*)codes->getBasePtr(x, y))) & 0x10);
 		} else {
 			isWalkableData->result = false;

Modified: scummvm/trunk/engines/m4/scene.cpp
===================================================================
--- scummvm/trunk/engines/m4/scene.cpp	2009-12-07 18:20:20 UTC (rev 46279)
+++ scummvm/trunk/engines/m4/scene.cpp	2009-12-07 18:22:18 UTC (rev 46280)
@@ -435,8 +435,8 @@
 
 // Test function, shows all scene codes
 void Scene::showCodes() {
-	uint8 *pixelData = (uint8*)_codeSurface->pixels;
-	for (int i = 0; i < _codeSurface->w * _codeSurface->h; i++)
+	uint8 *pixelData = _codeSurface->getBasePtr(0, 0);
+	for (int i = 0; i < _codeSurface->width() * _codeSurface->height(); i++)
 		if (pixelData[i] & 0x10)
 			pixelData[i] = 0xFF;
 		else
@@ -450,7 +450,7 @@
 	_vm->_palette->setPalette(colors, 0, 256);
 
 	_backgroundSurface->copyFrom(_codeSurface, Common::Rect(0, 0, 640, 480), 0, 0);
-	//_system->copyRectToScreen((byte *)codes->pixels, codes->w, 0, 0, codes->w, codes->h);
+	//_system->copyRectToScreen(codes->getBasePtr(0, 0), codes->w, 0, 0, codes->w, codes->h);
 }
 
 void Scene::playIntro() {

Modified: scummvm/trunk/engines/m4/viewmgr.cpp
===================================================================
--- scummvm/trunk/engines/m4/viewmgr.cpp	2009-12-07 18:20:20 UTC (rev 46279)
+++ scummvm/trunk/engines/m4/viewmgr.cpp	2009-12-07 18:22:18 UTC (rev 46280)
@@ -68,8 +68,7 @@
 
 //--------------------------------------------------------------------------
 
-HotkeyList::HotkeyList(View *owner) {
-	_view = owner;
+HotkeyList::HotkeyList(View *owner) : _view(owner) {
 }
 
 HotkeyList::~HotkeyList() {
@@ -106,14 +105,15 @@
 
 // View constructor
 
-View::View(M4Engine *vm, const Common::Rect &viewBounds, bool transparent):
-	_hotkeys(HotkeyList(this)), M4Surface(viewBounds.width(), viewBounds.height()), _vm(vm) {
+View::View(M4Engine *vm, const Common::Rect &viewBounds, bool transparent)
+	: M4Surface(viewBounds.width(), viewBounds.height()), _hotkeys(this), _vm(vm) {
 	SCREEN_FLAGS_DEFAULT;
 	_coords = viewBounds;
 	_transparent = transparent;
 }
 
-View::View(M4Engine *vm, int x, int y, bool transparent): _hotkeys(HotkeyList(this)), M4Surface(), _vm(vm) {
+View::View(M4Engine *vm, int x, int y, bool transparent)
+	: M4Surface(), _hotkeys(this), _vm(vm) {
 	SCREEN_FLAGS_DEFAULT;
 	_coords.left = x;
 	_coords.top = y;

Modified: scummvm/trunk/engines/m4/ws_sequence.cpp
===================================================================
--- scummvm/trunk/engines/m4/ws_sequence.cpp	2009-12-07 18:20:20 UTC (rev 46279)
+++ scummvm/trunk/engines/m4/ws_sequence.cpp	2009-12-07 18:22:18 UTC (rev 46280)
@@ -291,8 +291,8 @@
 	info.encoding = _curFrame->encoding;
 	info.inverseColorTable = _vm->_scene->getInverseColorTable();
 	info.palette = _ws->getMainPalette();
-	info.width = _curFrame->w;
-	info.height = _curFrame->h;
+	info.width = _curFrame->width();
+	info.height = _curFrame->height();
 	int32 scaler = FixedMul(_vars[kSeqVarScale], 100 << 16) >> 16;
 	info.scaleX = _vars[kSeqVarWidth] < 0 ? -scaler : scaler;
 	info.scaleY = scaler;
@@ -750,8 +750,8 @@
 
 	_streamSpriteAsset->loadStreamingFrame(_curFrame, frameNum, _vars[kSeqVarX], _vars[kSeqVarY]);
 
-	_vars[kSeqVarWidth] = _curFrame->w << 16;
-	_vars[kSeqVarHeight] = _curFrame->h << 16;
+	_vars[kSeqVarWidth] = _curFrame->width() << 16;
+	_vars[kSeqVarHeight] = _curFrame->height() << 16;
 
 	return 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