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

megath at users.sourceforge.net megath at users.sourceforge.net
Sun Nov 8 21:00:32 CET 2009


Revision: 45756
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45756&view=rev
Author:   megath
Date:     2009-11-08 20:00:31 +0000 (Sun, 08 Nov 2009)

Log Message:
-----------
implemented async messages (some animation requires it), added custom positioning.

Modified Paths:
--------------
    scummvm/trunk/engines/teenagent/callbacks.cpp
    scummvm/trunk/engines/teenagent/dialog.cpp
    scummvm/trunk/engines/teenagent/scene.cpp
    scummvm/trunk/engines/teenagent/scene.h
    scummvm/trunk/engines/teenagent/teenagent.cpp
    scummvm/trunk/engines/teenagent/teenagent.h

Modified: scummvm/trunk/engines/teenagent/callbacks.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/callbacks.cpp	2009-11-08 19:11:57 UTC (rev 45755)
+++ scummvm/trunk/engines/teenagent/callbacks.cpp	2009-11-08 20:00:31 UTC (rev 45756)
@@ -38,7 +38,7 @@
 	//random reject message:
 	uint i = random.getRandomNumber(3);
 	//debug(0, "reject message: %s", (const char *)res->dseg.ptr(res->dseg.get_word(0x339e + 2 * i)));
-	scene->displayMessage((const char *)res->dseg.ptr(res->dseg.get_word(0x339e + 2 * i)));
+	displayMessage(res->dseg.get_word(0x339e + 2 * i));
 }
 
 
@@ -141,7 +141,7 @@
 		showActor();
 		moveTo(319, 150, 1, true);
 		moveTo(63, 150, 1);
-		displayMessage(0x5da8); //fixme: with delay!
+		displayAsyncMessage(0x5da8, 19844, 18, 36);
 		playAnimation(851, 0);
 		playSound(24, 11);
 		playActorAnimation(931);
@@ -316,7 +316,7 @@
 
 	case 0x44cb:
 		if (CHECK_FLAG(0xDBE5, 1)) {
-			scene->displayMessage((const char *)res->dseg.ptr(0x57c0));
+			displayMessage(0x57c0);
 		} else {
 			playSound(49, 14);
 			playSound(5, 21);
@@ -726,9 +726,8 @@
 			playSound(56, 8);
 			playSound(56, 12);
 			playSound(49, 10);
-			//there's some black magic here! investigate!
+			displayAsyncMessage(0x4652, 31579, 16, 24);
 			playActorAnimation(587);
-			displayMessage(0x4652);
 			displayMessage(0x3668);
 		}
 		return true;
@@ -1712,14 +1711,17 @@
 			return false;
 
 	case 0x62d0://Get bone from under rock
+		displayAsyncMessage(0x463c, 30938, 16, 24);
 		playSound(26, 6);
+		playSound(26, 10);
+		playSound(24, 13);
+		playSound(46, 37);
 		setOns(0, 0);
 		playActorAnimation(594);
 		setOns(0, 29);
-		displayMessage(0x463c);
 		disableObject(1);
 		inventory->add(36);
-		playSound(5, 3);
+		playSound(5, 2);
 		playActorAnimation(595);
 		displayMessage(0x3790);
 		return true;
@@ -1883,8 +1885,8 @@
 			playSound(89, 4);
 			playSound(89, 4);
 			playSound(87, 45);
+			displayAsyncMessage(0x4fcb, 34672, 11, 35, 0xe5);
 			playActorAnimation(718);
-			displayMessage(0x4fcb); //fixme: move it to animation
 			displayMessage(0x4fe2);
 			SET_FLAG(0xDBCF, 1);
 		}
@@ -1929,7 +1931,7 @@
 	case 0x7336:
 		setOns(1, 0);
 		playSound(5, 42);
-		displayMessage(0x4d02);
+		displayAsyncMessage(0x4d02, 32642, 20, 38);
 		playActorAnimation(697);
 		inventory->add(56);
 		disableObject(1);
@@ -2270,13 +2272,18 @@
 		playActorAnimation(620);
 		for (byte i = 3; i <= 18; i += 3)
 			playSound(56, i);
