[Scummvm-cvs-logs] SF.net SVN: scummvm:[45915] scummvm/trunk/engines/teenagent

megath at users.sourceforge.net megath at users.sourceforge.net
Sun Nov 15 11:49:57 CET 2009


Revision: 45915
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45915&view=rev
Author:   megath
Date:     2009-11-15 10:49:57 +0000 (Sun, 15 Nov 2009)

Log Message:
-----------
implemented src_rect for surface blitting, added proper animation frames.

Modified Paths:
--------------
    scummvm/trunk/engines/teenagent/actor.cpp
    scummvm/trunk/engines/teenagent/scene.cpp
    scummvm/trunk/engines/teenagent/surface.cpp
    scummvm/trunk/engines/teenagent/surface.h

Modified: scummvm/trunk/engines/teenagent/actor.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/actor.cpp	2009-11-15 10:15:39 UTC (rev 45914)
+++ scummvm/trunk/engines/teenagent/actor.cpp	2009-11-15 10:49:57 UTC (rev 45915)
@@ -36,9 +36,31 @@
 	const uint8 frames_up[] = {18, 19, 20, 21, 22, 23, 24, 25, };
 	const uint8 frames_down[] = {10, 11, 12, 13, 14, 15, 16, 17, };
 
-	const uint8 frames_head_left_right[] = {39, 26, 27, 28, 29, 30, 31, };
-	const uint8 frames_head_up[] = { 41, 37, 38, };
-	const uint8 frames_head_down[] = {40, 32, 33, 34, 35, 36};
+	const uint8 frames_head_left_right[] = { 
+		0x27, 0x1a, 0x1b, 
+		0x27, 0x1c, 0x1d, 
+		0x27, 0x1a, 
+		0x27, 0x1e, 0x1f, 
+		0x27, 0x1a, 0x1b, 
+		0x27, 0x1c, 
+		0x27, 0x1e, 
+		0x27, 0x1a, 
+	};
+	
+	const uint8 frames_head_up[] = {
+		0x29, 0x25, 0x29, 0x29, 
+		0x26, 0x29, 0x26, 0x29, 
+		0x29, 0x25, 0x29, 0x25, 
+		0x29, 0x29, 0x29, 0x25, 
+		0x25, 0x29, 0x29, 0x26
+	};
+	const uint8 frames_head_down[] = {
+		0x20, 0x21, 0x22, 0x23, 
+		0x28, 0x24, 0x28, 0x28, 
+		0x24, 0x28, 0x20, 0x21, 
+		0x20, 0x23, 0x28, 0x20, 
+		0x28, 0x28, 0x20, 0x28
+	};
 
 	Surface *s = NULL, *head = NULL;
 
@@ -94,7 +116,16 @@
 		return Common::Rect();
 	}
 	index += delta_frame;
+	if (s == NULL) {
+		warning("no surface, skipping");
+		return Common::Rect();
+	}
 
+	Common::Rect dirty;
+	Common::Rect clip(0, 0, s->w, s->h);
+	if (head != NULL) 
+		clip.top = head->h;
+
 	int xp = position.x - dx, yp = position.y - dy;
 	if (xp < 0)
 		xp = 0;
@@ -103,15 +134,12 @@
 
 	if (yp < 0)
 		yp = 0;
-	if (yp + s->h > 200)
-		yp = 200 - s->h;
+	if (yp + clip.top + clip.height() > 200)
+		yp = 200 - clip.top - clip.height();
 	
-	Common::Rect dirty;
-	
-	if (s)
-		dirty = s->render(surface, xp, yp, orientation == Object::kActorLeft);
+	dirty = s->render(surface, xp, yp + clip.top, orientation == Object::kActorLeft, clip);
 
-	if (head)
+	if (head != NULL)
 		dirty.extend(head->render(surface, xp, yp, orientation == Object::kActorLeft));
 
 	return dirty;

Modified: scummvm/trunk/engines/teenagent/scene.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/scene.cpp	2009-11-15 10:15:39 UTC (rev 45914)
+++ scummvm/trunk/engines/teenagent/scene.cpp	2009-11-15 10:49:57 UTC (rev 45915)
@@ -668,7 +668,7 @@
 					} else
 						busy = true;
 				} else
-					actor_animation_position = teenagent.render(surface, position, orientation, 0, false);
+					actor_animation_position = teenagent.render(surface, position, orientation, 0, true);
 			}
 		}
 

Modified: scummvm/trunk/engines/teenagent/surface.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/surface.cpp	2009-11-15 10:15:39 UTC (rev 45914)
+++ scummvm/trunk/engines/teenagent/surface.cpp	2009-11-15 10:49:57 UTC (rev 45915)
@@ -75,15 +75,22 @@
 	stream->read(pixels, w_ * h_);
 }
 
-Common::Rect Surface::render(Graphics::Surface *surface, int dx, int dy, bool mirror) {
-	assert(x + dx + w <= surface->w);
-	assert(y + dy + h <= surface->h);
+Common::Rect Surface::render(Graphics::Surface *surface, int dx, int dy, bool mirror, Common::Rect src_rect) {
+	if (src_rect.isEmpty()) {
+		src_rect = Common::Rect(0, 0, w, h);
+	} else if (src_rect.right > w)
+		src_rect.right = w;
+	else if (src_rect.bottom < h) 
+		src_rect.bottom = h;
 
-	byte *src = (byte *)pixels;
+	assert(x + dx + src_rect.width() <= surface->w);
+	assert(y + dy + src_rect.height() <= surface->h);
+
+	byte *src = (byte *)getBasePtr(src_rect.left, src_rect.top);
 	byte *dst = (byte *)surface->getBasePtr(dx + x, dy + y);
 
-	for (int i = 0; i < h; ++i) {
-		for (int j = 0; j < w; ++j) {
+	for (int i = src_rect.top; i < src_rect.bottom; ++i) {
+		for (int j = src_rect.left; j < src_rect.right; ++j) {
 			byte p = src[j];
 			if (p != 0xff)
 				dst[mirror? w - j - 1: j] = p;

Modified: scummvm/trunk/engines/teenagent/surface.h
===================================================================
--- scummvm/trunk/engines/teenagent/surface.h	2009-11-15 10:15:39 UTC (rev 45914)
+++ scummvm/trunk/engines/teenagent/surface.h	2009-11-15 10:49:57 UTC (rev 45915)
@@ -40,7 +40,7 @@
 
 	Surface();
 	void load(Common::SeekableReadStream *stream, Type type);
-	Common::Rect render(Graphics::Surface *surface, int dx = 0, int dy = 0, bool mirror = false);
+	Common::Rect render(Graphics::Surface *surface, int dx = 0, int dy = 0, bool mirror = false, Common::Rect src_rect = Common::Rect());
 
 	bool empty() const { return pixels == NULL; }
 };


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