diff options
| author | Filippos Karapetis | 2010-06-16 23:30:22 +0000 | 
|---|---|---|
| committer | Filippos Karapetis | 2010-06-16 23:30:22 +0000 | 
| commit | 18dc295a339cb7cc618ba565f68d05c6eada9782 (patch) | |
| tree | 2a5e0bbb63f7eb8e048cea34d5a1d2b564450ad1 /engines/sci/engine/kernel32.cpp | |
| parent | 93890a49c1f62791f39e4ee07c2366c8fdb8fb37 (diff) | |
| download | scummvm-rg350-18dc295a339cb7cc618ba565f68d05c6eada9782.tar.gz scummvm-rg350-18dc295a339cb7cc618ba565f68d05c6eada9782.tar.bz2 scummvm-rg350-18dc295a339cb7cc618ba565f68d05c6eada9782.zip  | |
Hooked the VMD player in kPlayVMD. The VMD videos in the demo of Phantasmagoria 1 are shown now (e.g. the intro and the chapter beginning)
svn-id: r49912
Diffstat (limited to 'engines/sci/engine/kernel32.cpp')
| -rw-r--r-- | engines/sci/engine/kernel32.cpp | 70 | 
1 files changed, 70 insertions, 0 deletions
diff --git a/engines/sci/engine/kernel32.cpp b/engines/sci/engine/kernel32.cpp index 7067e87c60..9adfdca21c 100644 --- a/engines/sci/engine/kernel32.cpp +++ b/engines/sci/engine/kernel32.cpp @@ -30,8 +30,10 @@  #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" @@ -893,6 +895,74 @@ reg_t kMulDiv(EngineState *s, int argc, reg_t *argv) {  	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; +	Common::String fileName; + +	Common::String warningMsg; + +	switch (operation) { +	case 0:	// play +		fileName = s->_segMan->derefString(argv[1]); +		// TODO: argv[2] (usually 0) +		videoDecoder = new VMDDecoder(g_system->getMixer()); + +		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()); + +		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  | 
