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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Mon Jun 30 03:36:50 CEST 2008


Revision: 32847
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32847&view=rev
Author:   peres001
Date:     2008-06-29 18:36:50 -0700 (Sun, 29 Jun 2008)

Log Message:
-----------
Small cleanup/shuffling of Gfx code.

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

Modified: scummvm/trunk/engines/parallaction/debug.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/debug.cpp	2008-06-29 23:36:44 UTC (rev 32846)
+++ scummvm/trunk/engines/parallaction/debug.cpp	2008-06-30 01:36:50 UTC (rev 32847)
@@ -188,7 +188,7 @@
 	const char *objType[] = { "DOOR", "GET", "ANIM" };
 
 	DebugPrintf("+--------------------+-----+-----+-----+-----+--------+--------+\n"
-				"| name               |  x  |  y  |  z  |  f  |  type  |  flag  |\n"
+				"| name               |  x  |  y  |  z  |  f  |  type  |  visi  |\n"
 				"+--------------------+-----+-----+-----+-----+--------+--------+\n");
 
 	GfxObjList::iterator b = _vm->_gfx->_gfxobjList.begin();
@@ -196,7 +196,7 @@
 
 	for ( ; b != e; b++) {
 		GfxObj *obj = *b;
-		DebugPrintf("|%-20s|%5i|%5i|%5i|%5i|%8s|%8x|\n", obj->getName(), obj->x, obj->y, obj->z, obj->frame, objType[obj->type], 6 );
+		DebugPrintf("|%-20s|%5i|%5i|%5i|%5i|%8s|%8x|\n", obj->getName(), obj->x, obj->y, obj->z, obj->frame, objType[obj->type], obj->isVisible() );
 	}
 
 	DebugPrintf("+--------------------+-----+-----+-----+-----+--------+--------+\n");

Modified: scummvm/trunk/engines/parallaction/gfxbase.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gfxbase.cpp	2008-06-29 23:36:44 UTC (rev 32846)
+++ scummvm/trunk/engines/parallaction/gfxbase.cpp	2008-06-30 01:36:50 UTC (rev 32847)
@@ -92,6 +92,7 @@
 	// animation Z is not set here, but controlled by game scripts and user interaction.
 	// it is always >=0 and <screen height
 	obj->type = kGfxObjTypeAnim;
+	_gfxobjList.push_back(obj);
 	return obj;
 }
 
@@ -102,6 +103,7 @@
 
 	obj->z = kGfxObjGetZ;	// this preset Z value ensures that get zones are drawn after doors but before animations
 	obj->type = kGfxObjTypeGet;
+	_gfxobjList.push_back(obj);
 	return obj;
 }
 
@@ -111,6 +113,7 @@
 
 	obj->z = kGfxObjDoorZ;	// this preset Z value ensures that doors are drawn first
 	obj->type = kGfxObjTypeDoor;
+	_gfxobjList.push_back(obj);
 	return obj;
 }
 
@@ -119,16 +122,17 @@
 }
 
 void Gfx::showGfxObj(GfxObj* obj, bool visible) {
-	if (!obj || obj->isVisible() == visible) {
-		return;
-	}
+//	if (!obj || obj->isVisible() == visible) {
+//		return;
+//	}
 
+	assert(obj);
+
 	if (visible) {
 		obj->setFlags(kGfxObjVisible);
-		_gfxobjList.push_back(obj);
 	} else {
 		obj->clearFlags(kGfxObjVisible);
-		_gfxobjList.remove(obj);
+//		_gfxobjList.remove(obj);
 	}
 
 }
@@ -174,4 +178,210 @@
 	}
 }
 
