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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Mon Aug 18 09:12:06 CEST 2008


Revision: 33985
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33985&view=rev
Author:   peres001
Date:     2008-08-18 07:12:05 +0000 (Mon, 18 Aug 2008)

Log Message:
-----------
* Split up blt routine (there is room for a ton of improvements)
* Added scaling as a new blt option
* Activated scaling for the main character in BRA

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/balloons.cpp
    scummvm/trunk/engines/parallaction/exec_ns.cpp
    scummvm/trunk/engines/parallaction/gfxbase.cpp
    scummvm/trunk/engines/parallaction/graphics.cpp
    scummvm/trunk/engines/parallaction/graphics.h
    scummvm/trunk/engines/parallaction/parallaction.cpp

Modified: scummvm/trunk/engines/parallaction/balloons.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/balloons.cpp	2008-08-18 06:47:14 UTC (rev 33984)
+++ scummvm/trunk/engines/parallaction/balloons.cpp	2008-08-18 07:12:05 UTC (rev 33985)
@@ -318,7 +318,7 @@
 		winding = (winding == 0 ? 1 : 0);
 		Common::Rect s(BALLOON_TAIL_WIDTH, BALLOON_TAIL_HEIGHT);
 		s.moveTo(r.width()/2 - 5, r.bottom - 1);
-		_gfx->blt(s, _resBalloonTail[winding], balloon->surface, LAYER_FOREGROUND, BALLOON_TRANSPARENT_COLOR_NS);
+		_gfx->blt(s, _resBalloonTail[winding], balloon->surface, LAYER_FOREGROUND, 100, BALLOON_TRANSPARENT_COLOR_NS);
 	}
 
 	_numBalloons++;
@@ -591,7 +591,7 @@
 	Graphics::Surface *surf = new Graphics::Surface;
 	surf->create(rect.width(), rect.height(), 1);
 
-	_gfx->unpackBlt(rect, data->getData(frameNum), data->getRawSize(frameNum), surf, LAYER_FOREGROUND, BALLOON_TRANSPARENT_COLOR_BR);
+	_gfx->unpackBlt(rect, data->getData(frameNum), data->getRawSize(frameNum), surf, LAYER_FOREGROUND, 100, BALLOON_TRANSPARENT_COLOR_BR);
 
 	return surf;
 }

Modified: scummvm/trunk/engines/parallaction/exec_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-08-18 06:47:14 UTC (rev 33984)
+++ scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-08-18 07:12:05 UTC (rev 33985)
@@ -321,7 +321,7 @@
 void Parallaction_ns::drawAnimations() {
 	debugC(9, kDebugExec, "Parallaction_ns::drawAnimations()\n");
 
-	uint16 layer = 0;
+	uint16 layer = 0, scale = 100;
 
 	for (AnimationList::iterator it = _location._animations.begin(); it != _location._animations.end(); it++) {
 
@@ -350,6 +350,18 @@
 				}
 			}
 
+			if (getGameType() == GType_BRA) {
+				if (anim->_flags & (kFlagsScaled | kFlagsCharacter)) {
+					if (anim->getZ() <= _location._zeta0) {
+						if (anim->getZ() >= _location._zeta1) {
+							scale = ((anim->getZ() - _location._zeta1) * (100 - _location._zeta2)) / (_location._zeta0 - _location._zeta1) + _location._zeta2;
+						} else {
+							scale = _location._zeta2;
+						}
+					}
+				}
+			}
+
 			if (obj) {
 				_gfx->showGfxObj(obj, true);
 				obj->frame = anim->getF();
@@ -357,6 +369,7 @@
 				obj->y = anim->getY();
 				obj->z = anim->getZ();
 				obj->layer = layer;
+				obj->scale = scale;
 			}
 		}
 

