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

megath at users.sourceforge.net megath at users.sourceforge.net
Tue Nov 17 23:09:16 CET 2009


Revision: 45962
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45962&view=rev
Author:   megath
Date:     2009-11-17 22:09:16 +0000 (Tue, 17 Nov 2009)

Log Message:
-----------
implemented zoomed rendering

Modified Paths:
--------------
    scummvm/trunk/engines/teenagent/actor.cpp
    scummvm/trunk/engines/teenagent/actor.h
    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-17 21:47:26 UTC (rev 45961)
+++ scummvm/trunk/engines/teenagent/actor.cpp	2009-11-17 22:09:16 UTC (rev 45962)
@@ -31,7 +31,7 @@
 
 //idle animation lists at dseg: 0x6540
 
-Common::Rect Actor::render(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame, bool render_head) {
+Common::Rect Actor::render(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame, bool render_head, uint zoom) {
 	const uint8 frames_left_right[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
 	const uint8 frames_up[] = {18, 19, 20, 21, 22, 23, 24, 25, };
 	const uint8 frames_down[] = {10, 11, 12, 13, 14, 15, 16, 17, };
@@ -137,10 +137,10 @@
 	if (yp + clip.top + clip.height() > 200)
 		yp = 200 - clip.top - clip.height();
 	
-	dirty = s->render(surface, xp, yp + clip.top, orientation == Object::kActorLeft, clip);
+	dirty = s->render(surface, xp, yp + clip.top, orientation == Object::kActorLeft, clip, zoom);
 
 	if (head != NULL)
-		dirty.extend(head->render(surface, xp, yp, orientation == Object::kActorLeft));
+		dirty.extend(head->render(surface, xp, yp, orientation == Object::kActorLeft, Common::Rect(), zoom));
 
 	return dirty;
 }

Modified: scummvm/trunk/engines/teenagent/actor.h
===================================================================
--- scummvm/trunk/engines/teenagent/actor.h	2009-11-17 21:47:26 UTC (rev 45961)
+++ scummvm/trunk/engines/teenagent/actor.h	2009-11-17 22:09:16 UTC (rev 45962)
@@ -31,7 +31,7 @@
 	uint head_index;
 public:
 	Actor();
-	Common::Rect render(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame, bool head);
+	Common::Rect render(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame, bool head, uint zoom);
 };
 
 } // End of namespace TeenAgent

Modified: scummvm/trunk/engines/teenagent/scene.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/scene.cpp	2009-11-17 21:47:26 UTC (rev 45961)
+++ scummvm/trunk/engines/teenagent/scene.cpp	2009-11-17 22:09:16 UTC (rev 45962)
@@ -666,6 +666,10 @@
 				got_any_animation = true;
 			} else if (!hide_actor) {
 				actor_animation.free();
+				uint zoom = 256;
+				if (_id == 18) { //zoom hack
+					zoom = 192;
+				}
 
 				if (!path.empty()) {
 					const int speed_x = 10, speed_y = 5;
@@ -691,7 +695,7 @@
 					position.x += (ABS(dp.x) < speed_x? dp.x: SIGN(dp.x) * speed_x);
 					position.y += (ABS(dp.y) < speed_y? dp.y: SIGN(dp.y) * speed_y);
 					
-					actor_animation_position = teenagent.render(surface, position, o, 1, false);
+					actor_animation_position = teenagent.render(surface, position, o, 1, false, zoom);
 					if (position == destination) {
 						path.pop_front();
 						if (path.empty()) {
@@ -705,7 +709,7 @@
 					} else
 						busy = true;
 				} else 
-					actor_animation_position = teenagent.render(surface, position, orientation, 0, actor_talking);
+					actor_animation_position = teenagent.render(surface, position, orientation, 0, actor_talking, zoom);
 			}
 		}
 

Modified: scummvm/trunk/engines/teenagent/surface.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/surface.cpp	2009-11-17 21:47:26 UTC (rev 45961)
+++ scummvm/trunk/engines/teenagent/surface.cpp	2009-11-17 22:09:16 UTC (rev 45962)
@@ -62,7 +62,7 @@
 	stream->read(pixels, w_ * h_);
 }
 
-Common::Rect Surface::render(Graphics::Surface *surface, int dx, int dy, bool mirror, Common::Rect src_rect) const {
+Common::Rect Surface::render(Graphics::Surface *surface, int dx, int dy, bool mirror, Common::Rect src_rect, uint zoom) const {
 	if (src_rect.isEmpty()) {
 		src_rect = Common::Rect(0, 0, w, h);
 	} else if (src_rect.right > w)
@@ -70,20 +70,41 @@
 	else if (src_rect.bottom < h) 
 		src_rect.bottom = h;
 
-	assert(x + dx + src_rect.width() <= surface->w);
-	assert(y + dy + src_rect.height() <= surface->h);
+	if (zoom == 256) {
+		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);
+		byte *src = (byte *)getBasePtr(src_rect.left, src_rect.top);
+		byte *dst = (byte *)surface->getBasePtr(dx + x, dy + y);
 
-	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;
+		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;
+			}
+			dst += surface->pitch;
+			src += pitch;
 		}
-		dst += surface->pitch;
-		src += pitch;
+	} else {
+		Common::Rect dst_rect(src_rect);
+		dst_rect.right = (dst_rect.width() * zoom / 256) + dst_rect.left;
+		dst_rect.top = dst_rect.bottom - (dst_rect.height() * zoom / 256);
+
+		assert(x + dx + dst_rect.width() <= surface->w);
+		assert(y + dy + dst_rect.height() <= surface->h);
+
+		byte *dst = (byte *)surface->getBasePtr(dx + x, dy + y + dst_rect.top - src_rect.top);
+		for(int i = 0; i < dst_rect.height(); ++i) {
+			for (int j = 0; j < dst_rect.width(); ++j) {
+				int px = j * 256 / zoom;
+				byte *src = (byte *)getBasePtr(src_rect.left + (mirror? w - px - 1: px), src_rect.top + i * 256 / zoom);
+				byte p = *src;
+				if (p != 0xff)
+					dst[j + dst_rect.left] = p;
+			}
+			dst += surface->pitch;
+		}
 	}
 	return Common::Rect(x + dx, y + dy, x + w + dx, y + h + dy);
 }

Modified: scummvm/trunk/engines/teenagent/surface.h
===================================================================
--- scummvm/trunk/engines/teenagent/surface.h	2009-11-17 21:47:26 UTC (rev 45961)
+++ scummvm/trunk/engines/teenagent/surface.h	2009-11-17 22:09:16 UTC (rev 45962)
@@ -39,7 +39,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 src_rect = Common::Rect()) const;
+	Common::Rect render(Graphics::Surface *surface, int dx = 0, int dy = 0, bool mirror = false, Common::Rect src_rect = Common::Rect(), uint zoom = 256) const;
 
 	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