diff options
author | Filippos Karapetis | 2008-09-10 08:25:12 +0000 |
---|---|---|
committer | Filippos Karapetis | 2008-09-10 08:25:12 +0000 |
commit | 3202ef4dd15f12bdd8cd648d31a9f41b5e0c3053 (patch) | |
tree | cd16304a52bf61dccf3f9d89130b70887d2a6967 /engines | |
parent | cde2ee58b18684628b7c37d297178323ad58c73f (diff) | |
download | scummvm-rg350-3202ef4dd15f12bdd8cd648d31a9f41b5e0c3053.tar.gz scummvm-rg350-3202ef4dd15f12bdd8cd648d31a9f41b5e0c3053.tar.bz2 scummvm-rg350-3202ef4dd15f12bdd8cd648d31a9f41b5e0c3053.zip |
Reduced game memory usage by about 400KB by only loading the current language strings, not all strings
svn-id: r34472
Diffstat (limited to 'engines')
-rw-r--r-- | engines/drascula/animation.cpp | 44 | ||||
-rw-r--r-- | engines/drascula/converse.cpp | 6 | ||||
-rw-r--r-- | engines/drascula/drascula.cpp | 38 | ||||
-rw-r--r-- | engines/drascula/drascula.h | 34 | ||||
-rw-r--r-- | engines/drascula/interface.cpp | 2 | ||||
-rw-r--r-- | engines/drascula/objects.cpp | 2 | ||||
-rw-r--r-- | engines/drascula/rooms.cpp | 18 | ||||
-rw-r--r-- | engines/drascula/talk.cpp | 36 |
8 files changed, 87 insertions, 93 deletions
diff --git a/engines/drascula/animation.cpp b/engines/drascula/animation.cpp index 5f0ad234e8..f9a194707a 100644 --- a/engines/drascula/animation.cpp +++ b/engines/drascula/animation.cpp @@ -87,7 +87,7 @@ void DrasculaEngine::animation_1_1() { if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; color_abc(kColorRed); - centerText(_textmisc[_lang][1], 160, 100); + centerText(_textmisc[1], 160, 100); updateScreen(); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; @@ -219,12 +219,12 @@ void DrasculaEngine::animation_1_1() { loadPic("plan1.alg", screenSurface, HALF_PAL); updateScreen(); pause(10); - talk_solo(_textd[_lang][4],"d4.als"); + talk_solo(_textd[4],"d4.als"); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; loadPic("plan1.alg", screenSurface, HALF_PAL); updateScreen(); - talk_solo(_textd[_lang][5], "d5.als"); + talk_solo(_textd[5], "d5.als"); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; if (animate("lib2.bin", 16)) @@ -233,7 +233,7 @@ void DrasculaEngine::animation_1_1() { loadPic("plan2.alg", screenSurface, HALF_PAL); updateScreen(); pause(20); - talk_solo(_textd[_lang][6], "d6.als"); + talk_solo(_textd[6], "d6.als"); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; if (animate("lib2.bin", 16)) @@ -244,12 +244,12 @@ void DrasculaEngine::animation_1_1() { pause(20); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; - talk_solo(_textd[_lang][7], "d7.als"); + talk_solo(_textd[7], "d7.als"); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; loadPic("plan3.alg", screenSurface, HALF_PAL); updateScreen(); - talk_solo(_textd[_lang][8], "d8.als"); + talk_solo(_textd[8], "d8.als"); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; clearRoom(); @@ -436,7 +436,7 @@ void DrasculaEngine::animation_2_1() { if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; - talk_solo(_textbj[_lang][1], "BJ1.als"); + talk_solo(_textbj[1], "BJ1.als"); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; clearRoom(); @@ -449,7 +449,7 @@ void DrasculaEngine::animation_2_1() { if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; color_solo = kColorYellow; - talk_solo(_text[_lang][214], "214.als"); + talk_solo(_text[214], "214.als"); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; clearRoom(); @@ -523,7 +523,7 @@ void DrasculaEngine::animation_2_1() { pause(120); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; - talk_solo(_text[_lang][223], "223.als"); + talk_solo(_text[223], "223.als"); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; color_solo = kColorWhite; @@ -532,7 +532,7 @@ void DrasculaEngine::animation_2_1() { break; updateScreen(); pause(110); - talk_solo(_textbj[_lang][11], "BJ11.als"); + talk_solo(_textbj[11], "BJ11.als"); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; updateRoom(); @@ -836,7 +836,7 @@ void DrasculaEngine::animation_16_2() { copyBackground(); if (_lang != kSpanish) - centerText(_texthis[_lang][1], 180, 180); + centerText(_texthis[1], 180, 180); updateScreen(); @@ -866,7 +866,7 @@ void DrasculaEngine::animation_16_2() { copyBackground(); if (_lang != kSpanish) - centerText(_texthis[_lang][2], 180, 180); + centerText(_texthis[2], 180, 180); updateScreen(); key = getScan(); @@ -892,7 +892,7 @@ void DrasculaEngine::animation_16_2() { copyBackground(); if (_lang != kSpanish) - centerText(_texthis[_lang][3], 180, 180); + centerText(_texthis[3], 180, 180); updateScreen(); key = getScan(); @@ -917,7 +917,7 @@ void DrasculaEngine::animation_16_2() { copyBackground(0, 0, 0, 0, 320, 200, drawSurface3, screenSurface); if (_lang != kSpanish) - centerText(_texthis[_lang][1], 180, 180); + centerText(_texthis[1], 180, 180); updateScreen(); key = getScan(); @@ -1660,7 +1660,7 @@ void DrasculaEngine::animation_14_5() { trackProtagonist = 3; updateRoom(); updateScreen(); - talk_solo(_textd[_lang][18], "d18.als"); + talk_solo(_textd[18], "d18.als"); fadeToBlack(1); } @@ -1818,11 +1818,11 @@ void DrasculaEngine::animation_9_6() { clearRoom(); loadPic("nota.alg", bgSurface, COMPLETE_PAL); color_abc(kColorWhite); - talk_solo(_textbj[_lang][24], "bj24.als"); - talk_solo(_textbj[_lang][25], "bj25.als"); - talk_solo(_textbj[_lang][26], "bj26.als"); - talk_solo(_textbj[_lang][27], "bj27.als"); - talk_solo(_textbj[_lang][28], "bj28.als"); + talk_solo(_textbj[24], "bj24.als"); + talk_solo(_textbj[25], "bj25.als"); + talk_solo(_textbj[26], "bj26.als"); + talk_solo(_textbj[27], "bj27.als"); + talk_solo(_textbj[28], "bj28.als"); trackProtagonist = 3; clearRoom(); loadPic(96, frontSurface, COMPLETE_PAL); @@ -1837,7 +1837,7 @@ void DrasculaEngine::animation_9_6() { copyBackground(0, 0, 0, 0, 320, 200, screenSurface, bgSurface); updateScreen(); color_abc(kColorLightGreen); - talk_solo(_textmisc[_lang][2], "s15.als"); + talk_solo(_textmisc[2], "s15.als"); loadPic("nota2.alg", bgSurface); trackProtagonist = 0; updateRoom(); @@ -2219,7 +2219,7 @@ void DrasculaEngine::animation_5_2() { loadPic("aux5.alg", drawSurface3); flags[8] = 1; curX = curX - 4; - talk_sync(_text[_lang][46], "46.als", "4442444244244"); + talk_sync(_text[46], "46.als", "4442444244244"); withoutVerb(); } diff --git a/engines/drascula/converse.cpp b/engines/drascula/converse.cpp index fafbbe8685..950c73c241 100644 --- a/engines/drascula/converse.cpp +++ b/engines/drascula/converse.cpp @@ -139,19 +139,19 @@ void DrasculaEngine::converse(int index) { _arj.close(); if (currentChapter == 2 && !strcmp(fileName, "op_5.cal") && flags[38] == 1 && flags[33] == 1) { - strcpy(phrase3, _text[_lang][405]); + strcpy(phrase3, _text[405]); strcpy(sound3, "405.als"); answer3 = 31; } if (currentChapter == 6 && !strcmp(fileName, "op_12.cal") && flags[7] == 1) { - strcpy(phrase3, _text[_lang][273]); + strcpy(phrase3, _text[273]); strcpy(sound3, "273.als"); answer3 = 14; } if (currentChapter == 6 && !strcmp(fileName, "op_12.cal") && flags[10] == 1) { - strcpy(phrase3, _text[_lang][274]); + strcpy(phrase3, _text[274]); strcpy(sound3, "274.als"); answer3 = 15; } diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index ef6c9158d2..b81c4bc729 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -259,7 +259,7 @@ int DrasculaEngine::go() { memset(iconName, 0, sizeof(iconName)); for (i = 0; i < 6; i++) - strcpy(iconName[i + 1], _textverbs[_lang][i]); + strcpy(iconName[i + 1], _textverbs[i]); assignDefaultPalette(); if (!runCurrentChapter()) { @@ -563,12 +563,12 @@ bool DrasculaEngine::runCurrentChapter() { withoutVerb(); } else if (key == Common::KEYCODE_v) { withVoices = 1; - print_abc(_textsys[_lang][2], 96, 86); + print_abc(_textsys[2], 96, 86); updateScreen(); delay(1410); } else if (key == Common::KEYCODE_t) { withVoices = 0; - print_abc(_textsys[_lang][3], 94, 86); + print_abc(_textsys[3], 94, 86); updateScreen(); delay(1460); } else if (key == Common::KEYCODE_ESCAPE) { @@ -1002,24 +1002,22 @@ bool DrasculaEngine::loadDrasculaDat() { return true; } -char ***DrasculaEngine::loadTexts(Common::File &in) { +char **DrasculaEngine::loadTexts(Common::File &in) { int numTexts = in.readUint16BE(); - char ***res; + char **res = (char **)malloc(sizeof(char *) * numTexts); int entryLen; - char *pos; + char *pos = 0; int len; - res = (char ***)malloc(sizeof(char *) * _numLangs); - for (int lang = 0; lang < _numLangs; lang++) { entryLen = in.readUint16BE(); - - res[lang] = (char **)malloc(sizeof(char *) * numTexts); - pos = (char *)malloc(entryLen); - res[lang][0] = pos; - - in.read(res[lang][0], entryLen); + if (lang == _lang) { + res[0] = pos; + in.read(res[0], entryLen); + } else { + in.read(pos, entryLen); + } pos += DATAALIGNMENT; @@ -1029,23 +1027,19 @@ char ***DrasculaEngine::loadTexts(Common::File &in) { len = READ_BE_UINT16(pos); pos += 2 + len; - res[lang][i] = pos; + if (lang == _lang) + res[i] = pos; } } return res; } -void DrasculaEngine::freeTexts(char ***ptr) { +void DrasculaEngine::freeTexts(char **ptr) { if (!ptr) return; - for (int lang = 0; lang < _numLangs; lang++) { - if (ptr[lang]) { - free(ptr[lang][0]); - free(ptr[lang]); - } - } + free(ptr[0]); free(ptr); } diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index 98a48e3042..0c820d92c2 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -691,21 +691,21 @@ private: int _talkSequencesSize; int _numLangs; - char ***_text; - char ***_textd; - char ***_textb; - char ***_textbj; - char ***_texte; - char ***_texti; - char ***_textl; - char ***_textp; - char ***_textt; - char ***_textvb; - char ***_textsys; - char ***_texthis; - char ***_textverbs; - char ***_textmisc; - char ***_textd1; + char **_text; + char **_textd; + char **_textb; + char **_textbj; + char **_texte; + char **_texti; + char **_textl; + char **_textp; + char **_textt; + char **_textvb; + char **_textsys; + char **_texthis; + char **_textverbs; + char **_textmisc; + char **_textd1; ItemLocation *_itemLocations; int *_polX, *_polY; int *_verbBarX; @@ -717,8 +717,8 @@ private: RoomTalkAction *_roomActions; TalkSequenceCommand *_talkSequences; - char ***loadTexts(Common::File &in); - void freeTexts(char ***ptr); + char **loadTexts(Common::File &in); + void freeTexts(char **ptr); }; } // End of namespace Drascula diff --git a/engines/drascula/interface.cpp b/engines/drascula/interface.cpp index ef1d1cc7a3..cfa3e0c346 100644 --- a/engines/drascula/interface.cpp +++ b/engines/drascula/interface.cpp @@ -61,7 +61,7 @@ bool DrasculaEngine::confirmExit() { color_abc(kColorRed); updateRoom(); - centerText(_textsys[_lang][1], 160, 87); + centerText(_textsys[1], 160, 87); updateScreen(); delay(100); diff --git a/engines/drascula/objects.cpp b/engines/drascula/objects.cpp index 01967d975d..cb031026f9 100644 --- a/engines/drascula/objects.cpp +++ b/engines/drascula/objects.cpp @@ -256,7 +256,7 @@ void DrasculaEngine::updateVisible() { if (roomNumber == 22 && flags[27] == 1) visible[3] = 0; if (roomNumber == 26 && flags[21] == 0) - strcpy(objName[2], _textmisc[_lang][0]); + strcpy(objName[2], _textmisc[0]); if (roomNumber == 26 && flags[18] == 1) visible[2] = 0; if (roomNumber == 26 && flags[12] == 1) diff --git a/engines/drascula/rooms.cpp b/engines/drascula/rooms.cpp index 39f7799ca5..f5b87dd7ea 100644 --- a/engines/drascula/rooms.cpp +++ b/engines/drascula/rooms.cpp @@ -184,9 +184,9 @@ bool DrasculaEngine::room_3(int fl) { if (pickedObject == kVerbTalk && fl == 129) { talk(23); pause(6); - talk_sync(_text[_lang][50], "50.als", "11111111111144432554433"); + talk_sync(_text[50], "50.als", "11111111111144432554433"); } else if (pickedObject == kVerbTalk && fl == 133) { - talk_sync(_text[_lang][322], "322.als", "13333334125433333333"); + talk_sync(_text[322], "322.als", "13333334125433333333"); updateRoom(); updateScreen(); pause(25); @@ -407,7 +407,7 @@ bool DrasculaEngine::room_15(int fl) { talk(336); trackProtagonist = 3; talk(337); - talk_sync(_text[_lang][46], "46.als", "4442444244244"); + talk_sync(_text[46], "46.als", "4442444244244"); trackProtagonist = 1; } else if (pickedObject == 18 && fl == 188 && flags[26] == 0) { copyBackground(); @@ -441,7 +441,7 @@ bool DrasculaEngine::room_16(int fl) { else if (pickedObject == kVerbTalk && fl == 183) { talk(341); pause(10); - talk_sync(_text[_lang][50], "50.als", "11111111111144432554433"); + talk_sync(_text[50], "50.als", "11111111111144432554433"); pause(3); talk_trunk(83); } else if (pickedObject == kVerbOpen && fl == 183) { @@ -948,19 +948,19 @@ bool DrasculaEngine::room_59(int fl) { talk_htel(240); color_abc(kColorBrown); - talk_solo(_textvb[_lang][58], "VB58.als"); + talk_solo(_textvb[58], "VB58.als"); talk_htel(241); color_abc(kColorBrown); - talk_solo(_textvb[_lang][59], "VB59.als"); + talk_solo(_textvb[59], "VB59.als"); talk_htel(242); color_abc(kColorBrown); - talk_solo(_textvb[_lang][60], "VB60.als"); + talk_solo(_textvb[60], "VB60.als"); talk_htel(196); color_abc(kColorBrown); - talk_solo(_textvb[_lang][61],"VB61.als"); + talk_solo(_textvb[61],"VB61.als"); talk_htel(244); color_abc(kColorBrown); - talk_solo(_textvb[_lang][62], "VB62.als"); + talk_solo(_textvb[62], "VB62.als"); clearRoom(); loadPic("aux59.alg", drawSurface3); loadPic(96, frontSurface, COMPLETE_PAL); diff --git a/engines/drascula/talk.cpp b/engines/drascula/talk.cpp index 5ee7f13a25..38956449c4 100644 --- a/engines/drascula/talk.cpp +++ b/engines/drascula/talk.cpp @@ -55,7 +55,7 @@ bool DrasculaEngine::isTalkFinished(int* length) { void DrasculaEngine::talk_igor(int index, int talkerType) { char filename[20]; sprintf(filename, "I%i.als", index); - const char *said = _texti[_lang][index]; + const char *said = _texti[index]; int x_talk0[8] = { 56, 82, 108, 134, 160, 186, 212, 238 }; int x_talk1[8] = { 56, 86, 116, 146, 176, 206, 236, 266 }; int x_talk3[4] = { 80, 102, 124, 146 }; @@ -136,7 +136,7 @@ void DrasculaEngine::talk_igor(int index, int talkerType) { // Talker type 0: talk_dr_izq, 1: talk_dr_dch void DrasculaEngine::talk_drascula(int index, int talkerType) { - const char *said = _textd[_lang][index]; + const char *said = _textd[index]; char filename[20]; sprintf(filename, "d%i.als", index); int x_talk[8] = { 1, 40, 79, 118, 157, 196, 235, 274 }; @@ -196,7 +196,7 @@ void DrasculaEngine::talk_drascula(int index, int talkerType) { void DrasculaEngine::talk_drascula_big(int index) { char filename[20]; sprintf(filename, "d%i.als", index); - const char *said = _textd[_lang][index]; + const char *said = _textd[index]; int x_talk[4] = {47, 93, 139, 185}; int face; int l = 0; @@ -266,10 +266,10 @@ void DrasculaEngine::talk_bartender(int index, int talkerType) { // Line 82 is a special case if (index != 82) - said = _textt[_lang][index]; + said = _textt[index]; else { sprintf(filename, "d%i.als", index); - said = _textd[_lang][index]; + said = _textd[index]; } int x_talk[9] = { 1, 23, 45, 67, 89, 111, 133, 155, 177 }; @@ -321,7 +321,7 @@ void DrasculaEngine::talk_bartender(int index, int talkerType) { void DrasculaEngine::talk_bj(int index) { char filename[20]; sprintf(filename, "BJ%i.als", index); - const char *said = _textbj[_lang][index]; + const char *said = _textbj[index]; int x_talk[5] = { 64, 92, 120, 148, 176 }; int face; int length = strlen(said); @@ -369,7 +369,7 @@ void DrasculaEngine::talk_bj(int index) { void DrasculaEngine::talk(int index) { char name[20]; sprintf(name, "%i.als", index); - talk(_text[_lang][index], name); + talk(_text[index], name); } void DrasculaEngine::talk(const char *said, const char *filename) { @@ -491,7 +491,7 @@ void DrasculaEngine::talk(const char *said, const char *filename) { void DrasculaEngine::talk_pianist(int index) { char filename[20]; sprintf(filename, "P%i.als", index); - const char* said = _textp[_lang][index]; + const char* said = _textp[index]; int x_talk[4] = { 97, 145, 193, 241 }; int coords[7] = { 139, 228, 112, 47, 60, 221, 128 }; @@ -502,7 +502,7 @@ void DrasculaEngine::talk_pianist(int index) { void DrasculaEngine::talk_drunk(int index) { char filename[20]; sprintf(filename, "B%i.als", index); - const char *said = _textb[_lang][index]; + const char *said = _textb[index]; int x_talk[8] = { 1, 21, 41, 61, 81, 101, 121, 141 }; int coords[7] = { 29, 177, 50, 19, 19, 181, 54 }; @@ -539,7 +539,7 @@ void DrasculaEngine::talk_drunk(int index) { void DrasculaEngine::talk_vonBraun(int index, int talkerType) { char filename[20]; sprintf(filename, "VB%i.als", index); - const char *said = _textvb[_lang][index]; + const char *said = _textvb[index]; int x_talk[6] = {1, 27, 53, 79, 105, 131}; int face; int length = strlen(said); @@ -591,8 +591,8 @@ void DrasculaEngine::talk_blind(int index) { // voice files start from 58, not 1 char filename[20]; sprintf(filename, "d%i.als", index + TEXTD_START - 1); - const char *said = _textd[_lang][index + TEXTD_START - 1]; - const char *syncChar = _textd1[_lang][index - 1]; + const char *said = _textd[index + TEXTD_START - 1]; + const char *syncChar = _textd1[index - 1]; byte *faceBuffer; int p = 0; @@ -641,7 +641,7 @@ void DrasculaEngine::talk_blind(int index) { void DrasculaEngine::talk_hacker(int index) { char filename[20]; sprintf(filename, "d%i.als", index); - const char *said = _textd[_lang][index]; + const char *said = _textd[index]; int length = strlen(said); copyBackground(); @@ -661,7 +661,7 @@ void DrasculaEngine::talk_hacker(int index) { void DrasculaEngine::talk_werewolf(int index) { char filename[20]; sprintf(filename, "L%i.als", index); - const char *said = _textl[_lang][index]; + const char *said = _textl[index]; int x_talk[9] = {52, 79, 106, 133, 160, 187, 214, 241, 268}; int coords[7] = { 136, 198, 81, 26, 24, 203, 78 }; @@ -672,7 +672,7 @@ void DrasculaEngine::talk_werewolf(int index) { void DrasculaEngine::talk_mus(int index) { char filename[20]; sprintf(filename, "E%i.als", index); - const char *said = _texte[_lang][index]; + const char *said = _texte[index]; int x_talk[8] = { 16, 35, 54, 73, 92, 111, 130, 149}; int coords[7] = { 156, 190, 64, 18, 24, 197, 64 }; @@ -735,7 +735,7 @@ void DrasculaEngine::talk_pen(const char *said, const char *filename, int talker void DrasculaEngine::talk_bj_bed(int index) { char filename[20]; sprintf(filename, "BJ%i.als", index); - const char *said = _textbj[_lang][index]; + const char *said = _textbj[index]; int x_talk[5] = {51, 101, 151, 201, 251}; int face; int length = strlen(said); @@ -771,7 +771,7 @@ void DrasculaEngine::talk_bj_bed(int index) { void DrasculaEngine::talk_htel(int index) { char filename[20]; sprintf(filename, "%i.als", index); - const char *said = _text[_lang][index]; + const char *said = _text[index]; char *faceBuffer; int x_talk[3] = {1, 94, 187}; int face, curScreen; @@ -895,7 +895,7 @@ void DrasculaEngine::talk_sync(const char *said, const char *filename, const cha void DrasculaEngine::talk_trunk(int index) { char filename[20]; sprintf(filename, "d%i.als", index); - const char *said = _text[_lang][index]; + const char *said = _text[index]; int face = 0, cara_antes; int length = strlen(said); |