2006-02-22 22:40:53 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2006 The ScummVM project
|
|
|
|
*
|
|
|
|
* cinE Engine is (C) 2004-2005 by CinE Team
|
|
|
|
*
|
|
|
|
* 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$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/stdafx.h"
|
|
|
|
#include "common/file.h"
|
2006-06-24 08:07:48 +00:00
|
|
|
#include "common/fs.h"
|
2006-02-22 22:40:53 +00:00
|
|
|
#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
|
|
|
|
|
|
|
#include "base/plugins.h"
|
|
|
|
|
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-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-02-25 01:01:27 +00:00
|
|
|
#include "cine/sfx_player.h"
|
2006-02-22 22:40:53 +00:00
|
|
|
#include "cine/sound_driver.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 {
|
|
|
|
|
2006-03-09 22:37:19 +00:00
|
|
|
SoundDriver *g_soundDriver;
|
|
|
|
SfxPlayer *g_sfxPlayer;
|
2006-04-10 05:37:31 +00:00
|
|
|
Common::SaveFileManager *g_saveFileMan;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
static void initialize();
|
|
|
|
|
2006-04-08 11:21:04 +00:00
|
|
|
struct GameSettings {
|
2006-04-09 19:44:40 +00:00
|
|
|
const char *gameid;
|
2006-02-22 22:40:53 +00:00
|
|
|
const char *description;
|
|
|
|
byte id;
|
|
|
|
uint32 features;
|
|
|
|
const char *detectname;
|
|
|
|
};
|
|
|
|
|
2006-04-08 11:21:04 +00:00
|
|
|
static const GameSettings cine_settings[] = {
|
2006-02-22 22:40:53 +00:00
|
|
|
{"fw", "Future Wars", Cine::GID_FW, MDT_ADLIB, "AUTO00.PRC"},
|
|
|
|
{"os", "Operation Stealth", Cine::GID_OS, MDT_ADLIB, "PROCS00"},
|
|
|
|
{NULL, NULL, 0, 0, NULL}
|
|
|
|
};
|
|
|
|
|
2006-04-09 19:44:40 +00:00
|
|
|
} // End of namespace Cine
|
|
|
|
|
|
|
|
|
2006-02-22 22:40:53 +00:00
|
|
|
GameList Engine_CINE_gameIDList() {
|
|
|
|
GameList games;
|
2006-04-09 19:44:40 +00:00
|
|
|
const Cine::GameSettings *g = Cine::cine_settings;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-04-09 19:44:40 +00:00
|
|
|
while (g->gameid) {
|
|
|
|
games.push_back(*g);
|
2006-02-22 22:40:53 +00:00
|
|
|
g++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return games;
|
|
|
|
}
|
|
|
|
|
2006-03-09 02:52:51 +00:00
|
|
|
GameDescriptor Engine_CINE_findGameID(const char *gameid) {
|
2006-04-09 19:44:40 +00:00
|
|
|
const Cine::GameSettings *g = Cine::cine_settings;
|
|
|
|
while (g->gameid) {
|
|
|
|
if (0 == scumm_stricmp(gameid, g->gameid))
|
2006-02-22 22:40:53 +00:00
|
|
|
break;
|
|
|
|
g++;
|
|
|
|
}
|
2006-04-09 19:44:40 +00:00
|
|
|
return *g;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DetectedGameList Engine_CINE_detectGames(const FSList &fslist) {
|
|
|
|
DetectedGameList detectedGames;
|
2006-04-09 19:44:40 +00:00
|
|
|
const Cine::GameSettings *g;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-04-09 19:44:40 +00:00
|
|
|
for (g = Cine::cine_settings; g->gameid; ++g) {
|
2006-02-22 22:40:53 +00:00
|
|
|
// Iterate over all files in the given directory
|
|
|
|
for (FSList::const_iterator file = fslist.begin();
|
|
|
|
file != fslist.end(); ++file) {
|
2006-07-22 14:50:50 +00:00
|
|
|
const char *fileName = file->name().c_str();
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-07-22 14:50:50 +00:00
|
|
|
if (0 == scumm_stricmp(g->detectname, fileName)) {
|
2006-02-22 22:40:53 +00:00
|
|
|
// Match found, add to list of candidates, then abort inner loop.
|
2006-04-09 19:44:40 +00:00
|
|
|
detectedGames.push_back(*g);
|
2006-02-22 22:40:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return detectedGames;
|
|
|
|
}
|
|
|
|
|
2006-04-29 00:27:20 +00:00
|
|
|
PluginError Engine_CINE_create(OSystem *syst, Engine **engine) {
|
2006-08-04 09:46:40 +00:00
|
|
|
assert(syst);
|
2006-04-29 00:27:20 +00:00
|
|
|
assert(engine);
|
2006-08-04 09:46:40 +00:00
|
|
|
|
|
|
|
FSList fslist;
|
|
|
|
FilesystemNode dir(ConfMan.get("path"));
|
|
|
|
if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
|
|
|
|
warning("CineEngine: invalid game path '%s'", dir.path().c_str());
|
|
|
|
return kInvalidPathError;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Invoke the detector
|
|
|
|
Common::String gameid = ConfMan.get("gameid");
|
|
|
|
DetectedGameList detectedGames = Engine_CINE_detectGames(fslist);
|
|
|
|
|
|
|
|
for (uint i = 0; i < detectedGames.size(); i++) {
|
|
|
|
if (detectedGames[i].gameid == gameid) {
|
|
|
|
*engine = new Cine::CineEngine(syst);
|
|
|
|
return kNoError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
warning("CineEngine: Unable to locate game data at path '%s'", dir.path().c_str());
|
|
|
|
return kNoGameDataFoundError;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2006-07-31 13:41:21 +00:00
|
|
|
REGISTER_PLUGIN(CINE, "CINE Engine", "TODO (C) TODO");
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
namespace Cine {
|
|
|
|
|
2006-04-15 20:36:41 +00:00
|
|
|
CineEngine::CineEngine(OSystem *syst) : Engine(syst) {
|
2006-04-12 01:48:15 +00:00
|
|
|
Common::addSpecialDebugLevel(kCineDebugScript, "Script", "Script 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-04-09 19:44:40 +00:00
|
|
|
const Cine::GameSettings *g;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-04-15 20:36:41 +00:00
|
|
|
const char *gameid = ConfMan.get("gameid").c_str();
|
2006-04-09 19:44:40 +00:00
|
|
|
for (g = Cine::cine_settings; g->gameid; ++g)
|
2006-04-15 20:36:41 +00:00
|
|
|
if (!scumm_stricmp(g->gameid, gameid)) {
|
2006-02-22 22:40:53 +00:00
|
|
|
_gameId = g->id;
|
2006-04-15 20:36:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
gameType = _gameId;
|
|
|
|
}
|
|
|
|
|
|
|
|
CineEngine::~CineEngine() {
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
2006-03-09 22:37:19 +00:00
|
|
|
if (gameType == GID_FW) {
|
|
|
|
g_soundDriver = new AdlibSoundDriverINS(_mixer);
|
|
|
|
} else {
|
|
|
|
g_soundDriver = new AdlibSoundDriverADL(_mixer);
|
|
|
|
}
|
|
|
|
g_sfxPlayer = new SfxPlayer(g_soundDriver);
|
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);
|
|
|
|
|
|
|
|
if (gameType == Cine::GID_FW)
|
|
|
|
snd_clearBasesonEntries();
|
|
|
|
|
2006-03-09 22:37:19 +00:00
|
|
|
delete g_sfxPlayer;
|
2006-03-15 22:34:46 +00:00
|
|
|
delete g_soundDriver;
|
2006-02-22 22:40:53 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int gameType;
|
|
|
|
|
|
|
|
static void 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-04-08 07:50:47 +00:00
|
|
|
initLanguage(Common::parseLanguage(ConfMan.get("language")));
|
2006-02-22 22:40:53 +00:00
|
|
|
init_video();
|
|
|
|
|
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));
|
|
|
|
|
2006-02-22 22:40:53 +00:00
|
|
|
loadTextData("texte.dat", textDataPtr);
|
2006-04-13 15:42:52 +00:00
|
|
|
|
|
|
|
switch (gameType) {
|
|
|
|
case Cine::GID_FW:
|
2006-03-09 22:37:19 +00:00
|
|
|
snd_loadBasesonEntries("BASESON.SND");
|
2006-04-13 15:42:52 +00:00
|
|
|
break;
|
|
|
|
case Cine::GID_OS:
|
|
|
|
// TODO
|
|
|
|
// load POLDAT.DAT
|
|
|
|
// load ERRMESS.DAT (default responses to actions)
|
|
|
|
break;
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2006-03-02 20:08:41 +00:00
|
|
|
// bypass protection
|
2006-03-23 03:15:39 +00:00
|
|
|
if (gameType == GID_OS && !ConfMan.getBool("copy_protection")) {
|
2006-03-02 20:08:41 +00:00
|
|
|
globalVars[255] = 1;
|
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
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;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2006-03-16 20:29:07 +00:00
|
|
|
for (i = 0; i < NUM_MAX_ANIMDATA; i++) {
|
2006-02-22 22:40:53 +00:00
|
|
|
animDataTable[i].ptr1 = NULL;
|
|
|
|
animDataTable[i].ptr2 = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
overlayHead.next = NULL;
|
|
|
|
overlayHead.previous = NULL;
|
|
|
|
|
|
|
|
var8 = 0;
|
|
|
|
var9 = NULL;
|
|
|
|
|
|
|
|
objScriptList.next = NULL;
|
|
|
|
globalScriptsHead.next = NULL;
|
|
|
|
|
|
|
|
objScriptList.scriptPtr = NULL;
|
|
|
|
globalScriptsHead.scriptPtr = NULL;
|
|
|
|
|
|
|
|
var2 = 0;
|
|
|
|
var3 = 0;
|
|
|
|
var4 = 0;
|
|
|
|
var5 = 0;
|
|
|
|
|
|
|
|
freePrcLinkedList();
|
|
|
|
|
|
|
|
loadPrc(BOOT_PRC_NAME);
|
|
|
|
strcpy(currentPrcName, BOOT_PRC_NAME);
|
|
|
|
|
2006-03-16 20:29:07 +00:00
|
|
|
setMouseCursor(MOUSE_CURSOR_NORMAL);
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
2006-02-25 00:26:14 +00:00
|
|
|
|
|
|
|
} // End of namespace Cine
|