+
+
+void Gfx::drawText(Font *font, Graphics::Surface* surf, uint16 x, uint16 y, const char *text, byte color) {
+	byte *dst = (byte*)surf->getBasePtr(x, y);
+	font->setColor(color);
+	font->drawString(dst, surf->w, text);
+}
+
+void Gfx::drawWrappedText(Font *font, Graphics::Surface* surf, char *text, byte color, int16 wrapwidth) {
+
+	uint16 lines = 0;
+	uint16 linewidth = 0;
+
+	uint16 rx = 10;
+	uint16 ry = 4;
+
+	uint16 blankWidth = font->getStringWidth(" ");
+	uint16 tokenWidth = 0;
+
+	char token[MAX_TOKEN_LEN];
+
+	if (wrapwidth == -1)
+		wrapwidth = _vm->_screenWidth;
+
+	while (strlen(text) > 0) {
+
+		text = parseNextToken(text, token, MAX_TOKEN_LEN, "   ", true);
+
+		if (!scumm_stricmp(token, "%p")) {
+			lines++;
+			rx = 10;
+			ry = 4 + lines*10;	// y
+
+			strcpy(token, "> .......");
+			strncpy(token+2, _password, strlen(_password));
+			tokenWidth = font->getStringWidth(token);
+		} else {
+			tokenWidth = font->getStringWidth(token);
+
+			linewidth += tokenWidth;
+
+			if (linewidth > wrapwidth) {
+				// wrap line
+				lines++;
+				rx = 10;			// x
+				ry = 4 + lines*10;	// y
+				linewidth = tokenWidth;
+			}
+
+			if (!scumm_stricmp(token, "%s")) {
+				sprintf(token, "%d", _score);
+			}
+
+		}
+
+		drawText(font, surf, rx, ry, token, color);
+
+		rx += tokenWidth + blankWidth;
+		linewidth += blankWidth;
+
+		text = Common::ltrim(text);
+	}
+
+}
+
+
+// this is the maximum size of an unpacked frame in BRA
+byte _unpackedBitmap[640*401];
+
+#if 0
+void Gfx::unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surface *surf, uint16 z, byte transparentColor) {
+
+	byte *d = _unpackedBitmap;
+
+	while (size > 0) {
+
+		uint8 p = *data++;
+		size--;
+		uint8 color = p & 0xF;
+		uint8 repeat = (p & 0xF0) >> 4;
+		if (repeat == 0) {
+			repeat = *data++;
+			size--;
+		}
+
+		memset(d, color, repeat);
+		d += repeat;
+	}
+
+	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) {
+
+	byte *d = _unpackedBitmap;
+	uint pixelsLeftInLine = r.width();
+
+	while (size > 0) {
+		uint8 p = *data++;
+		size--;
+		uint8 color = p & 0xF;
+		uint8 repeat = (p & 0xF0) >> 4;
+		if (repeat == 0) {
+			repeat = *data++;
+			size--;
+		}
+		if (repeat == 0) {
+			// end of line
+			repeat = pixelsLeftInLine;
+			pixelsLeftInLine = r.width();
+		} else {
+			pixelsLeftInLine -= repeat;
+		}
+
+		memset(d, color, repeat);
+		d += repeat;
+	}
+
+	blt(r, _unpackedBitmap, surf, z, transparentColor);
+}
+
+
+void Gfx::blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, 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++) {
+
+			for (uint16 j = 0; j < q.width(); j++) {
+				if (*s != transparentColor) {
+					if (_backgroundInfo.mask.data && (z < LAYER_FOREGROUND)) {
+						byte v = _backgroundInfo.mask.getValue(dp.x + j, dp.y + i);
+						if (z >= v) *d = 5;
+					} else {
+						*d = 5;
+					}
+				}
+
+				s++;
+				d++;
+			}
+
+			s += sPitch;
+			d += dPitch;
+		}
+
+    } 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;
+			}
+
+		}
+	}
+
+}
+
+
 } // namespace Parallaction

Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp	2008-06-29 23:36:44 UTC (rev 32846)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2008-06-30 01:36:50 UTC (rev 32847)
@@ -531,149 +531,10 @@
 
 }
 
-// this is the maximum size of an unpacked frame in BRA
-byte _unpackedBitmap[640*401];
 
