From ea0b2a8cb8e1e23c62442f248c5b6551469e8db8 Mon Sep 17 00:00:00 2001 From: Vladimir Menshakov Date: Sun, 8 Nov 2009 22:37:03 +0000 Subject: implemented mouse-rock-glue time challenge svn-id: r45767 --- engines/teenagent/callbacks.cpp | 83 +++++++++++++++++++++++++++-------------- engines/teenagent/inventory.cpp | 5 ++- engines/teenagent/objects.h | 2 +- engines/teenagent/scene.cpp | 20 +++++++++- engines/teenagent/scene.h | 2 + engines/teenagent/teenagent.cpp | 13 +++++++ 6 files changed, 93 insertions(+), 32 deletions(-) (limited to 'engines') diff --git a/engines/teenagent/callbacks.cpp b/engines/teenagent/callbacks.cpp index 53fa80517f..e5ba6472dc 100644 --- a/engines/teenagent/callbacks.cpp +++ b/engines/teenagent/callbacks.cpp @@ -2710,35 +2710,62 @@ bool TeenAgentEngine::processCallback(uint16 addr) { scene->getObject(3)->save(); return true; - case 0x8d57: - playSound(5, 2); - playSound(15, 12); - playActorAnimation(638); - inventory->remove(48); - //fixme: add time challenge here! + case 0x8d79: //mouse falls back from the hole (cave) + if (CHECK_FLAG(0, 1)) { + inventory->add(48); + playSound(24, 26); + playActorAnimation(650, true); + playAnimation(651, 2, true); + waitAnimation(); + } else { + playSound(27, 5); + setOns(1, 0); + playActorAnimation(652); + playSound(24, 4); + playSound(5, 12); + moveTo(186, 179, 1, true); + playActorAnimation(653); + playActorAnimation(654, true); + playAnimation(655, 2, true); + waitAnimation(); + displayMessage(0x3bf6); + inventory->add(49); + setLan(2, 4, 27); + enableObject(4, 27); + SET_FLAG(0xdba9, 0); + } + SET_FLAG(0, 0); + return true; - /* - inventory->add(48); - playSound(24, 26); - playActorAnimation(650, true); - playAnimation(651, 2, true); - waitAnimation(); - */ - playSound(5, 2); - playSound(52, 13); - setOns(1, 46); - inventory->remove(49); - - //third part - playActorAnimation(649); - setOns(1, 47); - for (byte i = 1; i <= 37; i += 4) - playSound(68, i); - playAnimation(639, 2); - setOns(0, 42); - enableObject(6); - disableObject(5); - SET_FLAG(0xDBAB, 1); + case 0x8d57: + if (CHECK_FLAG(0, 0)) { + playSound(5, 2); + playSound(15, 12); + playActorAnimation(638); + inventory->remove(48); + setTimerCallback(0x8d79, 100); + SET_FLAG(0, 1); + } else if (CHECK_FLAG(0, 1)) { + playSound(5, 2); + playSound(52, 13); + playActorAnimation(648); + setOns(1, 46); + inventory->remove(49); + setTimerCallback(0x8d79, 100); + SET_FLAG(0, 2); + } else if (CHECK_FLAG(0, 2)) { + playActorAnimation(649); + setOns(1, 47); + for (byte i = 1; i <= 37; i += 4) + playSound(68, i); + playAnimation(639, 2); + setOns(0, 42); + enableObject(6); + disableObject(5); + SET_FLAG(0xDBAB, 1); + SET_FLAG(0, 0); + setTimerCallback(0, 0); + } return true; case 0x8f1d: diff --git a/engines/teenagent/inventory.cpp b/engines/teenagent/inventory.cpp index fb3c937932..70e58d5b24 100644 --- a/engines/teenagent/inventory.cpp +++ b/engines/teenagent/inventory.cpp @@ -164,7 +164,7 @@ bool Inventory::processEvent(const Common::Event &event) { int id1 = selected_obj->id; int id2 = hovered_obj->id; - debug(0, "combine(0x%02x, 0x%02x)!", id1, id2); + debug(0, "combine(%u, %u)!", id1, id2); byte *table = res->dseg.ptr(0xC335); while (table[0] != 0 && table[1] != 0) { if ( @@ -173,10 +173,11 @@ bool Inventory::processEvent(const Common::Event &event) { ) { remove(id1); remove(id2); + debug(0, "adding object %u", table[2]); add(table[2]); uint16 msg = READ_LE_UINT16(table + 3); - _engine->displayMessage(msg); _engine->playSoundNow(69); + _engine->displayMessage(msg); activate(false); resetSelectedObject(); return true; diff --git a/engines/teenagent/objects.h b/engines/teenagent/objects.h index 78a41df6a9..1cba0391cf 100644 --- a/engines/teenagent/objects.h +++ b/engines/teenagent/objects.h @@ -113,7 +113,7 @@ protected: struct UseHotspot { byte inventory_id; byte object_id; - byte orientation; //? + byte orientation; uint16 actor_x, actor_y; uint16 callback; void load(byte *src); diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp index 23644f16f6..bad567943a 100644 --- a/engines/teenagent/scene.cpp +++ b/engines/teenagent/scene.cpp @@ -38,7 +38,7 @@ Scene::Scene() : intro(false), _engine(NULL), _id(0), ons(0), orientation(Object::kActorRight), message_timer(0), message_first_frame(0), message_last_frame(0), - current_event(SceneEvent::kNone), hide_actor(false) {} + current_event(SceneEvent::kNone), hide_actor(false), callback(0), callback_timer(0) {} void Scene::warp(const Common::Point &_point, byte o) { Common::Point point(_point); @@ -500,6 +500,15 @@ bool Scene::render(OSystem *system) { busy = true; } } + + if (!busy && callback_timer) { + if (--callback_timer == 0) { + if (_engine->inventory->active()) + _engine->inventory->activate(false); + _engine->processCallback(callback); + callback = 0; + } + } system->unlockScreen(); @@ -680,6 +689,13 @@ bool Scene::processEventQueue() { case SceneEvent::kWaitLanAnimationFrame: debug(0, "waiting for the frame %d in slot %d", current_event.animation, current_event.slot); break; + + case SceneEvent::kTimer: + callback = current_event.callback; + callback_timer = current_event.timer; + debug(0, "triggering callback %04x in %u frames", callback, callback_timer); + current_event.clear(); + break; case SceneEvent::kQuit: debug(0, "quit!"); @@ -772,6 +788,8 @@ void Scene::clear() { animation[i].free(); custom_animation[i].free(); } + callback = 0; + callback_timer = 0; } void Scene::clearMessage() { diff --git a/engines/teenagent/scene.h b/engines/teenagent/scene.h index 411cbb9477..fe886f8c80 100644 --- a/engines/teenagent/scene.h +++ b/engines/teenagent/scene.h @@ -197,6 +197,8 @@ private: EventList events; SceneEvent current_event; bool hide_actor; + + uint16 callback, callback_timer; struct Sound { byte id, delay; diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp index 39b60289a5..67a0a42d5d 100644 --- a/engines/teenagent/teenagent.cpp +++ b/engines/teenagent/teenagent.cpp @@ -63,6 +63,19 @@ void TeenAgentEngine::processObject() { case kActionUse: { InventoryObject *inv = inventory->selectedObject(); if (inv != NULL) { + debug(0, "checking active object %u on %u", inv->id, dst_object->id); + + //mouse time challenge hack: + if ( + (res->dseg.get_byte(0) == 1 && inv->id == 49 && dst_object->id == 5) || + (res->dseg.get_byte(0) == 2 && inv->id == 29 && dst_object->id == 5) + ) { + //putting rock into hole or superglue on rock + processCallback(0x8d57); + return; + } + + const Common::Array &hotspots = use_hotspots[scene->getId() - 1]; for (uint i = 0; i < hotspots.size(); ++i) { const UseHotspot &spot = hotspots[i]; -- cgit v1.2.3