2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2006-02-22 22:40:53 +00:00
|
|
|
*
|
2007-05-30 21:56:52 +00:00
|
|
|
* 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.
|
2006-02-22 22:40:53 +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-09-19 13:55:05 +00:00
|
|
|
#include "common/events.h"
|
2006-02-22 22:40:53 +00:00
|
|
|
#include "common/file.h"
|
|
|
|
#include "common/savefile.h"
|
|
|
|
#include "common/config-manager.h"
|
2006-02-25 01:01:27 +00:00
|
|
|
#include "common/system.h"
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-05-25 22:51:42 +00:00
|
|
|
#include "graphics/cursorman.h"
|
|
|
|
|
2006-02-22 22:40:53 +00:00
|
|
|
#include "sound/mididrv.h"
|
|
|
|
#include "sound/mixer.h"
|
|
|
|
|
|
|
|
#include "cine/cine.h"
|
2006-11-08 21:46:57 +00:00
|
|
|
#include "cine/bg_list.h"
|
2006-02-25 01:01:27 +00:00
|
|
|
#include "cine/main_loop.h"
|
2006-02-25 01:18:01 +00:00
|
|
|
#include "cine/object.h"
|
2006-11-13 21:16:50 +00:00
|
|
|
#include "cine/texte.h"
|
2007-05-19 12:08:41 +00:00
|
|
|
#include "cine/sound.h"
|
2006-02-25 01:18:01 +00:00
|
|
|
#include "cine/various.h"
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-02-25 00:26:14 +00:00
|
|
|
|
|
|
|
namespace Cine {
|
|
|
|
|
2007-05-19 12:08:41 +00:00
|
|
|
Sound *g_sound;
|
2006-04-10 05:37:31 +00:00
|
|
|
Common::SaveFileManager *g_saveFileMan;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-10-15 01:06:44 +00:00
|
|
|
CineEngine *g_cine;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2007-11-03 21:06:58 +00:00
|
|
|
CineEngine::CineEngine(OSystem *syst, const CINEGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
|
2006-04-12 01:48:15 +00:00
|
|
|
Common::addSpecialDebugLevel(kCineDebugScript, "Script", "Script debug level");
|
2007-12-07 20:45:51 +00:00
|
|
|
Common::addSpecialDebugLevel(kCineDebugPart, "Part", "Part debug level");
|
2007-12-09 13:41:59 +00:00
|
|
|
Common::addSpecialDebugLevel(kCineDebugSound, "Sound", "Sound debug level");
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
// Setup mixer
|
|
|
|
if (!_mixer->isReady()) {
|
|
|
|
warning("Sound initialization failed.");
|
|
|
|
}
|
|
|
|
|
2006-02-23 18:47:28 +00:00
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
|
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-10-15 01:06:44 +00:00
|
|
|
g_cine = this;
|
2007-09-19 13:55:05 +00:00
|
|
|
|
|
|
|
syst->getEventManager()->registerRandomSource(_rnd, "cine");
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CineEngine::~CineEngine() {
|
2006-11-13 21:16:50 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_OS) {
|
|
|
|
freePoldatDat();
|
|
|
|
freeErrmessDat();
|
|
|
|
}
|
2007-12-09 13:41:59 +00:00
|
|
|
Common::clearAllSpecialDebugLevels();
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2006-04-15 20:36:41 +00:00
|
|
|
int CineEngine::init() {
|
2006-02-22 22:40:53 +00:00
|
|
|
// Initialize backend
|
|
|
|
_system->beginGFXTransaction();
|
2006-04-15 20:36:41 +00:00
|
|
|
initCommonGFX(false);
|
2006-02-23 18:47:28 +00:00
|
|
|
_system->initSize(320, 200);
|
2006-02-22 22:40:53 +00:00
|
|
|
_system->endGFXTransaction();
|
|
|
|
|
2007-05-13 16:11:19 +00:00
|
|
|
if (g_cine->getPlatform() == Common::kPlatformPC) {
|
2007-05-19 12:08:41 +00:00
|
|
|
g_sound = new PCSound(_mixer, this);
|
2006-03-09 22:37:19 +00:00
|
|
|
} else {
|
2007-05-13 16:11:19 +00:00
|
|
|
// Paula chipset for Amiga and Atari versions
|
2007-05-19 12:08:41 +00:00
|
|
|
g_sound = new PaulaSound(_mixer, this);
|
2006-03-09 22:37:19 +00:00
|
|
|
}
|
2006-04-10 05:37:31 +00:00
|
|
|
g_saveFileMan = _saveFileMan;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
initialize();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CineEngine::go() {
|
2006-05-25 22:51:42 +00:00
|
|
|
CursorMan.showMouse(true);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
mainLoop(1);
|
|
|
|
|
2007-05-19 12:08:41 +00:00
|
|
|
delete g_sound;
|
2006-02-22 22:40:53 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-25 09:28:00 +00:00
|
|
|
void CineEngine::initialize() {
|
2006-02-23 09:12:21 +00:00
|
|
|
uint16 i;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-04-08 13:20:40 +00:00
|
|
|
setupOpcodes();
|
|
|
|
|
2006-11-11 15:37:03 +00:00
|
|
|
initLanguage(g_cine->getLanguage());
|
2007-05-19 21:12:10 +00:00
|
|
|
gfxInit();
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-23 03:45:52 +00:00
|
|
|
textDataPtr = (byte *)malloc(8000);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-16 20:29:07 +00:00
|
|
|
partBuffer = (PartBuffer *)malloc(NUM_MAX_PARTDATA * sizeof(PartBuffer));
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-03-16 20:29:07 +00:00
|
|
|
animDataTable = (AnimData *)malloc(NUM_MAX_ANIMDATA * sizeof(AnimData));
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-12-08 09:51:24 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_OS) {
|
2007-12-07 20:45:51 +00:00
|
|
|
readVolCnf();
|
|
|
|
}
|
|
|
|
|
2006-02-22 22:40:53 +00:00
|
|
|
loadTextData("texte.dat", textDataPtr);
|
2006-04-13 15:42:52 +00:00
|
|
|
|
2007-05-13 16:07:33 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_OS && !(g_cine->getFeatures() & GF_DEMO)) {
|
|
|
|
loadPoldatDat("poldat.dat");
|
|
|
|
loadErrmessDat("errmess.dat");
|
2006-04-13 15:42:52 +00:00
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
for (i = 0; i < NUM_MAX_OBJECT; i++) {
|
|
|
|
objectTable[i].part = 0;
|
|
|
|
objectTable[i].name[0] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_MAX_OBJECTDATA; i++) {
|
|
|
|
globalVars[i] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_MAX_SCRIPT; i++) {
|
|
|
|
scriptTable[i].ptr = NULL;
|
2006-02-25 18:16:40 +00:00
|
|
|
scriptTable[i].size = 0;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_MAX_MESSAGE; i++) {
|
|
|
|
messageTable[i].ptr = NULL;
|
|
|
|
messageTable[i].len = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_MAX_REL; i++) {
|
2006-02-24 22:34:22 +00:00
|
|
|
relTable[i].data = NULL;
|
|
|
|
relTable[i].size = 0;
|
|
|
|
relTable[i].obj1Param1 = 0;
|
|
|
|
relTable[i].obj1Param2 = 0;
|
|
|
|
relTable[i].obj2Param = 0;
|
2007-12-07 20:45:51 +00:00
|
|
|
relTable[i].runCount = 0;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2006-03-16 20:29:07 +00:00
|
|
|
for (i = 0; i < NUM_MAX_ANIMDATA; i++) {
|
2007-12-13 12:33:31 +00:00
|
|
|
animDataTable[i].ptr1 = animDataTable[i].ptr2 = NULL;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2007-12-13 12:33:31 +00:00
|
|
|
overlayHead.next = overlayHead.previous = NULL;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
var8 = 0;
|
2006-11-08 21:46:57 +00:00
|
|
|
bgIncrustList = NULL;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
objScriptList.next = NULL;
|
|
|
|
objScriptList.scriptPtr = NULL;
|
2007-12-13 12:33:31 +00:00
|
|
|
|
|
|
|
globalScriptsHead.next = NULL;
|
2006-02-22 22:40:53 +00:00
|
|
|
globalScriptsHead.scriptPtr = NULL;
|
|
|
|
|
2007-12-13 12:33:31 +00:00
|
|
|
var2 = var3 = var4 = var5 = 0;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
freePrcLinkedList();
|
|
|
|
|
2006-11-25 09:28:00 +00:00
|
|
|
_preLoad = false;
|
|
|
|
if (ConfMan.hasKey("save_slot")) {
|
|
|
|
char saveNameBuffer[256];
|
|
|
|
|
|
|
|
sprintf(saveNameBuffer, "%s.%1d", _targetName.c_str(), ConfMan.getInt("save_slot"));
|
|
|
|
|
|
|
|
bool res = makeLoad(saveNameBuffer);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-11-25 09:28:00 +00:00
|
|
|
if (res)
|
|
|
|
_preLoad = true;
|
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-11-25 09:28:00 +00:00
|
|
|
if (!_preLoad) {
|
|
|
|
loadPrc(BOOT_PRC_NAME);
|
|
|
|
strcpy(currentPrcName, BOOT_PRC_NAME);
|
|
|
|
setMouseCursor(MOUSE_CURSOR_NORMAL);
|
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
2006-02-25 00:26:14 +00:00
|
|
|
|
|
|
|
} // End of namespace Cine
|