+
+		displayAsyncMessage(0x3ace, 3878, 20, 37, 0xd9);
 		playActorAnimation(621, true);
 		playAnimation(623, 1, true);
 		waitAnimation();
+
+		displayAsyncMessage(0x3ae6, 3870, 1, 9, 0xd9);
 		playSound(35);
 		playActorAnimation(622, true);
 		playAnimation(624, 1, true);
 		displayMessage(0x3afd);
+
 		inventory->remove(43);
 		processCallback(0x9d45);
 		return true;
@@ -2418,9 +2425,11 @@
 			playSound(5, 43);
 			playSound(61, 70);
 			playSound(61, 91);
-			playActorAnimation(505);
-			displayMessage(0x3cfb);
-			playAnimation(507, 1);
+			displayAsyncMessage(0x3cfb, 28877, 6, 17);
+			playActorAnimation(505, true);
+			playAnimation(507, 0, true);
+			waitAnimation();
+			
 			setOns(0, 4);
 			{
 				Object *obj = scene->getObject(3);
@@ -2440,8 +2449,8 @@
 			disableObject(15);
 			disableObject(16);
 			moveTo(162, 164, 2);
-			displayMessage(0x3d01, 0xe5);
-			displayMessage(0x3d20, 0xd8);
+			displayMessage(0x3d01, 0xe5, 24390);
+			displayMessage(0x3d20, 0xd8, 24410);
 			moveTo(162, 191, 2);
 			setOns(1, 0);
 			setOns(2, 0);

Modified: scummvm/trunk/engines/teenagent/dialog.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/dialog.cpp	2009-11-08 19:11:57 UTC (rev 45755)
+++ scummvm/trunk/engines/teenagent/dialog.cpp	2009-11-08 20:00:31 UTC (rev 45756)
@@ -40,14 +40,14 @@
 	if (animation1 != 0) {
 		SceneEvent e(SceneEvent::kPlayAnimation);
 		e.animation = animation1;
-		e.lan = 0xc0 | slot1; //looped, paused
+		e.slot = 0xc0 | slot1; //looped, paused
 		scene->push(e);
 	}
 
 	if (animation2 != 0) {
 		SceneEvent e(SceneEvent::kPlayAnimation);
 		e.animation = animation2;
-		e.lan = 0xc0 | slot2; //looped, paused
+		e.slot = 0xc0 | slot2; //looped, paused
 		scene->push(e);
 	}
 
@@ -70,26 +70,26 @@
 					//pause animation in other slot
 					if (animation1 != 0) {
 						SceneEvent e(SceneEvent::kPauseAnimation);
-						e.lan = 0x80 | slot1;
+						e.slot = 0x80 | slot1;
 						scene->push(e);
 					}
 					if (animation2 != 0) {
 						SceneEvent e(SceneEvent::kPlayAnimation);
 						e.animation = animation2;
-						e.lan = 0x80 | slot2;
+						e.slot = 0x80 | slot2;
 						scene->push(e);
 					}
 				} else if (color == color1) {
 					//pause animation in other slot
 					if (animation2 != 0) {
 						SceneEvent e(SceneEvent::kPauseAnimation);
-						e.lan = 0x80 | slot2;
+						e.slot = 0x80 | slot2;
 						scene->push(e);
 					}
 					if (animation1 != 0) {
 						SceneEvent e(SceneEvent::kPlayAnimation);
 						e.animation = animation1;
-						e.lan = 0x80 | slot1;
+						e.slot = 0x80 | slot1;
 						scene->push(e);
 					}
 				}
@@ -102,9 +102,9 @@
 					e.message = message;
 					e.color = color;
 					if (animation1 != 0 && color == color1)
-						e.lan = slot1;
+						e.slot = slot1;
 					if (animation2 != 0 && color == color2)
-						e.lan = slot2;
+						e.slot = slot2;
 					scene->push(e);
 					message.clear();
 				}

Modified: scummvm/trunk/engines/teenagent/scene.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/scene.cpp	2009-11-08 19:11:57 UTC (rev 45755)
+++ scummvm/trunk/engines/teenagent/scene.cpp	2009-11-08 20:00:31 UTC (rev 45756)
@@ -36,7 +36,8 @@
 Scene::Scene() : intro(false), _engine(NULL),
 		_system(NULL),
 		_id(0), ons(0),
