aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Menshakov2009-11-08 20:00:31 +0000
committerVladimir Menshakov2009-11-08 20:00:31 +0000
commit54d163c9661d86ab6d4364dde208e28ce42553d3 (patch)
tree01193e0c3f137309573c43a01818fffa6b2cb220
parentc1b1d42b8740f31cc0dbb1a11e934d6db9de08b5 (diff)
downloadscummvm-rg350-54d163c9661d86ab6d4364dde208e28ce42553d3.tar.gz
scummvm-rg350-54d163c9661d86ab6d4364dde208e28ce42553d3.tar.bz2
scummvm-rg350-54d163c9661d86ab6d4364dde208e28ce42553d3.zip
implemented async messages (some animation requires it), added custom positioning.
svn-id: r45756
-rw-r--r--engines/teenagent/callbacks.cpp37
-rw-r--r--engines/teenagent/dialog.cpp16
-rw-r--r--engines/teenagent/scene.cpp69
-rw-r--r--engines/teenagent/scene.h20
-rw-r--r--engines/teenagent/teenagent.cpp46
-rw-r--r--engines/teenagent/teenagent.h5
6 files changed, 126 insertions, 67 deletions
diff --git a/engines/teenagent/callbacks.cpp b/engines/teenagent/callbacks.cpp
index afde1a4421..f1ca7856c6 100644
--- a/engines/teenagent/callbacks.cpp
+++ b/engines/teenagent/callbacks.cpp
@@ -38,7 +38,7 @@ void TeenAgentEngine::rejectMessage() {
//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 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
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 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
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 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
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 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
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 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
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 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
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 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
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 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
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 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
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);
diff --git a/engines/teenagent/dialog.cpp b/engines/teenagent/dialog.cpp
index 8adbde4ba9..fc2573209a 100644
--- a/engines/teenagent/dialog.cpp
+++ b/engines/teenagent/dialog.cpp
@@ -40,14 +40,14 @@ void Dialog::show(Scene *scene, uint16 addr, uint16 animation1, uint16 animation
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 @@ void Dialog::show(Scene *scene, uint16 addr, uint16 animation1, uint16 animation
//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 @@ void Dialog::show(Scene *scene, uint16 addr, uint16 animation1, uint16 animation
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();
}
diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp
index 2b5d603001..c8f3947bad 100644
--- a/engines/teenagent/scene.cpp
+++ b/engines/teenagent/scene.cpp
@@ -36,7 +36,8 @@ namespace TeenAgent {
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 @@ bool Scene::processEvent(const Common::Event &event) {
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 @@ bool Scene::processEvent(const Common::Event &event) {
return true;
}
- if (!message.empty()) {
+ if (!message.empty() && message_first_frame == 0) {
clearMessage();
nextEvent();
return true;
@@ -399,7 +400,7 @@ bool Scene::render(OSystem *system) {
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 @@ bool Scene::render(OSystem *system) {
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 @@ bool Scene::render(OSystem *system) {
}
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 @@ bool Scene::processEventQueue() {
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 @@ bool Scene::processEventQueue() {
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 @@ bool Scene::processEventQueue() {
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 @@ void Scene::clearMessage() {
message.clear();
message_timer = 0;
message_color = 0xd1;
+ message_first_frame = 0;
+ message_last_frame = 0;
}
} // End of namespace TeenAgent
diff --git a/engines/teenagent/scene.h b/engines/teenagent/scene.h
index ac599679d4..0dd04f5893 100644
--- a/engines/teenagent/scene.h
+++ b/engines/teenagent/scene.h
@@ -60,24 +60,32 @@ struct SceneEvent {
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 @@ struct SceneEvent {
}
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 @@ private:
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;
diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp
index 9acb318314..29f942f25d 100644
--- a/engines/teenagent/teenagent.cpp
+++ b/engines/teenagent/teenagent.cpp
@@ -355,18 +355,6 @@ Common::Error TeenAgentEngine::run() {
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,9 +370,35 @@ Common::String TeenAgentEngine::parseMessage(uint16 addr) {
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;
+
+ scene->push(event);
+}
+
+void TeenAgentEngine::displayMessage(uint16 addr, byte color, uint16 position) {
+ displayMessage(parseMessage(addr), color, position);
+}
-void TeenAgentEngine::displayMessage(uint16 addr, byte color) {
- displayMessage(parseMessage(addr), color);
+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) {
@@ -455,7 +469,7 @@ void TeenAgentEngine::moveRel(int16 x, int16 y, byte o, bool warp) {
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 @@ void TeenAgentEngine::waitLanAnimationFrame(byte slot, uint16 frame) {
if (frame > 0)
--frame;
- event.color = slot - 1;
+ event.slot = slot - 1;
event.animation = frame;
scene->push(event);
}
diff --git a/engines/teenagent/teenagent.h b/engines/teenagent/teenagent.h
index 85cbc2418e..6623654334 100644
--- a/engines/teenagent/teenagent.h
+++ b/engines/teenagent/teenagent.h
@@ -66,8 +66,9 @@ public:
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);