From da33617061d3d35becaaa741c8144377bf40f39b Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Thu, 11 Nov 2010 05:18:40 +0000 Subject: SCI: Allow duck videos to be played from the console svn-id: r54195 --- engines/sci/console.cpp | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 539e205023..c5b8d2ae0d 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -58,6 +58,8 @@ #include "common/file.h" #include "common/savefile.h" +#include "engines/util.h" + namespace Sci { int g_debug_sleeptime_factor = 1; @@ -226,10 +228,12 @@ void Console::preEnter() { void Console::postEnter() { if (!_videoFile.empty()) { - _engine->_gfxCursor->kernelHide(); - Graphics::VideoDecoder *videoDecoder = 0; +#ifdef ENABLE_SCI32 + bool duckMode = false; +#endif + if (_videoFile.hasSuffix(".seq")) { SeqDecoder *seqDecoder = new SeqDecoder(); seqDecoder->setFrameDelay(_videoFrameDelay); @@ -237,12 +241,35 @@ void Console::postEnter() { #ifdef ENABLE_SCI32 } else if (_videoFile.hasSuffix(".vmd")) { videoDecoder = new Graphics::VMDDecoder(g_system->getMixer()); +#endif + } else if (_videoFile.hasSuffix(".duk")) { +#ifdef ENABLE_SCI32 + duckMode = true; + videoDecoder = new Graphics::AviDecoder(g_system->getMixer()); +#else + warning("Duck videos require SCI32 support compiled in"); #endif } else if (_videoFile.hasSuffix(".avi")) { videoDecoder = new Graphics::AviDecoder(g_system->getMixer()); } if (videoDecoder && videoDecoder->loadFile(_videoFile)) { + _engine->_gfxCursor->kernelHide(); + +#ifdef ENABLE_SCI32 + // Duck videos are 16bpp, so we need to change pixel formats + int oldWidth = g_system->getWidth(); + int oldHeight = g_system->getHeight(); + if (duckMode) { + Common::List formats; + formats.push_back(videoDecoder->getPixelFormat()); + initGraphics(640, 480, true, formats); + + if (g_system->getScreenFormat().bytesPerPixel != videoDecoder->getPixelFormat().bytesPerPixel) + error("Could not switch screen format for the duck video"); + } +#endif + uint16 x = (g_system->getWidth() - videoDecoder->getWidth()) / 2; uint16 y = (g_system->getHeight() - videoDecoder->getHeight()) / 2; bool skipVideo = false; @@ -273,10 +300,17 @@ void Console::postEnter() { } delete videoDecoder; + +#ifdef ENABLE_SCI32 + // Switch back to 8bpp if we played a duck video + if (duckMode) + initGraphics(oldWidth, oldHeight, oldWidth > 320); +#endif + + _engine->_gfxCursor->kernelShow(); } else warning("Could not play video %s\n", _videoFile.c_str()); - _engine->_gfxCursor->kernelShow(); _videoFile.clear(); _videoFrameDelay = 0; } @@ -1547,7 +1581,7 @@ bool Console::cmdPicVisualize(int argc, const char **argv) { bool Console::cmdPlayVideo(int argc, const char **argv) { if (argc < 2) { - DebugPrintf("Plays a SEQ, AVI or VMD video.\n"); + DebugPrintf("Plays a SEQ, AVI, DUK or VMD video.\n"); DebugPrintf("Usage: %s