diff options
-rw-r--r-- | scumm/actor.cpp | 17 | ||||
-rw-r--r-- | scumm/actor.h | 1 | ||||
-rw-r--r-- | scumm/sound.cpp | 4 | ||||
-rw-r--r-- | scumm/string.cpp | 19 |
4 files changed, 22 insertions, 19 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp index 095b8535cc..90bfff0c86 100644 --- a/scumm/actor.cpp +++ b/scumm/actor.cpp @@ -1192,7 +1192,7 @@ void ScummEngine::actorTalk(const byte *msg) { stopTalk(); setTalkingActor(a->number); if (!_string[0].no_talk_anim) { - a->startAnimActor(a->talkStartFrame); + a->runActorTalkScript(a->talkStartFrame); _useTalkAnims = true; } oldact = getTalkingActor(); @@ -1216,6 +1216,19 @@ void ScummEngine::actorTalk(const byte *msg) { CHARSET_1(); } +void Actor::runActorTalkScript(int f) { + if (talkScript) { + int script = talkScript; + int args[16]; + memset(args, 0, sizeof(args)); + args[1] = f; + args[0] = number; + + _vm->runScript(script, 1, 0, args); + } else + startAnimActor(f); +} + void ScummEngine::stopTalk() { int act; @@ -1228,7 +1241,7 @@ void ScummEngine::stopTalk() { if (act && act < 0x80) { Actor *a = derefActor(act, "stopTalk"); if ((a->isInCurrentRoom() && _useTalkAnims) || (_features & GF_NEW_COSTUMES)) { - a->startAnimActor(a->talkStopFrame); + a->runActorTalkScript(a->talkStopFrame); _useTalkAnims = false; } if (!(_features & GF_HUMONGOUS)) diff --git a/scumm/actor.h b/scumm/actor.h index ba766f8263..6e822e82cb 100644 --- a/scumm/actor.h +++ b/scumm/actor.h @@ -166,6 +166,7 @@ public: protected: void startWalkAnim(int cmd, int angle); public: + void runActorTalkScript(int f); void startAnimActor(int frame); void remapActorPalette(int r_fact, int g_fact, int b_fact, int threshold); diff --git a/scumm/sound.cpp b/scumm/sound.cpp index aff38e969c..7b788fe81e 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -522,10 +522,10 @@ void Sound::processSfxQueues() { if (_mouthSyncMode != b) { _mouthSyncMode = b; if (_talk_sound_frame != -1) { - a->startAnimActor(_talk_sound_frame); + a->runActorTalkScript(_talk_sound_frame); _talk_sound_frame = -1; } else - a->startAnimActor(b ? a->talkStopFrame : a->talkStartFrame); + a->runActorTalkScript(b ? a->talkStopFrame : a->talkStartFrame); } } } diff --git a/scumm/string.cpp b/scumm/string.cpp index e6fec42994..70b3cb0aa6 100644 --- a/scumm/string.cpp +++ b/scumm/string.cpp @@ -80,8 +80,6 @@ void ScummEngine::CHARSET_1() { int frme = -1; Actor *a; byte *buffer; - bool has_talk_sound = false; - bool has_anim = false; if (!_haveMsg) return; @@ -152,7 +150,7 @@ void ScummEngine::CHARSET_1() { } if (a && !_string[0].no_talk_anim) { - has_anim = true; + a->runActorTalkScript(a->talkStartFrame); _useTalkAnims = true; } @@ -230,14 +228,15 @@ void ScummEngine::CHARSET_1() { case 9: frme = *buffer++; frme |= *buffer++ << 8; - has_anim = true; + a->startAnimActor(frme != -1 ? frme : a->talkStartFrame); break; case 10: talk_sound_a = buffer[0] | (buffer[1] << 8) | (buffer[4] << 16) | (buffer[5] << 24); talk_sound_b = buffer[8] | (buffer[9] << 8) | (buffer[12] << 16) | (buffer[13] << 24); - has_talk_sound = true; buffer += 14; + _sound->talkSound(talk_sound_a, talk_sound_b, 2, frme); + // Set flag that speech variant exist of this msg. // TODO: This does not work for the speech system in V7+ games // since they encode the voice information differently, and it @@ -303,16 +302,6 @@ void ScummEngine::CHARSET_1() { } } while (c != 2 && c != 3); - // Even if talkSound() is called, we may still have to call - // startAnimActor() since actorTalk() may already have caused the - // wrong animation frame to be drawn, and the talkSound() won't be - // processed until after the next screen update. Bleah. - - if (has_talk_sound) - _sound->talkSound(talk_sound_a, talk_sound_b, 2, frme); - if (a && has_anim) - a->startAnimActor(frme != -1 ? frme : a->talkStartFrame); - _charsetBufPos = buffer - _charsetBuffer; // FIXME: Remove this and the next two lines eventually! |