Modified: scummvm/trunk/engines/parallaction/gfxbase.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gfxbase.cpp	2008-08-18 06:47:14 UTC (rev 33984)
+++ scummvm/trunk/engines/parallaction/gfxbase.cpp	2008-08-18 07:12:05 UTC (rev 33985)
@@ -32,7 +32,7 @@
 
 namespace Parallaction {
 
-GfxObj::GfxObj(uint objType, Frames *frames, const char* name) : _frames(frames), _keep(true), x(0), y(0), z(0), _flags(kGfxObjNormal), type(objType), frame(0), layer(3)  {
+GfxObj::GfxObj(uint objType, Frames *frames, const char* name) : _frames(frames), _keep(true), x(0), y(0), z(0), _flags(kGfxObjNormal), type(objType), frame(0), layer(3), scale(100)  {
 	if (name) {
 		_name = strdup(name);
 	} else {
@@ -180,9 +180,9 @@
 	data = obj->getData(obj->frame);
 
 	if (obj->getSize(obj->frame) == obj->getRawSize(obj->frame)) {
-		blt(rect, data, &surf, obj->layer, obj->transparentKey);
+		blt(rect, data, &surf, obj->layer, obj->scale, obj->transparentKey);
 	} else {
-		unpackBlt(rect, data, obj->getRawSize(obj->frame), &surf, obj->layer, obj->transparentKey);
+		unpackBlt(rect, data, obj->getRawSize(obj->frame), &surf, obj->layer, obj->scale, obj->transparentKey);
 	}
 
 }
@@ -233,7 +233,7 @@
 	blt(r, _unpackedBitmap, surf, z, transparentColor);
 }
 #endif
-void Gfx::unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surface *surf, uint16 z, byte transparentColor) {
+void Gfx::unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor) {
 
 	byte *d = _unpackedBitmap;
 	uint pixelsLeftInLine = r.width();
@@ -259,13 +259,82 @@
 		d += repeat;
 	}
 
-	blt(r, _unpackedBitmap, surf, z, transparentColor);
+	blt(r, _unpackedBitmap, surf, z, scale, transparentColor);
 }
 
 
-void Gfx::blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, byte transparentColor) {
+void Gfx::bltMaskScale(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor) {
+	if (scale == 100) {
+		// use optimized path
+		bltMaskNoScale(r, data, surf, z, transparentColor);
+		return;
+	}
 
+	Common::Rect q(r);
+	Common::Rect clipper(surf->w, surf->h);
+	q.clip(clipper);
+	if (!q.isValidRect()) return;
+
+	uint inc = r.width() * (100 - scale);
+	uint thr = r.width() * 100;
+	uint xAccum = 0, yAccum = 0;
+
 	Common::Point dp;
+	dp.x = q.left + (r.width() * (100 - scale)) / 200;
+	dp.y = q.top + (r.height() * (100 - scale)) / 100;
+	q.translate(-r.left, -r.top);
+	byte *s = data + q.left + q.top * r.width();
+	byte *d = (byte*)surf->getBasePtr(dp.x, dp.y);
+
+	uint line = 0, col = 0;
+
+	for (uint16 i = 0; i < q.height(); i++) {
+		yAccum += inc;
+
+		if (yAccum >= thr) {
+			yAccum -= thr;
+			s += r.width();
+			continue;
+		}
+
+		xAccum = 0;
+		byte *d2 = d;
+		col = 0;
+
+		for (uint16 j = 0; j < q.width(); j++) {
+			xAccum += inc;
+
+			if (xAccum >= thr) {
+				xAccum -= thr;
+				s++;
+				continue;
+			}
+
+			if (*s != transparentColor) {
+				byte v = _backgroundInfo->mask.getValue(dp.x + col, dp.y + line);
+				if (z >= v) *d2 = *s;
+			}
+
+			s++;
+			d2++;
+			col++;
+		}
+
+		s += r.width() - q.width();
+		d += surf->w;
+		line++;
+	}
+
+}
+
+void Gfx::bltMaskNoScale(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, byte transparentColor) {
+	if (!_backgroundInfo->mask.data || (z == LAYER_FOREGROUND)) {
+		// use optimized path
+		bltNoMaskNoScale(r, data, surf, transparentColor);
+		return;
+	}
+
+	Common::Point dp;
 	Common::Rect q(r);
 
 	Common::Rect clipper(surf->w, surf->h);
@@ -284,7 +353,81 @@
 	uint sPitch = r.width() - q.width();
 	uint dPitch = surf->w - q.width();
 
+	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);
+				if (z >= v) *d = *s;
+			}
+
+			s++;
+			d++;
+		}
+
+		s += sPitch;
+		d += dPitch;
+	}
+
+}
+
+void Gfx::bltNoMaskNoScale(const Common::Rect& r, byte *data, Graphics::Surface *surf, byte transparentColor) {
+	Common::Point dp;
+	Common::Rect q(r);
+
+	Common::Rect clipper(surf->w, surf->h);
+
+	q.clip(clipper);
+	if (!q.isValidRect()) return;
+
+	dp.x = q.left;
+	dp.y = q.top;
+
+	q.translate(-r.left, -r.top);
+
+	byte *s = data + q.left + q.top * r.width();
+	byte *d = (byte*)surf->getBasePtr(dp.x, dp.y);
+
+	uint sPitch = r.width() - q.width();
+	uint dPitch = surf->w - q.width();
+
+	for (uint16 i = q.top; i < q.bottom; i++) {
+		for (uint16 j = q.left; j < q.right; j++) {
+			if (*s != transparentColor)
+				*d = *s;
+
+			s++;
+			d++;
+		}
+
+		s += sPitch;
+		d += dPitch;
+	}
+}
+
+
+void Gfx::blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor) {
+
+	Common::Point dp;
+	Common::Rect q(r);
+
+	Common::Rect clipper(surf->w, surf->h);
+
+	q.clip(clipper);
+	if (!q.isValidRect()) return;
+
+	dp.x = q.left;
+	dp.y = q.top;
+
+	q.translate(-r.left, -r.top);
+
+	byte *s = data + q.left + q.top * r.width();
+	byte *d = (byte*)surf->getBasePtr(dp.x, dp.y);
+
+	uint sPitch = r.width() - q.width();
+	uint dPitch = surf->w - q.width();
+
+
 	if (_varRenderMode == 2) {
 
 		for (uint16 i = 0; i < q.height(); i++) {
@@ -308,40 +451,7 @@
 		}
 
     } else {
-		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);
-						if (z >= v) *d = *s;
-					}
-
-					s++;
-					d++;
-				}
-
-				s += sPitch;
-				d += dPitch;
-			}
-
-		} else {
-
-			for (uint16 i = q.top; i < q.bottom; i++) {
-				for (uint16 j = q.left; j < q.right; j++) {
-					if (*s != transparentColor)
-						*d = *s;
-
-					s++;
-					d++;
-				}
-
-				s += sPitch;
-				d += dPitch;
-			}
-
-		}
+    	bltMaskScale(r, data, surf, z, scale, transparentColor);
 	}
 
 }

Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp	2008-08-18 06:47:14 UTC (rev 33984)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2008-08-18 07:12:05 UTC (rev 33985)
@@ -506,7 +506,7 @@
 	r.moveTo(x, y);
 
 	uint16 z = (mask) ? _backgroundInfo->getLayer(y) : LAYER_FOREGROUND;
