From e6d2ed3ca8f06a9d6b5b37d3015eb53d5bbf772c Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 2 Jun 2008 10:58:45 +0000 Subject: Further cleanup of the talk code svn-id: r32494 --- engines/drascula/animation.cpp | 62 ++++---- engines/drascula/drascula.h | 21 +-- engines/drascula/rooms.cpp | 8 +- engines/drascula/talk.cpp | 330 ++++++++++++++--------------------------- 4 files changed, 146 insertions(+), 275 deletions(-) (limited to 'engines') diff --git a/engines/drascula/animation.cpp b/engines/drascula/animation.cpp index b19aec0fae..37c1f20e2a 100644 --- a/engines/drascula/animation.cpp +++ b/engines/drascula/animation.cpp @@ -176,7 +176,7 @@ void DrasculaEngine::animation_1_1() { break; copyBackground(0, 0, 0, 0, 320, 200, screenSurface, drawSurface1); - talk_dr_grande(_textd[_lang][1], "D1.als"); + talk_dr_grande(1); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; @@ -196,7 +196,7 @@ void DrasculaEngine::animation_1_1() { placeIgor(); placeDrascula(); updateScreen(); - talk_igor_dch(8); + talk_igor(8, 0); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; copyBackground(0, 0, 0, 0, 320, 200, drawSurface1, screenSurface); @@ -257,13 +257,13 @@ void DrasculaEngine::animation_1_1() { stopMusic(); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; - talk_igor_dch(9); + talk_igor(9, 0); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; talk_drascula(9); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; - talk_igor_dch(10); + talk_igor(10, 0); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; playMusic(11); @@ -289,7 +289,7 @@ void DrasculaEngine::animation_1_1() { if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; sentido_dr = 1; - talk_igor_dch(1); + talk_igor(1, 0); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; talk_drascula(11, 1); @@ -320,7 +320,7 @@ void DrasculaEngine::animation_1_1() { placeIgor(); placeDrascula(); updateScreen(); - talk_igor_dch(2); + talk_igor(2, 0); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; pause(13); @@ -341,19 +341,19 @@ void DrasculaEngine::animation_1_1() { talk_drascula(14); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; - talk_igor_dch(3); + talk_igor(3, 0); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; talk_drascula(15); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; - talk_igor_dch(4); + talk_igor(4, 0); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; talk_drascula(16); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; - talk_igor_dch(5); + talk_igor(5, 0); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; sentido_igor = 3; @@ -363,7 +363,7 @@ void DrasculaEngine::animation_1_1() { pause(18); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; - talk_igor_front(6); + talk_igor(6, 1); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; fadeToBlack(0); @@ -651,13 +651,13 @@ void DrasculaEngine::animation_4_1() { stopMusic(); flags[11] = 1; - talk_pianist(_textp[_lang][1], "p1.als"); + talk_pianist(1); talk(206); - talk_pianist(_textp[_lang][2], "p2.als"); + talk_pianist(2); talk(207); - talk_pianist(_textp[_lang][3], "p3.als"); + talk_pianist(3); talk(208); - talk_pianist(_textp[_lang][4], "p4.als"); + talk_pianist(4); talk(209); if (_lang == kSpanish) @@ -1449,26 +1449,26 @@ void DrasculaEngine::animation_rayo() { } void DrasculaEngine::animation_2_4() { - talk_igor_seated(16); + talk_igor(16, 3); talk(278); - talk_igor_seated(17); + talk_igor(17, 3); talk(279); - talk_igor_seated(18); + talk_igor(18, 3); } void DrasculaEngine::animation_3_4() { - talk_igor_seated(19); - talk_igor_seated(20); + talk_igor(19, 3); + talk_igor(20, 3); talk(281); } void DrasculaEngine::animation_4_4() { talk(287); - talk_igor_seated(21); + talk_igor(21, 3); talk(284); - talk_igor_seated(22); + talk_igor(22, 3); talk(285); - talk_igor_seated(23); + talk_igor(23, 3); } void DrasculaEngine::animation_7_4() { @@ -1928,10 +1928,10 @@ void DrasculaEngine::animation_1_6() { talk_drascula(31, 1); animation_5_6(); talk_drascula(32, 1); - talk_igor_dch(11); + talk_igor(11, 0); sentido_igor = 3; talk_drascula(33, 1); - talk_igor_front(12); + talk_igor(12, 1); talk_drascula(34, 1); sentido_dr = 0; talk_drascula(35); @@ -2630,9 +2630,9 @@ void DrasculaEngine::animation_1_4() { flags[18] = 1; flags[20] = 1; - talk_igor_seated(13); - talk_igor_seated(14); - talk_igor_seated(15); + talk_igor(13, 3); + talk_igor(14, 3); + talk_igor(15, 3); flags[21] = 1; } else { talk(356); @@ -2655,7 +2655,7 @@ void DrasculaEngine::animation_1_4() { talk(276); pause(14); - talk_igor_seated(6); + talk_igor(6, 3); } converse("op_6.cal"); @@ -2682,8 +2682,8 @@ void DrasculaEngine::animation_5_4(){ loadPic("auxigor.alg", frontSurface, 1); igorX = 100; igorY = 65; - talk_igor_front(29); - talk_igor_front(30); + talk_igor(29, 1); + talk_igor(30, 1); loadPic("96.alg", frontSurface, 1); loadPic("99.alg", backSurface, 1); hare_se_ve = 1; @@ -2706,7 +2706,7 @@ void DrasculaEngine::animation_6_4() { placeIgor(); updateScreen(); pause(40); - talk_igor_front(26); + talk_igor(26, 1); roomNumber = prevRoom; clearRoom(); loadPic("96.alg", frontSurface, 1); diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index e98cad2a6c..366ef620a3 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -420,40 +420,25 @@ public: void talkInit(const char *filename); bool isTalkFinished(int* length); - void talk_igor_dch(int); + void talk_igor(int, int); void talk_drascula(int index, int talkerType = 0); void talk_solo(const char *, const char *); - void talk_igor_front(int); void talk_bartender(int, int talkerType = 0); - void talk_igor_door(int); - void talk_igor_door(const char *said, const char *filename); - void talk_igor_wig(int); - void talk_igor_wig(const char *said, const char *filename); void talk_pen(const char *, const char *, int); void talk_bj_bed(int); - void talk_bj_bed(const char *said, const char * filename); void talk_htel(int); - void talk_htel(const char *said, const char *filename); void talk_bj(int); - void talk_baul(const char *said, const char *filename); + void talk_baul(int); void talk(int); void talk(const char *, const char *); void talk_sinc(const char *, const char *, const char *); void talk_drunk(int); - void talk_drunk(const char *said, const char *filename); void talk_pianist(int); - void talk_pianist(const char *said, const char *filename); - void talk_igor_seated(int); - void talk_igor_seated(const char *, const char *); void talk_wolf(int); - void talk_wolf(const char *said, const char *filename); void talk_mus(int); - void talk_mus(const char *said, const char *filename); - void talk_dr_grande(const char *said, const char *filename); + void talk_dr_grande(int); void talk_vb(int); - void talk_vb(const char *, const char *); void talk_vbpuerta(int); - void talk_vbpuerta(const char *said, const char *filename); void talk_blind(int); void talk_hacker(const char *, const char *); diff --git a/engines/drascula/rooms.cpp b/engines/drascula/rooms.cpp index 0a65ffb23d..055801a24d 100644 --- a/engines/drascula/rooms.cpp +++ b/engines/drascula/rooms.cpp @@ -373,7 +373,7 @@ void DrasculaEngine::room_16(int fl) { pause(10); talk_sinc(_text[_lang][50], "50.als", "11111111111144432554433"); pause(3); - talk_baul(_text[_lang][83], "d83.als"); + talk_baul(83); } else if (pickedObject == kVerbOpen && fl == 183) { openDoor(19, NO_DOOR); if (flags[20] == 0) { @@ -600,16 +600,16 @@ void DrasculaEngine::room_26(int fl) { flags[12] = 1; closeDoor(2, 0); sentido_hare = 2; - talk_igor_door(27); + talk_igor(27, 2); flags[30] = 1; - talk_igor_door(28); + talk_igor(28, 2); lleva_al_hare(153, 180); } else if (pickedObject == kVerbPick && fl == 143 && flags[18] == 0) { lleva_al_hare(260, 180); copyBackground(80, 78, 199, 94, 38, 27, drawSurface3, screenSurface); updateScreen(199, 94, 199, 94, 38, 27, screenSurface); pause(3); - talk_igor_wig(25); + talk_igor(25, 4); lleva_al_hare(153, 180); } else if (pickedObject == kVerbTalk && fl == 51) animation_1_4(); diff --git a/engines/drascula/talk.cpp b/engines/drascula/talk.cpp index 821f7f9860..3fae1def14 100644 --- a/engines/drascula/talk.cpp +++ b/engines/drascula/talk.cpp @@ -50,11 +50,20 @@ bool DrasculaEngine::isTalkFinished(int* length) { return true; } -void DrasculaEngine::talk_igor_dch(int index) { +// talker types: +// 0: talk_igor_dch +// 1: talk_igor_front +// 2: talk_igor_door +// 3: talk_igor_seated +// 4: talk_igor_wig +void DrasculaEngine::talk_igor(int index, int talkerType) { char filename[20]; sprintf(filename, "I%i.als", index); const char *said = _texti[_lang][index]; - int x_talk[8] = { 56, 82, 108, 134, 160, 186, 212, 238 }; + int x_talk[8] = { 56, 82, 108, 134, 160, 186, 212, 238 }; + int x_talk2[8] = { 56, 86, 116, 146, 176, 206, 236, 266 }; + int x_talk3[4] = { 80, 102, 124, 146 }; + int x_talk4[4] = { 119, 158, 197, 236 }; int face; int length = strlen(said); @@ -63,35 +72,79 @@ void DrasculaEngine::talk_igor_dch(int index) { talkInit(filename); do { - face = _rnd->getRandomNumber(7); + if (talkerType == 0 || talkerType == 1) { + face = _rnd->getRandomNumber(7); + copyBackground(0, 0, 0, 0, 320, 200, drawSurface1, screenSurface); + updateRefresh_pre(); + } else if (talkerType == 3 || talkerType == 4) { + face = _rnd->getRandomNumber(3); + copyBackground(0, 0, 0, 0, 320, 200, drawSurface1, screenSurface); + updateRefresh_pre(); + } + + if (talkerType == 0) { + placeIgor(); + placeDrascula(); + copyBackground(igorX + 17, igorY, igorX + 17, igorY, 37, 24, drawSurface1, screenSurface); + copyRect(x_talk[face], 148, igorX + 17, igorY, 25, 24, frontSurface, screenSurface); + updateRefresh(); + if (withVoices == 0) + centerText(said, igorX + 26, igorY); + updateScreen(); + pause(3); + } else if (talkerType == 1) { + if (currentChapter == 1 || currentChapter == 4) + placeIgor(); + if (currentChapter == 1) + placeDrascula(); + if (currentChapter == 1 || currentChapter == 6) + copyBackground(igorX, igorY, igorX, igorY, 29, 25, drawSurface1, screenSurface); + copyRect(x_talk2[face], 173, igorX, igorY, 29, 25, frontSurface, screenSurface); + updateRefresh(); + if (withVoices == 0) + centerText(said, igorX + 26, igorY); + updateScreen(); + pause(3); + } else if (talkerType == 2) { + updateRoom(); + if (withVoices == 0) + centerText(said, 87, 66); + updateScreen(); + } else if (talkerType == 3) { + copyBackground(x_talk2[face], 109, 207, 92, 21, 23, drawSurface3, screenSurface); + pon_hare(); + updateRefresh(); + if (withVoices == 0) + centerText(said, 221, 102); - copyBackground(0, 0, 0, 0, 320, 200, drawSurface1, screenSurface); + updateScreen(); + pause(3); + } else if (talkerType == 4) { + copyBackground(x_talk3[face], 78, 199, 94, 38, 27, drawSurface3, screenSurface); + pon_hare(); + updateRefresh(); + if (withVoices == 0) + centerText(said, 221, 102); - updateRefresh_pre(); + updateScreen(); + pause(3); + } + } while (!isTalkFinished(&length)); + if ((talkerType == 1 && currentChapter == 6) || + talkerType == 2 || talkerType == 3 || talkerType == 4) { + updateRoom(); + } + + if (talkerType == 0 || (talkerType == 1 && currentChapter == 1)) { + copyBackground(0, 0, 0, 0, 320, 200, drawSurface1, screenSurface); placeIgor(); placeDrascula(); - copyBackground(igorX + 17, igorY, igorX + 17, igorY, 37, 24, drawSurface1, screenSurface); - - copyRect(x_talk[face], 148, igorX + 17, igorY, 25, 24, frontSurface, screenSurface); - - updateRefresh(); - - if (withVoices == 0) - centerText(said, igorX + 26, igorY); - - updateScreen(); - - pause(3); - - } while (!isTalkFinished(&length)); - - copyBackground(0, 0, 0, 0, 320, 200, drawSurface1, screenSurface); - placeIgor(); - placeDrascula(); + } updateScreen(); } +// Talker type 0: talk_dr_izq, 1: talk_dr_dch void DrasculaEngine::talk_drascula(int index, int talkerType) { const char *said = _textd[_lang][index]; char filename[20]; @@ -181,55 +234,6 @@ void DrasculaEngine::talk_solo(const char *said, const char *filename) { } } -void DrasculaEngine::talk_igor_front(int index) { - char filename[20]; - sprintf(filename, "I%i.als", index); - const char *said = _texti[_lang][index]; - int x_talk[8] = { 56, 86, 116, 146, 176, 206, 236, 266 }; - int face; - int length = strlen(said); - - color_abc(kColorWhite); - - talkInit(filename); - - do { - face = _rnd->getRandomNumber(7); - - copyBackground(0, 0, 0, 0, 320, 200, drawSurface1, screenSurface); - - updateRefresh_pre(); - - if (currentChapter == 1 || currentChapter == 4) - placeIgor(); - if (currentChapter == 1) - placeDrascula(); - if (currentChapter == 1 || currentChapter == 6) - copyBackground(igorX, igorY, igorX, igorY, 29, 25, drawSurface1, screenSurface); - copyRect(x_talk[face], 173, igorX, igorY, 29, 25, frontSurface, screenSurface); - - updateRefresh(); - - if (withVoices == 0) - centerText(said, igorX + 26, igorY); - - updateScreen(); - - pause(3); - } while (!isTalkFinished(&length)); - - if (currentChapter == 6) { - updateRoom(); - } - - if (currentChapter == 1) { - copyBackground(0, 0, 0, 0, 320, 200, drawSurface1, screenSurface); - placeIgor(); - placeDrascula(); - } - updateScreen(); -} - void DrasculaEngine::talk_bartender(int index, int talkerType) { char filename[20]; sprintf(filename, "t%i.als", index); @@ -462,12 +466,9 @@ void DrasculaEngine::talk(const char *said, const char *filename) { } void DrasculaEngine::talk_pianist(int index) { - char name[20]; - sprintf(name, "P%i.als", index); - talk(_textp[_lang][index], name); -} - -void DrasculaEngine::talk_pianist(const char *said, const char *filename) { + char filename[20]; + sprintf(filename, "P%i.als", index); + const char* said = _textp[_lang][index]; int x_talk[4] = { 97, 145, 193, 241 }; int face; int length = strlen(said); @@ -501,12 +502,9 @@ void DrasculaEngine::talk_pianist(const char *said, const char *filename) { } void DrasculaEngine::talk_drunk(int index) { - char name[20]; - sprintf(name, "B%i.als", index); - talk_drunk(_textb[_lang][index], name); -} - -void DrasculaEngine::talk_drunk(const char *said, const char *filename) { + char filename[20]; + sprintf(filename, "B%i.als", index); + const char *said = _textb[_lang][index]; int x_talk[8] = { 1, 21, 41, 61, 81, 101, 121, 141 }; int face; int length = strlen(said); @@ -563,12 +561,9 @@ void DrasculaEngine::talk_drunk(const char *said, const char *filename) { } void DrasculaEngine::talk_vb(int index) { - char name[20]; - sprintf(name, "VB%i.als", index); - talk_vb(_textvb[_lang][index], name); -} - -void DrasculaEngine::talk_vb(const char *said, const char *filename) { + char filename[20]; + sprintf(filename, "VB%i.als", index); + const char *said = _textvb[_lang][index]; int x_talk[6] = {1, 27, 53, 79, 105, 131}; int face; int length = strlen(said); @@ -607,12 +602,9 @@ void DrasculaEngine::talk_vb(const char *said, const char *filename) { } void DrasculaEngine::talk_vbpuerta(int index) { - char name[20]; - sprintf(name, "VB%i.als", index); - talk_vb(_textvb[_lang][index], name); -} - -void DrasculaEngine::talk_vbpuerta(const char *said, const char *filename) { + char filename[20]; + sprintf(filename, "VB%i.als", index); + const char *said = _textvb[_lang][index]; int length = strlen(said); color_abc(kColorBrown); @@ -711,12 +703,9 @@ void DrasculaEngine::talk_hacker(const char *said, const char *filename) { } void DrasculaEngine::talk_wolf(int index) { - char name[20]; - sprintf(name, "L%i.als", index); - talk_wolf(_textl[_lang][index], name); -} - -void DrasculaEngine::talk_wolf(const char *said, const char *filename) { + char filename[20]; + sprintf(filename, "L%i.als", index); + const char *said = _textl[_lang][index]; int x_talk[9] = {52, 79, 106, 133, 160, 187, 214, 241, 268}; int face; int length = strlen(said); @@ -749,12 +738,9 @@ void DrasculaEngine::talk_wolf(const char *said, const char *filename) { } void DrasculaEngine::talk_mus(int index) { - char name[20]; - sprintf(name, "E%i.als", index); - talk_mus(_texte[_lang][index], name); -} - -void DrasculaEngine::talk_mus(const char *said, const char *filename) { + char filename[20]; + sprintf(filename, "E%i.als", index); + const char *said = _texte[_lang][index]; int x_talk[8] = { 16, 35, 54, 73, 92, 111, 130, 149}; int face; int length = strlen(said); @@ -840,12 +826,9 @@ void DrasculaEngine::talk_pen(const char *said, const char *filename, int talker } void DrasculaEngine::talk_bj_bed(int index) { - char name[20]; - sprintf(name, "BJ%i.als", index); - talk_bj_bed(_textbj[_lang][index], name); -} - -void DrasculaEngine::talk_bj_bed(const char *said, const char *filename) { + char filename[20]; + sprintf(filename, "BJ%i.als", index); + const char *said = _textbj[_lang][index]; int x_talk[5] = {51, 101, 151, 201, 251}; int face; int length = strlen(said); @@ -879,12 +862,9 @@ void DrasculaEngine::talk_bj_bed(const char *said, const char *filename) { } void DrasculaEngine::talk_htel(int index) { - char name[20]; - sprintf(name, "%i.als", index); - talk_htel(_text[_lang][index], name); -} - -void DrasculaEngine::talk_htel(const char *said, const char *filename) { + char filename[20]; + sprintf(filename, "%i.als", index); + const char *said = _text[_lang][index]; char *num_cara; int x_talk[3] = {1, 94, 187}; int face, pantalla; @@ -1005,7 +985,10 @@ void DrasculaEngine::talk_sinc(const char *said, const char *filename, const cha playMusic(roomMusic); } -void DrasculaEngine::talk_baul(const char *said, const char *filename) { +void DrasculaEngine::talk_baul(int index) { + char filename[20]; + sprintf(filename, "d%i.als", index); + const char *said = _text[_lang][index]; int face = 0, cara_antes; int length = strlen(said); @@ -1034,107 +1017,10 @@ void DrasculaEngine::talk_baul(const char *said, const char *filename) { updateScreen(); } -void DrasculaEngine::talk_igor_door(int index) { - char name[20]; - sprintf(name, "I%i.als", index); - talk_igor_door(_texti[_lang][index], name); -} - -void DrasculaEngine::talk_igor_door(const char *said, const char *filename) { - int length = strlen(said); - - color_abc(kColorWhite); - - talkInit(filename); - - do { - updateRoom(); - if (withVoices == 0) - centerText(said, 87, 66); - updateScreen(); - } while (!isTalkFinished(&length)); - - updateRoom(); - updateScreen(); -} - -void DrasculaEngine::talk_igor_seated(int index) { - char name[20]; - sprintf(name, "I%i.als", index); - talk_igor_seated(_texti[_lang][index], name); -} - -void DrasculaEngine::talk_igor_seated(const char *said, const char *filename) { - int x_talk[4] = { 80, 102, 124, 146 }; - int face; - int length = strlen(said); - - color_abc(kColorWhite); - - talkInit(filename); - - do { - face = _rnd->getRandomNumber(3); - - copyBackground(0, 0, 0, 0, 320, 200, drawSurface1, screenSurface); - - updateRefresh_pre(); - - copyBackground(x_talk[face], 109, 207, 92, 21, 23, drawSurface3, screenSurface); - pon_hare(); - updateRefresh(); - - if (withVoices == 0) - centerText(said, 221, 102); - - updateScreen(); - - pause(3); - } while (!isTalkFinished(&length)); - - updateRoom(); - updateScreen(); -} - -void DrasculaEngine::talk_igor_wig(int index) { - char name[20]; - sprintf(name, "I%i.als", index); - talk_igor_wig(_texti[_lang][index], name); -} - -void DrasculaEngine::talk_igor_wig(const char *said, const char *filename) { - int x_talk[4] = {119, 158, 197, 236}; - int face = 0; - int length = strlen(said); - - color_abc(kColorWhite); - - talkInit(filename); - - do { - face = _rnd->getRandomNumber(3); - - copyBackground(0, 0, 0, 0, 320, 200, drawSurface1, screenSurface); - - updateRefresh_pre(); - - copyBackground(x_talk[face], 78, 199, 94, 38, 27, drawSurface3, screenSurface); - pon_hare(); - updateRefresh(); - - if (withVoices == 0) - centerText(said, 221, 102); - - updateScreen(); - - pause(3); - } while (!isTalkFinished(&length)); - - updateRoom(); - updateScreen(); -} - -void DrasculaEngine::talk_dr_grande(const char *said, const char *filename) { +void DrasculaEngine::talk_dr_grande(int index) { + char filename[20]; + sprintf(filename, "D%i.als", index); + const char *said = _textd[_lang][index]; int x_talk[4] = {47, 93, 139, 185}; int face; int l = 0; -- cgit v1.2.3