diff options
author | Paul Gilbert | 2014-12-26 14:37:20 +1100 |
---|---|---|
committer | Paul Gilbert | 2014-12-26 14:37:20 +1100 |
commit | 4f423c74b701b4dceff680259d174acb6a450b76 (patch) | |
tree | 7492eea7aeeece67c648caec752d0d14560def1a | |
parent | 1249bc03fdbf6d1bc390f9aea45b482cbb258e33 (diff) | |
download | scummvm-rg350-4f423c74b701b4dceff680259d174acb6a450b76.tar.gz scummvm-rg350-4f423c74b701b4dceff680259d174acb6a450b76.tar.bz2 scummvm-rg350-4f423c74b701b4dceff680259d174acb6a450b76.zip |
XEEN: Implement beginnings of Dark Side intro and supporting methods
-rw-r--r-- | engines/xeen/darkside/darkside_game.cpp | 41 | ||||
-rw-r--r-- | engines/xeen/events.cpp | 27 | ||||
-rw-r--r-- | engines/xeen/events.h | 8 | ||||
-rw-r--r-- | engines/xeen/module.mk | 1 | ||||
-rw-r--r-- | engines/xeen/screen.cpp | 63 | ||||
-rw-r--r-- | engines/xeen/screen.h | 16 | ||||
-rw-r--r-- | engines/xeen/sound.cpp | 34 | ||||
-rw-r--r-- | engines/xeen/sound.h | 43 | ||||
-rw-r--r-- | engines/xeen/xeen.cpp | 3 | ||||
-rw-r--r-- | engines/xeen/xeen.h | 2 |
10 files changed, 226 insertions, 12 deletions
diff --git a/engines/xeen/darkside/darkside_game.cpp b/engines/xeen/darkside/darkside_game.cpp index 2e9186e42f..728e15595f 100644 --- a/engines/xeen/darkside/darkside_game.cpp +++ b/engines/xeen/darkside/darkside_game.cpp @@ -46,12 +46,53 @@ void DarkSideEngine::darkSideIntro() { File("dragon1.voc"), File("dragon2.voc"), File("dragon3.voc") }; + // Load backgrounds _screen->loadBackground("nwc1.raw"); _screen->loadPage(0); _screen->loadBackground("nwc2.raw"); _screen->loadPage(1); + // Draw the screen and fade it in _screen->horizMerge(0); + _screen->draw(); + _screen->fade(4); + + bool breakFlag = false; + int nwcIndex = 0, nwcFrame = 0; + for (int idx = 0; idx < 55 && !shouldQuit(); ++idx) { + _events->updateGameCounter(); + _screen->vertMerge(0); + const XSurface &frame = nwc[nwcIndex].getFrame(nwcFrame); + _screen->transBlitFrom(frame, Common::Point(0, 0)); + _screen->draw(); + + switch (idx) { + case 17: + _sound->proc2(voc[0]); + break; + case 34: + case 44: + ++nwcIndex; + ++nwcFrame; + break; + case 35: + _sound->proc2(voc[1]); + break; + default: + ++nwcFrame; + } + + while (!shouldQuit() && _events->timeElapsed() < 2) { + _events->pollEventsAndWait(); + Common::KeyState keyState; + if (_events->getKey(keyState)) { + if (keyState.keycode == Common::KEYCODE_ESCAPE) + breakFlag = true; + } + } + } + + } } // End of namespace Xeen diff --git a/engines/xeen/events.cpp b/engines/xeen/events.cpp index e75744eb01..c4adabc433 100644 --- a/engines/xeen/events.cpp +++ b/engines/xeen/events.cpp @@ -39,6 +39,8 @@ EventsManager::EventsManager(XeenEngine *vm) : _vm(vm) { _priorFrameCounterTime = 0; _gameCounter = 0; _priorGameCounterTime = 0; + _keyCode = Common::KEYCODE_INVALID; + _leftButton = _rightButton = false; } /** @@ -81,12 +83,37 @@ void EventsManager::pollEvents() { case Common::EVENT_QUIT: case Common::EVENT_RTL: return; + case Common::EVENT_KEYDOWN: + _keyCode = event.kbd.keycode; + break; default: break; } } } +void EventsManager::pollEventsAndWait() { + pollEvents(); + g_system->delayMillis(10); +} + +void EventsManager::clearEvents() { + _keyCode = Common::KEYCODE_INVALID; + _leftButton = _rightButton = false; + +} + + +bool EventsManager::getKey(Common::KeyState &key) { + if (_keyCode == Common::KEYCODE_INVALID) { + return false; + } else { + key = _keyCode; + _keyCode = Common::KEYCODE_INVALID; + return true; + } +} + /** * Updates the game counter to match the current frame counter */ diff --git a/engines/xeen/events.h b/engines/xeen/events.h index 637d710364..4d775ac758 100644 --- a/engines/xeen/events.h +++ b/engines/xeen/events.h @@ -39,6 +39,8 @@ private: uint32 _priorFrameCounterTime; uint32 _gameCounter; uint32 _priorGameCounterTime; + Common::KeyCode _keyCode; + bool _leftButton, _rightButton; void nextFrame(); public: @@ -56,6 +58,12 @@ public: void pollEvents(); + void pollEventsAndWait(); + + void clearEvents(); + + bool getKey(Common::KeyState &key); + void updateGameCounter(); uint32 timeElapsed(); diff --git a/engines/xeen/module.mk b/engines/xeen/module.mk index c036376e93..aafe9b4c22 100644 --- a/engines/xeen/module.mk +++ b/engines/xeen/module.mk @@ -9,6 +9,7 @@ MODULE_OBJS := \ events.o \ resources.o \ screen.o \ + sound.o \ xeen.o \ xsurface.o diff --git a/engines/xeen/screen.cpp b/engines/xeen/screen.cpp index 4783890a60..65f9600220 100644 --- a/engines/xeen/screen.cpp +++ b/engines/xeen/screen.cpp @@ -20,8 +20,11 @@ * */ +#include "common/system.h" +#include "graphics/palette.h" #include "xeen/screen.h" #include "xeen/resources.h" +#include "xeen/xeen.h" namespace Xeen { @@ -29,7 +32,7 @@ namespace Xeen { * Constructor */ Screen::Screen(XeenEngine *vm) : _vm(vm) { - + _fadeMode = false; } void Screen::update() { @@ -116,9 +119,8 @@ void Screen::loadPalette(const Common::String &name) { void Screen::loadBackground(const Common::String &name) { File f(name); - _background.create(SCREEN_WIDTH, SCREEN_HEIGHT); assert(f.size() == (SCREEN_WIDTH * SCREEN_HEIGHT)); - f.read((byte *)_background.getPixels(), SCREEN_WIDTH * SCREEN_HEIGHT); + f.read((byte *)getPixels(), SCREEN_WIDTH * SCREEN_HEIGHT); } /** @@ -131,7 +133,7 @@ void Screen::loadPage(int pageNum) { _pages[1].create(SCREEN_WIDTH, SCREEN_HEIGHT); } - _pages[pageNum].blitFrom(_background); + _pages[pageNum].blitFrom(*this); } /** @@ -142,7 +144,7 @@ void Screen::horizMerge(int xp) { return; for (int y = 0; y < SCREEN_HEIGHT; ++y) { - byte *destP = (byte *)_background.getBasePtr(0, y); + byte *destP = (byte *)getBasePtr(0, y); const byte *srcP = (const byte *)_pages[0].getBasePtr(0, y); Common::copy(srcP, srcP + SCREEN_WIDTH - xp, destP); @@ -162,13 +164,13 @@ void Screen::vertMerge(int yp) { for (int y = 0; y < SCREEN_HEIGHT - yp; ++y) { const byte *srcP = (const byte *)_pages[0].getBasePtr(0, y); - byte *destP = (byte *)_background.getBasePtr(0, y); + byte *destP = (byte *)getBasePtr(0, y); Common::copy(srcP, srcP + SCREEN_WIDTH, destP); } for (int y = yp; y < SCREEN_HEIGHT; ++y) { const byte *srcP = (const byte *)_pages[1].getBasePtr(0, y); - byte *destP = (byte *)_background.getBasePtr(0, y); + byte *destP = (byte *)getBasePtr(0, y); Common::copy(srcP, srcP + SCREEN_WIDTH, destP); } } @@ -176,11 +178,54 @@ void Screen::vertMerge(int yp) { void Screen::draw(void *data) { // TODO: Figure out data structure that can be passed to method assert(!data); - drawBackground(); + drawScreen(); +} + +/** + * Mark the entire screen for drawing + */ +void Screen::drawScreen() { + addDirtyRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); +} + +void Screen::fade(int step) { + _fadeMode = true; + fadeInner(step); +} + +void Screen::fade2(int step) { + _fadeMode = false; + fadeInner(step); } -void Screen::drawBackground() { +void Screen::fadeInner(int step) { + for (int idx = 128; idx != 0 && !_vm->shouldQuit(); idx -= step) { + int val = idx; + bool flag = !_fadeMode; + if (!flag) { + val = -(val - 128); + flag = step != 0x81; + } + + if (!flag) { + step = 0x80; + } else { + // Create a scaled palette from the temporary one + for (int i = 0; i < PALETTE_SIZE; ++i) { + _mainPalette[i] = (_tempPaltte[i] * val * 2) >> 8; + } + + updatePalette(); + } + } +} + +void Screen::updatePalette() { + updatePalette(_mainPalette, 0, 16); +} +void Screen::updatePalette(const byte *pal, int start, int count16) { + g_system->getPaletteManager()->setPalette(pal, start, count16 * 16); } } // End of namespace Xeen diff --git a/engines/xeen/screen.h b/engines/xeen/screen.h index 645c4da4c7..3359af8336 100644 --- a/engines/xeen/screen.h +++ b/engines/xeen/screen.h @@ -44,14 +44,20 @@ private: Common::List<Common::Rect> _dirtyRects; byte _mainPalette[PALETTE_SIZE]; byte _tempPaltte[PALETTE_SIZE]; - XSurface _background; XSurface _pages[2]; + bool _fadeMode; void mergeDirtyRects(); bool unionRectangle(Common::Rect &destRect, const Common::Rect &src1, const Common::Rect &src2); - void drawBackground(); + void drawScreen(); + + void fadeInner(int step); + + void updatePalette(); + + void updatePalette(const byte *pal, int start, int count16); public: virtual void transBlitFrom(const XSurface &src, const Common::Point &destPos); @@ -73,7 +79,11 @@ public: void vertMerge(int yp); - void draw(void *data); + void draw(void *data = nullptr); + + void fade(int step); + + void fade2(int step); }; } // End of namespace Xeen diff --git a/engines/xeen/sound.cpp b/engines/xeen/sound.cpp new file mode 100644 index 0000000000..2863a3d564 --- /dev/null +++ b/engines/xeen/sound.cpp @@ -0,0 +1,34 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "xeen/sound.h" + +namespace Xeen { + +SoundManager::SoundManager(XeenEngine *vm): _vm(vm) { +} + +void SoundManager::proc2(File &f) { + +} + +} // End of namespace Xeen diff --git a/engines/xeen/sound.h b/engines/xeen/sound.h new file mode 100644 index 0000000000..2e163e7cce --- /dev/null +++ b/engines/xeen/sound.h @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef XEEN_SOUND_H +#define XEEN_SOUND_H + +#include "common/scummsys.h" +#include "common/system.h" +#include "xeen/resources.h" + +namespace Xeen { + +class SoundManager { +private: + XeenEngine *_vm; +public: + SoundManager(XeenEngine *vm); + + void proc2(File &f); +}; + +} // End of namespace Xeen + +#endif /* XEEN_SOUND_H */ diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp index cf60aa4555..f1330f5b0e 100644 --- a/engines/xeen/xeen.cpp +++ b/engines/xeen/xeen.cpp @@ -37,12 +37,14 @@ XeenEngine::XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc) _debugger = nullptr; _events = nullptr; _screen = nullptr; + _sound = nullptr; } XeenEngine::~XeenEngine() { delete _debugger; delete _events; delete _screen; + delete _sound; } void XeenEngine::initialize() { @@ -56,6 +58,7 @@ void XeenEngine::initialize() { _debugger = new Debugger(this); _events = new EventsManager(this); _screen = new Screen(this); + _sound = new SoundManager(this); Resources::init(this); // Set graphics mode diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h index dba340e329..df53b784fc 100644 --- a/engines/xeen/xeen.h +++ b/engines/xeen/xeen.h @@ -35,6 +35,7 @@ #include "xeen/debugger.h" #include "xeen/events.h" #include "xeen/screen.h" +#include "xeen/sound.h" /** * This is the namespace of the Xeen engine. @@ -108,6 +109,7 @@ public: Debugger *_debugger; EventsManager *_events; Screen *_screen; + SoundManager *_sound; public: XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc); virtual ~XeenEngine(); |