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

megath at users.sourceforge.net megath at users.sourceforge.net
Tue Jan 5 23:09:16 CET 2010


Revision: 47056
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47056&view=rev
Author:   megath
Date:     2010-01-05 22:09:16 +0000 (Tue, 05 Jan 2010)

Log Message:
-----------
separate timers for mark, scene and messages.

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

Modified: scummvm/trunk/engines/teenagent/actor.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/actor.cpp	2010-01-05 22:02:04 UTC (rev 47055)
+++ scummvm/trunk/engines/teenagent/actor.cpp	2010-01-05 22:09:16 UTC (rev 47056)
@@ -31,7 +31,7 @@
 Actor::Actor() : head_index(0), idle_type(0) {}
 
 //idle animation lists at dseg: 0x6540
-Common::Rect Actor::renderIdle(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, uint zoom) {
+Common::Rect Actor::renderIdle(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame, uint zoom) {
 	static Common::RandomSource random;
 	if (index == 0) {
 		idle_type = random.getRandomNumber(2);
@@ -41,7 +41,8 @@
 	Resources * res = Resources::instance();
 	byte *frames_idle;
 	do {
-		frames_idle = res->dseg.ptr(res->dseg.get_word(0x6540 + idle_type * 2)) + index++;
+		frames_idle = res->dseg.ptr(res->dseg.get_word(0x6540 + idle_type * 2)) + index;
+		index += delta_frame;
 		if (*frames_idle == 0) {
 			idle_type = random.getRandomNumber(2);
 			debug(0, "switched to idle animation %u[loop]", idle_type);
@@ -100,11 +101,9 @@
 
 	Surface *s = NULL, *head = NULL;
 
-	if (delta_frame == 0) {
-		index = 0; //static animation
-	}
-
 	bool mirror = orientation == kActorLeft;
+	index += delta_frame;
+
 	switch (orientation) {
 	case kActorLeft:
 	case kActorRight:
@@ -146,7 +145,6 @@
 	default:
 		return Common::Rect();
 	}
-	index += delta_frame;
 	if (s == NULL) {
 		warning("no surface, skipping");
 		return Common::Rect();

Modified: scummvm/trunk/engines/teenagent/actor.h
===================================================================
--- scummvm/trunk/engines/teenagent/actor.h	2010-01-05 22:02:04 UTC (rev 47055)
+++ scummvm/trunk/engines/teenagent/actor.h	2010-01-05 22:09:16 UTC (rev 47056)
@@ -33,7 +33,7 @@
 public:
 	Actor();
 	Common::Rect render(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame, bool head, uint zoom);
-	Common::Rect renderIdle(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, uint zoom);
+	Common::Rect renderIdle(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame, uint zoom);
 };
 
 } // End of namespace TeenAgent

Modified: scummvm/trunk/engines/teenagent/animation.h
===================================================================
--- scummvm/trunk/engines/teenagent/animation.h	2010-01-05 22:02:04 UTC (rev 47055)
+++ scummvm/trunk/engines/teenagent/animation.h	2010-01-05 22:09:16 UTC (rev 47056)
@@ -42,7 +42,7 @@
 	void free();
 
 	Surface *firstFrame();
-	Surface *currentFrame(int dt = 1);
+	Surface *currentFrame(int dt);
 	uint16 currentIndex() const { return index; }
 	void resetIndex() { index = 0; }
 

Modified: scummvm/trunk/engines/teenagent/inventory.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/inventory.cpp	2010-01-05 22:02:04 UTC (rev 47055)
+++ scummvm/trunk/engines/teenagent/inventory.cpp	2010-01-05 22:09:16 UTC (rev 47056)
@@ -254,9 +254,9 @@
 			animation.load(inventory->items, Animation::kTypeInventory);
 		}
 		if (hovered) {
-			Surface *s = animation.currentFrame();
+			Surface *s = animation.currentFrame(1);
 			if (animation.currentIndex() == 0)
-				s = animation.currentFrame();
+				s = animation.currentFrame(1);
 			if (s != NULL)
 				s->render(dst, rect.left + 1, rect.top + 1);
 		} else {

Modified: scummvm/trunk/engines/teenagent/scene.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/scene.cpp	2010-01-05 22:02:04 UTC (rev 47055)
+++ scummvm/trunk/engines/teenagent/scene.cpp	2010-01-05 22:09:16 UTC (rev 47056)
@@ -532,21 +532,23 @@
 }
 
 
-bool Scene::render() {
+bool Scene::render(bool tick_game, bool tick_mark, uint32 message_delta) {
 	Resources *res = Resources::instance();
 	bool busy;
 	bool restart;
+	uint32 game_delta = tick_game? 1: 0;
+	uint32 mark_delta = tick_mark? 1: 0;
 
 	do {
 		restart = false;
 		busy = processEventQueue();
 		
-		if (_fade_timer) {
+		if (_fade_timer && game_delta != 0) {
 			if (_fade_timer > 0) {
-				--_fade_timer;
+				_fade_timer -= game_delta;
 				setPalette(_fade_timer);
 			} else {
-				++_fade_timer;
+				_fade_timer += game_delta;
 				setPalette(_fade_timer + 4);
 			}
 		}
@@ -556,7 +558,7 @@
 			_system->fillScreen(0);
 			///\todo: optimize me
 			Graphics::Surface *surface = _system->lockScreen();
-			res->font7.render(surface, current_event.dst.x, current_event.dst.y--, current_event.message, current_event.color);
+			res->font7.render(surface, current_event.dst.x, current_event.dst.y -= game_delta, current_event.message, current_event.color);
 			_system->unlockScreen();
 
 			if (current_event.dst.y < -(int)current_event.timer)
@@ -568,11 +570,12 @@
 		}
 
 		if (!message.empty() && message_timer != 0) {
-			if (--message_timer == 0) {
+			if (message_timer <= message_delta) {
 				clearMessage();
 				nextEvent();
 				continue;
-			}
+			} else
+				message_timer -= message_delta;
 		}
 
 		if (current_event.type == SceneEvent::kCreditsMessage) {
@@ -609,7 +612,7 @@
 		
 		for (byte i = 0; i < 4; ++i) {
 			Animation *a = custom_animation + i;
-			Surface *s = a->currentFrame();
+			Surface *s = a->currentFrame(game_delta);
 			if (s != NULL) {
 				if (!a->ignore) 
 					busy = true;
@@ -622,7 +625,7 @@
 					custom_animation[i].free();
 					a->restart();
 				}
-				s = a->currentFrame();
+				s = a->currentFrame(game_delta);
 			}
 			
 			if (current_event.type == SceneEvent::kWaitLanAnimationFrame && current_event.slot == i) {
@@ -667,19 +670,29 @@
 			s->render(surface);
 		}
 
-		Surface *mark = actor_animation.currentFrame();
-		if (mark == NULL) {
-			if (!hide_actor) {
-				actor_animation.free();
-				uint zoom = lookupZoom(position.y);
+		Surface *mark = actor_animation.currentFrame(game_delta);
+		if (!hide_actor && mark == NULL) {
+			actor_animation.free();
+			uint zoom = lookupZoom(position.y);
 
-				if (!path.empty()) {
+			if (!path.empty()) {
+				const Common::Point &destination = path.front();
+				Common::Point dp(destination.x - position.x, destination.y - position.y);
+
+				int o;
+				if (ABS(dp.x) > ABS(dp.y))
+					o = dp.x > 0 ? kActorRight : kActorLeft;
+				else {
+					o = dp.y > 0 ? kActorDown : kActorUp;
+				}
+
+				if (tick_mark) {
 					int speed_x;
 					switch(teenagent.currentIndex()) {
 					case 6: 
 						speed_x = 10;
 						break;
-					case 8:
+					case 7:
 						speed_x = 1;
 						break;
 					default:
@@ -687,53 +700,44 @@
 						break;
 					}
 					speed_x = speed_x * zoom / 256;
-					int speed_y = 1 * zoom / 256;
+					int speed_y = (o == kActorDown || o == kActorUp? 2: 1) * zoom / 256;
 					if (speed_x == 0)
 						speed_x = 1;
 					if (speed_y == 0)
 						speed_y = 1;
-					
-					const Common::Point &destination = path.front();
-					Common::Point dp(destination.x - position.x, destination.y - position.y);
-
-					int o;
-					if (ABS(dp.x) > ABS(dp.y))
-						o = dp.x > 0 ? kActorRight : kActorLeft;
-					else {
-						o = dp.y > 0 ? kActorDown : kActorUp;
-						speed_y *= 2;
-					}
-
+				
 					position.y += (ABS(dp.y) < speed_y? dp.y: SIGN(dp.y) * speed_y);
 					position.x += (o == kActorDown || o == kActorUp)? 
 						(ABS(dp.x) < speed_y? dp.x: SIGN(dp.x) * speed_y):
 						(ABS(dp.x) < speed_x? dp.x: SIGN(dp.x) * speed_x);
+				}
+				
+				_idle_timer = 0;
+				teenagent_idle.resetIndex();
+				actor_animation_position = teenagent.render(surface, position, o, mark_delta, false, zoom);
 
-					_idle_timer = 0;
-					teenagent_idle.resetIndex();
-					actor_animation_position = teenagent.render(surface, position, o, 1, false, zoom);
-
-					if (position == destination) {
-						path.pop_front();
-						if (path.empty()) {
-							if (orientation == 0)
-								orientation = o; //save last orientation
-							nextEvent();
-							got_any_animation = true;
-							restart = true;
-						}
-						busy = true;
-					} else
-						busy = true;
-				} else {
-					++_idle_timer;
-					if (_idle_timer < 50)
-						actor_animation_position = teenagent.render(surface, position, orientation, 0, actor_talking, zoom);
-					else 
-						actor_animation_position = teenagent_idle.renderIdle(surface, position, orientation, zoom);
-				}
+				if (tick_mark && position == destination) {
+					path.pop_front();
+					if (path.empty()) {
+						if (orientation == 0)
+							orientation = o; //save last orientation
+						nextEvent();
+						got_any_animation = true;
+						restart = true;
+					}
+					busy = true;
+				} else
+					busy = true;
+			} else {
+				teenagent.resetIndex();
+				_idle_timer += mark_delta;
+				if (_idle_timer < 50)
+					actor_animation_position = teenagent.render(surface, position, orientation, 0, actor_talking, zoom);
+				else 
+					actor_animation_position = teenagent_idle.renderIdle(surface, position, orientation, mark_delta, zoom);
 			}
 		}
+
 		if (restart) {
 			_system->unlockScreen();
 			continue;
@@ -825,7 +829,7 @@
 			_engine->playSoundNow(sound.id);
 			i = sounds.erase(i);
 		} else {
-			--sound.delay;
+			sound.delay -= game_delta;
 			++i;
 		}
 	}
@@ -910,7 +914,7 @@
 						message_animation = &actor_animation;
 					debug(0, "async message %d-%d (slot %u)", message_first_frame, message_last_frame, current_event.slot);
 				} else {
-					message_timer = current_event.timer? current_event.timer: messageDuration(message);
+					message_timer = current_event.timer? current_event.timer * 110: messageDuration(message);
 					message_first_frame = message_last_frame = 0;
 				}
 				Common::Point p;
@@ -1141,7 +1145,7 @@
 	
 	uint delay = 60 + (total_width * delay_delta) / 8;
 	//debug(0, "delay = %u, delta: %u", delay, delay_delta);
-	return delay / 10;
+	return delay * 10;
 }
 
 

Modified: scummvm/trunk/engines/teenagent/scene.h
===================================================================
--- scummvm/trunk/engines/teenagent/scene.h	2010-01-05 22:02:04 UTC (rev 47055)
+++ scummvm/trunk/engines/teenagent/scene.h	2010-01-05 22:09:16 UTC (rev 47056)
@@ -127,7 +127,7 @@
 
 	void init(TeenAgentEngine *engine, OSystem *system);
 	void init(int id, const Common::Point &pos);
-	bool render();
+	bool render(bool tick_game, bool tick_mark, uint32 message_delta);
 	int getId() const { return _id; }
 
 	void warp(const Common::Point &point, byte orientation = 0);

Modified: scummvm/trunk/engines/teenagent/teenagent.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/teenagent.cpp	2010-01-05 22:02:04 UTC (rev 47055)
+++ scummvm/trunk/engines/teenagent/teenagent.cpp	2010-01-05 22:09:16 UTC (rev 47056)
@@ -518,18 +518,27 @@
 		uint32 delta = new_timer - timer;
 		timer = new_timer;
 
-		if (game_timer <= delta) {
-			bool b = scene->render();
+		bool tick_game = game_timer <= delta;
+		if (tick_game)
+			game_timer = kGameDelay - ((delta - game_timer) % kGameDelay);
+		else
+			game_timer -= delta;
+
+		bool tick_mark = mark_timer <= delta;
+		if (tick_mark)
+			mark_timer = kMarkDelay - ((delta - mark_timer) % kMarkDelay);
+		else
+			mark_timer -= delta;
+
+		if (tick_game || tick_mark) {
+			bool b = scene->render(tick_game, tick_mark, delta);
 			if (!inventory->active() && !b && action != kActionNone) {
 				processObject();
 				action = kActionNone;
 				dst_object = NULL;
 			}
-
 			scene_busy = b;
-			game_timer = kGameDelay - ((delta - game_timer) % kGameDelay);
-		} else
-			game_timer -= delta;
+		}
 
 		bool busy = inventory->active() || scene_busy;
 


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