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 | |
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')
-rw-r--r-- | engines/sci/engine/kernel32.cpp | 84 | ||||
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 75 | ||||
-rw-r--r-- | engines/sci/engine/kmath.cpp | 18 |
3 files changed, 93 insertions, 84 deletions
diff --git a/engines/sci/engine/kernel32.cpp b/engines/sci/engine/kernel32.cpp index dedcf0df5f..a077f110cf 100644 --- a/engines/sci/engine/kernel32.cpp +++ b/engines/sci/engine/kernel32.cpp @@ -30,10 +30,8 @@ #include "sci/engine/segment.h" #include "sci/engine/state.h" #include "sci/engine/selector.h" -#include "sci/graphics/cursor.h" #include "sci/graphics/frameout.h" #include "sci/graphics/screen.h" -#include "sci/video/vmd_decoder.h" #include "common/system.h" @@ -881,88 +879,6 @@ reg_t kCreateTextBitmap(EngineState *s, int argc, reg_t *argv) { return NULL_REG; } -reg_t kMulDiv(EngineState *s, int argc, reg_t *argv) { - int16 multiplicant = argv[0].toSint16(); - int16 multiplier = argv[1].toSint16(); - int16 denominator = argv[2].toSint16(); - - // Sanity check... - if (!denominator) { - warning("kMulDiv: attempt to divide by zero (%d * %d / %d", multiplicant, multiplier, denominator); - return NULL_REG; - } - - return make_reg(0, multiplicant * multiplier / denominator); -} - -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) - 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; -} - } // End of namespace Sci #endif // ENABLE_SCI32 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) { diff --git a/engines/sci/engine/kmath.cpp b/engines/sci/engine/kmath.cpp index dbf317860f..6d4b9a2a04 100644 --- a/engines/sci/engine/kmath.cpp +++ b/engines/sci/engine/kmath.cpp @@ -153,4 +153,22 @@ reg_t kTimesCot(EngineState *s, int argc, reg_t *argv) { return make_reg(0, (int16)(tan(param * PI / 180.0) * scale)); } +#ifdef ENABLE_SCI32 + +reg_t kMulDiv(EngineState *s, int argc, reg_t *argv) { + int16 multiplicant = argv[0].toSint16(); + int16 multiplier = argv[1].toSint16(); + int16 denominator = argv[2].toSint16(); + + // Sanity check... + if (!denominator) { + warning("kMulDiv: attempt to divide by zero (%d * %d / %d", multiplicant, multiplier, denominator); + return NULL_REG; + } + + return make_reg(0, multiplicant * multiplier / denominator); +} + +#endif + } // End of namespace Sci |