Add skeleton music support for CMI (but codec not implemented)
svn-id: r6193
This commit is contained in:
parent
56b6b10301
commit
d3ade5b23e
4 changed files with 43 additions and 19 deletions
|
@ -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 (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 (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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue