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.
|
2005-04-05 18:08:02 +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
|
2008-01-05 12:45:14 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2005-04-05 18:08:02 +00:00
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2005-04-09 19:19:54 +00:00
|
|
|
* 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.
|
2005-04-05 18:08:02 +00:00
|
|
|
*
|
2006-02-11 10:11:37 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2005-04-05 18:08:02 +00:00
|
|
|
*
|
|
|
|
*/
|
2006-03-29 15:59:37 +00:00
|
|
|
|
|
|
|
#include "common/endian.h"
|
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
#include "gob/gob.h"
|
|
|
|
#include "gob/init.h"
|
2007-03-20 14:51:57 +00:00
|
|
|
#include "gob/global.h"
|
2005-04-05 15:07:40 +00:00
|
|
|
#include "gob/util.h"
|
2007-03-20 14:51:57 +00:00
|
|
|
#include "gob/dataio.h"
|
|
|
|
#include "gob/draw.h"
|
|
|
|
#include "gob/game.h"
|
2009-06-23 01:20:05 +00:00
|
|
|
#include "gob/script.h"
|
2007-04-05 13:37:20 +00:00
|
|
|
#include "gob/palanim.h"
|
2008-05-28 21:15:11 +00:00
|
|
|
#include "gob/inter.h"
|
2007-03-20 14:51:57 +00:00
|
|
|
#include "gob/video.h"
|
2007-07-30 15:53:38 +00:00
|
|
|
#include "gob/videoplayer.h"
|
2009-04-29 23:54:29 +00:00
|
|
|
#include "gob/demos/scnplayer.h"
|
|
|
|
#include "gob/demos/batplayer.h"
|
2008-05-08 00:47:23 +00:00
|
|
|
#include "gob/sound/sound.h"
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
namespace Gob {
|
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
const char *Init::_fontNames[] = { "jeulet1.let", "jeulet2.let", "jeucar1.let", "jeumath.let" };
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
Init::Init(GobEngine *vm) : _vm(vm) {
|
2006-01-04 01:48:15 +00:00
|
|
|
_palDesc = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
}
|
|
|
|
|
2009-07-25 16:08:31 +00:00
|
|
|
Init::~Init() {
|
|
|
|
}
|
|
|
|
|
2009-05-20 23:13:44 +00:00
|
|
|
void Init::cleanup() {
|
2006-01-03 23:14:39 +00:00
|
|
|
_vm->_video->freeDriver();
|
2009-06-06 20:03:13 +00:00
|
|
|
_vm->_global->_primarySurfDesc.reset();
|
2006-01-29 02:27:10 +00:00
|
|
|
|
2008-05-08 00:47:23 +00:00
|
|
|
_vm->_sound->speakerOff();
|
|
|
|
_vm->_sound->blasterStop(0);
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_dataIO->closeDataFile();
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2009-05-20 23:13:44 +00:00
|
|
|
void Init::doDemo() {
|
|
|
|
if (_vm->isSCNDemo()) {
|
|
|
|
// This is a non-interactive demo with a SCN script and VMD videos
|
|
|
|
|
|
|
|
_vm->_video->setPrePalette();
|
|
|
|
|
|
|
|
SCNPlayer scnPlayer(_vm);
|
|
|
|
|
|
|
|
if (_vm->_demoIndex > 0)
|
|
|
|
scnPlayer.play(_vm->_demoIndex - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_vm->isBATDemo()) {
|
|
|
|
// This is a non-interactive demo with a BAT script and videos
|
|
|
|
|
|
|
|
BATPlayer batPlayer(_vm);
|
|
|
|
|
|
|
|
if (_vm->_demoIndex > 0)
|
|
|
|
batPlayer.play(_vm->_demoIndex - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-21 21:44:37 +00:00
|
|
|
void Init::initGame() {
|
2007-08-13 14:04:50 +00:00
|
|
|
byte *infBuf;
|
2005-04-05 15:07:40 +00:00
|
|
|
char *infPtr;
|
|
|
|
char *infEnd;
|
2007-08-13 14:04:50 +00:00
|
|
|
char buffer[128];
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
initVideo();
|
2009-07-25 16:08:31 +00:00
|
|
|
updateConfig();
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2009-05-20 23:13:44 +00:00
|
|
|
if (!_vm->isDemo()) {
|
2009-06-22 10:12:33 +00:00
|
|
|
if (_vm->_dataIO->existData(_vm->_startStk.c_str()))
|
2009-05-31 16:59:45 +00:00
|
|
|
_vm->_dataIO->openDataFile(_vm->_startStk.c_str());
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
_vm->_util->initInput();
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
_vm->_video->initPrimary(_vm->_global->_videoMode);
|
|
|
|
_vm->_global->_mouseXShift = 1;
|
|
|
|
_vm->_global->_mouseYShift = 1;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-29 02:27:10 +00:00
|
|
|
_palDesc = new Video::PalDesc;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->validateVideoMode(_vm->_global->_videoMode);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_global->_setAllPalette = true;
|
2006-01-07 22:28:54 +00:00
|
|
|
_palDesc->vgaPal = _vm->_draw->_vgaPalette;
|
|
|
|
_palDesc->unused1 = _vm->_draw->_unusedPalette1;
|
|
|
|
_palDesc->unused2 = _vm->_draw->_unusedPalette2;
|
2006-01-04 01:48:15 +00:00
|
|
|
_vm->_video->setFullPalette(_palDesc);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (int i = 0; i < 8; i++)
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_draw->_fonts[i] = 0;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2009-05-20 23:13:44 +00:00
|
|
|
if (_vm->isDemo()) {
|
|
|
|
doDemo();
|
2009-04-30 15:55:59 +00:00
|
|
|
delete _palDesc;
|
|
|
|
_vm->_video->initPrimary(-1);
|
|
|
|
cleanup();
|
2009-04-24 18:23:17 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-06-22 10:12:33 +00:00
|
|
|
if (!_vm->_dataIO->existData("intro.inf")) {
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2009-06-22 10:12:33 +00:00
|
|
|
for (int i = 0; i < 4; i++)
|
2009-07-09 02:54:10 +00:00
|
|
|
_vm->_draw->loadFont(i, _fontNames[i]);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2009-06-22 10:12:33 +00:00
|
|
|
} else {
|
2007-08-13 14:04:50 +00:00
|
|
|
infBuf = _vm->_dataIO->getData("intro.inf");
|
|
|
|
infPtr = (char *) infBuf;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-08-13 14:04:50 +00:00
|
|
|
infEnd = (char *) (infBuf + _vm->_dataIO->getDataSize("intro.inf"));
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-09-21 18:50:53 +00:00
|
|
|
for (int i = 0; i < 8; i++, infPtr++) {
|
2007-03-20 14:51:57 +00:00
|
|
|
int j;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
for (j = 0; infPtr < infEnd && *infPtr >= ' '; j++, infPtr++)
|
|
|
|
buffer[j] = *infPtr;
|
2005-04-05 15:07:40 +00:00
|
|
|
buffer[j] = 0;
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
strcat(buffer, ".let");
|
2009-07-09 02:54:10 +00:00
|
|
|
|
|
|
|
_vm->_draw->loadFont(i, buffer);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if ((infPtr + 1) >= infEnd)
|
2005-04-05 15:07:40 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
infPtr++;
|
|
|
|
}
|
2006-01-29 02:27:10 +00:00
|
|
|
delete[] infBuf;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2009-06-22 10:12:33 +00:00
|
|
|
if (_vm->_dataIO->existData(_vm->_startTot.c_str())) {
|
2009-06-23 01:20:05 +00:00
|
|
|
_vm->_inter->allocateVars(Script::getVariablesCount(_vm->_startTot.c_str(), _vm));
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2009-06-22 10:12:33 +00:00
|
|
|
strcpy(_vm->_game->_curTotFile, _vm->_startTot.c_str());
|
2005-04-13 18:27:29 +00:00
|
|
|
|
2008-05-08 00:47:23 +00:00
|
|
|
_vm->_sound->cdTest(1, "GOB");
|
|
|
|
_vm->_sound->cdLoadLIC("gob.lic");
|
2007-03-29 17:55:39 +00:00
|
|
|
|
2007-04-05 13:37:20 +00:00
|
|
|
// Search for a Coktel logo animation or image to display
|
2009-06-22 10:12:33 +00:00
|
|
|
if (_vm->_dataIO->existData("coktel.imd")) {
|
2007-03-29 17:55:39 +00:00
|
|
|
_vm->_draw->initScreen();
|
2007-04-05 13:37:20 +00:00
|
|
|
_vm->_draw->_cursorIndex = -1;
|
2007-07-30 15:53:38 +00:00
|
|
|
|
2007-03-31 15:25:54 +00:00
|
|
|
_vm->_util->longDelay(200); // Letting everything settle
|
2007-07-30 15:53:38 +00:00
|
|
|
|
2008-04-27 03:19:19 +00:00
|
|
|
if (_vm->_vidPlayer->primaryOpen("coktel.imd")) {
|
|
|
|
_vm->_vidPlayer->primaryPlay();
|
|
|
|
_vm->_vidPlayer->primaryClose();
|
2007-07-30 15:53:38 +00:00
|
|
|
}
|
|
|
|
|
2007-03-29 17:55:39 +00:00
|
|
|
_vm->_draw->closeScreen();
|
2009-06-22 10:12:33 +00:00
|
|
|
} else if (_vm->_dataIO->existData("coktel.clt")) {
|
2007-04-05 13:37:20 +00:00
|
|
|
_vm->_draw->initScreen();
|
|
|
|
_vm->_util->clearPalette();
|
2009-06-22 10:12:33 +00:00
|
|
|
|
2009-06-23 01:20:05 +00:00
|
|
|
DataStream *stream = _vm->_dataIO->getDataStream("coktel.clt");
|
2007-07-31 01:43:32 +00:00
|
|
|
stream->read((byte *) _vm->_draw->_vgaPalette, 768);
|
|
|
|
delete stream;
|
|
|
|
|
2009-06-22 10:12:33 +00:00
|
|
|
if (_vm->_dataIO->existData("coktel.ims")) {
|
2007-04-05 13:37:20 +00:00
|
|
|
byte *sprBuf;
|
|
|
|
|
|
|
|
sprBuf = _vm->_dataIO->getData("coktel.ims");
|
|
|
|
_vm->_video->drawPackedSprite(sprBuf, 320, 200, 0, 0, 0,
|
2009-06-06 20:03:13 +00:00
|
|
|
*_vm->_draw->_frontSurface);
|
2007-04-05 13:37:20 +00:00
|
|
|
_vm->_palAnim->fade(_palDesc, 0, 0);
|
|
|
|
_vm->_util->delay(500);
|
|
|
|
|
|
|
|
delete[] sprBuf;
|
|
|
|
}
|
|
|
|
_vm->_draw->closeScreen();
|
2007-03-29 17:55:39 +00:00
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
_vm->_game->start();
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2008-05-08 00:47:23 +00:00
|
|
|
_vm->_sound->cdStop();
|
|
|
|
_vm->_sound->cdUnloadLIC();
|
2005-04-13 18:27:29 +00:00
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-29 02:27:10 +00:00
|
|
|
delete _palDesc;
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->_dataIO->closeDataFile();
|
2006-01-03 23:14:39 +00:00
|
|
|
_vm->_video->initPrimary(-1);
|
|
|
|
cleanup();
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2009-07-25 16:08:31 +00:00
|
|
|
void Init::updateConfig() {
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
} // End of namespace Gob
|