diff options
author | Paul Gilbert | 2014-12-27 09:07:25 +1100 |
---|---|---|
committer | Paul Gilbert | 2014-12-27 09:07:25 +1100 |
commit | 537da8b7b9090ef9be2ea9b4c3ef2b76461364ab (patch) | |
tree | 48f57e7650bb2de030347f72999056bb9bf8d80f | |
parent | 1d62e224b98e4d2c9736c4965b3da5735b32c022 (diff) | |
download | scummvm-rg350-537da8b7b9090ef9be2ea9b4c3ef2b76461364ab.tar.gz scummvm-rg350-537da8b7b9090ef9be2ea9b4c3ef2b76461364ab.tar.bz2 scummvm-rg350-537da8b7b9090ef9be2ea9b4c3ef2b76461364ab.zip |
XEEN: Second Dark Side title screen, beginnings of starting sequence
-rw-r--r-- | engines/xeen/darkside/darkside_game.cpp | 112 | ||||
-rw-r--r-- | engines/xeen/darkside/darkside_game.h | 8 | ||||
-rw-r--r-- | engines/xeen/screen.cpp | 32 | ||||
-rw-r--r-- | engines/xeen/screen.h | 11 |
4 files changed, 137 insertions, 26 deletions
diff --git a/engines/xeen/darkside/darkside_game.cpp b/engines/xeen/darkside/darkside_game.cpp index c067242431..3dd4c0ea30 100644 --- a/engines/xeen/darkside/darkside_game.cpp +++ b/engines/xeen/darkside/darkside_game.cpp @@ -34,13 +34,31 @@ void DarkSideEngine::playGame() { playGame(); } +bool DarkSideEngine::pause(int amount) { + while (!shouldQuit() && _events->timeElapsed() < amount) { + _events->pollEventsAndWait(); + if (_events->isKeyMousePressed()) + return true; + } + + return shouldQuit(); +} + void DarkSideEngine::darkSideIntro() { - showTitle(); + showTitle1(); if (shouldQuit()) return; + + showTitle2(); + if (shouldQuit()) + return; + + // TODO: Only show startup if not seen before + showStartSequence(); } -void DarkSideEngine::showTitle() { +void DarkSideEngine::showTitle1() { + // TODO: Starting method, and sound //sub_28F40 _screen->loadPalette("dark.pal"); SpriteResource nwc[4] = { @@ -87,11 +105,8 @@ void DarkSideEngine::showTitle() { ++nwcFrame; } - while (!shouldQuit() && _events->timeElapsed() < 2) { - _events->pollEventsAndWait(); - if (_events->isKeyMousePressed()) - return; - } + if (pause(2)) + return; } // Loop for dragon using flyspray @@ -121,22 +136,87 @@ void DarkSideEngine::showTitle() { break; } - while (!shouldQuit() && _events->timeElapsed() < 2) { + if (pause(2)) + return; + } + + // Pause for a bit + pause(10); +} + +void DarkSideEngine::showTitle2() { + _screen->fadeOut(8); + //TODO: Stuff + + _screen->loadBackground("jvc.raw"); + _screen->draw(); + _screen->fade(4); + + _events->updateGameCounter(); + pause(60); +} + +void DarkSideEngine::showStartSequence() { + _screen->fadeOut(8); + _screen->loadBackground("pyramid2.raw"); + _screen->loadPage(0); + _screen->loadPage(1); + _screen->loadBackground("pyramid3.raw"); + _screen->saveScreen(1); + + SpriteResource sprites[3] = { + SpriteResource("title.int"), SpriteResource("pyratop.int"), SpriteResource("pyramid.int") + }; + File voc[2] = { + File("pharoh1a.voc"), File("pharoh1b.voc") + }; + + _screen->vertMerge(SCREEN_HEIGHT); + _screen->loadPage(0); + _screen->loadPage(1); + + int yp = 0; + int frame = 0; + int idx1 = 0; + bool skipElapsed = false; + uint32 timeExpired = 0; + bool fadeFlag = true; + + for (int idx = 200; idx > 0; ) { + _events->updateGameCounter(); + _screen->vertMerge(yp); + + sprites[0].draw(*_screen, 0); + if (frame) + sprites[0].draw(*_screen, frame); + + idx1 = (idx1 + 1) % 4; + if (!idx1) + frame = (frame + 1) % 10; + + _screen->draw(); + if (!skipElapsed) { + timeExpired = MAX(_events->timeElapsed(), (uint32)1); + skipElapsed = true; + } + + idx -= timeExpired; + frame = MIN(frame + timeExpired, (uint)200); + + while (_events->timeElapsed() < 1) { _events->pollEventsAndWait(); if (_events->isKeyMousePressed()) return; } } - // Pause fora bit - while (!shouldQuit() && _events->timeElapsed() < 10) { - _events->pollEventsAndWait(); - if (_events->isKeyMousePressed()) - return; - } - - // TODO: Stop sound and music + _screen->vertMerge(SCREEN_HEIGHT); + _screen->saveScreen(1); + _screen->draw(); + _screen->freePages(); + _events->updateGameCounter(); + pause(30); } } // End of namespace Xeen diff --git a/engines/xeen/darkside/darkside_game.h b/engines/xeen/darkside/darkside_game.h index 5574d459e1..39ec87fa1c 100644 --- a/engines/xeen/darkside/darkside_game.h +++ b/engines/xeen/darkside/darkside_game.h @@ -29,7 +29,13 @@ namespace Xeen { class DarkSideEngine : virtual public XeenEngine { private: - void showTitle(); + bool pause(int amount); + + void showTitle1(); + + void showTitle2(); + + void showStartSequence(); protected: void darkSideIntro(); diff --git a/engines/xeen/screen.cpp b/engines/xeen/screen.cpp index 5276b6971f..699e13e8ce 100644 --- a/engines/xeen/screen.cpp +++ b/engines/xeen/screen.cpp @@ -32,7 +32,7 @@ namespace Xeen { * Constructor */ Screen::Screen(XeenEngine *vm) : _vm(vm) { - _fadeMode = false; + _fadeIn = false; create(SCREEN_WIDTH, SCREEN_HEIGHT); } @@ -128,6 +128,11 @@ void Screen::loadPage(int pageNum) { blitTo(_pages[pageNum]); } +void Screen::freePages() { + _pages[0].free(); + _pages[1].free(); +} + /** * Merge the two pages along a horizontal split point */ @@ -181,19 +186,19 @@ void Screen::drawScreen() { } void Screen::fade(int step) { - _fadeMode = true; + _fadeIn = true; fadeInner(step); } -void Screen::fade2(int step) { - _fadeMode = false; +void Screen::fadeOut(int step) { + _fadeIn = false; fadeInner(step); } void Screen::fadeInner(int step) { - for (int idx = 128; idx != 0 && !_vm->shouldQuit(); idx -= step) { - int val = idx; - bool flag = !_fadeMode; + for (int idx = 128; idx >= 0 && !_vm->shouldQuit(); idx -= step) { + int val = MAX(idx, 0); + bool flag = !_fadeIn; if (!flag) { val = -(val - 128); flag = step != 0x81; @@ -222,4 +227,17 @@ void Screen::updatePalette(const byte *pal, int start, int count16) { g_system->getPaletteManager()->setPalette(pal, start, count16 * 16); } +void Screen::saveScreen(int slot) { + assert(slot > 0 && slot < 10); + _savedScreens[slot - 1].copyFrom(*this); +} + +void Screen::restoreScreen(int slot) { + assert(slot > 0 && slot < 10); + + _savedScreens[slot - 1].blitTo(*this); + _savedScreens[slot - 1].free(); +} + + } // End of namespace Xeen diff --git a/engines/xeen/screen.h b/engines/xeen/screen.h index 02fe74607c..72d9da0437 100644 --- a/engines/xeen/screen.h +++ b/engines/xeen/screen.h @@ -45,7 +45,8 @@ private: byte _mainPalette[PALETTE_SIZE]; byte _tempPaltte[PALETTE_SIZE]; XSurface _pages[2]; - bool _fadeMode; + XSurface _savedScreens[10]; + bool _fadeIn; void mergeDirtyRects(); @@ -71,6 +72,8 @@ public: void loadPage(int pageNum); + void freePages(); + void horizMerge(int xp); void vertMerge(int yp); @@ -79,7 +82,11 @@ public: void fade(int step); - void fade2(int step); + void fadeOut(int step); + + void saveScreen(int slot); + + void restoreScreen(int slot); }; } // End of namespace Xeen |