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
|
|
|
*/
|
|
|
|
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2004-12-21 02:12:58 +00:00
|
|
|
#include "common/config-manager.h"
|
2006-07-08 11:42:07 +00:00
|
|
|
#include "common/file.h"
|
2007-03-17 00:53:21 +00:00
|
|
|
#include "common/events.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"
|
2007-02-08 21:55:37 +00:00
|
|
|
#include "sword2/logic.h"
|
2004-02-05 14:19:07 +00:00
|
|
|
#include "sword2/maketext.h"
|
2006-07-08 11:42:07 +00:00
|
|
|
#include "sword2/mouse.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"
|
2006-02-17 15:07:36 +00:00
|
|
|
#include "sword2/screen.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/sound.h"
|
2006-02-09 15:41:23 +00:00
|
|
|
#include "sword2/animation.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
|
|
|
|
2006-07-15 22:04:42 +00:00
|
|
|
const MovieInfo MoviePlayer::_movies[19] = {
|
|
|
|
{ "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
|
|
|
};
|
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
MoviePlayer::MoviePlayer(Sword2Engine *vm, const char *name) {
|
2006-07-08 11:42:07 +00:00
|
|
|
_vm = vm;
|
2007-02-08 21:55:37 +00:00
|
|
|
_name = strdup(name);
|
2006-07-08 11:42:07 +00:00
|
|
|
_mixer = _vm->_mixer;
|
|
|
|
_system = _vm->_system;
|
2008-11-09 13:20:43 +00:00
|
|
|
_pauseTicks = 0;
|
2006-07-08 11:42:07 +00:00
|
|
|
_textSurface = NULL;
|
|
|
|
_bgSoundStream = NULL;
|
|
|
|
_ticks = 0;
|
|
|
|
_currentFrame = 0;
|
|
|
|
_frameBuffer = NULL;
|
|
|
|
_frameWidth = 0;
|
|
|
|
_frameHeight = 0;
|
|
|
|
_frameX = 0;
|
|
|
|
_frameY = 0;
|
|
|
|
_black = 1;
|
|
|
|
_white = 255;
|
|
|
|
_numFrames = 0;
|
|
|
|
_leadOutFrame = (uint)-1;
|
|
|
|
_seamless = false;
|
|
|
|
_framesSkipped = 0;
|
|
|
|
_forceFrame = false;
|
|
|
|
_currentText = 0;
|
2004-03-21 18:49:04 +00:00
|
|
|
}
|
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
MoviePlayer::~MoviePlayer() {
|
2006-08-26 12:29:00 +00:00
|
|
|
free(_name);
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
2008-11-09 13:20:43 +00:00
|
|
|
uint32 MoviePlayer::getTick() {
|
|
|
|
return _system->getMillis() - _pauseTicks;
|
|
|
|
}
|
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
void MoviePlayer::updatePalette(byte *pal, bool packed) {
|
|
|
|
byte palette[4 * 256];
|
|
|
|
byte *p = palette;
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
uint32 maxWeight = 0;
|
|
|
|
uint32 minWeight = 0xFFFFFFFF;
|
|
|
|
|
|
|
|
for (int i = 0; i < 256; i++) {
|
|
|
|
int r = *pal++;
|
|
|
|
int g = *pal++;
|
|
|
|
int b = *pal++;
|
|
|
|
|
|
|
|
if (!packed)
|
|
|
|
pal++;
|
|
|
|
|
|
|
|
uint32 weight = 3 * r * r + 6 * g * g + 2 * b * b;
|
|
|
|
|
|
|
|
if (weight >= maxWeight) {
|
2006-07-15 22:22:39 +00:00
|
|
|
_white = i;
|
2006-07-08 11:42:07 +00:00
|
|
|
maxWeight = weight;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (weight <= minWeight) {
|
2006-07-15 22:22:39 +00:00
|
|
|
_black = i;
|
2006-07-08 11:42:07 +00:00
|
|
|
minWeight = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
*p++ = r;
|
|
|
|
*p++ = g;
|
|
|
|
*p++ = b;
|
|
|
|
*p++ = 0;
|
2004-01-18 21:09:57 +00:00
|
|
|
}
|
2006-07-08 11:42:07 +00:00
|
|
|
|
|
|
|
_vm->_screen->setPalette(0, 256, palette, RDPAL_INSTANT);
|
|
|
|
_forceFrame = true;
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
void MoviePlayer::savePalette() {
|
|
|
|
memcpy(_originalPalette, _vm->_screen->getPalette(), sizeof(_originalPalette));
|
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
void MoviePlayer::restorePalette() {
|
|
|
|
_vm->_screen->setPalette(0, 256, _originalPalette, RDPAL_INSTANT);
|
|
|
|
}
|
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-15 23:44:44 +00:00
|
|
|
void MoviePlayer::clearFrame() {
|
|
|
|
memset(_frameBuffer, 0, _vm->_screen->getScreenWide() * _vm->_screen->getScreenDeep());
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
2004-03-24 07:29:59 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
void MoviePlayer::updateScreen() {
|
|
|
|
_system->updateScreen();
|
|
|
|
}
|
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
|
|
|
bool MoviePlayer::checkSkipFrame() {
|
|
|
|
if (_forceFrame) {
|
|
|
|
_forceFrame = false;
|
|
|
|
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
|
|
|
if (_framesSkipped > 10) {
|
|
|
|
warning("Forced frame %d to be displayed", _currentFrame);
|
|
|
|
_framesSkipped = 0;
|
|
|
|
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
|
|
|
if (_bgSoundStream) {
|
|
|
|
if ((_mixer->getSoundElapsedTime(_bgSoundHandle) * 12) / 1000 < _currentFrame + 1)
|
|
|
|
return false;
|
|
|
|
} else {
|
2008-11-09 13:20:43 +00:00
|
|
|
if (getTick() <= _ticks)
|
2006-07-08 11:42:07 +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
|
|
|
_framesSkipped++;
|
|
|
|
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
|
|
|
|
2007-04-14 14:07:11 +00:00
|
|
|
bool MoviePlayer::syncFrame() {
|
2006-07-15 23:44:44 +00:00
|
|
|
_ticks += 83;
|
|
|
|
|
|
|
|
if (checkSkipFrame()) {
|
|
|
|
warning("Skipped frame %d", _currentFrame);
|
2007-04-14 14:07:11 +00:00
|
|
|
return false;
|
2006-07-15 23:44:44 +00:00
|
|
|
}
|
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
if (_bgSoundStream) {
|
|
|
|
while (_mixer->isSoundHandleActive(_bgSoundHandle) && (_mixer->getSoundElapsedTime(_bgSoundHandle) * 12) / 1000 < _currentFrame) {
|
|
|
|
_system->delayMillis(10);
|
|
|
|
}
|
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
|
|
|
// 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.
|
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
|
|
|
|
2008-11-09 13:20:43 +00:00
|
|
|
_ticks = getTick();
|
2006-07-08 11:42:07 +00:00
|
|
|
} else {
|
2008-11-09 13:20:43 +00:00
|
|
|
while (getTick() < _ticks) {
|
2006-07-08 11:42:07 +00:00
|
|
|
_system->delayMillis(10);
|
|
|
|
}
|
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
|
|
|
|
|
|
|
return true;
|
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
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
void MoviePlayer::drawFrame() {
|
|
|
|
int screenWidth = _vm->_screen->getScreenWide();
|
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
|
|
|
_system->copyRectToScreen(_frameBuffer + _frameY * screenWidth + _frameX, screenWidth, _frameX, _frameY, _frameWidth, _frameHeight);
|
|
|
|
}
|
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-02-08 21:55:37 +00:00
|
|
|
void MoviePlayer::openTextObject(SequenceTextInfo *t) {
|
|
|
|
// Pull out the text line to get the official text number (for WAV id)
|
|
|
|
|
|
|
|
uint32 res = t->textNumber / SIZE;
|
|
|
|
uint32 localText = t->textNumber & 0xffff;
|
|
|
|
|
|
|
|
// Open text resource and get the line
|
|
|
|
|
|
|
|
byte *text = _vm->fetchTextLine(_vm->_resman->openResource(res), localText);
|
|
|
|
|
|
|
|
_textObject.speechId = READ_LE_UINT16(text);
|
|
|
|
|
|
|
|
// Is it speech or subtitles, or both?
|
|
|
|
|
|
|
|
// If we want subtitles, or there was no sound
|
|
|
|
|
|
|
|
if (_vm->getSubtitles() || !_textObject.speechId) {
|
|
|
|
_textObject.textMem = _vm->_fontRenderer->makeTextSprite(text + 2, 600, 255, _vm->_speechFontId, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
_vm->_resman->closeResource(res);
|
|
|
|
|
|
|
|
if (_textObject.textMem) {
|
|
|
|
FrameHeader frame;
|
|
|
|
|
|
|
|
frame.read(_textObject.textMem);
|
|
|
|
|
|
|
|
_textObject.textSprite.x = 320 - frame.width / 2;
|
|
|
|
_textObject.textSprite.y = 440 - frame.height;
|
|
|
|
_textObject.textSprite.w = frame.width;
|
|
|
|
_textObject.textSprite.h = frame.height;
|
|
|
|
_textObject.textSprite.type = RDSPR_DISPLAYALIGN | RDSPR_NOCOMPRESSION;
|
|
|
|
_textObject.textSprite.data = _textObject.textMem + FrameHeader::size();
|
|
|
|
_vm->_screen->createSurface(&_textObject.textSprite, &_textSurface);
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
|
|
|
}
|
2005-04-24 15:38:53 +00:00
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
void MoviePlayer::closeTextObject() {
|
|
|
|
free(_textObject.textMem);
|
|
|
|
_textObject.textMem = NULL;
|
|
|
|
|
|
|
|
_textObject.speechId = 0;
|
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
if (_textSurface) {
|
|
|
|
_vm->_screen->deleteSurface(_textSurface);
|
|
|
|
_textSurface = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
void MoviePlayer::calcTextPosition(int &xPos, int &yPos) {
|
|
|
|
xPos = 320 - _textObject.textSprite.w / 2;
|
|
|
|
yPos = 420 - _textObject.textSprite.h;
|
2006-08-23 21:13:11 +00:00
|
|
|
}
|
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
void MoviePlayer::drawTextObject() {
|
|
|
|
if (_textObject.textMem && _textSurface) {
|
2006-07-08 11:42:07 +00:00
|
|
|
int screenWidth = _vm->_screen->getScreenWide();
|
2007-02-08 21:55:37 +00:00
|
|
|
byte *src = _textObject.textSprite.data;
|
|
|
|
uint16 width = _textObject.textSprite.w;
|
|
|
|
uint16 height = _textObject.textSprite.h;
|
2006-08-23 21:13:11 +00:00
|
|
|
int xPos, yPos;
|
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
calcTextPosition(xPos, yPos);
|
2006-08-23 21:13:11 +00:00
|
|
|
|
|
|
|
byte *dst = _frameBuffer + yPos * screenWidth + xPos;
|
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)
|
|
|
|
dst[x] = _black;
|
2006-07-15 22:22:39 +00:00
|
|
|
else if (src[x] == 255)
|
|
|
|
dst[x] = _white;
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
2007-02-08 21:55:37 +00:00
|
|
|
src += width;
|
2006-07-08 11:42:07 +00:00
|
|
|
dst += screenWidth;
|
2005-04-24 15:38:53 +00:00
|
|
|
}
|
2006-08-23 21:13:11 +00:00
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
if (yPos + height > _frameY + _frameHeight || width > _frameWidth) {
|
|
|
|
_system->copyRectToScreen(_frameBuffer + yPos * screenWidth + xPos, screenWidth, xPos, yPos, width, height);
|
2006-08-23 21:13:11 +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
|
|
|
}
|
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
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
void MoviePlayer::undrawTextObject() {
|
|
|
|
if (_textObject.textMem) {
|
2006-10-02 23:07:43 +00:00
|
|
|
int xPos, yPos;
|
2006-08-23 21:13:11 +00:00
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
calcTextPosition(xPos, yPos);
|
|
|
|
uint16 width = _textObject.textSprite.w;
|
|
|
|
uint16 height = _textObject.textSprite.h;
|
2006-08-23 21:13:11 +00:00
|
|
|
|
2006-10-02 23:07:43 +00:00
|
|
|
// We only need to undraw the text if it's outside the frame.
|
|
|
|
// Otherwise the next frame will cover the old text anyway.
|
2006-08-23 21:13:11 +00:00
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
if (yPos + height > _frameY + _frameHeight || width > _frameWidth) {
|
2006-10-02 23:07:43 +00:00
|
|
|
int screenWidth = _vm->_screen->getScreenWide();
|
|
|
|
byte *dst = _frameBuffer + yPos * screenWidth + xPos;
|
2006-08-23 21:13:11 +00:00
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
for (int y = 0; y < height; y++) {
|
|
|
|
memset(dst, 0, width);
|
2006-10-02 23:07:43 +00:00
|
|
|
dst += screenWidth;
|
|
|
|
}
|
2006-08-23 21:13:11 +00:00
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
_system->copyRectToScreen(_frameBuffer + yPos * screenWidth + xPos, screenWidth, xPos, yPos, width, height);
|
2006-10-02 23:07:43 +00:00
|
|
|
}
|
2006-08-23 21:13:11 +00:00
|
|
|
}
|
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
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
bool MoviePlayer::load() {
|
2006-07-08 11:42:07 +00:00
|
|
|
_bgSoundStream = NULL;
|
|
|
|
_currentText = 0;
|
|
|
|
_currentFrame = 0;
|
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
|
|
|
for (int i = 0; i < ARRAYSIZE(_movies); i++) {
|
2007-02-08 21:55:37 +00:00
|
|
|
if (scumm_stricmp(_name, _movies[i].name) == 0) {
|
2006-07-08 11:42:07 +00:00
|
|
|
_seamless = _movies[i].seamless;
|
|
|
|
_numFrames = _movies[i].frames;
|
|
|
|
if (_numFrames > 60)
|
|
|
|
_leadOutFrame = _numFrames - 60;
|
2006-07-10 18:57:40 +00:00
|
|
|
|
|
|
|
// Not all cutscenes cover the entire screen, so clear
|
|
|
|
// it. We will always clear the game screen, no matter
|
|
|
|
// how the cutscene is to be displayed. (We have to do
|
|
|
|
// this before showing the overlay.)
|
|
|
|
|
|
|
|
_vm->_mouse->closeMenuImmediately();
|
|
|
|
|
|
|
|
if (!_seamless) {
|
|
|
|
_vm->_screen->clearScene();
|
|
|
|
}
|
|
|
|
|
|
|
|
_vm->_screen->updateDisplay();
|
2006-07-08 11:42:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2008-01-12 20:18:41 +00:00
|
|
|
bool MoviePlayer::userInterrupt() {
|
|
|
|
Common::Event event;
|
|
|
|
bool terminate = false;
|
|
|
|
|
|
|
|
Common::EventManager *eventMan = _system->getEventManager();
|
|
|
|
while (eventMan->pollEvent(event)) {
|
|
|
|
switch (event.type) {
|
|
|
|
case Common::EVENT_SCREEN_CHANGED:
|
|
|
|
handleScreenChanged();
|
|
|
|
break;
|
2008-07-16 04:22:56 +00:00
|
|
|
case Common::EVENT_RTL:
|
2008-01-12 20:18:41 +00:00
|
|
|
case Common::EVENT_QUIT:
|
|
|
|
terminate = true;
|
|
|
|
break;
|
|
|
|
case Common::EVENT_KEYDOWN:
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_ESCAPE)
|
|
|
|
terminate = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return terminate;
|
|
|
|
}
|
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
void MoviePlayer::play(SequenceTextInfo *textList, uint32 numLines, int32 leadIn, int32 leadOut) {
|
2006-07-08 11:42:07 +00:00
|
|
|
bool terminate = false;
|
|
|
|
bool textVisible = false;
|
2004-01-18 19:50:59 +00:00
|
|
|
bool startNextText = false;
|
2006-07-08 11:42:07 +00:00
|
|
|
|
|
|
|
// This happens if the user quits during the "eye" cutscene.
|
2008-09-30 12:27:38 +00:00
|
|
|
if (_vm->shouldQuit())
|
2006-07-08 11:42:07 +00:00
|
|
|
return;
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
_numSpeechLines = numLines;
|
|
|
|
_firstSpeechFrame = (numLines > 0) ? textList[0].startFrame : 0;
|
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
if (leadIn) {
|
2007-01-26 18:21:41 +00:00
|
|
|
_vm->_sound->playMovieSound(leadIn, kLeadInSound);
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
savePalette();
|
|
|
|
|
|
|
|
_framesSkipped = 0;
|
2008-11-09 13:20:43 +00:00
|
|
|
_ticks = getTick();
|
2006-08-26 12:29:00 +00:00
|
|
|
_bgSoundStream = Audio::AudioStream::openStreamFile(_name);
|
2006-07-08 11:42:07 +00:00
|
|
|
|
|
|
|
if (_bgSoundStream) {
|
|
|
|
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSoundHandle, _bgSoundStream);
|
|
|
|
}
|
2004-03-24 07:29:59 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
while (!terminate && _currentFrame < _numFrames && decodeFrame()) {
|
|
|
|
_currentFrame++;
|
|
|
|
|
|
|
|
// The frame has been decoded. Now draw the subtitles, if any,
|
|
|
|
// before drawing it to the screen.
|
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
if (_currentText < numLines) {
|
|
|
|
SequenceTextInfo *t = &textList[_currentText];
|
2006-07-08 11:42:07 +00:00
|
|
|
|
|
|
|
if (_currentFrame == t->startFrame) {
|
|
|
|
openTextObject(t);
|
2004-01-13 10:09:53 +00:00
|
|
|
textVisible = true;
|
2004-01-18 12:07:21 +00:00
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
if (_textObject.speechId) {
|
2004-01-18 19:50:59 +00:00
|
|
|
startNextText = true;
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
2004-01-18 19:50:59 +00:00
|
|
|
}
|
2004-01-18 12:07:21 +00:00
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
if (startNextText && _vm->_sound->amISpeaking() == RDSE_QUIET) {
|
|
|
|
_vm->_sound->playCompSpeech(_textObject.speechId, 16, 0);
|
2004-01-18 19:50:59 +00:00
|
|
|
startNextText = false;
|
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
if (_currentFrame == t->endFrame) {
|
2007-02-08 21:55:37 +00:00
|
|
|
undrawTextObject();
|
|
|
|
closeTextObject();
|
2006-07-08 11:42:07 +00:00
|
|
|
_currentText++;
|
2004-01-13 10:09:53 +00:00
|
|
|
textVisible = false;
|
|
|
|
}
|
2004-03-24 07:29:59 +00:00
|
|
|
|
2004-01-13 10:09:53 +00:00
|
|
|
if (textVisible)
|
2007-02-08 21:55:37 +00:00
|
|
|
drawTextObject();
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
if (leadOut && _currentFrame == _leadOutFrame) {
|
2007-01-26 18:21:41 +00:00
|
|
|
_vm->_sound->playMovieSound(leadOut, kLeadOutSound);
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
|
|
|
|
2007-04-14 14:07:11 +00:00
|
|
|
if (syncFrame()) {
|
|
|
|
drawFrame();
|
|
|
|
updateScreen();
|
|
|
|
}
|
2004-02-15 14:22:54 +00:00
|
|
|
|
2008-01-12 20:18:41 +00:00
|
|
|
if (userInterrupt()) {
|
|
|
|
terminate = true;
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-25 05:23:21 +00:00
|
|
|
if (!_seamless) {
|
2006-07-08 11:42:07 +00:00
|
|
|
// Most cutscenes fade to black on their own, but not all of
|
|
|
|
// them. I think it looks better if they do.
|
2004-02-15 14:22:54 +00:00
|
|
|
|
2006-07-15 23:44:44 +00:00
|
|
|
clearFrame();
|
2004-02-15 14:22:54 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
// If the sound is still playing, draw the subtitles one final
|
|
|
|
// time. This happens in the "carib" cutscene.
|
2004-02-15 14:22:54 +00:00
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
if (textVisible && _vm->_sound->amISpeaking() == RDSE_SPEAKING) {
|
|
|
|
drawTextObject();
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
2004-02-15 14:22:54 +00:00
|
|
|
|
2006-07-15 23:44:44 +00:00
|
|
|
drawFrame();
|
2006-07-08 11:42:07 +00:00
|
|
|
updateScreen();
|
|
|
|
}
|
2004-02-15 14:22:54 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
if (!terminate) {
|
2006-07-15 23:44:44 +00:00
|
|
|
// Wait for the voice and sound track to stop playing. This is
|
|
|
|
// to make sure that we don't cut off the speech in
|
|
|
|
// mid-sentence, and - even more importantly - that we don't
|
|
|
|
// free the sound buffer while it's still in use.
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
while (_vm->_sound->amISpeaking() == RDSE_SPEAKING || _mixer->isSoundHandleActive(_bgSoundHandle)) {
|
2008-01-12 20:18:41 +00:00
|
|
|
if (userInterrupt()) {
|
|
|
|
terminate = true;
|
|
|
|
_vm->_sound->stopSpeech();
|
|
|
|
_mixer->stopHandle(_bgSoundHandle);
|
|
|
|
}
|
2006-07-08 11:42:07 +00:00
|
|
|
_system->delayMillis(100);
|
|
|
|
}
|
|
|
|
} else {
|
2007-02-08 21:55:37 +00:00
|
|
|
_vm->_sound->stopSpeech();
|
2006-07-08 11:42:07 +00:00
|
|
|
_mixer->stopHandle(_bgSoundHandle);
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
2006-08-23 21:13:11 +00:00
|
|
|
// The current text object may still be open
|
2007-02-08 21:55:37 +00:00
|
|
|
undrawTextObject();
|
|
|
|
closeTextObject();
|
2006-08-23 21:13:11 +00:00
|
|
|
|
2005-04-25 05:23:21 +00:00
|
|
|
if (!_seamless) {
|
2006-07-15 23:44:44 +00:00
|
|
|
clearFrame();
|
|
|
|
drawFrame();
|
2006-07-08 11:42:07 +00:00
|
|
|
updateScreen();
|
2005-04-25 05:23:21 +00:00
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
// Setting the palette implies a full redraw.
|
|
|
|
restorePalette();
|
|
|
|
}
|
|
|
|
|
2008-11-09 13:20:43 +00:00
|
|
|
void MoviePlayer::pauseMovie(bool pause) {
|
|
|
|
_mixer->pauseHandle(_bgSoundHandle, pause);
|
|
|
|
|
|
|
|
if (pause) {
|
|
|
|
_pauseStartTick = _system->getMillis();
|
|
|
|
} else {
|
|
|
|
_pauseTicks += (_system->getMillis() - _pauseStartTick);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
#ifdef USE_ZLIB
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Movie player for the new DXA movies
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
MoviePlayerDXA::MoviePlayerDXA(Sword2Engine *vm, const char *name)
|
|
|
|
: MoviePlayer(vm, name) {
|
2006-07-08 11:42:07 +00:00
|
|
|
debug(0, "Creating DXA cutscene player");
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
MoviePlayerDXA::~MoviePlayerDXA() {
|
|
|
|
closeFile();
|
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
void MoviePlayerDXA::setPalette(byte *pal) {
|
|
|
|
updatePalette(pal);
|
|
|
|
}
|
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
|
|
|
bool MoviePlayerDXA::decodeFrame() {
|
|
|
|
decodeNextFrame();
|
|
|
|
copyFrameToBuffer(_frameBuffer, _frameX, _frameY, _vm->_screen->getScreenWide());
|
|
|
|
return true;
|
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
bool MoviePlayerDXA::load() {
|
|
|
|
if (!MoviePlayer::load())
|
2006-07-08 11:42:07 +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
|
|
|
char filename[20];
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
snprintf(filename, sizeof(filename), "%s.dxa", _name);
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2007-11-01 06:00:16 +00:00
|
|
|
if (loadFile(filename)) {
|
2006-07-08 11:42:07 +00:00
|
|
|
// The Broken Sword games always use external audio tracks.
|
2008-12-14 23:41:48 +00:00
|
|
|
if (_fileStream->readUint32BE() != MKID_BE('NULL'))
|
2006-07-08 11:42:07 +00:00
|
|
|
return false;
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
_frameBuffer = _vm->_screen->getScreen();
|
2004-12-21 02:12:58 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
_frameWidth = getWidth();
|
|
|
|
_frameHeight = getHeight();
|
|
|
|
|
|
|
|
_frameX = (_vm->_screen->getScreenWide() - _frameWidth) / 2;
|
|
|
|
_frameY = (_vm->_screen->getScreenDeep() - _frameHeight) / 2;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2006-07-10 09:29:12 +00:00
|
|
|
#ifdef USE_MPEG2
|
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Movie player for the old MPEG movies
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
MoviePlayerMPEG::MoviePlayerMPEG(Sword2Engine *vm, const char *name)
|
|
|
|
: MoviePlayer(vm, name) {
|
2006-07-08 11:42:07 +00:00
|
|
|
#ifdef BACKEND_8BIT
|
|
|
|
debug(0, "Creating MPEG cutscene player (8-bit)");
|
2005-01-04 15:31:30 +00:00
|
|
|
#else
|
2006-07-08 11:42:07 +00:00
|
|
|
debug(0, "Creating MPEG cutscene player (16-bit)");
|
2005-01-04 15:31:30 +00:00
|
|
|
#endif
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MoviePlayerMPEG::~MoviePlayerMPEG() {
|
|
|
|
delete _anim;
|
|
|
|
_anim = NULL;
|
|
|
|
}
|
2004-12-21 02:12:58 +00:00
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
bool MoviePlayerMPEG::load() {
|
|
|
|
if (!MoviePlayer::load())
|
2006-07-08 11:42:07 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
_anim = new AnimationState(_vm, this);
|
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
if (!_anim->init(_name)) {
|
2006-07-08 11:42:07 +00:00
|
|
|
delete _anim;
|
|
|
|
_anim = NULL;
|
|
|
|
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
|
|
|
#ifdef BACKEND_8BIT
|
|
|
|
_frameBuffer = _vm->_screen->getScreen();
|
|
|
|
#endif
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
Applied my own patch #1341495, in an attempt to fix alignment issues
reported by Crilith.
To elaborate a bit, the engine no longer accesses resource data through
packed structs. Instead it uses memory streams and the READ/WRITE
functions.
If data is mainly read, not written, I have replaced the old struct with a
new one with a read() function to read the whole thing from memory into the
struct's variables, and a write() function to dump the struct's variables
to memory. In fact, most of these write() functions remain unused.
If data is both read and written, I have replaced the struct with a class
with individual get/set functions to replace the old variables. This
manipulates memory directly.
Since I'm fairly sure that these structs are frequently stored as local
variables for a script, all script variables (both local and global) are
stored as little-endian and accessed through the READ/WRITE functions,
rather than being treated as arrays of 32-bit integers.
On a positive note, the functions for doing endian conversion of resources
and save games have been removed, and some general cleanups have been made
to assist in the rewrite.
Initial reports indicate that this patch indeed fixes alignment issues, and
that I have not - surprisingly - broken the game on big-endian platforms.
At least not in any immediately obvious way. And there's still plenty of
time to fix regressions before 0.9.0, too.
svn-id: r19366
2005-10-29 21:24:54 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
bool MoviePlayerMPEG::decodeFrame() {
|
|
|
|
bool result = _anim->decodeFrame();
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
#ifdef BACKEND_8BIT
|
|
|
|
_frameWidth = _anim->getFrameWidth();
|
|
|
|
_frameHeight = _anim->getFrameHeight();
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
_frameX = (_vm->_screen->getScreenWide() - _frameWidth) / 2;
|
|
|
|
_frameY = (_vm->_screen->getScreenDeep() - _frameHeight) / 2;
|
|
|
|
#endif
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
return result;
|
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2006-07-10 09:29:12 +00:00
|
|
|
AnimationState::AnimationState(Sword2Engine *vm, MoviePlayer *player)
|
2006-08-26 12:29:00 +00:00
|
|
|
: BaseAnimationState(vm->_system, 640, 480) {
|
2006-07-10 09:29:12 +00:00
|
|
|
_vm = vm;
|
|
|
|
_player = player;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimationState::~AnimationState() {
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef BACKEND_8BIT
|
|
|
|
|
|
|
|
void AnimationState::setPalette(byte *pal) {
|
|
|
|
_player->updatePalette(pal, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
void MoviePlayerMPEG::handleScreenChanged() {
|
|
|
|
_anim->handleScreenChanged();
|
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2006-07-15 23:44:44 +00:00
|
|
|
void MoviePlayerMPEG::clearFrame() {
|
|
|
|
_anim->clearFrame();
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
void MoviePlayerMPEG::drawFrame() {
|
|
|
|
}
|
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
|
|
|
void MoviePlayerMPEG::updateScreen() {
|
|
|
|
_anim->updateScreen();
|
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
void MoviePlayerMPEG::drawTextObject() {
|
|
|
|
if (_textObject.textMem && _textSurface) {
|
|
|
|
_anim->drawTextObject(&_textObject.textSprite, _textSurface);
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
void MoviePlayerMPEG::undrawTextObject() {
|
2006-08-23 21:13:11 +00:00
|
|
|
// As long as we only have subtitles for full-sized cutscenes, we don't
|
|
|
|
// really need to implement this function.
|
|
|
|
}
|
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
void AnimationState::drawTextObject(SpriteInfo *s, byte *src) {
|
|
|
|
int moviePitch = _movieScale * _movieWidth;
|
|
|
|
int textX = _movieScale * s->x;
|
|
|
|
int textY = _movieScale * (_frameHeight - s->h - 12);
|
|
|
|
|
|
|
|
OverlayColor *dst = _overlay + textY * moviePitch + textX;
|
|
|
|
|
2008-11-06 15:02:50 +00:00
|
|
|
Graphics::PixelFormat format = _sys->getOverlayFormat();
|
2009-01-22 04:35:10 +00:00
|
|
|
OverlayColor pen = format.RGBToColor(255, 255, 255);
|
|
|
|
OverlayColor border = format.RGBToColor(0, 0, 0);
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
// TODO: Use the AdvMame scalers for the text? Pre-scale it?
|
|
|
|
|
|
|
|
for (int y = 0; y < s->h; y++) {
|
|
|
|
OverlayColor *ptr = dst;
|
|
|
|
|
|
|
|
for (int x = 0; x < s->w; x++) {
|
|
|
|
switch (src[x]) {
|
|
|
|
case 1:
|
|
|
|
*ptr++ = border;
|
|
|
|
if (_movieScale > 1) {
|
|
|
|
*ptr++ = border;
|
|
|
|
if (_movieScale > 2)
|
|
|
|
*ptr++ = border;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 255:
|
|
|
|
*ptr++ = pen;
|
|
|
|
if (_movieScale > 1) {
|
|
|
|
*ptr++ = pen;
|
|
|
|
if (_movieScale > 2)
|
|
|
|
*ptr++ = pen;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ptr += _movieScale;
|
|
|
|
break;
|
2004-01-13 10:09:53 +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
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
if (_movieScale > 1) {
|
|
|
|
memcpy(dst + moviePitch, dst, _movieScale * s->w * sizeof(OverlayColor));
|
|
|
|
if (_movieScale > 2)
|
|
|
|
memcpy(dst + 2 * moviePitch, dst, _movieScale * s->w * sizeof(OverlayColor));
|
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
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
dst += _movieScale * moviePitch;
|
|
|
|
src += s->w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2006-07-15 23:44:44 +00:00
|
|
|
void AnimationState::clearFrame() {
|
2006-07-08 11:42:07 +00:00
|
|
|
#ifdef BACKEND_8BIT
|
|
|
|
memset(_vm->_screen->getScreen(), 0, _movieWidth * _movieHeight);
|
|
|
|
#else
|
2008-11-06 15:02:50 +00:00
|
|
|
Graphics::PixelFormat format = _sys->getOverlayFormat();
|
2009-01-22 04:35:10 +00:00
|
|
|
OverlayColor black = format.RGBToColor(0, 0, 0);
|
2006-07-08 11:42:07 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < _movieScale * _movieWidth * _movieScale * _movieHeight; i++)
|
|
|
|
_overlay[i] = black;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void AnimationState::drawYUV(int width, int height, byte *const *dat) {
|
|
|
|
_frameWidth = width;
|
|
|
|
_frameHeight = height;
|
|
|
|
|
|
|
|
#ifdef BACKEND_8BIT
|
|
|
|
byte *buf = _vm->_screen->getScreen() + ((480 - height) / 2) * RENDERWIDE + (640 - width) / 2;
|
|
|
|
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
int ypos = 0;
|
|
|
|
int cpos = 0;
|
|
|
|
int linepos = 0;
|
|
|
|
|
|
|
|
for (y = 0; y < height; y += 2) {
|
|
|
|
for (x = 0; x < width; x += 2) {
|
|
|
|
int i = ((((dat[2][cpos] + ROUNDADD) >> SHIFT) * (BITDEPTH + 1)) + ((dat[1][cpos] + ROUNDADD) >> SHIFT)) * (BITDEPTH + 1);
|
|
|
|
cpos++;
|
|
|
|
|
|
|
|
buf[linepos ] = _lut[i + ((dat[0][ ypos ] + ROUNDADD) >> SHIFT)];
|
|
|
|
buf[RENDERWIDE + linepos++] = _lut[i + ((dat[0][width + ypos++] + ROUNDADD) >> SHIFT)];
|
|
|
|
buf[linepos ] = _lut[i + ((dat[0][ ypos ] + ROUNDADD) >> SHIFT)];
|
|
|
|
buf[RENDERWIDE + linepos++] = _lut[i + ((dat[0][width + ypos++] + ROUNDADD) >> SHIFT)];
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
2006-07-08 11:42:07 +00:00
|
|
|
linepos += (2 * RENDERWIDE - width);
|
|
|
|
ypos += width;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
plotYUV(width, height, dat);
|
|
|
|
#endif
|
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2006-07-10 09:29:12 +00:00
|
|
|
#endif
|
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Dummy player for subtitled speech only
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
MoviePlayerDummy::MoviePlayerDummy(Sword2Engine *vm, const char *name)
|
|
|
|
: MoviePlayer(vm, name) {
|
2006-07-08 11:42:07 +00:00
|
|
|
debug(0, "Creating Dummy cutscene player");
|
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
MoviePlayerDummy::~MoviePlayerDummy() {
|
|
|
|
}
|
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
bool MoviePlayerDummy::load() {
|
|
|
|
if (!MoviePlayer::load())
|
2006-07-08 11:42:07 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
_frameBuffer = _vm->_screen->getScreen();
|
|
|
|
|
|
|
|
_frameWidth = 640;
|
|
|
|
_frameHeight = 400;
|
|
|
|
_frameX = 0;
|
|
|
|
_frameY = 40;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MoviePlayerDummy::decodeFrame() {
|
2008-01-12 20:18:41 +00:00
|
|
|
if ((_currentFrame == 0 && _numSpeechLines > 0) || _mixer->isSoundHandleActive(_bgSoundHandle)) {
|
2006-07-08 11:42:07 +00:00
|
|
|
byte dummyPalette[] = {
|
|
|
|
0, 0, 0, 0,
|
|
|
|
255, 255, 255, 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
// 0 is always black
|
|
|
|
// 1 is the border colour - black
|
|
|
|
// 255 is the pen colour - white
|
|
|
|
|
|
|
|
_system->setPalette(dummyPalette, 0, 1);
|
|
|
|
_system->setPalette(dummyPalette, 1, 1);
|
|
|
|
_system->setPalette(dummyPalette + 4, 255, 1);
|
|
|
|
|
|
|
|
byte msgNoCutscenesRU[] = "Po\344uk - to\344\345ko pev\345: hagmute k\344abuwy Ucke\343n, u\344u nocetute ca\343t npoekta u ckava\343te budeo po\344uku";
|
|
|
|
|
|
|
|
#if defined(USE_MPEG2) || defined(USE_ZLIB)
|
|
|
|
byte msgNoCutscenes[] = "Cutscene - Narration Only: Press ESC to exit, or visit www.scummvm.org to download cutscene videos";
|
|
|
|
#else
|
2006-07-21 11:04:21 +00:00
|
|
|
byte msgNoCutscenes[] = "Cutscene - Narration Only: Press ESC to exit, or recompile ScummVM with MPEG2 or ZLib support";
|
2006-07-08 11:42:07 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
byte *msg;
|
|
|
|
|
|
|
|
// Russian version substituted latin characters with Cyrillic.
|
|
|
|
if (Common::parseLanguage(ConfMan.get("language")) == Common::RU_RUS) {
|
|
|
|
msg = msgNoCutscenesRU;
|
|
|
|
} else {
|
|
|
|
msg = msgNoCutscenes;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte *data = _vm->_fontRenderer->makeTextSprite(msg, RENDERWIDE, 255, _vm->_speechFontId);
|
|
|
|
|
|
|
|
FrameHeader frame_head;
|
|
|
|
SpriteInfo msgSprite;
|
|
|
|
byte *msgSurface;
|
|
|
|
|
|
|
|
frame_head.read(data);
|
|
|
|
|
|
|
|
msgSprite.x = _vm->_screen->getScreenWide() / 2 - frame_head.width / 2;
|
|
|
|
msgSprite.y = (480 - frame_head.height) / 2;
|
|
|
|
msgSprite.w = frame_head.width;
|
|
|
|
msgSprite.h = frame_head.height;
|
|
|
|
msgSprite.type = RDSPR_NOCOMPRESSION;
|
|
|
|
msgSprite.data = data + FrameHeader::size();
|
|
|
|
|
|
|
|
_vm->_screen->createSurface(&msgSprite, &msgSurface);
|
|
|
|
_vm->_screen->drawSurface(&msgSprite, msgSurface);
|
|
|
|
_vm->_screen->deleteSurface(msgSurface);
|
|
|
|
|
|
|
|
free(data);
|
|
|
|
updateScreen();
|
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
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
// If we have played the final voice-over, skip ahead to the lead out
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2008-01-12 20:18:41 +00:00
|
|
|
if (!_mixer->isSoundHandleActive(_bgSoundHandle) &&
|
|
|
|
_currentText >= _numSpeechLines &&
|
|
|
|
_vm->_sound->amISpeaking() == RDSE_QUIET &&
|
|
|
|
_leadOutFrame != (uint)-1 &&
|
|
|
|
_currentFrame < _leadOutFrame) {
|
2006-07-08 11:42:07 +00:00
|
|
|
_currentFrame = _leadOutFrame - 1;
|
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
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2007-04-14 14:07:11 +00:00
|
|
|
bool MoviePlayerDummy::syncFrame() {
|
2008-01-12 20:18:41 +00:00
|
|
|
if ((_numSpeechLines == 0 || _currentFrame < _firstSpeechFrame) && !_mixer->isSoundHandleActive(_bgSoundHandle)) {
|
2008-11-09 13:20:43 +00:00
|
|
|
_ticks = getTick();
|
2007-04-14 14:07:11 +00:00
|
|
|
return false;
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
|
|
|
|
2007-04-14 14:07:11 +00:00
|
|
|
return MoviePlayer::syncFrame();
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MoviePlayerDummy::drawFrame() {
|
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
void MoviePlayerDummy::drawTextObject() {
|
|
|
|
if (_textObject.textMem && _textSurface) {
|
|
|
|
_vm->_screen->drawSurface(&_textObject.textSprite, _textSurface);
|
2006-07-15 22:42:28 +00:00
|
|
|
}
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
void MoviePlayerDummy::undrawTextObject() {
|
|
|
|
if (_textObject.textMem && _textSurface) {
|
|
|
|
memset(_textSurface, 1, _textObject.textSprite.w * _textObject.textSprite.h);
|
|
|
|
drawTextObject();
|
2006-07-15 22:42:28 +00:00
|
|
|
}
|
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
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
MoviePlayer *makeMoviePlayer(Sword2Engine *vm, const char *name) {
|
2007-02-08 21:55:37 +00:00
|
|
|
static char filename[20];
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2006-07-08 11:42:07 +00:00
|
|
|
#ifdef USE_ZLIB
|
|
|
|
snprintf(filename, sizeof(filename), "%s.dxa", name);
|
|
|
|
|
|
|
|
if (Common::File::exists(filename)) {
|
2007-02-08 21:55:37 +00:00
|
|
|
return new MoviePlayerDXA(vm, name);
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_MPEG2
|
|
|
|
snprintf(filename, sizeof(filename), "%s.mp2", name);
|
|
|
|
|
|
|
|
if (Common::File::exists(filename)) {
|
2007-02-08 21:55:37 +00:00
|
|
|
return new MoviePlayerMPEG(vm, name);
|
2006-07-08 11:42:07 +00:00
|
|
|
}
|
|
|
|
#endif
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2007-02-08 21:55:37 +00:00
|
|
|
return new MoviePlayerDummy(vm, name);
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
2004-01-12 11:11:19 +00:00
|
|
|
} // End of namespace Sword2
|