diff options
Diffstat (limited to 'engines/kyra/kyra.cpp')
-rw-r--r-- | engines/kyra/kyra.cpp | 107 |
1 files changed, 56 insertions, 51 deletions
diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp index 5ee2c1ed0c..05d8b79a4e 100644 --- a/engines/kyra/kyra.cpp +++ b/engines/kyra/kyra.cpp @@ -39,15 +39,14 @@ namespace Kyra { KyraEngine::KyraEngine(OSystem *system, const GameFlags &flags) - : Engine(system) { + : Engine(system), _flags(flags) { _res = 0; _sound = 0; _text = 0; _staticres = 0; _timer = 0; - _scriptInterpreter = 0; + _emc = 0; - _flags = flags; _gameSpeed = 60; _tickLength = (uint8)(1000.0 / _gameSpeed); @@ -87,50 +86,53 @@ int KyraEngine::init() { _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume")); - // We prefer AdLib over native MIDI, since our AdLib playback code is much - // more mature than our MIDI player. For example we are missing MT-32 support - // and it seems our MIDI playback code has threading issues (see bug #1506583 - // "KYRA1: Crash on exceeded polyphony" for more information). - int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB/* | MDT_PREFER_MIDI*/); - - if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98) { - // TODO: currently we don't support the PC98 sound data, - // but since it has the FM-Towns data files, we just use the - // FM-Towns driver - if (_flags.gameID == GI_KYRA1) - _sound = new SoundTowns(this, _mixer); - else - _sound = new SoundTowns_v2(this, _mixer); - } else if (midiDriver == MD_ADLIB) { - _sound = new SoundAdlibPC(this, _mixer); - assert(_sound); - } else { - bool native_mt32 = ((midiDriver == MD_MT32) || ConfMan.getBool("native_mt32")); - - MidiDriver *driver = MidiDriver::createMidi(midiDriver); - assert(driver); - if (native_mt32) - driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE); - - SoundMidiPC *soundMidiPc = new SoundMidiPC(this, _mixer, driver); - _sound = soundMidiPc; - assert(_sound); - soundMidiPc->hasNativeMT32(native_mt32); - - // Unlike some SCUMM games, it's not that the MIDI sounds are - // missing. It's just that at least at the time of writing they - // are decidedly inferior to the Adlib ones. - if (ConfMan.getBool("multi_midi")) { - SoundAdlibPC *adlib = new SoundAdlibPC(this, _mixer); - assert(adlib); - - _sound = new MixedSoundDriver(this, _mixer, soundMidiPc, adlib); + if (!_flags.useDigSound) { + // We prefer AdLib over native MIDI, since our AdLib playback code is much + // more mature than our MIDI player. For example we are missing MT-32 support + // and it seems our MIDI playback code has threading issues (see bug #1506583 + // "KYRA1: Crash on exceeded polyphony" for more information). + int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB/* | MDT_PREFER_MIDI*/); + + if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98) { + // TODO: currently we don't support the PC98 sound data, + // but since it has the FM-Towns data files, we just use the + // FM-Towns driver + if (_flags.gameID == GI_KYRA1) + _sound = new SoundTowns(this, _mixer); + else + _sound = new SoundTowns_v2(this, _mixer); + } else if (midiDriver == MD_ADLIB) { + _sound = new SoundAdlibPC(this, _mixer); + assert(_sound); + } else { + bool native_mt32 = ((midiDriver == MD_MT32) || ConfMan.getBool("native_mt32")); + + MidiDriver *driver = MidiDriver::createMidi(midiDriver); + assert(driver); + if (native_mt32) + driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE); + + SoundMidiPC *soundMidiPc = new SoundMidiPC(this, _mixer, driver); + _sound = soundMidiPc; assert(_sound); + soundMidiPc->hasNativeMT32(native_mt32); + + // Unlike some SCUMM games, it's not that the MIDI sounds are + // missing. It's just that at least at the time of writing they + // are decidedly inferior to the Adlib ones. + if (ConfMan.getBool("multi_midi")) { + SoundAdlibPC *adlib = new SoundAdlibPC(this, _mixer); + assert(adlib); + + _sound = new MixedSoundDriver(this, _mixer, soundMidiPc, adlib); + assert(_sound); + } } } if (_sound) _sound->updateVolumeSettings(); + _res = new Resource(this); assert(_res); _res->reset(); @@ -143,8 +145,8 @@ int KyraEngine::init() { _timer = new TimerManager(this, _system); assert(_timer); setupTimers(); - _scriptInterpreter = new ScriptHelper(this); - assert(_scriptInterpreter); + _emc = new EMCInterpreter(this); + assert(_emc); setupOpcodeTable(); readSettings(); @@ -198,7 +200,7 @@ KyraEngine::~KyraEngine() { delete _sound; delete _text; delete _timer; - delete _scriptInterpreter; + delete _emc; } void KyraEngine::quitGame() { @@ -271,8 +273,10 @@ void KyraEngine::readSettings() { } _configSounds = ConfMan.getBool("sfx_mute") ? 0 : 1; - _sound->enableMusic(_configMusic); - _sound->enableSFX(_configSounds); + if (_sound) { + _sound->enableMusic(_configMusic); + _sound->enableSFX(_configSounds); + } bool speechMute = ConfMan.getBool("speech_mute"); bool subtitles = ConfMan.getBool("subtitles"); @@ -311,11 +315,12 @@ void KyraEngine::writeSettings() { break; } - if (!_configMusic) - _sound->beginFadeOut(); - - _sound->enableMusic(_configMusic); - _sound->enableSFX(_configSounds); + if (_sound) { + if (!_configMusic) + _sound->beginFadeOut(); + _sound->enableMusic(_configMusic); + _sound->enableSFX(_configSounds); + } ConfMan.setBool("speech_mute", speechMute); ConfMan.setBool("subtitles", subtitles); |