From ab5c3e2dad5b1c3493b686647dc73094979fc208 Mon Sep 17 00:00:00 2001 From: athrxx Date: Tue, 17 Jan 2012 23:11:00 +0100 Subject: KYRA: (EOB) - move EOB 1 intro code into separate class --- engines/kyra/eob.cpp | 10 +- engines/kyra/eob.h | 37 +- engines/kyra/sequences_eob.cpp | 831 ++++++++++++++++++++++------------------- engines/kyra/staticres_eob.cpp | 21 -- 4 files changed, 455 insertions(+), 444 deletions(-) diff --git a/engines/kyra/eob.cpp b/engines/kyra/eob.cpp index a2ddc928fd..40b028184f 100644 --- a/engines/kyra/eob.cpp +++ b/engines/kyra/eob.cpp @@ -33,18 +33,14 @@ EoBEngine::EoBEngine(OSystem *system, const GameFlags &flags) _numSpells = 53; _menuChoiceInit = 4; - _turnUndeadString = _introFilesOpening = _introFilesTower = _introFilesOrb = 0; - _introFilesWdEntry = _introFilesKing = _introFilesHands = _introFilesWdExit = 0; - _introFilesTunnel = _finBonusStrings = _npcStrings[1] = _npcStrings[2] = 0; + _turnUndeadString = 0; + _finBonusStrings = _npcStrings[1] = _npcStrings[2] = 0; _npcStrings[3] = _npcStrings[4] = _npcStrings[5] = _npcStrings[6] = 0; _npcStrings[7] = _npcStrings[8] = _npcStrings[9] = _npcStrings[10] = 0; - _introOpeningFrmDelay = _introWdEncodeX = _introWdEncodeY = _introWdEncodeWH = 0; - _npcShpData = _npcSubShpIndex1 = _npcSubShpIndex2 = _npcSubShpY = _introWdDsY = 0; - _introTvlX1 = _introTvlY1 = _introTvlX2 = _introTvlY2 = _introTvlW = _introTvlH = 0; + _npcShpData = _npcSubShpIndex1 = _npcSubShpIndex2 = _npcSubShpY = 0; _dscDoorScaleMult4 = _dscDoorScaleMult5 = _dscDoorScaleMult6 = _dscDoorY3 = 0; _dscDoorY4 = _dscDoorY5 = _dscDoorY6 = _dscDoorY7 = _doorShapeEncodeDefs = 0; _doorSwitchShapeEncodeDefs = _doorSwitchCoords = 0; - _introWdDsX = 0; _dscDoorCoordsExt = 0; } diff --git a/engines/kyra/eob.h b/engines/kyra/eob.h index ce71c76af4..89d2b25b23 100644 --- a/engines/kyra/eob.h +++ b/engines/kyra/eob.h @@ -31,6 +31,7 @@ namespace Kyra { class EoBEngine : public EoBCoreEngine { friend class GUI_EoB; +friend class EoBIntroPlayer; public: EoBEngine(OSystem *system, const GameFlags &flags); ~EoBEngine(); @@ -51,46 +52,10 @@ private: void startupLoad(); // Intro/Outro - void seq_playOpeningCredits(); void seq_playIntro(); void seq_playFinale(); - - void seq_tower(); - void seq_orb(); - void seq_waterdeepEntry(); - void seq_king(); - void seq_hands(); - void seq_waterdeepExit(); - void seq_tunnel(); - void seq_xdeath(); - void loadSetIntroPalette(const char *filename); - void copyBlurRegion(int x1, int y1, int x2, int y2, int w, int h, int step); - void boxMorphTransition(int targetDestX, int targetDestY, int targetFinalX, int targetFinalY, int targetSrcX, int targetSrcY, int targetFinalW, int targetFinalH, int originX1, int originY1, int originW, int originH); - void whirlTransition(); - - const char *const *_introFilesOpening; - const char *const *_introFilesTower; - const char *const *_introFilesOrb; - const char *const *_introFilesWdEntry; - const char *const *_introFilesKing; - const char *const *_introFilesHands; - const char *const *_introFilesWdExit; - const char *const *_introFilesTunnel; - const uint8 *_introOpeningFrmDelay; - const uint8 *_introWdEncodeX; - const uint8 *_introWdEncodeY; - const uint8 *_introWdEncodeWH; - const uint16 *_introWdDsX; - const uint8 *_introWdDsY; - const uint8 *_introTvlX1; - const uint8 *_introTvlY1; - const uint8 *_introTvlX2; - const uint8 *_introTvlY2; - const uint8 *_introTvlW; - const uint8 *_introTvlH; - const char *const *_finBonusStrings; // characters diff --git a/engines/kyra/sequences_eob.cpp b/engines/kyra/sequences_eob.cpp index 64f88e95ce..f18c67f659 100644 --- a/engines/kyra/sequences_eob.cpp +++ b/engines/kyra/sequences_eob.cpp @@ -33,111 +33,89 @@ namespace Kyra { -int EoBEngine::mainMenu() { - int menuChoice = _menuChoiceInit; - _menuChoiceInit = 0; - - Screen::FontId of = _screen->_currentFont; - - while (menuChoice >= 0 && !shouldQuit()) { - switch (menuChoice) { - case 0: { - _screen->loadPalette("EOBPAL.COL", _screen->getPalette(0)); - _screen->loadEoBBitmap("INTRO", 0, 5, 3, 2); - _screen->setScreenPalette(_screen->getPalette(0)); - _screen->_curPage = 2; - of = _screen->setFont(Screen::FID_6_FNT); - Common::String versionString(Common::String::format("ScummVM %s", gScummVMVersion)); - _screen->printText(versionString.c_str(), 280 - versionString.size() * 6, 153, _screen->getPagePixel(2, 0, 0), 0); - _screen->setFont(of); - _screen->fillRect(0, 159, 319, 199, _screen->getPagePixel(2, 0, 0)); - gui_drawBox(77, 165, 173, 29, 13, 14, 12); - gui_drawBox(76, 164, 175, 31, 13, 14, -1); - _screen->_curPage = 0; - _screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0, Screen::CR_NO_P_CHECK); - _screen->updateScreen(); - _allowImport = true; - menuChoice = mainMenuLoop(); - _allowImport = false; - } break; - - case 1: - // load game in progress - // - menuChoice = -1; - break; - - case 2: - // create new party - menuChoice = -2; - break; - - case 3: - // quit - menuChoice = -5; - break; - - case 4: - // intro - _sound->loadSoundFile("SOUND"); - _screen->hideMouse(); - seq_playOpeningCredits(); - seq_playIntro(); - _screen->showMouse(); - _sound->loadSoundFile("ADLIB"); - menuChoice = 0; - break; - } - } - - return shouldQuit() ? -5 : menuChoice; -} - -int EoBEngine::mainMenuLoop() { - int sel = -1; - do { - _screen->setScreenDim(28); - _gui->simpleMenu_setup(8, 0, _mainMenuStrings, -1, 0, 0); - - while (sel == -1 && !shouldQuit()) - sel = _gui->simpleMenu_process(8, _mainMenuStrings, 0, -1, 0); - } while ((sel < 0 || sel > 5) && !shouldQuit()); - - return sel + 1; -} - -void EoBEngine::seq_playOpeningCredits() { - _allowSkip = true; - - loadSetIntroPalette(_introFilesOpening[5]); - _screen->loadBitmap(_introFilesOpening[4], 5, 3, 0); - _screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0, Screen::CR_NO_P_CHECK); - _screen->updateScreen(); - - snd_playSong(1); - delay(_introOpeningFrmDelay[0] * _tickLength); - - for (int i = 0; i < 4 && !shouldQuit() && !skipFlag(); i++) { - _screen->loadBitmap(_introFilesOpening[i], 5, 3, 0); - uint32 nextFrameTimer = _system->getMillis() + _introOpeningFrmDelay[i + 1] * _tickLength; - _screen->crossFadeRegion(0, 50, 0, 50, 320, 102, 2, 0); - delayUntil(nextFrameTimer); - } - - _allowSkip = false; +class EoBIntroPlayer { +public: + EoBIntroPlayer(EoBEngine *vm, Screen_EoB *screen); + ~EoBIntroPlayer() {} + + void start(); + +private: + void openingCredits(); + void tower(); + void orb(); + void waterdeepEntry(); + void king(); + void hands(); + void waterdeepExit(); + void tunnel(); + + void loadAndSetPalette(const char *filename); + void copyBlurRegion(int x1, int y1, int x2, int y2, int w, int h, int step); + void boxMorphTransition(int targetDestX, int targetDestY, int targetFinalX, int targetFinalY, int targetSrcX, int targetSrcY, int targetFinalW, int targetFinalH, int originX1, int originY1, int originW, int originH); + void whirlTransition(); + + EoBEngine *_vm; + Screen_EoB *_screen; + + const char *const *_filesOpening; + const char *const *_filesTower; + const char *const *_filesOrb; + const char *const *_filesWdEntry; + const char *const *_filesKing; + const char *const *_filesHands; + const char *const *_filesWdExit; + const char *const *_filesTunnel; + const uint8 *_openingFrmDelay; + const uint8 *_wdEncodeX; + const uint8 *_wdEncodeY; + const uint8 *_wdEncodeWH; + const uint16 *_wdDsX; + const uint8 *_wdDsY; + const uint8 *_tvlX1; + const uint8 *_tvlY1; + const uint8 *_tvlX2; + const uint8 *_tvlY2; + const uint8 *_tvlW; + const uint8 *_tvlH; +}; + +EoBIntroPlayer::EoBIntroPlayer(EoBEngine *vm, Screen_EoB *screen) : _vm(vm), _screen(screen) { + int temp = 0; + _filesOpening = _vm->staticres()->loadStrings(kEoB1IntroFilesOpening, temp); + _filesTower = _vm->staticres()->loadStrings(kEoB1IntroFilesTower, temp); + _filesOrb = _vm->staticres()->loadStrings(kEoB1IntroFilesOrb, temp); + _filesWdEntry = _vm->staticres()->loadStrings(kEoB1IntroFilesWdEntry, temp); + _filesKing = _vm->staticres()->loadStrings(kEoB1IntroFilesKing, temp); + _filesHands = _vm->staticres()->loadStrings(kEoB1IntroFilesHands, temp); + _filesWdExit = _vm->staticres()->loadStrings(kEoB1IntroFilesWdExit, temp); + _filesTunnel = _vm->staticres()->loadStrings(kEoB1IntroFilesTunnel, temp); + _openingFrmDelay = _vm->staticres()->loadRawData(kEoB1IntroOpeningFrmDelay, temp); + _wdEncodeX = _vm->staticres()->loadRawData(kEoB1IntroWdEncodeX, temp); + _wdEncodeY = _vm->staticres()->loadRawData(kEoB1IntroWdEncodeY, temp); + _wdEncodeWH = _vm->staticres()->loadRawData(kEoB1IntroWdEncodeWH, temp); + _wdDsX = _vm->staticres()->loadRawDataBe16(kEoB1IntroWdDsX, temp); + _wdDsY = _vm->staticres()->loadRawData(kEoB1IntroWdDsY, temp); + _tvlX1 = _vm->staticres()->loadRawData(kEoB1IntroTvlX1, temp); + _tvlY1 = _vm->staticres()->loadRawData(kEoB1IntroTvlY1, temp); + _tvlX2 = _vm->staticres()->loadRawData(kEoB1IntroTvlX2, temp); + _tvlY2 = _vm->staticres()->loadRawData(kEoB1IntroTvlY2, temp); + _tvlW = _vm->staticres()->loadRawData(kEoB1IntroTvlW, temp); + _tvlH = _vm->staticres()->loadRawData(kEoB1IntroTvlH, temp); } -void EoBEngine::seq_playIntro() { - _allowSkip = true; +void EoBIntroPlayer::start() { + _vm->_allowSkip = true; + openingCredits(); - if (!shouldQuit() && !skipFlag()) { - snd_playSong(2); + if (!_vm->shouldQuit() && !_vm->skipFlag()) { + _vm->snd_playSong(2); _screen->loadBitmap("TITLE-V.CMP", 5, 3, 0); _screen->crossFadeRegion(0, 0, 0, 0, 320, 200, 2, 0); - delay(120 * _tickLength); + _vm->delay(120 * _vm->_tickLength); } - Common::SeekableReadStream *s = _res->createReadStream("TEXT.RAW"); + Common::SeekableReadStream *s = _vm->resource()->createReadStream("TEXT.RAW"); if (s) { s->seek(768); _screen->loadFileDataToPage(s, 6, s->size() - 768); @@ -146,65 +124,41 @@ void EoBEngine::seq_playIntro() { _screen->loadBitmap("TEXT.CMP", 3, 6, 0); } - seq_tower(); - seq_orb(); - seq_waterdeepEntry(); - seq_king(); - seq_hands(); - seq_waterdeepExit(); - seq_tunnel(); + tower(); + orb(); + waterdeepEntry(); + king(); + hands(); + waterdeepExit(); + tunnel(); whirlTransition(); - _sound->haltTrack(); - _allowSkip = false; + _vm->snd_stopSound(); + _vm->_allowSkip = false; } -void EoBEngine::seq_playFinale() { - Common::SeekableReadStream *s = _res->createReadStream("TEXT.DAT"); - _screen->loadFileDataToPage(s, 5, 32000); - delete s; - - snd_playSoundEffect(20); - - _txt->resetPageBreakString(); - _txt->setWaitButtonMode(1); - _txt->setupField(12, true); - gui_drawBox(0, 0, 176, 175, guiSettings()->colors.frame1, guiSettings()->colors.frame2, guiSettings()->colors.fill); - _txt->printDialogueText(51, _moreStrings[0]); - - if (!checkScriptFlags(0x1ffe)) { - _screen->fadeToBlack(); - return; - } - - _txt->printDialogueText(_finBonusStrings[0]); - for (int i = 0; i < 6; i++) { - _txt->printDialogueText(_finBonusStrings[1]); - if (_characters[i].flags & 1) - _txt->printDialogueText(_characters[i].name); - } +void EoBIntroPlayer::openingCredits() { + loadAndSetPalette(_filesOpening[5]); + _screen->loadBitmap(_filesOpening[4], 5, 3, 0); + _screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); - uint32 password = 0; - for (int i = 0; i < 4; i++) { - if (!(_characters[i].flags & 1)) - continue; + _vm->snd_playSong(1); + _vm->delay(_openingFrmDelay[0] * _vm->_tickLength); - int len = strlen(_characters[i].name); - for (int ii = 0; ii < len; ii++) { - uint32 c = _characters[i].name[ii]; - password += (c * c); - } + for (int i = 0; i < 4 && !_vm->shouldQuit() && !_vm->skipFlag(); i++) { + _screen->loadBitmap(_filesOpening[i], 5, 3, 0); + uint32 nextFrameTimer = _vm->_system->getMillis() + _openingFrmDelay[i + 1] * _vm->_tickLength; + _screen->crossFadeRegion(0, 50, 0, 50, 320, 102, 2, 0); + _vm->delayUntil(nextFrameTimer); } - - _txt->printDialogueText(Common::String::format(_finBonusStrings[2], password).c_str(), true); - _screen->fadeToBlack(); } -void EoBEngine::seq_tower() { - if (shouldQuit() || skipFlag()) +void EoBIntroPlayer::tower() { + if (_vm->shouldQuit() || _vm->skipFlag()) return; - _screen->loadBitmap(_introFilesTower[1], 5, 3, 0); + _screen->loadBitmap(_filesTower[1], 5, 3, 0); _screen->setCurPage(2); uint8 *shp = _screen->encodeShape(0, 0, 16, 56, true); _screen->copyPage(3, 4); @@ -216,7 +170,7 @@ void EoBEngine::seq_tower() { _screen->fillRect(0, 184, 319, 199, 12); int cp = _screen->setCurPage(0); whirlTransition(); - loadSetIntroPalette(_introFilesTower[0]); + loadAndSetPalette(_filesTower[0]); _screen->setCurPage(cp); _screen->clearCurPage(); @@ -226,29 +180,29 @@ void EoBEngine::seq_tower() { _screen->setCurPage(0); - for (int i = 0; i < 64 && !shouldQuit() && !skipFlag(); i += 2) { - uint32 end = _system->getMillis() + 2 * _tickLength; + for (int i = 0; i < 64 && !_vm->shouldQuit() && !_vm->skipFlag(); i += 2) { + uint32 end = _vm->_system->getMillis() + 2 * _vm->_tickLength; _screen->copyRegion(0, 142 - i, 96, 0, 128, i + 1, 4, 0, Screen::CR_NO_P_CHECK); _screen->copyRegion(0, 0, 96, i + 1, 128, 167 - i, 2, 0, Screen::CR_NO_P_CHECK); if (!i) _screen->copyRegion(0, 0, 0, 168, 320, 32, 6, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } - for (int i = 0; i < 24 && !shouldQuit() && !skipFlag(); i += 2) { - uint32 end = _system->getMillis() + 2 * _tickLength; + for (int i = 0; i < 24 && !_vm->shouldQuit() && !_vm->skipFlag(); i += 2) { + uint32 end = _vm->_system->getMillis() + 2 * _vm->_tickLength; _screen->copyRegion(0, 79 - i, 96, 0, 24, 65 + i, 4, 0, Screen::CR_NO_P_CHECK); _screen->copyRegion(104, 79 - i, 200, 0, 24, 65 + i, 4, 0, Screen::CR_NO_P_CHECK); _screen->copyRegion(24, 110, 120, i + 31, 80, 34, 4, 0, Screen::CR_NO_P_CHECK); _screen->copyRegion(152, 0, 120, 32, 80, i + 1, 4, 0, Screen::CR_NO_P_CHECK); _screen->copyRegion(0, 0, 96, 65 + i, 128, 103 - i, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } - for (int i = 0; i < 56 && !shouldQuit() && !skipFlag(); i += 2) { - uint32 end = _system->getMillis() + 2 * _tickLength; + for (int i = 0; i < 56 && !_vm->shouldQuit() && !_vm->skipFlag(); i += 2) { + uint32 end = _vm->_system->getMillis() + 2 * _vm->_tickLength; _screen->copyRegion(0, 56, 96, i, 24, 54, 4, 0, Screen::CR_NO_P_CHECK); _screen->copyRegion(104, 56, 200, i, 24, 54, 4, 0, Screen::CR_NO_P_CHECK); _screen->copyRegion(0, 110, 96, 54 + i, 128, 34, 4, 0, Screen::CR_NO_P_CHECK); @@ -266,24 +220,24 @@ void EoBEngine::seq_tower() { _screen->copyRegion(128, 0, 96, 0, 128, i + 1, 2, 0, Screen::CR_NO_P_CHECK); _screen->copyRegion(0, 0, 96, i + 89, 128, 79 - i, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } _screen->copyRegion(0, 32, 0, 168, 320, 32, 6, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delay(65 * _tickLength); + _vm->delay(65 * _vm->_tickLength); delete[] shp; } -void EoBEngine::seq_orb() { - if (shouldQuit() || skipFlag()) +void EoBIntroPlayer::orb() { + if (_vm->shouldQuit() || _vm->skipFlag()) return; uint8 *shp[5]; - _screen->loadBitmap(_introFilesOrb[0], 5, 3, 0); + _screen->loadBitmap(_filesOrb[0], 5, 3, 0); _screen->setCurPage(2); shp[4] = _screen->encodeShape(0, 0, 20, 136, true); - _screen->loadBitmap(_introFilesOrb[1], 5, 3, 0); + _screen->loadBitmap(_filesOrb[1], 5, 3, 0); shp[3] = _screen->encodeShape(16, 0, 16, 104, true); _screen->fillRect(0, 0, 127, 103, 12); @@ -297,51 +251,51 @@ void EoBEngine::seq_orb() { _screen->copyPage(3, 4); _screen->clearCurPage(); - snd_playSoundEffect(6); + _vm->snd_playSoundEffect(6); - for (int i = -1; i < 4 && !shouldQuit() && !skipFlag(); i++) { - uint32 end = _system->getMillis() + 3 * _tickLength; + for (int i = -1; i < 4 && !_vm->shouldQuit() && !_vm->skipFlag(); i++) { + uint32 end = _vm->_system->getMillis() + 3 * _vm->_tickLength; if (i >= 0) _screen->drawShape(2, shp[i], 16, 16, 0); _screen->drawShape(2, shp[4], 0, 0, 0); _screen->copyRegion(0, 0, 80, 24, 160, 136, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } _screen->copyRegion(0, 64, 0, 168, 320, 16, 6, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delay(40 * _tickLength); + _vm->delay(40 * _vm->_tickLength); - snd_playSoundEffect(6); + _vm->snd_playSoundEffect(6); - for (int i = 3; i > -2 && !shouldQuit() && !skipFlag(); i--) { - uint32 end = _system->getMillis() + 3 * _tickLength; + for (int i = 3; i > -2 && !_vm->shouldQuit() && !_vm->skipFlag(); i--) { + uint32 end = _vm->_system->getMillis() + 3 * _vm->_tickLength; _screen->fillRect(16, 16, 143, 119, 12, 2); if (i >= 0) _screen->drawShape(2, shp[i], 16, 16, 0); _screen->drawShape(2, shp[4], 0, 0, 0); _screen->copyRegion(0, 0, 80, 24, 160, 136, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } - delay(40 * _tickLength); + _vm->delay(40 * _vm->_tickLength); for (int i = 0; i < 5; i++) delete[] shp[i]; } -void EoBEngine::seq_waterdeepEntry() { - if (shouldQuit() || skipFlag()) +void EoBIntroPlayer::waterdeepEntry() { + if (_vm->shouldQuit() || _vm->skipFlag()) return; uint8 *shp[4]; uint8 *shp2[31]; uint8 *shp3[3]; - loadSetIntroPalette(_introFilesWdEntry[0]); - _screen->loadBitmap(_introFilesWdEntry[1], 5, 3, 0); + loadAndSetPalette(_filesWdEntry[0]); + _screen->loadBitmap(_filesWdEntry[1], 5, 3, 0); _screen->setCurPage(2); shp[3] = _screen->encodeShape(0, 0, 20, 136, true); for (int i = 1; i < 4; i++) { @@ -352,57 +306,57 @@ void EoBEngine::seq_waterdeepEntry() { _screen->copyPage(3, 4); _screen->fillRect(0, 168, 319, 199, 12, 0); - snd_playSoundEffect(6); + _vm->snd_playSoundEffect(6); - for (int i = 0; i < 4 && !shouldQuit() && !skipFlag(); i++) { - uint32 end = _system->getMillis() + 3 * _tickLength; + for (int i = 0; i < 4 && !_vm->shouldQuit() && !_vm->skipFlag(); i++) { + uint32 end = _vm->_system->getMillis() + 3 * _vm->_tickLength; _screen->drawShape(0, shp[i], 80, 24, 0); delete[] shp[i]; _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } _screen->copyRegion(0, 80, 0, 168, 320, 16, 6, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delay(50 * _tickLength); + _vm->delay(50 * _vm->_tickLength); _screen->setCurPage(2); shp[0] = _screen->encodeShape(20, 0, 20, 136, true); - _screen->loadBitmap(_introFilesWdEntry[2], 5, 3, 0); + _screen->loadBitmap(_filesWdEntry[2], 5, 3, 0); shp[1] = _screen->encodeShape(0, 0, 20, 136, true); shp[2] = _screen->encodeShape(20, 0, 20, 136, true); - _screen->loadBitmap(_introFilesWdEntry[3], 5, 3, 0); + _screen->loadBitmap(_filesWdEntry[3], 5, 3, 0); for (int i = 0; i < 31; i++) - shp2[i] = _screen->encodeShape(_introWdEncodeX[i], 136 + (_introWdEncodeY[i] << 3), _introWdEncodeWH[i], _introWdEncodeWH[i] << 3, true); + shp2[i] = _screen->encodeShape(_wdEncodeX[i], 136 + (_wdEncodeY[i] << 3), _wdEncodeWH[i], _wdEncodeWH[i] << 3, true); for (int i = 0; i < 3; i++) shp3[i] = _screen->encodeShape(5 * i, 152, 5, 32, true); _screen->copyPage(3, 4); - for (int i = 0; i < 3 && !shouldQuit() && !skipFlag(); i++) { - uint32 end = _system->getMillis() + 3 * _tickLength; + for (int i = 0; i < 3 && !_vm->shouldQuit() && !_vm->skipFlag(); i++) { + uint32 end = _vm->_system->getMillis() + 3 * _vm->_tickLength; _screen->fillRect(0, 0, 159, 135, 12, 2); _screen->drawShape(2, shp[i], 0, 0, 0); _screen->copyRegion(0, 0, 80, 24, 160, 136, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } _screen->copyRegion(0, 0, 80, 24, 160, 136, 4, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delay(4 * _tickLength); + _vm->delay(4 * _vm->_tickLength); _screen->copyRegion(160, 0, 80, 24, 160, 136, 4, 0, Screen::CR_NO_P_CHECK); _screen->fillRect(0, 168, 319, 199, 12, 0); _screen->updateScreen(); - delay(4 * _tickLength); + _vm->delay(4 * _vm->_tickLength); _screen->copyRegion(0, 184, 40, 184, 232, 16, 4, 0, Screen::CR_NO_P_CHECK); int cx = 264; int cy = 11; - for (int i = 0; i < 70 && !shouldQuit() && !skipFlag(); i++) { - uint32 end = _system->getMillis() + 3 * _tickLength; + for (int i = 0; i < 70 && !_vm->shouldQuit() && !_vm->skipFlag(); i++) { + uint32 end = _vm->_system->getMillis() + 3 * _vm->_tickLength; _screen->copyRegion(cx - 2, cy - 2, 0, 0, 48, 36, 4, 4, Screen::CR_NO_P_CHECK); _screen->drawShape(4, shp3[((i & 3) == 3) ? 1 : (i & 3)], cx, cy, 0); @@ -412,15 +366,15 @@ void EoBEngine::seq_waterdeepEntry() { cy++; for (int ii = 0; ii < 5; ii++) { - int s = _rnd.getRandomNumber(255) % 31; - _screen->drawShape(0, shp2[s], _introWdDsX[s] - 80, _introWdDsY[s] + 24, 0); + int s = _vm->_rnd.getRandomNumber(255) % 31; + _screen->drawShape(0, shp2[s], _wdDsX[s] - 80, _wdDsY[s] + 24, 0); } - if (!(_rnd.getRandomNumber(255) & 7)) - snd_playSoundEffect(_rnd.getRandomBit() ? 5 : 14); + if (!(_vm->_rnd.getRandomNumber(255) & 7)) + _vm->snd_playSoundEffect(_vm->_rnd.getRandomBit() ? 5 : 14); _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } for (int i = 0; i < 3; i++) { @@ -432,11 +386,11 @@ void EoBEngine::seq_waterdeepEntry() { delete[] shp2[i]; } -void EoBEngine::seq_king() { - if (shouldQuit() || skipFlag()) +void EoBIntroPlayer::king() { + if (_vm->shouldQuit() || _vm->skipFlag()) return; - _screen->loadBitmap(_introFilesKing[0], 5, 3, 0); + _screen->loadBitmap(_filesKing[0], 5, 3, 0); _screen->copyPage(3, 4); int x = 15; @@ -444,8 +398,8 @@ void EoBEngine::seq_king() { int w = 1; int h = 1; - for (int i = 0; i < 10 && !shouldQuit() && !skipFlag(); i++) { - uint32 end = _system->getMillis() + _tickLength; + for (int i = 0; i < 10 && !_vm->shouldQuit() && !_vm->skipFlag(); i++) { + uint32 end = _vm->_system->getMillis() + _vm->_tickLength; _screen->copyRegion(x << 3, y << 3, x << 3, y << 3, w << 3, h << 3, 4, 0, Screen::CR_NO_P_CHECK); if (x > 6) x --; @@ -458,10 +412,10 @@ void EoBEngine::seq_king() { if (y + h > 23) h = 23 - y; _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } - delay(25 * _tickLength); + _vm->delay(25 * _vm->_tickLength); uint8 *shp[4]; int16 dy[4]; @@ -471,19 +425,19 @@ void EoBEngine::seq_king() { static const uint8 advEncW[] = { 6, 6, 7, 6 }; static const int8 modY[] = { -4, -8, -2, -2, 1, 0, 0, 0 }; - _screen->loadBitmap(_introFilesKing[1], 5, 3, 0); + _screen->loadBitmap(_filesKing[1], 5, 3, 0); _screen->setCurPage(2); for (int i = 0; i < 4; i++) { shp[i] = _screen->encodeShape(advEncX[i], 0, advEncW[i], 98, true); - dy[i] = 180 + ((_rnd.getRandomNumber(255) & 3) << 3); + dy[i] = 180 + ((_vm->_rnd.getRandomNumber(255) & 3) << 3); stepY[i] = (i * 5) & 3; } _screen->copyPage(0, 4); - for (bool runloop = true; runloop && !shouldQuit() && !skipFlag();) { + for (bool runloop = true; runloop && !_vm->shouldQuit() && !_vm->skipFlag();) { runloop = false; - uint32 end = _system->getMillis() + 2 * _tickLength; + uint32 end = _vm->_system->getMillis() + 2 * _vm->_tickLength; for (int i = 0; i < 4; i++) { if (dy[i] <= 82) @@ -503,29 +457,29 @@ void EoBEngine::seq_king() { runloop = true; } - if (!(_rnd.getRandomNumber(255) & 3)) - snd_playSoundEffect(7); + if (!(_vm->_rnd.getRandomNumber(255) & 3)) + _vm->snd_playSoundEffect(7); _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } _screen->copyRegion(0, 96, 0, 160, 320, 32, 6, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delay(70 * _tickLength); + _vm->delay(70 * _vm->_tickLength); for (int i = 0; i < 4; i++) delete[] shp[i]; } -void EoBEngine::seq_hands() { - if (shouldQuit() || skipFlag()) +void EoBIntroPlayer::hands() { + if (_vm->shouldQuit() || _vm->skipFlag()) return; _screen->setCurPage(2); uint8 *shp1 = _screen->encodeShape(0, 140, 21, 60, true); uint8 *shp2 = _screen->encodeShape(21, 140, 12, 60, true); - _screen->loadBitmap(_introFilesHands[0], 3, 5, 0); + _screen->loadBitmap(_filesHands[0], 3, 5, 0); _screen->fillRect(0, 160, 319, 199, 12, 0); _screen->fillRect(0, 0, 191, 63, 157, 2); @@ -535,24 +489,24 @@ void EoBEngine::seq_hands() { _screen->copyRegion(0, 128, 0, 176, 320, 16, 6, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delay(15 * _tickLength); - snd_playSoundEffect(11); + _vm->delay(15 * _vm->_tickLength); + _vm->snd_playSoundEffect(11); - for (int i = -22; i <= 20 && !shouldQuit() && !skipFlag(); i += 4) { - uint32 end = _system->getMillis() + _tickLength; + for (int i = -22; i <= 20 && !_vm->shouldQuit() && !_vm->skipFlag(); i += 4) { + uint32 end = _vm->_system->getMillis() + _vm->_tickLength; _screen->fillRect(0, 0, 167, 63, 157); _screen->drawShape(2, shp1, i, 4, 0); _screen->drawShape(2, shp2, 105 - i, 4, 0); _screen->copyRegion(0, 0, 144, 32, 168, 64, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } - snd_playSoundEffect(10); + _vm->snd_playSoundEffect(10); delete[] shp1; delete[] shp2; - delay(15 * _tickLength); + _vm->delay(15 * _vm->_tickLength); _screen->setCurPage(4); shp1 = _screen->encodeShape(17, 0, 11, 120, true); @@ -564,35 +518,35 @@ void EoBEngine::seq_hands() { _screen->drawShape(2, shp1, 32, -80, 0); _screen->drawShape(2, shp2, 40, -16, 0); boxMorphTransition(18, 16, 10, 12, 0, 0, 17, 8, 17, 3, 25, 10); - delay(15 * _tickLength); + _vm->delay(15 * _vm->_tickLength); - for (int i = -80; i <= 0 && !shouldQuit() && !skipFlag(); i += 4) { - uint32 end = _system->getMillis() + _tickLength; + for (int i = -80; i <= 0 && !_vm->shouldQuit() && !_vm->skipFlag(); i += 4) { + uint32 end = _vm->_system->getMillis() + _vm->_tickLength; _screen->fillRect(0, 0, 135, 63, 157); _screen->drawShape(2, shp1, 32, i, 0); _screen->drawShape(2, shp2, 40, i + 64, 0); _screen->copyRegion(0, 0, 80, 96, 136, 64, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } - snd_playSoundEffect(12); - delay(5 * _tickLength); + _vm->snd_playSoundEffect(12); + _vm->delay(5 * _vm->_tickLength); - for (int i = 0; i > -54 && !shouldQuit() && !skipFlag(); i -= 4) { - uint32 end = _system->getMillis() + _tickLength; + for (int i = 0; i > -54 && !_vm->shouldQuit() && !_vm->skipFlag(); i -= 4) { + uint32 end = _vm->_system->getMillis() + _vm->_tickLength; _screen->fillRect(0, 0, 135, 63, 157); _screen->drawShape(2, shp3, 12, 64 + i, 0); _screen->drawShape(2, shp1, 32, i, 0); _screen->copyRegion(0, 0, 80, 96, 136, 64, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } delete[] shp1; delete[] shp2; delete[] shp3; - delay(15 * _tickLength); + _vm->delay(15 * _vm->_tickLength); _screen->setCurPage(4); shp1 = _screen->encodeShape(0, 0, 17, 136, true); @@ -603,23 +557,23 @@ void EoBEngine::seq_hands() { _screen->drawShape(2, shp1, -56, -56, 0); _screen->drawShape(2, shp2, 52, 49, 0); boxMorphTransition(9, 6, 0, 0, 0, 0, 18, 12, 8, 11, 21, 10); - delay(15 * _tickLength); - snd_playSoundEffect(11); + _vm->delay(15 * _vm->_tickLength); + _vm->snd_playSoundEffect(11); - for (int i = -56; i <= -8 && !shouldQuit() && !skipFlag(); i += 4) { - uint32 end = _system->getMillis() + _tickLength; + for (int i = -56; i <= -8 && !_vm->shouldQuit() && !_vm->skipFlag(); i += 4) { + uint32 end = _vm->_system->getMillis() + _vm->_tickLength; _screen->fillRect(0, 0, 143, 95, 157); _screen->drawShape(2, shp1, i, i, 0); _screen->drawShape(2, shp2, (i == -8) ? 55 : 52, (i == -8) ? 52 : 49, 0); _screen->copyRegion(0, 0, 0, 0, 144, 96, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } - snd_playSoundEffect(10); + _vm->snd_playSoundEffect(10); delete[] shp1; delete[] shp2; - delay(30 * _tickLength); + _vm->delay(30 * _vm->_tickLength); _screen->setCurPage(4); shp1 = _screen->encodeShape(28, 0, 11, 40, true); @@ -629,46 +583,46 @@ void EoBEngine::seq_hands() { _screen->fillRect(0, 0, 87, 112, 157); _screen->drawShape(2, shp2, 0, 90, 0); boxMorphTransition(20, 13, 15, 6, 0, 0, 11, 14, 0, 0, 24, 16); - delay(15 * _tickLength); + _vm->delay(15 * _vm->_tickLength); int dy = 90; - for (int i = -40; i <= 0 && !shouldQuit() && !skipFlag(); i += 4) { - uint32 end = _system->getMillis() + _tickLength; + for (int i = -40; i <= 0 && !_vm->shouldQuit() && !_vm->skipFlag(); i += 4) { + uint32 end = _vm->_system->getMillis() + _vm->_tickLength; _screen->fillRect(0, 0, 87, 112, 157); _screen->drawShape(2, shp2, 0, dy, 0); _screen->copyRegion(0, 0, 120, 48, 88, 112, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); dy -= 5; } - snd_playSoundEffect(13); + _vm->snd_playSoundEffect(13); - for (int i = -40; i <= 0 && !shouldQuit() && !skipFlag(); i += 4) { - uint32 end = _system->getMillis() + _tickLength; + for (int i = -40; i <= 0 && !_vm->shouldQuit() && !_vm->skipFlag(); i += 4) { + uint32 end = _vm->_system->getMillis() + _vm->_tickLength; _screen->fillRect(0, 0, 87, 39, 157); _screen->drawShape(2, shp1, 0, i, 0); _screen->copyRegion(0, 0, 120, 48, 88, 112, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } delete[] shp1; delete[] shp2; - delay(48 * _tickLength); + _vm->delay(48 * _vm->_tickLength); } -void EoBEngine::seq_waterdeepExit() { - if (shouldQuit() || skipFlag()) +void EoBIntroPlayer::waterdeepExit() { + if (_vm->shouldQuit() || _vm->skipFlag()) return; uint8 *shp2[31]; uint8 *shp3[3]; - _screen->loadBitmap(_introFilesWdExit[0], 5, 3, 0); + _screen->loadBitmap(_filesWdExit[0], 5, 3, 0); _screen->setCurPage(2); for (int i = 0; i < 31; i++) - shp2[i] = _screen->encodeShape(_introWdEncodeX[i], 136 + (_introWdEncodeY[i] << 3), _introWdEncodeWH[i], _introWdEncodeWH[i] << 3, true); + shp2[i] = _screen->encodeShape(_wdEncodeX[i], 136 + (_wdEncodeY[i] << 3), _wdEncodeWH[i], _wdEncodeWH[i] << 3, true); for (int i = 0; i < 3; i++) shp3[i] = _screen->encodeShape(5 * i + 15, 152, 5, 32, true); uint8 *shp1 = _screen->encodeShape(31, 136, 5, 32, true); @@ -680,8 +634,8 @@ void EoBEngine::seq_waterdeepExit() { int cx = 140; int cy = 128; - for (int i = 0; i < 70 && !shouldQuit() && !skipFlag(); i++) { - uint32 end = _system->getMillis() + 3 * _tickLength; + for (int i = 0; i < 70 && !_vm->shouldQuit() && !_vm->skipFlag(); i++) { + uint32 end = _vm->_system->getMillis() + 3 * _vm->_tickLength; int fx = cx - 2; if (fx < 160) fx = 160; @@ -698,15 +652,15 @@ void EoBEngine::seq_waterdeepExit() { cy--; for (int ii = 0; ii < 5; ii++) { - int s = _rnd.getRandomNumber(255) % 31; - _screen->drawShape(0, shp2[s], _introWdDsX[s] - 80, _introWdDsY[s] + 24, 0); + int s = _vm->_rnd.getRandomNumber(255) % 31; + _screen->drawShape(0, shp2[s], _wdDsX[s] - 80, _wdDsY[s] + 24, 0); } - if (!(_rnd.getRandomNumber(255) & 7)) - snd_playSoundEffect(_rnd.getRandomBit() ? 5 : 14); + if (!(_vm->_rnd.getRandomNumber(255) & 7)) + _vm->snd_playSoundEffect(_vm->_rnd.getRandomBit() ? 5 : 14); _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } for (int i = 0; i < 3; i++) @@ -720,19 +674,19 @@ void EoBEngine::seq_waterdeepExit() { _screen->fillRect(0, 168, 319, 199, 12, 0); _screen->copyRegion(0, 136, 0, 0, 48, 36, 0, 4, Screen::CR_NO_P_CHECK); - loadSetIntroPalette(_introFilesWdExit[1]); - _screen->loadBitmap(_introFilesWdExit[2], 3, 5, 0); + loadAndSetPalette(_filesWdExit[1]); + _screen->loadBitmap(_filesWdExit[2], 3, 5, 0); _screen->copyPage(5, 2); whirlTransition(); - delay(6 * _tickLength); + _vm->delay(6 * _vm->_tickLength); _screen->copyRegion(0, 144, 0, 184, 320, 16, 6, 0, Screen::CR_NO_P_CHECK); cx = 0; cy = 136; int dy = 0; - for (int i = 0; i < 19 && !shouldQuit() && !skipFlag(); i++) { - uint32 end = _system->getMillis() + _tickLength; + for (int i = 0; i < 19 && !_vm->shouldQuit() && !_vm->skipFlag(); i++) { + uint32 end = _vm->_system->getMillis() + _vm->_tickLength; _screen->copyRegion(cx, cy, 80, dy + 16, 160, 8, 2, 0, Screen::CR_NO_P_CHECK); cy += 8; dy += 8; @@ -741,199 +695,142 @@ void EoBEngine::seq_waterdeepExit() { cy = 0; } _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } - snd_playSong(3); - delay(60 * _tickLength); + _vm->snd_playSong(3); + _vm->delay(60 * _vm->_tickLength); - for (int i = 0; i < 56 && !shouldQuit() && !skipFlag(); i++) { - uint32 end = _system->getMillis() + _tickLength; + for (int i = 0; i < 56 && !_vm->shouldQuit() && !_vm->skipFlag(); i++) { + uint32 end = _vm->_system->getMillis() +_vm->_tickLength; _screen->copyRegion(0, 136 + i, 80, 16, 160, 56 - i, 2, 0, Screen::CR_NO_P_CHECK); _screen->copyRegion(160, 0, 80, 72 - i, 160, 96 + i, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } - for (int i = 1; i < 48 && !shouldQuit() && !skipFlag(); i++) { - uint32 end = _system->getMillis() + _tickLength; + for (int i = 1; i < 48 && !_vm->shouldQuit() && !_vm->skipFlag(); i++) { + uint32 end = _vm->_system->getMillis() + _vm->_tickLength; _screen->copyRegion(160, i, 80, 16, 160, 152, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } - _screen->loadBitmap(_introFilesWdExit[3], 3, 5, 0); + _screen->loadBitmap(_filesWdExit[3], 3, 5, 0); _screen->copyPage(5, 2); - delay(30 * _tickLength); + _vm->delay(30 * _vm->_tickLength); _screen->setCurPage(0); _screen->fillRect(0, 16, 319, 31, 12); _screen->fillRect(0, 136, 319, 199, 12); _screen->copyRegion(0, 0, 80, 32, 160, 120, 2, 0, Screen::CR_NO_P_CHECK); - loadSetIntroPalette(_introFilesWdExit[4]); + loadAndSetPalette(_filesWdExit[4]); _screen->updateScreen(); - delay(50 * _tickLength); + _vm->delay(50 * _vm->_tickLength); } -void EoBEngine::seq_tunnel() { - if (shouldQuit() || skipFlag()) +void EoBIntroPlayer::tunnel() { + if (_vm->shouldQuit() || _vm->skipFlag()) return; _screen->setCurPage(4); uint8 *shp2 = _screen->encodeShape(20, 0, 20, 120, true); uint8 *shp1 = _screen->encodeShape(0, 0, 20, 120, true); - drawBlockObject(1, 4, shp2, 160, 0, 0); - drawBlockObject(1, 4, shp1, 0, 0, 0); + _vm->drawBlockObject(1, 4, shp2, 160, 0, 0); + _vm->drawBlockObject(1, 4, shp1, 0, 0, 0); delete[] shp1; delete[] shp2; - for (int i = 0; i < 3 && !shouldQuit() && !skipFlag(); i++) { - uint32 end = _system->getMillis() + 8 * _tickLength; + for (int i = 0; i < 3 && !_vm->shouldQuit() && !_vm->skipFlag(); i++) { + uint32 end = _vm->_system->getMillis() + 8 * _vm->_tickLength; _screen->copyRegion(0, 0, 80, 32, 160, 120, 4, 0, Screen::CR_NO_P_CHECK); - snd_playSoundEffect(7); + _vm->snd_playSoundEffect(7); _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); _screen->copyRegion(0, 0, 80, 32, 160, 120, 2, 0, Screen::CR_NO_P_CHECK); - snd_playSoundEffect(7); - end = _system->getMillis() + 8 * _tickLength; + _vm->snd_playSoundEffect(7); + end = _vm->_system->getMillis() + 8 * _vm->_tickLength; _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } _screen->copyRegion(0, 160, 0, 184, 320, 16, 6, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delay(18 * _tickLength); + _vm->delay(18 * _vm->_tickLength); _screen->copyRegion(160, 0, 80, 32, 160, 120, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delay(5 * _tickLength); + _vm->delay(5 * _vm->_tickLength); _screen->copyRegion(0, 122, 80, 32, 160, 60, 2, 0, Screen::CR_NO_P_CHECK); _screen->copyRegion(160, 122, 80, 92, 160, 60, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delay(5 * _tickLength); + _vm->delay(5 * _vm->_tickLength); _screen->copyRegion(160, 0, 80, 32, 160, 120, 4, 0, Screen::CR_NO_P_CHECK); for (int i = 0; i < 6; i++) _screen->copyRegion(i * 48, 185, 56, (i << 3) + 24, 48, 8, 2, 2, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delay(5 * _tickLength); + _vm->delay(5 * _vm->_tickLength); _screen->copyRegion(0, 0, 80, 32, 160, 120, 2, 0, Screen::CR_NO_P_CHECK); - _screen->loadBitmap(_introFilesTunnel[0], 5, 3, 0); + _screen->loadBitmap(_filesTunnel[0], 5, 3, 0); _screen->copyPage(3, 4); _screen->updateScreen(); - delay(40 * _tickLength); + _vm->delay(40 * _vm->_tickLength); _screen->copyRegion(264, 0, 136, 56, 48, 48, 4, 0, Screen::CR_NO_P_CHECK); - snd_playSoundEffect(8); + _vm->snd_playSoundEffect(8); _screen->copyRegion(0, 0, 0, 0, 320, 184, 0, 2, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delay(16 * _tickLength); - snd_playSoundEffect(4); + _vm->delay(16 * _vm->_tickLength); + _vm->snd_playSoundEffect(4); - for (int i = 0; i < 30 && !shouldQuit() && !skipFlag(); i++) { - uint32 end = _system->getMillis() + _tickLength; + for (int i = 0; i < 30 && !_vm->shouldQuit() && !_vm->skipFlag(); i++) { + uint32 end = _vm->_system->getMillis() + _vm->_tickLength; if (i == 0) _screen->fillRect(0, 168, 319, 199, 12, 0); - _screen->copyRegion(80, 25 + (_rnd.getRandomNumber(255) & 7), 80, 24, 160, 144, 2, 0, Screen::CR_NO_P_CHECK); + _screen->copyRegion(80, 25 + (_vm->_rnd.getRandomNumber(255) & 7), 80, 24, 160, 144, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } - snd_playSoundEffect(9); + _vm->snd_playSoundEffect(9); - for (int i = 0; i < 6 && !shouldQuit() && !skipFlag(); i++) { - uint32 end = _system->getMillis() + _tickLength; - _screen->copyRegion(_introTvlX1[i] << 3, _introTvlY1[i], _introTvlX2[i] << 3, _introTvlY2[i], _introTvlW[i] << 3, _introTvlH[i], 4, 2, Screen::CR_NO_P_CHECK); - for (int ii = 0; ii < 4 && !shouldQuit() && !skipFlag(); ii++) { + for (int i = 0; i < 6 && !_vm->shouldQuit() && !_vm->skipFlag(); i++) { + uint32 end = _vm->_system->getMillis() + _vm->_tickLength; + _screen->copyRegion(_tvlX1[i] << 3, _tvlY1[i], _tvlX2[i] << 3, _tvlY2[i], _tvlW[i] << 3, _tvlH[i], 4, 2, Screen::CR_NO_P_CHECK); + for (int ii = 0; ii < 4 && !_vm->shouldQuit() && !_vm->skipFlag(); ii++) { _screen->updateScreen(); - delayUntil(end); - end = _system->getMillis() + _tickLength; - _screen->copyRegion(80, 25 + (_rnd.getRandomNumber(255) & 7), 80, 24, 160, 144, 2, 0, Screen::CR_NO_P_CHECK); + _vm->delayUntil(end); + end = _vm->_system->getMillis() + _vm->_tickLength; + _screen->copyRegion(80, 25 + (_vm->_rnd.getRandomNumber(255) & 7), 80, 24, 160, 144, 2, 0, Screen::CR_NO_P_CHECK); } } _screen->copyRegion(0, 0, 0, 0, 320, 168, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delay(40 * _tickLength); + _vm->delay(40 * _vm->_tickLength); - _screen->loadBitmap(_introFilesTunnel[1], 5, 3, 0); + _screen->loadBitmap(_filesTunnel[1], 5, 3, 0); _screen->copyPage(3, 4); - snd_playSoundEffect(6); + _vm->snd_playSoundEffect(6); _screen->copyRegion(0, 0, 80, 32, 160, 120, 4, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delay(2 * _tickLength); + _vm->delay(2 * _vm->_tickLength); _screen->copyRegion(160, 0, 80, 32, 160, 120, 4, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); - delay(2 * _tickLength); + _vm->delay(2 * _vm->_tickLength); _screen->copyRegion(0, 120, 80, 30, 160, 64, 4, 0, Screen::CR_NO_P_CHECK); _screen->copyRegion(160, 120, 80, 94, 160, 64, 4, 0, Screen::CR_NO_P_CHECK); _screen->copyRegion(0, 176, 0, 184, 320, 16, 6, 0, Screen::CR_NO_P_CHECK); _screen->setCurPage(0); _screen->updateScreen(); - delay(50 * _tickLength); + _vm->delay(50 * _vm->_tickLength); } -void EoBEngine::seq_xdeath() { - uint8 *shapes1[5]; - uint8 *shapes2; - - _screen->loadShapeSetBitmap("XDEATH2", 5, 3); - for (int i = 0; i < 4; i++) - shapes1[i] = _screen->encodeShape(i / 2 * 14, i / 2 * 88, 14, 88, true); - _screen->loadShapeSetBitmap("XDEATH3", 5, 3); - shapes2 = _screen->encodeShape(22, 0, 16, 95, true); - _screen->loadEoBBitmap("XDEATH1", 0, 5, 3, -1); - _screen->setCurPage(0); - - for (int i = 0; i < 10; i++) { - if (i == 2) - snd_playSoundEffect(72); - else if (i == 4 || i == 6) - snd_playSoundEffect(54); - else - snd_playSoundEffect(34); - - if (i < 6) { - _screen->copyRegion((i % 3) * 104, i / 3 * 88, 32, 10, 104, 88, 2, 0, Screen::CR_NO_P_CHECK); - } else { - snd_playSoundEffect(42); - _screen->drawShape(0, shapes1[i - 6], 32, 10, 0); - } - - _screen->updateScreen(); - delay(4 * _tickLength); - } - - const ScreenDim *dm = _screen->getScreenDim(5); - _screen->modifyScreenDim(5, dm->sx, 8, dm->w, dm->h); - _screen->copyRegion(0, 0, 0, 0, 176, 120, 0, 5, Screen::CR_NO_P_CHECK); - - for (int i = 0; i < 19; i++) { - snd_playSoundEffect(119); - _screen->copyRegion(0, 0, 0, 0, 176, 120, 5, 2, Screen::CR_NO_P_CHECK); - _screen->drawShape(2, shapes2, 24, i * 5 - 90, 5); - _screen->copyRegion(0, 0, 0, 0, 176, 120, 2, 0, Screen::CR_NO_P_CHECK); - _screen->updateScreen(); - delay(2 * _tickLength); - } - - _screen->modifyScreenDim(5, dm->sx, 0, dm->w, dm->h); - - snd_playSoundEffect(5); - delay(60 * _tickLength); - - for (int i = 0; i < 4; i++) - delete[] shapes1[i]; - delete[] shapes2; - - gui_drawPlayField(false); - gui_drawAllCharPortraitsWithStats(); -} - -void EoBEngine::loadSetIntroPalette(const char *filename) { +void EoBIntroPlayer::loadAndSetPalette(const char *filename) { _screen->loadPalette(filename, _screen->getPalette(0)); _screen->getPalette(0).fill(0, 1, 0); _screen->setScreenPalette(_screen->getPalette(0)); } -void EoBEngine::copyBlurRegion(int x1, int y1, int x2, int y2, int w, int h, int step) { +void EoBIntroPlayer::copyBlurRegion(int x1, int y1, int x2, int y2, int w, int h, int step) { const uint8 *ptr2 = _screen->getCPagePtr(3) + y1 * 320 + x1; if (step == 1) { @@ -993,7 +890,7 @@ void EoBEngine::copyBlurRegion(int x1, int y1, int x2, int y2, int w, int h, int } } -void EoBEngine::boxMorphTransition(int targetDestX, int targetDestY, int targetFinalX, int targetFinalY, int targetSrcX, int targetSrcY, int targetFinalW, int targetFinalH, int originX1, int originY1, int originW, int originH) { +void EoBIntroPlayer::boxMorphTransition(int targetDestX, int targetDestY, int targetFinalX, int targetFinalY, int targetSrcX, int targetSrcY, int targetFinalW, int targetFinalH, int originX1, int originY1, int originW, int originH) { int originX2 = originX1 + originW; int originY2 = originY1 + originH; if (originY2 > 21) @@ -1001,8 +898,8 @@ void EoBEngine::boxMorphTransition(int targetDestX, int targetDestY, int targetF int w = 1; int h = 1; - for (bool runloop = true; runloop && !shouldQuit() && !skipFlag();) { - uint32 end = _system->getMillis() + _tickLength; + for (bool runloop = true; runloop && !_vm->shouldQuit() && !_vm->skipFlag();) { + uint32 end = _vm->_system->getMillis() + _vm->_tickLength; _screen->copyRegion(targetSrcX << 3, targetSrcY << 3, targetDestX << 3, targetDestY << 3, w << 3, h << 3, 2, 0, Screen::CR_NO_P_CHECK); if (originX1 < targetDestX) _screen->copyRegion(312, 0, originX1 << 3, 0, 8, 176, 0, 0, Screen::CR_NO_P_CHECK); @@ -1046,14 +943,14 @@ void EoBEngine::boxMorphTransition(int targetDestX, int targetDestY, int targetF originY2--; _screen->updateScreen(); - delayUntil(end); + _vm->delayUntil(end); } } -void EoBEngine::whirlTransition() { +void EoBIntroPlayer::whirlTransition() { for (int i = 0; i < 2; i++) { for (int ii = 0; ii < 8; ii++) { - uint32 e = _system->getMillis() + 3; + uint32 e = _vm->_system->getMillis() + 3; if (ii & 1) { for (int iii = i + ii; iii < 320; iii += 8) _screen->drawClippedLine(iii, 0, iii, 199, 12); @@ -1062,11 +959,185 @@ void EoBEngine::whirlTransition() { _screen->drawClippedLine(0, iii, 319, iii, 12); } _screen->updateScreen(); - uint32 c = _system->getMillis(); + uint32 c = _vm->_system->getMillis(); if (e > c) - _system->delayMillis(e - c); + _vm->_system->delayMillis(e - c); + } + } +} + +int EoBEngine::mainMenu() { + int menuChoice = _menuChoiceInit; + _menuChoiceInit = 0; + + Screen::FontId of = _screen->_currentFont; + + while (menuChoice >= 0 && !shouldQuit()) { + switch (menuChoice) { + case 0: { + _screen->loadPalette("EOBPAL.COL", _screen->getPalette(0)); + _screen->loadEoBBitmap("INTRO", 0, 5, 3, 2); + _screen->setScreenPalette(_screen->getPalette(0)); + _screen->_curPage = 2; + of = _screen->setFont(Screen::FID_6_FNT); + Common::String versionString(Common::String::format("ScummVM %s", gScummVMVersion)); + _screen->printText(versionString.c_str(), 280 - versionString.size() * 6, 153, _screen->getPagePixel(2, 0, 0), 0); + _screen->setFont(of); + _screen->fillRect(0, 159, 319, 199, _screen->getPagePixel(2, 0, 0)); + gui_drawBox(77, 165, 173, 29, 13, 14, 12); + gui_drawBox(76, 164, 175, 31, 13, 14, -1); + _screen->_curPage = 0; + _screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); + _allowImport = true; + menuChoice = mainMenuLoop(); + _allowImport = false; + } break; + + case 1: + // load game in progress + // + menuChoice = -1; + break; + + case 2: + // create new party + menuChoice = -2; + break; + + case 3: + // quit + menuChoice = -5; + break; + + case 4: + // intro + _sound->loadSoundFile("SOUND"); + _screen->hideMouse(); + seq_playIntro(); + _screen->showMouse(); + _sound->loadSoundFile("ADLIB"); + menuChoice = 0; + break; } } + + return shouldQuit() ? -5 : menuChoice; +} + +int EoBEngine::mainMenuLoop() { + int sel = -1; + do { + _screen->setScreenDim(28); + _gui->simpleMenu_setup(8, 0, _mainMenuStrings, -1, 0, 0); + + while (sel == -1 && !shouldQuit()) + sel = _gui->simpleMenu_process(8, _mainMenuStrings, 0, -1, 0); + } while ((sel < 0 || sel > 5) && !shouldQuit()); + + return sel + 1; +} + +void EoBEngine::seq_playIntro() { + EoBIntroPlayer(this, _screen).start(); +} + +void EoBEngine::seq_playFinale() { + Common::SeekableReadStream *s = _res->createReadStream("TEXT.DAT"); + _screen->loadFileDataToPage(s, 5, 32000); + delete s; + + snd_playSoundEffect(20); + + _txt->resetPageBreakString(); + _txt->setWaitButtonMode(1); + _txt->setupField(12, true); + gui_drawBox(0, 0, 176, 175, guiSettings()->colors.frame1, guiSettings()->colors.frame2, guiSettings()->colors.fill); + _txt->printDialogueText(51, _moreStrings[0]); + + if (!checkScriptFlags(0x1ffe)) { + _screen->fadeToBlack(); + return; + } + + _txt->printDialogueText(_finBonusStrings[0]); + for (int i = 0; i < 6; i++) { + _txt->printDialogueText(_finBonusStrings[1]); + if (_characters[i].flags & 1) + _txt->printDialogueText(_characters[i].name); + } + + uint32 password = 0; + for (int i = 0; i < 4; i++) { + if (!(_characters[i].flags & 1)) + continue; + + int len = strlen(_characters[i].name); + for (int ii = 0; ii < len; ii++) { + uint32 c = _characters[i].name[ii]; + password += (c * c); + } + } + + _txt->printDialogueText(Common::String::format(_finBonusStrings[2], password).c_str(), true); + _screen->fadeToBlack(); +} + +void EoBEngine::seq_xdeath() { + uint8 *shapes1[5]; + uint8 *shapes2; + + _screen->loadShapeSetBitmap("XDEATH2", 5, 3); + for (int i = 0; i < 4; i++) + shapes1[i] = _screen->encodeShape(i / 2 * 14, i / 2 * 88, 14, 88, true); + _screen->loadShapeSetBitmap("XDEATH3", 5, 3); + shapes2 = _screen->encodeShape(22, 0, 16, 95, true); + _screen->loadEoBBitmap("XDEATH1", 0, 5, 3, -1); + _screen->setCurPage(0); + + for (int i = 0; i < 10; i++) { + if (i == 2) + snd_playSoundEffect(72); + else if (i == 4 || i == 6) + snd_playSoundEffect(54); + else + snd_playSoundEffect(34); + + if (i < 6) { + _screen->copyRegion((i % 3) * 104, i / 3 * 88, 32, 10, 104, 88, 2, 0, Screen::CR_NO_P_CHECK); + } else { + snd_playSoundEffect(42); + _screen->drawShape(0, shapes1[i - 6], 32, 10, 0); + } + + _screen->updateScreen(); + delay(4 * _tickLength); + } + + const ScreenDim *dm = _screen->getScreenDim(5); + _screen->modifyScreenDim(5, dm->sx, 8, dm->w, dm->h); + _screen->copyRegion(0, 0, 0, 0, 176, 120, 0, 5, Screen::CR_NO_P_CHECK); + + for (int i = 0; i < 19; i++) { + snd_playSoundEffect(119); + _screen->copyRegion(0, 0, 0, 0, 176, 120, 5, 2, Screen::CR_NO_P_CHECK); + _screen->drawShape(2, shapes2, 24, i * 5 - 90, 5); + _screen->copyRegion(0, 0, 0, 0, 176, 120, 2, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); + delay(2 * _tickLength); + } + + _screen->modifyScreenDim(5, dm->sx, 0, dm->w, dm->h); + + snd_playSoundEffect(5); + delay(60 * _tickLength); + + for (int i = 0; i < 4; i++) + delete[] shapes1[i]; + delete[] shapes2; + + gui_drawPlayField(false); + gui_drawAllCharPortraitsWithStats(); } } // End of namespace Kyra diff --git a/engines/kyra/staticres_eob.cpp b/engines/kyra/staticres_eob.cpp index 638a185367..a65ade7aee 100644 --- a/engines/kyra/staticres_eob.cpp +++ b/engines/kyra/staticres_eob.cpp @@ -1016,27 +1016,6 @@ void EoBEngine::initStaticResource() { _mainMenuStrings = _staticres->loadStrings(kEoB1MainMenuStrings, temp); _finBonusStrings = _staticres->loadStrings(kEoB1BonusStrings, temp); - _introFilesOpening = _staticres->loadStrings(kEoB1IntroFilesOpening, temp); - _introFilesTower = _staticres->loadStrings(kEoB1IntroFilesTower, temp); - _introFilesOrb = _staticres->loadStrings(kEoB1IntroFilesOrb, temp); - _introFilesWdEntry = _staticres->loadStrings(kEoB1IntroFilesWdEntry, temp); - _introFilesKing = _staticres->loadStrings(kEoB1IntroFilesKing, temp); - _introFilesHands = _staticres->loadStrings(kEoB1IntroFilesHands, temp); - _introFilesWdExit = _staticres->loadStrings(kEoB1IntroFilesWdExit, temp); - _introFilesTunnel = _staticres->loadStrings(kEoB1IntroFilesTunnel, temp); - _introOpeningFrmDelay = _staticres->loadRawData(kEoB1IntroOpeningFrmDelay, temp); - _introWdEncodeX = _staticres->loadRawData(kEoB1IntroWdEncodeX, temp); - _introWdEncodeY = _staticres->loadRawData(kEoB1IntroWdEncodeY, temp); - _introWdEncodeWH = _staticres->loadRawData(kEoB1IntroWdEncodeWH, temp); - _introWdDsX = _staticres->loadRawDataBe16(kEoB1IntroWdDsX, temp); - _introWdDsY = _staticres->loadRawData(kEoB1IntroWdDsY, temp); - _introTvlX1 = _staticres->loadRawData(kEoB1IntroTvlX1, temp); - _introTvlY1 = _staticres->loadRawData(kEoB1IntroTvlY1, temp); - _introTvlX2 = _staticres->loadRawData(kEoB1IntroTvlX2, temp); - _introTvlY2 = _staticres->loadRawData(kEoB1IntroTvlY2, temp); - _introTvlW = _staticres->loadRawData(kEoB1IntroTvlW, temp); - _introTvlH = _staticres->loadRawData(kEoB1IntroTvlH, temp); - _doorShapeEncodeDefs = _staticres->loadRawData(kEoB1DoorShapeDefs, temp); _doorSwitchShapeEncodeDefs = _staticres->loadRawData(kEoB1DoorSwitchShapeDefs, temp); _doorSwitchCoords = _staticres->loadRawData(kEoB1DoorSwitchCoords, temp); -- cgit v1.2.3