diff options
author | richiesams | 2013-07-08 16:08:16 -0500 |
---|---|---|
committer | richiesams | 2013-08-04 13:32:08 -0500 |
commit | 76b2aa33ca129b1c7a626f1a043e5d828e72af57 (patch) | |
tree | ef6ecb4d84690b1424823a4e4c3a79265e03087e /engines | |
parent | afbcca2187c7a07e6e0853bd0befdc1e9a67dce2 (diff) | |
download | scummvm-rg350-76b2aa33ca129b1c7a626f1a043e5d828e72af57.tar.gz scummvm-rg350-76b2aa33ca129b1c7a626f1a043e5d828e72af57.tar.bz2 scummvm-rg350-76b2aa33ca129b1c7a626f1a043e5d828e72af57.zip |
ZVISION: Create/refactor methods for playing video.
The pixel format for videos is not the same as for the rest of the game.
(Game: RGB 555, Video: RGB 565)
Diffstat (limited to 'engines')
-rw-r--r-- | engines/zvision/video.cpp | 79 | ||||
-rw-r--r-- | engines/zvision/zvision.cpp | 10 | ||||
-rw-r--r-- | engines/zvision/zvision.h | 5 |
3 files changed, 44 insertions, 50 deletions
diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp index 8f77554619..5e27e3ada1 100644 --- a/engines/zvision/video.cpp +++ b/engines/zvision/video.cpp @@ -21,16 +21,14 @@ */ #include "common/scummsys.h" + #include "common/system.h" +#include "engines/util.h" -#include "engines/engine.h" -#include "graphics/decoders/tga.h" +#include "graphics/surface.h" -#include "zvision/zork_avi_decoder.h" -#include "zvision/zork_raw.h" +#include "zvision/zvision.h" -#include "common/events.h" -#include "common/file.h" namespace ZVision { @@ -73,63 +71,50 @@ void scale2x(const byte *src, byte *dst, int16 srcWidth, int16 srcHeight, byte b } } -void playVideo(Video::VideoDecoder *videoDecoder /*, VideoState videoState*/) { +void ZVision::startVideo(Video::VideoDecoder *videoDecoder) { if (!videoDecoder) return; - videoDecoder->start(); + _currentVideo = videoDecoder; - byte *scaleBuffer = 0; - byte bytesPerPixel = videoDecoder->getPixelFormat().bytesPerPixel; - uint16 width = videoDecoder->getWidth(); - uint16 height = videoDecoder->getHeight(); - uint16 pitch = videoDecoder->getWidth() * bytesPerPixel; - uint16 screenWidth = 640;//g_sci->_gfxScreen->getDisplayWidth(); - uint16 screenHeight = 480;//g_sci->_gfxScreen->getDisplayHeight(); + Common::List<Graphics::PixelFormat> formats; + formats.push_back(videoDecoder->getPixelFormat()); + initGraphics(640, 480, true, formats); + _currentVideo->start(); - bool zoom2x = true; + continueVideo(); +} - if (zoom2x) { - width *= 2; - height *= 2; - pitch *= 2; - scaleBuffer = new byte[width * height * bytesPerPixel]; +void ZVision::continueVideo() { + if (_currentVideo == 0) { + warning("No video loaded. Nothing to continue"); + return; } - uint16 x, y; - - x = (screenWidth - width) / 2; - y = (screenHeight - height) / 2; + byte bytesPerPixel = _currentVideo->getPixelFormat().bytesPerPixel; + uint16 width = _currentVideo->getWidth(); + uint16 height = _currentVideo->getHeight(); + uint16 pitch = _currentVideo->getWidth() * bytesPerPixel; - bool skipVideo = false; + uint16 x = (_system->getWidth() - width) / 2; + uint16 y = (_system->getWidth() - height) / 2; - while (!g_engine->shouldQuit() && !videoDecoder->endOfVideo() && !skipVideo) { - if (videoDecoder->needsUpdate()) { - const Graphics::Surface *frame = videoDecoder->decodeNextFrame(); + if (!_currentVideo->endOfVideo()) { + if (_currentVideo->needsUpdate()) { + const Graphics::Surface *frame = _currentVideo->decodeNextFrame(); if (frame) { - if (scaleBuffer) { - scale2x((byte *)frame->pixels, scaleBuffer, videoDecoder->getWidth(), videoDecoder->getHeight(), bytesPerPixel); - g_system->copyRectToScreen(scaleBuffer, pitch, x, y, width, height); - } else { - g_system->copyRectToScreen(frame->pixels, frame->pitch, x, y, width, height); - } - - g_system->updateScreen(); - } - } + _system->copyRectToScreen(frame->pixels, pitch, x, y, width, height); - Common::Event event; - while (g_system->getEventManager()->pollEvent(event)) { - if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) || event.type == Common::EVENT_LBUTTONUP) - skipVideo = true; + _needsScreenUpdate = true; + } } - - g_system->delayMillis(10); + } else { + initGraphics(_width, _height, true, &_pixelFormat); + delete _currentVideo; + _currentVideo = 0; } - delete[] scaleBuffer; - delete videoDecoder; } } // End of namespace ZVision diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index ac810d8d07..de1730f354 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -122,9 +122,13 @@ Common::Error ZVision::run() { currentTime = _system->getMillis(); uint32 deltaTime = currentTime - lastTime; lastTime = currentTime; - - updateScripts(); - updateAnimations(deltaTime); + + if (_currentVideo != 0) + continueVideo(); + else { + updateScripts(); + updateAnimations(deltaTime); + } if (_needsScreenUpdate || _console->isActive()) { _system->updateScreen(); diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index d18319a056..ffda12ac1a 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -27,6 +27,8 @@ #include "common/random.h" #include "common/events.h" +#include "video/video_decoder.h" + #include "engines/engine.h" #include "zvision/script_manager.h" @@ -67,6 +69,7 @@ private: bool _needsScreenUpdate; + Video::VideoDecoder *_currentVideo; public: uint32 getFeatures() const; Common::Language getLanguage() const; @@ -74,6 +77,8 @@ public: ScriptManager *getScriptManager() const; Common::RandomSource *getRandomSource() const; void renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y); + void startVideo(Video::VideoDecoder *videoDecoder); + void continueVideo(); private: void initialize(); |