diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sherlock/animation.cpp | 69 | ||||
-rw-r--r-- | engines/sherlock/animation.h | 2 | ||||
-rw-r--r-- | engines/sherlock/graphics.cpp | 26 | ||||
-rw-r--r-- | engines/sherlock/graphics.h | 2 | ||||
-rw-r--r-- | engines/sherlock/scalpel/scalpel.cpp | 34 | ||||
-rw-r--r-- | engines/sherlock/scalpel/scalpel.h | 8 | ||||
-rw-r--r-- | engines/sherlock/sherlock.cpp | 1 | ||||
-rw-r--r-- | engines/sherlock/sound.cpp | 10 | ||||
-rw-r--r-- | engines/sherlock/sound.h | 12 | ||||
-rw-r--r-- | engines/sherlock/sprite.cpp | 13 | ||||
-rw-r--r-- | engines/sherlock/sprite.h | 5 |
11 files changed, 145 insertions, 37 deletions
diff --git a/engines/sherlock/animation.cpp b/engines/sherlock/animation.cpp index 2e9eb294d3..e4ec06b741 100644 --- a/engines/sherlock/animation.cpp +++ b/engines/sherlock/animation.cpp @@ -65,10 +65,13 @@ static const int NO_FRAMES = FRAMES_END; Animation::Animation(SherlockEngine *vm): _vm(vm) { } -void Animation::playPrologue(const Common::String &filename, int minDelay, int fade, +bool Animation::playPrologue(const Common::String &filename, int minDelay, int fade, bool setPalette, int speed) { EventsManager &events = *_vm->_events; Screen &screen = *_vm->_screen; + Sound &sound = *_vm->_sound; + int soundNumber = 0; + sound._playingEpilogue = true; // Check for any any sound frames for the given animation const int *soundFrames = checkForSoundFrames(filename); @@ -89,7 +92,6 @@ void Animation::playPrologue(const Common::String &filename, int minDelay, int f stream = _vm->_res->load(vdxName, "epilog2.lib"); else stream = _vm->_res->load(vdxName, "epilogoue.lib"); - int resourceIndex = _vm->_res->resourceIndex(); // Load initial image Common::String vdaName = baseName + ".vda"; @@ -99,16 +101,75 @@ void Animation::playPrologue(const Common::String &filename, int minDelay, int f events.delay(minDelay); if (fade != 0 && fade != 255) screen.fadeToBlack(); - + fade = 0; //***DEBUG**** if (setPalette) { if (fade != 255) screen.setPalette(sprite._palette); } - // TODO + int frameNumber = 0; + int spriteFrame; + Common::Point pt; + bool skipped = false; + while (!_vm->shouldQuit()) { + spriteFrame = stream->readSint16LE(); + if (spriteFrame != -1) { + if (spriteFrame < 0) { + spriteFrame = ABS(spriteFrame); + pt.x = stream->readUint16LE(); + pt.y = stream->readUint16LE(); + } else { + pt = sprite[spriteFrame]._position; + } + + screen.copyFrom(sprite[spriteFrame]._frame); + events.pollEventsAndWait(); + } else { + if (fade == 255) { + // Gradual fade in + if (screen.equalizePalette(sprite._palette) == 0) + fade = 0; + } + + // Check if we've reached a frame with sound + if (frameNumber++ == *soundFrames) { + ++soundNumber; + ++soundFrames; + Common::String fname = _vm->_soundOverride.empty() ? + Common::String::format("%s%01d", baseName.c_str(), soundNumber) : + Common::String::format("%s%02d", baseName.c_str(), soundNumber); + + if (sound._voicesEnabled) + sound.playSound(fname); + } + + events.delay(speed); + if (stream->readSint16LE() == -2) + // End of animation + break; + stream->seek(-2, SEEK_CUR); + } + if (events.isKeyPressed()) { + Common::KeyState keyState = events.getKey(); + if (keyState.keycode == Common::KEYCODE_ESCAPE || + keyState.keycode == Common::KEYCODE_SPACE) { + skipped = true; + break; + } + } else if (events._mouseClicked) { + skipped = true; + break; + } + } + + events.clearEvents(); + sound.stopSound(); delete stream; + sound._playingEpilogue = false; + + return !skipped && !_vm->shouldQuit(); } /** diff --git a/engines/sherlock/animation.h b/engines/sherlock/animation.h index 14384cfa28..da4c5baad7 100644 --- a/engines/sherlock/animation.h +++ b/engines/sherlock/animation.h @@ -39,7 +39,7 @@ public: public: Animation(SherlockEngine *vm); - void playPrologue(const Common::String &filename, int minDelay, int fade, bool setPalette, int speed); + bool playPrologue(const Common::String &filename, int minDelay, int fade, bool setPalette, int speed); }; } // End of namespace Sherlock diff --git a/engines/sherlock/graphics.cpp b/engines/sherlock/graphics.cpp index 583389e060..f4fe6b6b46 100644 --- a/engines/sherlock/graphics.cpp +++ b/engines/sherlock/graphics.cpp @@ -63,6 +63,7 @@ void Screen::setFont(int fontNumber) { } void Screen::update() { + g_system->copyRectToScreen(getPixels(), this->w, 0, 0, this->w, this->h); g_system->updateScreen(); } @@ -74,6 +75,31 @@ void Screen::setPalette(const byte palette[PALETTE_SIZE]) { g_system->getPaletteManager()->setPalette(palette, 0, PALETTE_COUNT); } +int Screen::equalizePalette(const byte palette[PALETTE_SIZE]) { + int total = 0; + byte tempPalette[PALETTE_SIZE]; + getPalette(tempPalette); + + // For any palette component that doesn't already match the given destination + // palette, change by 1 towards the reference palette component + for (int idx = 0; idx < PALETTE_SIZE; ++idx) { + if (tempPalette[idx] > palette[idx]) + { + --tempPalette[idx]; + ++total; + } else if (tempPalette[idx] < palette[idx]) { + ++tempPalette[idx]; + ++total; + } + } + + if (total > 0) + // Palette changed, so reload it + setPalette(tempPalette); + + return total; +} + void Screen::fadeToBlack() { const int FADE_AMOUNT = 2; bool repeatFlag; diff --git a/engines/sherlock/graphics.h b/engines/sherlock/graphics.h index 0385deebde..c6611db1ce 100644 --- a/engines/sherlock/graphics.h +++ b/engines/sherlock/graphics.h @@ -59,6 +59,8 @@ public: void setPalette(const byte palette[PALETTE_SIZE]); + int equalizePalette(const byte palette[PALETTE_SIZE]); + void fadeToBlack(); }; diff --git a/engines/sherlock/scalpel/scalpel.cpp b/engines/sherlock/scalpel/scalpel.cpp index 0b651bbb69..90a93de1b1 100644 --- a/engines/sherlock/scalpel/scalpel.cpp +++ b/engines/sherlock/scalpel/scalpel.cpp @@ -45,21 +45,21 @@ void ScalpelEngine::initialize() { * Show the opening sequence */ void ScalpelEngine::showOpening() { - if (!_events->isKeyPressed()) - showCityCutscene(); - if (!_events->isKeyPressed()) - showAlleyCutscene(); - if (!_events->isKeyPressed()) - showStreetCutscene(); - if (!_events->isKeyPressed()) - showOfficeCutscene(); + if (!showCityCutscene()) + return; + if (!showAlleyCutscene()) + return; + if (!showStreetCutscene()) + return; + if (!showOfficeCutscene()) + return; _events->clearEvents(); _sound->stopMusic(); } -void ScalpelEngine::showCityCutscene() { - byte palette[PALETTE_SIZE]; +bool ScalpelEngine::showCityCutscene() { +// byte palette[PALETTE_SIZE]; _sound->playMusic("prolog1.mus"); _titleOverride = "title.lib"; @@ -67,21 +67,21 @@ void ScalpelEngine::showCityCutscene() { _animation->playPrologue("26open1", 1, 255, true, 2); // TODO + return true; } -void ScalpelEngine::showAlleyCutscene() { - +bool ScalpelEngine::showAlleyCutscene() { + return true; } -void ScalpelEngine::showStreetCutscene() { - +bool ScalpelEngine::showStreetCutscene() { + return true; } -void ScalpelEngine::showOfficeCutscene() { - +bool ScalpelEngine::showOfficeCutscene() { + return true; } - } // End of namespace Scalpel } // End of namespace Scalpel diff --git a/engines/sherlock/scalpel/scalpel.h b/engines/sherlock/scalpel/scalpel.h index 5da33e1d52..584bd78a20 100644 --- a/engines/sherlock/scalpel/scalpel.h +++ b/engines/sherlock/scalpel/scalpel.h @@ -31,10 +31,10 @@ namespace Scalpel { class ScalpelEngine : public SherlockEngine { private: - void showCityCutscene(); - void showAlleyCutscene(); - void showStreetCutscene(); - void showOfficeCutscene(); + bool showCityCutscene(); + bool showAlleyCutscene(); + bool showStreetCutscene(); + bool showOfficeCutscene(); protected: virtual void initialize(); diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp index cb0472feff..1fba746f8d 100644 --- a/engines/sherlock/sherlock.cpp +++ b/engines/sherlock/sherlock.cpp @@ -80,6 +80,7 @@ void SherlockEngine::initialize() { _res = new Resources(); _rooms = new Rooms(); _screen = new Screen(this); + _sound = new Sound(this); _talk = new Talk(); } diff --git a/engines/sherlock/sound.cpp b/engines/sherlock/sound.cpp index f16dd5a80d..0957315a35 100644 --- a/engines/sherlock/sound.cpp +++ b/engines/sherlock/sound.cpp @@ -25,9 +25,13 @@ namespace Sherlock { Sound::Sound(SherlockEngine *vm): _vm(vm) { + _sfxEnabled = true; + _musicEnabled = true; + _voicesEnabled = true; + _playingEpilogue = false; } -void Sound::playSound(const Common::String &name) { +void Sound::playSound(const Common::String &name, WaitType waitType) { // TODO } @@ -43,6 +47,10 @@ void Sound::clearCache() { // TODO } +void Sound::stopSound() { + // TODO +} + void Sound::playMusic(const Common::String &name) { // TODO } diff --git a/engines/sherlock/sound.h b/engines/sherlock/sound.h index b1759a9c8e..7775016c94 100644 --- a/engines/sherlock/sound.h +++ b/engines/sherlock/sound.h @@ -30,16 +30,26 @@ namespace Sherlock { class SherlockEngine; +enum WaitType { + WAIT_RETURN_IMMEDIATELY = 0, WAIT_FINISH = 1, WAIT_KBD_OR_FINISH = 2 +}; + class Sound { private: SherlockEngine *_vm; public: + bool _sfxEnabled; + bool _musicEnabled; + bool _voicesEnabled; + bool _playingEpilogue; +public: Sound(SherlockEngine *vm); - void playSound(const Common::String &name); + void playSound(const Common::String &name, WaitType waitType = WAIT_RETURN_IMMEDIATELY); void cacheSound(const Common::String &name, int index); void playCachedSound(int index); void clearCache(); + void stopSound(); void playMusic(const Common::String &name); void stopMusic(); diff --git a/engines/sherlock/sprite.cpp b/engines/sherlock/sprite.cpp index c8d9ab55e3..9883d078ae 100644 --- a/engines/sherlock/sprite.cpp +++ b/engines/sherlock/sprite.cpp @@ -46,16 +46,16 @@ void Sprite::load(Common::SeekableReadStream &stream, bool skipPal) { SpriteFrame frame; frame._width = stream.readUint16LE() + 1; frame._height = stream.readUint16LE() + 1; - frame._flags = stream.readUint16LE(); - stream.readUint16LE(); + frame._flags = stream.readByte(); + frame._position.x = stream.readUint16LE(); + frame._position.y = stream.readByte(); - if (skipPal) - frame._flags = 0; + frame._rleEncoded = !skipPal && (frame._position.x == 1); if (frame._flags & 0xFF) { // Nibble packed frame data frame._size = (frame._width * frame._height) / 2; - } else if (frame._flags & RLE_ENCODED) { + } else if (frame._rleEncoded) { // this size includes the header size, which we subtract frame._size = stream.readUint16LE() - 11; frame._rleMarker = stream.readByte(); @@ -78,6 +78,7 @@ void Sprite::load(Common::SeekableReadStream &stream, bool skipPal) { * Gets the palette at the start of the sprite file */ void Sprite::loadPalette(Common::SeekableReadStream &stream) { + // Read in the palette int v1 = stream.readUint16LE() + 1; int v2 = stream.readUint16LE() + 1; int size = v1 * v2; @@ -95,7 +96,7 @@ void Sprite::decompressFrame(SpriteFrame &frame, const byte *src) { if (frame._flags & 0xFF) { debug("TODO: Sprite::decompressFrame() 4-bits/pixel\n"); - } else if (frame._flags & RLE_ENCODED) { + } else if (frame._rleEncoded) { // RLE encoded byte *dst = (byte *)frame._frame.getPixels(); diff --git a/engines/sherlock/sprite.h b/engines/sherlock/sprite.h index 5a510b2548..8aedbdb9c5 100644 --- a/engines/sherlock/sprite.h +++ b/engines/sherlock/sprite.h @@ -30,13 +30,12 @@ namespace Sherlock { -enum { RLE_ENCODED = 0x0100 }; - struct SpriteFrame { uint32 _size; uint16 _width, _height; int _flags; - Common::Point _offset; + bool _rleEncoded; + Common::Point _position; byte _rleMarker; Graphics::Surface _frame; }; |