diff options
author | Filippos Karapetis | 2010-06-17 07:26:06 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-06-17 07:26:06 +0000 |
commit | 894ba682cdfb60a268dd4f4cb09d74d5cbb590b0 (patch) | |
tree | 1b4d9a3548b2bcb5a4e1d3228e6c1fc916f977a4 /engines/sci/engine/kgraphics.cpp | |
parent | f10b1a23f807d7889a2776ce80ea8b7a77160eb5 (diff) | |
download | scummvm-rg350-894ba682cdfb60a268dd4f4cb09d74d5cbb590b0.tar.gz scummvm-rg350-894ba682cdfb60a268dd4f4cb09d74d5cbb590b0.tar.bz2 scummvm-rg350-894ba682cdfb60a268dd4f4cb09d74d5cbb590b0.zip |
Moved kMulDiv together with the rest of the math functions, and kPlayVMD together with the rest of the video playing functions
svn-id: r49920
Diffstat (limited to 'engines/sci/engine/kgraphics.cpp')
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 5c84ddfb49..84fbbe98eb 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -48,6 +48,9 @@ #include "sci/graphics/screen.h" #include "sci/graphics/text16.h" #include "sci/graphics/view.h" +#ifdef ENABLE_SCI32 +#include "sci/video/vmd_decoder.h" +#endif namespace Sci { @@ -1230,6 +1233,78 @@ reg_t kRobot(EngineState *s, int argc, reg_t *argv) { return s->r_acc; } + +reg_t kPlayVMD(EngineState *s, int argc, reg_t *argv) { + uint16 operation = argv[0].toUint16(); + Graphics::VideoDecoder *videoDecoder = 0; + bool reshowCursor = g_sci->_gfxCursor->isVisible(); + Common::String fileName, warningMsg; + + switch (operation) { + case 0: // play + fileName = s->_segMan->derefString(argv[1]); + // TODO: argv[2] (usually 0) + if (argv[2] != NULL_REG) + warning("kPlayVMD: third parameter isn't 0 (it's %04x:%04x)", PRINT_REG(argv[2])); + + videoDecoder = new VMDDecoder(g_system->getMixer()); + + if (reshowCursor) + g_sci->_gfxCursor->kernelHide(); + + if (videoDecoder && videoDecoder->loadFile(fileName)) { + uint16 x = (g_system->getWidth() - videoDecoder->getWidth()) / 2; + uint16 y = (g_system->getHeight() - videoDecoder->getHeight()) / 2; + bool skipVideo = false; + + while (!g_engine->shouldQuit() && !videoDecoder->endOfVideo() && !skipVideo) { + if (videoDecoder->needsUpdate()) { + Graphics::Surface *frame = videoDecoder->decodeNextFrame(); + if (frame) { + g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h); + + if (videoDecoder->hasDirtyPalette()) + videoDecoder->setSystemPalette(); + + 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); + } + + // Copy video contents to screen buffer + g_sci->_gfxScreen->kernelSyncWithFramebuffer(); + + delete videoDecoder; + } else + warning("Could not play video %s\n", fileName.c_str()); + + if (reshowCursor) + g_sci->_gfxCursor->kernelShow(); + break; + default: + warningMsg = "PlayVMD - unsupported subop. Params: " + + Common::String::printf("%d", argc) + " ("; + + for (int i = 0; i < argc; i++) { + warningMsg += Common::String::printf("%04x:%04x", PRINT_REG(argv[i])); + warningMsg += (i == argc - 1 ? ")" : ", "); + } + + warning("%s", warningMsg.c_str()); + break; + } + + return s->r_acc; +} + #endif reg_t kSetVideoMode(EngineState *s, int argc, reg_t *argv) { |