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

megath at users.sourceforge.net megath at users.sourceforge.net
Mon Nov 9 08:58:27 CET 2009


Revision: 45772
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45772&view=rev
Author:   megath
Date:     2009-11-09 07:58:27 +0000 (Mon, 09 Nov 2009)

Log Message:
-----------
added 'ignore' flag, ported guard and anchor challenges to it. minor fixes

Modified Paths:
--------------
    scummvm/trunk/engines/teenagent/animation.cpp
    scummvm/trunk/engines/teenagent/animation.h
    scummvm/trunk/engines/teenagent/callbacks.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/animation.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/animation.cpp	2009-11-09 04:27:08 UTC (rev 45771)
+++ scummvm/trunk/engines/teenagent/animation.cpp	2009-11-09 07:58:27 UTC (rev 45772)
@@ -27,7 +27,7 @@
 
 namespace TeenAgent {
 
-Animation::Animation() : id(0), x(0), y(0), loop(true), paused(false), data(0), data_size(0), frames_count(0), frames(0), index(0) {
+Animation::Animation() : id(0), x(0), y(0), loop(true), paused(false), ignore(false), data(0), data_size(0), frames_count(0), frames(0), index(0) {
 }
 
 Surface *Animation::firstFrame() {
@@ -86,6 +86,7 @@
 
 void Animation::restart() {
 	paused = false;
+	ignore = false;
 	index = 0;
 }
 
@@ -94,6 +95,7 @@
 	x = y = 0;
 	loop = true;
 	paused = false;
+	ignore = false;
 
 	delete[] data;
 	data = NULL;

Modified: scummvm/trunk/engines/teenagent/animation.h
===================================================================
--- scummvm/trunk/engines/teenagent/animation.h	2009-11-09 04:27:08 UTC (rev 45771)
+++ scummvm/trunk/engines/teenagent/animation.h	2009-11-09 07:58:27 UTC (rev 45772)
@@ -33,7 +33,7 @@
 class Animation  {
 public:
 	uint16 id, x, y;
-	bool loop, paused;
+	bool loop, paused, ignore;
 
 	enum Type {kTypeLan, kTypeVaria, kTypeInventory};
 

Modified: scummvm/trunk/engines/teenagent/callbacks.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/callbacks.cpp	2009-11-09 04:27:08 UTC (rev 45771)
+++ scummvm/trunk/engines/teenagent/callbacks.cpp	2009-11-09 07:58:27 UTC (rev 45772)
@@ -32,6 +32,7 @@
 #define CHECK_FLAG(addr, v) (res->dseg.get_byte(addr) == (v))
 #define SET_FLAG(addr, v) (res->dseg.set_byte((addr), (v)))
 #define GET_FLAG(addr) (res->dseg.get_byte(addr))
+#define INC_FLAG(addr) (++*res->dseg.ptr(addr))
 
 void TeenAgentEngine::rejectMessage() {
 	Resources * res = Resources::instance();
@@ -750,24 +751,25 @@
 		return true;
 
 	case 0x5104:
-		loadScene(11, 319, 198, 4); //orientation: left
+		loadScene(11, 319, 198, 4);
 		if (CHECK_FLAG(0xDB9C, 1))
 			return true;
 
+		//guard's drinking
 		SET_FLAG(0, 3);
-		setTimerCallback(0x516d, 40); //fail
-		playAnimation(544, 0);
+		setTimerCallback(0x516d, 40);
+		playAnimation(544, 0, true, true); //ignore busy flag for this animation
 		return true;
 		
-	case 0x516d:
+	case 0x516d: //too late to scare guard, resetting
 		SET_FLAG(0, 0);
 		return true;
 
-	case 0x5189:
+	case 0x5189: //guard's drinking, boo!
 		SET_FLAG(0, 0);
 		setTimerCallback(0, 0);
-		scene->cancelAnimation(0);
-		SET_FLAG(0xDB9C, 1); //guard's drinking, boo!
+		scene->getAnimation(0)->free();
+		SET_FLAG(0xDB9C, 1); 
 		
 		displayAsyncMessage(0x3563, 320 * 130 + 300, 1, 5);
 		setOns(0, 16);
@@ -1584,8 +1586,7 @@
 	case 0x5f73: //exiting ann's house
 		if (CHECK_FLAG(0xDBEE, 1))
 			playMusic(6);
-		loadScene(21, 161, 165);
-
+		loadScene(21, 99, 180, 3);
 		return true;
 
 	case 0x5fba:
@@ -1699,10 +1700,10 @@
 
 	case 0x6480: //dive mask
 		if (CHECK_FLAG(0xDB96, 1)) {
-			setOns(3, 36);
 			playSound(56, 7);
 			playSound(5, 15);
 			playActorAnimation(613);
+			setOns(3, 36);
 			inventory->add(39);
 			disableObject(5);
 			displayMessage(0x387c);
@@ -2523,8 +2524,9 @@
 	case 0x88de:
 		playSound(5, 2);
 		Dialog::show(scene, 0x1B5F, 0, 523, 0xd1, 0xe5, 0, 1);
-		playActorAnimation(537);
-		playAnimation(538, 0);
+		playActorAnimation(537, true);
+		playAnimation(538, 0, true);
+		waitAnimation();
 		Dialog::show(scene, 0x1BE0, 0, 523, 0xd1, 0xe5, 0, 1);
 		return true;
 
@@ -2551,16 +2553,16 @@
 		return true;
 
 	case 0x8942:
-		Dialog::show(scene, 0x2293);
+		Dialog::show(scene, 0x2293, 0, 524, 0xd1, 0xe5, 0, 2);
 		playSound(5, 10);
 		playActorAnimation(540, true);
 		playAnimation(539, 1, true);
 		waitAnimation();
-		Dialog::show(scene, 0x24b1);
-		Dialog::show(scene, 0x24d7);
-		Dialog::show(scene, 0x2514);
+		Dialog::show(scene, 0x24b1, 0, 524, 0xd1, 0xe5, 0, 2);
+		Dialog::show(scene, 0x24d7, 0, 524, 0xd1, 0xe5, 0, 2);
+		Dialog::show(scene, 0x2514, 0, 524, 0xd1, 0xe5, 0, 2);
 		moveTo(scene->getPosition().x, scene->getPosition().y + 1, 0);
-		Dialog::show(scene, 0x2570);
+		Dialog::show(scene, 0x2570, 0, 524, 0xd1, 0xe5, 0, 2);
 		return true;
 
 	case 0x89aa:
@@ -3716,11 +3718,9 @@
 
 	case 0x9921: {
 		int id = scene->getId();
-		Common::Point p = scene->getPosition();
 		if (id != 15) {
 			displayMessage(id == 16 ? 0x38ce : 0x38a7);
 		} else {
-			moveTo(156, 180, 3);
 			playSound(5, 3);
 			playSound(38, 16);
 			playSound(38, 22);
@@ -3729,28 +3729,68 @@
 			playSound(44, 10);
 			playSound(20, 26);
 			playActorAnimation(615);
-			loadScene(17, p);
+			loadScene(17, 156, 180, 3);
+			SET_FLAG(0, 4);
 			playSound(64, 7);
 			playSound(64, 21);
 			playSound(64, 42);
 			playSound(64, 63);
-			playActorAnimation(617);
+			setTimerCallback(0x9a1d, 40);
+			playActorAnimation(617, false, true);
 			//another time challenge!
-			if (true) {
-				playSound(64, 7);
-				playActorAnimation(618);
-				disableObject(5);
-				setOns(0, 0);
-				playSound(31, 1);
-				playActorAnimation(619);
-				inventory->add(42);
-				displayMessage(0x3989);
-			}
-			loadScene(id, p);
 		}
 	}
 	return true;
-
+	
+	case 0x9a1d: //no anchor, timeout
+		SET_FLAG(0, 0);
+		processCallback(0x9a7a);
+		INC_FLAG(0xDBA6);
+		switch(GET_FLAG(0xDBA6)) {
+		case 1:
+			displayMessage(0x39ae);
+			break;
+		case 2:
+			displayMessage(0x39f6);
+			break;
+		case 3:
+			displayMessage(0x3a28);
+			break;
+		case 4:
+			displayMessage(0x3a85);
+			break;
+		case 5:
+			displayMessage(0x39ae);
+			break;
+		default: 
+			displayMessage(0x39b7);
+		}
+		return true;
+	
+	case 0x99e0: //success getting an anchor
+		SET_FLAG(0, 0);
+		setTimerCallback(0, 0);
+		scene->getActorAnimation()->free();
+		playSound(64, 7);
+		playActorAnimation(618);
+		disableObject(5);
+		setOns(0, 0);
+		playSound(31, 1);
+		playActorAnimation(619);
+		processCallback(0x9a7a);
+		inventory->add(42);
+		displayMessage(0x3989);
+		return true;
+		
+	case 0x9a7a:
+		loadScene(15, 156, 180, 3);
+		playSound(5, 5);
+		playSound(38, 14);
+		playSound(38, 20);
+		playSound(5, 25);
+		playActorAnimation(616);
+		return true;
+		
 	case 0x9aca:
 		if (scene->getId() == 13) {
 			moveTo(172, 181, 1);

Modified: scummvm/trunk/engines/teenagent/scene.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/scene.cpp	2009-11-09 04:27:08 UTC (rev 45771)
+++ scummvm/trunk/engines/teenagent/scene.cpp	2009-11-09 07:58:27 UTC (rev 45772)
@@ -274,7 +274,7 @@
 		_engine->music->load(res->dseg.get_byte(0xDB90));
 }
 
-void Scene::playAnimation(byte idx, uint id, bool loop, bool paused) {
+void Scene::playAnimation(byte idx, uint id, bool loop, bool paused, bool ignore) {
 	assert(idx < 4);
 	Common::SeekableReadStream *s = Resources::instance()->loadLan(id + 1);
 	if (s == NULL)
@@ -283,25 +283,22 @@
 	custom_animation[idx].load(s);
 	custom_animation[idx].loop = loop;
 	custom_animation[idx].paused = paused;
+	custom_animation[idx].ignore = ignore;
 }
 
-void Scene::playActorAnimation(uint id, bool loop) {
+void Scene::playActorAnimation(uint id, bool loop, bool ignore) {
 	Common::SeekableReadStream *s = Resources::instance()->loadLan(id + 1);
 	if (s == NULL)
 		error("playing animation %u failed", id);
 
 	actor_animation.load(s);
 	actor_animation.loop = loop;
+	actor_animation.ignore = ignore;
 }
 
-bool Scene::cancelAnimation(byte slot) {
+Animation * Scene::getAnimation(byte slot) {
 	assert(slot < 4);
-	if (custom_animation[slot].empty())
-		return false;
-	else {
-		custom_animation[slot].free();
-		return true;
-	}
+	return custom_animation + slot;
 }
 
 void Scene::push(const SceneEvent &event) {
@@ -404,7 +401,10 @@
 			Animation *a = custom_animation + i;
 			Surface *s = a->currentFrame();
 			if (s != NULL) {
-				busy = true;
+				if (!a->ignore) 
+					busy = true;
+				else 
+					busy = false;
 				if (!a->paused && !a->loop)
 					got_any_animation = true;
 			} else {
@@ -452,7 +452,10 @@
 			Surface *mark = actor_animation.currentFrame();
 			if (mark != NULL) {
 				actor_animation_position = mark->render(surface);
-				busy = true;
+				if (!actor_animation.ignore) 
+					busy = true;
+				else 
+					busy = false;
 				got_any_animation = true;
 			} else if (!hide_actor) {
 				actor_animation.free();
@@ -500,7 +503,7 @@
 			bool visible = true;
 			if (message_first_frame != 0 && message_animation != NULL) {
 				int index = message_animation->currentIndex() + 1;
-				debug(0, "message: %s first: %u index: %u", message.c_str(), message_first_frame, index);
+				//debug(0, "message: %s first: %u index: %u", message.c_str(), message_first_frame, index);
 				if (index < message_first_frame)
 					visible = false;
 				if (index > message_last_frame) {
@@ -520,7 +523,6 @@
 				if (_engine->inventory->active())
 					_engine->inventory->activate(false);
 				_engine->processCallback(callback);
-				callback = 0;
 			}
 		}
 
@@ -655,7 +657,7 @@
 
 		case SceneEvent::kPlayAnimation:
 			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);
+			playAnimation(current_event.slot & 3, current_event.animation, (current_event.slot & 0x80) != 0, (current_event.slot & 0x40) != 0, (current_event.slot & 0x20) != 0);
 			current_event.clear();
 			break;
 
@@ -673,7 +675,7 @@
 
 		case SceneEvent::kPlayActorAnimation:
 			debug(0, "playing actor animation %u", current_event.animation);
-			playActorAnimation(current_event.animation, (current_event.slot & 0x80) != 0);
+			playActorAnimation(current_event.animation, (current_event.slot & 0x80) != 0, (current_event.slot & 0x20) != 0);
 			current_event.clear();
 			break;
 

Modified: scummvm/trunk/engines/teenagent/scene.h
===================================================================
--- scummvm/trunk/engines/teenagent/scene.h	2009-11-09 04:27:08 UTC (rev 45771)
+++ scummvm/trunk/engines/teenagent/scene.h	2009-11-09 07:58:27 UTC (rev 45772)
@@ -148,14 +148,15 @@
 	Object *findObject(const Common::Point &point);
 
 	void loadObjectData();
-	bool cancelAnimation(byte slot);
+	Animation * getAnimation(byte slot);
+	inline Animation * getActorAnimation() { return &actor_animation; }
 
 private:
 	void loadOns();
 	void loadLans();
 
-	void playAnimation(byte idx, uint id, bool loop, bool paused);
-	void playActorAnimation(uint id, bool loop);
+	void playAnimation(byte idx, uint id, bool loop, bool paused, bool ignore);
+	void playActorAnimation(uint id, bool loop, bool ignore);
 
 	byte palette[768];
 	void setPalette(OSystem *system, const byte *palette, unsigned mul = 1);

Modified: scummvm/trunk/engines/teenagent/teenagent.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/teenagent.cpp	2009-11-09 04:27:08 UTC (rev 45771)
+++ scummvm/trunk/engines/teenagent/teenagent.cpp	2009-11-09 07:58:27 UTC (rev 45772)
@@ -300,15 +300,20 @@
 				}
 				break;
 			case Common::EVENT_LBUTTONDOWN:
+				examine(event.mouse, current_object);
+				break;
 			case Common::EVENT_RBUTTONDOWN:
-				if (res->dseg.get_byte(0) == 3) {
+				//if (current_object)
+				//	debug(0, "%d, %s", current_object->id, current_object->name.c_str());
+				if (res->dseg.get_byte(0) == 3 && current_object->id == 1) {
 					processCallback(0x5189); //boo!
 					break;
 				}
-				if (event.type == Common::EVENT_LBUTTONDOWN)
-					examine(event.mouse, current_object);
-				else
-					use(current_object);
+				if (res->dseg.get_byte(0) == 4 && current_object->id == 5) {
+					processCallback(0x99e0); //getting an anchor
+					break;
+				}
+				use(current_object);
 				break;
 			case Common::EVENT_MOUSEMOVE:
 				mouse = event.mouse;
@@ -496,18 +501,19 @@
 	scene->push(event);
 }
 
-void TeenAgentEngine::playAnimation(uint16 id, byte slot, bool async) {
+void TeenAgentEngine::playAnimation(uint16 id, byte slot, bool async, bool ignore) {
 	SceneEvent event(SceneEvent::kPlayAnimation);
 	event.animation = id;
-	event.slot = slot;
+	event.slot = slot | (ignore? 0x20: 0);
 	scene->push(event);
 	if (!async)
 		waitAnimation();
 }
 
-void TeenAgentEngine::playActorAnimation(uint16 id, bool async) {
+void TeenAgentEngine::playActorAnimation(uint16 id, bool async, bool ignore) {
 	SceneEvent event(SceneEvent::kPlayActorAnimation);
 	event.animation = id;
+	event.slot = ignore? 0x20: 0;
 	scene->push(event);
 	if (!async)
 		waitAnimation();

Modified: scummvm/trunk/engines/teenagent/teenagent.h
===================================================================
--- scummvm/trunk/engines/teenagent/teenagent.h	2009-11-09 04:27:08 UTC (rev 45771)
+++ scummvm/trunk/engines/teenagent/teenagent.h	2009-11-09 07:58:27 UTC (rev 45772)
@@ -76,8 +76,8 @@
 	void moveTo(uint16 x, uint16 y, byte o, bool warp = false);
 	void moveTo(Object *obj);
 	void moveRel(int16 x, int16 y, byte o, bool warp = false);
-	void playActorAnimation(uint16 id, bool async = false);
-	void playAnimation(uint16 id, byte slot, bool async = false);
+	void playActorAnimation(uint16 id, bool async = false, bool ignore = false);
+	void playAnimation(uint16 id, byte slot, bool async = false, bool ignore = false);
 	void loadScene(byte id, const Common::Point &pos, byte o = 0);
 	void loadScene(byte id, uint16 x, uint16 y, byte o = 0);
 	void setOns(byte id, byte value, byte scene_id = 0);


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