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

megath at users.sourceforge.net megath at users.sourceforge.net
Tue Sep 15 00:23:35 CEST 2009


Revision: 44091
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44091&view=rev
Author:   megath
Date:     2009-09-14 22:23:35 +0000 (Mon, 14 Sep 2009)

Log Message:
-----------
added PauseAnimation/ClearAnimations event, fixed dialogue animations in intro.

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

Modified: scummvm/trunk/engines/teenagent/animation.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/animation.cpp	2009-09-14 21:07:01 UTC (rev 44090)
+++ scummvm/trunk/engines/teenagent/animation.cpp	2009-09-14 22:23:35 UTC (rev 44091)
@@ -27,14 +27,26 @@
 
 namespace TeenAgent {
 
-Animation::Animation() : id(0), x(0), y(0), loop(true), data(0), data_size(0), frames_count(0), frames(0), index(0) {
+Animation::Animation() : id(0), x(0), y(0), loop(true), paused(false), data(0), data_size(0), frames_count(0), frames(0), index(0) {
 }
 
-Surface * Animation::firstFrame() const {
-	return frames;
+Surface * Animation::firstFrame(){
+	if (frames == NULL || frames_count == 0)
+		return NULL;
+	
+	Surface * r = frames;
+	uint16 pos = READ_LE_UINT16(data + 1);
+	if (pos != 0) {
+		r->x = pos % 320;
+		r->y = pos / 320;
+	}
+	return r;
 }
 
 Surface * Animation::currentFrame(int dt) {
+	if (paused)
+		return firstFrame();
+	
 	if (frames == NULL || frames_count == 0)
 		return NULL;
 	
@@ -77,6 +89,7 @@
 	id = 0;
 	x = y = 0;
 	loop = true;
+	paused = false;
 	
 	delete[] data;
 	data = NULL;

Modified: scummvm/trunk/engines/teenagent/animation.h
===================================================================
--- scummvm/trunk/engines/teenagent/animation.h	2009-09-14 21:07:01 UTC (rev 44090)
+++ scummvm/trunk/engines/teenagent/animation.h	2009-09-14 22:23:35 UTC (rev 44091)
@@ -33,7 +33,7 @@
 class Animation  {
 public: 
 	uint16 id, x, y;
-	bool loop;
+	bool loop, paused;
 	
 	enum Type {TypeLan, TypeVaria, TypeInventory};
 	
@@ -41,7 +41,7 @@
 	void load(Common::SeekableReadStream * s, Type type = TypeLan);
 	void free();
 	
-	Surface * firstFrame() const;
+	Surface * firstFrame();
 	Surface * currentFrame(int dt = 1);
 	uint16 currentIndex() const { return index; }
 	

Modified: scummvm/trunk/engines/teenagent/callbacks.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/callbacks.cpp	2009-09-14 21:07:01 UTC (rev 44090)
+++ scummvm/trunk/engines/teenagent/callbacks.cpp	2009-09-14 22:23:35 UTC (rev 44091)
@@ -90,6 +90,7 @@
 	
 	case 0x024c: //intro
 		hideActor();
+
 		loadScene(41, 139, 156, 3);
 		playSound(41, 12);
 		playAnimation(912, 1);
@@ -99,7 +100,7 @@
 		playAnimation(913, 1);
 		setOns(1, 109);
 		setLan(2, 1);
-		Dialog::show(scene, 0x748e, 914, 915, 0xe7, 0xd7);
+		Dialog::show(scene, 0x748e, 914, 915, 0xe7, 0xd7, 2, 1);
 		displayCredits(0xe3c2);
 		loadScene(42, 139, 156, 3);
 		playSound(15, 20);
@@ -113,7 +114,7 @@
 		playAnimation(917, 1, true);
 		waitAnimation();
 		displayCredits(0xe3e6);
-
+		
 		loadScene(40, 139, 156, 3);
 		playMusic(3);
 		Dialog::show(scene, 0x750d, 920, 924, 0xe7, 0xeb); //as i told you, our organization...
@@ -121,7 +122,7 @@
 		playAnimation(925, 0, true);
 		playAnimation(926, 1, true);
 		waitAnimation();
-		Dialog::show(scene, 0x78a6, 927, 920, 0xeb, 0xeb); 
+		Dialog::show(scene, 0x78a6, 920, 927, 0xeb, 0xeb); 
 		displayCredits(0xe3ff);
 		
 		loadScene(39, 139, 156, 3);

Modified: scummvm/trunk/engines/teenagent/dialog.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/dialog.cpp	2009-09-14 21:07:01 UTC (rev 44090)
+++ scummvm/trunk/engines/teenagent/dialog.cpp	2009-09-14 22:23:35 UTC (rev 44091)
@@ -28,13 +28,29 @@
 
 namespace TeenAgent {
 
-void Dialog::show(Scene * scene, uint16 addr, uint16 animation1, uint16 animation2, byte color1, byte color2) {
-	debug(0, "Dialog::show(%04x, %u, %u)", addr, animation1, animation2);
+void Dialog::show(Scene * scene, uint16 addr, uint16 animation1, uint16 animation2, byte color1, byte color2, byte slot1, byte slot2) {
+	--slot1;
+	--slot2;
+	debug(0, "Dialog::pop(%04x, %u:%u, %u:%u)", addr, slot1, animation1, slot2, animation2);
 	Resources * res = Resources::instance();
 	int n = 0;
 	Common::String message;
 	byte color = color1;
 	
+	if (animation1 != 0) {
+		SceneEvent e(SceneEvent::PlayAnimation);
+		e.animation = animation1;
+		e.color = 0xc0 | slot1; //looped, paused
+		scene->push(e);
+	}
+
+	if (animation2 != 0) {
+		SceneEvent e(SceneEvent::PlayAnimation);
+		e.animation = animation2;
+		e.color = 0xc0 | slot2; //looped, paused
+		scene->push(e);
+	}
+	
 	while (n < 4) {
 		byte c = res->eseg.get_byte(addr++);
 		//debug(0, "%02x: %c", c, c > 0x20? c: '.');
@@ -51,15 +67,31 @@
 				//debug(0, "displaymessage\n");
 				
 				if (color == color2 && animation2 != 0) {
-					SceneEvent e(SceneEvent::PlayAnimation);
-					e.animation = animation2;
-					e.color = 0x41;
-					scene->push(e);
+					//pause animation in other slot
+					{
+						SceneEvent e(SceneEvent::PauseAnimation);
+						e.color = 0x80 | slot1;
+						scene->push(e);
+					}
+					{
+						SceneEvent e(SceneEvent::PlayAnimation);
+						e.animation = animation2;
+						e.color = 0x80 | slot2;
+						scene->push(e);
+					}
 				} else if (color == color1 && animation1 != 0) {
-					SceneEvent e(SceneEvent::PlayAnimation);
-					e.animation = animation1;
-					e.color = 0x41;
-					scene->push(e);
+					//pause animation in other slot
+					{
+						SceneEvent e(SceneEvent::PauseAnimation);
+						e.color = 0x80 | slot2;
+						scene->push(e);
+					}
+					{
+						SceneEvent e(SceneEvent::PlayAnimation);
+						e.animation = animation1;
+						e.color = 0x80 | slot1;
+						scene->push(e);
+					}
 				}
 				
 				{
@@ -103,10 +135,12 @@
 		scene->push(e);
 	}
 	*/
+	SceneEvent e(SceneEvent::ClearAnimations);
+	scene->push(e);
 }
 
-uint16 Dialog::pop(Scene *scene, uint16 addr, uint16 animation, uint16 actor_animation, byte color1, byte color2) {
-	debug(0, "Dialog::pop(%04x, %u)", addr, animation);
+uint16 Dialog::pop(Scene *scene, uint16 addr, uint16 animation1, uint16 animation2, byte color1, byte color2, byte slot1, byte slot2) {
+	debug(0, "Dialog::pop(%04x, %u:%u, %u:%u)", addr, slot1, animation1, slot2, animation2);
 	Resources * res = Resources::instance();
 	uint16 next;
 	do {
@@ -116,7 +150,7 @@
 	uint16 next2 = res->dseg.get_word(addr);
 	if (next2 != 0xffff)
 		res->dseg.set_word(addr - 2, 0);
-	show(scene, next, animation, actor_animation, color1, color2);
+	show(scene, next, animation1, animation2, color1, color2, slot1, slot2);
 	return next;
 }
 

Modified: scummvm/trunk/engines/teenagent/dialog.h
===================================================================
--- scummvm/trunk/engines/teenagent/dialog.h	2009-09-14 21:07:01 UTC (rev 44090)
+++ scummvm/trunk/engines/teenagent/dialog.h	2009-09-14 22:23:35 UTC (rev 44091)
@@ -33,8 +33,8 @@
 class Scene;
 class Dialog {
 public: 
-	static uint16 pop(Scene *scene, uint16 addr, uint16 animation1 = 0, uint16 animation2 = 0, byte color1 = 0xd1, byte color2 = 0xd0);
-	static void show(Scene *scene, uint16 addr, uint16 animation1 = 0, uint16 animation2 = 0, byte color1 = 0xd1, byte color2 = 0xd0);
+	static uint16 pop(Scene *scene, uint16 addr, uint16 animation1 = 0, uint16 animation2 = 0, byte color1 = 0xd1, byte color2 = 0xd0, byte slot1 = 1, byte slot2 = 2);
+	static void show(Scene *scene, uint16 addr, uint16 animation1 = 0, uint16 animation2 = 0, byte color1 = 0xd1, byte color2 = 0xd0, byte slot1 = 1, byte slot2 = 2);
 };
 
 } // End of namespace TeenAgent

Modified: scummvm/trunk/engines/teenagent/scene.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/scene.cpp	2009-09-14 21:07:01 UTC (rev 44090)
+++ scummvm/trunk/engines/teenagent/scene.cpp	2009-09-14 22:23:35 UTC (rev 44091)
@@ -230,7 +230,7 @@
 		_engine->music->load(res->dseg.get_byte(0xDB90));
 }
 
-void Scene::playAnimation(byte idx, uint id, bool loop) {
+void Scene::playAnimation(byte idx, uint id, bool loop, bool paused) {
 	assert(idx < 4);
 	Common::SeekableReadStream * s = Resources::instance()->loadLan(id + 1);
 	if (s == NULL)
@@ -238,6 +238,7 @@
 
 	custom_animations[idx].load(s);
 	custom_animations[idx].loop = loop;
+	custom_animations[idx].paused = paused;
 }
 
 void Scene::playActorAnimation(uint id, bool loop) {
@@ -261,10 +262,6 @@
 	case Common::EVENT_RBUTTONDOWN: 
 		if (!message.empty()) {
 			message.clear();
-			for(int i = 0; i < 4; ++i) {
-				if (custom_animations[i].loop)
-					custom_animations[i].free();
-			}
 			nextEvent();
 			return true;
 		}
@@ -482,49 +479,61 @@
 			message = current_event.message;
 			message_pos = messagePosition(message, position);
 			message_color = current_event.color;
-		break;
+			break;
 		
-		case SceneEvent::PlayAnimation: {
+		case SceneEvent::PlayAnimation: 
 			debug(0, "playing animation %u", current_event.animation);
-			playAnimation(current_event.color & 0x3 /*slot actually :)*/, current_event.animation, (current_event.color & 0x40) != 0);
+			playAnimation(current_event.color & 0x3 /*slot actually :)*/, current_event.animation, (current_event.color & 0x80) != 0, (current_event.color & 0x40) != 0);
 			current_event.clear();
-		} break;
+			break;
 
-		case SceneEvent::PlayActorAnimation: {
+		case SceneEvent::PauseAnimation:
+			debug(0, "pause animation in slot %u", current_event.color & 3);
+			custom_animations[current_event.color & 3].paused = (current_event.color & 0x80) != 0;
+			current_event.clear();
+			break;
+
+		case SceneEvent::ClearAnimations:
+			for(byte i = 0; i < 4; ++i) 
+				custom_animations[i].free();
+			current_event.clear();
+			break;
+		
+		case SceneEvent::PlayActorAnimation: 
 			debug(0, "playing actor animation %u", current_event.animation);
-			playActorAnimation(current_event.animation, (current_event.color & 0x40) != 0);
+			playActorAnimation(current_event.animation, (current_event.color & 0x80) != 0);
 			current_event.clear();
-		} break;
-		
-		case SceneEvent::PlayMusic: {
+			break;
+			
+		case SceneEvent::PlayMusic:
 			debug(0, "setting music %u", current_event.music);
 			_engine->setMusic(current_event.music);
 			Resources::instance()->dseg.set_byte(0xDB90, current_event.music);
 			current_event.clear();
-		} break;
+			break;
 
-		case SceneEvent::PlaySound: {
+		case SceneEvent::PlaySound:
 			debug(0, "playing sound %u, delay: %u", current_event.sound, current_event.color);
 			if (current_event.color == 0) {
 				_engine->playSoundNow(current_event.sound);
 			} else {
 				sounds.push_back(Sound(current_event.sound, current_event.color));
 			}
-			
 			current_event.clear();
-		} break;
+			break;
 		
 		case SceneEvent::EnableObject: {
-			debug(0, "%s object #%u", current_event.color?"enabling":"disabling", current_event.object - 1);
-			Object * obj = getObject(current_event.object - 1, current_event.scene == 0? _id: current_event.scene);
-			obj->enabled = current_event.color;
-			current_event.clear();
-		} break;
+				debug(0, "%s object #%u", current_event.color?"enabling":"disabling", current_event.object - 1);
+				Object * obj = getObject(current_event.object - 1, current_event.scene == 0? _id: current_event.scene);
+				obj->enabled = current_event.color;
+				current_event.clear();
+			}
+			break;
 		
-		case SceneEvent::HideActor: {
+		case SceneEvent::HideActor:
 			hide_actor = current_event.color != 0;
 			current_event.clear();
-		} break;
+			break;
 		
 		case SceneEvent::WaitForAnimation:
 			debug(0, "waiting for the animation");

Modified: scummvm/trunk/engines/teenagent/scene.h
===================================================================
--- scummvm/trunk/engines/teenagent/scene.h	2009-09-14 21:07:01 UTC (rev 44090)
+++ scummvm/trunk/engines/teenagent/scene.h	2009-09-14 22:23:35 UTC (rev 44091)
@@ -40,7 +40,7 @@
 
 struct SceneEvent {
 	enum Type { 
-		None, Message, Walk, PlayAnimation, PlayActorAnimation, 
+		None, Message, Walk, PlayAnimation, PlayActorAnimation, PauseAnimation, ClearAnimations, 
 		LoadScene, SetOn, SetLan, PlayMusic, 
 		PlaySound, EnableObject, HideActor, 
 		WaitForAnimation, CreditsMessage, 
@@ -125,7 +125,7 @@
 	void loadOns();
 	void loadLans();
 
-	void playAnimation(byte idx, uint id, bool loop);
+	void playAnimation(byte idx, uint id, bool loop, bool paused);
 	void playActorAnimation(uint id, bool loop);
 	
 	byte palette[768];


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