diff options
-rw-r--r-- | scumm/imuse_digi/dimuse.cpp | 250 | ||||
-rw-r--r-- | scumm/imuse_digi/dimuse.h | 12 | ||||
-rw-r--r-- | scumm/imuse_digi/dimuse_script.cpp | 29 | ||||
-rw-r--r-- | scumm/imuse_digi/dimuse_track.cpp | 96 | ||||
-rw-r--r-- | scumm/script.cpp | 7 | ||||
-rw-r--r-- | scumm/scumm.cpp | 6 | ||||
-rw-r--r-- | scumm/smush/smush_player.cpp | 7 |
7 files changed, 203 insertions, 204 deletions
diff --git a/scumm/imuse_digi/dimuse.cpp b/scumm/imuse_digi/dimuse.cpp index 6633ef5182..48f88d2b21 100644 --- a/scumm/imuse_digi/dimuse.cpp +++ b/scumm/imuse_digi/dimuse.cpp @@ -38,23 +38,20 @@ IMuseDigital::Track::Track() : soundId(-1), used(false), stream(NULL), stream2(NULL) { } -void IMuseDigital::timer_handler(void *refCon) { - IMuseDigital *imuseDigital = (IMuseDigital *)refCon; - imuseDigital->callback(); -} - IMuseDigital::IMuseDigital(ScummEngine *scumm, int fps) : _vm(scumm) { _pause = false; _sound = new ImuseDigiSndMgr(_vm); _callbackFps = fps; + _interval = 1000000 / fps; + _counter = _interval; + _firstCall = true; resetState(); for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) { _track[l] = new Track; _track[l]->trackId = l; _track[l]->used = false; } - _vm->_timer->installTimerProc(timer_handler, 1000000 / _callbackFps, this); _audioNames = NULL; _numAudioNames = 0; @@ -62,7 +59,6 @@ IMuseDigital::IMuseDigital(ScummEngine *scumm, int fps) IMuseDigital::~IMuseDigital() { stopAllSounds(); - _vm->_timer->removeTimerProc(timer_handler); for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) { delete _track[l]; } @@ -79,8 +75,6 @@ void IMuseDigital::resetState() { } void IMuseDigital::saveOrLoad(Serializer *ser) { - Common::StackLock lock(_mutex, "IMuseDigital::saveOrLoad()"); - const SaveLoadEntry mainEntries[] = { MK_OBSOLETE(IMuseDigital, _volVoice, sleInt32, VER(31), VER(42)), MK_OBSOLETE(IMuseDigital, _volSfx, sleInt32, VER(31), VER(42)), @@ -203,142 +197,154 @@ void IMuseDigital::saveOrLoad(Serializer *ser) { } void IMuseDigital::callback() { - Common::StackLock lock(_mutex, "IMuseDigital::callback()"); + if (_firstCall) { + _thisTime = _vm->_system->getMillis(); + _firstCall = false; + } - for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) { - Track *track = _track[l]; - if (track->used && !track->readyToRemove) { - if (track->toBeRemoved) { - track->readyToRemove = true; - continue; - } + _lastTime = _thisTime; + _thisTime = _vm->_system->getMillis(); + int32 interval = 1000 * (_thisTime - _lastTime); + if (interval > 100000) { + warning("IMuseDigital::callback: long interval: %d", interval); + interval = _interval; + } - if (_pause || !_vm) - return; + _counter -= interval; - if (track->volFadeUsed) { - if (track->volFadeStep < 0) { - if (track->vol > track->volFadeDest) { - track->vol += track->volFadeStep; - if (track->vol < track->volFadeDest) { - track->vol = track->volFadeDest; - track->volFadeUsed = false; - } - if (track->vol == 0) { - track->toBeRemoved = true; + while (_counter <= 0) { + _counter += _interval; + + if (_vm->_quit) + return; + + for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) { + Track *track = _track[l]; + if (track->used && !track->toBeRemoved) { + if (track->volFadeUsed) { + if (track->volFadeStep < 0) { + if (track->vol > track->volFadeDest) { + track->vol += track->volFadeStep; + if (track->vol < track->volFadeDest) { + track->vol = track->volFadeDest; + track->volFadeUsed = false; + } + if (track->vol == 0) { + track->toBeRemoved = true; + } } - } - } else if (track->volFadeStep > 0) { - if (track->vol < track->volFadeDest) { - track->vol += track->volFadeStep; + } else if (track->volFadeStep > 0) { + if (track->vol < track->volFadeDest) { + track->vol += track->volFadeStep; if (track->vol > track->volFadeDest) { - track->vol = track->volFadeDest; - track->volFadeUsed = false; + track->vol = track->volFadeDest; + track->volFadeUsed = false; + } } } + debug(5, "Fade: sound(%d), Vol(%d)", track->soundId, track->vol / 1000); } - debug(5, "Fade: sound(%d), Vol(%d)", track->soundId, track->vol / 1000); - } - - const int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0; - const int vol = track->vol / 1000; - Audio::Mixer::SoundType type = Audio::Mixer::kPlainSoundType; - - if (track->volGroupId == 1) - type = Audio::Mixer::kSpeechSoundType; - if (track->volGroupId == 2) - type = Audio::Mixer::kSFXSoundType; - if (track->volGroupId == 3) - type = Audio::Mixer::kMusicSoundType; - if (track->stream) { - byte *data = NULL; - int32 result = 0; + const int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0; + const int vol = track->vol / 1000; + Audio::Mixer::SoundType type = Audio::Mixer::kPlainSoundType; - if (track->curRegion == -1) { - switchToNextRegion(track); - if (track->toBeRemoved) - continue; - } + if (track->volGroupId == 1) + type = Audio::Mixer::kSpeechSoundType; + if (track->volGroupId == 2) + type = Audio::Mixer::kSFXSoundType; + if (track->volGroupId == 3) + type = Audio::Mixer::kMusicSoundType; - int bits = _sound->getBits(track->soundHandle); - int channels = _sound->getChannels(track->soundHandle); + if (track->stream) { + byte *data = NULL; + int32 result = 0; - int32 mixer_size = track->iteration / _callbackFps; - - if (track->stream->endOfData()) { - mixer_size *= 2; - } + if (track->curRegion == -1) { + switchToNextRegion(track); + if (track->toBeRemoved) + continue; + } - if ((bits == 12) || (bits == 16)) { - if (channels == 1) - mixer_size &= ~1; - if (channels == 2) - mixer_size &= ~3; - } else { - if (channels == 2) - mixer_size &= ~1; - } + int bits = _sound->getBits(track->soundHandle); + int channels = _sound->getChannels(track->soundHandle); - if (mixer_size == 0) - continue; + int32 mixer_size = track->iteration / _callbackFps; - do { - if (bits == 12) { - byte *ptr = NULL; + if (track->stream->endOfData()) { + mixer_size *= 2; + } - mixer_size += track->mod; - int mixer_size_12 = (mixer_size * 3) / 4; - int length = (mixer_size_12 / 3) * 4; - track->mod = mixer_size - length; + if ((bits == 12) || (bits == 16)) { + if (channels == 1) + mixer_size &= ~1; + if (channels == 2) + mixer_size &= ~3; + } else { + if (channels == 2) + mixer_size &= ~1; + } - int32 offset = (track->regionOffset * 3) / 4; - int result2 = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &ptr, offset, mixer_size_12); - result = BundleCodecs::decode12BitsSample(ptr, &data, result2); + if (mixer_size == 0) + continue; - free(ptr); - } else if (bits == 16) { - result = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &data, track->regionOffset, mixer_size); - if (channels == 1) { - result &= ~1; - } - if (channels == 2) { - result &= ~3; + do { + if (bits == 12) { + byte *ptr = NULL; + + mixer_size += track->mod; + int mixer_size_12 = (mixer_size * 3) / 4; + int length = (mixer_size_12 / 3) * 4; + track->mod = mixer_size - length; + + int32 offset = (track->regionOffset * 3) / 4; + int result2 = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &ptr, offset, mixer_size_12); + result = BundleCodecs::decode12BitsSample(ptr, &data, result2); + + free(ptr); + } else if (bits == 16) { + result = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &data, track->regionOffset, mixer_size); + if (channels == 1) { + result &= ~1; + } + if (channels == 2) { + result &= ~3; + } + } else if (bits == 8) { + result = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &data, track->regionOffset, mixer_size); + if (channels == 2) { + result &= ~1; } - } else if (bits == 8) { - result = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &data, track->regionOffset, mixer_size); - if (channels == 2) { - result &= ~1; } - } - if (result > mixer_size) - result = mixer_size; + if (result > mixer_size) + result = mixer_size; - if (_vm->_mixer->isReady()) { - _vm->_mixer->setChannelVolume(track->handle, vol); - _vm->_mixer->setChannelBalance(track->handle, pan); - track->stream->append(data, result); - track->regionOffset += result; - } - free(data); + if (_vm->_mixer->isReady()) { + _vm->_mixer->setChannelVolume(track->handle, vol); + _vm->_mixer->setChannelBalance(track->handle, pan); + track->stream->append(data, result); + track->regionOffset += result; + } + free(data); - if (_sound->isEndOfRegion(track->soundHandle, track->curRegion)) { - switchToNextRegion(track); - if (track->toBeRemoved) - break; - } - mixer_size -= result; - assert(mixer_size >= 0); - } while (mixer_size != 0); - } else if (track->stream2) { - if (_vm->_mixer->isReady()) { - if (!track->started) { - track->started = true; - _vm->_mixer->playInputStream(type, &track->handle, track->stream2, -1, vol, pan, false); - } else { - _vm->_mixer->setChannelVolume(track->handle, vol); - _vm->_mixer->setChannelBalance(track->handle, pan); + if (_sound->isEndOfRegion(track->soundHandle, track->curRegion)) { + switchToNextRegion(track); + if (track->toBeRemoved) + break; + } + mixer_size -= result; + assert(mixer_size >= 0); + } while (mixer_size != 0); + } else if (track->stream2) { + if (_vm->_mixer->isReady()) { + if (!track->started) { + track->started = true; + _vm->_mixer->playInputStream(type, &track->handle, track->stream2, -1, vol, pan, false); + } else { + _vm->_mixer->setChannelVolume(track->handle, vol); + _vm->_mixer->setChannelBalance(track->handle, pan); + } } } } diff --git a/scumm/imuse_digi/dimuse.h b/scumm/imuse_digi/dimuse.h index 34d9e91098..892f1b5f1f 100644 --- a/scumm/imuse_digi/dimuse.h +++ b/scumm/imuse_digi/dimuse.h @@ -45,8 +45,6 @@ class Serializer; class IMuseDigital : public MusicEngine { private: - int _callbackFps; - struct Track { int trackId; @@ -86,7 +84,6 @@ private: Track *_track[MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS]; - Common::Mutex _mutex; ScummEngine *_vm; ImuseDigiSndMgr *_sound; @@ -101,8 +98,10 @@ private: int32 _curMusicSeq; int32 _curMusicCue; - static void timer_handler(void *refConf); - void callback(); + int _callbackFps; + int32 _lastTime, _thisTime, _interval, _counter, _diff; + bool _firstCall; + void switchToNextRegion(Track *track); int allocSlot(int priority); void startSound(int soundId, const char *soundName, int soundType, int volGroupId, AudioStream *input, int hookId, int volume, int priority); @@ -132,6 +131,9 @@ public: IMuseDigital(ScummEngine *scumm, int fps); virtual ~IMuseDigital(); + void callback(); + void addDiff(int32 diff) { _diff += diff; } + void setAudioNames(int32 num, char *names); void startVoice(int soundId, AudioStream *input); diff --git a/scumm/imuse_digi/dimuse_script.cpp b/scumm/imuse_digi/dimuse_script.cpp index fcadf609dc..f38462e4f8 100644 --- a/scumm/imuse_digi/dimuse_script.cpp +++ b/scumm/imuse_digi/dimuse_script.cpp @@ -163,15 +163,13 @@ void IMuseDigital::flushTracks() { debug(5, "flushTracks()"); for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) { Track *track = _track[l]; - if (track->used && (track->readyToRemove || - (_vm->_insaneRunning && track->toBeRemoved))) { // INSANE hack for sync timer mode + if (track->used && track->toBeRemoved) { if (track->stream) { if (!track->stream->endOfStream()) { track->stream->finish(); } if (track->stream->endOfStream() - || _vm->_mixer->isPaused() // hack for paused Mixer - || _vm->_insaneRunning) { // INSANE hack for sync timer mode + || _vm->_mixer->isPaused()) { // hack for paused Mixer _vm->_mixer->stopHandle(track->handle); delete track->stream; track->stream = NULL; @@ -194,7 +192,7 @@ void IMuseDigital::refreshScripts() { bool found = false; for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) { + if (track->used && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) { found = true; } } @@ -238,7 +236,7 @@ void IMuseDigital::getLipSync(int soundId, int syncId, int32 msPos, int32 &width if (msPos < 65536) { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if ((track->soundId == soundId) && track->used && !track->toBeRemoved) { + if ((track->soundId == soundId) && track->used) { _sound->getSyncSizeAndPtrById(track->soundHandle, syncId, sync_size, &sync_ptr); if ((sync_size != 0) && (sync_ptr != NULL)) { sync_size /= 4; @@ -265,7 +263,7 @@ void IMuseDigital::getLipSync(int soundId, int syncId, int32 msPos, int32 &width int32 IMuseDigital::getPosInMs(int soundId) { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if ((track->soundId == soundId) && track->used && !track->toBeRemoved) { + if ((track->soundId == soundId) && track->used) { int32 pos = (5 * (track->dataOffset + track->regionOffset)) / (track->iteration / 200); return pos; } @@ -280,7 +278,7 @@ int IMuseDigital::getSoundStatus(int sound) const { Track *track = _track[l]; if (track->soundId == sound) { if ((track->stream2 && _vm->_mixer->isSoundHandleActive(track->handle)) || - (track->stream && track->used && !track->readyToRemove)) { + (track->stream && track->used)) { return 1; } } @@ -293,7 +291,7 @@ void IMuseDigital::stopSound(int soundId) { debug(5, "IMuseDigital::stopSound(%d)", soundId); for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if ((track->soundId == soundId) && track->used && !track->toBeRemoved) { + if ((track->soundId == soundId) && track->used) { track->toBeRemoved = true; } } @@ -304,7 +302,7 @@ int32 IMuseDigital::getCurMusicPosInMs() { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) { + if (track->used && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) { soundId = track->soundId; } } @@ -337,7 +335,7 @@ int32 IMuseDigital::getCurMusicLipSyncWidth(int syncId) { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) { + if (track->used && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) { soundId = track->soundId; } } @@ -355,7 +353,7 @@ int32 IMuseDigital::getCurMusicLipSyncHeight(int syncId) { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) { + if (track->used && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) { soundId = track->soundId; } } @@ -383,14 +381,13 @@ void IMuseDigital::stopAllSounds() { if (!foundNotRemoved) break; flushTracks(); - _vm->_system->delayMillis(50); -#if defined(_WIN32_WCE) || defined (PALMOS_MODE) || defined(__SYMBIAN32__) - _vm->parseEvents(); // timers are events, we need to consume them -#endif } } void IMuseDigital::pause(bool p) { + if ((_pause) && (!p)) { + _thisTime = _vm->_system->getMillis(); + } _pause = p; } diff --git a/scumm/imuse_digi/dimuse_track.cpp b/scumm/imuse_digi/dimuse_track.cpp index 3723705c14..38de38fd72 100644 --- a/scumm/imuse_digi/dimuse_track.cpp +++ b/scumm/imuse_digi/dimuse_track.cpp @@ -47,8 +47,7 @@ int IMuseDigital::allocSlot(int priority) { debug(5, "IMuseDigital::startSound(): All slots are full"); for (l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if (track->used && !track->toBeRemoved && - (lowest_priority > track->priority) && !track->stream2) { + if (track->used && (lowest_priority > track->priority) && !track->stream2) { lowest_priority = track->priority; trackId = l; } @@ -76,17 +75,8 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, } Track *track = _track[l]; - while (track->used) { - // The designated track is not yet available. So, we call flushTracks() - // to get it processed (and thus made ready for us). Since the actual - // processing is done by another thread, we also call parseEvents to - // give it some time (and to avoid busy waiting/looping). - flushTracks(); -#ifndef __PLAYSTATION2__ - _vm->parseEvents(); -#endif - } - + flushTracks(); + assert(!track->used); track->pan = 64; track->vol = volume * 1000; track->volFadeDest = 0; @@ -191,7 +181,7 @@ void IMuseDigital::setPriority(int soundId, int priority) { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if ((track->soundId == soundId) && track->used && !track->toBeRemoved) { + if ((track->soundId == soundId) && track->used) { track->priority = priority; } } @@ -202,18 +192,16 @@ void IMuseDigital::setVolume(int soundId, int volume) { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if ((track->soundId == soundId) && track->used && !track->toBeRemoved) { + if ((track->soundId == soundId) && track->used) { track->vol = volume * 1000; } } } void IMuseDigital::setHookId(int soundId, int hookId) { - Common::StackLock lock(_mutex, "IMuseDigital::setHookId()"); - for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if ((track->soundId == soundId) && track->used && !track->toBeRemoved) { + if ((track->soundId == soundId) && track->used) { track->curHookId = hookId; } } @@ -224,7 +212,7 @@ int IMuseDigital::getCurMusicSoundId() { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) { + if (track->used && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) { soundId = track->soundId; } } @@ -237,7 +225,7 @@ char *IMuseDigital::getCurMusicSoundName() { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) { + if (track->used && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) { soundName = track->soundName; } } @@ -250,7 +238,7 @@ void IMuseDigital::setPan(int soundId, int pan) { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if ((track->soundId == soundId) && track->used && !track->toBeRemoved) { + if ((track->soundId == soundId) && track->used) { track->pan = pan; } } @@ -265,19 +253,18 @@ void IMuseDigital::selectVolumeGroup(int soundId, int volGroupId) { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if ((track->soundId == soundId) && track->used && !track->toBeRemoved) { + if ((track->soundId == soundId) && track->used) { track->volGroupId = volGroupId; } } } void IMuseDigital::setFade(int soundId, int destVolume, int delay60HzTicks) { - Common::StackLock lock(_mutex, "IMuseDigital::setFade()"); debug(5, "IMuseDigital::setFade(%d, %d, %d)", soundId, destVolume, delay60HzTicks); for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if ((track->soundId == soundId) && track->used && !track->toBeRemoved) { + if ((track->soundId == soundId) && track->used) { track->volFadeDelay = delay60HzTicks; track->volFadeDest = destVolume * 1000; track->volFadeStep = (track->volFadeDest - track->vol) * 60 * (1000 / _callbackFps) / (1000 * delay60HzTicks); @@ -290,7 +277,7 @@ void IMuseDigital::fadeOutMusic(int fadeDelay) { debug(5, "IMuseDigital::fadeOutMusic"); for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; - if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) { + if (track->used && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) { cloneToFadeOutTrack(track, fadeDelay); track->toBeRemoved = true; } @@ -303,39 +290,36 @@ IMuseDigital::Track *IMuseDigital::cloneToFadeOutTrack(Track *track, int fadeDel debug(5, "IMuseDigital::cloneToFadeOutTrack(%d, %d)", track->trackId, fadeDelay); - { - Common::StackLock lock(_mutex, "IMuseDigital::cloneToFadeOutTrack()"); - for (int l = MAX_DIGITAL_TRACKS; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) { - if (!_track[l]->used) { - fadeTrack = _track[l]; - break; - } + for (int l = MAX_DIGITAL_TRACKS; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) { + if (!_track[l]->used) { + fadeTrack = _track[l]; + break; } - if (fadeTrack == 0) - error("IMuseDigital::cloneToFadeOutTrack() Can't find free fade track"); - - fadeTrack->pan = track->pan; - fadeTrack->vol = track->vol; - fadeTrack->volGroupId = track->volGroupId; - fadeTrack->priority = track->priority; - fadeTrack->soundId = track->soundId; - fadeTrack->dataOffset = track->dataOffset; - fadeTrack->regionOffset = track->regionOffset; - fadeTrack->curRegion = track->curRegion; - fadeTrack->curHookId = track->curHookId; - fadeTrack->iteration = track->iteration; - fadeTrack->mixerFlags = track->mixerFlags; - fadeTrack->mod = track->mod; - fadeTrack->toBeRemoved = track->toBeRemoved; - fadeTrack->readyToRemove = track->readyToRemove; - fadeTrack->souStream = track->souStream; - fadeTrack->started = track->started; - fadeTrack->stream2 = track->stream2; - strcpy(fadeTrack->soundName, track->soundName); - fadeTrack->soundType = track->soundType; - fadeTrack->soundHandle = _sound->cloneSound(track->soundHandle); - assert(fadeTrack->soundHandle); } + if (fadeTrack == 0) + error("IMuseDigital::cloneToFadeOutTrack() Can't find free fade track"); + + fadeTrack->pan = track->pan; + fadeTrack->vol = track->vol; + fadeTrack->volGroupId = track->volGroupId; + fadeTrack->priority = track->priority; + fadeTrack->soundId = track->soundId; + fadeTrack->dataOffset = track->dataOffset; + fadeTrack->regionOffset = track->regionOffset; + fadeTrack->curRegion = track->curRegion; + fadeTrack->curHookId = track->curHookId; + fadeTrack->iteration = track->iteration; + fadeTrack->mixerFlags = track->mixerFlags; + fadeTrack->mod = track->mod; + fadeTrack->toBeRemoved = track->toBeRemoved; + fadeTrack->readyToRemove = track->readyToRemove; + fadeTrack->souStream = track->souStream; + fadeTrack->started = track->started; + fadeTrack->stream2 = track->stream2; + strcpy(fadeTrack->soundName, track->soundName); + fadeTrack->soundType = track->soundType; + fadeTrack->soundHandle = _sound->cloneSound(track->soundHandle); + assert(fadeTrack->soundHandle); fadeTrack->volFadeDelay = fadeDelay; fadeTrack->volFadeDest = 0; diff --git a/scumm/script.cpp b/scumm/script.cpp index 5750f2d500..06fc03dbfe 100644 --- a/scumm/script.cpp +++ b/scumm/script.cpp @@ -31,6 +31,7 @@ #include "scumm/util.h" #include "scumm/scumm.h" #include "scumm/verbs.h" +#include "scumm/imuse_digi/dimuse.h" namespace Scumm { @@ -463,7 +464,13 @@ void ScummEngine::executeScript() { } printf("\n"); } + + if (_imuseDigital) { + _imuseDigital->callback(); + } + executeOpcode(_opcode); + } CHECK_HEAP; } diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp index 943c7f8d5f..7e5f5c5210 100644 --- a/scumm/scumm.cpp +++ b/scumm/scumm.cpp @@ -2341,9 +2341,11 @@ void ScummEngine::waitForTimer(int msec_delay) { start_time = _system->getMillis(); while (!_quit) { - parseEvents(); - + if (_imuseDigital) { + _imuseDigital->callback(); + } _sound->updateCD(); // Loop CD Audio if needed + parseEvents(); if (_system->getMillis() >= start_time + msec_delay) break; _system->delayMillis(10); diff --git a/scumm/smush/smush_player.cpp b/scumm/smush/smush_player.cpp index 0002e260b8..002910f41b 100644 --- a/scumm/smush/smush_player.cpp +++ b/scumm/smush/smush_player.cpp @@ -1102,8 +1102,6 @@ void SmushPlayer::parseNextFrame() { if (_insanity) _vm->_sound->processSound(); - - _vm->_imuseDigital->flushTracks(); } void SmushPlayer::setPalette(const byte *palette) { @@ -1270,6 +1268,9 @@ void SmushPlayer::play(const char *filename, int32 offset, int32 startFrame) { if (_vm->_smushVideoShouldFinish || _vm->_quit || _vm->_saveLoadFlag) break; + _vm->_imuseDigital->callback(); + _vm->_imuseDigital->flushTracks(); + lastTime = thisTime; thisTime = _vm->_system->getMillis(); interval = 1000 * (thisTime - lastTime - diff); @@ -1284,7 +1285,7 @@ void SmushPlayer::play(const char *filename, int32 offset, int32 startFrame) { _vm->_system->warpMouse(_warpX, _warpY); _warpNeeded = false; } - + int32 before = _vm->_system->getMillis(); _vm->parseEvents(); _vm->processKbd(true); |