From ba5cebfaf8cdddef3bd1d814106935ab305bb410 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 1 Jun 2008 20:58:05 +0000 Subject: Now whole game could be run from original packed files. svn-id: r32475 --- engines/drascula/animation.cpp | 40 ++++---- engines/drascula/drascula.cpp | 228 ++++++++++++++++------------------------- engines/drascula/drascula.h | 17 ++- engines/drascula/rooms.cpp | 16 +-- engines/drascula/talk.cpp | 17 +-- 5 files changed, 128 insertions(+), 190 deletions(-) (limited to 'engines') diff --git a/engines/drascula/animation.cpp b/engines/drascula/animation.cpp index 0bd5acde19..fd75a41031 100644 --- a/engines/drascula/animation.cpp +++ b/engines/drascula/animation.cpp @@ -107,7 +107,7 @@ void DrasculaEngine::animation_1_1() { break; if (animate("scr2.bin", 17)) break; - stopSound_corte(); + stopSound(); if (animate("scr3.bin", 17)) break; loadAndDecompressPic("cielo2.alg", screenSurface, COMPLETE_PAL); @@ -281,7 +281,7 @@ void DrasculaEngine::animation_1_1() { break; if (animate("frel.bin", 16)) break; - stopSound_corte(); + stopSound(); clearRoom(); black(); playMusic(23); @@ -417,7 +417,7 @@ void DrasculaEngine::animation_2_1() { pause(4); playSound(1); hiccup(18); - stopSound(); + finishSound(); if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)) break; @@ -698,13 +698,13 @@ void DrasculaEngine::animation_2_2() { copyBackground(0, 0, 0, 0, 320, 200, drawSurface1, screenSurface); updateScreen(); - stopSound(); + finishSound(); pause (4); playSound(1); hipo_sin_nadie(12); - stopSound(); + finishSound(); } void DrasculaEngine::animation_3_2() { @@ -841,7 +841,7 @@ void DrasculaEngine::animation_14_2() { playSound(7); hiccup(15); - stopSound(); + finishSound(); loadAndDecompressPic("99.alg", backSurface, 1); } @@ -1178,7 +1178,7 @@ void DrasculaEngine::animation_25_2() { updateScreen(); } - stopSound(); + finishSound(); loadAndDecompressPic("99.alg", backSurface, 1); } @@ -1313,7 +1313,7 @@ void DrasculaEngine::animation_35_2() { playSound(1); hipo_sin_nadie(18); - stopSound(); + finishSound(); pause(10); @@ -1445,7 +1445,7 @@ void DrasculaEngine::animation_rayo() { updateScreen(0, 0, 0, 0, 320, 200, drawSurface3); pause(3); updateScreen(0, 0, 0, 0, 320, 200, frontSurface); - stopSound(); + finishSound(); } void DrasculaEngine::animation_2_4() { @@ -1620,7 +1620,7 @@ void DrasculaEngine::animation_5_5(){ updateScreen(0, 0, 0, 0, 320, 200, drawSurface1); playSound(1); - stopSound(); + finishSound(); loadAndDecompressPic("99.alg", backSurface, 1); loadAndDecompressPic("97.alg", extraSurface, 1); @@ -1743,7 +1743,7 @@ void DrasculaEngine::animation_12_5() { updateScreen(); } - stopSound_corte(); + stopSound(); for (frame = 0; frame < 15; frame++) { if (frame == 2 || frame == 4 || frame == 7 || frame == 9) @@ -1769,7 +1769,7 @@ void DrasculaEngine::animation_12_5() { animation_13_5(); playSound(1); hiccup(12); - stopSound(); + finishSound(); loadAndDecompressPic("99.alg", backSurface, 1); @@ -1834,7 +1834,7 @@ void DrasculaEngine::animation_14_5() { playSound(3); updateRoom(); updateScreen(0, 0, 0,0 , 320, 200, screenSurface); - stopSound(); + finishSound(); pause(17); sentido_hare = 3; talk(246); @@ -1843,7 +1843,7 @@ void DrasculaEngine::animation_14_5() { playSound(7); updateRoom(); updateScreen(); - stopSound(); + finishSound(); pause(14); sentido_hare = 3; updateRoom(); @@ -2094,7 +2094,7 @@ void DrasculaEngine::animation_10_6() { updateRefresh_pre(); copyBackground(164, 85, 155, 48, 113, 114, drawSurface3, screenSurface); updateScreen(); - stopSound(); + finishSound(); talk_taber2(23); flags[7] = 1; } @@ -2146,7 +2146,7 @@ void DrasculaEngine::animation_19_6() { updateScreen(); playSound(4); pause(6); - stopSound(); + finishSound(); } void DrasculaEngine::animation_12_2() { @@ -2232,7 +2232,7 @@ void DrasculaEngine::animation_26_2() { pause(3); } - stopSound_corte(); + stopSound(); updateAnim(121, 225, 113, 50, 59, 6, extraSurface); @@ -2303,7 +2303,7 @@ void DrasculaEngine::animation_22_2() { updateRoom(); updateScreen(); playSound(13); - stopSound(); + finishSound(); sentido_hare = 1; talk_vbpuerta(1); @@ -2381,7 +2381,7 @@ void DrasculaEngine::animation_34_2() { updateAnim(1, 218, 79, 83, 75, 3, extraSurface); - stopSound(); + finishSound(); pause(30); @@ -2493,7 +2493,7 @@ void DrasculaEngine::animation_5_2() { playSound(1); updateAnim(86, 213, 66, 53, 84, 6, frontSurface); - stopSound_corte(); + stopSound(); updateAnim(1, 213, 66, 53, 84, 6, drawSurface3); diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 64c5c751c8..a8ad7a805f 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -151,8 +151,6 @@ int DrasculaEngine::go() { frame_bat = 0; c_mirar = 0; c_poder = 0; - ald = NULL; - sku = NULL; allocMemory(); @@ -223,7 +221,7 @@ int DrasculaEngine::go() { void DrasculaEngine::releaseGame() { if (hay_sb == 1) - ctvd_end(); + stopSound(); clearRoom(); black(); MusicFadeout(); @@ -792,8 +790,7 @@ bool DrasculaEngine::para_cargar(char gameName[]) { if (!loadGame(gameName)) return false; if (currentChapter == 2 || currentChapter == 3 || currentChapter == 5) { - delete ald; - ald = NULL; + // } carga_escoba(currentData); withoutVerb(); @@ -801,14 +798,14 @@ bool DrasculaEngine::para_cargar(char gameName[]) { return true; } -static char *getLine(Common::File *fp, char *buf, int len) { +char *DrasculaEngine::getLine(char *buf, int len) { byte c; char *b; for (;;) { b = buf; - while (!fp->eos()) { - c = ~fp->readByte(); + while (!_arj.eos()) { + c = ~_arj.readByte(); if (c == '\r') continue; if (c == '\n' || b - buf >= (len - 1)) @@ -816,7 +813,7 @@ static char *getLine(Common::File *fp, char *buf, int len) { *b++ = c; } *b = '\0'; - if (fp->eos() && b == buf) + if (_arj.eos() && b == buf) return NULL; if (b != buf) break; @@ -824,13 +821,13 @@ static char *getLine(Common::File *fp, char *buf, int len) { return buf; } -void getIntFromLine(Common::File *fp, char *buf, int len, int* result) { - getLine(fp, buf, len); +void DrasculaEngine::getIntFromLine(char *buf, int len, int* result) { + getLine(buf, len); sscanf(buf, "%d", result); } -void getStringFromLine(Common::File *fp, char *buf, int len, char* result) { - getLine(fp, buf, len); +void DrasculaEngine::getStringFromLine(char *buf, int len, char* result) { + getLine(buf, len); sscanf(buf, "%s", result); } @@ -846,32 +843,31 @@ void DrasculaEngine::carga_escoba(const char *nom_fich) { strcpy(para_codificar, nom_fich); strcpy(currentData, nom_fich); - ald = new Common::File; - ald->open(nom_fich); - if (!ald->isOpen()) { - error("missing data file"); + _arj.open(nom_fich); + if (!_arj.isOpen()) { + error("missing data file %s", nom_fich); } - int size = ald->size(); + int size = _arj.size(); - getIntFromLine(ald, buffer, size, &roomNumber); - getIntFromLine(ald, buffer, size, &roomMusic); - getStringFromLine(ald, buffer, size, roomDisk); - getIntFromLine(ald, buffer, size, &nivel_osc); + getIntFromLine(buffer, size, &roomNumber); + getIntFromLine(buffer, size, &roomMusic); + getStringFromLine(buffer, size, roomDisk); + getIntFromLine(buffer, size, &nivel_osc); if (currentChapter == 2) - getIntFromLine(ald, buffer, size, &martin); + getIntFromLine(buffer, size, &martin); if (currentChapter == 2 && martin != 0) { ancho_hare = martin; - getIntFromLine(ald, buffer, size, &alto_hare); - getIntFromLine(ald, buffer, size, &feetHeight); - getIntFromLine(ald, buffer, size, &stepX); - getIntFromLine(ald, buffer, size, &stepY); + getIntFromLine(buffer, size, &alto_hare); + getIntFromLine(buffer, size, &feetHeight); + getIntFromLine(buffer, size, &stepX); + getIntFromLine(buffer, size, &stepY); - getStringFromLine(ald, buffer, size, pant1); - getStringFromLine(ald, buffer, size, pant2); - getStringFromLine(ald, buffer, size, pant3); - getStringFromLine(ald, buffer, size, pant4); + getStringFromLine(buffer, size, pant1); + getStringFromLine(buffer, size, pant2); + getStringFromLine(buffer, size, pant3); + getStringFromLine(buffer, size, pant4); loadAndDecompressPic(pant2, extraSurface, 1); loadAndDecompressPic(pant1, frontSurface, 1); @@ -880,41 +876,40 @@ void DrasculaEngine::carga_escoba(const char *nom_fich) { strcpy(menuBackground, pant4); } - getIntFromLine(ald, buffer, size, &numRoomObjs); + getIntFromLine(buffer, size, &numRoomObjs); for (l = 0; l < numRoomObjs; l++) { - getIntFromLine(ald, buffer, size, &objectNum[l]); - getStringFromLine(ald, buffer, size, objName[l]); - getIntFromLine(ald, buffer, size, &x1[l]); - getIntFromLine(ald, buffer, size, &y1[l]); - getIntFromLine(ald, buffer, size, &x2[l]); - getIntFromLine(ald, buffer, size, &y2[l]); - getIntFromLine(ald, buffer, size, &sitiobj_x[l]); - getIntFromLine(ald, buffer, size, &sitiobj_y[l]); - getIntFromLine(ald, buffer, size, &sentidobj[l]); - getIntFromLine(ald, buffer, size, &visible[l]); - getIntFromLine(ald, buffer, size, &isDoor[l]); + getIntFromLine(buffer, size, &objectNum[l]); + getStringFromLine(buffer, size, objName[l]); + getIntFromLine(buffer, size, &x1[l]); + getIntFromLine(buffer, size, &y1[l]); + getIntFromLine(buffer, size, &x2[l]); + getIntFromLine(buffer, size, &y2[l]); + getIntFromLine(buffer, size, &sitiobj_x[l]); + getIntFromLine(buffer, size, &sitiobj_y[l]); + getIntFromLine(buffer, size, &sentidobj[l]); + getIntFromLine(buffer, size, &visible[l]); + getIntFromLine(buffer, size, &isDoor[l]); if (isDoor[l] != 0) { - getStringFromLine(ald, buffer, size, _targetSurface[l]); - getIntFromLine(ald, buffer, size, &_destX[l]); - getIntFromLine(ald, buffer, size, &_destY[l]); - getIntFromLine(ald, buffer, size, &sentido_alkeva[l]); - getIntFromLine(ald, buffer, size, &alapuertakeva[l]); + getStringFromLine(buffer, size, _targetSurface[l]); + getIntFromLine(buffer, size, &_destX[l]); + getIntFromLine(buffer, size, &_destY[l]); + getIntFromLine(buffer, size, &sentido_alkeva[l]); + getIntFromLine(buffer, size, &alapuertakeva[l]); updateDoor(l); } } - getIntFromLine(ald, buffer, size, &suelo_x1); - getIntFromLine(ald, buffer, size, &suelo_y1); - getIntFromLine(ald, buffer, size, &suelo_x2); - getIntFromLine(ald, buffer, size, &suelo_y2); + getIntFromLine(buffer, size, &suelo_x1); + getIntFromLine(buffer, size, &suelo_y1); + getIntFromLine(buffer, size, &suelo_x2); + getIntFromLine(buffer, size, &suelo_y2); if (currentChapter != 2) { - getIntFromLine(ald, buffer, size, &far); - getIntFromLine(ald, buffer, size, &near); + getIntFromLine(buffer, size, &far); + getIntFromLine(buffer, size, &near); } - delete ald; - ald = NULL; + _arj.close(); if (currentChapter == 2) { if (martin == 0) { @@ -1849,16 +1844,8 @@ void DrasculaEngine::playSound(int soundNum) { char file[20]; sprintf(file, "s%i.als", soundNum); - if (hay_sb == 1) { - sku = new Common::File; - sku->open(file); - if (!sku->isOpen()) { - error("no puedo abrir archivo de voz"); - } - } - ctvd_init(2); - ctvd_speaker(1); - ctvd_output(sku); + if (hay_sb == 1) + playFile(file); } bool DrasculaEngine::animate(const char *animationFile, int FPS) { @@ -1916,15 +1903,6 @@ bool DrasculaEngine::animate(const char *animationFile, int FPS) { return ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE)); } -void DrasculaEngine::animastopSound_corte() { - if (hay_sb == 1) { - ctvd_stop(); - delete sku; - sku = NULL; - ctvd_terminate(); - } -} - void DrasculaEngine::fadeToBlack(int fadeSpeed) { char fundido; unsigned int color, component; @@ -2040,13 +2018,12 @@ void DrasculaEngine::hiccup(int counter) { updateScreen(); } -void DrasculaEngine::stopSound() { +void DrasculaEngine::finishSound() { delay(1); if (hay_sb == 1) { - while (soundIsActive()); - delete sku; - sku = NULL; + while (soundIsActive()) + _system->delayMillis(10); } } @@ -2504,8 +2481,7 @@ bool DrasculaEngine::exitRoom(int l) { addObject(11); } clearRoom(); - delete ald; - ald = NULL; + strcpy(salgo, _targetSurface[l]); strcat(salgo, ".ald"); hare_x =- 1; @@ -2690,7 +2666,7 @@ void DrasculaEngine::enterName() { void DrasculaEngine::para_grabar(char gameName[]) { saveGame(gameName); playSound(99); - stopSound(); + finishSound(); } void DrasculaEngine::openSSN(const char *Name, int Pause) { @@ -3149,26 +3125,25 @@ void DrasculaEngine::converse(const char *nom_fich) { if (currentChapter == 5) withoutVerb(); - ald = new Common::File; - ald->open(nom_fich); - if (!ald->isOpen()) { - error("missing data file"); - } - int size = ald->size(); - - getStringFromLine(ald, buffer, size, phrase1); - getStringFromLine(ald, buffer, size, phrase2); - getStringFromLine(ald, buffer, size, phrase3); - getStringFromLine(ald, buffer, size, phrase4); - getStringFromLine(ald, buffer, size, sound1); - getStringFromLine(ald, buffer, size, sound2); - getStringFromLine(ald, buffer, size, sound3); - getStringFromLine(ald, buffer, size, sound4); - getIntFromLine(ald, buffer, size, &answer1); - getIntFromLine(ald, buffer, size, &answer2); - getIntFromLine(ald, buffer, size, &answer3); - delete ald; - ald = NULL; + _arj.open(nom_fich); + if (!_arj.isOpen()) { + error("missing data file %s", nom_fich); + } + int size = _arj.size(); + + getStringFromLine(buffer, size, phrase1); + getStringFromLine(buffer, size, phrase2); + getStringFromLine(buffer, size, phrase3); + getStringFromLine(buffer, size, phrase4); + getStringFromLine(buffer, size, sound1); + getStringFromLine(buffer, size, sound2); + getStringFromLine(buffer, size, sound3); + getStringFromLine(buffer, size, sound4); + getIntFromLine(buffer, size, &answer1); + getIntFromLine(buffer, size, &answer2); + getIntFromLine(buffer, size, &answer3); + + _arj.close(); if (currentChapter == 2 && !strcmp(nom_fich, "op_5.cal") && flags[38] == 1 && flags[33] == 1) { strcpy(phrase3, _text[_lang][405]); @@ -3413,12 +3388,9 @@ void DrasculaEngine::addObject(int osj) { } } -void DrasculaEngine::stopSound_corte() { +void DrasculaEngine::stopSound() { if (hay_sb == 1) { - ctvd_stop(); - delete sku; - sku = NULL; - ctvd_terminate(); + _mixer->stopHandle(_soundHandle); } } @@ -3441,27 +3413,15 @@ void DrasculaEngine::MusicFadeout() { _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, org_vol); } -void DrasculaEngine::ctvd_end() { - _mixer->stopHandle(_soundHandle); -} - -void DrasculaEngine::ctvd_stop() { - _mixer->stopHandle(_soundHandle); -} - -void DrasculaEngine::ctvd_terminate() { -// _mixer->stopHandle(_soundHandle); -} - -void DrasculaEngine::ctvd_speaker(int flag) {} - -void DrasculaEngine::ctvd_output(Common::File *file_handle) {} +void DrasculaEngine::playFile(const char *fname) { + _arj.open(fname); -void DrasculaEngine::ctvd_init(int b) { - int soundSize = sku->size(); + int soundSize = _arj.size(); byte *soundData = (byte *)malloc(soundSize); - sku->seek(32); - sku->read(soundData, soundSize); + _arj.seek(32); + _arj.read(soundData, soundSize); + _arj.close(); + _mixer->playRaw(Audio::Mixer::kSFXSoundType, &_soundHandle, soundData, soundSize - 64, 11025, Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED); } @@ -3666,7 +3626,7 @@ void DrasculaEngine::openDoor(int nflag, int doorNum) { updateDoor(doorNum); updateRoom(); updateScreen(); - stopSound(); + finishSound(); withoutVerb(); } } @@ -3693,16 +3653,8 @@ void DrasculaEngine::grr() { color_abc(kColorDarkGreen); - if (hay_sb == 1) { - sku = new Common::File; - sku->open("s10.als"); - if (!sku->isOpen()) { - error("no puedo abrir archivo de voz"); - } - ctvd_init(4); - ctvd_speaker(1); - ctvd_output(sku); - } + if (hay_sb == 1) + playFile("s10.als"); updateRoom(); copyBackground(253, 110, 150, 65, 20, 30, drawSurface3, screenSurface); @@ -3740,7 +3692,7 @@ void DrasculaEngine::closeDoor(int nflag, int doorNum) { updateDoor(doorNum); updateRoom(); updateScreen(); - stopSound(); + finishSound(); withoutVerb(); } } diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index ec7d016a9b..09973b8d41 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -229,8 +229,6 @@ public: byte cPal[768]; byte *pcxBuffer; - Common::File *ald, *sku; - Common::ArjFile _arj; int hay_sb; @@ -423,7 +421,6 @@ public: void centerText(const char *,int,int); void playSound(int soundNum); bool animate(const char *animation, int FPS); - void stopSound_corte(); void fadeToBlack(int fadeSpeed); void pause(int); void placeIgor(); @@ -479,6 +476,7 @@ public: void talk_hacker(const char *, const char *); void hiccup(int); + void finishSound(); void stopSound(); void closeDoor(int nflag, int doorNum); void playMusic(int p); @@ -487,7 +485,6 @@ public: void updateRoom(); bool loadGame(const char *); void updateDoor(int); - void animastopSound_corte(); void color_hare(); void funde_hare(int oscuridad); void paleta_hare_claro(); @@ -588,12 +585,12 @@ public: void response(int); void MusicFadeout(); - void ctvd_end(); - void ctvd_stop(); - void ctvd_terminate(); - void ctvd_speaker(int flag); - void ctvd_output(Common::File *file_handle); - void ctvd_init(int b); + void playFile(const char *fname); + + char *getLine(char *buf, int len); + void getIntFromLine(char *buf, int len, int* result); + void getStringFromLine(char *buf, int len, char* result); + void grr(); bool room_13(int fl); void update_13(); diff --git a/engines/drascula/rooms.cpp b/engines/drascula/rooms.cpp index 2c76ed37cd..0e22e4a85c 100644 --- a/engines/drascula/rooms.cpp +++ b/engines/drascula/rooms.cpp @@ -179,7 +179,7 @@ void DrasculaEngine::room_6(int fl){ flags[2] = 1; updateRoom(); updateScreen(); - stopSound(); + finishSound(); } else if (pickedObject == kVerbClose && fl == 143 && flags[2] == 1) { copyBackground(0, 0, 0, 0, 320, 200, drawSurface1, screenSurface); flags[2] = 0; @@ -190,7 +190,7 @@ void DrasculaEngine::room_6(int fl){ playSound(4); updateRoom(); updateScreen(); - stopSound(); + finishSound(); } else if (pickedObject == kVerbOpen && fl == 139 && flags[1] == 0) { copyBackground(0, 0, 0, 0, 320, 200, drawSurface1, screenSurface); updateRefresh_pre(); @@ -203,7 +203,7 @@ void DrasculaEngine::room_6(int fl){ visible[2] = 0; updateRoom(); updateScreen(); - stopSound(); + finishSound(); } else if (pickedObject == kVerbPick && fl == 140) { copyBackground(0, 0, 0, 0, 320, 200, drawSurface1, screenSurface); updateRefresh_pre(); @@ -334,7 +334,7 @@ void DrasculaEngine::room_15(int fl) { copyRect(133, 135, hare_x + 6, hare_y, 39, 63, drawSurface3, screenSurface); updateScreen(); playSound(8); - stopSound(); + finishSound(); talk(338); flags[27] = 0; pickObject(19); @@ -519,7 +519,7 @@ void DrasculaEngine::room_22(int fl) { flags[26]=1; playSound(1); hiccup(14); - stopSound(); + finishSound(); withoutVerb(); removeObject(22); updateVisible(); @@ -874,7 +874,7 @@ void DrasculaEngine::room_55(int fl) { else if (fl == 206) { playSound(11); animate("det.bin", 17); - stopSound(); + finishSound(); lleva_al_hare(hare_x - 3, hare_y + alto_hare + 6); } else hasAnswer = 0; @@ -920,7 +920,7 @@ void DrasculaEngine::room_59(int fl) { if (flags[11] == 0) { playSound(12); delay(40); - stopSound(); + finishSound(); delay(10); lleva_al_hare(174, 168); sentido_hare = 2; @@ -929,7 +929,7 @@ void DrasculaEngine::room_59(int fl) { pause(40); playSound(12); pause(19); - stopSound_corte(); + stopSound(); hare_se_ve = 0; updateRoom(); copyRect(101, 34, hare_x - 4, hare_y - 1, 37, 70, drawSurface3, screenSurface); diff --git a/engines/drascula/talk.cpp b/engines/drascula/talk.cpp index 5955a35891..71e0b77587 100644 --- a/engines/drascula/talk.cpp +++ b/engines/drascula/talk.cpp @@ -30,28 +30,17 @@ namespace Drascula { void DrasculaEngine::talkInit(const char *filename) { _rnd->setSeed((unsigned int)_system->getMillis() / 2); - if (hay_sb == 1) { - sku = new Common::File; - sku->open(filename); - if (!sku->isOpen()) { - error("no puedo abrir archivo de voz"); - } - ctvd_init(2); - ctvd_speaker(1); - ctvd_output(sku); - } + if (hay_sb == 1) + playFile(filename); } bool DrasculaEngine::isTalkFinished(int* length) { byte key = getScan(); if (key != 0) - ctvd_stop(); + stopSound(); if (hay_sb == 1) { if (soundIsActive()) return false; - delete(sku); - sku = 0; - ctvd_terminate(); } else { length -= 2; if (length > 0) -- cgit v1.2.3