From 90eabcc885c4854f143bfe637c4205a2d563e450 Mon Sep 17 00:00:00 2001 From: Vladimir Menshakov Date: Mon, 14 Sep 2009 21:07:01 +0000 Subject: rewrote dialog parser, fixed color swapping. svn-id: r44090 --- engines/teenagent/dialog.cpp | 75 +++++++++++++++++++++++++------------------- engines/teenagent/dialog.h | 4 +-- 2 files changed, 45 insertions(+), 34 deletions(-) (limited to 'engines/teenagent') diff --git a/engines/teenagent/dialog.cpp b/engines/teenagent/dialog.cpp index d686040422..3afeecdd85 100644 --- a/engines/teenagent/dialog.cpp +++ b/engines/teenagent/dialog.cpp @@ -28,8 +28,8 @@ namespace TeenAgent { -void Dialog::show(Scene * scene, uint16 addr, uint16 animation, uint16 actor_animation, byte color1, byte color2) { - debug(0, "Dialog::show(%04x, %u)", addr, animation); +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); Resources * res = Resources::instance(); int n = 0; Common::String message; @@ -37,49 +37,59 @@ void Dialog::show(Scene * scene, uint16 addr, uint16 animation, uint16 actor_ani while (n < 4) { byte c = res->eseg.get_byte(addr++); + //debug(0, "%02x: %c", c, c > 0x20? c: '.'); + switch(c) { case 0: ++n; - if (n == 3) { + switch(n) { + case 1: + //debug(0, "new line\n"); + message += '\n'; + break; + case 2: + //debug(0, "displaymessage\n"); + + if (color == color2 && animation2 != 0) { + SceneEvent e(SceneEvent::PlayAnimation); + e.animation = animation2; + e.color = 0x41; + scene->push(e); + } else if (color == color1 && animation1 != 0) { + SceneEvent e(SceneEvent::PlayAnimation); + e.animation = animation1; + e.color = 0x41; + scene->push(e); + } + + { + SceneEvent e(SceneEvent::Message); + e.message = message; + e.color = color; + scene->push(e); + message.clear(); + } + break; + + case 3: color = color == color1? color2: color1; - //debug(0, "changing color", message); + //debug(0, "changing color to %02x", color); + break; } - continue; + break; + case 0xff: { //fixme : wait for the next cycle of the animation } - continue; + break; + default: - if (n > 1) { - if (!message.empty()) { - if (animation != 0) { - SceneEvent e(SceneEvent::PlayAnimation); - e.animation = animation; - e.color = 0x41; - scene->push(e); - } - if (actor_animation != 0) { - SceneEvent e(SceneEvent::PlayAnimation); - e.animation = actor_animation; - e.color = 0x40; - scene->push(e); - } - SceneEvent e(SceneEvent::Message); - e.message = message; - e.color = color; - scene->push(e); - } - message = (const char *)Resources::instance()->eseg.ptr(addr - 1); - } else if (n == 1) { - message += '\n'; - message += (const char *)Resources::instance()->eseg.ptr(addr - 1); - } else if (n == 0 && message.empty()) { - message = (const char *)Resources::instance()->eseg.ptr(addr - 1); - } + message += c; n = 0; } } + /* if (!message.empty()) { if (animation != 0) { SceneEvent e(SceneEvent::PlayAnimation); @@ -92,6 +102,7 @@ void Dialog::show(Scene * scene, uint16 addr, uint16 animation, uint16 actor_ani e.color = color; scene->push(e); } + */ } uint16 Dialog::pop(Scene *scene, uint16 addr, uint16 animation, uint16 actor_animation, byte color1, byte color2) { diff --git a/engines/teenagent/dialog.h b/engines/teenagent/dialog.h index 65da1dcc74..98774916b4 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 animation = 0, uint16 actor_animation = 0, byte color1 = 0xd1, byte color2 = 0xd0); - static void show(Scene *scene, uint16 addr, uint16 animation = 0, uint16 actor_animation = 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); + static void show(Scene *scene, uint16 addr, uint16 animation1 = 0, uint16 animation2 = 0, byte color1 = 0xd1, byte color2 = 0xd0); }; } // End of namespace TeenAgent -- cgit v1.2.3