scummvm/engines/lab/intro.cpp

439 lines
9.4 KiB
C++
Raw Normal View History

2014-10-06 14:50:05 +02: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.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* This code is based on Labyrinth of Time code with assistance of
*
* Copyright (c) 1993 Terra Nova Development
* Copyright (c) 2004 The Wyrmkeep Entertainment Co.
*
*/
2014-12-27 14:18:40 +01:00
#include "lab/lab.h"
2015-12-08 21:10:54 +01:00
#include "lab/anim.h"
#include "lab/dispman.h"
#include "lab/eventman.h"
2015-11-20 20:17:30 +01:00
#include "lab/intro.h"
#include "lab/music.h"
2015-12-08 21:10:54 +01:00
#include "lab/resource.h"
#include "lab/utils.h"
2014-10-06 14:50:05 +02:00
namespace Lab {
2015-12-02 23:10:41 +01:00
Intro::Intro(LabEngine *vm) : _vm(vm) {
2015-11-20 20:17:30 +01:00
_quitIntro = false;
_introDoBlack = false;
_font = _vm->_resource->getFont("F:Map.fon");
}
Intro::~Intro() {
2015-12-24 18:30:54 +02:00
_vm->_graphics->freeFont(&_font);
2015-11-20 20:17:30 +01:00
}
2014-10-06 14:50:05 +02:00
2015-11-20 20:17:30 +01:00
void Intro::introEatMessages() {
2014-10-06 14:50:05 +02:00
while (1) {
2015-12-13 15:37:39 +02:00
IntuiMessage *msg = _vm->_event->getMsg();
2014-10-06 14:50:05 +02:00
if (_vm->shouldQuit()) {
2015-11-20 20:17:30 +01:00
_quitIntro = true;
2015-02-26 01:15:54 +02:00
return;
}
if (!msg)
2014-10-06 14:50:05 +02:00
return;
2015-12-18 00:41:24 +02:00
if ((msg->_msgClass == kMessageRightClick)
|| ((msg->_msgClass == kMessageRawKey) && (msg->_code == Common::KEYCODE_ESCAPE)))
_quitIntro = true;
2014-10-06 14:50:05 +02:00
}
}
2015-12-24 01:42:21 +01:00
void Intro::doPictText(const Common::String filename, bool isScreen) {
Common::String path = Common::String("Lab:rooms/Intro/") + filename;
2014-10-06 14:50:05 +02:00
uint timeDelay = (isScreen) ? 35 : 7;
_vm->updateMusicAndEvents();
2014-10-06 14:50:05 +02:00
2015-11-20 20:17:30 +01:00
if (_quitIntro)
2014-10-06 14:50:05 +02:00
return;
uint32 lastMillis = 0;
bool drawNextText = true;
bool doneFl = false;
bool begin = true;
2015-12-02 23:10:41 +01:00
Common::File *textFile = _vm->_resource->openDataFile(path);
byte *textBuffer = new byte[textFile->size()];
textFile->read(textBuffer, textFile->size());
delete textFile;
byte *curText = textBuffer;
2014-10-06 14:50:05 +02:00
while (1) {
2015-11-20 20:17:30 +01:00
if (drawNextText) {
if (begin)
2015-11-20 20:17:30 +01:00
begin = false;
else if (isScreen)
_vm->_graphics->fade(false);
2014-10-06 14:50:05 +02:00
2015-12-02 23:10:41 +01:00
if (isScreen) {
2015-12-24 12:08:51 +02:00
_vm->_graphics->rectFillScaled(10, 10, 310, 190, 7);
2014-10-06 14:50:05 +02:00
2015-12-24 11:59:03 +02:00
curText += _vm->_graphics->flowText(_font, _vm->_isHiRes ? 0 : -1, 5, 7, false, false, true, true, _vm->_utils->vgaRectScale(14, 11, 306, 189), (char *)curText);
_vm->_graphics->fade(true);
} else
2015-12-24 11:59:03 +02:00
curText += _vm->_graphics->longDrawMessage(Common::String((char *)curText), false);
2014-10-06 14:50:05 +02:00
doneFl = (*curText == 0);
2014-10-06 14:50:05 +02:00
2015-11-20 20:17:30 +01:00
drawNextText = false;
2014-10-06 14:50:05 +02:00
introEatMessages();
2015-11-20 20:17:30 +01:00
if (_quitIntro) {
2015-12-02 23:10:41 +01:00
if (isScreen)
_vm->_graphics->fade(false);
2014-10-06 14:50:05 +02:00
delete[] textBuffer;
2014-10-06 14:50:05 +02:00
return;
}
2015-12-23 18:56:35 +01:00
lastMillis = _vm->_system->getMillis();
2014-10-06 14:50:05 +02:00
}
IntuiMessage *msg = _vm->_event->getMsg();
if (_vm->shouldQuit()) {
_quitIntro = true;
return;
}
2014-10-06 14:50:05 +02:00
if (!msg) {
_vm->updateMusicAndEvents();
2015-12-02 23:10:41 +01:00
_vm->_anim->diffNextFrame();
2015-12-23 18:56:35 +01:00
uint32 elapsedSeconds = (_vm->_system->getMillis() - lastMillis) / 1000;
2014-10-06 14:50:05 +02:00
if (elapsedSeconds > timeDelay) {
if (doneFl) {
2015-12-02 23:10:41 +01:00
if (isScreen)
_vm->_graphics->fade(false);
2014-10-06 14:50:05 +02:00
delete[] textBuffer;
2014-10-06 14:50:05 +02:00
return;
} else {
2015-11-20 20:17:30 +01:00
drawNextText = true;
2014-10-06 14:50:05 +02:00
}
}
2015-12-02 23:10:41 +01:00
_vm->waitTOF();
2014-10-06 14:50:05 +02:00
} else {
uint32 msgClass = msg->_msgClass;
uint16 code = msg->_code;
2014-10-06 14:50:05 +02:00
2015-12-18 00:41:24 +02:00
if ((msgClass == kMessageRightClick) ||
((msgClass == kMessageRawKey) && (code == Common::KEYCODE_ESCAPE))) {
2015-11-20 20:17:30 +01:00
_quitIntro = true;
2014-10-06 14:50:05 +02:00
2015-12-02 23:10:41 +01:00
if (isScreen)
_vm->_graphics->fade(false);
2014-10-06 14:50:05 +02:00
delete[] textBuffer;
2014-10-06 14:50:05 +02:00
return;
2015-12-18 00:41:24 +02:00
} else if ((msgClass == kMessageLeftClick) || (msgClass == kMessageRightClick)) {
if (msgClass == kMessageLeftClick) {
if (doneFl) {
2015-12-02 23:10:41 +01:00
if (isScreen)
_vm->_graphics->fade(false);
2014-10-06 14:50:05 +02:00
delete[] textBuffer;
2014-10-06 14:50:05 +02:00
return;
} else
2015-11-20 20:17:30 +01:00
drawNextText = true;
2014-10-06 14:50:05 +02:00
}
introEatMessages();
2015-11-20 20:17:30 +01:00
if (_quitIntro) {
2015-12-02 23:10:41 +01:00
if (isScreen)
_vm->_graphics->fade(false);
2014-10-06 14:50:05 +02:00
delete[] textBuffer;
2014-10-06 14:50:05 +02:00
return;
}
}
if (doneFl) {
2015-12-02 23:10:41 +01:00
if (isScreen)
_vm->_graphics->fade(false);
2014-10-06 14:50:05 +02:00
delete[] textBuffer;
2014-10-06 14:50:05 +02:00
return;
} else
2015-11-20 20:17:30 +01:00
drawNextText = true;
2014-10-06 14:50:05 +02:00
}
} // while(1)
2014-10-06 14:50:05 +02:00
}
2015-11-20 20:17:30 +01:00
void Intro::musicDelay() {
_vm->updateMusicAndEvents();
2014-10-06 14:50:05 +02:00
2015-11-20 20:17:30 +01:00
if (_quitIntro)
2014-10-06 14:50:05 +02:00
return;
for (int i = 0; i < 20; i++) {
_vm->updateMusicAndEvents();
2015-12-02 23:10:41 +01:00
_vm->waitTOF();
_vm->waitTOF();
_vm->waitTOF();
2014-10-06 14:50:05 +02:00
}
}
void Intro::nReadPict(const Common::String filename, bool playOnce) {
2015-11-20 20:17:30 +01:00
Common::String finalFileName = Common::String("P:Intro/") + filename;
2014-10-06 14:50:05 +02:00
_vm->updateMusicAndEvents();
introEatMessages();
2014-10-06 14:50:05 +02:00
2015-11-20 20:17:30 +01:00
if (_quitIntro)
2014-10-06 14:50:05 +02:00
return;
2015-12-02 23:10:41 +01:00
_vm->_anim->_doBlack = _introDoBlack;
_vm->_anim->stopDiffEnd();
2015-12-20 16:46:45 +01:00
_vm->_graphics->readPict(finalFileName, playOnce);
2014-10-06 14:50:05 +02:00
}
2015-12-24 01:47:53 +01:00
void Intro::play() {
2015-11-20 20:17:30 +01:00
uint16 palette[16] = {
0x0000, 0x0855, 0x0FF9, 0x0EE7,
0x0ED5, 0x0DB4, 0x0CA2, 0x0C91,
0x0B80, 0x0B80, 0x0B91, 0x0CA2,
0x0CB3, 0x0DC4, 0x0DD6, 0x0EE7
};
2014-10-06 14:50:05 +02:00
2015-12-02 23:10:41 +01:00
_vm->_anim->_doBlack = true;
2014-10-06 14:50:05 +02:00
if (_vm->getPlatform() == Common::kPlatformDOS) {
2015-12-20 16:46:45 +01:00
nReadPict("EA0");
nReadPict("EA1");
nReadPict("EA2");
nReadPict("EA3");
} else if (_vm->getPlatform() == Common::kPlatformWindows) {
2015-12-20 16:46:45 +01:00
nReadPict("WYRMKEEP");
// Wait 4 seconds
for (int i = 0; i < 4 * 1000 / 10; i++) {
introEatMessages();
2015-11-20 20:17:30 +01:00
if (_quitIntro)
break;
2015-12-23 18:56:35 +01:00
_vm->_system->delayMillis(10);
}
2014-12-27 14:18:40 +01:00
}
_vm->_graphics->blackAllScreen();
if (_vm->getPlatform() == Common::kPlatformAmiga)
_vm->_music->initMusic("Music:BackGround");
else
_vm->_music->initMusic("Music:BackGrou");
2014-10-06 14:50:05 +02:00
2015-12-02 23:10:41 +01:00
_vm->_anim->_noPalChange = true;
if (_vm->getPlatform() == Common::kPlatformDOS)
2015-12-20 16:46:45 +01:00
nReadPict("TNDcycle.pic");
else
2015-12-20 16:46:45 +01:00
nReadPict("TNDcycle2.pic");
2015-12-02 23:10:41 +01:00
_vm->_anim->_noPalChange = false;
2014-10-06 14:50:05 +02:00
2015-12-14 08:59:16 +01:00
_vm->_graphics->_fadePalette = palette;
2014-10-06 14:50:05 +02:00
for (int i = 0; i < 16; i++) {
2015-11-20 20:17:30 +01:00
if (_quitIntro)
break;
2015-12-02 23:10:41 +01:00
palette[i] = ((_vm->_anim->_diffPalette[i * 3] >> 2) << 8) +
2015-12-08 09:19:00 +01:00
((_vm->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) +
(_vm->_anim->_diffPalette[i * 3 + 2] >> 2);
2014-10-06 14:50:05 +02:00
}
_vm->updateMusicAndEvents();
_vm->_graphics->fade(true);
2014-10-06 14:50:05 +02:00
for (int times = 0; times < 150; times++) {
2015-11-20 20:17:30 +01:00
if (_quitIntro)
break;
_vm->updateMusicAndEvents();
2015-11-20 20:17:30 +01:00
uint16 temp = palette[2];
2014-10-06 14:50:05 +02:00
for (int i = 2; i < 15; i++)
palette[i] = palette[i + 1];
2014-10-06 14:50:05 +02:00
2015-11-20 20:17:30 +01:00
palette[15] = temp;
2014-10-06 14:50:05 +02:00
_vm->_graphics->setAmigaPal(palette);
2015-12-02 23:10:41 +01:00
_vm->waitTOF();
2014-10-06 14:50:05 +02:00
}
_vm->_graphics->fade(false);
_vm->_graphics->blackAllScreen();
_vm->updateMusicAndEvents();
2014-10-06 14:50:05 +02:00
2015-12-20 16:46:45 +01:00
nReadPict("Title.A");
nReadPict("AB");
2014-10-06 14:50:05 +02:00
musicDelay();
2015-12-20 16:46:45 +01:00
nReadPict("BA");
nReadPict("AC");
2014-10-06 14:50:05 +02:00
musicDelay();
2014-12-27 14:18:40 +01:00
2015-12-02 23:10:41 +01:00
if (_vm->getPlatform() == Common::kPlatformWindows)
2014-12-27 14:18:40 +01:00
musicDelay(); // more credits on this page now
2015-12-20 16:46:45 +01:00
nReadPict("CA");
nReadPict("AD");
2014-10-06 14:50:05 +02:00
musicDelay();
2014-12-27 14:18:40 +01:00
2015-12-02 23:10:41 +01:00
if (_vm->getPlatform() == Common::kPlatformWindows)
2014-12-27 14:18:40 +01:00
musicDelay(); // more credits on this page now
2015-12-20 16:46:45 +01:00
nReadPict("DA");
2014-10-06 14:50:05 +02:00
musicDelay();
_vm->updateMusicAndEvents();
_vm->_graphics->blackAllScreen();
_vm->updateMusicAndEvents();
2014-10-06 14:50:05 +02:00
2015-12-02 23:10:41 +01:00
_vm->_anim->_noPalChange = true;
2015-12-20 16:46:45 +01:00
nReadPict("Intro.1");
2015-12-02 23:10:41 +01:00
_vm->_anim->_noPalChange = false;
2014-10-06 14:50:05 +02:00
for (int i = 0; i < 16; i++) {
2015-12-02 23:10:41 +01:00
palette[i] = ((_vm->_anim->_diffPalette[i * 3] >> 2) << 8) +
2015-12-08 09:19:00 +01:00
((_vm->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) +
(_vm->_anim->_diffPalette[i * 3 + 2] >> 2);
2014-10-06 14:50:05 +02:00
}
2015-12-24 01:42:21 +01:00
doPictText("i.1", true);
2015-12-18 04:21:22 +02:00
if (_vm->getPlatform() == Common::kPlatformWindows) {
2015-12-24 01:42:21 +01:00
doPictText("i.2A", true);
doPictText("i.2B", true);
2015-12-18 04:21:22 +02:00
}
2014-10-06 14:50:05 +02:00
_vm->_graphics->blackAllScreen();
_vm->updateMusicAndEvents();
2014-10-06 14:50:05 +02:00
2015-11-20 20:17:30 +01:00
_introDoBlack = true;
2015-12-20 16:46:45 +01:00
nReadPict("Station1");
2015-12-24 01:42:21 +01:00
doPictText("i.3");
2014-10-06 14:50:05 +02:00
2015-12-20 16:46:45 +01:00
nReadPict("Station2");
2015-12-24 01:42:21 +01:00
doPictText("i.4");
2014-10-06 14:50:05 +02:00
2015-12-20 16:46:45 +01:00
nReadPict("Stiles4");
2015-12-24 01:42:21 +01:00
doPictText("i.5");
2014-10-06 14:50:05 +02:00
2015-12-20 16:46:45 +01:00
nReadPict("Stiles3");
2015-12-24 01:42:21 +01:00
doPictText("i.6");
2014-10-06 14:50:05 +02:00
2015-12-18 04:21:22 +02:00
if (_vm->getPlatform() == Common::kPlatformWindows)
2015-12-20 16:46:45 +01:00
nReadPict("Platform2");
2015-12-18 04:21:22 +02:00
else
2015-12-20 16:46:45 +01:00
nReadPict("Platform");
2015-12-24 01:42:21 +01:00
doPictText("i.7");
2014-10-06 14:50:05 +02:00
2015-12-20 16:46:45 +01:00
nReadPict("Subway.1");
2015-12-24 01:42:21 +01:00
doPictText("i.8");
2014-10-06 14:50:05 +02:00
2015-12-20 16:46:45 +01:00
nReadPict("Subway.2");
2014-10-06 14:50:05 +02:00
2015-12-24 01:42:21 +01:00
doPictText("i.9");
doPictText("i.10");
doPictText("i.11");
2014-10-06 14:50:05 +02:00
2015-11-20 20:17:30 +01:00
if (!_quitIntro)
for (int i = 0; i < 50; i++) {
for (int idx = (8 * 3); idx < (255 * 3); idx++)
2015-12-02 23:10:41 +01:00
_vm->_anim->_diffPalette[idx] = 255 - _vm->_anim->_diffPalette[idx];
2014-10-06 14:50:05 +02:00
_vm->updateMusicAndEvents();
2015-12-02 23:10:41 +01:00
_vm->waitTOF();
2015-12-06 14:36:49 +01:00
_vm->_graphics->setPalette(_vm->_anim->_diffPalette, 256);
2015-12-02 23:10:41 +01:00
_vm->waitTOF();
_vm->waitTOF();
2014-10-06 14:50:05 +02:00
}
2015-12-24 01:42:21 +01:00
doPictText("i.12");
doPictText("i.13");
2014-10-06 14:50:05 +02:00
2015-11-20 20:17:30 +01:00
_introDoBlack = false;
2015-12-20 16:46:45 +01:00
nReadPict("Daed0");
2015-12-24 01:42:21 +01:00
doPictText("i.14");
2014-10-06 14:50:05 +02:00
2015-12-20 16:46:45 +01:00
nReadPict("Daed1");
2015-12-24 01:42:21 +01:00
doPictText("i.15");
2014-10-06 14:50:05 +02:00
2015-12-20 16:46:45 +01:00
nReadPict("Daed2");
2015-12-24 01:42:21 +01:00
doPictText("i.16");
doPictText("i.17");
doPictText("i.18");
2014-10-06 14:50:05 +02:00
2015-12-20 16:46:45 +01:00
nReadPict("Daed3");
2015-12-24 01:42:21 +01:00
doPictText("i.19");
doPictText("i.20");
2014-10-06 14:50:05 +02:00
2015-12-20 16:46:45 +01:00
nReadPict("Daed4");
2015-12-24 01:42:21 +01:00
doPictText("i.21");
2014-10-06 14:50:05 +02:00
2015-12-20 16:46:45 +01:00
nReadPict("Daed5");
2015-12-24 01:42:21 +01:00
doPictText("i.22");
doPictText("i.23");
doPictText("i.24");
2014-10-06 14:50:05 +02:00
2015-12-20 16:46:45 +01:00
nReadPict("Daed6");
2015-12-24 01:42:21 +01:00
doPictText("i.25");
doPictText("i.26");
2014-10-06 14:50:05 +02:00
2015-11-20 20:17:30 +01:00
nReadPict("Daed7", false);
2015-12-24 01:42:21 +01:00
doPictText("i.27");
doPictText("i.28");
2015-12-02 23:10:41 +01:00
_vm->_anim->stopDiffEnd();
2014-10-06 14:50:05 +02:00
2015-12-20 16:46:45 +01:00
nReadPict("Daed8");
2015-12-24 01:42:21 +01:00
doPictText("i.29");
doPictText("i.30");
2014-10-06 14:50:05 +02:00
2015-12-20 16:46:45 +01:00
nReadPict("Daed9");
2015-12-24 01:42:21 +01:00
doPictText("i.31");
doPictText("i.32");
doPictText("i.33");
2014-10-06 14:50:05 +02:00
2015-12-20 16:46:45 +01:00
nReadPict("Daed9a");
nReadPict("Daed10");
2015-12-24 01:42:21 +01:00
doPictText("i.34");
doPictText("i.35");
doPictText("i.36");
2014-10-06 14:50:05 +02:00
2015-12-20 16:46:45 +01:00
nReadPict("SubX");
2014-10-06 14:50:05 +02:00
2015-11-20 20:17:30 +01:00
if (_quitIntro) {
2015-12-24 12:08:51 +02:00
_vm->_graphics->rectFill(0, 0, _vm->_graphics->_screenWidth - 1, _vm->_graphics->_screenHeight - 1, 0);
2015-12-02 23:10:41 +01:00
_vm->_anim->_doBlack = true;
2014-10-06 14:50:05 +02:00
}
}
} // End of namespace Lab