-	blt(r, (byte*)surf.pixels, &_backgroundInfo->bg, z, 0);
+	blt(r, (byte*)surf.pixels, &_backgroundInfo->bg, z, 100, 0);
 }
 
 void Gfx::fillBackground(const Common::Rect& r, byte color) {

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2008-08-18 06:47:14 UTC (rev 33984)
+++ scummvm/trunk/engines/parallaction/graphics.h	2008-08-18 07:12:05 UTC (rev 33985)
@@ -410,6 +410,7 @@
 	uint frame;
 	uint layer;
 	uint transparentKey;
+	uint scale;
 
 	GfxObj(uint type, Frames *frames, const char *name = NULL);
 	virtual ~GfxObj();
@@ -646,8 +647,12 @@
 	void drawText(Font *font, Graphics::Surface* surf, uint16 x, uint16 y, const char *text, byte color);
 
 	void drawGfxObject(GfxObj *obj, Graphics::Surface &surf, bool scene);
-    void blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, byte transparentColor);
-	void unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surface *surf, uint16 z, byte transparentColor);
+    void blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor);
+	void unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor);
+
+	void bltMaskScale(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, uint scale, byte transparentColor);
+	void bltMaskNoScale(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, byte transparentColor);
+	void bltNoMaskNoScale(const Common::Rect& r, byte *data, Graphics::Surface *surf, byte transparentColor);
 };
 
 

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2008-08-18 06:47:14 UTC (rev 33984)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2008-08-18 07:12:05 UTC (rev 33985)
@@ -514,7 +514,7 @@
 	_ani->setY(100);
 	_ani->setZ(10);
 	_ani->setF(0);
-	_ani->_flags = kFlagsActive | kFlagsNoName;
+	_ani->_flags = kFlagsActive | kFlagsNoName | kFlagsCharacter;
 	_ani->_type = kZoneYou;
 	strncpy(_ani->_name, "yourself", ZONENAME_LENGTH);
 


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