2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2004-04-12 21:51:26 +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.
|
2004-04-12 21:51:26 +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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-04-12 21:51:26 +00:00
|
|
|
*
|
2006-02-11 12:44:16 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2004-04-12 21:51:26 +00:00
|
|
|
*
|
|
|
|
*/
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2004-03-14 23:39:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "common/file.h"
|
|
|
|
#include "common/config-manager.h"
|
2005-01-10 22:06:49 +00:00
|
|
|
#include "common/system.h"
|
2007-09-19 13:55:05 +00:00
|
|
|
#include "common/events.h"
|
2005-01-10 22:06:49 +00:00
|
|
|
|
|
|
|
#include "sound/mixer.h"
|
2004-03-14 23:39:41 +00:00
|
|
|
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/saga.h"
|
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
#include "saga/rscfile.h"
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/gfx.h"
|
|
|
|
#include "saga/render.h"
|
|
|
|
#include "saga/actor.h"
|
|
|
|
#include "saga/animation.h"
|
2004-08-10 18:31:33 +00:00
|
|
|
#include "saga/console.h"
|
2004-08-10 19:00:30 +00:00
|
|
|
#include "saga/events.h"
|
2004-08-03 00:06:18 +00:00
|
|
|
#include "saga/font.h"
|
2004-08-06 01:39:17 +00:00
|
|
|
#include "saga/interface.h"
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/isomap.h"
|
2005-05-23 02:23:34 +00:00
|
|
|
#include "saga/puzzle.h"
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/script.h"
|
2004-08-04 20:28:57 +00:00
|
|
|
#include "saga/scene.h"
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/sndres.h"
|
2004-08-03 01:07:34 +00:00
|
|
|
#include "saga/sprite.h"
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/sound.h"
|
|
|
|
#include "saga/music.h"
|
2004-08-10 19:20:33 +00:00
|
|
|
#include "saga/palanim.h"
|
2005-01-18 15:01:21 +00:00
|
|
|
#include "saga/objectmap.h"
|
2006-05-13 10:30:38 +00:00
|
|
|
#include "saga/sagaresnames.h"
|
2004-03-14 23:39:41 +00:00
|
|
|
|
|
|
|
namespace Saga {
|
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
#define MAX_TIME_DELTA 100
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2007-11-03 21:06:58 +00:00
|
|
|
SagaEngine::SagaEngine(OSystem *syst, const SAGAGameDescription *gameDesc)
|
|
|
|
: Engine(syst), _gameDescription(gameDesc) {
|
2004-03-14 23:39:41 +00:00
|
|
|
|
2005-04-18 20:03:14 +00:00
|
|
|
_leftMouseButtonPressed = _rightMouseButtonPressed = false;
|
|
|
|
|
2004-12-03 19:15:44 +00:00
|
|
|
_console = NULL;
|
2005-01-11 21:10:36 +00:00
|
|
|
_quit = false;
|
2004-12-03 19:15:44 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
_resource = NULL;
|
2005-03-18 17:11:37 +00:00
|
|
|
_sndRes = NULL;
|
|
|
|
_events = NULL;
|
|
|
|
_font = NULL;
|
|
|
|
_sprite = NULL;
|
|
|
|
_anim = NULL;
|
|
|
|
_script = NULL;
|
|
|
|
_interface = NULL;
|
|
|
|
_actor = NULL;
|
|
|
|
_palanim = NULL;
|
|
|
|
_scene = NULL;
|
|
|
|
_isoMap = NULL;
|
|
|
|
_gfx = NULL;
|
|
|
|
_console = NULL;
|
|
|
|
_render = NULL;
|
|
|
|
_music = NULL;
|
|
|
|
_sound = NULL;
|
2005-05-23 02:23:34 +00:00
|
|
|
_puzzle = NULL;
|
2005-03-18 17:11:37 +00:00
|
|
|
|
2005-07-30 14:41:25 +00:00
|
|
|
_frameCount = 0;
|
2005-09-26 07:22:32 +00:00
|
|
|
_globalFlags = 0;
|
2007-06-06 19:46:10 +00:00
|
|
|
_mouseClickCount = 0;
|
2005-09-26 07:22:32 +00:00
|
|
|
memset(_ethicsPoints, 0, sizeof(_ethicsPoints));
|
2005-07-30 14:41:25 +00:00
|
|
|
|
2004-10-01 06:45:13 +00:00
|
|
|
// The Linux version of Inherit the Earth puts all data files in an
|
|
|
|
// 'itedata' sub-directory, except for voices.rsc
|
2005-05-10 22:56:25 +00:00
|
|
|
Common::File::addDefaultDirectory(_gameDataPath + "itedata/");
|
2004-10-01 06:45:13 +00:00
|
|
|
|
|
|
|
// The Windows version of Inherit the Earth puts various data files in
|
|
|
|
// other subdirectories.
|
2005-05-10 22:56:25 +00:00
|
|
|
Common::File::addDefaultDirectory(_gameDataPath + "graphics/");
|
|
|
|
Common::File::addDefaultDirectory(_gameDataPath + "music/");
|
|
|
|
Common::File::addDefaultDirectory(_gameDataPath + "sound/");
|
2004-03-14 23:39:41 +00:00
|
|
|
|
2005-09-21 10:06:56 +00:00
|
|
|
// The Multi-OS version puts the voices file in the root directory of
|
|
|
|
// the CD. The rest of the data files are in game/itedata
|
|
|
|
Common::File::addDefaultDirectory(_gameDataPath + "game/itedata/");
|
|
|
|
|
2005-01-02 20:29:27 +00:00
|
|
|
// Mac CD Wyrmkeep
|
2005-05-10 22:56:25 +00:00
|
|
|
Common::File::addDefaultDirectory(_gameDataPath + "patch/");
|
2005-01-02 20:29:27 +00:00
|
|
|
|
2004-03-14 23:39:41 +00:00
|
|
|
// Setup mixer
|
|
|
|
if (!_mixer->isReady()) {
|
|
|
|
warning("Sound initialization failed.");
|
|
|
|
}
|
|
|
|
|
2005-07-08 16:56:03 +00:00
|
|
|
_displayClip.left = _displayClip.top = 0;
|
2007-09-19 13:55:05 +00:00
|
|
|
syst->getEventManager()->registerRandomSource(_rnd, "saga");
|
2004-03-14 23:39:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SagaEngine::~SagaEngine() {
|
2005-07-19 19:05:52 +00:00
|
|
|
if (_scene != NULL) {
|
|
|
|
if (_scene->isSceneLoaded()) {
|
|
|
|
_scene->endScene();
|
|
|
|
}
|
2005-05-18 18:28:10 +00:00
|
|
|
}
|
2005-01-11 21:10:36 +00:00
|
|
|
|
2005-05-23 02:23:34 +00:00
|
|
|
delete _puzzle;
|
2005-04-24 18:26:12 +00:00
|
|
|
delete _sndRes;
|
|
|
|
delete _events;
|
|
|
|
delete _font;
|
|
|
|
delete _sprite;
|
|
|
|
delete _anim;
|
|
|
|
delete _script;
|
|
|
|
delete _interface;
|
|
|
|
delete _actor;
|
|
|
|
delete _palanim;
|
|
|
|
delete _scene;
|
|
|
|
delete _isoMap;
|
|
|
|
delete _render;
|
|
|
|
delete _music;
|
|
|
|
delete _sound;
|
|
|
|
delete _gfx;
|
|
|
|
delete _console;
|
2005-01-11 21:10:36 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
delete _resource;
|
2004-03-14 23:39:41 +00:00
|
|
|
}
|
|
|
|
|
2006-04-15 20:36:41 +00:00
|
|
|
int SagaEngine::init() {
|
2005-09-02 20:17:52 +00:00
|
|
|
_soundVolume = ConfMan.getInt("sfx_volume") / 25;
|
|
|
|
_musicVolume = ConfMan.getInt("music_volume") / 25;
|
|
|
|
_subtitlesEnabled = ConfMan.getBool("subtitles");
|
2006-06-11 20:30:43 +00:00
|
|
|
_readingSpeed = getTalkspeed();
|
2005-10-17 03:28:21 +00:00
|
|
|
_copyProtection = ConfMan.getBool("copy_protection");
|
2007-07-13 16:37:37 +00:00
|
|
|
_gf_wyrmkeep = false;
|
|
|
|
_gf_compressed_sounds = false;
|
2005-09-02 20:17:52 +00:00
|
|
|
|
|
|
|
if (_readingSpeed > 3)
|
|
|
|
_readingSpeed = 0;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
_resource = new Resource(this);
|
|
|
|
|
2004-05-01 13:19:15 +00:00
|
|
|
// Detect game and open resource files
|
2005-07-19 19:05:52 +00:00
|
|
|
if (!initGame()) {
|
2007-04-21 21:23:26 +00:00
|
|
|
GUIErrorMessage("Error loading game resources.");
|
2005-03-18 17:11:37 +00:00
|
|
|
return FAILURE;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 13:19:15 +00:00
|
|
|
// Initialize engine modules
|
2004-04-28 23:54:40 +00:00
|
|
|
_sndRes = new SndRes(this);
|
2004-08-10 19:00:30 +00:00
|
|
|
_events = new Events(this);
|
2004-08-03 00:06:18 +00:00
|
|
|
_font = new Font(this);
|
2004-08-03 01:07:34 +00:00
|
|
|
_sprite = new Sprite(this);
|
2004-08-01 13:34:20 +00:00
|
|
|
_anim = new Anim(this);
|
2005-01-28 19:25:41 +00:00
|
|
|
_script = new Script(this);
|
2004-08-06 01:39:17 +00:00
|
|
|
_interface = new Interface(this); // requires script module
|
2005-10-08 15:35:07 +00:00
|
|
|
_scene = new Scene(this);
|
2004-08-02 15:47:42 +00:00
|
|
|
_actor = new Actor(this);
|
2004-08-10 19:20:33 +00:00
|
|
|
_palanim = new PalAnim(this);
|
2005-01-28 19:25:41 +00:00
|
|
|
_isoMap = new IsoMap(this);
|
2005-05-23 02:23:34 +00:00
|
|
|
_puzzle = new Puzzle(this);
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-05-01 13:19:15 +00:00
|
|
|
// System initialization
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-09-28 20:19:37 +00:00
|
|
|
_previousTicks = _system->getMillis();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-10-21 22:40:06 +00:00
|
|
|
// Initialize graphics
|
2006-04-15 20:36:41 +00:00
|
|
|
_gfx = new Gfx(this, _system, getDisplayWidth(), getDisplayHeight());
|
2004-10-21 22:40:06 +00:00
|
|
|
|
2004-12-03 19:15:44 +00:00
|
|
|
// Graphics driver should be initialized before console
|
|
|
|
_console = new Console(this);
|
|
|
|
|
2004-10-21 22:40:06 +00:00
|
|
|
// Graphics should be initialized before music
|
2005-12-30 14:18:21 +00:00
|
|
|
int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI);
|
|
|
|
bool native_mt32 = ((midiDriver == MD_MT32) || ConfMan.getBool("native_mt32"));
|
|
|
|
bool adlib = (midiDriver == MD_ADLIB);
|
2004-11-20 17:19:15 +00:00
|
|
|
|
2004-12-02 00:33:42 +00:00
|
|
|
MidiDriver *driver = MidiDriver::createMidi(midiDriver);
|
2005-12-30 14:18:21 +00:00
|
|
|
if (native_mt32)
|
2004-04-29 03:52:59 +00:00
|
|
|
driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE);
|
|
|
|
|
2005-09-02 20:17:52 +00:00
|
|
|
_music = new Music(this, _mixer, driver, _musicVolume);
|
2004-11-19 07:41:59 +00:00
|
|
|
_music->setNativeMT32(native_mt32);
|
2004-11-20 17:19:15 +00:00
|
|
|
_music->setAdlib(adlib);
|
2004-10-21 22:40:06 +00:00
|
|
|
|
2005-09-02 20:17:52 +00:00
|
|
|
if (!_musicVolume) {
|
2005-07-05 16:58:36 +00:00
|
|
|
debug(1, "Music disabled.");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
2004-03-14 23:39:41 +00:00
|
|
|
|
2004-10-07 23:02:19 +00:00
|
|
|
_render = new Render(this, _system);
|
2004-07-31 23:00:48 +00:00
|
|
|
if (!_render->initialized()) {
|
2005-03-18 17:11:37 +00:00
|
|
|
return FAILURE;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2004-05-01 13:19:15 +00:00
|
|
|
// Initialize system specific sound
|
2005-09-02 20:17:52 +00:00
|
|
|
_sound = new Sound(this, _mixer, _soundVolume);
|
|
|
|
if (!_soundVolume) {
|
2005-07-05 16:58:36 +00:00
|
|
|
debug(1, "Sound disabled.");
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-01-18 10:45:36 +00:00
|
|
|
_interface->converseInit();
|
2006-01-13 20:20:01 +00:00
|
|
|
_script->setVerb(_script->getVerbType(kVerbWalkTo));
|
2005-01-17 20:17:06 +00:00
|
|
|
|
2005-06-19 21:18:00 +00:00
|
|
|
_music->setVolume(-1, 1);
|
|
|
|
|
2005-10-05 01:31:46 +00:00
|
|
|
_gfx->initPalette();
|
|
|
|
|
2007-12-23 02:33:58 +00:00
|
|
|
if (_voiceFilesExist) {
|
|
|
|
if (getGameType() == GType_IHNM) {
|
|
|
|
if (!ConfMan.hasKey("voices")) {
|
|
|
|
_voicesEnabled = true;
|
|
|
|
ConfMan.setBool("voices", true);
|
|
|
|
} else {
|
|
|
|
_voicesEnabled = ConfMan.getBool("voices");
|
|
|
|
}
|
2007-06-13 20:13:06 +00:00
|
|
|
} else {
|
2007-12-23 02:33:58 +00:00
|
|
|
_voicesEnabled = true;
|
2007-06-13 20:13:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-14 15:15:52 +00:00
|
|
|
// FIXME: This is the ugly way of reducing redraw overhead. It works
|
|
|
|
// well for 320x200 but it's unclear how well it will work for
|
|
|
|
// 640x480.
|
|
|
|
|
|
|
|
if (getGameType() == GType_ITE)
|
|
|
|
_system->setFeatureState(OSystem::kFeatureAutoComputeDirtyRects, true);
|
|
|
|
|
2005-03-18 17:11:37 +00:00
|
|
|
return SUCCESS;
|
2004-11-23 00:03:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int SagaEngine::go() {
|
|
|
|
int msec = 0;
|
|
|
|
|
2004-09-28 20:19:37 +00:00
|
|
|
_previousTicks = _system->getMillis();
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
if (ConfMan.hasKey("start_scene")) {
|
2005-07-08 16:56:03 +00:00
|
|
|
_scene->changeScene(ConfMan.getInt("start_scene"), 0, kTransitionNoFade);
|
2005-08-04 10:48:54 +00:00
|
|
|
} else if (ConfMan.hasKey("boot_param")) {
|
|
|
|
if (getGameType() == GType_ITE)
|
2005-08-05 23:14:11 +00:00
|
|
|
_interface->addToInventory(_actor->objIndexToId(ITE_OBJ_MAGIC_HAT));
|
2005-08-04 10:48:54 +00:00
|
|
|
_scene->changeScene(ConfMan.getInt("boot_param"), 0, kTransitionNoFade);
|
|
|
|
} else if (ConfMan.hasKey("save_slot")) {
|
2005-06-02 22:14:57 +00:00
|
|
|
// First scene sets up palette
|
|
|
|
_scene->changeScene(getStartSceneNumber(), 0, kTransitionNoFade);
|
|
|
|
_events->handleEvents(0); // Process immediate events
|
|
|
|
|
2007-09-16 12:42:25 +00:00
|
|
|
_interface->setMode(kPanelMain);
|
2005-06-02 22:14:57 +00:00
|
|
|
char *fileName;
|
|
|
|
fileName = calcSaveFileName(ConfMan.getInt("save_slot"));
|
|
|
|
load(fileName);
|
|
|
|
} else {
|
2005-09-28 15:49:20 +00:00
|
|
|
_framesEsc = 0;
|
2005-06-02 22:14:57 +00:00
|
|
|
_scene->startScene();
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-02 12:41:40 +00:00
|
|
|
uint32 currentTicks;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-05-08 21:49:52 +00:00
|
|
|
while (!_quit) {
|
2004-12-03 19:15:44 +00:00
|
|
|
if (_console->isAttached())
|
|
|
|
_console->onFrame();
|
|
|
|
|
2004-07-31 23:00:48 +00:00
|
|
|
if (_render->getFlags() & RF_RENDERPAUSE) {
|
2004-05-01 13:19:15 +00:00
|
|
|
// Freeze time while paused
|
2004-09-28 20:19:37 +00:00
|
|
|
_previousTicks = _system->getMillis();
|
2004-04-12 21:40:49 +00:00
|
|
|
} else {
|
2004-09-28 20:19:37 +00:00
|
|
|
currentTicks = _system->getMillis();
|
2004-08-02 12:41:40 +00:00
|
|
|
// Timer has rolled over after 49 days
|
|
|
|
if (currentTicks < _previousTicks)
|
|
|
|
msec = 0;
|
|
|
|
else {
|
|
|
|
msec = currentTicks - _previousTicks;
|
|
|
|
_previousTicks = currentTicks;
|
|
|
|
}
|
2004-10-27 21:32:28 +00:00
|
|
|
if (msec > MAX_TIME_DELTA) {
|
|
|
|
msec = MAX_TIME_DELTA;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
2005-01-07 15:49:47 +00:00
|
|
|
|
2007-06-15 03:58:21 +00:00
|
|
|
// Since Puzzle and forced text are actorless, we do them here
|
|
|
|
if (_puzzle->isActive() || _actor->isForcedTextShown()) {
|
2005-05-23 02:23:34 +00:00
|
|
|
_actor->handleSpeech(msec);
|
Allowed IHNM to use the opSpeak opcode. Aborting that code path early meant
that the instruction wasn't fully read, so the next opcode would be wrong.
This is what caused it to crash.
To keep the game from hanging, I also allowed the engine to call the
_actors->direct() function for IHNM. This allows AM's intro speech to be
played in its entirety.
Since this includes the "hate" speech, I've removed that part from the
hard-coded intro. To get the right music playing, I've enabled the
sfPlayMusic() function for IHNM. This is pure guesswork, though. Once the
scene changes, the wrong music plays again. However, this is scene music,
i.e. not scripted.
It doesn't play the background sound. Looks like _fxTable[] isn't generated
for IHNM. More noticeably, until the scene changes it doesn't show any
graphics apart from the subtitles, which are drawn in the wrong colour and
(I believe) the wrong font.
svn-id: r18712
2005-08-26 12:07:31 +00:00
|
|
|
} else if (!_scene->isInIntro()) {
|
2005-05-23 02:23:34 +00:00
|
|
|
if (_interface->getMode() == kPanelMain ||
|
2005-10-08 16:25:18 +00:00
|
|
|
_interface->getMode() == kPanelConverse ||
|
|
|
|
_interface->getMode() == kPanelCutaway ||
|
|
|
|
_interface->getMode() == kPanelNull ||
|
|
|
|
_interface->getMode() == kPanelChapterSelection)
|
2005-01-06 15:29:17 +00:00
|
|
|
_actor->direct(msec);
|
2005-05-31 01:03:13 +00:00
|
|
|
}
|
2005-01-06 14:02:53 +00:00
|
|
|
|
2004-08-12 23:57:45 +00:00
|
|
|
_events->handleEvents(msec);
|
2004-12-21 06:49:07 +00:00
|
|
|
_script->executeThreads(msec);
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
2004-05-01 13:19:15 +00:00
|
|
|
// Per frame processing
|
2004-07-31 23:00:48 +00:00
|
|
|
_render->drawScene();
|
2004-09-28 20:19:37 +00:00
|
|
|
_system->delayMillis(10);
|
2004-05-01 13:19:15 +00:00
|
|
|
}
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-01-11 21:10:36 +00:00
|
|
|
return 0;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
2005-01-08 21:06:06 +00:00
|
|
|
void SagaEngine::loadStrings(StringsTable &stringsTable, const byte *stringsPointer, size_t stringsLength) {
|
2005-01-08 20:30:07 +00:00
|
|
|
uint16 stringsCount;
|
|
|
|
size_t offset;
|
2005-01-18 15:01:21 +00:00
|
|
|
int i;
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
if (stringsLength == 0) {
|
|
|
|
error("SagaEngine::loadStrings() Error loading strings list resource");
|
|
|
|
}
|
|
|
|
|
2005-01-08 21:06:06 +00:00
|
|
|
stringsTable.stringsPointer = (byte*)malloc(stringsLength);
|
|
|
|
memcpy(stringsTable.stringsPointer, stringsPointer, stringsLength);
|
2005-01-08 20:30:07 +00:00
|
|
|
|
2005-07-29 17:58:00 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
MemoryReadStreamEndian scriptS(stringsTable.stringsPointer, stringsLength, isBigEndian()); //TODO: get endianess from context
|
2005-01-08 20:30:07 +00:00
|
|
|
|
|
|
|
offset = scriptS.readUint16();
|
2005-01-18 15:01:21 +00:00
|
|
|
stringsCount = offset / 2;
|
|
|
|
stringsTable.strings = (const char **)malloc(stringsCount * sizeof(*stringsTable.strings));
|
2005-07-29 17:58:00 +00:00
|
|
|
i = 0;
|
2005-01-08 20:30:07 +00:00
|
|
|
scriptS.seek(0);
|
2005-01-18 15:01:21 +00:00
|
|
|
while (i < stringsCount) {
|
2005-01-08 20:30:07 +00:00
|
|
|
offset = scriptS.readUint16();
|
2005-01-18 15:01:21 +00:00
|
|
|
if (offset == stringsLength) {
|
|
|
|
stringsCount = i;
|
|
|
|
stringsTable.strings = (const char **)realloc(stringsTable.strings, stringsCount * sizeof(*stringsTable.strings));
|
|
|
|
break;
|
|
|
|
}
|
2005-01-08 20:30:07 +00:00
|
|
|
if (offset > stringsLength) {
|
2007-09-30 01:29:12 +00:00
|
|
|
// This case should never occur, but apparently it does in the Italian fan
|
|
|
|
// translation of IHNM
|
|
|
|
warning("SagaEngine::loadStrings wrong strings table");
|
|
|
|
stringsCount = i;
|
|
|
|
stringsTable.strings = (const char **)realloc(stringsTable.strings, stringsCount * sizeof(*stringsTable.strings));
|
|
|
|
break;
|
2005-01-08 20:30:07 +00:00
|
|
|
}
|
2005-01-08 21:06:06 +00:00
|
|
|
stringsTable.strings[i] = (const char *)stringsTable.stringsPointer + offset;
|
2005-04-22 14:11:04 +00:00
|
|
|
debug(9, "string[%i]=%s", i, stringsTable.strings[i]);
|
2005-01-18 15:01:21 +00:00
|
|
|
i++;
|
2005-01-08 20:30:07 +00:00
|
|
|
}
|
2005-01-18 15:01:21 +00:00
|
|
|
stringsTable.stringsCount = stringsCount;
|
2005-01-08 20:30:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *SagaEngine::getObjectName(uint16 objectId) {
|
2005-01-18 21:13:44 +00:00
|
|
|
ActorData *actor;
|
|
|
|
ObjectData *obj;
|
2005-01-18 15:01:21 +00:00
|
|
|
const HitZone *hitZone;
|
2007-06-15 16:26:14 +00:00
|
|
|
|
|
|
|
// Disable the object names in IHNM when the chapter is 8
|
|
|
|
if (getGameType() == GType_IHNM && _scene->currentChapterNumber() == 8)
|
|
|
|
return "";
|
|
|
|
|
2005-01-18 15:01:21 +00:00
|
|
|
switch (objectTypeId(objectId)) {
|
2005-03-07 11:49:59 +00:00
|
|
|
case kGameObjectObject:
|
|
|
|
obj = _actor->getObj(objectId);
|
2005-10-08 22:09:21 +00:00
|
|
|
if (getGameType() == GType_ITE)
|
|
|
|
return _script->_mainStrings.getString(obj->_nameIndex);
|
|
|
|
return _actor->_objectsStrings.getString(obj->_nameIndex);
|
2005-07-29 17:58:00 +00:00
|
|
|
case kGameObjectActor:
|
|
|
|
actor = _actor->getActor(objectId);
|
2005-08-10 14:53:17 +00:00
|
|
|
return _actor->_actorsStrings.getString(actor->_nameIndex);
|
2005-03-07 11:49:59 +00:00
|
|
|
case kGameObjectHitZone:
|
2005-05-23 02:23:34 +00:00
|
|
|
hitZone = _scene->_objectMap->getHitZone(objectIdToIndex(objectId));
|
2007-06-06 16:37:10 +00:00
|
|
|
|
|
|
|
if (hitZone == NULL)
|
|
|
|
return "";
|
|
|
|
|
2005-05-23 02:23:34 +00:00
|
|
|
return _scene->_sceneStrings.getString(hitZone->getNameIndex());
|
2005-01-08 20:30:07 +00:00
|
|
|
}
|
2005-01-18 21:13:44 +00:00
|
|
|
warning("SagaEngine::getObjectName name not found for 0x%X", objectId);
|
2005-01-08 20:30:07 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-01-13 22:42:49 +00:00
|
|
|
const char *SagaEngine::getTextString(int textStringId) {
|
2005-01-14 11:22:45 +00:00
|
|
|
const char *string;
|
2007-09-30 01:29:12 +00:00
|
|
|
int lang = 0;
|
|
|
|
|
2007-09-30 13:37:05 +00:00
|
|
|
switch (getLanguage()) {
|
|
|
|
case Common::DE_DEU:
|
|
|
|
lang = 1;
|
|
|
|
break;
|
2007-12-21 02:08:30 +00:00
|
|
|
case Common::IT_ITA:
|
2007-09-30 13:37:05 +00:00
|
|
|
lang = 2;
|
|
|
|
break;
|
2007-12-21 02:08:30 +00:00
|
|
|
case Common::ES_ESP:
|
2007-09-30 13:37:05 +00:00
|
|
|
lang = 3;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
lang = 0;
|
|
|
|
break;
|
|
|
|
}
|
2005-01-14 01:17:34 +00:00
|
|
|
|
2005-08-08 08:15:16 +00:00
|
|
|
string = ITEinterfaceTextStrings[lang][textStringId];
|
2005-01-14 11:22:45 +00:00
|
|
|
if (!string)
|
2005-08-08 08:15:16 +00:00
|
|
|
string = ITEinterfaceTextStrings[0][textStringId];
|
2005-01-14 11:22:45 +00:00
|
|
|
|
|
|
|
return string;
|
2005-01-13 22:42:49 +00:00
|
|
|
}
|
|
|
|
|
2005-01-15 20:12:49 +00:00
|
|
|
void SagaEngine::getExcuseInfo(int verb, const char *&textString, int &soundResourceId) {
|
2005-08-11 15:28:08 +00:00
|
|
|
textString = NULL;
|
2006-01-13 20:20:01 +00:00
|
|
|
|
|
|
|
if (verb == _script->getVerbType(kVerbPickUp)) {
|
2005-08-16 19:04:51 +00:00
|
|
|
textString = getTextString(kTextICantPickup);
|
2005-03-07 11:49:59 +00:00
|
|
|
soundResourceId = RID_BOAR_VOICE_007;
|
2007-09-19 08:40:12 +00:00
|
|
|
} else
|
2006-01-13 20:20:01 +00:00
|
|
|
if (verb == _script->getVerbType(kVerbLookAt)) {
|
2005-08-16 19:04:51 +00:00
|
|
|
textString = getTextString(kTextNothingSpecial);
|
2005-03-07 11:49:59 +00:00
|
|
|
soundResourceId = RID_BOAR_VOICE_006;
|
2006-01-13 20:20:01 +00:00
|
|
|
}
|
|
|
|
if (verb == _script->getVerbType(kVerbOpen)) {
|
2005-08-16 19:04:51 +00:00
|
|
|
textString = getTextString(kTextNoPlaceToOpen);
|
2005-03-07 11:49:59 +00:00
|
|
|
soundResourceId = RID_BOAR_VOICE_000;
|
2006-01-13 20:20:01 +00:00
|
|
|
}
|
|
|
|
if (verb == _script->getVerbType(kVerbClose)) {
|
2005-08-16 19:04:51 +00:00
|
|
|
textString = getTextString(kTextNoOpening);
|
2005-03-07 11:49:59 +00:00
|
|
|
soundResourceId = RID_BOAR_VOICE_002;
|
2006-01-13 20:20:01 +00:00
|
|
|
}
|
|
|
|
if (verb == _script->getVerbType(kVerbUse)) {
|
2005-08-16 19:04:51 +00:00
|
|
|
textString = getTextString(kTextDontKnow);
|
2005-03-07 11:49:59 +00:00
|
|
|
soundResourceId = RID_BOAR_VOICE_005;
|
2005-01-15 20:12:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-26 12:08:05 +00:00
|
|
|
ColorId SagaEngine::KnownColor2ColorId(KnownColor knownColor) {
|
|
|
|
ColorId colorId = kITEColorTransBlack;
|
|
|
|
|
|
|
|
if (getGameType() == GType_ITE) {
|
2005-11-26 16:54:55 +00:00
|
|
|
switch (knownColor) {
|
2005-11-26 12:08:05 +00:00
|
|
|
case(kKnownColorTransparent):
|
|
|
|
colorId = kITEColorTransBlack;
|
|
|
|
break;
|
|
|
|
case (kKnownColorBrightWhite):
|
|
|
|
colorId = kITEColorBrightWhite;
|
|
|
|
break;
|
2007-08-18 01:59:18 +00:00
|
|
|
case (kKnownColorWhite):
|
|
|
|
colorId = kITEColorWhite;
|
|
|
|
break;
|
2005-11-26 12:08:05 +00:00
|
|
|
case (kKnownColorBlack):
|
|
|
|
colorId = kITEColorBlack;
|
|
|
|
break;
|
|
|
|
case (kKnownColorSubtitleTextColor):
|
|
|
|
colorId = (ColorId)255;
|
|
|
|
break;
|
|
|
|
case (kKnownColorVerbText):
|
|
|
|
colorId = kITEColorBlue;
|
|
|
|
break;
|
|
|
|
case (kKnownColorVerbTextShadow):
|
|
|
|
colorId = kITEColorBlack;
|
|
|
|
break;
|
|
|
|
case (kKnownColorVerbTextActive):
|
|
|
|
colorId = (ColorId)96;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
error("SagaEngine::KnownColor2ColorId unknown color %i", knownColor);
|
|
|
|
}
|
|
|
|
} else if (getGameType() == GType_IHNM) {
|
2007-12-11 22:40:39 +00:00
|
|
|
// The default colors in the Spanish version of IHNM are shifted by one
|
|
|
|
// Fixes bug #1848016 - "IHNM: Wrong Subtitles Color (Spanish)"
|
|
|
|
int offset = (getGameId() == GID_IHNM_CD_ES) ? 1 : 0;
|
|
|
|
|
2007-09-10 13:17:20 +00:00
|
|
|
switch (knownColor) {
|
2005-11-26 12:08:05 +00:00
|
|
|
case(kKnownColorTransparent):
|
2007-12-11 22:40:39 +00:00
|
|
|
colorId = (ColorId)(249 - offset);
|
2005-11-26 12:08:05 +00:00
|
|
|
break;
|
2007-07-30 11:55:11 +00:00
|
|
|
case (kKnownColorBrightWhite):
|
2007-12-11 22:40:39 +00:00
|
|
|
colorId = (ColorId)(251 - offset);
|
2007-07-30 11:55:11 +00:00
|
|
|
break;
|
2007-08-18 01:59:18 +00:00
|
|
|
case (kKnownColorWhite):
|
2007-12-11 22:40:39 +00:00
|
|
|
colorId = (ColorId)(251 - offset);
|
2007-09-19 08:40:12 +00:00
|
|
|
break;
|
2005-11-26 12:08:05 +00:00
|
|
|
case (kKnownColorBlack):
|
2007-12-11 22:40:39 +00:00
|
|
|
colorId = (ColorId)(249 - offset);
|
2005-11-26 12:08:05 +00:00
|
|
|
break;
|
|
|
|
case (kKnownColorVerbText):
|
2007-12-11 22:40:39 +00:00
|
|
|
colorId = (ColorId)(253 - offset);
|
2005-11-26 12:08:05 +00:00
|
|
|
break;
|
|
|
|
case (kKnownColorVerbTextShadow):
|
2007-12-11 22:40:39 +00:00
|
|
|
colorId = (ColorId)(15 - offset);
|
2005-11-26 12:08:05 +00:00
|
|
|
break;
|
|
|
|
case (kKnownColorVerbTextActive):
|
2007-12-11 22:40:39 +00:00
|
|
|
colorId = (ColorId)(252 - offset);
|
2005-11-26 12:08:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
error("SagaEngine::KnownColor2ColorId unknown color %i", knownColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return colorId;
|
|
|
|
}
|
|
|
|
|
2006-06-11 20:30:43 +00:00
|
|
|
void SagaEngine::setTalkspeed(int talkspeed) {
|
|
|
|
ConfMan.setInt("talkspeed", (talkspeed * 255 + 3 / 2) / 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
int SagaEngine::getTalkspeed() {
|
|
|
|
return (ConfMan.getInt("talkspeed") * 3 + 255 / 2) / 255;
|
|
|
|
}
|
2005-11-26 12:08:05 +00:00
|
|
|
|
2004-03-22 21:25:29 +00:00
|
|
|
} // End of namespace Saga
|