aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/kyra/script_tim.cpp4
-rw-r--r--engines/kyra/sound.h1
-rw-r--r--engines/kyra/sound_midi.cpp35
3 files changed, 24 insertions, 16 deletions
diff --git a/engines/kyra/script_tim.cpp b/engines/kyra/script_tim.cpp
index 9b215b2c03..b10a6adbba 100644
--- a/engines/kyra/script_tim.cpp
+++ b/engines/kyra/script_tim.cpp
@@ -559,7 +559,11 @@ int TIMInterpreter::cmd_playVocFile(const uint16 *param) {
int TIMInterpreter::cmd_loadSoundFile(const uint16 *param) {
const char *file = (const char *)(_currentTim->text + READ_LE_UINT16(_currentTim->text + (param[0]<<1)));
+
_vm->sound()->loadSoundFile(file);
+ if (_vm->gameFlags().gameID == GI_LOL)
+ _vm->sound()->loadSfxFile(file);
+
return 1;
}
diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h
index 5b8e82bcc4..84aebcf363 100644
--- a/engines/kyra/sound.h
+++ b/engines/kyra/sound.h
@@ -350,7 +350,6 @@ private:
// Midi file related
byte *_musicFile, *_sfxFile;
- uint32 _musicFileSize, _sfxFileSize;
MidiParser *_music;
MidiParser *_sfx[3];
diff --git a/engines/kyra/sound_midi.cpp b/engines/kyra/sound_midi.cpp
index d611f4b1e2..a1d5b92716 100644
--- a/engines/kyra/sound_midi.cpp
+++ b/engines/kyra/sound_midi.cpp
@@ -450,7 +450,6 @@ SoundMidiPC::SoundMidiPC(KyraEngine_v1 *vm, Audio::Mixer *mixer, MidiDriver *dri
_output = 0;
_musicFile = _sfxFile = 0;
- _musicFileSize = _sfxFileSize = 0;
_music = MidiParser::createParser_XMIDI();
assert(_music);
@@ -551,38 +550,44 @@ void SoundMidiPC::loadSoundFile(Common::String file) {
for (int i = 0; i < 16; ++i)
_output->stopNotesOnChannel(i);
- if (_sfxFile != _musicFile)
- delete[] _sfxFile;
delete[] _musicFile;
-
- _musicFile = _sfxFile = _vm->resource()->fileData(file.c_str(), &_musicFileSize);
- _sfxFileSize = _musicFileSize;
+ uint32 fileSize = 0;
+ _musicFile = _vm->resource()->fileData(file.c_str(), &fileSize);
_output->setSoundSource(0);
- _music->loadMusic(_musicFile, _musicFileSize);
+ _music->loadMusic(_musicFile, fileSize);
_music->stopPlaying();
- for (int i = 0; i < 3; ++i) {
- _output->setSoundSource(i+1);
- _sfx[i]->loadMusic(_musicFile, _musicFileSize);
- _sfx[i]->stopPlaying();
+ // Since KYRA1 uses the same file for SFX and Music
+ // we setup sfx to play from music file as well
+ if (_vm->gameFlags().gameID == GI_KYRA1) {
+ for (int i = 0; i < 3; ++i) {
+ _output->setSoundSource(i+1);
+ _sfx[i]->loadMusic(_musicFile, fileSize);
+ _sfx[i]->stopPlaying();
+ }
}
}
void SoundMidiPC::loadSfxFile(Common::String file) {
Common::StackLock lock(_mutex);
+ // Kyrandia 1 doesn't use a special sfx file
+ if (_vm->gameFlags().gameID == GI_KYRA1)
+ return;
+
file += _useC55 ? ".C55" : ".XMI";
if (!_vm->resource()->exists(file.c_str()))
return;
- if (_sfxFile != _musicFile)
- delete[] _sfxFile;
+ delete[] _sfxFile;
+
+ uint32 fileSize = 0;
+ _sfxFile = _vm->resource()->fileData(file.c_str(), &fileSize);
- _sfxFile = _vm->resource()->fileData(file.c_str(), &_sfxFileSize);
for (int i = 0; i < 3; ++i) {
_output->setSoundSource(i+1);
- _sfx[i]->loadMusic(_sfxFile, _sfxFileSize);
+ _sfx[i]->loadMusic(_sfxFile, fileSize);
_sfx[i]->stopPlaying();
}
}