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.
|
2004-01-13 01:26:18 +00:00
|
|
|
*
|
2007-05-31 20:28:29 +00:00
|
|
|
* Additional copyright for this file:
|
|
|
|
* Copyright (C) 1994-1998 Revolution Software Ltd.
|
|
|
|
*
|
2004-01-13 01:26:18 +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.
|
2006-02-09 15:12:44 +00:00
|
|
|
*
|
2004-01-13 01:26:18 +00:00
|
|
|
* 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.
|
2006-02-09 15:12:44 +00:00
|
|
|
*
|
2004-01-13 01:26:18 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-01-13 01:26:18 +00:00
|
|
|
*
|
2006-02-09 15:12:44 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2004-01-13 01:26:18 +00:00
|
|
|
*/
|
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
#include "common/file.h"
|
2005-01-10 22:06:49 +00:00
|
|
|
#include "common/system.h"
|
2006-07-08 11:42:07 +00:00
|
|
|
|
2004-01-12 11:11:19 +00:00
|
|
|
#include "sword2/sword2.h"
|
2005-02-27 16:11:19 +00:00
|
|
|
#include "sword2/defs.h"
|
2006-02-17 15:07:36 +00:00
|
|
|
#include "sword2/header.h"
|
2004-02-05 14:19:07 +00:00
|
|
|
#include "sword2/maketext.h"
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
#include "sword2/resman.h"
|
|
|
|
#include "sword2/sound.h"
|
2006-02-09 15:41:23 +00:00
|
|
|
#include "sword2/animation.h"
|
2004-01-12 11:11:19 +00:00
|
|
|
|
2009-02-15 13:29:48 +00:00
|
|
|
#include "gui/message.h"
|
|
|
|
|
2004-01-12 11:11:19 +00:00
|
|
|
namespace Sword2 {
|
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Basic movie player
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2004-01-13 14:16:40 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
static const MovieInfo sequenceList[19] = {
|
2006-07-15 22:04:42 +00:00
|
|
|
{ "carib", 222, false },
|
|
|
|
{ "escape", 187, false },
|
|
|
|
{ "eye", 248, false },
|
|
|
|
{ "finale", 1485, false },
|
|
|
|
{ "guard", 75, false },
|
|
|
|
{ "intro", 1800, false },
|
|
|
|
{ "jungle", 186, false },
|
|
|
|
{ "museum", 167, false },
|
|
|
|
{ "pablo", 75, false },
|
|
|
|
{ "pyramid", 60, false },
|
|
|
|
{ "quaram", 184, false },
|
|
|
|
{ "river", 656, false },
|
|
|
|
{ "sailing", 138, false },
|
|
|
|
{ "shaman", 788, true },
|
|
|
|
{ "stone1", 34, true },
|
|
|
|
{ "stone2", 282, false },
|
|
|
|
{ "stone3", 65, true },
|
|
|
|
{ "demo", 60, false },
|
|
|
|
{ "enddemo", 110, false }
|
2004-02-15 14:22:54 +00:00
|
|
|
};
|
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
MoviePlayer::MoviePlayer(Sword2Engine *vm, Audio::Mixer *snd, OSystem *system, Audio::SoundHandle *bgSoundHandle, Graphics::VideoDecoder *decoder, DecoderType decoderType)
|
|
|
|
: _vm(vm), _snd(snd), _bgSoundHandle(bgSoundHandle), _system(system), VideoPlayer(decoder) {
|
2006-07-08 11:42:07 +00:00
|
|
|
_bgSoundStream = NULL;
|
2009-02-21 15:07:05 +00:00
|
|
|
_decoderType = decoderType;
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
MoviePlayer:: ~MoviePlayer(void) {
|
|
|
|
delete _bgSoundHandle;
|
|
|
|
delete _decoder;
|
2008-11-09 13:20:43 +00:00
|
|
|
}
|
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
/**
|
|
|
|
* Plays an animated cutscene.
|
|
|
|
* @param id the id of the file
|
|
|
|
*/
|
|
|
|
bool MoviePlayer::load(const char *name) {
|
|
|
|
_id = -1;
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
for (int i = 0; i < ARRAYSIZE(sequenceList); i++) {
|
|
|
|
if (scumm_stricmp(name, sequenceList[i].name) == 0) {
|
|
|
|
_id = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
if (_decoderType == kVideoDecoderDXA) {
|
|
|
|
_bgSoundStream = Audio::AudioStream::openStreamFile(name);
|
|
|
|
} else {
|
|
|
|
_bgSoundStream = NULL;
|
|
|
|
}
|
2004-03-24 07:29:59 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
_textSurface = NULL;
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
char filename[20];
|
|
|
|
switch (_decoderType) {
|
|
|
|
case kVideoDecoderDXA:
|
|
|
|
snprintf(filename, sizeof(filename), "%s.dxa", name);
|
|
|
|
break;
|
|
|
|
case kVideoDecoderSMK:
|
|
|
|
snprintf(filename, sizeof(filename), "%s.smk", name);
|
|
|
|
break;
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
if (_decoder->loadFile(filename)) {
|
|
|
|
// The DXA animations in the Broken Sword games always use external audio tracks,
|
|
|
|
// if they have any sound at all.
|
|
|
|
if (_decoderType == kVideoDecoderDXA && _decoder->readSoundHeader() != MKID_BE('NULL'))
|
2006-07-08 11:42:07 +00:00
|
|
|
return false;
|
|
|
|
} else {
|
2009-02-21 15:07:05 +00:00
|
|
|
return false;
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
}
|
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
void MoviePlayer::play(MovieText *movieTexts, uint32 numMovieTexts, uint32 leadIn, uint32 leadOut) {
|
|
|
|
// This happens when quitting during the "eye" cutscene.
|
|
|
|
if (_vm->shouldQuit())
|
|
|
|
return;
|
|
|
|
|
|
|
|
bool seamless = false;
|
2006-07-15 23:44:44 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
if (_id >= 0) {
|
|
|
|
seamless = sequenceList[_id].seamless;
|
|
|
|
_numFrames = sequenceList[_id].frames;
|
|
|
|
if (_numFrames > 60)
|
|
|
|
_leadOutFrame = _numFrames - 60;
|
2006-07-15 23:44:44 +00:00
|
|
|
}
|
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
_movieTexts = movieTexts;
|
|
|
|
_numMovieTexts = numMovieTexts;
|
|
|
|
_currentMovieText = 0;
|
|
|
|
_leadOut = leadOut;
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
if (leadIn) {
|
|
|
|
_vm->_sound->playMovieSound(leadIn, kLeadInSound);
|
|
|
|
}
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
if (_bgSoundStream) {
|
|
|
|
_snd->playInputStream(Audio::Mixer::kSFXSoundType, _bgSoundHandle, _bgSoundStream);
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
}
|
2007-04-14 14:07:11 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
bool terminated = false;
|
|
|
|
|
|
|
|
Common::List<Common::Event> stopEvents;
|
|
|
|
Common::Event stopEvent;
|
|
|
|
stopEvents.clear();
|
|
|
|
stopEvent.type = Common::EVENT_KEYDOWN;
|
|
|
|
stopEvent.kbd = Common::KEYCODE_ESCAPE;
|
|
|
|
stopEvents.push_back(stopEvent);
|
|
|
|
|
|
|
|
terminated = !playVideo(&stopEvents);
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
closeTextObject(_currentMovieText);
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
if (terminated) {
|
|
|
|
_snd->stopHandle(*_bgSoundHandle);
|
|
|
|
_vm->_sound->stopMovieSounds();
|
|
|
|
_vm->_sound->stopSpeech();
|
|
|
|
}
|
|
|
|
|
|
|
|
while (_snd->isSoundHandleActive(*_bgSoundHandle))
|
|
|
|
_system->delayMillis(100);
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
void MoviePlayer::openTextObject(uint32 index) {
|
|
|
|
MovieText *text = &_movieTexts[index];
|
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
// Pull out the text line to get the official text number (for WAV id)
|
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
uint32 res = text->_textNumber / SIZE;
|
|
|
|
uint32 localText = text->_textNumber & 0xffff;
|
2007-02-08 21:55:37 +00:00
|
|
|
|
|
|
|
// Open text resource and get the line
|
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
byte *textData = _vm->fetchTextLine(_vm->_resman->openResource(res), localText);
|
2007-02-08 21:55:37 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
text->_speechId = READ_LE_UINT16(textData);
|
2007-02-08 21:55:37 +00:00
|
|
|
|
|
|
|
// Is it speech or subtitles, or both?
|
|
|
|
|
|
|
|
// If we want subtitles, or there was no sound
|
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
if (_vm->getSubtitles() || !text->_speechId) {
|
|
|
|
text->_textMem = _vm->_fontRenderer->makeTextSprite(textData + 2, 600, 255, _vm->_speechFontId, 1);
|
2007-02-08 21:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_vm->_resman->closeResource(res);
|
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
if (text->_textMem) {
|
2007-02-08 21:55:37 +00:00
|
|
|
FrameHeader frame;
|
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
frame.read(text->_textMem);
|
2007-02-08 21:55:37 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
text->_textSprite.x = 320 - frame.width / 2;
|
|
|
|
text->_textSprite.y = 440 - frame.height;
|
|
|
|
text->_textSprite.w = frame.width;
|
|
|
|
text->_textSprite.h = frame.height;
|
|
|
|
text->_textSprite.type = RDSPR_DISPLAYALIGN | RDSPR_NOCOMPRESSION;
|
|
|
|
text->_textSprite.data = text->_textMem + FrameHeader::size();
|
|
|
|
_vm->_screen->createSurface(&text->_textSprite, &_textSurface);
|
|
|
|
|
|
|
|
_textX = 320 - text->_textSprite.w / 2;
|
|
|
|
_textY = 420 - text->_textSprite.h;
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
|
|
|
}
|
2005-04-24 15:38:53 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
void MoviePlayer::closeTextObject(uint32 index) {
|
|
|
|
if (index < _numMovieTexts) {
|
|
|
|
MovieText *text = &_movieTexts[index];
|
2007-02-08 21:55:37 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
free(text->_textMem);
|
|
|
|
text->_textMem = NULL;
|
2007-02-08 21:55:37 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
if (_textSurface) {
|
|
|
|
_vm->_screen->deleteSurface(_textSurface);
|
|
|
|
_textSurface = NULL;
|
|
|
|
}
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
void MoviePlayer::drawTextObject(uint32 index, byte *screen) {
|
|
|
|
MovieText *text = &_movieTexts[index];
|
2006-08-23 21:13:11 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
byte white = _decoder->getWhite();
|
|
|
|
byte black = _decoder->getBlack();
|
2006-08-23 21:13:11 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
if (text->_textMem && _textSurface) {
|
|
|
|
byte *src = text->_textSprite.data;
|
|
|
|
uint16 width = text->_textSprite.w;
|
|
|
|
uint16 height = text->_textSprite.h;
|
2006-08-23 21:13:11 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
byte *dst = screen + _textY * _decoder->getWidth() + _textX;
|
2006-07-08 11:42:07 +00:00
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
for (int y = 0; y < height; y++) {
|
|
|
|
for (int x = 0; x < width; x++) {
|
2006-07-08 11:42:07 +00:00
|
|
|
if (src[x] == 1)
|
2009-02-21 15:07:05 +00:00
|
|
|
dst[x] = black;
|
2006-07-15 22:22:39 +00:00
|
|
|
else if (src[x] == 255)
|
2009-02-21 15:07:05 +00:00
|
|
|
dst[x] = white;
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
2007-02-08 21:55:37 +00:00
|
|
|
src += width;
|
2009-02-21 15:07:05 +00:00
|
|
|
dst += _decoder->getWidth();
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
|
|
|
}
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
}
|
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
// FIXME: This assumes that the subtitles always fit within the frame of the
|
|
|
|
// movie. In Broken Sword 2, that's a fairly safe assumption, but not
|
|
|
|
// necessarily in all other games.
|
2006-07-08 11:42:07 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
void MoviePlayer::performPostProcessing(byte *screen) {
|
|
|
|
MovieText *text;
|
|
|
|
int frame = _decoder->getCurFrame();
|
2006-07-08 11:42:07 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
if (_currentMovieText < _numMovieTexts) {
|
|
|
|
text = &_movieTexts[_currentMovieText];
|
|
|
|
} else {
|
|
|
|
text = NULL;
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
if (text && frame == text->_startFrame) {
|
|
|
|
if ((_vm->getSubtitles() || !text->_speechId) && _currentMovieText < _numMovieTexts) {
|
|
|
|
openTextObject(_currentMovieText);
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
|
|
|
}
|
2004-02-15 14:22:54 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
if (text && frame >= text->_startFrame) {
|
|
|
|
if (text->_speechId && !text->_played && _vm->_sound->amISpeaking() == RDSE_QUIET) {
|
|
|
|
text->_played = true;
|
|
|
|
_vm->_sound->playCompSpeech(text->_speechId, 16, 0);
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
2009-02-21 15:07:05 +00:00
|
|
|
if (frame <= text->_endFrame) {
|
|
|
|
drawTextObject(_currentMovieText, screen);
|
2006-07-08 11:42:07 +00:00
|
|
|
} else {
|
2009-02-21 15:07:05 +00:00
|
|
|
_currentMovieText++;
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
if (_leadOut && _decoder->getCurFrame() == _leadOutFrame) {
|
|
|
|
_vm->_sound->playMovieSound(_leadOut, kLeadOutSound);
|
Began what I hope is the final major restructuring of the BS2 engine.
In this first step, I have moved all opcode functions into functions.cpp,
instead of having them scattered all over the place.
To get things to compile again, I had to rewrite the overly complicated
sound effects handling. It's much simpler now.
The next step will be to move any non-trivial code out of the opcode
functions and into the appropriate object. This, I hope, will make it
easier to create well-separated objects, instead of the current mess.
I also want to tear down the artificial boundary between the main directory
and the "driver" directory. We already have a cross-platform layer; there's
no need to have yet another one. (Actually, the rewriting of the sound
effects code took one first step in this direction.)
At the final stage, I'd like to get rid of the "drivers" directory
completely, but I'll probably need some help with that if I want to
preserve the CVS history of the code.
Things will probably be a bit bumpy along the way, but I seem to have
reached a point of relative stability again, which is why I'm commiting
this now.
svn-id: r16668
2005-01-28 16:33:14 +00:00
|
|
|
}
|
2009-02-21 15:07:05 +00:00
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
DXAPlayerWithSound::DXAPlayerWithSound(Audio::Mixer *mixer, Audio::SoundHandle *bgSoundHandle)
|
|
|
|
: _mixer(mixer), _bgSoundHandle(bgSoundHandle) {
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
int32 DXAPlayerWithSound::getAudioLag() {
|
|
|
|
if (!_fileStream)
|
|
|
|
return 0;
|
2006-07-08 11:42:07 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
if (!_mixer->isSoundHandleActive(*_bgSoundHandle))
|
|
|
|
return 0;
|
2006-07-08 11:42:07 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
int32 frameDelay = getFrameDelay();
|
|
|
|
int32 videoTime = _videoInfo.currentFrame * frameDelay;
|
|
|
|
int32 audioTime;
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
audioTime = (((int32) _mixer->getSoundElapsedTime(*_bgSoundHandle)) * 100);
|
2006-07-08 11:42:07 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
return videoTime - audioTime;
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Factory function for creating the appropriate cutscene player
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
MoviePlayer *makeMoviePlayer(const char *name, Sword2Engine *vm, Audio::Mixer *snd, OSystem *system) {
|
|
|
|
char filename[20];
|
|
|
|
char buf[60];
|
|
|
|
Audio::SoundHandle *bgSoundHandle = new Audio::SoundHandle;
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2009-02-15 13:29:48 +00:00
|
|
|
snprintf(filename, sizeof(filename), "%s.smk", name);
|
|
|
|
|
|
|
|
if (Common::File::exists(filename)) {
|
2009-02-21 15:07:05 +00:00
|
|
|
Graphics::SMKPlayer *smkDecoder = new Graphics::SMKPlayer(snd);
|
|
|
|
return new MoviePlayer(vm, snd, system, bgSoundHandle, smkDecoder, kVideoDecoderSMK);
|
2009-02-15 13:29:48 +00:00
|
|
|
}
|
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
snprintf(filename, sizeof(filename), "%s.dxa", name);
|
|
|
|
|
|
|
|
if (Common::File::exists(filename)) {
|
2009-02-21 15:07:05 +00:00
|
|
|
#ifdef USE_ZLIB
|
|
|
|
DXAPlayerWithSound *dxaDecoder = new DXAPlayerWithSound(snd, bgSoundHandle);
|
|
|
|
return new MoviePlayer(vm, snd, system, bgSoundHandle, dxaDecoder, kVideoDecoderDXA);
|
|
|
|
#else
|
|
|
|
GUI::MessageDialog dialog("DXA cutscenes found but ScummVM has been built without zlib support", "OK");
|
|
|
|
dialog.runModal();
|
|
|
|
return NULL;
|
2006-07-08 11:42:07 +00:00
|
|
|
#endif
|
2009-02-21 15:07:05 +00:00
|
|
|
}
|
2006-07-08 11:42:07 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
// Old MPEG2 cutscenes
|
2006-07-08 11:42:07 +00:00
|
|
|
snprintf(filename, sizeof(filename), "%s.mp2", name);
|
|
|
|
|
|
|
|
if (Common::File::exists(filename)) {
|
2009-02-15 13:29:48 +00:00
|
|
|
GUI::MessageDialog dialog("MPEG2 cutscenes are no longer supported", "OK");
|
|
|
|
dialog.runModal();
|
2009-02-21 15:07:05 +00:00
|
|
|
return NULL;
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
sprintf(buf, "Cutscene '%s' not found", name);
|
|
|
|
GUI::MessageDialog dialog(buf, "OK");
|
|
|
|
dialog.runModal();
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MoviePlayer::pauseMovie(bool pause) {
|
|
|
|
if (_bgSoundHandle) {
|
|
|
|
_snd->pauseHandle(*_bgSoundHandle, pause);
|
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
2004-01-12 11:11:19 +00:00
|
|
|
} // End of namespace Sword2
|