[Scummvm-cvs-logs] SF.net SVN: scummvm: [30731] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sat Feb 2 10:48:09 CET 2008


Revision: 30731
          http://scummvm.svn.sourceforge.net/scummvm/?rev=30731&view=rev
Author:   peres001
Date:     2008-02-02 01:48:07 -0800 (Sat, 02 Feb 2008)

Log Message:
-----------
Some more integration of background code into BackgroundInfo.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/callables_ns.cpp
    scummvm/trunk/engines/parallaction/exec_ns.cpp
    scummvm/trunk/engines/parallaction/graphics.cpp
    scummvm/trunk/engines/parallaction/graphics.h
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parser_br.cpp

Modified: scummvm/trunk/engines/parallaction/callables_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/callables_ns.cpp	2008-02-02 07:18:49 UTC (rev 30730)
+++ scummvm/trunk/engines/parallaction/callables_ns.cpp	2008-02-02 09:48:07 UTC (rev 30731)
@@ -330,8 +330,8 @@
 
 void Parallaction_ns::_c_setMask(void *parm) {
 
-	memset(_gfx->_backgroundInfo->mask.data + 3600, 0, 3600);
-	_gfx->_backgroundInfo->layers[1] = 500;
+	memset(_gfx->_backgroundInfo.mask.data + 3600, 0, 3600);
+	_gfx->_backgroundInfo.layers[1] = 500;
 
 	return;
 }
@@ -584,7 +584,7 @@
 		newx = _rightHandPositions[2*index];
 	}
 
-	Graphics::drawLine(oldx, oldy, newx, newy, 0, zeroMask, _gfx->_backgroundInfo);
+	Graphics::drawLine(oldx, oldy, newx, newy, 0, zeroMask, &_gfx->_backgroundInfo);
 
 	_rightHandAnim->_left = newx;
 	_rightHandAnim->_top = newy - 20;
@@ -606,11 +606,11 @@
 		_rightHandAnim->_top
 	);
 
-	uint16 _di = r.left/4 + r.top * _gfx->_backgroundInfo->mask.internalWidth;
+	uint16 _di = r.left/4 + r.top * _gfx->_backgroundInfo.mask.internalWidth;
 
 	for (uint16 _si = r.top; _si < r.bottom; _si++) {
-		memset(_gfx->_backgroundInfo->mask.data + _di, 0, r.width()/4+1);
-		_di += _gfx->_backgroundInfo->mask.internalWidth;
+		memset(_gfx->_backgroundInfo.mask.data + _di, 0, r.width()/4+1);
+		_di += _gfx->_backgroundInfo.mask.internalWidth;
 	}
 
 	return;

Modified: scummvm/trunk/engines/parallaction/exec_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-02-02 07:18:49 UTC (rev 30730)
+++ scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-02-02 09:48:07 UTC (rev 30731)
@@ -333,7 +333,7 @@
 			if (v18->_flags & kFlagsNoMasked)
 				layer = 3;
 			else
