2007-05-30 21:56:52 +00:00
|
|
|
/* 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.
|
2006-04-17 04:02:48 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-04-17 04:02:48 +00:00
|
|
|
|
2009-08-12 00:53:35 +00:00
|
|
|
#ifdef ENABLE_AGOS2
|
|
|
|
|
2006-04-17 04:02:48 +00:00
|
|
|
#include "common/endian.h"
|
2008-10-06 12:48:52 +00:00
|
|
|
#include "common/events.h"
|
2009-08-11 14:42:44 +00:00
|
|
|
#include "common/file.h"
|
2006-04-17 04:02:48 +00:00
|
|
|
#include "common/system.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/textconsole.h"
|
2011-06-13 21:19:18 +00:00
|
|
|
#include "common/translation.h"
|
2006-04-17 04:02:48 +00:00
|
|
|
|
2006-05-25 22:51:42 +00:00
|
|
|
#include "graphics/cursorman.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "graphics/palette.h"
|
2007-06-21 03:14:20 +00:00
|
|
|
#include "graphics/surface.h"
|
2006-05-25 22:51:42 +00:00
|
|
|
|
2006-09-29 08:14:27 +00:00
|
|
|
#include "agos/animation.h"
|
|
|
|
#include "agos/intern.h"
|
|
|
|
#include "agos/agos.h"
|
2006-04-17 12:05:45 +00:00
|
|
|
|
2011-02-09 01:09:01 +00:00
|
|
|
#include "audio/audiostream.h"
|
|
|
|
#include "audio/decoders/wave.h"
|
2006-04-17 12:05:45 +00:00
|
|
|
|
2008-12-31 16:06:55 +00:00
|
|
|
#include "gui/message.h"
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
namespace AGOS {
|
2006-04-17 12:05:45 +00:00
|
|
|
|
2009-05-16 05:34:16 +00:00
|
|
|
MoviePlayer::MoviePlayer(AGOSEngine_Feeble *vm)
|
2008-12-21 04:36:11 +00:00
|
|
|
: _vm(vm) {
|
|
|
|
_mixer = _vm->_mixer;
|
2007-06-12 06:08:47 +00:00
|
|
|
|
2006-04-24 06:01:51 +00:00
|
|
|
_leftButtonDown = false;
|
|
|
|
_rightButtonDown = false;
|
2008-12-21 04:36:11 +00:00
|
|
|
_skipMovie = false;
|
2006-04-24 06:01:51 +00:00
|
|
|
|
2006-06-02 11:33:11 +00:00
|
|
|
memset(baseName, 0, sizeof(baseName));
|
|
|
|
|
2006-04-24 06:01:51 +00:00
|
|
|
_ticks = 0;
|
2006-04-17 12:05:45 +00:00
|
|
|
}
|
|
|
|
|
2008-12-21 04:36:11 +00:00
|
|
|
MoviePlayer::~MoviePlayer() {
|
2006-04-24 10:24:56 +00:00
|
|
|
}
|
2006-04-17 13:19:36 +00:00
|
|
|
|
2006-04-24 10:24:56 +00:00
|
|
|
void MoviePlayer::play() {
|
2007-06-10 09:07:23 +00:00
|
|
|
if (_vm->getBitFlag(40)) {
|
2008-12-21 04:36:11 +00:00
|
|
|
_vm->setBitFlag(42, false);
|
|
|
|
startSound();
|
2006-04-24 10:24:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-04-17 13:19:36 +00:00
|
|
|
_leftButtonDown = false;
|
|
|
|
_rightButtonDown = false;
|
2008-12-21 04:36:11 +00:00
|
|
|
_skipMovie = false;
|
2006-04-17 13:19:36 +00:00
|
|
|
|
2008-12-21 04:36:11 +00:00
|
|
|
_vm->_mixer->stopAll();
|
2006-04-17 12:05:45 +00:00
|
|
|
|
2006-04-24 10:24:56 +00:00
|
|
|
_ticks = _vm->_system->getMillis();
|
2006-04-23 02:11:49 +00:00
|
|
|
|
2006-04-24 10:24:56 +00:00
|
|
|
startSound();
|
|
|
|
|
2008-12-21 04:36:11 +00:00
|
|
|
playVideo();
|
|
|
|
stopVideo();
|
2006-04-17 12:05:45 +00:00
|
|
|
|
|
|
|
_vm->o_killAnimate();
|
|
|
|
|
|
|
|
if (_vm->getBitFlag(41)) {
|
2007-06-21 05:10:42 +00:00
|
|
|
_vm->fillBackFromFront();
|
2006-04-17 12:05:45 +00:00
|
|
|
} else {
|
2011-02-15 22:22:30 +00:00
|
|
|
uint8 palette[768];
|
2006-04-30 06:23:32 +00:00
|
|
|
memset(palette, 0, sizeof(palette));
|
2007-06-21 05:10:42 +00:00
|
|
|
_vm->clearSurfaces();
|
2011-02-07 17:52:38 +00:00
|
|
|
_vm->_system->getPaletteManager()->setPalette(palette, 0, 256);
|
2006-04-17 04:02:48 +00:00
|
|
|
}
|
2006-04-30 06:12:50 +00:00
|
|
|
|
2008-08-08 02:18:17 +00:00
|
|
|
_vm->fillBackGroundFromBack();
|
2006-04-30 06:12:50 +00:00
|
|
|
_vm->_fastFadeOutFlag = true;
|
2006-04-17 04:02:48 +00:00
|
|
|
}
|
|
|
|
|
2006-04-24 10:24:56 +00:00
|
|
|
void MoviePlayer::handleNextFrame() {
|
2007-03-17 19:02:05 +00:00
|
|
|
Common::Event event;
|
2007-03-17 00:53:21 +00:00
|
|
|
Common::EventManager *eventMan = _vm->_system->getEventManager();
|
|
|
|
while (eventMan->pollEvent(event)) {
|
2006-04-24 10:24:56 +00:00
|
|
|
switch (event.type) {
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_KEYDOWN:
|
2009-04-24 10:11:58 +00:00
|
|
|
if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
|
2006-05-02 23:46:23 +00:00
|
|
|
_leftButtonDown = true;
|
|
|
|
_rightButtonDown = true;
|
2009-04-24 10:11:58 +00:00
|
|
|
} else if (event.kbd.keycode == Common::KEYCODE_PAUSE) {
|
|
|
|
_vm->pause();
|
2006-05-02 23:46:23 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_LBUTTONDOWN:
|
2006-04-24 10:24:56 +00:00
|
|
|
_leftButtonDown = true;
|
|
|
|
break;
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_RBUTTONDOWN:
|
2006-04-24 10:24:56 +00:00
|
|
|
_rightButtonDown = true;
|
|
|
|
break;
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_LBUTTONUP:
|
2006-04-24 10:24:56 +00:00
|
|
|
_leftButtonDown = false;
|
|
|
|
break;
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_RBUTTONUP:
|
2006-04-24 10:24:56 +00:00
|
|
|
_rightButtonDown = false;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_leftButtonDown && _rightButtonDown && !_vm->getBitFlag(41)) {
|
2008-12-21 04:36:11 +00:00
|
|
|
_skipMovie = true;
|
2006-10-01 07:17:34 +00:00
|
|
|
_mixer->stopHandle(_bgSound);
|
2006-04-24 10:24:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-21 04:36:11 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Movie player for DXA movies
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2006-04-24 10:24:56 +00:00
|
|
|
|
2011-09-07 22:38:39 +00:00
|
|
|
const char *const MoviePlayerDXA::_sequenceList[90] = {
|
2006-06-28 14:06:54 +00:00
|
|
|
"agent32",
|
|
|
|
"Airlock",
|
|
|
|
"Badluck",
|
|
|
|
"bentalk1",
|
|
|
|
"bentalk2",
|
|
|
|
"bentalk3",
|
|
|
|
"BigFight",
|
|
|
|
"BLOWLAB",
|
|
|
|
"breakdown",
|
|
|
|
"bridge",
|
|
|
|
"button2",
|
|
|
|
"cargo",
|
|
|
|
"COACH",
|
|
|
|
"Colatalk",
|
|
|
|
"cygnus2",
|
|
|
|
"dream",
|
|
|
|
"escape2",
|
|
|
|
"FASALL",
|
|
|
|
"fbikewurb",
|
|
|
|
"feebdel",
|
|
|
|
"Feebohno",
|
|
|
|
"feebpump",
|
|
|
|
"feefone1",
|
|
|
|
"feefone2",
|
|
|
|
"founder2",
|
|
|
|
"founder3",
|
|
|
|
"founder4",
|
|
|
|
"fxmadsam",
|
|
|
|
"fxwakeup",
|
|
|
|
"gate",
|
|
|
|
"Get Car",
|
|
|
|
"getaxe",
|
|
|
|
"getlift",
|
|
|
|
"icetrench",
|
|
|
|
"intomb1",
|
|
|
|
"intomb2",
|
|
|
|
"Jackpot",
|
|
|
|
"knockout",
|
|
|
|
"labocto",
|
|
|
|
"longfeeb",
|
|
|
|
"Mainmin",
|
|
|
|
"maznat",
|
|
|
|
"meetsquid",
|
|
|
|
"mflirt",
|
|
|
|
"mfxHappy",
|
|
|
|
"Mix_Feeb1",
|
|
|
|
"Mix_Feeb2",
|
|
|
|
"Mix_Feeb3",
|
|
|
|
"Mix_Guardscn",
|
|
|
|
"Mlights1",
|
|
|
|
"MLights2",
|
|
|
|
"MProtest",
|
|
|
|
"mudman",
|
|
|
|
"munlock",
|
|
|
|
"MUS5P2",
|
|
|
|
"MUSOSP1",
|
|
|
|
"Omenter",
|
|
|
|
"Omnicofe",
|
|
|
|
"OUTMIN~1",
|
|
|
|
"Readbook",
|
|
|
|
"Rebelhq",
|
|
|
|
"RebelHQ2",
|
|
|
|
"Reedin",
|
|
|
|
"rescue1",
|
|
|
|
"rescue2",
|
|
|
|
"samcar",
|
|
|
|
"Samdead",
|
|
|
|
"scanner",
|
|
|
|
"Sleepy",
|
|
|
|
"spitbrai",
|
|
|
|
"statue1",
|
|
|
|
"statue2",
|
|
|
|
"sva1",
|
|
|
|
"sva2",
|
|
|
|
"Teeter",
|
|
|
|
"Temple2",
|
|
|
|
"Temple3",
|
|
|
|
"Temple4",
|
|
|
|
"Temple5",
|
|
|
|
"Temple6",
|
|
|
|
"Temple7",
|
|
|
|
"Temple8",
|
|
|
|
"Tic-tac2",
|
|
|
|
"torture",
|
|
|
|
"transmit",
|
|
|
|
"Typey",
|
|
|
|
"ventfall",
|
|
|
|
"ventoff",
|
|
|
|
"wasting",
|
|
|
|
"wurbatak"
|
2006-05-06 08:21:57 +00:00
|
|
|
};
|
|
|
|
|
2009-05-16 05:34:16 +00:00
|
|
|
MoviePlayerDXA::MoviePlayerDXA(AGOSEngine_Feeble *vm, const char *name)
|
2008-12-21 04:36:11 +00:00
|
|
|
: MoviePlayer(vm) {
|
|
|
|
debug(0, "Creating DXA cutscene player");
|
|
|
|
|
|
|
|
memset(baseName, 0, sizeof(baseName));
|
|
|
|
memcpy(baseName, name, strlen(name));
|
|
|
|
|
|
|
|
_sequenceNum = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MoviePlayerDXA::load() {
|
|
|
|
if ((_vm->getPlatform() == Common::kPlatformAmiga || _vm->getPlatform() == Common::kPlatformMacintosh) &&
|
|
|
|
_vm->_language != Common::EN_ANY) {
|
|
|
|
_sequenceNum = 0;
|
2010-05-18 14:17:24 +00:00
|
|
|
for (uint i = 0; i < 90; i++) {
|
2008-12-21 04:36:11 +00:00
|
|
|
if (!scumm_stricmp(baseName, _sequenceList[i]))
|
|
|
|
_sequenceNum = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-01 16:02:28 +00:00
|
|
|
Common::String videoName = Common::String::format("%s.dxa", baseName);
|
2012-01-27 19:30:02 +00:00
|
|
|
Common::SeekableReadStream *videoStream = _vm->_archives.createReadStreamForMember(videoName);
|
2011-08-27 14:40:55 +00:00
|
|
|
if (!videoStream)
|
2010-05-18 14:17:24 +00:00
|
|
|
error("Failed to load video file %s", videoName.c_str());
|
2011-08-27 14:40:55 +00:00
|
|
|
if (!loadStream(videoStream))
|
|
|
|
error("Failed to load video stream from file %s", videoName.c_str());
|
2008-12-21 04:36:11 +00:00
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
debug(0, "Playing video %s", videoName.c_str());
|
2008-12-21 04:36:11 +00:00
|
|
|
|
|
|
|
CursorMan.showMouse(false);
|
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
_firstFrameOffset = _fileStream->pos();
|
|
|
|
|
2008-12-21 04:36:11 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
void MoviePlayerDXA::copyFrameToBuffer(byte *dst, uint x, uint y, uint pitch) {
|
|
|
|
uint h = getHeight();
|
|
|
|
uint w = getWidth();
|
|
|
|
|
2010-12-16 01:35:13 +00:00
|
|
|
const Graphics::Surface *surface = decodeNextFrame();
|
2010-05-18 14:17:24 +00:00
|
|
|
byte *src = (byte *)surface->pixels;
|
|
|
|
dst += y * pitch + x;
|
|
|
|
|
|
|
|
do {
|
|
|
|
memcpy(dst, src, w);
|
|
|
|
dst += pitch;
|
|
|
|
src += w;
|
|
|
|
} while (--h);
|
|
|
|
|
|
|
|
if (hasDirtyPalette())
|
|
|
|
setSystemPalette();
|
|
|
|
}
|
|
|
|
|
2008-12-21 04:36:11 +00:00
|
|
|
void MoviePlayerDXA::playVideo() {
|
2009-08-15 10:31:20 +00:00
|
|
|
// Most of the videos included in the Amiga version, reduced the
|
2010-01-25 01:39:44 +00:00
|
|
|
// resoluton to 384 x 280, so require the screen to be cleared,
|
2009-08-15 10:31:20 +00:00
|
|
|
// before starting playing those videos.
|
|
|
|
if (getWidth() == 384 && getHeight() == 280) {
|
|
|
|
_vm->clearSurfaces();
|
|
|
|
}
|
|
|
|
|
2010-05-17 21:59:05 +00:00
|
|
|
while (!endOfVideo() && !_skipMovie && !_vm->shouldQuit())
|
2008-12-21 04:36:11 +00:00
|
|
|
handleNextFrame();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MoviePlayerDXA::stopVideo() {
|
2010-05-18 14:17:24 +00:00
|
|
|
close();
|
2008-12-21 04:36:11 +00:00
|
|
|
_mixer->stopHandle(_bgSound);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MoviePlayerDXA::startSound() {
|
2009-05-20 10:43:18 +00:00
|
|
|
uint32 offset, size;
|
2008-12-21 04:36:11 +00:00
|
|
|
|
2011-04-12 14:53:15 +00:00
|
|
|
if (getSoundTag() == MKTAG('W','A','V','E')) {
|
2008-12-21 04:36:11 +00:00
|
|
|
size = _fileStream->readUint32BE();
|
|
|
|
|
|
|
|
if (_sequenceNum) {
|
|
|
|
Common::File in;
|
|
|
|
|
|
|
|
_fileStream->seek(size, SEEK_CUR);
|
|
|
|
|
2012-01-23 11:20:31 +00:00
|
|
|
in.open("audio.wav");
|
2008-12-21 04:36:11 +00:00
|
|
|
if (!in.isOpen()) {
|
|
|
|
error("Can't read offset file 'audio.wav'");
|
|
|
|
}
|
|
|
|
|
|
|
|
in.seek(_sequenceNum * 8, SEEK_SET);
|
|
|
|
offset = in.readUint32LE();
|
|
|
|
size = in.readUint32LE();
|
|
|
|
|
|
|
|
in.seek(offset, SEEK_SET);
|
2010-01-16 21:36:08 +00:00
|
|
|
_bgSoundStream = Audio::makeWAVStream(in.readStream(size), DisposeAfterUse::YES);
|
2008-12-21 04:36:11 +00:00
|
|
|
in.close();
|
|
|
|
} else {
|
2010-01-16 21:36:08 +00:00
|
|
|
_bgSoundStream = Audio::makeWAVStream(_fileStream->readStream(size), DisposeAfterUse::YES);
|
2008-12-21 04:36:11 +00:00
|
|
|
}
|
|
|
|
} else {
|
2010-01-06 15:23:33 +00:00
|
|
|
_bgSoundStream = Audio::SeekableAudioStream::openStreamFile(baseName);
|
2008-12-21 04:36:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_bgSoundStream != NULL) {
|
|
|
|
_vm->_mixer->stopHandle(_bgSound);
|
2010-04-12 09:14:17 +00:00
|
|
|
_vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_bgSound, _bgSoundStream);
|
2008-12-21 04:36:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MoviePlayerDXA::nextFrame() {
|
2010-05-18 14:17:24 +00:00
|
|
|
if (_bgSoundStream && _vm->_mixer->isSoundHandleActive(_bgSound) && needsUpdate()) {
|
2008-12-21 04:36:11 +00:00
|
|
|
copyFrameToBuffer(_vm->getBackBuf(), 465, 222, _vm->_screenWidth);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-05-17 21:59:05 +00:00
|
|
|
if (_vm->_interactiveVideo == TYPE_LOOPING && endOfVideo()) {
|
2010-05-18 14:17:24 +00:00
|
|
|
_fileStream->seek(_firstFrameOffset);
|
|
|
|
_curFrame = -1;
|
2009-05-19 01:20:54 +00:00
|
|
|
startSound();
|
|
|
|
}
|
|
|
|
|
2010-05-17 21:59:05 +00:00
|
|
|
if (!endOfVideo()) {
|
2009-05-16 05:34:16 +00:00
|
|
|
if (_vm->_interactiveVideo == TYPE_OMNITV) {
|
|
|
|
copyFrameToBuffer(_vm->getBackBuf(), 465, 222, _vm->_screenWidth);
|
|
|
|
} else if (_vm->_interactiveVideo == TYPE_LOOPING) {
|
|
|
|
copyFrameToBuffer(_vm->getBackBuf(), (_vm->_screenWidth - getWidth()) / 2, (_vm->_screenHeight - getHeight()) / 2, _vm->_screenWidth);
|
|
|
|
}
|
2009-05-19 01:20:54 +00:00
|
|
|
} else if (_vm->_interactiveVideo == TYPE_OMNITV) {
|
2010-05-18 14:17:24 +00:00
|
|
|
close();
|
2009-05-19 01:20:54 +00:00
|
|
|
_vm->_interactiveVideo = 0;
|
|
|
|
_vm->_variableArray[254] = 6747;
|
2008-12-21 04:36:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MoviePlayerDXA::handleNextFrame() {
|
|
|
|
if (processFrame())
|
|
|
|
_vm->_system->updateScreen();
|
|
|
|
|
|
|
|
MoviePlayer::handleNextFrame();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MoviePlayerDXA::processFrame() {
|
|
|
|
Graphics::Surface *screen = _vm->_system->lockScreen();
|
2011-02-26 10:58:41 +00:00
|
|
|
copyFrameToBuffer((byte *)screen->pixels, (_vm->_screenWidth - getWidth()) / 2, (_vm->_screenHeight - getHeight()) / 2, screen->pitch);
|
2008-12-21 04:36:11 +00:00
|
|
|
_vm->_system->unlockScreen();
|
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
Common::Rational soundTime(_mixer->getSoundElapsedTime(_bgSound), 1000);
|
2010-09-07 09:02:46 +00:00
|
|
|
if ((_bgSoundStream == NULL) || ((soundTime * getFrameRate()).toInt() / 1000 < getCurFrame() + 1)) {
|
2008-12-21 04:36:11 +00:00
|
|
|
|
|
|
|
if (_bgSoundStream && _mixer->isSoundHandleActive(_bgSound)) {
|
2010-09-07 09:02:46 +00:00
|
|
|
while (_mixer->isSoundHandleActive(_bgSound) && (soundTime * getFrameRate()).toInt() < getCurFrame()) {
|
2008-12-21 04:36:11 +00:00
|
|
|
_vm->_system->delayMillis(10);
|
2010-05-18 14:17:24 +00:00
|
|
|
soundTime = Common::Rational(_mixer->getSoundElapsedTime(_bgSound), 1000);
|
2008-12-21 04:36:11 +00:00
|
|
|
}
|
|
|
|
// In case the background sound ends prematurely, update
|
|
|
|
// _ticks so that we can still fall back on the no-sound
|
|
|
|
// sync case for the subsequent frames.
|
|
|
|
_ticks = _vm->_system->getMillis();
|
|
|
|
} else {
|
2010-05-18 14:17:24 +00:00
|
|
|
_ticks += getTimeToNextFrame();
|
2008-12-21 04:36:11 +00:00
|
|
|
while (_vm->_system->getMillis() < _ticks)
|
|
|
|
_vm->_system->delayMillis(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-01-06 17:45:39 +00:00
|
|
|
warning("dropped frame %i", getCurFrame());
|
2008-12-21 04:36:11 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Movie player for Smacker movies
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2009-05-16 05:34:16 +00:00
|
|
|
MoviePlayerSMK::MoviePlayerSMK(AGOSEngine_Feeble *vm, const char *name)
|
2009-03-09 03:45:23 +00:00
|
|
|
: MoviePlayer(vm), SmackerDecoder(vm->_mixer) {
|
2008-12-21 04:36:11 +00:00
|
|
|
debug(0, "Creating SMK cutscene player");
|
|
|
|
|
|
|
|
memset(baseName, 0, sizeof(baseName));
|
|
|
|
memcpy(baseName, name, strlen(name));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MoviePlayerSMK::load() {
|
2010-11-01 16:02:28 +00:00
|
|
|
Common::String videoName = Common::String::format("%s.smk", baseName);
|
2008-12-21 04:36:11 +00:00
|
|
|
|
2012-01-27 19:30:02 +00:00
|
|
|
Common::SeekableReadStream *videoStream = _vm->_archives.createReadStreamForMember(videoName);
|
2011-08-27 14:40:55 +00:00
|
|
|
if (!videoStream)
|
2010-05-18 14:17:24 +00:00
|
|
|
error("Failed to load video file %s", videoName.c_str());
|
2011-08-27 14:40:55 +00:00
|
|
|
if (!loadStream(videoStream))
|
|
|
|
error("Failed to load video stream from file %s", videoName.c_str());
|
2008-12-21 04:36:11 +00:00
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
debug(0, "Playing video %s", videoName.c_str());
|
2008-12-21 04:36:11 +00:00
|
|
|
|
|
|
|
CursorMan.showMouse(false);
|
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
_firstFrameOffset = _fileStream->pos();
|
|
|
|
|
2008-12-21 04:36:11 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
void MoviePlayerSMK::copyFrameToBuffer(byte *dst, uint x, uint y, uint pitch) {
|
|
|
|
uint h = getHeight();
|
|
|
|
uint w = getWidth();
|
|
|
|
|
2010-12-16 01:35:13 +00:00
|
|
|
const Graphics::Surface *surface = decodeNextFrame();
|
2010-05-18 14:17:24 +00:00
|
|
|
byte *src = (byte *)surface->pixels;
|
|
|
|
dst += y * pitch + x;
|
|
|
|
|
|
|
|
do {
|
|
|
|
memcpy(dst, src, w);
|
|
|
|
dst += pitch;
|
|
|
|
src += w;
|
|
|
|
} while (--h);
|
|
|
|
|
|
|
|
if (hasDirtyPalette())
|
|
|
|
setSystemPalette();
|
|
|
|
}
|
|
|
|
|
2008-12-21 04:36:11 +00:00
|
|
|
void MoviePlayerSMK::playVideo() {
|
2010-05-17 21:59:05 +00:00
|
|
|
while (!endOfVideo() && !_skipMovie && !_vm->shouldQuit())
|
2008-12-21 04:36:11 +00:00
|
|
|
handleNextFrame();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MoviePlayerSMK::stopVideo() {
|
2010-05-18 14:17:24 +00:00
|
|
|
close();
|
2008-12-21 04:36:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MoviePlayerSMK::startSound() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void MoviePlayerSMK::handleNextFrame() {
|
2009-01-03 16:24:27 +00:00
|
|
|
processFrame();
|
2008-12-21 04:36:11 +00:00
|
|
|
|
|
|
|
MoviePlayer::handleNextFrame();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MoviePlayerSMK::nextFrame() {
|
2010-05-17 21:59:05 +00:00
|
|
|
if (_vm->_interactiveVideo == TYPE_LOOPING && endOfVideo()) {
|
2010-05-18 14:17:24 +00:00
|
|
|
_fileStream->seek(_firstFrameOffset);
|
|
|
|
_curFrame = -1;
|
2009-05-19 01:20:54 +00:00
|
|
|
}
|
|
|
|
|
2010-05-17 21:59:05 +00:00
|
|
|
if (!endOfVideo()) {
|
2008-12-21 04:36:11 +00:00
|
|
|
decodeNextFrame();
|
2009-05-16 05:34:16 +00:00
|
|
|
if (_vm->_interactiveVideo == TYPE_OMNITV) {
|
|
|
|
copyFrameToBuffer(_vm->getBackBuf(), 465, 222, _vm->_screenWidth);
|
|
|
|
} else if (_vm->_interactiveVideo == TYPE_LOOPING) {
|
|
|
|
copyFrameToBuffer(_vm->getBackBuf(), (_vm->_screenWidth - getWidth()) / 2, (_vm->_screenHeight - getHeight()) / 2, _vm->_screenWidth);
|
|
|
|
}
|
2009-05-19 01:20:54 +00:00
|
|
|
} else if (_vm->_interactiveVideo == TYPE_OMNITV) {
|
2010-05-18 14:17:24 +00:00
|
|
|
close();
|
2009-05-19 01:20:54 +00:00
|
|
|
_vm->_interactiveVideo = 0;
|
|
|
|
_vm->_variableArray[254] = 6747;
|
2008-12-21 04:36:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MoviePlayerSMK::processFrame() {
|
|
|
|
Graphics::Surface *screen = _vm->_system->lockScreen();
|
2011-02-26 10:58:41 +00:00
|
|
|
copyFrameToBuffer((byte *)screen->pixels, (_vm->_screenWidth - getWidth()) / 2, (_vm->_screenHeight - getHeight()) / 2, screen->pitch);
|
2008-12-21 04:36:11 +00:00
|
|
|
_vm->_system->unlockScreen();
|
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
uint32 waitTime = getTimeToNextFrame();
|
2008-12-21 04:36:11 +00:00
|
|
|
|
2009-01-03 13:32:14 +00:00
|
|
|
if (!waitTime) {
|
|
|
|
warning("dropped frame %i", getCurFrame());
|
|
|
|
return false;
|
2008-12-21 04:36:11 +00:00
|
|
|
}
|
|
|
|
|
2009-01-03 16:24:27 +00:00
|
|
|
_vm->_system->updateScreen();
|
|
|
|
|
|
|
|
// Wait before showing the next frame
|
2009-01-03 13:32:14 +00:00
|
|
|
_vm->_system->delayMillis(waitTime);
|
|
|
|
return true;
|
2008-12-21 04:36:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Factory function for creating the appropriate cutscene player
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2009-05-16 05:34:16 +00:00
|
|
|
MoviePlayer *makeMoviePlayer(AGOSEngine_Feeble *vm, const char *name) {
|
2008-12-21 04:36:11 +00:00
|
|
|
char baseName[40];
|
|
|
|
char filename[20];
|
|
|
|
|
|
|
|
int baseLen = strlen(name) - 4;
|
|
|
|
memset(baseName, 0, sizeof(baseName));
|
|
|
|
memcpy(baseName, name, baseLen);
|
|
|
|
|
|
|
|
if (vm->getLanguage() == Common::DE_DEU && baseLen >= 8) {
|
|
|
|
// Check short filename to work around
|
|
|
|
// bug in a German Windows 2CD version.
|
|
|
|
char shortName[20];
|
|
|
|
memset(shortName, 0, sizeof(shortName));
|
2008-12-29 15:08:10 +00:00
|
|
|
memcpy(shortName, baseName, 6);
|
2008-12-21 04:36:11 +00:00
|
|
|
|
|
|
|
sprintf(filename, "%s~1.dxa", shortName);
|
2011-11-13 23:35:02 +00:00
|
|
|
if (vm->_archives.hasFile(filename)) {
|
2008-12-21 04:36:11 +00:00
|
|
|
memset(baseName, 0, sizeof(baseName));
|
2009-01-20 05:43:57 +00:00
|
|
|
memcpy(baseName, filename, 8);
|
2008-12-21 04:36:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(filename, "%s~1.smk", shortName);
|
2011-11-13 23:35:02 +00:00
|
|
|
if (vm->_archives.hasFile(filename)) {
|
2008-12-21 04:36:11 +00:00
|
|
|
memset(baseName, 0, sizeof(baseName));
|
2009-01-20 05:43:57 +00:00
|
|
|
memcpy(baseName, filename, 8);
|
2008-12-21 04:36:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(filename, "%s.dxa", baseName);
|
2011-11-13 23:35:02 +00:00
|
|
|
if (vm->_archives.hasFile(filename)) {
|
2008-12-21 04:36:11 +00:00
|
|
|
return new MoviePlayerDXA(vm, baseName);
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(filename, "%s.smk", baseName);
|
2011-11-13 23:35:02 +00:00
|
|
|
if (vm->_archives.hasFile(filename)) {
|
2008-12-21 04:36:11 +00:00
|
|
|
return new MoviePlayerSMK(vm, baseName);
|
|
|
|
}
|
|
|
|
|
2011-06-13 21:19:18 +00:00
|
|
|
Common::String buf = Common::String::format(_("Cutscene file '%s' not found!"), baseName);
|
|
|
|
GUI::MessageDialog dialog(buf, _("OK"));
|
2008-12-31 16:06:55 +00:00
|
|
|
dialog.runModal();
|
|
|
|
|
2008-12-21 04:36:11 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
} // End of namespace AGOS
|
2009-08-12 00:53:35 +00:00
|
|
|
|
|
|
|
#endif // ENABLE_AGOS2
|