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"
|
2009-03-07 17:27:18 +00:00
|
|
|
#include "sword2/logic.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"
|
2009-04-07 19:52:46 +00:00
|
|
|
#include "sword2/screen.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
|
|
|
MoviePlayer::MoviePlayer(Sword2Engine *vm, Audio::Mixer *snd, OSystem *system, Audio::SoundHandle *bgSoundHandle, Graphics::VideoDecoder *decoder, DecoderType decoderType)
|
2010-05-18 14:17:24 +00:00
|
|
|
: _vm(vm), _snd(snd), _bgSoundHandle(bgSoundHandle), _system(system) {
|
2006-07-08 11:42:07 +00:00
|
|
|
_bgSoundStream = NULL;
|
2009-02-21 15:07:05 +00:00
|
|
|
_decoderType = decoderType;
|
2010-05-18 14:17:24 +00:00
|
|
|
_decoder = decoder;
|
2010-05-23 11:16:10 +00:00
|
|
|
|
|
|
|
_white = 255;
|
|
|
|
_black = 0;
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
2009-11-02 21:54:57 +00:00
|
|
|
MoviePlayer:: ~MoviePlayer() {
|
2009-02-21 15:07:05 +00:00
|
|
|
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) {
|
2010-05-18 14:17:24 +00:00
|
|
|
if (_decoderType == kVideoDecoderDXA)
|
2010-01-06 15:23:33 +00:00
|
|
|
_bgSoundStream = Audio::SeekableAudioStream::openStreamFile(name);
|
2010-05-18 14:17:24 +00:00
|
|
|
else
|
2009-02-21 15:07:05 +00:00
|
|
|
_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-05-20 10:43:18 +00:00
|
|
|
return _decoder->loadFile(filename);
|
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::play(MovieText *movieTexts, uint32 numMovieTexts, uint32 leadIn, uint32 leadOut) {
|
|
|
|
// This happens when quitting during the "eye" cutscene.
|
|
|
|
if (_vm->shouldQuit())
|
|
|
|
return;
|
|
|
|
|
2009-05-20 04:29:09 +00:00
|
|
|
_leadOutFrame = _decoder->getFrameCount();
|
|
|
|
if (_leadOutFrame > 60)
|
|
|
|
_leadOutFrame -= 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
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
if (leadIn)
|
2009-02-21 15:07:05 +00:00
|
|
|
_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
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
if (_bgSoundStream)
|
2010-04-12 09:14:17 +00:00
|
|
|
_snd->playStream(Audio::Mixer::kSFXSoundType, _bgSoundHandle, _bgSoundStream);
|
2007-04-14 14:07:11 +00:00
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
bool terminated = false;
|
|
|
|
|
2009-10-16 07:42:23 +00:00
|
|
|
terminated = !playVideo();
|
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-07-28 17:53:59 +00:00
|
|
|
closeTextObject(_currentMovieText, 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
|
|
|
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();
|
2009-04-07 19:52:46 +00:00
|
|
|
text->_textSprite.isText = true;
|
2009-02-21 15:07:05 +00:00
|
|
|
_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-07-28 17:53:59 +00:00
|
|
|
void MoviePlayer::closeTextObject(uint32 index, byte *screen) {
|
2009-02-21 15:07:05 +00:00
|
|
|
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) {
|
2009-07-28 17:53:59 +00:00
|
|
|
if (screen) {
|
|
|
|
// If the frame doesn't cover the entire
|
|
|
|
// screen, we have to erase the subtitles
|
|
|
|
// manually.
|
|
|
|
|
|
|
|
int frameWidth = _decoder->getWidth();
|
|
|
|
int frameHeight = _decoder->getHeight();
|
|
|
|
int frameX = (_system->getWidth() - frameWidth) / 2;
|
|
|
|
int frameY = (_system->getHeight() - frameHeight) / 2;
|
|
|
|
|
|
|
|
byte *dst = screen + _textY * _system->getWidth();
|
|
|
|
|
|
|
|
for (int y = 0; y < text->_textSprite.h; y++) {
|
|
|
|
if (_textY + y < frameY || _textY + y >= frameY + frameHeight) {
|
2010-05-18 14:17:24 +00:00
|
|
|
memset(dst + _textX, findBlackPalIndex(), text->_textSprite.w);
|
2009-07-28 17:53:59 +00:00
|
|
|
} else {
|
|
|
|
if (frameX > _textX)
|
2010-05-18 14:17:24 +00:00
|
|
|
memset(dst + _textX, findBlackPalIndex(), frameX - _textX);
|
2009-07-28 17:53:59 +00:00
|
|
|
if (frameX + frameWidth < _textX + text->_textSprite.w)
|
2010-05-18 14:17:24 +00:00
|
|
|
memset(dst + frameX + frameWidth, findBlackPalIndex(), _textX + text->_textSprite.w - (frameX + frameWidth));
|
2009-07-28 17:53:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dst += _system->getWidth();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-21 15:07:05 +00:00
|
|
|
_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
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
byte white = findWhitePalIndex();
|
|
|
|
byte black = findBlackPalIndex();
|
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-04-07 19:52:46 +00:00
|
|
|
// Resize text sprites for PSX version
|
2009-05-24 15:17:42 +00:00
|
|
|
if (Sword2Engine::isPsx()) {
|
2009-04-07 19:52:46 +00:00
|
|
|
height *= 2;
|
|
|
|
byte *buffer = (byte *)malloc(width * height);
|
|
|
|
Screen::resizePsxSprite(buffer, src, width, height);
|
|
|
|
src = buffer;
|
|
|
|
}
|
|
|
|
|
2009-07-28 17:53:59 +00:00
|
|
|
byte *dst = screen + _textY * RENDERWIDE + _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-07-28 17:53:59 +00:00
|
|
|
dst += RENDERWIDE;
|
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::performPostProcessing(byte *screen) {
|
|
|
|
MovieText *text;
|
2010-05-18 14:17:24 +00:00
|
|
|
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
|
|
|
}
|
2010-05-15 08:54:58 +00:00
|
|
|
if (frame < text->_endFrame) {
|
2009-02-21 15:07:05 +00:00
|
|
|
drawTextObject(_currentMovieText, screen);
|
2006-07-08 11:42:07 +00:00
|
|
|
} else {
|
2009-07-28 17:53:59 +00:00
|
|
|
closeTextObject(_currentMovieText, screen);
|
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
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
bool MoviePlayer::playVideo() {
|
|
|
|
uint16 x = (g_system->getWidth() - _decoder->getWidth()) / 2;
|
|
|
|
uint16 y = (g_system->getHeight() - _decoder->getHeight()) / 2;
|
|
|
|
|
|
|
|
while (!_vm->shouldQuit() && !_decoder->endOfVideo()) {
|
|
|
|
if (_decoder->needsUpdate()) {
|
|
|
|
Graphics::Surface *frame = _decoder->decodeNextFrame();
|
|
|
|
if (frame)
|
|
|
|
_vm->_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);
|
|
|
|
|
2010-05-23 11:16:10 +00:00
|
|
|
if (_decoder->hasDirtyPalette()) {
|
2010-05-18 14:17:24 +00:00
|
|
|
_decoder->setSystemPalette();
|
|
|
|
|
2010-05-23 11:16:10 +00:00
|
|
|
uint32 maxWeight = 0;
|
|
|
|
uint32 minWeight = 0xFFFFFFFF;
|
|
|
|
uint32 weight;
|
|
|
|
byte r, g, b;
|
|
|
|
|
|
|
|
byte *palette = _decoder->getPalette();
|
|
|
|
|
|
|
|
for (int i = 0; i < 256; i++) {
|
|
|
|
r = *palette++;
|
|
|
|
g = *palette++;
|
|
|
|
b = *palette++;
|
|
|
|
|
|
|
|
weight = 3 * r * r + 6 * g * g + 2 * b * b;
|
|
|
|
|
|
|
|
if (weight >= maxWeight) {
|
|
|
|
maxWeight = weight;
|
|
|
|
_white = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (weight <= minWeight) {
|
|
|
|
minWeight = weight;
|
|
|
|
_black = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
Graphics::Surface *screen = _vm->_system->lockScreen();
|
|
|
|
performPostProcessing((byte *)screen->pixels);
|
|
|
|
_vm->_system->unlockScreen();
|
|
|
|
_vm->_system->updateScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Event event;
|
|
|
|
while (_vm->_system->getEventManager()->pollEvent(event))
|
|
|
|
if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) || event.type == Common::EVENT_LBUTTONUP)
|
|
|
|
return false;
|
2010-05-23 10:50:14 +00:00
|
|
|
|
|
|
|
_vm->_system->delayMillis(10);
|
2010-05-18 14:17:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return !_vm->shouldQuit();
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
byte MoviePlayer::findBlackPalIndex() {
|
2010-05-23 11:16:10 +00:00
|
|
|
return _black;
|
2010-05-18 14:17:24 +00:00
|
|
|
}
|
2006-07-08 11:42:07 +00:00
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
byte MoviePlayer::findWhitePalIndex() {
|
2010-05-23 11:16:10 +00:00
|
|
|
return _white;
|
2010-05-18 14:17:24 +00:00
|
|
|
}
|
2006-07-08 11:42:07 +00:00
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
DXADecoderWithSound::DXADecoderWithSound(Audio::Mixer *mixer, Audio::SoundHandle *bgSoundHandle)
|
|
|
|
: _mixer(mixer), _bgSoundHandle(bgSoundHandle) {
|
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
uint32 DXADecoderWithSound::getElapsedTime() const {
|
|
|
|
if (_mixer->isSoundHandleActive(*_bgSoundHandle))
|
|
|
|
return _mixer->getSoundElapsedTime(*_bgSoundHandle);
|
2006-07-08 11:42:07 +00:00
|
|
|
|
2010-05-18 14:17:24 +00:00
|
|
|
return VideoDecoder::getElapsedTime();
|
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-03-09 03:45:23 +00:00
|
|
|
Graphics::SmackerDecoder *smkDecoder = new Graphics::SmackerDecoder(snd);
|
2009-02-21 15:07:05 +00:00
|
|
|
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
|
2009-03-09 03:45:23 +00:00
|
|
|
DXADecoderWithSound *dxaDecoder = new DXADecoderWithSound(snd, bgSoundHandle);
|
2009-02-21 15:07:05 +00:00
|
|
|
return new MoviePlayer(vm, snd, system, bgSoundHandle, dxaDecoder, kVideoDecoderDXA);
|
|
|
|
#else
|
2009-03-07 19:24:31 +00:00
|
|
|
GUI::MessageDialog dialog("DXA cutscenes found but ScummVM has been built without zlib support", "OK");
|
|
|
|
dialog.runModal();
|
2009-02-21 15:07:05 +00:00
|
|
|
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-03-07 19:24:31 +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-09-18 16:39:14 +00:00
|
|
|
// The demo tries to play some cutscenes that aren't there, so make those warnings more discreet.
|
|
|
|
// In addition, some of the later re-releases of the game don't have the "eye" Virgin logo movie.
|
|
|
|
if (!vm->_logic->readVar(DEMO) && strcmp(name, "eye") != 0) {
|
2009-03-07 17:27:18 +00:00
|
|
|
sprintf(buf, "Cutscene '%s' not found", name);
|
2009-03-07 19:24:31 +00:00
|
|
|
GUI::MessageDialog dialog(buf, "OK");
|
|
|
|
dialog.runModal();
|
2009-03-07 17:27:18 +00:00
|
|
|
} else
|
|
|
|
warning("Cutscene '%s' not found", name);
|
2009-02-21 15:07:05 +00:00
|
|
|
|
|
|
|
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
|