-				layer = _gfx->queryMask(v18->_top + v18->height());
+				layer = _gfx->_backgroundInfo.getLayer(v18->_top + v18->height());
 
 
 			_gfx->showGfxObj(obj, true);

Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp	2008-02-02 07:18:49 UTC (rev 30730)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2008-02-02 09:48:07 UTC (rev 30731)
@@ -32,7 +32,6 @@
 
 namespace Parallaction {
 
-#define BUFFER_FOREGROUND   3
 #define	LABEL_TRANSPARENT_COLOR 0xFF
 #define	BALLOON_TRANSPARENT_COLOR 2
 
@@ -262,7 +261,7 @@
 
 	PaletteFxRange *range;
 	for (uint16 i = 0; i < 4; i++) {
-		range = &_backgroundInfo->ranges[i];
+		range = &_backgroundInfo.ranges[i];
 
 		if ((range->_flags & 1) == 0) continue;		// animated palette
 		range->_timer += range->_step * 2;	// update timer
@@ -326,7 +325,7 @@
 
 	Graphics::Surface *surf = g_system->lockScreen();
 	for (uint i = 0; i < _numItems; i++) {
-	    blt(_items[i].rect, _items[i].data->getData(_items[i].frame), surf, BUFFER_FOREGROUND, 0);
+	    blt(_items[i].rect, _items[i].data->getData(_items[i].frame), surf, LAYER_FOREGROUND, 0);
 	}
 	g_system->unlockScreen();
 }
@@ -340,14 +339,14 @@
 	for (uint i = 0; i < _numBalloons; i++) {
 		Common::Rect r(_balloons[i].surface.w, _balloons[i].surface.h);
 		r.moveTo(_balloons[i].x, _balloons[i].y);
-		blt(r, (byte*)_balloons[i].surface.getBasePtr(0, 0), surf, BUFFER_FOREGROUND, BALLOON_TRANSPARENT_COLOR);
+		blt(r, (byte*)_balloons[i].surface.getBasePtr(0, 0), surf, LAYER_FOREGROUND, BALLOON_TRANSPARENT_COLOR);
 	}
 	g_system->unlockScreen();
 }
 
 void Gfx::updateScreen() {
 
-	g_system->copyRectToScreen((const byte*)_backgroundInfo->bg.pixels, _backgroundInfo->bg.pitch, _screenX, _screenY, _vm->_screenWidth, _vm->_screenHeight);
+	g_system->copyRectToScreen((const byte*)_backgroundInfo.bg.pixels, _backgroundInfo.bg.pitch, _screenX, _screenY, _vm->_screenWidth, _vm->_screenHeight);
 
 	Graphics::Surface *surf = g_system->lockScreen();
 	drawGfxObjects(*surf);
@@ -355,7 +354,7 @@
 	if (_halfbrite) {
 		// FIXME: the implementation of halfbrite is now largely sub-optimal in that a full screen
 		// rewrite is needed to apply the effect.
-		byte *src = (byte*)_backgroundInfo->bg.pixels;
+		byte *src = (byte*)_backgroundInfo.bg.pixels;
 		byte *dst = (byte*)surf->pixels;
 		for (int i = 0; i < surf->w*surf->h; i++) {
 			*dst++ = *src++ | 0x20;
@@ -384,7 +383,7 @@
 //	graphic primitives
 //
 void Gfx::clearBackground() {
-	memset(_backgroundInfo->bg.pixels, 0, _vm->_screenSize);
+	memset(_backgroundInfo.bg.pixels, 0, _vm->_screenSize);
 }
 
 
@@ -393,17 +392,17 @@
 	Common::Rect r(surf.w, surf.h);
 	r.moveTo(x, y);
 
-	uint16 z = (mask) ? queryMask(y) : BUFFER_FOREGROUND;
-	blt(r, (byte*)surf.pixels, &_backgroundInfo->bg, z, 0);
+	uint16 z = (mask) ? _backgroundInfo.getLayer(y) : LAYER_FOREGROUND;
+	blt(r, (byte*)surf.pixels, &_backgroundInfo.bg, z, 0);
 }
 
 void Gfx::fillBackground(const Common::Rect& r, byte color) {
-	_backgroundInfo->bg.fillRect(r, color);
+	_backgroundInfo.bg.fillRect(r, color);
 }
 
 void Gfx::invertBackground(const Common::Rect& r) {
 
-	byte *d = (byte*)_backgroundInfo->bg.getBasePtr(r.left, r.top);
+	byte *d = (byte*)_backgroundInfo.bg.getBasePtr(r.left, r.top);
 
 	for (int i = 0; i < r.height(); i++) {
 		for (int j = 0; j < r.width(); j++) {
@@ -411,7 +410,7 @@
 			d++;
 		}
 
-		d += (_backgroundInfo->bg.pitch - r.width());
+		d += (_backgroundInfo.bg.pitch - r.width());
 	}
 
 }
@@ -437,13 +436,13 @@
 	uint sPitch = r.width() - q.width();
 	uint dPitch = surf->w - q.width();
 
-    if (_backgroundInfo->mask.data && (z < BUFFER_FOREGROUND)) {
+    if (_backgroundInfo.mask.data && (z < LAYER_FOREGROUND)) {
 
         for (uint16 i = 0; i < q.height(); i++) {
 
             for (uint16 j = 0; j < q.width(); j++) {
                 if (*s != transparentColor) {
-                    byte v = _backgroundInfo->mask.getValue(dp.x + j, dp.y + i);
+                    byte v = _backgroundInfo.mask.getValue(dp.x + j, dp.y + i);
                     if (z >= v) *d = *s;
                 }
 
@@ -627,14 +626,14 @@
 		if (_labels[i]->_visible) {
 			Common::Rect r(_labels[i]->_cnv.w, _labels[i]->_cnv.h);
 			r.moveTo(_labels[i]->_pos);
-			blt(r, (byte*)_labels[i]->_cnv.getBasePtr(0, 0), surf, BUFFER_FOREGROUND, LABEL_TRANSPARENT_COLOR);
+			blt(r, (byte*)_labels[i]->_cnv.getBasePtr(0, 0), surf, LAYER_FOREGROUND, LABEL_TRANSPARENT_COLOR);
 		}
 	}
 
 	if (_floatingLabel) {
 		Common::Rect r(_floatingLabel->_cnv.w, _floatingLabel->_cnv.h);
 		r.moveTo(_floatingLabel->_pos);
-        blt(r, (byte*)_floatingLabel->_cnv.getBasePtr(0, 0), surf, BUFFER_FOREGROUND, LABEL_TRANSPARENT_COLOR);
+        blt(r, (byte*)_floatingLabel->_cnv.getBasePtr(0, 0), surf, LAYER_FOREGROUND, LABEL_TRANSPARENT_COLOR);
 	}
 
 	g_system->unlockScreen();
@@ -727,19 +726,10 @@
 }
 
 void Gfx::grabBackground(const Common::Rect& r, Graphics::Surface &dst) {
-	copyRect(r, _backgroundInfo->bg, dst);
+	copyRect(r, _backgroundInfo.bg, dst);
 }
 
 
-uint16 Gfx::queryMask(uint16 v) {
-
-	for (uint16 _si = 0; _si < 3; _si++) {
-		if (_backgroundInfo->layers[_si+1] > v) return _si;
-	}
-
-	return BUFFER_FOREGROUND;
-}
-
 Gfx::Gfx(Parallaction* vm) :
 	_vm(vm), _disk(vm->_disk) {
 
@@ -762,7 +752,6 @@
 	_hbCircleRadius = 0;
 
 	_font = NULL;
-	_backgroundInfo = new BackgroundInfo;
 
 	return;
 }
@@ -770,7 +759,6 @@
 Gfx::~Gfx() {
 
 	freeBackground();
-	delete _backgroundInfo;
 
 	return;
 }
@@ -826,7 +814,7 @@
 		winding = (winding == 0 ? 1 : 0);
 		Common::Rect s(BALLOON_TAIL_WIDTH, BALLOON_TAIL_HEIGHT);
 		s.moveTo(r.width()/2 - 5, r.bottom - 1);
-		blt(s, _resBalloonTail[winding], &balloon->surface, BUFFER_FOREGROUND, BALLOON_TRANSPARENT_COLOR);
+		blt(s, _resBalloonTail[winding], &balloon->surface, LAYER_FOREGROUND, BALLOON_TRANSPARENT_COLOR);
 	}
 
 	_numBalloons++;
@@ -1000,25 +988,18 @@
 }
 
 void Gfx::freeBackground() {
-
-	if (!_backgroundInfo)
-		return;
-
-	_backgroundInfo->bg.free();
-	_backgroundInfo->mask.free();
-	_backgroundInfo->path.free();
-
+	_backgroundInfo.free();
 }
 
 void Gfx::setBackground(uint type, const char* name, const char* mask, const char* path) {
 
 	if (type == kBackgroundLocation) {
-		_disk->loadScenery(*_backgroundInfo, name, mask, path);
-		setPalette(_backgroundInfo->palette);
-		_palette.clone(_backgroundInfo->palette);
+		_disk->loadScenery(_backgroundInfo, name, mask, path);
+		setPalette(_backgroundInfo.palette);
+		_palette.clone(_backgroundInfo.palette);
 	} else {
-		_disk->loadSlide(*_backgroundInfo, name);
-		setPalette(_backgroundInfo->palette);
+		_disk->loadSlide(_backgroundInfo, name);
+		setPalette(_backgroundInfo.palette);
 	}
 
 }

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2008-02-02 07:18:49 UTC (rev 30730)
+++ scummvm/trunk/engines/parallaction/graphics.h	2008-02-02 09:48:07 UTC (rev 30731)
@@ -326,6 +326,8 @@
 
 typedef Common::List<GfxObj*> GfxObjList;
 
+#define LAYER_FOREGROUND   3
+
 struct BackgroundInfo {
 	uint width;
 	uint height;
@@ -348,6 +350,20 @@
 		assert(index < 6);
 		memcpy(&ranges[index], &range, sizeof(PaletteFxRange));
 	}
+
+	uint16 getLayer(uint16 z) {
+		for (uint16 i = 0; i < 3; i++) {
+			if (layers[i+1] > z) return i;
+		}
+		return LAYER_FOREGROUND;
+	}
+
+	void free() {
+		bg.free();
+		mask.free();
+		path.free();
+	}
+
 };
 
 
@@ -394,7 +410,7 @@
 	void freeItems();
 
 	// background surface
-	BackgroundInfo	*_backgroundInfo;
+	BackgroundInfo	_backgroundInfo;
 	void setBackground(uint type, const char* name, const char* mask, const char* path);
 	void clearBackground();
 	void patchBackground(Graphics::Surface &surf, int16 x, int16 y, bool mask = false);
@@ -412,10 +428,6 @@
 	void setHalfbriteMode(bool enable);
 	void setProjectorPos(int x, int y);
 
-	// misc
-	uint16 queryMask(uint16 v);
-	void setMask(MaskBuffer *buffer);
-
 	// init
 	Gfx(Parallaction* vm);
 	virtual ~Gfx();

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2008-02-02 07:18:49 UTC (rev 30730)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2008-02-02 09:48:07 UTC (rev 30731)
@@ -745,7 +745,7 @@
 void Parallaction::setBackground(const char* name, const char* mask, const char* path) {
 
 	_gfx->setBackground(kBackgroundLocation, name, mask, path);
-	_pathBuffer = &_gfx->_backgroundInfo->path;
+	_pathBuffer = &_gfx->_backgroundInfo.path;
 
 	return;
 }

Modified: scummvm/trunk/engines/parallaction/parser_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser_br.cpp	2008-02-02 07:18:49 UTC (rev 30730)
+++ scummvm/trunk/engines/parallaction/parser_br.cpp	2008-02-02 09:48:07 UTC (rev 30731)
@@ -132,9 +132,9 @@
 //		flip();
 //	}
 
-	_gfx->setBackground(&_backgroundInfo->bg);
-	_gfx->_palette.clone(_backgroundInfo->palette);
-	_gfx->setPalette(_backgroundInfo->palette);
+	_gfx->setBackground(&_backgroundInfo.bg);
+	_gfx->_palette.clone(_backgroundInfo.palette);
+	_gfx->setPalette(_backgroundInfo.palette);
 #endif
 
 	if (_tokens[nextToken][0] != '\0') {
@@ -273,7 +273,7 @@
 	debugC(7, kDebugParser, "LOCATION_PARSER(mask) ");
 #if 0
 	_disk->loadScenery(*_backgroundInfo, NULL, _tokens[1], NULL);
-	_gfx->setMask(&_backgroundInfo->mask);
+	_gfx->setMask(&_backgroundInfo.mask);
 
 	_gfx->_bgLayers[0] = atoi(_tokens[2]);
 	_gfx->_bgLayers[1] = atoi(_tokens[3]);
@@ -286,7 +286,7 @@
 	debugC(7, kDebugParser, "LOCATION_PARSER(path) ");
 #if 0
 	_disk->loadScenery(*_backgroundInfo, NULL, NULL, _tokens[1]);
-	_pathBuffer = &_backgroundInfo->path;
+	_pathBuffer = &_backgroundInfo.path;
 #endif
 }
 


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