sampled sound in MI1&2 (patch )

svn-id: r4773
This commit is contained in:
Max Horn 2002-08-19 12:56:12 +00:00
parent a07644c0eb
commit be528b93da
2 changed files with 40 additions and 1 deletions

@ -605,6 +605,9 @@ int Scumm::readSoundResource(int type, int idx)
pri = -1;
switch (tag) {
case MKID('SBL '):
pri = 15;
break;
case MKID('ADL '):
if (_use_adlib)
pri = 10;
@ -702,7 +705,7 @@ int Scumm::readSoundResource(int type, int idx)
00 0F 00 40
Maybe I am mistaken when I think it's four byte, some other parts
seem to suggest it's 2 byte oriented, or even variable lenght...
seem to suggest it's 2 byte oriented, or even variable length...
*/
fileSeek(_fileHandle, -12, SEEK_CUR);
total_size = fileReadDwordBE();

@ -216,6 +216,42 @@ void Sound::playSound(int sound) {
_scumm->_mixer->play_raw(NULL, sound, size, rate, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
return;
}
// Support for sampled sound effects in Monkey1 and Monkey2
else if (ptr != NULL && READ_UINT32_UNALIGNED(ptr) == MKID('SBL ')) {
debug(2, "Using SBL sound effect");
// TODO - Figuring out how the SBL chunk works. Here's an
// example:
//
// 53 42 4c 20 00 00 11 ae |SBL ....|
// 41 55 68 64 00 00 00 03 |AUhd....|
// 00 00 80 41 55 64 74 00 |...AUdt.|
// 00 11 9b 01 96 11 00 a6 |........|
// 00 7f 7f 7e 7e 7e 7e 7e |...~~~~~|
// 7e 7f 7f 80 80 7f 7f 7f |~.......|
// 7f 80 80 7f 7e 7d 7d 7e |....~}}~|
// 7e 7e 7e 7e 7e 7e 7e 7f |~~~~~~~.|
// 7f 7f 7f 80 80 80 80 80 |........|
// 80 81 80 80 7f 7f 80 85 |........|
// 8b 8b 83 78 72 6d 6f 75 |...xrmou|
// 7a 78 77 7d 83 84 83 81 |zxw}....|
//
// The length of the AUhd chunk always seems to be 3 bytes.
// Let's skip that for now.
//
// The starting offset, length and sample rate is all pure
// guesswork. The result sounds reasonable to me, but I've
// never heard the original.
int size = READ_BE_UINT32_UNALIGNED(ptr + 4) - 27;
int rate = 8000;
// Allocate a sound buffer, copy the data into it, and play
char *sound = (char*)malloc(size);
memcpy(sound, ptr + 33, size);
_scumm->_mixer->play_raw(NULL, sound, size, rate, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
return;
}
if ((_scumm->_features & GF_OLD256) && (ptr != NULL)) {
char *sound;