aboutsummaryrefslogtreecommitdiff
path: root/engines/chewy/graphics.cpp
diff options
context:
space:
mode:
authorFilippos Karapetis2016-09-24 11:49:54 +0300
committerFilippos Karapetis2016-10-03 00:33:45 +0300
commit0152b7c47f0eef04bd01ae6e1cb808d25ccdd9a0 (patch)
tree5572e128ccaafb11c62c65b57128fc04a922d690 /engines/chewy/graphics.cpp
parentf017940ca08e32a206982376df0bdc334acdea55 (diff)
downloadscummvm-rg350-0152b7c47f0eef04bd01ae6e1cb808d25ccdd9a0.tar.gz
scummvm-rg350-0152b7c47f0eef04bd01ae6e1cb808d25ccdd9a0.tar.bz2
scummvm-rg350-0152b7c47f0eef04bd01ae6e1cb808d25ccdd9a0.zip
CHEWY: Add initial video (CFO) player
The game's videos are modified FLICs. There are some changes needed to our FLIC decoder, which are included in a separate commit
Diffstat (limited to 'engines/chewy/graphics.cpp')
-rw-r--r--engines/chewy/graphics.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/engines/chewy/graphics.cpp b/engines/chewy/graphics.cpp
index c3b29febff..887bb75bb4 100644
--- a/engines/chewy/graphics.cpp
+++ b/engines/chewy/graphics.cpp
@@ -21,10 +21,12 @@
*/
#include "common/system.h"
+#include "common/events.h"
#include "graphics/palette.h"
#include "chewy/graphics.h"
#include "chewy/resource.h"
+#include "chewy/video/cfo_decoder.h"
namespace Chewy {
@@ -41,4 +43,43 @@ void Graphics::drawImage(Common::String filename, int imageNum) {
delete res;
}
+void Graphics::playVideo(uint num) {
+ CfoDecoder *cfoDecoder = new CfoDecoder();
+ VideoResource *videoResource = new VideoResource("cut.tap");
+ Common::SeekableReadStream *videoStream = videoResource->getVideoStream(num);
+
+ if (!cfoDecoder->loadStream(videoStream)) {
+ delete videoResource;
+ delete cfoDecoder;
+ return;
+ }
+
+ uint16 x = (g_system->getWidth() - cfoDecoder->getWidth()) / 2;
+ uint16 y = (g_system->getHeight() - cfoDecoder->getHeight()) / 2;
+ bool skipVideo = false;
+
+ cfoDecoder->start();
+
+ while (!g_engine->shouldQuit() && !cfoDecoder->endOfVideo() && !skipVideo) {
+ if (cfoDecoder->needsUpdate()) {
+ const ::Graphics::Surface *frame = cfoDecoder->decodeNextFrame();
+ if (frame) {
+ g_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
+
+ if (cfoDecoder->hasDirtyPalette())
+ g_system->getPaletteManager()->setPalette(cfoDecoder->getPalette(), 0, 256);
+
+ g_system->updateScreen();
+ }
+ }
+
+ 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;
+ }
+
+ g_system->delayMillis(10);
+ }
+}
} // End of namespace Chewy