diff options
author | Paweł Kołodziejski | 2002-10-15 06:53:42 +0000 |
---|---|---|
committer | Paweł Kołodziejski | 2002-10-15 06:53:42 +0000 |
commit | 45b1a8ea4563536b221c75c260b2b83b43bf3737 (patch) | |
tree | 72ca1cfce24d9ad6cf356e90ebd7148f9202dd21 /scumm | |
parent | 3fb3f65a1877c7ce607c455bd10557d79a6dc2bb (diff) | |
download | scummvm-rg350-45b1a8ea4563536b221c75c260b2b83b43bf3737.tar.gz scummvm-rg350-45b1a8ea4563536b221c75c260b2b83b43bf3737.tar.bz2 scummvm-rg350-45b1a8ea4563536b221c75c260b2b83b43bf3737.zip |
cleanup sfx and music in imuse, changed talkdelay description(disable) in the dig
svn-id: r5148
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/imuse.cpp | 30 | ||||
-rw-r--r-- | scumm/imuse.h | 3 | ||||
-rw-r--r-- | scumm/saveload.cpp | 11 | ||||
-rw-r--r-- | scumm/smush/scumm_renderer.cpp | 11 | ||||
-rw-r--r-- | scumm/sound.cpp | 72 | ||||
-rw-r--r-- | scumm/sound.h | 3 | ||||
-rw-r--r-- | scumm/string.cpp | 4 |
7 files changed, 94 insertions, 40 deletions
diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp index 0c7ef1e960..82f1232e9f 100644 --- a/scumm/imuse.cpp +++ b/scumm/imuse.cpp @@ -4998,6 +4998,7 @@ IMuseDigital::IMuseDigital(Scumm *scumm) { memset(_channel, 0, sizeof(channel) * MAX_DIGITAL_CHANNELS); _scumm = scumm; _scumm->_timer->installProcedure(imus_digital_handler, 200); + _pause = false; } IMuseDigital::~IMuseDigital() { @@ -5395,9 +5396,11 @@ static const imuse_ft_music_table _ftSeqMusicTable[] = { }; void IMuseDigital::handler() { - bool new_mixer; uint32 l = 0, i = 0; + if (_pause == true) + return; + for (l = 0; l < MAX_DIGITAL_CHANNELS;l ++) { if (_channel[l]._used) { if (_channel[l]._toBeRemoved == true) { @@ -5449,11 +5452,9 @@ void IMuseDigital::handler() { uint32 mixer_size = new_size; if (_channel[l]._mixerTrack == -1) { - new_mixer = true; mixer_size *= 2; new_size *= 2; } else { - new_mixer = false; } if (_channel[l]._isJump == false) { @@ -5506,7 +5507,12 @@ void IMuseDigital::handler() { } } - if (new_mixer) { + + if (_channel[l]._mixerTrack == -1) { + _channel[l]._mixerTrack = _scumm->_mixer->playStream(NULL, -1, buf, mixer_size, + _channel[l]._freq, _channel[l]._mixerFlags); + continue; + } else if (_scumm->_mixer->_channels[_channel[l]._mixerTrack] == NULL) { _channel[l]._mixerTrack = _scumm->_mixer->playStream(NULL, -1, buf, mixer_size, _channel[l]._freq, _channel[l]._mixerFlags); } else { @@ -5692,6 +5698,10 @@ void IMuseDigital::stopAll() { } } +void IMuseDigital::pause(bool pause) { + _pause = pause; +} + int32 IMuseDigital::doCommand(int a, int b, int c, int d, int e, int f, int g, int h) { byte cmd = a & 0xFF; byte param = a >> 8; @@ -5791,7 +5801,7 @@ int32 IMuseDigital::doCommand(int a, int b, int c, int d, int e, int f, int g, i } else if (param == 16) { switch (cmd) { case 0: // play music (state) - debug(1, "IMuseDigital::doCommand 0x1000 (%d)", b); + debug(2, "IMuseDigital::doCommand 0x1000 (%d)", b); if (_scumm->_gameId == GID_DIG) { for(l = 0;; l++) { if (_digStateMusicMap[l].room == -1) { @@ -5799,7 +5809,7 @@ int32 IMuseDigital::doCommand(int a, int b, int c, int d, int e, int f, int g, i } if (_digStateMusicMap[l].room == b) { int16 music = _digStateMusicMap[l].table_index; - debug(1, "Play imuse music: %s, %s, %s", _digStateMusicTable[music].name, _digStateMusicTable[music].title, _digStateMusicTable[music].filename); + debug(2, "Play imuse music: %s, %s, %s", _digStateMusicTable[music].name, _digStateMusicTable[music].title, _digStateMusicTable[music].filename); if (_digStateMusicTable[music].filename[0] != 0) { _scumm->_sound->playBundleMusic((char*)&_digStateMusicTable[music].filename); } @@ -5812,7 +5822,7 @@ int32 IMuseDigital::doCommand(int a, int b, int c, int d, int e, int f, int g, i return 1; } if (_ftStateMusicTable[l].index == b) { - debug(1, "Play imuse music: %s, %s", _ftStateMusicTable[l].name, _ftStateMusicTable[l].audioname); + debug(2, "Play imuse music: %s, %s", _ftStateMusicTable[l].name, _ftStateMusicTable[l].audioname); if (_ftStateMusicTable[l].audioname[0] != 0) { for(r = 0; r < _scumm->_numAudioNames; r++) { if (strcmp(_ftStateMusicTable[l].audioname, &_scumm->_audioNames[r * 9]) == 0) { @@ -5826,14 +5836,14 @@ int32 IMuseDigital::doCommand(int a, int b, int c, int d, int e, int f, int g, i } return 0; case 1: // play music (seq) - debug(1, "IMuseDigital::doCommand 0x1001 (%d)", b); + debug(2, "IMuseDigital::doCommand 0x1001 (%d)", b); if (_scumm->_gameId == GID_DIG) { for(l = 0;; l++) { if (_digSeqMusicTable[l].index == -1) { return 1; } if ((_digSeqMusicTable[l].index == b)) { - debug(1, "Play imuse music: %s, %s, %s", _digSeqMusicTable[l].name, _digSeqMusicTable[l].title, _digSeqMusicTable[l].filename); + debug(2, "Play imuse music: %s, %s, %s", _digSeqMusicTable[l].name, _digSeqMusicTable[l].title, _digSeqMusicTable[l].filename); if (_digSeqMusicTable[l].filename[0] != 0) { _scumm->_sound->playBundleMusic((char*)&_digSeqMusicTable[l].filename); } @@ -5846,7 +5856,7 @@ int32 IMuseDigital::doCommand(int a, int b, int c, int d, int e, int f, int g, i return 1; } if (_ftSeqMusicTable[l].index == b) { - debug(1, "Play imuse music: %s, %s", _ftSeqMusicTable[l].name, _ftSeqMusicTable[l].audioname); + debug(2, "Play imuse music: %s, %s", _ftSeqMusicTable[l].name, _ftSeqMusicTable[l].audioname); if (_ftSeqMusicTable[l].audioname[0] != 0) { for(r = 0; r < _scumm->_numAudioNames; r++) { if (strcmp(_ftSeqMusicTable[l].audioname, &_scumm->_audioNames[r * 9]) == 0) { diff --git a/scumm/imuse.h b/scumm/imuse.h index 80063199ab..2620276073 100644 --- a/scumm/imuse.h +++ b/scumm/imuse.h @@ -21,6 +21,7 @@ */ class IMuseInternal; +class MidiDriver; class IMuse { public: @@ -108,6 +109,7 @@ private: } _channel[MAX_DIGITAL_CHANNELS]; Scumm * _scumm; + bool _pause; public: IMuseDigital(Scumm *scumm); @@ -116,6 +118,7 @@ public: void startSound(int sound); void stopSound(int sound); void stopAll(); + void pause(bool pause); int32 doCommand(int a, int b, int c, int d, int e, int f, int g, int h); int getSoundStatus(int sound); }; diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp index bdbdb03516..f1d07c1383 100644 --- a/scumm/saveload.cpp +++ b/scumm/saveload.cpp @@ -115,6 +115,8 @@ bool Scumm::loadState(int slot, bool compat) _imuseDigital->stopAll(); } + _sound->stopBundleMusic(); + _sound->pauseSounds(true); CHECK_HEAP openRoom(-1); @@ -614,8 +616,13 @@ void Scumm::saveOrLoad(Serializer *s) int var120Backup; int var98Backup; - if (_mixer && !s->isSaving()) - _mixer->stopAll(); + if (_mixer && !s->isSaving()) { + if (_imuseDigital) { + _imuseDigital->stopAll(); + } else { + _mixer->stopAll(); + } + } if (_current_version == VER_V9) s->saveLoadEntries(this, mainEntriesV9); diff --git a/scumm/smush/scumm_renderer.cpp b/scumm/smush/scumm_renderer.cpp index 2db34688bd..94e0616ebd 100644 --- a/scumm/smush/scumm_renderer.cpp +++ b/scumm/smush/scumm_renderer.cpp @@ -27,9 +27,9 @@ #include "sound/mixer.h" #include "scumm/scumm.h" #include "scumm/sound.h" +#include "scumm/imuse.h" #include "scumm/actor.h" - class ScummMixer : public Mixer { private: SoundMixer * _mixer; //!< pointer to the SoundMixer instance @@ -188,7 +188,6 @@ bool ScummMixer::stop() { _channels[i].chan = 0; } } -// _mixer->stopAll(); return true; } @@ -196,7 +195,6 @@ ScummRenderer::ScummRenderer(Scumm * scumm, uint32 speed) : _scumm(scumm), _smixer(0), _insaneSpeed(speed) { -// scumm->_mixer->stopAll(); } static ScummRenderer * s_renderer; @@ -207,7 +205,6 @@ static void smush_handler(void * engine) { Mixer * ScummRenderer::getMixer() { if(_smixer == 0) { - _scumm->_sound->pauseBundleMusic(true); _smixer = new ScummMixer(_scumm->_mixer); if(!_smixer) error("unable to allocate a smush mixer"); s_renderer = this; @@ -224,6 +221,9 @@ ScummRenderer::~ScummRenderer() { delete _smixer; _smixer = 0; } + if (_scumm->_imuseDigital) { + _scumm->_imuseDigital->pause(false); + } _scumm->_sound->pauseBundleMusic(false); _scumm->_fullRedraw = 1; _scumm->redrawBGAreas(); @@ -240,6 +240,9 @@ bool ScummRenderer::wait(int32 ms) { } bool ScummRenderer::startDecode(const char * fname, int32 version, int32 nbframes) { + if (_scumm->_imuseDigital) { + _scumm->_imuseDigital->pause(true); + } _scumm->_sound->pauseBundleMusic(true); _scumm->_videoFinished = false; _scumm->_insaneState = true; diff --git a/scumm/sound.cpp b/scumm/sound.cpp index fb9714b188..00204c8b3a 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -710,6 +710,12 @@ void Sound::pauseSounds(bool pause) { _soundsPaused = pause; _scumm->_mixer->pause(pause); + _scumm->_sound->pauseBundleMusic(pause); + + if (_scumm->_imuseDigital) { + _scumm->_imuseDigital->pause(pause); + } + if ((_scumm->_features & GF_AUDIOTRACKS) && _scumm->_vars[_scumm->VAR_MI1_TIMER] > 0) { if (pause) stopCDTimer(); @@ -843,8 +849,9 @@ File * Sound::openSfxFile() { void Sound::stopSfxSound() { if (_scumm->_imuseDigital) { _scumm->_imuseDigital->stopAll(); + } else { + _scumm->_mixer->stopAll(); } - _scumm->_mixer->stopAll(); } @@ -901,6 +908,8 @@ void Sound::playBundleMusic(char * song) { _offsetSampleBundleMusic = 0; _offsetBufBundleMusic = 0; _pauseBundleMusic = false; + _musicBundleToBeRemoved = false; + _musicBundleToBeChanged = false; _bundleMusicTrack = -1; _numberSamplesBundleMusic = _scumm->_bundle->getNumberOfMusicSamplesByName(song); _nameBundleMusic = song; @@ -908,11 +917,9 @@ void Sound::playBundleMusic(char * song) { return; } if (strcmp(_nameBundleMusic, song) != 0) { - _numberSamplesBundleMusic = _scumm->_bundle->getNumberOfMusicSamplesByName(song); - _nameBundleMusic = song; - _currentSampleBundleMusic = 0; - _offsetSampleBundleMusic = 0; - _offsetBufBundleMusic = 0; + _newNameBundleMusic = song; + _musicBundleToBeRemoved = false; + _musicBundleToBeChanged = true; } } @@ -921,17 +928,7 @@ void Sound::pauseBundleMusic(bool state) { } void Sound::stopBundleMusic() { - _scumm->_timer->releaseProcedure(&music_handler); - _nameBundleMusic = NULL; - _bundleMusicTrack = -1; - if (_musicBundleBufFinal) { - free(_musicBundleBufFinal); - _musicBundleBufFinal = NULL; - } - if (_musicBundleBufOutput) { - free(_musicBundleBufOutput); - _musicBundleBufOutput = NULL; - } + _musicBundleToBeRemoved = true; } void Sound::bundleMusicHandler(Scumm * scumm) { @@ -940,11 +937,36 @@ void Sound::bundleMusicHandler(Scumm * scumm) { int32 rate = 22050; int32 tag, size = -1, header_size = 0; - ptr = _musicBundleBufOutput; - if (_pauseBundleMusic) return; + if (_musicBundleToBeRemoved == true) { + _scumm->_timer->releaseProcedure(&music_handler); + _nameBundleMusic = NULL; + _scumm->_mixer->stopChannel(_bundleMusicTrack); + _bundleMusicTrack = -1; + if (_musicBundleBufFinal) { + free(_musicBundleBufFinal); + _musicBundleBufFinal = NULL; + } + if (_musicBundleBufOutput) { + free(_musicBundleBufOutput); + _musicBundleBufOutput = NULL; + } + return; + } + + if (_musicBundleToBeChanged == true) { + _nameBundleMusic = _newNameBundleMusic; + _numberSamplesBundleMusic = _scumm->_bundle->getNumberOfMusicSamplesByName(_nameBundleMusic); + _currentSampleBundleMusic = 0; + _offsetSampleBundleMusic = 0; + _offsetBufBundleMusic = 0; + _musicBundleToBeChanged = false; + } + + ptr = _musicBundleBufOutput; + for (k = 0, l = _currentSampleBundleMusic; l < num; k++) { length = _scumm->_bundle->decompressMusicSampleByName(_nameBundleMusic, l, (_musicBundleBufOutput + ((k * 0x2000) + _offsetBufBundleMusic))); _offsetSampleBundleMusic += length; @@ -953,7 +975,7 @@ void Sound::bundleMusicHandler(Scumm * scumm) { tag = READ_BE_UINT32(ptr); ptr += 4; if (tag != MKID_BE('iMUS')) { warning("Decompression of bundle song failed"); - _nameBundleMusic = NULL; + _musicBundleToBeRemoved = true; return; } @@ -980,7 +1002,7 @@ void Sound::bundleMusicHandler(Scumm * scumm) { } if (size < 0) { warning("Decompression sound failed (no size field)"); - _nameBundleMusic = NULL; + _musicBundleToBeRemoved = true; return; } header_size = (ptr - _musicBundleBufOutput); @@ -998,17 +1020,21 @@ void Sound::bundleMusicHandler(Scumm * scumm) { } } - if (_currentSampleBundleMusic == num) + if (_currentSampleBundleMusic == num) { _currentSampleBundleMusic = 0; + _offsetSampleBundleMusic = 0; + _offsetBufBundleMusic = 0; + } size = OUTPUT_SIZE; ptr = _musicBundleBufFinal; byte * buffer = NULL; uint32 final_size = decode12BitsSample(ptr, &buffer, size); + if (_bundleMusicTrack == -1) { _bundleMusicTrack = _scumm->_mixer->playStream(NULL, -1, buffer, final_size, rate, - SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_16BITS | SoundMixer::FLAG_STEREO); + SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_16BITS | SoundMixer::FLAG_STEREO, -1); } else { _scumm->_mixer->append(_bundleMusicTrack, buffer, final_size, rate, SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_16BITS | SoundMixer::FLAG_STEREO); diff --git a/scumm/sound.h b/scumm/sound.h index cad4619376..409e1b7c58 100644 --- a/scumm/sound.h +++ b/scumm/sound.h @@ -44,6 +44,7 @@ enum { bool _soundVolumePreset; char * _nameBundleMusic; + char * _newNameBundleMusic; int32 _currentSampleBundleMusic; int32 _numberSamplesBundleMusic; int32 _offsetSampleBundleMusic; @@ -52,6 +53,8 @@ enum { byte * _musicBundleBufOutput; bool _pauseBundleMusic; int32 _bundleMusicTrack; + bool _musicBundleToBeChanged; + bool _musicBundleToBeRemoved; int _talkChannel; /* Mixer channel actor is talking on */ File *_sfxFile; diff --git a/scumm/string.cpp b/scumm/string.cpp index 61c83be5ef..2de4718f54 100644 --- a/scumm/string.cpp +++ b/scumm/string.cpp @@ -475,7 +475,9 @@ void Scumm::description() charset._center = false; charset._color = 15; _bkColor = 0; - _talkDelay = 1; + // FIXME: _talkdelay = 1 - display description, not correct ego actor talking, + // 0 - no display, correct ego actor talking + _talkDelay = 0; restoreCharsetBg(); |