scummvm/engines/lab/intro.cpp

475 lines
10 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-11-20 20:17:30 +01:00
#include "lab/intro.h"
2014-10-06 14:50:05 +02:00
#include "lab/labfun.h"
#include "lab/resource.h"
2014-10-06 14:50:05 +02:00
#include "lab/diff.h"
#include "lab/text.h"
#include "lab/interface.h"
namespace Lab {
extern bool nopalchange, DoBlack, IsHiRes;
2014-10-06 14:50:05 +02:00
extern char diffcmap[256 * 3];
extern uint32 VGAScreenWidth, VGAScreenHeight;
extern uint16 *FadePalette;
2015-11-20 20:17:30 +01:00
Intro::Intro() {
_msgfont = &_filler;
_quitIntro = false;
}
2014-10-06 14:50:05 +02:00
/******************************************************************************/
/* Goes thru, and responds to all the intuition messages currently in the */
/* the message port. */
/******************************************************************************/
2015-11-20 20:17:30 +01:00
void Intro::introEatMessages() {
2014-10-06 14:50:05 +02:00
while (1) {
2015-11-20 20:17:30 +01:00
IntuiMessage *msg = getMsg();
2014-10-06 14:50:05 +02:00
2015-02-26 01:15:54 +02:00
if (g_engine->shouldQuit()) {
2015-11-20 20:17:30 +01:00
_quitIntro = true;
2015-02-26 01:15:54 +02:00
return;
}
2015-11-20 20:17:30 +01:00
if (msg == NULL)
2014-10-06 14:50:05 +02:00
return;
else {
2015-11-20 20:17:30 +01:00
if (((msg->Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & msg->Qualifier)) ||
((msg->Class == RAWKEY) && (msg->Code == 27))
2015-02-26 01:15:54 +02:00
)
2015-11-20 20:17:30 +01:00
_quitIntro = true;
2014-10-06 14:50:05 +02:00
}
}
}
/*****************************************************************************/
/* Reads in a picture. */
/*****************************************************************************/
2015-11-20 20:17:30 +01:00
void Intro::doPictText(const char *filename, bool isscreen) {
2014-10-06 14:50:05 +02:00
uint32 lastsecs = 0L, lastmicros = 0L, secs = 0L, micros = 0L;
2015-11-20 20:17:30 +01:00
IntuiMessage *msg;
char path[50] = "Lab:rooms/Intro/";
2014-10-06 14:50:05 +02:00
byte *curplace, **tfile;
2015-11-20 20:17:30 +01:00
bool drawNextText = true, end = false, begin = true;
2014-10-06 14:50:05 +02:00
2015-11-20 20:17:30 +01:00
int32 cls, code, Drawn;
int16 qualifier;
2014-10-06 14:50:05 +02:00
uint timedelay;
2015-11-20 20:17:30 +01:00
strcat(path, filename);
2014-10-06 14:50:05 +02:00
if (isscreen) {
g_music->updateMusic();
2014-10-06 14:50:05 +02:00
timedelay = 35;
} else {
g_music->updateMusic();
2014-10-06 14:50:05 +02:00
timedelay = 7;
}
2015-11-20 20:17:30 +01:00
if (_quitIntro)
2014-10-06 14:50:05 +02:00
return;
while (1) {
2015-11-20 20:17:30 +01:00
if (drawNextText) {
if (begin) {
begin = false;
2014-10-06 14:50:05 +02:00
2015-11-20 20:17:30 +01:00
tfile = g_music->newOpen(path);
2014-10-06 14:50:05 +02:00
if (!tfile)
return;
curplace = *tfile;
} else if (isscreen)
fade(false, 0);
if (isscreen) {
setAPen(7L);
rectFill(VGAScaleX(10), VGAScaleY(10), VGAScaleX(310), VGAScaleY(190));
2015-11-20 20:17:30 +01:00
Drawn = flowText(_msgfont, (!IsHiRes) * -1, 5, 7, false, false, true, true, VGAScaleX(14), VGAScaleY(11), VGAScaleX(306), VGAScaleY(189), (char *)curplace);
2014-10-06 14:50:05 +02:00
fade(true, 0);
} else {
Drawn = longDrawMessage((char *)curplace);
2014-10-06 14:50:05 +02:00
}
curplace += Drawn;
2015-11-20 20:17:30 +01:00
end = (*curplace == 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) {
2014-10-06 14:50:05 +02:00
if (isscreen)
fade(false, 0);
return;
}
2015-11-20 19:45:07 +01:00
g_lab->getTime(&lastsecs, &lastmicros);
2014-10-06 14:50:05 +02:00
}
2015-11-20 20:17:30 +01:00
msg = getMsg();
2014-10-06 14:50:05 +02:00
2015-11-20 20:17:30 +01:00
if (msg == NULL) {
g_music->updateMusic();
2014-10-06 14:50:05 +02:00
diffNextFrame();
2015-11-20 19:45:07 +01:00
g_lab->getTime(&secs, &micros);
g_lab->anyTimeDiff(lastsecs, lastmicros, secs, micros, &secs, &micros);
2014-10-06 14:50:05 +02:00
if (secs > timedelay) {
2015-11-20 20:17:30 +01:00
if (end) {
2014-10-06 14:50:05 +02:00
if (isscreen)
fade(false, 0);
return;
} else {
2015-11-20 20:17:30 +01:00
drawNextText = true;
2014-10-06 14:50:05 +02:00
}
}
waitTOF();
} else {
2015-11-20 20:17:30 +01:00
cls = msg->Class;
qualifier = msg->Qualifier;
code = msg->Code;
2014-10-06 14:50:05 +02:00
2015-11-20 20:17:30 +01:00
if (((cls == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) ||
((cls == RAWKEY) && (code == 27))) {
_quitIntro = true;
2014-10-06 14:50:05 +02:00
if (isscreen)
fade(false, 0);
return;
}
2015-11-20 20:17:30 +01:00
else if (cls == MOUSEBUTTONS) {
if (IEQUALIFIER_LEFTBUTTON & qualifier) {
if (end) {
2014-10-06 14:50:05 +02:00
if (isscreen)
fade(false, 0);
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) {
2014-10-06 14:50:05 +02:00
if (isscreen)
fade(false, 0);
return;
}
}
2015-11-20 20:17:30 +01:00
if (end) {
2014-10-06 14:50:05 +02:00
if (isscreen)
fade(false, 0);
return;
} else
2015-11-20 20:17:30 +01:00
drawNextText = true;
2014-10-06 14:50:05 +02:00
}
}
}
/*****************************************************************************/
/* Does a one second delay, but checks the music while doing it. */
/*****************************************************************************/
2015-11-20 20:17:30 +01:00
void Intro::musicDelay() {
2014-10-06 14:50:05 +02:00
int16 counter;
g_music->updateMusic();
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 (counter = 0; counter < 20; counter++) {
g_music->updateMusic();
2014-10-06 14:50:05 +02:00
waitTOF();
waitTOF();
waitTOF();
}
}
2015-11-20 20:17:30 +01:00
void Intro::nReadPict(const char *filename, bool playOnce) {
Common::String finalFileName = Common::String("P:Intro/") + filename;
2014-10-06 14:50:05 +02:00
g_music->updateMusic();
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-11-20 20:17:30 +01:00
DoBlack = _introDoBlack;
2014-10-06 14:50:05 +02:00
stopDiffEnd();
2015-11-20 20:17:30 +01:00
readPict(finalFileName.c_str(), playOnce);
2014-10-06 14:50:05 +02:00
}
/*****************************************************************************/
/* Does the introduction sequence for Labyrinth. */
/*****************************************************************************/
2015-11-20 20:17:30 +01:00
void Intro::introSequence() {
2014-10-06 14:50:05 +02:00
uint16 counter, counter1;
2015-11-20 19:45:07 +01:00
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
DoBlack = true;
2014-12-27 14:18:40 +01:00
if (g_lab->getPlatform() != Common::kPlatformWindows) {
2015-11-20 20:17:30 +01:00
nReadPict("EA0", true);
nReadPict("EA1", true);
nReadPict("EA2", true);
nReadPict("EA3", true);
2014-12-27 14:18:40 +01:00
} else {
2015-11-20 20:17:30 +01:00
nReadPict("WYRMKEEP", true);
// Wait 4 seconds
for (counter = 0; counter < 4 * 1000 / 10; counter++) {
introEatMessages();
2015-11-20 20:17:30 +01:00
if (_quitIntro)
break;
g_system->delayMillis(10);
}
2014-12-27 14:18:40 +01:00
}
2014-10-06 14:50:05 +02:00
blackAllScreen();
g_music->initMusic();
nopalchange = true;
if (g_lab->getPlatform() != Common::kPlatformWindows)
2015-11-20 20:17:30 +01:00
nReadPict("TNDcycle.pic", true);
else
2015-11-20 20:17:30 +01:00
nReadPict("TNDcycle2.pic", true);
2014-10-06 14:50:05 +02:00
nopalchange = false;
2015-11-20 20:17:30 +01:00
FadePalette = palette;
2014-10-06 14:50:05 +02:00
for (counter = 0; counter < 16; counter++) {
2015-11-20 20:17:30 +01:00
if (_quitIntro)
break;
2015-11-20 20:17:30 +01:00
palette[counter] = ((diffcmap[counter * 3] >> 2) << 8) +
2014-10-06 14:50:05 +02:00
((diffcmap[counter * 3 + 1] >> 2) << 4) +
(diffcmap[counter * 3 + 2] >> 2);
}
g_music->updateMusic();
2014-10-06 14:50:05 +02:00
fade(true, 0);
for (int times = 0; times < 150; times++) {
2015-11-20 20:17:30 +01:00
if (_quitIntro)
break;
g_music->updateMusic();
2015-11-20 20:17:30 +01:00
uint16 temp = palette[2];
2014-10-06 14:50:05 +02:00
for (counter = 2; counter < 15; counter++)
2015-11-20 20:17:30 +01:00
palette[counter] = palette[counter + 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
2015-11-20 20:17:30 +01:00
setAmigaPal(palette, 16);
2014-10-06 14:50:05 +02:00
waitTOF();
}
fade(false, 0);
blackAllScreen();
2014-12-27 14:18:40 +01:00
g_music->updateMusic();
2014-10-06 14:50:05 +02:00
2015-11-20 20:17:30 +01:00
nReadPict("Title.A", true);
nReadPict("AB", true);
2014-10-06 14:50:05 +02:00
musicDelay();
2015-11-20 20:17:30 +01:00
nReadPict("BA", true);
nReadPict("AC", true);
2014-10-06 14:50:05 +02:00
musicDelay();
2014-12-27 14:18:40 +01:00
if (g_lab->getPlatform() == Common::kPlatformWindows)
musicDelay(); // more credits on this page now
2015-11-20 20:17:30 +01:00
nReadPict("CA", true);
nReadPict("AD", true);
2014-10-06 14:50:05 +02:00
musicDelay();
2014-12-27 14:18:40 +01:00
if (g_lab->getPlatform() == Common::kPlatformWindows)
musicDelay(); // more credits on this page now
2015-11-20 20:17:30 +01:00
nReadPict("DA", true);
2014-10-06 14:50:05 +02:00
musicDelay();
g_music->newOpen("p:Intro/Intro.1"); /* load the picture into the buffer */
g_music->updateMusic();
2014-10-06 14:50:05 +02:00
blackAllScreen();
g_music->updateMusic();
2014-10-06 14:50:05 +02:00
2015-11-20 20:17:30 +01:00
_msgfont = g_resource->getFont("P:Map.fon");
2014-10-06 14:50:05 +02:00
nopalchange = true;
2015-11-20 20:17:30 +01:00
nReadPict("Intro.1", true);
2014-10-06 14:50:05 +02:00
nopalchange = false;
for (counter = 0; counter < 16; counter++) {
2015-11-20 20:17:30 +01:00
palette[counter] = ((diffcmap[counter * 3] >> 2) << 8) +
2014-10-06 14:50:05 +02:00
((diffcmap[counter * 3 + 1] >> 2) << 4) +
(diffcmap[counter * 3 + 2] >> 2);
}
doPictText("i.1", true);
doPictText("i.2A", true);
doPictText("i.2B", true);
freeAllStolenMem();
blackAllScreen();
g_music->updateMusic();
2014-10-06 14:50:05 +02:00
2015-11-20 20:17:30 +01:00
_introDoBlack = true;
nReadPict("Station1", true);
2014-10-06 14:50:05 +02:00
doPictText("i.3", false);
2015-11-20 20:17:30 +01:00
nReadPict("Station2", true);
2014-10-06 14:50:05 +02:00
doPictText("i.4", false);
2015-11-20 20:17:30 +01:00
nReadPict("Stiles4", true);
2014-10-06 14:50:05 +02:00
doPictText("i.5", false);
2015-11-20 20:17:30 +01:00
nReadPict("Stiles3", true);
2014-10-06 14:50:05 +02:00
doPictText("i.6", false);
2015-11-20 20:17:30 +01:00
nReadPict("Platform2", true);
2014-10-06 14:50:05 +02:00
doPictText("i.7", false);
2015-11-20 20:17:30 +01:00
nReadPict("Subway.1", true);
2014-10-06 14:50:05 +02:00
doPictText("i.8", false);
2015-11-20 20:17:30 +01:00
nReadPict("Subway.2", true);
2014-10-06 14:50:05 +02:00
doPictText("i.9", false);
doPictText("i.10", false);
doPictText("i.11", false);
2015-11-20 20:17:30 +01:00
if (!_quitIntro)
2014-10-06 14:50:05 +02:00
for (counter = 0; counter < 50; counter++) {
for (counter1 = (8 * 3); counter1 < (255 * 3); counter1++)
diffcmap[counter1] = 255 - diffcmap[counter1];
g_music->updateMusic();
2014-10-06 14:50:05 +02:00
waitTOF();
VGASetPal(diffcmap, 256);
waitTOF();
waitTOF();
}
doPictText("i.12", false);
doPictText("i.13", false);
2015-11-20 20:17:30 +01:00
_introDoBlack = false;
nReadPict("Daed0", true);
2014-10-06 14:50:05 +02:00
doPictText("i.14", false);
2015-11-20 20:17:30 +01:00
nReadPict("Daed1", true);
2014-10-06 14:50:05 +02:00
doPictText("i.15", false);
2015-11-20 20:17:30 +01:00
nReadPict("Daed2", true);
2014-10-06 14:50:05 +02:00
doPictText("i.16", false);
doPictText("i.17", false);
doPictText("i.18", false);
2015-11-20 20:17:30 +01:00
nReadPict("Daed3", true);
2014-10-06 14:50:05 +02:00
doPictText("i.19", false);
doPictText("i.20", false);
2015-11-20 20:17:30 +01:00
nReadPict("Daed4", true);
2014-10-06 14:50:05 +02:00
doPictText("i.21", false);
2015-11-20 20:17:30 +01:00
nReadPict("Daed5", true);
2014-10-06 14:50:05 +02:00
doPictText("i.22", false);
doPictText("i.23", false);
doPictText("i.24", false);
2015-11-20 20:17:30 +01:00
nReadPict("Daed6", true);
2014-10-06 14:50:05 +02:00
doPictText("i.25", false);
doPictText("i.26", false);
2015-11-20 20:17:30 +01:00
nReadPict("Daed7", false);
2014-10-06 14:50:05 +02:00
doPictText("i.27", false);
doPictText("i.28", false);
stopDiffEnd();
2015-11-20 20:17:30 +01:00
nReadPict("Daed8", true);
2014-10-06 14:50:05 +02:00
doPictText("i.29", false);
doPictText("i.30", false);
2015-11-20 20:17:30 +01:00
nReadPict("Daed9", true);
2014-10-06 14:50:05 +02:00
doPictText("i.31", false);
doPictText("i.32", false);
doPictText("i.33", false);
2015-11-20 20:17:30 +01:00
nReadPict("Daed9a", true);
nReadPict("Daed10", true);
2014-10-06 14:50:05 +02:00
doPictText("i.34", false);
doPictText("i.35", false);
doPictText("i.36", false);
2015-11-20 20:17:30 +01:00
nReadPict("SubX", true);
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
setAPen(0);
rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1);
DoBlack = true;
}
}
} // End of namespace Lab