diff options
author | Paul Gilbert | 2014-01-17 21:57:33 -0500 |
---|---|---|
committer | Paul Gilbert | 2014-01-17 21:57:33 -0500 |
commit | 6b059631ce8a54556bb27891438f65cd1fed59dc (patch) | |
tree | 5ba5e7afe5f44dae4836158bc8e0fb9b0658c0e7 /engines/voyeur | |
parent | c1657dc2789cf5fd680248850ca9f51c85698498 (diff) | |
download | scummvm-rg350-6b059631ce8a54556bb27891438f65cd1fed59dc.tar.gz scummvm-rg350-6b059631ce8a54556bb27891438f65cd1fed59dc.tar.bz2 scummvm-rg350-6b059631ce8a54556bb27891438f65cd1fed59dc.zip |
VOYEUR: Cleanup of doGossip, and better generic video playback code
Diffstat (limited to 'engines/voyeur')
-rw-r--r-- | engines/voyeur/animation.cpp | 64 | ||||
-rw-r--r-- | engines/voyeur/animation.h | 18 | ||||
-rw-r--r-- | engines/voyeur/voyeur_game.cpp | 62 |
3 files changed, 71 insertions, 73 deletions
diff --git a/engines/voyeur/animation.cpp b/engines/voyeur/animation.cpp index 42172b7a33..02dc8c25be 100644 --- a/engines/voyeur/animation.cpp +++ b/engines/voyeur/animation.cpp @@ -23,6 +23,7 @@ #include "voyeur/animation.h" #include "voyeur/staticres.h" #include "voyeur/voyeur.h" +#include "common/endian.h" #include "common/memstream.h" #include "common/system.h" #include "audio/decoders/raw.h" @@ -98,27 +99,6 @@ RL2Decoder::RL2VideoTrack *RL2Decoder::getVideoTrack() { return (RL2VideoTrack *)track; } -void RL2Decoder::play(::Voyeur::VoyeurEngine *vm) { - vm->_eventsManager.getMouseInfo(); - - while (!vm->shouldQuit() && !endOfVideo() && !vm->_eventsManager._mouseClicked) { - if (hasDirtyPalette()) { - const byte *palette = getPalette(); - vm->_graphicsManager.setPalette(palette, 0, 256); - } - - if (needsUpdate()) { - const Graphics::Surface *frame = decodeNextFrame(); - - Common::copy((const byte *)frame->getPixels(), (const byte *)frame->getPixels() + 320 * 200, - (byte *)vm->_graphicsManager._screenSurface.getPixels()); - } - - vm->_eventsManager.getMouseInfo(); - g_system->delayMillis(10); - } -} - /*------------------------------------------------------------------------*/ RL2Decoder::RL2FileHeader::RL2FileHeader() { @@ -446,3 +426,45 @@ Audio::QueuingAudioStream *RL2Decoder::RL2AudioTrack::createAudioStream() { } } // End of namespace Video + +/*------------------------------------------------------------------------*/ + +namespace Voyeur { + +void VoyeurRL2Decoder::play(VoyeurEngine *vm, int resourceOffset, byte *frames, byte *imgPos) { + vm->flipPageAndWait(); + + PictureResource videoFrame(getVideoTrack()->getBackSurface()); + int picCtr = 0; + while (!vm->shouldQuit() && !endOfVideo() && !vm->_eventsManager._mouseClicked) { + if (hasDirtyPalette()) { + const byte *palette = getPalette(); + vm->_graphicsManager.setPalette(palette, 128, 128); + } + + if (needsUpdate()) { + if (frames) { + // If reached a point where a new background is needed, load it + // and copy over to the video decoder + if (getCurFrame() >= READ_LE_UINT16(frames + picCtr * 4)) { + PictureResource *newPic = vm->_bVoy->boltEntry(0x302 + picCtr)._picResource; + Common::Point pt(READ_LE_UINT16(imgPos + 4 * picCtr) - 32, + READ_LE_UINT16(imgPos + 4 * picCtr + 2) - 20); + + vm->_graphicsManager.sDrawPic(newPic, &videoFrame, pt); + ++picCtr; + } + + // Decode the next frame and display + const Graphics::Surface *frame = decodeNextFrame(); + Common::copy((const byte *)frame->getPixels(), (const byte *)frame->getPixels() + 320 * 200, + (byte *)vm->_graphicsManager._screenSurface.getPixels()); + } + } + + vm->_eventsManager.getMouseInfo(); + g_system->delayMillis(10); + } +} + +} // End of namespace Video diff --git a/engines/voyeur/animation.h b/engines/voyeur/animation.h index 34cc9eec12..b1648887ab 100644 --- a/engines/voyeur/animation.h +++ b/engines/voyeur/animation.h @@ -29,6 +29,7 @@ #include "common/list.h" #include "common/rect.h" #include "common/stream.h" +#include "voyeur/files.h" namespace Voyeur { @@ -156,10 +157,25 @@ public: void clearDirtyRects(); void copyDirtyRectsToBuffer(uint8 *dst, uint pitch); RL2VideoTrack *getVideoTrack(); - void play(::Voyeur::VoyeurEngine *vm); int getPaletteCount() const { return _header._colorCount; } }; } // End of namespace Video +namespace Voyeur { + +class VoyeurRL2Decoder: public Video::RL2Decoder { +public: + /** + * Play back a given Voyeur RL2 video + * @param vm Engine reference + * @param resourceOffset Starting resource to use for frame pictures + * @param frames Optional frame numbers resource for when to apply image data + * @param imgPos Position to draw image data + */ + void play(VoyeurEngine *vm, int resourceOffset = 0, byte *frames = NULL, byte *imgPos = NULL); +}; + +} + #endif /* VOYEUR_ANIMATION_H */ diff --git a/engines/voyeur/voyeur_game.cpp b/engines/voyeur/voyeur_game.cpp index 64af53899d..2e59b77004 100644 --- a/engines/voyeur/voyeur_game.cpp +++ b/engines/voyeur/voyeur_game.cpp @@ -230,7 +230,7 @@ void VoyeurEngine::doTailTitle() { _graphicsManager.screenReset(); if (_bVoy->getBoltGroup(0x600)) { - ::Video::RL2Decoder decoder; + VoyeurRL2Decoder decoder; decoder.loadFile("a1100200.rl2"); decoder.start(); decoder.play(this); @@ -679,10 +679,11 @@ void VoyeurEngine::doGossip() { return; // Load the gossip animation - ::Video::RL2Decoder decoder; + VoyeurRL2Decoder decoder; decoder.loadFile("a2050100.rl2"); decoder.start(); + // Get the resource data for the first gossip video PictureResource *bgPic = _bVoy->boltEntry(0x300)._picResource; CMapResource *pal = _bVoy->boltEntry(0x301)._cMapResource; pal->startFade(); @@ -692,61 +693,20 @@ void VoyeurEngine::doGossip() { bgPic->_bounds.moveTo(0, 0); _graphicsManager.sDrawPic(bgPic, &videoFrame, Common::Point(0, 0)); - flipPageAndWait(); - byte *frameNumsP = _bVoy->memberAddr(0x309); byte *posP = _bVoy->boltEntry(0x30A)._data; - // Main playback loop - int picCtr = 0; - while (!shouldQuit() && !decoder.endOfVideo() && !_eventsManager._mouseClicked) { - if (decoder.hasDirtyPalette()) { - const byte *palette = decoder.getPalette(); - _graphicsManager.setPalette(palette, 128, 128); - } - - if (decoder.needsUpdate()) { - // If reached a point where a new background is needed, load it - // and copy over to the video decoder - if (decoder.getCurFrame() >= READ_LE_UINT16(frameNumsP + picCtr * 4)) { - PictureResource *newBgPic = _bVoy->boltEntry(0x302 + picCtr)._picResource; - Common::Point pt(READ_LE_UINT16(posP + 4 * picCtr + 2), - READ_LE_UINT16(posP + 4 * picCtr)); - - _graphicsManager.sDrawPic(newBgPic, &videoFrame, pt); - ++picCtr; - } - - // Decode the next frame and display - const Graphics::Surface *frame = decoder.decodeNextFrame(); - Common::copy((const byte *)frame->getPixels(), (const byte *)frame->getPixels() + 320 * 200, - (byte *)_graphicsManager._screenSurface.getPixels()); - } - - _eventsManager.getMouseInfo(); - g_system->delayMillis(10); - } - /* - decoder.loadFile("a2110100.rl2"); - decoder.start(); - - while (!shouldQuit() && !decoder.endOfVideo() && !_eventsManager._mouseClicked) { - if (decoder.hasDirtyPalette()) { - const byte *palette = decoder.getPalette(); - _graphicsManager.setPalette(palette, 0, 256); - } - - if (decoder.needsUpdate()) { - const Graphics::Surface *frame = decoder.decodeNextFrame(); + // Play the initial gossip video + decoder.play(this, 0x302, frameNumsP, posP); - Common::copy((const byte *)frame->getPixels(), (const byte *)frame->getPixels() + 320 * 200, - (byte *)_graphicsManager._screenSurface.getPixels()); - } + if (!_eventsManager._mouseClicked) { + // Play further interview + decoder.loadFile("a2110100.rl2"); + decoder.start(); - _eventsManager.pollEvents(); - g_system->delayMillis(10); + decoder.play(this); } - */ + _bVoy->freeBoltGroup(0x300); _graphicsManager.screenReset(); } |