aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorVladimir Menshakov2009-11-09 07:58:27 +0000
committerVladimir Menshakov2009-11-09 07:58:27 +0000
commitdfc4dc6d85e5da9590e4647284fbc2c133f76fc9 (patch)
tree7e93cfcd3caa10d7476ad0b63e3d69a3c783f4eb /engines
parented348133d172ff8a2729b664f9d228b6b6da13d2 (diff)
downloadscummvm-rg350-dfc4dc6d85e5da9590e4647284fbc2c133f76fc9.tar.gz
scummvm-rg350-dfc4dc6d85e5da9590e4647284fbc2c133f76fc9.tar.bz2
scummvm-rg350-dfc4dc6d85e5da9590e4647284fbc2c133f76fc9.zip
added 'ignore' flag, ported guard and anchor challenges to it. minor fixes
svn-id: r45772
Diffstat (limited to 'engines')
-rw-r--r--engines/teenagent/animation.cpp4
-rw-r--r--engines/teenagent/animation.h2
-rw-r--r--engines/teenagent/callbacks.cpp106
-rw-r--r--engines/teenagent/scene.cpp32
-rw-r--r--engines/teenagent/scene.h7
-rw-r--r--engines/teenagent/teenagent.cpp22
-rw-r--r--engines/teenagent/teenagent.h4
7 files changed, 114 insertions, 63 deletions
diff --git a/engines/teenagent/animation.cpp b/engines/teenagent/animation.cpp
index ee7e05cbd3..33037959b6 100644
--- a/engines/teenagent/animation.cpp
+++ b/engines/teenagent/animation.cpp
@@ -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 @@ Surface *Animation::currentFrame(int dt) {
void Animation::restart() {
paused = false;
+ ignore = false;
index = 0;
}
@@ -94,6 +95,7 @@ void Animation::free() {
x = y = 0;
loop = true;
paused = false;
+ ignore = false;
delete[] data;
data = NULL;
diff --git a/engines/teenagent/animation.h b/engines/teenagent/animation.h
index 5936905b5c..3e65a73b94 100644
--- a/engines/teenagent/animation.h
+++ b/engines/teenagent/animation.h
@@ -33,7 +33,7 @@ namespace TeenAgent {
class Animation {
public:
uint16 id, x, y;
- bool loop, paused;
+ bool loop, paused, ignore;
enum Type {kTypeLan, kTypeVaria, kTypeInventory};
diff --git a/engines/teenagent/callbacks.cpp b/engines/teenagent/callbacks.cpp
index 3ef25dc67f..256e823053 100644
--- a/engines/teenagent/callbacks.cpp
+++ b/engines/teenagent/callbacks.cpp
@@ -32,6 +32,7 @@ namespace TeenAgent {
#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 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
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 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
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 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
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 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
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 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
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 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
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 @@ bool TeenAgentEngine::processCallback(uint16 addr) {
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);
diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp
index a7f3ae0919..f6473681ec 100644
--- a/engines/teenagent/scene.cpp
+++ b/engines/teenagent/scene.cpp
@@ -274,7 +274,7 @@ void Scene::init(int id, const Common::Point &pos) {
_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 @@ void Scene::playAnimation(byte idx, uint id, bool loop, bool paused) {
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 @@ bool Scene::render(OSystem *system) {
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 @@ bool Scene::render(OSystem *system) {
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 Scene::render(OSystem *system) {
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 @@ bool Scene::render(OSystem *system) {
if (_engine->inventory->active())
_engine->inventory->activate(false);
_engine->processCallback(callback);
- callback = 0;
}
}
@@ -655,7 +657,7 @@ bool Scene::processEventQueue() {
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 @@ bool Scene::processEventQueue() {
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;
diff --git a/engines/teenagent/scene.h b/engines/teenagent/scene.h
index 7ca7c48b11..897b883fae 100644
--- a/engines/teenagent/scene.h
+++ b/engines/teenagent/scene.h
@@ -148,14 +148,15 @@ public:
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);
diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp
index 03c8018ef4..3a5db2df94 100644
--- a/engines/teenagent/teenagent.cpp
+++ b/engines/teenagent/teenagent.cpp
@@ -300,15 +300,20 @@ Common::Error TeenAgentEngine::run() {
}
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 @@ void TeenAgentEngine::moveRel(int16 x, int16 y, byte o, bool warp) {
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();
diff --git a/engines/teenagent/teenagent.h b/engines/teenagent/teenagent.h
index 36ae9ba57b..b357b75509 100644
--- a/engines/teenagent/teenagent.h
+++ b/engines/teenagent/teenagent.h
@@ -76,8 +76,8 @@ public:
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);