From cf82bef02ee2941ddad6664e34f3c94e35e015a3 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 8 Oct 2010 22:30:39 +0000 Subject: TOON: Merged Toon engine to ScummVM trunk svn-id: r53087 --- engines/toon/movie.cpp | 111 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 engines/toon/movie.cpp (limited to 'engines/toon/movie.cpp') diff --git a/engines/toon/movie.cpp b/engines/toon/movie.cpp new file mode 100644 index 0000000000..9918c3e38f --- /dev/null +++ b/engines/toon/movie.cpp @@ -0,0 +1,111 @@ +/* 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. +* +* 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. +* +* $URL$ +* $Id$ +* +*/ + +#include "movie.h" + +namespace Toon { + +void ToonstruckSmackerDecoder::handleAudioTrack(const byte &track, const uint32 &chunkSize, const uint32 &unpackedSize) { + debugC(6, kDebugMovie, "handleAudioTrack(%d, %d, %d)", track, chunkSize, unpackedSize); + + if (track == 1 && chunkSize == 4) { + /* uint16 width = */ _fileStream->readUint16LE(); + uint16 height = _fileStream->readUint16LE(); + + _header.flags = (height == getHeight() / 2) ? 4 : 0; + } else + Graphics::SmackerDecoder::handleAudioTrack(track, chunkSize, unpackedSize); +} + +bool ToonstruckSmackerDecoder::loadFile(const Common::String &filename, int forcedflags) { + debugC(1, kDebugMovie, "loadFile(%s, %d)", filename.c_str(), forcedflags); + + if (Graphics::SmackerDecoder::loadFile(filename)) { + if (forcedflags & 0x10 || _surface->h == 200) { + + _header.flags = 4; + delete this->_surface; + _surface = new Graphics::Surface(); + _surface->create(640, 400, 1); + } + return true; + } + return false; +} + +ToonstruckSmackerDecoder::ToonstruckSmackerDecoder(Audio::Mixer *mixer, Audio::Mixer::SoundType soundType) : Graphics::SmackerDecoder(mixer, soundType) { + +} + +Movie::Movie(ToonEngine *vm , ToonstruckSmackerDecoder *decoder) { + _vm = vm; + _decoder = decoder; +} + +Movie::~Movie() { +} + +void Movie::init() const { +} + +void Movie::play(Common::String video, int32 flags) { + debugC(1, kDebugMovie, "play(%s, %d)", video.c_str(), flags); + + if (flags & 1) + _vm->getAudioManager()->setMusicVolume(0); + _decoder->loadFile(video.c_str(), flags); + playVideo(); + _vm->flushPalette(); + if (flags & 1) + _vm->getAudioManager()->setMusicVolume(100); + _decoder->close(); +} + +bool Movie::playVideo() { + debugC(1, kDebugMovie, "playVideo()"); + + int32 x = 0; + int32 y = 0; + while (!_vm->shouldQuit() && !_decoder->endOfVideo()) { + if (_decoder->needsUpdate()) { + Graphics::Surface *frame = _decoder->decodeNextFrame(); + if (frame) + _vm->getSystem()->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h); + _decoder->setSystemPalette(); + _vm->getSystem()->updateScreen(); + } + + Common::Event event; + while (_vm->getSystem()->getEventManager()->pollEvent(event)) + if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) || event.type == Common::EVENT_LBUTTONUP) { + return false; + } + + _vm->getSystem()->delayMillis(10); + } + return !_vm->shouldQuit(); +} + +} // End of namespace Toon -- cgit v1.2.3 From e11637c7bc41d59dc6a666d3f0399b9a699b2443 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 8 Oct 2010 22:45:28 +0000 Subject: TOON: Normalized include paths svn-id: r53089 --- engines/toon/movie.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/toon/movie.cpp') diff --git a/engines/toon/movie.cpp b/engines/toon/movie.cpp index 9918c3e38f..f01dd90d9c 100644 --- a/engines/toon/movie.cpp +++ b/engines/toon/movie.cpp @@ -23,7 +23,7 @@ * */ -#include "movie.h" +#include "toon/movie.h" namespace Toon { -- cgit v1.2.3 From 0fc6572b65908f7d3a7d13537afac67f1cc8a68b Mon Sep 17 00:00:00 2001 From: Sylvain Dupont Date: Sat, 9 Oct 2010 00:17:55 +0000 Subject: VIDEO: Remove useless references in handleAudioTrack function svn-id: r53091 --- engines/toon/movie.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/toon/movie.cpp') diff --git a/engines/toon/movie.cpp b/engines/toon/movie.cpp index f01dd90d9c..87a3e878b5 100644 --- a/engines/toon/movie.cpp +++ b/engines/toon/movie.cpp @@ -27,7 +27,7 @@ namespace Toon { -void ToonstruckSmackerDecoder::handleAudioTrack(const byte &track, const uint32 &chunkSize, const uint32 &unpackedSize) { +void ToonstruckSmackerDecoder::handleAudioTrack(byte track, uint32 chunkSize, uint32 unpackedSize) { debugC(6, kDebugMovie, "handleAudioTrack(%d, %d, %d)", track, chunkSize, unpackedSize); if (track == 1 && chunkSize == 4) { -- cgit v1.2.3