diff options
author | Florian Kagerer | 2010-08-18 21:38:43 +0000 |
---|---|---|
committer | Florian Kagerer | 2010-08-18 21:38:43 +0000 |
commit | 29a5c6a45b90e64cf5d618da4cdcd6e6da3425fb (patch) | |
tree | 16a964ac2f849c71399028e3debaf0faef45b447 /engines/scumm/sound.cpp | |
parent | c04d3e46899194af3558f611af634dc7124ab7c2 (diff) | |
download | scummvm-rg350-29a5c6a45b90e64cf5d618da4cdcd6e6da3425fb.tar.gz scummvm-rg350-29a5c6a45b90e64cf5d618da4cdcd6e6da3425fb.tar.bz2 scummvm-rg350-29a5c6a45b90e64cf5d618da4cdcd6e6da3425fb.zip |
SCUMM/FM-TOWNS: start rewriting audio code
- Start rewriting audio code for FM-TOWNS versions of Loom, Indy3 and Monkey Island 1 using the recently added code in towns_audio.cpp (Zak should work the same way, but I can't test, since I don't own that one).
- All sound types (pcm, euphony and cd audio) now support volume and balance control (e.g. try walking into/out of the kitchen and opening/closing the door in the Scumm Bar in Monkey Island 1 or walking into/out of the circus tent).
- Pcm sounds now support proper loop start/end and note offsets (e.g. try out the hammer sound in the forge in LOOM for example).
- some other minor improvements
- The FM-Towns versions of Indy 4 and Monkey Island 2 are not affected. I don't have Monkey Island 2, but I presume that it will work like Indy 4. Adding support for these will be a separate task, since they work quite differently.
svn-id: r52198
Diffstat (limited to 'engines/scumm/sound.cpp')
-rw-r--r-- | engines/scumm/sound.cpp | 94 |
1 files changed, 7 insertions, 87 deletions
diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp index 28f1372746..f12625c9e3 100644 --- a/engines/scumm/sound.cpp +++ b/engines/scumm/sound.cpp @@ -31,6 +31,7 @@ #include "scumm/file.h" #include "scumm/imuse/imuse.h" #include "scumm/imuse_digi/dimuse.h" +#include "scumm/player_towns.h" #include "scumm/scumm.h" #include "scumm/sound.h" #include "scumm/util.h" @@ -150,9 +151,10 @@ void Sound::processSoundQueues() { data[0] >> 8, data[0] & 0xFF, data[1], data[2], data[3], data[4], data[5], data[6], data[7]); - if (_vm->_imuse) { + if (_vm->_townsPlayer) + _vm->VAR(_vm->VAR_SOUNDRESULT) = (short)_vm->_townsPlayer->doCommand(num, data); + else if (_vm->_imuse) _vm->VAR(_vm->VAR_SOUNDRESULT) = (short)_vm->_imuse->doCommand(num, data); - } } } _soundQuePos = 0; @@ -312,91 +314,6 @@ void Sound::playSound(int soundID) { stream = Audio::makeRawStream(sound, size, rate, Audio::FLAG_UNSIGNED); _mixer->playStream(Audio::Mixer::kSFXSoundType, NULL, stream, soundID); } - else if ((_vm->_game.platform == Common::kPlatformFMTowns && _vm->_game.version == 3) || READ_BE_UINT32(ptr) == MKID_BE('SOUN') || READ_BE_UINT32(ptr) == MKID_BE('TOWS')) { - - bool tows = READ_BE_UINT32(ptr) == MKID_BE('TOWS'); - if (_vm->_game.version == 3) { - size = READ_LE_UINT32(ptr); - } else { - size = READ_BE_UINT32(ptr + 4) - 2; - if (tows) - size += 8; - ptr += 2; - } - - rate = 11025; - int type = *(ptr + 0x0D); - int numInstruments; - - if (tows) - type = 0; - - switch (type) { - case 0: // Sound effect - numInstruments = *(ptr + 0x14); - if (tows) - numInstruments = 1; - ptr += 0x16; - size -= 0x16; - - while (numInstruments--) { - int waveSize = READ_LE_UINT32(ptr + 0x0C); - int loopStart = READ_LE_UINT32(ptr + 0x10) * 2; - int loopEnd = READ_LE_UINT32(ptr + 0x14) - 1; - rate = READ_LE_UINT32(ptr + 0x18) * 1000 / 0x62; - ptr += 0x20; - size -= 0x20; - if (size < waveSize) { - warning("Wrong wave size in sound #%i: %i", soundID, waveSize); - waveSize = size; - } - sound = (byte *)malloc(waveSize); - for (int x = 0; x < waveSize; x++) { - byte b = *ptr++; - if (b < 0x80) - sound[x] = 0x7F - b; - else - sound[x] = b; - } - size -= waveSize; - - if (loopEnd > 0) { - Audio::SeekableAudioStream *s = Audio::makeRawStream(sound, waveSize, rate, Audio::FLAG_UNSIGNED); - stream = new Audio::SubLoopingAudioStream(s, 0, Audio::Timestamp(0, loopStart, rate), Audio::Timestamp(0, loopEnd, rate)); - } else { - stream = Audio::makeRawStream(sound, waveSize, rate, Audio::FLAG_UNSIGNED); - } - _mixer->playStream(Audio::Mixer::kSFXSoundType, NULL, stream, soundID, 255, 0); - } - break; - case 1: - // Music (Euphony format) - if (_vm->_musicEngine) - _vm->_musicEngine->startSound(soundID); - break; - case 2: // CD track resource - ptr += 0x16; - - if (soundID == _currentCDSound && pollCD() == 1) { - return; - } - - { - int track = ptr[0]; - int loops = ptr[1]; - int start = (ptr[2] * 60 + ptr[3]) * 75 + ptr[4]; - int end = (ptr[5] * 60 + ptr[6]) * 75 + ptr[7]; - - playCDTrack(track, loops == 0xff ? -1 : loops, start, end <= start ? 0 : end - start); - } - - _currentCDSound = soundID; - break; - default: - // All other sound types are ignored - break; - } - } else if ((_vm->_game.id == GID_LOOM) && (_vm->_game.platform == Common::kPlatformMacintosh)) { // Mac version of Loom uses yet another sound format /* @@ -480,6 +397,9 @@ void Sound::playSound(int soundID) { if (_vm->_musicEngine) { _vm->_musicEngine->startSound(soundID); } + + if (_vm->_townsPlayer) + _currentCDSound = _vm->_townsPlayer->getCurrentCdaSound(); } } |