-		orientation(Object::kActorRight),
+		orientation(Object::kActorRight), 
+		message_timer(0), message_first_frame(0), message_last_frame(0),
 		current_event(SceneEvent::kNone), hide_actor(false) {}
 
 void Scene::warp(const Common::Point &_point, byte o) {
@@ -303,7 +304,7 @@
 	switch (event.type) {
 	case Common::EVENT_LBUTTONDOWN:
 	case Common::EVENT_RBUTTONDOWN:
-		if (!message.empty()) {
+		if (!message.empty() && message_first_frame == 0) {
 			clearMessage();
 			nextEvent();
 			return true;
@@ -326,7 +327,7 @@
 				return true;
 			}
 		
-			if (!message.empty()) {
+			if (!message.empty() && message_first_frame == 0) {
 				clearMessage();
 				nextEvent();
 				return true;
@@ -399,7 +400,7 @@
 				s = a->currentFrame();
 			}
 			
-			if (current_event.type == SceneEvent::kWaitLanAnimationFrame && current_event.color == i) {
+			if (current_event.type == SceneEvent::kWaitLanAnimationFrame && current_event.slot == i) {
 				if (s == NULL) {
 					restart |= nextEvent();
 					continue;
@@ -407,7 +408,7 @@
 				int index = a->currentIndex();
 				debug(0, "current index = %d", index);
 				if (index == current_event.animation) {
-					debug(0, "kWaitLanAnimationFrame(%d, %d) complete", current_event.color, current_event.animation);
+					debug(0, "kWaitLanAnimationFrame(%d, %d) complete", current_event.slot, current_event.animation);
 					restart |= nextEvent();
 				}
 			}
@@ -484,8 +485,19 @@
 		}
 
 		if (!message.empty()) {
-			res->font7.render(surface, message_pos.x, message_pos.y, message, message_color);
-			busy = true;
+			bool visible = true;
+			if (message_first_frame != 0) {
+				int index = actor_animation.currentIndex() + 1;
+				if (index < message_first_frame)
+					visible = false;
+				if (index > message_last_frame) 
+					clearMessage();
+			}
+			
+			if (visible) {
+				res->font7.render(surface, message_pos.x, message_pos.y, message, message_color);
+				busy = true;
+			}
 		}
 
 		system->unlockScreen();
@@ -575,36 +587,47 @@
 		case SceneEvent::kCreditsMessage:
 		case SceneEvent::kMessage: {
 				message = current_event.message;
-				message_timer = messageDuration(message);
-				Common::Point p(
-					(actor_animation_position.left + actor_animation_position.right) / 2, 
-					actor_animation_position.top 
-				);
+				if (current_event.first_frame) {
+					message_timer = 0;
+					message_first_frame = current_event.first_frame;
+					message_last_frame = current_event.last_frame;
+				} else {
+					message_timer = messageDuration(message);
+					message_first_frame = message_last_frame = 0;
+				}
+				Common::Point p;
+				if (current_event.dst.x == 0 && current_event.dst.y == 0) {
+					p = Common::Point((actor_animation_position.left + actor_animation_position.right) / 2, 
+					actor_animation_position.top);
+				} else {
+					p = current_event.dst;
+				}
 				//FIXME: rewrite it:
-				if (current_event.lan < 4) {
-					const Surface *s = custom_animation[current_event.lan].currentFrame(0);
+				if (current_event.slot < 4) {
+					const Surface *s = custom_animation[current_event.slot].currentFrame(0);
 					if (s == NULL)
-						s = animation[current_event.lan].currentFrame(0);
+						s = animation[current_event.slot].currentFrame(0);
 					if (s != NULL) {
 						p.x = s->x + s->w / 2;
 						p.y = s->y;
 					} else 
-						warning("no animation in slot %u", current_event.lan);
+						warning("no animation in slot %u", current_event.slot);
 				}
 				message_pos = messagePosition(message, p);
 				message_color = current_event.color;
+				current_event.clear();
 			}
 			break;
 
 		case SceneEvent::kPlayAnimation:
-			debug(0, "playing animation %u in slot %u", current_event.animation, current_event.lan & 3);
-			playAnimation(current_event.lan & 3, current_event.animation, (current_event.lan & 0x80) != 0, (current_event.lan & 0x40) != 0);
+			debug(0, "playing animation %u in slot %u", current_event.animation, current_event.slot & 3);
+			playAnimation(current_event.slot & 3, current_event.animation, (current_event.slot & 0x80) != 0, (current_event.slot & 0x40) != 0);
 			current_event.clear();
 			break;
 
 		case SceneEvent::kPauseAnimation:
-			debug(0, "pause animation in slot %u", current_event.lan & 3);
-			custom_animation[current_event.lan & 3].paused = (current_event.lan & 0x80) != 0;
+			debug(0, "pause animation in slot %u", current_event.slot & 3);
+			custom_animation[current_event.slot & 3].paused = (current_event.slot & 0x80) != 0;
 			current_event.clear();
 			break;
 
@@ -616,7 +639,7 @@
 
 		case SceneEvent::kPlayActorAnimation:
 			debug(0, "playing actor animation %u", current_event.animation);
-			playActorAnimation(current_event.animation, (current_event.lan & 0x80) != 0);
+			playActorAnimation(current_event.animation, (current_event.slot & 0x80) != 0);
 			current_event.clear();
 			break;
 
@@ -652,7 +675,7 @@
 			break;
 
 		case SceneEvent::kWaitLanAnimationFrame:
-			debug(0, "waiting for the frame %d in slot %d", current_event.animation, current_event.color);
+			debug(0, "waiting for the frame %d in slot %d", current_event.animation, current_event.slot);
 			break;
 
 		case SceneEvent::kQuit:
@@ -752,6 +775,8 @@
 	message.clear();
 	message_timer = 0;
 	message_color = 0xd1;
+	message_first_frame = 0;
+	message_last_frame = 0;
 }
 
 } // End of namespace TeenAgent

Modified: scummvm/trunk/engines/teenagent/scene.h
===================================================================
--- scummvm/trunk/engines/teenagent/scene.h	2009-11-08 19:11:57 UTC (rev 45755)
+++ scummvm/trunk/engines/teenagent/scene.h	2009-11-08 20:00:31 UTC (rev 45756)
@@ -60,24 +60,32 @@
 
 	Common::String message;
 	byte color;
+	byte slot;
 	uint16 animation;
 	byte orientation;
 	Common::Point dst;
 	byte scene; //fixme: put some of these to the union?
 	byte ons;
 	byte lan;
-	byte music;
-	byte sound;
+	union {
+		byte music;
+		byte first_frame;
+	};
+	union {
+		byte sound;
+		byte last_frame;
+	};
 	byte object;
 
 	SceneEvent(Type type_) :
-			type(type_), message(), color(0xd1), animation(0), orientation(0), dst(),
+			type(type_), message(), color(0xd1), slot(0), animation(0), orientation(0), dst(),
 			scene(0), ons(0), lan(0), music(0), sound(0), object(0) {}
 
 	void clear() {
 		type = kNone;
 		message.clear();
 		color = 0xd1;
+		slot = 0;
 		orientation = 0;
 		animation = 0;
 		dst.x = dst.y = 0;
@@ -94,8 +102,8 @@
 	}
 
 	void dump() const {
-		debug(0, "event[%d]: \"%s\"[%02x], animation: %u, dst: (%d, %d) [%u], scene: %u, ons: %u, lan: %u, object: %u, music: %u, sound: %u",
-			(int)type, message.c_str(), color, animation, dst.x, dst.y, orientation, scene, ons, lan, object, music, sound
+		debug(0, "event[%d]: \"%s\"[%02x], slot: %d, animation: %u, dst: (%d, %d) [%u], scene: %u, ons: %u, lan: %u, object: %u, music: %u, sound: %u",
+			(int)type, message.c_str(), color, slot, animation, dst.x, dst.y, orientation, scene, ons, lan, object, music, sound
 		);
 	}
 };
@@ -176,6 +184,8 @@
 	Common::Point message_pos;
 	byte message_color;
 	uint message_timer;
+	byte message_first_frame;
+	byte message_last_frame;
 
 	typedef Common::List<SceneEvent> EventList;
 	EventList events;

Modified: scummvm/trunk/engines/teenagent/teenagent.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/teenagent.cpp	2009-11-08 19:11:57 UTC (rev 45755)
+++ scummvm/trunk/engines/teenagent/teenagent.cpp	2009-11-08 20:00:31 UTC (rev 45756)
@@ -355,18 +355,6 @@
 	return Common::kNoError;
 }
 
-void TeenAgentEngine::displayMessage(const Common::String &str, byte color) {
-	if (str.empty()) {
-		return;
-	}
-	SceneEvent event(SceneEvent::kMessage);
-	event.message = str;
-	event.color = color;
-	event.lan = 4;
-	scene->push(event);
-}
-
-
 Common::String TeenAgentEngine::parseMessage(uint16 addr) {
 	Common::String message;
 	for (
@@ -382,11 +370,37 @@
 	return message;
 }
 
+void TeenAgentEngine::displayMessage(const Common::String &str, byte color, uint16 position) {
+	if (str.empty()) {
+		return;
+	}
+	SceneEvent event(SceneEvent::kMessage);
+	event.message = str;
+	event.color = color;
+	event.slot = 4;
+	event.dst.x = position % 320;
+	event.dst.y = position / 320;
 
-void TeenAgentEngine::displayMessage(uint16 addr, byte color) {
-	displayMessage(parseMessage(addr), color);
+	scene->push(event);
 }
 
+void TeenAgentEngine::displayMessage(uint16 addr, byte color, uint16 position) {
+	displayMessage(parseMessage(addr), color, position);
+}
+
+void TeenAgentEngine::displayAsyncMessage(uint16 addr, uint16 position, uint16 first_frame, uint16 last_frame, byte color) {
+	SceneEvent event(SceneEvent::kMessage);
+	event.message = parseMessage(addr);
+	event.slot = 4;
+	event.color = color;
+	event.dst.x = position % 320;
+	event.dst.y = position / 320;
+	event.first_frame = first_frame;
+	event.last_frame = last_frame;
+
+	scene->push(event);
+}
+
 void TeenAgentEngine::displayCredits(uint16 addr) {
 	SceneEvent event(SceneEvent::kCreditsMessage);
 
@@ -455,7 +469,7 @@
 void TeenAgentEngine::playAnimation(uint16 id, byte slot, bool async) {
 	SceneEvent event(SceneEvent::kPlayAnimation);
 	event.animation = id;
-	event.lan = slot;
+	event.slot = slot;
 	scene->push(event);
 	if (!async)
 		waitAnimation();
@@ -561,7 +575,7 @@
 	if (frame > 0)
 		--frame;
 	
-	event.color = slot - 1;
+	event.slot = slot - 1;
 	event.animation = frame;
 	scene->push(event);
 }

Modified: scummvm/trunk/engines/teenagent/teenagent.h
===================================================================
--- scummvm/trunk/engines/teenagent/teenagent.h	2009-11-08 19:11:57 UTC (rev 45755)
+++ scummvm/trunk/engines/teenagent/teenagent.h	2009-11-08 20:00:31 UTC (rev 45756)
@@ -66,8 +66,9 @@
 	static Common::String parseMessage(uint16 addr);
 
 	//event driven:
-	void displayMessage(uint16 addr, byte color = 0xd1);
-	void displayMessage(const Common::String &str, byte color = 0xd1);
+	void displayMessage(uint16 addr, byte color = 0xd1, uint16 position = 0);
+	void displayMessage(const Common::String &str, byte color = 0xd1, uint16 position = 0);
+	void displayAsyncMessage(uint16 addr, uint16 position, uint16 first_frame, uint16 last_frame, byte color = 0xd1);
 	void displayCredits(uint16 addr);
 	void displayCutsceneMessage(uint16 addr, uint16 position);
 	void moveTo(const Common::Point &dst, byte o, bool warp = false);


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