From f675f9be936e89bcf9985d660c17510bb497dcf7 Mon Sep 17 00:00:00 2001 From: Dmitry Iskrich Date: Sat, 18 Jun 2016 18:31:20 +0300 Subject: [PATCH] DIRECTOR: Add initial code for QuickTime video --- engines/director/director.cpp | 8 ++--- engines/director/director.h | 2 ++ engines/director/module.mk | 1 + engines/director/movie.cpp | 66 +++++++++++++++++++++++++++++++++++ engines/director/movie.h | 51 +++++++++++++++++++++++++++ 5 files changed, 124 insertions(+), 4 deletions(-) create mode 100644 engines/director/movie.cpp create mode 100644 engines/director/movie.h diff --git a/engines/director/director.cpp b/engines/director/director.cpp index fb93400c524a..25a0e3fdf096 100644 --- a/engines/director/director.cpp +++ b/engines/director/director.cpp @@ -87,11 +87,11 @@ Common::Error DirectorEngine::run() { _mainArchive = new RIFFArchive(); _mainArchive->openFile("bookshelf_example.mmm"); - Score score(this); - debug(0, "Score name %s", score.getMacName().c_str()); + _currentScore = new Score(this); + debug(0, "Score name %s", _currentScore->getMacName().c_str()); - score.loadArchive(); - score.startLoop(); + _currentScore->loadArchive(); + _currentScore->startLoop(); if (getPlatform() == Common::kPlatformWindows) loadEXE(); diff --git a/engines/director/director.h b/engines/director/director.h index 7e32d5f8ca99..8a35ac029ffe 100644 --- a/engines/director/director.h +++ b/engines/director/director.h @@ -61,6 +61,7 @@ class DirectorEngine : public ::Engine { DirectorSound *getSoundManager() const { return _soundManager; } Archive *getMainArchive() const { return _mainArchive; } Lingo *getLingo() const { return _lingo; } + Score *getCurrentScore() const { return _currentScore; } void setPalette(byte *palette, uint16 count); bool hasFeature(EngineFeature f) const; const byte *getPalette() const { return _currentPalette; } @@ -89,6 +90,7 @@ class DirectorEngine : public ::Engine { byte *_currentPalette; uint16 _currentPaletteLength; Lingo *_lingo; + Score *_currentScore; }; } // End of namespace Director diff --git a/engines/director/module.mk b/engines/director/module.mk index c6f1f02a790c..2d0bb5164648 100644 --- a/engines/director/module.mk +++ b/engines/director/module.mk @@ -4,6 +4,7 @@ MODULE_OBJS = \ detection.o \ dib.o \ director.o \ + movie.o \ resource.o \ score.o \ sound.o \ diff --git a/engines/director/movie.cpp b/engines/director/movie.cpp new file mode 100644 index 000000000000..3c34e2d432f9 --- /dev/null +++ b/engines/director/movie.cpp @@ -0,0 +1,66 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * Additional copyright for this file: + * Copyright (C) 1995-1997 Presto Studios, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "video/qt_decoder.h" +#include "director/movie.h" +#include "director/score.h" +#include "common/debug.h" +#include "common/system.h" +namespace Director { + +Movie::Movie(Common::String fileName, DirectorEngine *vm) { + _vm = vm; + _currentVideo = new Video::QuickTimeDecoder(); + if (!_currentVideo->loadFile(fileName)) { + warning("Can not open file %s", fileName.c_str()); + return; + } +} + +void Movie::play(Common::Point dest) { + + _currentVideo->start(); + + uint16 width = _currentVideo->getWidth(); + uint16 height = _currentVideo->getHeight(); + + while (!_currentVideo->endOfVideo()) { + if (_currentVideo->needsUpdate()) { + const Graphics::Surface *frame = _currentVideo->decodeNextFrame(); + g_system->copyRectToScreen(frame->getPixels(), frame->pitch, dest.x, dest.y, width, height); + g_system->updateScreen(); + } + g_system->delayMillis(10); + _vm->getCurrentScore()->processEvents(); + } +} + +void Movie::stop() { + _currentVideo->stop(); +} + +Movie::~Movie() { + delete _currentVideo; +} + +} //End of namespace Director diff --git a/engines/director/movie.h b/engines/director/movie.h new file mode 100644 index 000000000000..e26d10a7c75b --- /dev/null +++ b/engines/director/movie.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * Additional copyright for this file: + * Copyright (C) 1995-1997 Presto Studios, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef DIRECTOR_MOVIE_H +#define DIRECTOR_MOVIE_H + +#include "common/str.h" +#include "common/rect.h" +#include "graphics/managed_surface.h" +#include "director/director.h" + +namespace Video { +class VideoDecoder; +} + +namespace Director { + +class Movie { +public: + Movie(Common::String fileName, DirectorEngine *vm); + ~Movie(); + void play(Common::Point dest); + void stop(); + +private: + Video::VideoDecoder *_currentVideo; + DirectorEngine *_vm; +}; +} //End of namespace Director + +#endif