-#if 0
-void Gfx::unpackBlt(const Common::Rect& r, byte *data, uint size, Graphics::Surface *surf, uint16 z, byte transparentColor) {
 
-	byte *d = _unpackedBitmap;
 
-	while (size > 0) {
 
-		uint8 p = *data++;
-		size--;
-		uint8 color = p & 0xF;
-		uint8 repeat = (p & 0xF0) >> 4;
-		if (repeat == 0) {
-			repeat = *data++;
-			size--;
-		}
-
-		memset(d, color, repeat);
-		d += repeat;
-	}
-
-	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) {
-
-	byte *d = _unpackedBitmap;
-	uint pixelsLeftInLine = r.width();
-
-	while (size > 0) {
-		uint8 p = *data++;
-		size--;
-		uint8 color = p & 0xF;
-		uint8 repeat = (p & 0xF0) >> 4;
-		if (repeat == 0) {
-			repeat = *data++;
-			size--;
-		}
-		if (repeat == 0) {
-			// end of line
-			repeat = pixelsLeftInLine;
-			pixelsLeftInLine = r.width();
-		} else {
-			pixelsLeftInLine -= repeat;
-		}
-
-		memset(d, color, repeat);
-		d += repeat;
-	}
-
-	blt(r, _unpackedBitmap, surf, z, transparentColor);
-}
-
-
-void Gfx::blt(const Common::Rect& r, byte *data, Graphics::Surface *surf, uint16 z, 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++) {
-
-			for (uint16 j = 0; j < q.width(); j++) {
-				if (*s != transparentColor) {
-					if (_backgroundInfo.mask.data && (z < LAYER_FOREGROUND)) {
-						byte v = _backgroundInfo.mask.getValue(dp.x + j, dp.y + i);
-						if (z >= v) *d = 5;
-					} else {
-						*d = 5;
-					}
-				}
-
-				s++;
-				d++;
-			}
-
-			s += sPitch;
-			d += dPitch;
-		}
-
-    } 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;
-			}
-
-		}
-	}
-
-}
-
-
-
-
-
 void setupLabelSurface(Graphics::Surface &surf, uint w, uint h) {
 	surf.create(w, h, 1);
 	surf.fillRect(Common::Rect(w,h), LABEL_TRANSPARENT_COLOR);
@@ -963,8 +824,8 @@
 	int id = _numItems;
 
 	_items[id].data = frames;
-	_items[id].x = x;
-	_items[id].y = y;
+	_items[id].data->x = x;
+	_items[id].data->y = y;
 
 	_items[id].transparentColor = transparentColor;
 
@@ -976,8 +837,6 @@
 void Gfx::setItemFrame(uint item, uint16 f) {
 	assert(item < _numItems);
 	_items[item].data->frame = f;
-	_items[item].data->x = _items[item].x;
-	_items[item].data->y = _items[item].y;
 }
 
 Gfx::Balloon* Gfx::getBalloon(uint id) {
@@ -1112,69 +971,6 @@
 	freeBalloons();
 }
 
-void Gfx::drawText(Font *font, Graphics::Surface* surf, uint16 x, uint16 y, const char *text, byte color) {
-	byte *dst = (byte*)surf->getBasePtr(x, y);
-	font->setColor(color);
-	font->drawString(dst, surf->w, text);
-}
-
-void Gfx::drawWrappedText(Font *font, Graphics::Surface* surf, char *text, byte color, int16 wrapwidth) {
-
-	uint16 lines = 0;
-	uint16 linewidth = 0;
-
-	uint16 rx = 10;
-	uint16 ry = 4;
-
-	uint16 blankWidth = font->getStringWidth(" ");
-	uint16 tokenWidth = 0;
-
-	char token[MAX_TOKEN_LEN];
-
-	if (wrapwidth == -1)
-		wrapwidth = _vm->_screenWidth;
-
-	while (strlen(text) > 0) {
-
-		text = parseNextToken(text, token, MAX_TOKEN_LEN, "   ", true);
-
-		if (!scumm_stricmp(token, "%p")) {
-			lines++;
-			rx = 10;
-			ry = 4 + lines*10;	// y
-
-			strcpy(token, "> .......");
-			strncpy(token+2, _password, strlen(_password));
-			tokenWidth = font->getStringWidth(token);
-		} else {
-			tokenWidth = font->getStringWidth(token);
-
-			linewidth += tokenWidth;
-
-			if (linewidth > wrapwidth) {
-				// wrap line
-				lines++;
-				rx = 10;			// x
-				ry = 4 + lines*10;	// y
-				linewidth = tokenWidth;
-			}
-
-			if (!scumm_stricmp(token, "%s")) {
-				sprintf(token, "%d", _score);
-			}
-
-		}
-
-		drawText(font, surf, rx, ry, token, color);
-
-		rx += tokenWidth + blankWidth;
-		linewidth += blankWidth;
-
-		text = Common::ltrim(text);
-	}
-
-}
-
 void Gfx::freeBackground() {
 	_backgroundInfo.free();
 }

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2008-06-29 23:36:44 UTC (rev 32846)
+++ scummvm/trunk/engines/parallaction/graphics.h	2008-06-30 01:36:50 UTC (rev 32847)
@@ -572,8 +572,6 @@
 	uint	_numBalloons;
 
 	struct Item {
-		uint16 x;
-		uint16 y;
 		uint16 frame;
 		GfxObj *data;
 


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