2004-01-13 01:26:18 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2005-01-01 15:10:22 +00:00
|
|
|
* Copyright (C) 2004-2005 The ScummVM project
|
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.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-01-12 11:11:19 +00:00
|
|
|
#include "common/stdafx.h"
|
2004-02-21 20:00:51 +00:00
|
|
|
#include "common/file.h"
|
2004-12-21 02:12:58 +00:00
|
|
|
#include "common/config-manager.h"
|
2004-02-21 20:00:51 +00:00
|
|
|
#include "sound/vorbis.h"
|
|
|
|
#include "sound/mp3.h"
|
|
|
|
|
2004-01-12 11:11:19 +00:00
|
|
|
#include "sword2/sword2.h"
|
2004-02-05 14:19:07 +00:00
|
|
|
#include "sword2/maketext.h"
|
2004-01-13 14:22:29 +00:00
|
|
|
#include "sword2/driver/animation.h"
|
2004-02-05 14:19:07 +00:00
|
|
|
#include "sword2/driver/d_draw.h"
|
|
|
|
#include "sword2/driver/d_sound.h"
|
2004-01-12 11:11:19 +00:00
|
|
|
#include "sword2/driver/menu.h"
|
|
|
|
#include "sword2/driver/render.h"
|
|
|
|
|
|
|
|
namespace Sword2 {
|
|
|
|
|
2004-01-13 14:16:40 +00:00
|
|
|
AnimationState::AnimationState(Sword2Engine *vm)
|
2004-03-22 15:57:51 +00:00
|
|
|
: BaseAnimationState(vm->_mixer, vm->_system, 640, 480), _vm(vm) {
|
2004-01-13 14:16:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AnimationState::~AnimationState() {
|
|
|
|
}
|
|
|
|
|
2004-01-17 14:20:32 +00:00
|
|
|
|
|
|
|
#ifdef BACKEND_8BIT
|
|
|
|
|
2004-03-21 18:49:04 +00:00
|
|
|
void AnimationState::setPalette(byte *pal) {
|
|
|
|
_vm->_graphics->setPalette(0, 256, pal, RDPAL_INSTANT);
|
|
|
|
}
|
|
|
|
|
2004-01-17 14:20:32 +00:00
|
|
|
#else
|
|
|
|
|
2004-04-23 07:02:11 +00:00
|
|
|
void AnimationState::drawTextObject(SpriteInfo *s, byte *src) {
|
2004-02-28 12:58:13 +00:00
|
|
|
OverlayColor *dst = overlay + RENDERWIDE * (s->y) + s->x;
|
2004-01-18 21:09:57 +00:00
|
|
|
|
|
|
|
// FIXME: These aren't the "right" colours, but look good to me.
|
|
|
|
|
2004-03-21 18:49:04 +00:00
|
|
|
OverlayColor pen = _sys->RGBToColor(255, 255, 255);
|
|
|
|
OverlayColor border = _sys->RGBToColor(0, 0, 0);
|
2004-01-18 21:09:57 +00:00
|
|
|
|
|
|
|
for (int y = 0; y < s->h; y++) {
|
|
|
|
for (int x = 0; x < s->w; x++) {
|
|
|
|
switch (src[x]) {
|
|
|
|
case 1:
|
|
|
|
dst[x] = border;
|
|
|
|
break;
|
|
|
|
case 255:
|
|
|
|
dst[x] = pen;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dst += RENDERWIDE;
|
|
|
|
src += s->w;
|
|
|
|
}
|
|
|
|
}
|
2004-01-17 14:20:32 +00:00
|
|
|
|
2004-03-24 07:29:59 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void AnimationState::clearScreen(void) {
|
|
|
|
#ifdef BACKEND_8BIT
|
|
|
|
memset(_vm->_graphics->getScreen(), 0, MOVIE_WIDTH * MOVIE_HEIGHT);
|
|
|
|
#else
|
2004-03-21 18:49:04 +00:00
|
|
|
OverlayColor black = _sys->RGBToColor(0, 0, 0);
|
2004-02-14 10:37:21 +00:00
|
|
|
|
2004-02-21 20:00:51 +00:00
|
|
|
for (int i = 0; i < MOVIE_WIDTH * MOVIE_HEIGHT; i++)
|
2004-02-14 10:37:21 +00:00
|
|
|
overlay[i] = black;
|
2004-03-24 07:29:59 +00:00
|
|
|
#endif
|
2004-02-14 10:37:21 +00:00
|
|
|
}
|
|
|
|
|
2004-03-24 07:29:59 +00:00
|
|
|
void AnimationState::updateScreen(void) {
|
|
|
|
#ifdef BACKEND_8BIT
|
|
|
|
byte *buf = _vm->_graphics->getScreen() + ((480 - MOVIE_HEIGHT) / 2) * RENDERWIDE + (640 - MOVIE_WIDTH) / 2;
|
2004-01-13 14:16:40 +00:00
|
|
|
|
2004-03-28 16:30:50 +00:00
|
|
|
_vm->_system->copyRectToScreen(buf, MOVIE_WIDTH, (640 - MOVIE_WIDTH) / 2, (480 - MOVIE_HEIGHT) / 2, MOVIE_WIDTH, MOVIE_HEIGHT);
|
2004-03-24 07:29:59 +00:00
|
|
|
#else
|
2004-03-28 16:30:50 +00:00
|
|
|
_sys->copyRectToOverlay(overlay, MOVIE_WIDTH, 0, 0, MOVIE_WIDTH, MOVIE_HEIGHT);
|
2004-01-17 14:20:32 +00:00
|
|
|
#endif
|
2004-03-24 07:29:59 +00:00
|
|
|
_vm->_system->updateScreen();
|
|
|
|
}
|
2004-01-17 14:20:32 +00:00
|
|
|
|
2004-03-23 00:10:18 +00:00
|
|
|
void AnimationState::drawYUV(int width, int height, byte *const *dat) {
|
2004-03-22 01:40:24 +00:00
|
|
|
#ifdef BACKEND_8BIT
|
2004-03-23 00:10:18 +00:00
|
|
|
_vm->_graphics->plotYUV(lut, width, height, dat);
|
2004-03-22 01:40:24 +00:00
|
|
|
#else
|
2004-03-23 00:10:18 +00:00
|
|
|
plotYUV(lookup, width, height, dat);
|
2004-03-22 01:40:24 +00:00
|
|
|
#endif
|
2004-01-13 14:16:40 +00:00
|
|
|
}
|
|
|
|
|
2004-02-15 14:22:54 +00:00
|
|
|
MovieInfo MoviePlayer::_movies[] = {
|
|
|
|
{ "carib", 222 },
|
|
|
|
{ "escape", 187 },
|
|
|
|
{ "eye", 248 },
|
|
|
|
{ "finale", 1485 },
|
|
|
|
{ "guard", 75 },
|
|
|
|
{ "intro", 1800 },
|
|
|
|
{ "jungle", 186 },
|
|
|
|
{ "museum", 167 },
|
|
|
|
{ "pablo", 75 },
|
|
|
|
{ "pyramid", 60 },
|
|
|
|
{ "quaram", 184 },
|
|
|
|
{ "river", 656 },
|
|
|
|
{ "sailing", 138 },
|
|
|
|
{ "shaman", 788 },
|
|
|
|
{ "stone1", 34 },
|
|
|
|
{ "stone2", 282 },
|
2004-03-01 00:32:47 +00:00
|
|
|
{ "stone3", 65 },
|
|
|
|
{ "demo", 60 },
|
|
|
|
{ "enddemo", 110 }
|
2004-02-15 14:22:54 +00:00
|
|
|
};
|
|
|
|
|
2004-03-21 18:49:04 +00:00
|
|
|
MoviePlayer::MoviePlayer(Sword2Engine *vm)
|
|
|
|
: _vm(vm), _snd(_vm->_mixer), _sys(_vm->_system), _textSurface(NULL) {
|
|
|
|
}
|
|
|
|
|
2004-01-13 10:09:53 +00:00
|
|
|
void MoviePlayer::openTextObject(MovieTextObject *obj) {
|
|
|
|
if (obj->textSprite)
|
|
|
|
_vm->_graphics->createSurface(obj->textSprite, &_textSurface);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MoviePlayer::closeTextObject(MovieTextObject *obj) {
|
|
|
|
if (_textSurface) {
|
|
|
|
_vm->_graphics->deleteSurface(_textSurface);
|
|
|
|
_textSurface = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-18 21:09:57 +00:00
|
|
|
void MoviePlayer::drawTextObject(AnimationState *anim, MovieTextObject *obj) {
|
|
|
|
if (obj->textSprite && _textSurface) {
|
|
|
|
#ifdef BACKEND_8BIT
|
2004-01-13 10:09:53 +00:00
|
|
|
_vm->_graphics->drawSurface(obj->textSprite, _textSurface);
|
2004-01-18 21:09:57 +00:00
|
|
|
#else
|
|
|
|
if (anim)
|
|
|
|
anim->drawTextObject(obj->textSprite, _textSurface);
|
|
|
|
else
|
|
|
|
_vm->_graphics->drawSurface(obj->textSprite, _textSurface);
|
|
|
|
#endif
|
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plays an animated cutscene.
|
|
|
|
* @param filename the file name of the cutscene file
|
|
|
|
* @param text the subtitles and voiceovers for the cutscene
|
|
|
|
* @param musicOut lead-out music
|
|
|
|
*/
|
|
|
|
|
2004-04-23 07:02:11 +00:00
|
|
|
int32 MoviePlayer::play(const char *filename, MovieTextObject *text[], byte *musicOut) {
|
2004-03-24 07:29:59 +00:00
|
|
|
// This happens if the user quits during the "eye" smacker
|
|
|
|
if (_vm->_quit)
|
|
|
|
return RD_OK;
|
|
|
|
|
2004-01-13 10:09:53 +00:00
|
|
|
#ifdef USE_MPEG2
|
2004-02-15 14:22:54 +00:00
|
|
|
uint frameCounter = 0, textCounter = 0;
|
2004-01-13 10:09:53 +00:00
|
|
|
PlayingSoundHandle handle;
|
|
|
|
bool skipCutscene = false, textVisible = false;
|
2004-01-17 14:20:32 +00:00
|
|
|
uint32 flags = SoundMixer::FLAG_16BITS;
|
2004-01-18 19:50:59 +00:00
|
|
|
bool startNextText = false;
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2004-06-09 06:33:29 +00:00
|
|
|
byte oldPal[256 * 4];
|
|
|
|
memcpy(oldPal, _vm->_graphics->_palette, sizeof(oldPal));
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2004-01-13 14:16:40 +00:00
|
|
|
AnimationState *anim = new AnimationState(_vm);
|
2004-02-15 14:22:54 +00:00
|
|
|
|
2004-01-13 14:16:40 +00:00
|
|
|
if (!anim->init(filename)) {
|
|
|
|
delete anim;
|
2004-01-13 10:09:53 +00:00
|
|
|
// Missing Files? Use the old 'Narration Only' hack
|
|
|
|
playDummy(filename, text, musicOut);
|
|
|
|
return RD_OK;
|
|
|
|
}
|
|
|
|
|
2004-03-28 13:10:52 +00:00
|
|
|
#ifndef BACKEND_8BIT
|
|
|
|
// Clear the screen, because whatever is on it will be visible when the
|
|
|
|
// overlay is removed.
|
|
|
|
_vm->_graphics->clearScene();
|
|
|
|
_vm->_graphics->updateDisplay();
|
|
|
|
#endif
|
2004-01-13 10:09:53 +00:00
|
|
|
|
|
|
|
#ifndef SCUMM_BIG_ENDIAN
|
|
|
|
flags |= SoundMixer::FLAG_LITTLE_ENDIAN;
|
|
|
|
#endif
|
|
|
|
|
2004-02-15 14:22:54 +00:00
|
|
|
int i;
|
|
|
|
uint leadOutFrame = (uint) -1;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAYSIZE(_movies); i++) {
|
|
|
|
if (scumm_stricmp(filename, _movies[i].name) == 0) {
|
|
|
|
if (_movies[i].frames >= 60)
|
|
|
|
leadOutFrame = _movies[i].frames - 60;
|
|
|
|
else
|
|
|
|
leadOutFrame = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == ARRAYSIZE(_movies))
|
|
|
|
warning("Unknown movie, '%s'", filename);
|
|
|
|
|
2004-03-24 07:29:59 +00:00
|
|
|
while (!skipCutscene && anim->decodeFrame()) {
|
|
|
|
// The frame has been drawn. Now draw the subtitles, if any,
|
|
|
|
// before updating the screen.
|
|
|
|
|
2004-01-22 21:02:29 +00:00
|
|
|
if (text && text[textCounter]) {
|
2004-01-13 10:09:53 +00:00
|
|
|
if (frameCounter == text[textCounter]->startFrame) {
|
|
|
|
openTextObject(text[textCounter]);
|
|
|
|
textVisible = true;
|
2004-01-18 12:07:21 +00:00
|
|
|
|
2004-01-18 19:50:59 +00:00
|
|
|
if (text[textCounter]->speech) {
|
|
|
|
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
|
|
|
|
2004-01-18 19:50:59 +00:00
|
|
|
if (startNextText && !handle.isActive()) {
|
2004-03-21 18:49:04 +00:00
|
|
|
_snd->playRaw(&handle, text[textCounter]->speech, text[textCounter]->speechBufferSize, 22050, flags);
|
2004-01-18 19:50:59 +00:00
|
|
|
startNextText = false;
|
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
|
|
|
if (frameCounter == text[textCounter]->endFrame) {
|
|
|
|
closeTextObject(text[textCounter]);
|
|
|
|
textCounter++;
|
|
|
|
textVisible = false;
|
|
|
|
}
|
2004-03-24 07:29:59 +00:00
|
|
|
|
2004-01-13 10:09:53 +00:00
|
|
|
if (textVisible)
|
2004-01-18 21:09:57 +00:00
|
|
|
drawTextObject(anim, text[textCounter]);
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
2004-03-24 07:29:59 +00:00
|
|
|
anim->updateScreen();
|
|
|
|
|
2004-01-13 10:09:53 +00:00
|
|
|
frameCounter++;
|
|
|
|
|
2004-02-15 14:22:54 +00:00
|
|
|
if (frameCounter == leadOutFrame && musicOut)
|
|
|
|
_vm->_sound->playFx(0, musicOut, 0, 0, RDSE_FXLEADOUT);
|
|
|
|
|
2004-03-24 07:29:59 +00:00
|
|
|
OSystem::Event event;
|
2004-09-28 20:19:37 +00:00
|
|
|
while (_sys->pollEvent(event)) {
|
2004-12-05 17:42:20 +00:00
|
|
|
switch (event.type) {
|
2004-03-24 07:29:59 +00:00
|
|
|
#ifndef BACKEND_8BIT
|
|
|
|
case OSystem::EVENT_SCREEN_CHANGED:
|
|
|
|
anim->invalidateLookup(true);
|
|
|
|
break;
|
2004-01-17 14:20:32 +00:00
|
|
|
#endif
|
2004-03-24 07:29:59 +00:00
|
|
|
case OSystem::EVENT_KEYDOWN:
|
|
|
|
if (event.kbd.keycode == 27)
|
|
|
|
skipCutscene = true;
|
|
|
|
break;
|
|
|
|
case OSystem::EVENT_QUIT:
|
|
|
|
_vm->closeGame();
|
|
|
|
skipCutscene = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-15 14:22:54 +00:00
|
|
|
if (!skipCutscene) {
|
|
|
|
// Sleep for one frame so that the last frame is displayed.
|
2004-09-28 20:19:37 +00:00
|
|
|
_sys->delayMillis(1000 / 12);
|
2004-02-15 14:22:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Most movies fade to black on their own, but not all of them. Since
|
|
|
|
// we may be hanging around in the cutscene player for a while longer,
|
|
|
|
// waiting for the lead-out sound to finish, paint the overlay black.
|
|
|
|
|
2004-03-24 07:29:59 +00:00
|
|
|
anim->clearScreen();
|
2004-02-15 14:22:54 +00:00
|
|
|
|
|
|
|
// If the speech is still playing, redraw the subtitles. At least in
|
|
|
|
// the English version this is most noticeable in the "carib" cutscene.
|
|
|
|
|
|
|
|
if (textVisible && handle.isActive())
|
|
|
|
drawTextObject(anim, text[textCounter]);
|
|
|
|
|
|
|
|
if (text)
|
|
|
|
closeTextObject(text[textCounter]);
|
|
|
|
|
2004-03-24 07:29:59 +00:00
|
|
|
anim->updateScreen();
|
2004-02-15 14:22:54 +00:00
|
|
|
|
2004-01-13 10:09:53 +00:00
|
|
|
// Wait for the voice 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 in use.
|
|
|
|
|
2004-03-24 07:29:59 +00:00
|
|
|
if (skipCutscene)
|
|
|
|
_snd->stopHandle(handle);
|
|
|
|
|
2004-01-13 10:09:53 +00:00
|
|
|
while (handle.isActive()) {
|
|
|
|
_vm->_graphics->updateDisplay(false);
|
2004-09-28 20:19:37 +00:00
|
|
|
_sys->delayMillis(100);
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
2004-02-15 14:22:54 +00:00
|
|
|
// Clear the screen again
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2004-03-24 07:29:59 +00:00
|
|
|
anim->clearScreen();
|
|
|
|
anim->updateScreen();
|
2004-01-13 10:09:53 +00:00
|
|
|
|
|
|
|
_vm->_graphics->setPalette(0, 256, oldPal, RDPAL_INSTANT);
|
|
|
|
|
2004-01-13 14:16:40 +00:00
|
|
|
delete anim;
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2004-02-15 14:22:54 +00:00
|
|
|
// Wait for the lead-out to stop, if there is any.
|
|
|
|
_vm->_sound->waitForLeadOut();
|
|
|
|
|
2004-01-13 10:09:53 +00:00
|
|
|
// Lead-in and lead-out music are, as far as I can tell, only used for
|
|
|
|
// the animated cut-scenes, so this seems like a good place to close
|
|
|
|
// both of them.
|
|
|
|
|
2004-05-01 10:42:23 +00:00
|
|
|
_vm->_sound->stopFx(-1);
|
|
|
|
_vm->_sound->stopFx(-2);
|
2004-01-13 10:09:53 +00:00
|
|
|
|
|
|
|
return RD_OK;
|
|
|
|
#else
|
|
|
|
// No MPEG2? Use the old 'Narration Only' hack
|
|
|
|
playDummy(filename, text, musicOut);
|
|
|
|
return RD_OK;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This just plays the cutscene with voiceovers / subtitles, in case the files
|
|
|
|
* are missing.
|
|
|
|
*/
|
|
|
|
|
2004-04-23 07:02:11 +00:00
|
|
|
int32 MoviePlayer::playDummy(const char *filename, MovieTextObject *text[], byte *musicOut) {
|
2004-01-13 10:09:53 +00:00
|
|
|
int frameCounter = 0, textCounter = 0;
|
|
|
|
if (text) {
|
2004-06-09 06:33:29 +00:00
|
|
|
byte oldPal[256 * 4];
|
|
|
|
byte tmpPal[256 * 4];
|
2004-01-13 10:09:53 +00:00
|
|
|
|
|
|
|
_vm->_graphics->clearScene();
|
|
|
|
|
|
|
|
// HACK: Draw instructions
|
|
|
|
//
|
|
|
|
// I'm using the the menu area, because that's unlikely to be
|
|
|
|
// touched by anything else during the cutscene.
|
|
|
|
|
|
|
|
memset(_vm->_graphics->_buffer, 0, _vm->_graphics->_screenWide * MENUDEEP);
|
|
|
|
|
2004-12-21 02:12:58 +00:00
|
|
|
byte *data;
|
|
|
|
|
|
|
|
// Russian version substituted latin characters with cyrillic. That's why
|
|
|
|
// it renders completely unreadable with default message
|
|
|
|
if (Common::parseLanguage(ConfMan.get("language")) == Common::RU_RUS) {
|
|
|
|
byte msg[] = "Po\344uk - to\344\345ko pev\345: hagmute k\344abuwy Ucke\343n, u\344u nocetute ca\343t npoekta u ckava\343te budeo po\344uku";
|
|
|
|
data = _vm->_fontRenderer->makeTextSprite(msg, RENDERWIDE, 255, _vm->_speechFontId);
|
|
|
|
} else {
|
2005-01-04 15:31:30 +00:00
|
|
|
// TODO: Translate message to other languages?
|
|
|
|
#ifdef USE_MPEG2
|
2004-12-21 02:12:58 +00:00
|
|
|
byte msg[] = "Cutscene - Narration Only: Press ESC to exit, or visit www.scummvm.org to download cutscene videos";
|
2005-01-04 15:31:30 +00:00
|
|
|
#else
|
|
|
|
byte msg[] = "Cutscene - Narration Only: Press ESC to exit, or recompile ScummVM with MPEG2 support";
|
|
|
|
#endif
|
2004-12-21 02:12:58 +00:00
|
|
|
data = _vm->_fontRenderer->makeTextSprite(msg, RENDERWIDE, 255, _vm->_speechFontId);
|
|
|
|
}
|
|
|
|
|
2004-04-23 07:02:11 +00:00
|
|
|
FrameHeader *frame = (FrameHeader *) data;
|
2004-01-13 10:09:53 +00:00
|
|
|
SpriteInfo msgSprite;
|
2004-04-23 07:02:11 +00:00
|
|
|
byte *msgSurface;
|
2004-01-13 10:09:53 +00:00
|
|
|
|
|
|
|
msgSprite.x = _vm->_graphics->_screenWide / 2 - frame->width / 2;
|
|
|
|
msgSprite.y = RDMENU_MENUDEEP / 2 - frame->height / 2;
|
|
|
|
msgSprite.w = frame->width;
|
|
|
|
msgSprite.h = frame->height;
|
|
|
|
msgSprite.type = RDSPR_NOCOMPRESSION;
|
2004-04-23 07:02:11 +00:00
|
|
|
msgSprite.data = data + sizeof(FrameHeader);
|
2004-01-13 10:09:53 +00:00
|
|
|
|
|
|
|
_vm->_graphics->createSurface(&msgSprite, &msgSurface);
|
|
|
|
_vm->_graphics->drawSurface(&msgSprite, msgSurface);
|
|
|
|
_vm->_graphics->deleteSurface(msgSurface);
|
2004-08-17 13:52:18 +00:00
|
|
|
free(data);
|
2004-01-13 10:09:53 +00:00
|
|
|
|
|
|
|
// In case the cutscene has a long lead-in, start just before
|
|
|
|
// the first line of text.
|
|
|
|
|
|
|
|
frameCounter = text[0]->startFrame - 12;
|
|
|
|
|
|
|
|
// Fake a palette that will hopefully make the text visible.
|
|
|
|
// In the opening cutscene it seems to use colours 1 (black?)
|
|
|
|
// and 255 (white?).
|
|
|
|
|
2004-06-09 06:33:29 +00:00
|
|
|
memcpy(oldPal, _vm->_graphics->_palette, sizeof(oldPal));
|
|
|
|
memset(tmpPal, 0, sizeof(tmpPal));
|
2004-01-13 10:09:53 +00:00
|
|
|
tmpPal[255 * 4 + 0] = 255;
|
|
|
|
tmpPal[255 * 4 + 1] = 255;
|
|
|
|
tmpPal[255 * 4 + 2] = 255;
|
|
|
|
_vm->_graphics->setPalette(0, 256, tmpPal, RDPAL_INSTANT);
|
|
|
|
|
|
|
|
PlayingSoundHandle handle;
|
|
|
|
|
|
|
|
bool skipCutscene = false;
|
|
|
|
|
|
|
|
uint32 flags = SoundMixer::FLAG_16BITS;
|
|
|
|
|
|
|
|
#ifndef SCUMM_BIG_ENDIAN
|
|
|
|
flags |= SoundMixer::FLAG_LITTLE_ENDIAN;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
if (!text[textCounter])
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (frameCounter == text[textCounter]->startFrame) {
|
|
|
|
_vm->_graphics->clearScene();
|
|
|
|
openTextObject(text[textCounter]);
|
2004-01-18 21:09:57 +00:00
|
|
|
drawTextObject(NULL, text[textCounter]);
|
2004-01-13 10:09:53 +00:00
|
|
|
if (text[textCounter]->speech) {
|
2004-03-21 18:49:04 +00:00
|
|
|
_snd->playRaw(&handle, text[textCounter]->speech, text[textCounter]->speechBufferSize, 22050, flags);
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (frameCounter == text[textCounter]->endFrame) {
|
|
|
|
closeTextObject(text[textCounter]);
|
|
|
|
_vm->_graphics->clearScene();
|
|
|
|
_vm->_graphics->setNeedFullRedraw();
|
|
|
|
textCounter++;
|
|
|
|
}
|
|
|
|
|
|
|
|
frameCounter++;
|
|
|
|
|
|
|
|
_vm->_graphics->updateDisplay();
|
|
|
|
|
2004-05-09 13:32:04 +00:00
|
|
|
KeyboardEvent *ke = _vm->keyboardEvent();
|
2004-01-13 10:09:53 +00:00
|
|
|
|
2004-05-09 13:32:04 +00:00
|
|
|
if ((ke && ke->keycode == 27) || _vm->_quit) {
|
2004-03-21 18:49:04 +00:00
|
|
|
_snd->stopHandle(handle);
|
2004-01-13 10:09:53 +00:00
|
|
|
skipCutscene = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Simulate ~12 frames per second. I don't know what
|
|
|
|
// frame rate the original movies had, or even if it
|
|
|
|
// was constant, but this seems to work reasonably.
|
|
|
|
|
2004-09-28 20:19:37 +00:00
|
|
|
_sys->delayMillis(90);
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Wait for the voice 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 in use.
|
|
|
|
|
|
|
|
while (handle.isActive()) {
|
|
|
|
_vm->_graphics->updateDisplay(false);
|
2004-09-28 20:19:37 +00:00
|
|
|
_sys->delayMillis(100);
|
2004-01-13 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
closeTextObject(text[textCounter]);
|
|
|
|
|
|
|
|
_vm->_graphics->clearScene();
|
|
|
|
_vm->_graphics->setNeedFullRedraw();
|
|
|
|
|
|
|
|
// HACK: Remove the instructions created above
|
|
|
|
Common::Rect r;
|
|
|
|
|
|
|
|
memset(_vm->_graphics->_buffer, 0, _vm->_graphics->_screenWide * MENUDEEP);
|
|
|
|
r.left = r.top = 0;
|
|
|
|
r.right = _vm->_graphics->_screenWide;
|
|
|
|
r.bottom = MENUDEEP;
|
|
|
|
_vm->_graphics->updateRect(&r);
|
|
|
|
|
|
|
|
// FIXME: For now, only play the lead-out music for cutscenes
|
|
|
|
// that have subtitles.
|
|
|
|
|
2004-02-15 14:22:54 +00:00
|
|
|
if (!skipCutscene && musicOut) {
|
|
|
|
_vm->_sound->playFx(0, musicOut, 0, 0, RDSE_FXLEADOUT);
|
|
|
|
_vm->_sound->waitForLeadOut();
|
|
|
|
}
|
2004-01-13 10:09:53 +00:00
|
|
|
|
|
|
|
_vm->_graphics->setPalette(0, 256, oldPal, RDPAL_INSTANT);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Lead-in and lead-out music are, as far as I can tell, only used for
|
|
|
|
// the animated cut-scenes, so this seems like a good place to close
|
|
|
|
// both of them.
|
|
|
|
|
2004-05-01 10:42:23 +00:00
|
|
|
_vm->_sound->stopFx(-1);
|
|
|
|
_vm->_sound->stopFx(-2);
|
2004-01-13 10:09:53 +00:00
|
|
|
|
|
|
|
return RD_OK;
|
|
|
|
}
|
|
|
|
|
2004-01-12 11:11:19 +00:00
|
|
|
} // End of namespace Sword2
|