diff options
author | Vladimir Menshakov | 2009-09-14 22:23:35 +0000 |
---|---|---|
committer | Vladimir Menshakov | 2009-09-14 22:23:35 +0000 |
commit | a13b03e4d9ed3e2147f4505bf514bbd81e7433fd (patch) | |
tree | 73edd93ebb0e8d77724e3e2e622ee7c21a052670 /engines/teenagent | |
parent | 90eabcc885c4854f143bfe637c4205a2d563e450 (diff) | |
download | scummvm-rg350-a13b03e4d9ed3e2147f4505bf514bbd81e7433fd.tar.gz scummvm-rg350-a13b03e4d9ed3e2147f4505bf514bbd81e7433fd.tar.bz2 scummvm-rg350-a13b03e4d9ed3e2147f4505bf514bbd81e7433fd.zip |
added PauseAnimation/ClearAnimations event, fixed dialogue animations in intro.
svn-id: r44091
Diffstat (limited to 'engines/teenagent')
-rw-r--r-- | engines/teenagent/animation.cpp | 19 | ||||
-rw-r--r-- | engines/teenagent/animation.h | 4 | ||||
-rw-r--r-- | engines/teenagent/callbacks.cpp | 7 | ||||
-rw-r--r-- | engines/teenagent/dialog.cpp | 60 | ||||
-rw-r--r-- | engines/teenagent/dialog.h | 4 | ||||
-rw-r--r-- | engines/teenagent/scene.cpp | 59 | ||||
-rw-r--r-- | engines/teenagent/scene.h | 4 |
7 files changed, 107 insertions, 50 deletions
diff --git a/engines/teenagent/animation.cpp b/engines/teenagent/animation.cpp index 5bd4f7bee9..794918de40 100644 --- a/engines/teenagent/animation.cpp +++ b/engines/teenagent/animation.cpp @@ -27,14 +27,26 @@ namespace TeenAgent { -Animation::Animation() : id(0), x(0), y(0), loop(true), data(0), data_size(0), frames_count(0), frames(0), index(0) { +Animation::Animation() : id(0), x(0), y(0), loop(true), paused(false), data(0), data_size(0), frames_count(0), frames(0), index(0) { } -Surface * Animation::firstFrame() const { - return frames; +Surface * Animation::firstFrame(){ + if (frames == NULL || frames_count == 0) + return NULL; + + Surface * r = frames; + uint16 pos = READ_LE_UINT16(data + 1); + if (pos != 0) { + r->x = pos % 320; + r->y = pos / 320; + } + return r; } Surface * Animation::currentFrame(int dt) { + if (paused) + return firstFrame(); + if (frames == NULL || frames_count == 0) return NULL; @@ -77,6 +89,7 @@ void Animation::free() { id = 0; x = y = 0; loop = true; + paused = false; delete[] data; data = NULL; diff --git a/engines/teenagent/animation.h b/engines/teenagent/animation.h index 4538bdbb7e..a5d7e25c7c 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; + bool loop, paused; enum Type {TypeLan, TypeVaria, TypeInventory}; @@ -41,7 +41,7 @@ public: void load(Common::SeekableReadStream * s, Type type = TypeLan); void free(); - Surface * firstFrame() const; + Surface * firstFrame(); Surface * currentFrame(int dt = 1); uint16 currentIndex() const { return index; } diff --git a/engines/teenagent/callbacks.cpp b/engines/teenagent/callbacks.cpp index 08577590f3..d6b771233e 100644 --- a/engines/teenagent/callbacks.cpp +++ b/engines/teenagent/callbacks.cpp @@ -90,6 +90,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) { case 0x024c: //intro hideActor(); + loadScene(41, 139, 156, 3); playSound(41, 12); playAnimation(912, 1); @@ -99,7 +100,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) { playAnimation(913, 1); setOns(1, 109); setLan(2, 1); - Dialog::show(scene, 0x748e, 914, 915, 0xe7, 0xd7); + Dialog::show(scene, 0x748e, 914, 915, 0xe7, 0xd7, 2, 1); displayCredits(0xe3c2); loadScene(42, 139, 156, 3); playSound(15, 20); @@ -113,7 +114,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) { playAnimation(917, 1, true); waitAnimation(); displayCredits(0xe3e6); - + loadScene(40, 139, 156, 3); playMusic(3); Dialog::show(scene, 0x750d, 920, 924, 0xe7, 0xeb); //as i told you, our organization... @@ -121,7 +122,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) { playAnimation(925, 0, true); playAnimation(926, 1, true); waitAnimation(); - Dialog::show(scene, 0x78a6, 927, 920, 0xeb, 0xeb); + Dialog::show(scene, 0x78a6, 920, 927, 0xeb, 0xeb); displayCredits(0xe3ff); loadScene(39, 139, 156, 3); diff --git a/engines/teenagent/dialog.cpp b/engines/teenagent/dialog.cpp index 3afeecdd85..3102266c10 100644 --- a/engines/teenagent/dialog.cpp +++ b/engines/teenagent/dialog.cpp @@ -28,13 +28,29 @@ namespace TeenAgent { -void Dialog::show(Scene * scene, uint16 addr, uint16 animation1, uint16 animation2, byte color1, byte color2) { - debug(0, "Dialog::show(%04x, %u, %u)", addr, animation1, animation2); +void Dialog::show(Scene * scene, uint16 addr, uint16 animation1, uint16 animation2, byte color1, byte color2, byte slot1, byte slot2) { + --slot1; + --slot2; + debug(0, "Dialog::pop(%04x, %u:%u, %u:%u)", addr, slot1, animation1, slot2, animation2); Resources * res = Resources::instance(); int n = 0; Common::String message; byte color = color1; + if (animation1 != 0) { + SceneEvent e(SceneEvent::PlayAnimation); + e.animation = animation1; + e.color = 0xc0 | slot1; //looped, paused + scene->push(e); + } + + if (animation2 != 0) { + SceneEvent e(SceneEvent::PlayAnimation); + e.animation = animation2; + e.color = 0xc0 | slot2; //looped, paused + scene->push(e); + } + while (n < 4) { byte c = res->eseg.get_byte(addr++); //debug(0, "%02x: %c", c, c > 0x20? c: '.'); @@ -51,15 +67,31 @@ void Dialog::show(Scene * scene, uint16 addr, uint16 animation1, uint16 animatio //debug(0, "displaymessage\n"); if (color == color2 && animation2 != 0) { - SceneEvent e(SceneEvent::PlayAnimation); - e.animation = animation2; - e.color = 0x41; - scene->push(e); + //pause animation in other slot + { + SceneEvent e(SceneEvent::PauseAnimation); + e.color = 0x80 | slot1; + scene->push(e); + } + { + SceneEvent e(SceneEvent::PlayAnimation); + e.animation = animation2; + e.color = 0x80 | slot2; + scene->push(e); + } } else if (color == color1 && animation1 != 0) { - SceneEvent e(SceneEvent::PlayAnimation); - e.animation = animation1; - e.color = 0x41; - scene->push(e); + //pause animation in other slot + { + SceneEvent e(SceneEvent::PauseAnimation); + e.color = 0x80 | slot2; + scene->push(e); + } + { + SceneEvent e(SceneEvent::PlayAnimation); + e.animation = animation1; + e.color = 0x80 | slot1; + scene->push(e); + } } { @@ -103,10 +135,12 @@ void Dialog::show(Scene * scene, uint16 addr, uint16 animation1, uint16 animatio scene->push(e); } */ + SceneEvent e(SceneEvent::ClearAnimations); + scene->push(e); } -uint16 Dialog::pop(Scene *scene, uint16 addr, uint16 animation, uint16 actor_animation, byte color1, byte color2) { - debug(0, "Dialog::pop(%04x, %u)", addr, animation); +uint16 Dialog::pop(Scene *scene, uint16 addr, uint16 animation1, uint16 animation2, byte color1, byte color2, byte slot1, byte slot2) { + debug(0, "Dialog::pop(%04x, %u:%u, %u:%u)", addr, slot1, animation1, slot2, animation2); Resources * res = Resources::instance(); uint16 next; do { @@ -116,7 +150,7 @@ uint16 Dialog::pop(Scene *scene, uint16 addr, uint16 animation, uint16 actor_ani uint16 next2 = res->dseg.get_word(addr); if (next2 != 0xffff) res->dseg.set_word(addr - 2, 0); - show(scene, next, animation, actor_animation, color1, color2); + show(scene, next, animation1, animation2, color1, color2, slot1, slot2); return next; } diff --git a/engines/teenagent/dialog.h b/engines/teenagent/dialog.h index 98774916b4..c1ef1d89b4 100644 --- a/engines/teenagent/dialog.h +++ b/engines/teenagent/dialog.h @@ -33,8 +33,8 @@ namespace TeenAgent { class Scene; class Dialog { public: - static uint16 pop(Scene *scene, uint16 addr, uint16 animation1 = 0, uint16 animation2 = 0, byte color1 = 0xd1, byte color2 = 0xd0); - static void show(Scene *scene, uint16 addr, uint16 animation1 = 0, uint16 animation2 = 0, byte color1 = 0xd1, byte color2 = 0xd0); + static uint16 pop(Scene *scene, uint16 addr, uint16 animation1 = 0, uint16 animation2 = 0, byte color1 = 0xd1, byte color2 = 0xd0, byte slot1 = 1, byte slot2 = 2); + static void show(Scene *scene, uint16 addr, uint16 animation1 = 0, uint16 animation2 = 0, byte color1 = 0xd1, byte color2 = 0xd0, byte slot1 = 1, byte slot2 = 2); }; } // End of namespace TeenAgent diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp index f7e1751f60..1d6830199f 100644 --- a/engines/teenagent/scene.cpp +++ b/engines/teenagent/scene.cpp @@ -230,7 +230,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) { +void Scene::playAnimation(byte idx, uint id, bool loop, bool paused) { assert(idx < 4); Common::SeekableReadStream * s = Resources::instance()->loadLan(id + 1); if (s == NULL) @@ -238,6 +238,7 @@ void Scene::playAnimation(byte idx, uint id, bool loop) { custom_animations[idx].load(s); custom_animations[idx].loop = loop; + custom_animations[idx].paused = paused; } void Scene::playActorAnimation(uint id, bool loop) { @@ -261,10 +262,6 @@ bool Scene::processEvent(const Common::Event &event) { case Common::EVENT_RBUTTONDOWN: if (!message.empty()) { message.clear(); - for(int i = 0; i < 4; ++i) { - if (custom_animations[i].loop) - custom_animations[i].free(); - } nextEvent(); return true; } @@ -482,49 +479,61 @@ bool Scene::processEventQueue() { message = current_event.message; message_pos = messagePosition(message, position); message_color = current_event.color; - break; + break; - case SceneEvent::PlayAnimation: { + case SceneEvent::PlayAnimation: debug(0, "playing animation %u", current_event.animation); - playAnimation(current_event.color & 0x3 /*slot actually :)*/, current_event.animation, (current_event.color & 0x40) != 0); + playAnimation(current_event.color & 0x3 /*slot actually :)*/, current_event.animation, (current_event.color & 0x80) != 0, (current_event.color & 0x40) != 0); current_event.clear(); - } break; + break; - case SceneEvent::PlayActorAnimation: { - debug(0, "playing actor animation %u", current_event.animation); - playActorAnimation(current_event.animation, (current_event.color & 0x40) != 0); + case SceneEvent::PauseAnimation: + debug(0, "pause animation in slot %u", current_event.color & 3); + custom_animations[current_event.color & 3].paused = (current_event.color & 0x80) != 0; current_event.clear(); - } break; + break; + + case SceneEvent::ClearAnimations: + for(byte i = 0; i < 4; ++i) + custom_animations[i].free(); + current_event.clear(); + break; - case SceneEvent::PlayMusic: { + case SceneEvent::PlayActorAnimation: + debug(0, "playing actor animation %u", current_event.animation); + playActorAnimation(current_event.animation, (current_event.color & 0x80) != 0); + current_event.clear(); + break; + + case SceneEvent::PlayMusic: debug(0, "setting music %u", current_event.music); _engine->setMusic(current_event.music); Resources::instance()->dseg.set_byte(0xDB90, current_event.music); current_event.clear(); - } break; + break; - case SceneEvent::PlaySound: { + case SceneEvent::PlaySound: debug(0, "playing sound %u, delay: %u", current_event.sound, current_event.color); if (current_event.color == 0) { _engine->playSoundNow(current_event.sound); } else { sounds.push_back(Sound(current_event.sound, current_event.color)); } - current_event.clear(); - } break; + break; case SceneEvent::EnableObject: { - debug(0, "%s object #%u", current_event.color?"enabling":"disabling", current_event.object - 1); - Object * obj = getObject(current_event.object - 1, current_event.scene == 0? _id: current_event.scene); - obj->enabled = current_event.color; - current_event.clear(); - } break; + debug(0, "%s object #%u", current_event.color?"enabling":"disabling", current_event.object - 1); + Object * obj = getObject(current_event.object - 1, current_event.scene == 0? _id: current_event.scene); + obj->enabled = current_event.color; + current_event.clear(); + } + break; - case SceneEvent::HideActor: { + case SceneEvent::HideActor: hide_actor = current_event.color != 0; current_event.clear(); - } break; + break; case SceneEvent::WaitForAnimation: debug(0, "waiting for the animation"); diff --git a/engines/teenagent/scene.h b/engines/teenagent/scene.h index 01b6164785..081b01c6fe 100644 --- a/engines/teenagent/scene.h +++ b/engines/teenagent/scene.h @@ -40,7 +40,7 @@ class Dialog; struct SceneEvent { enum Type { - None, Message, Walk, PlayAnimation, PlayActorAnimation, + None, Message, Walk, PlayAnimation, PlayActorAnimation, PauseAnimation, ClearAnimations, LoadScene, SetOn, SetLan, PlayMusic, PlaySound, EnableObject, HideActor, WaitForAnimation, CreditsMessage, @@ -125,7 +125,7 @@ private: void loadOns(); void loadLans(); - void playAnimation(byte idx, uint id, bool loop); + void playAnimation(byte idx, uint id, bool loop, bool paused); void playActorAnimation(uint id, bool loop); byte palette[768]; |