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$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-10-06 12:48:52 +00:00
|
|
|
#include "common/events.h"
|
2009-07-25 12:59:46 +00:00
|
|
|
#include "common/EventRecorder.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) {
|
2009-01-30 05:10:24 +00:00
|
|
|
Common::addDebugChannel(kCineDebugScript, "Script", "Script debug level");
|
|
|
|
Common::addDebugChannel(kCineDebugPart, "Part", "Part debug level");
|
|
|
|
Common::addDebugChannel(kCineDebugSound, "Sound", "Sound debug level");
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
// Setup mixer
|
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"));
|
2008-08-08 14:46:19 +00:00
|
|
|
// Use music volume for plain sound types (At least the Adlib player uses a plain sound type
|
|
|
|
// so previously the music and sfx volume controls didn't affect it at all).
|
|
|
|
// FIXME: Make Adlib player differentiate between playing sound effects and music and remove this.
|
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, 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
|
|
|
|
2009-07-25 12:59:46 +00:00
|
|
|
g_eventRec.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) {
|
|
|
|
freeErrmessDat();
|
|
|
|
}
|
2009-01-30 05:10:24 +00:00
|
|
|
Common::clearAllDebugChannels();
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2009-03-01 04:42:46 +00:00
|
|
|
Common::Error CineEngine::run() {
|
2006-02-22 22:40:53 +00:00
|
|
|
// Initialize backend
|
2008-11-14 22:08:10 +00:00
|
|
|
initGraphics(320, 200, false);
|
2006-02-22 22:40:53 +00:00
|
|
|
|
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();
|
|
|
|
|
2006-05-25 22:51:42 +00:00
|
|
|
CursorMan.showMouse(true);
|
2006-02-22 22:40:53 +00:00
|
|
|
mainLoop(1);
|
2008-05-24 22:11:41 +00:00
|
|
|
|
|
|
|
delete renderer;
|
2008-08-06 20:54:38 +00:00
|
|
|
delete[] collisionPage;
|
2007-05-19 12:08:41 +00:00
|
|
|
delete g_sound;
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-11-06 17:05:54 +00:00
|
|
|
return Common::kNoError;
|
2006-02-22 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
2008-08-07 21:46:56 +00:00
|
|
|
int CineEngine::getTimerDelay() const {
|
|
|
|
return (10923000 * _timerDelayMultiplier) / 1193180;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*! \brief Modify game speed
|
|
|
|
* \param speedChange Negative values slow game down, positive values speed it up, zero does nothing
|
|
|
|
* \return Timer delay multiplier's value after the game speed change
|
|
|
|
*/
|
|
|
|
int CineEngine::modifyGameSpeed(int speedChange) {
|
|
|
|
// If we want more speed we decrement the timer delay multiplier and vice versa.
|
|
|
|
_timerDelayMultiplier = CLIP(_timerDelayMultiplier - speedChange, 1, 50);
|
|
|
|
return _timerDelayMultiplier;
|
|
|
|
}
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2006-11-25 09:28:00 +00:00
|
|
|
void CineEngine::initialize() {
|
2009-08-03 17:52:07 +00:00
|
|
|
// Initialize all savegames' descriptions to empty strings
|
|
|
|
memset(currentSaveName, 0, sizeof(currentSaveName));
|
|
|
|
|
2008-08-09 20:50:10 +00:00
|
|
|
// Resize object table to its correct size and reset all its elements
|
|
|
|
objectTable.resize(NUM_MAX_OBJECT);
|
|
|
|
resetObjectTable();
|
|
|
|
|
2008-08-09 20:55:01 +00:00
|
|
|
// Resize animation data table to its correct size and reset all its elements
|
|
|
|
animDataTable.resize(NUM_MAX_ANIMDATA);
|
|
|
|
freeAnimDataTable();
|
|
|
|
|
2008-08-09 22:38:03 +00:00
|
|
|
// Resize zone data table to its correct size and reset all its elements
|
|
|
|
zoneData.resize(NUM_MAX_ZONE);
|
|
|
|
Common::set_to(zoneData.begin(), zoneData.end(), 0);
|
|
|
|
|
|
|
|
// Resize zone query table to its correct size and reset all its elements
|
2009-01-01 15:06:43 +00:00
|
|
|
zoneQuery.resize(NUM_MAX_ZONE);
|
2008-08-09 22:38:03 +00:00
|
|
|
Common::set_to(zoneQuery.begin(), zoneQuery.end(), 0);
|
|
|
|
|
2008-08-07 21:46:56 +00:00
|
|
|
_timerDelayMultiplier = 12; // Set default speed
|
2006-04-08 13:20:40 +00:00
|
|
|
setupOpcodes();
|
|
|
|
|
2006-11-11 15:37:03 +00:00
|
|
|
initLanguage(g_cine->getLanguage());
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-05-24 22:11:41 +00:00
|
|
|
if (g_cine->getGameType() == Cine::GType_OS) {
|
|
|
|
renderer = new OSRenderer;
|
|
|
|
} else {
|
|
|
|
renderer = new FWRenderer;
|
|
|
|
}
|
|
|
|
|
2009-08-25 23:11:17 +00:00
|
|
|
renderer->initialize();
|
|
|
|
|
2008-08-06 20:54:38 +00:00
|
|
|
collisionPage = new byte[320 * 200];
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2008-08-11 20:41:13 +00:00
|
|
|
// Clear part buffer as there's nothing loaded into it yet.
|
|
|
|
// Its size will change when loading data into it with the loadPart function.
|
|
|
|
partBuffer.clear();
|
2006-02-22 22:40:53 +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();
|
|
|
|
}
|
|
|
|
|
2008-08-11 21:26:41 +00:00
|
|
|
loadTextData("texte.dat");
|
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
|
|
|
|
2008-04-07 20:24:40 +00:00
|
|
|
// in case ScummVM engines can be restarted in the future
|
|
|
|
scriptTable.clear();
|
|
|
|
relTable.clear();
|
|
|
|
objectScripts.clear();
|
|
|
|
globalScripts.clear();
|
|
|
|
bgIncrustList.clear();
|
|
|
|
freeAnimDataTable();
|
2008-04-21 20:51:17 +00:00
|
|
|
overlayList.clear();
|
|
|
|
messageTable.clear();
|
2008-08-09 20:50:10 +00:00
|
|
|
resetObjectTable();
|
2006-02-22 22:40:53 +00:00
|
|
|
|
|
|
|
var8 = 0;
|
|
|
|
|
2007-12-13 12:33:31 +00:00
|
|
|
var2 = var3 = var4 = var5 = 0;
|
2006-02-22 22:40:53 +00:00
|
|
|
|
2009-05-11 19:31:55 +00:00
|
|
|
musicIsPlaying = 0;
|
|
|
|
currentDatName[0] = 0;
|
|
|
|
|
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
|