aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2015-06-15 03:15:08 +0300
committerFilippos Karapetis2015-06-15 03:15:08 +0300
commitdd992772be489b69803c8d00fd66347fe16ad804 (patch)
tree5f925f94a9fe0d0603f3b567353e17a62c70c446
parentfc8177cdd3fd2470fe353b83daed6dd033e7b159 (diff)
downloadscummvm-rg350-dd992772be489b69803c8d00fd66347fe16ad804.tar.gz
scummvm-rg350-dd992772be489b69803c8d00fd66347fe16ad804.tar.bz2
scummvm-rg350-dd992772be489b69803c8d00fd66347fe16ad804.zip
SHERLOCK: RT: Initial implementation of XMI music support for RT
-rw-r--r--engines/sherlock/music.cpp41
-rw-r--r--engines/sherlock/music.h2
-rw-r--r--engines/sherlock/sound.cpp1
-rw-r--r--engines/sherlock/sound.h1
-rw-r--r--engines/sherlock/tattoo/tattoo_scene.cpp2
5 files changed, 29 insertions, 18 deletions
diff --git a/engines/sherlock/music.cpp b/engines/sherlock/music.cpp
index 470c6fafb3..29e122f09c 100644
--- a/engines/sherlock/music.cpp
+++ b/engines/sherlock/music.cpp
@@ -218,7 +218,7 @@ Music::Music(SherlockEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) {
if (_vm->_interactiveFl)
_vm->_res->addToCache("MUSIC.LIB");
- _midiParser = new MidiParser_SH();
+ _midiParser = (IS_SERRATED_SCALPEL) ? new MidiParser_SH() : MidiParser::createParser_XMIDI();
MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MT32);
_musicType = MidiDriver::getMusicType(dev);
@@ -320,8 +320,14 @@ bool Music::loadSong(int songNumber) {
}
bool Music::loadSong(const Common::String &songName) {
- warning("TODO: Music::loadSong");
- return false;
+ freeSong(); // free any song that is currently loaded
+
+ if (!playMusic(songName))
+ return false;
+
+ stopMusic();
+ startSong();
+ return true;
}
void Music::syncMusicSettings() {
@@ -339,7 +345,7 @@ bool Music::playMusic(const Common::String &name) {
if (!_midiDriver)
return false;
- Common::String midiMusicName = name + ".MUS";
+ Common::String midiMusicName = (IS_SERRATED_SCALPEL) ? name + ".MUS" : name + ".XMI";
Common::SeekableReadStream *stream = _vm->_res->load(midiMusicName, "MUSIC.LIB");
_midiMusicData = new byte[stream->size()];
@@ -365,17 +371,24 @@ bool Music::playMusic(const Common::String &name) {
byte *dataPos = _midiMusicData;
int32 dataSize = _midiMusicDataSize;
- if (memcmp(" ", dataPos, 12)) {
- warning("Music: expected header not found in music file");
- return false;
- }
- dataPos += 12;
- dataSize -= 12;
+ if (IS_SERRATED_SCALPEL) {
+ if (memcmp(" ", dataPos, 12)) {
+ warning("Music: expected header not found in music file");
+ return false;
+ }
+ dataPos += 12;
+ dataSize -= 12;
- uint16 headerSize = READ_LE_UINT16(dataPos);
- if (headerSize != 0x7F) {
- warning("Music: header is not as expected");
- return false;
+ uint16 headerSize = READ_LE_UINT16(dataPos);
+ if (headerSize != 0x7F) {
+ warning("Music: header is not as expected");
+ return false;
+ }
+ } else {
+ if (memcmp("FORM", dataPos, 4)) {
+ warning("Music: expected header not found in music file");
+ return false;
+ }
}
switch (_musicType) {
diff --git a/engines/sherlock/music.h b/engines/sherlock/music.h
index 2ebede9ea3..25270c4abc 100644
--- a/engines/sherlock/music.h
+++ b/engines/sherlock/music.h
@@ -58,7 +58,7 @@ class Music {
private:
SherlockEngine *_vm;
Audio::Mixer *_mixer;
- MidiParser_SH *_midiParser;
+ MidiParser *_midiParser;
MidiDriver *_midiDriver;
Audio::SoundHandle _digitalMusicHandle;
MusicType _musicType;
diff --git a/engines/sherlock/sound.cpp b/engines/sherlock/sound.cpp
index 795ccb030e..70d42a737c 100644
--- a/engines/sherlock/sound.cpp
+++ b/engines/sherlock/sound.cpp
@@ -60,7 +60,6 @@ Sound::Sound(SherlockEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) {
_soundIsOn = &_soundPlaying;
_curPriority = 0;
_digiBuf = nullptr;
- _midiDrvLoaded = false;
_soundOn = true;
_speechOn = true;
diff --git a/engines/sherlock/sound.h b/engines/sherlock/sound.h
index 8514559434..e82d94bbe0 100644
--- a/engines/sherlock/sound.h
+++ b/engines/sherlock/sound.h
@@ -59,7 +59,6 @@ public:
bool _soundPlaying;
bool *_soundIsOn;
byte *_digiBuf;
- bool _midiDrvLoaded;
Common::String _currentSongName, _nextSongName;
public:
Sound(SherlockEngine *vm, Audio::Mixer *mixer);
diff --git a/engines/sherlock/tattoo/tattoo_scene.cpp b/engines/sherlock/tattoo/tattoo_scene.cpp
index 1cc7b65289..477739af63 100644
--- a/engines/sherlock/tattoo/tattoo_scene.cpp
+++ b/engines/sherlock/tattoo/tattoo_scene.cpp
@@ -87,7 +87,7 @@ bool TattooScene::loadScene(const Common::String &filename) {
setNPCPath(0);
// Handle loading music for the scene
- if (sound._midiDrvLoaded) {
+ if (music._musicOn) {
if (talk._scriptMoreFlag != 1 && talk._scriptMoreFlag != 3)
sound._nextSongName = Common::String::format("res%02d", _currentScene);