diff options
-rw-r--r-- | scumm/bundle.cpp | 35 | ||||
-rw-r--r-- | scumm/bundle.h | 4 | ||||
-rw-r--r-- | scumm/imuse.cpp | 7 | ||||
-rw-r--r-- | scumm/sound.cpp | 16 |
4 files changed, 43 insertions, 19 deletions
diff --git a/scumm/bundle.cpp b/scumm/bundle.cpp index 72a5238108..4ee3bde054 100644 --- a/scumm/bundle.cpp +++ b/scumm/bundle.cpp @@ -221,7 +221,7 @@ int32 Bundle::decompressVoiceSampleByName(char *name, byte *comp_final) { return final_size; } -int32 Bundle::decompressMusicSampleByName(char *name, int32 number, byte *comp_final) { +int32 Bundle::decompressMusicSampleByName(char *name, int32 number, byte *comp_final, bool fuzzy=false) { int32 final_size = 0, i; if (!name) { @@ -235,11 +235,18 @@ int32 Bundle::decompressMusicSampleByName(char *name, int32 number, byte *comp_f } for (i = 0; i < _numMusicFiles; i++) { - if (!scumm_stricmp(name, _bundleMusicTable[i].filename)) { - final_size = decompressMusicSampleByIndex(i, number, comp_final); - return final_size; - } + if (fuzzy) // Fuzzy matching, only look at the first part of the song + if (strstr(_bundleMusicTable[i].filename, name) == _bundleMusicTable[i].filename) { + final_size = decompressMusicSampleByIndex(i, number, comp_final); + return final_size; + } + else + if (!scumm_stricmp(name, _bundleMusicTable[i].filename)) { + final_size = decompressMusicSampleByIndex(i, number, comp_final); + return final_size; + } } + printf("Couldn't find sample %s\n", name); return final_size; } @@ -254,7 +261,7 @@ int32 Bundle::getNumberOfMusicSamplesByIndex(int32 index) { return _musicFile.readUint32BE(); } -int32 Bundle::getNumberOfMusicSamplesByName(char *name) { +int32 Bundle::getNumberOfMusicSamplesByName(char *name, bool fuzzy = false) { int32 number = 0, i; if (_musicFile.isOpen() == false) { @@ -263,11 +270,19 @@ int32 Bundle::getNumberOfMusicSamplesByName(char *name) { } for (i = 0; i < _numMusicFiles; i++) { - if (!scumm_stricmp(name, _bundleMusicTable[i].filename)) { - number = getNumberOfMusicSamplesByIndex(i); - return number; - } + if (fuzzy) // Fuzzy matching, only look at the first part of the song + if (strstr(_bundleMusicTable[i].filename, name) == _bundleMusicTable[i].filename) { + number = getNumberOfMusicSamplesByIndex(i); + return number; + } + else + if (!scumm_stricmp(name, _bundleMusicTable[i].filename)) { + number = getNumberOfMusicSamplesByIndex(i); + return number; + } + } + printf("Couldn't find numsample %s\n", name); return number; } diff --git a/scumm/bundle.h b/scumm/bundle.h index 7d2e1744e2..74984fc883 100644 --- a/scumm/bundle.h +++ b/scumm/bundle.h @@ -60,10 +60,10 @@ public: bool openMusicFile(const char *filename, const char *directory); int32 decompressVoiceSampleByName(char *name, byte *comp_final); int32 decompressVoiceSampleByIndex(int32 index, byte *comp_final); - int32 decompressMusicSampleByName(char *name, int32 number, byte *comp_final); + int32 decompressMusicSampleByName(char *name, int32 number, byte *comp_final, bool fuzzy=false); int32 decompressMusicSampleByIndex(int32 index, int32 number, byte *comp_final); int32 getNumberOfMusicSamplesByIndex(int32 index); - int32 getNumberOfMusicSamplesByName(char *name); + int32 getNumberOfMusicSamplesByName(char *name, bool fuzzy=false); }; #endif diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp index 16247d7fe4..a2ea7a4b75 100644 --- a/scumm/imuse.cpp +++ b/scumm/imuse.cpp @@ -4580,7 +4580,12 @@ int32 IMuseDigital::doCommand(int a, int b, int c, int d, int e, int f, int g, i switch (cmd) { case 0: // play music (state) debug(2, "IMuseDigital::doCommand 0x1000 (%d)", b); - if (_scumm->_gameId == GID_DIG) { + if (_scumm->_gameId == GID_CMI) { + char musicName[255]; + sprintf(musicName, "%d-", b); + _scumm->_sound->playBundleMusic(strdup(musicName)); + return 0; + } else if (_scumm->_gameId == GID_DIG) { for(l = 0;; l++) { if (_digStateMusicMap[l].room == -1) { return 1; diff --git a/scumm/sound.cpp b/scumm/sound.cpp index 9f23554205..d12e1bfd4d 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -961,10 +961,14 @@ void Sound::playBundleMusic(char * song) { if (_nameBundleMusic == NULL) { // FIXME: we have MUSDISK1.BUN and MUSDISK2.BUN in COMI. - if (_scumm->_bundle->openMusicFile("digmusic.bun", _scumm->getGameDataPath()) == false) { - return; + if (_scumm->_gameId == GID_CMI) { + printf("Opening bundle\n"); + if (_scumm->_bundle->openMusicFile("musdisk1.bun", _scumm->getGameDataPath()) == false) + return; + } else { + if (_scumm->_bundle->openMusicFile("digmusic.bun", _scumm->getGameDataPath()) == false) + return; } - _musicBundleBufFinal = (byte*)malloc(OUTPUT_SIZE); _musicBundleBufOutput = (byte*)malloc(10 * 0x2000); _currentSampleBundleMusic = 0; @@ -974,7 +978,7 @@ void Sound::playBundleMusic(char * song) { _musicBundleToBeRemoved = false; _musicBundleToBeChanged = false; _bundleMusicTrack = -1; - _numberSamplesBundleMusic = _scumm->_bundle->getNumberOfMusicSamplesByName(song); + _numberSamplesBundleMusic = _scumm->_bundle->getNumberOfMusicSamplesByName(song, (_scumm->_gameId == GID_CMI)); _nameBundleMusic = song; _scumm->_timer->installProcedure(&music_handler, 1000); return; @@ -1023,7 +1027,7 @@ void Sound::bundleMusicHandler(Scumm * scumm) { if (_musicBundleToBeChanged == true) { _nameBundleMusic = _newNameBundleMusic; - _numberSamplesBundleMusic = _scumm->_bundle->getNumberOfMusicSamplesByName(_nameBundleMusic); + _numberSamplesBundleMusic = _scumm->_bundle->getNumberOfMusicSamplesByName(_nameBundleMusic, (_scumm->_gameId == GID_CMI)); _currentSampleBundleMusic = 0; _offsetSampleBundleMusic = 0; _offsetBufBundleMusic = 0; @@ -1033,7 +1037,7 @@ void Sound::bundleMusicHandler(Scumm * scumm) { ptr = _musicBundleBufOutput; for (k = 0, l = _currentSampleBundleMusic; l < num; k++) { - length = _scumm->_bundle->decompressMusicSampleByName(_nameBundleMusic, l, (_musicBundleBufOutput + ((k * 0x2000) + _offsetBufBundleMusic))); + length = _scumm->_bundle->decompressMusicSampleByName(_nameBundleMusic, l, (_musicBundleBufOutput + ((k * 0x2000) + _offsetBufBundleMusic)), (_scumm->_gameId == GID_CMI)); _offsetSampleBundleMusic += length; if (l == 0) { |