diff options
author | Paweł Kołodziejski | 2008-01-15 21:35:03 +0000 |
---|---|---|
committer | Paweł Kołodziejski | 2008-01-15 21:35:03 +0000 |
commit | 6bb2f4447240bf3fe5fa16a8945ecd60866f2625 (patch) | |
tree | 3de3886de535bf438e04473da9bef0999ea0daa0 /engines/scumm/imuse_digi | |
parent | 8935c574d547903b0c8d760d406873a3d8a36228 (diff) | |
download | scummvm-rg350-6bb2f4447240bf3fe5fa16a8945ecd60866f2625.tar.gz scummvm-rg350-6bb2f4447240bf3fe5fa16a8945ecd60866f2625.tar.bz2 scummvm-rg350-6bb2f4447240bf3fe5fa16a8945ecd60866f2625.zip |
implement dimuse transition 12, not tested yet
svn-id: r30503
Diffstat (limited to 'engines/scumm/imuse_digi')
-rw-r--r-- | engines/scumm/imuse_digi/dimuse.cpp | 19 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse.h | 11 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse_music.cpp | 7 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse_sndmgr.cpp | 16 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse_sndmgr.h | 1 | ||||
-rw-r--r-- | engines/scumm/imuse_digi/dimuse_track.cpp | 8 |
6 files changed, 60 insertions, 2 deletions
diff --git a/engines/scumm/imuse_digi/dimuse.cpp b/engines/scumm/imuse_digi/dimuse.cpp index 1874546259..98b85321d2 100644 --- a/engines/scumm/imuse_digi/dimuse.cpp +++ b/engines/scumm/imuse_digi/dimuse.cpp @@ -101,6 +101,7 @@ void IMuseDigital::resetState() { memset(_attributes, 0, sizeof(_attributes)); _nextSeqToPlay = 0; _stopingSequence = false; + _triggerUsed = false; } void IMuseDigital::saveOrLoad(Serializer *ser) { @@ -364,6 +365,24 @@ void IMuseDigital::switchToNextRegion(Track *track) { } ImuseDigiSndMgr::SoundDesc *soundDesc = track->soundDesc; + if (_triggerUsed && track->soundDesc->numMarkers) { + if (_sound->checkForTriggerByRegionAndMarker(soundDesc, track->curRegion, _triggerParams.marker)) { + debug(5, "trigger %s reached, switchToNextRegion(track:%d)", track->trackId, _triggerParams.marker); + debug(5, "exit current region, switchToNextRegion(track:%d)", track->trackId); + Track *fadeTrack = cloneToFadeOutTrack(track, _triggerParams.fadeOutDelay); + if (fadeTrack) { + fadeTrack->dataOffset = _sound->getRegionOffset(fadeTrack->soundDesc, fadeTrack->curRegion); + fadeTrack->regionOffset = 0; + debug(5, "switchToNextRegion-sound(%d) select region %d, curHookId: %d", fadeTrack->soundId, fadeTrack->curRegion, fadeTrack->curHookId); + fadeTrack->curHookId = 0; + } + flushTrack(track); + startMusic(_triggerParams.filename, _triggerParams.soundId, _triggerParams.hookId, _triggerParams.volume); + _triggerUsed = false; + return; + } + } + int jumpId = _sound->getJumpIdByRegionAndHookId(soundDesc, track->curRegion, track->curHookId); if (jumpId == -1) jumpId = _sound->getJumpIdByRegionAndHookId(soundDesc, track->curRegion, 0); diff --git a/engines/scumm/imuse_digi/dimuse.h b/engines/scumm/imuse_digi/dimuse.h index 8eebeb9404..c35f351c60 100644 --- a/engines/scumm/imuse_digi/dimuse.h +++ b/engines/scumm/imuse_digi/dimuse.h @@ -117,6 +117,16 @@ private: } }; + struct TriggerParams { + char marker[10]; + int fadeOutDelay; + char filename[13]; + int soundId; + int hookId; + int volume; + } _triggerParams; + bool _triggerUsed; + Track *_track[MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS]; Common::Mutex _mutex; @@ -150,6 +160,7 @@ private: int getSoundIdByName(const char *soundName); void fadeOutMusic(int fadeDelay); void fadeOutMusicAndStartNew(int fadeDelay, const char *filename, int soundId); + void setTrigger(TriggerParams *trigger); void setHookIdForMusic(int hookId); Track *cloneToFadeOutTrack(Track *track, int fadeDelay); diff --git a/engines/scumm/imuse_digi/dimuse_music.cpp b/engines/scumm/imuse_digi/dimuse_music.cpp index 08c7fe6ae0..ca42633925 100644 --- a/engines/scumm/imuse_digi/dimuse_music.cpp +++ b/engines/scumm/imuse_digi/dimuse_music.cpp @@ -328,8 +328,11 @@ void IMuseDigital::playComiMusic(const char *songName, const imuseComiTable *tab (table->attribPos == _comiStateMusicTable[_curMusicState].attribPos)) { fadeOutMusicAndStartNew(table->fadeOutDelay, table->filename, table->soundId); } else if (table->transitionType == 12) { - fadeOutMusic(table->fadeOutDelay); - startMusic(table->filename, table->soundId, table->hookId, 127); + TriggerParams trigger; + strcpy(trigger.marker, "exit"); trigger.fadeOutDelay = table->fadeOutDelay; + strcpy(trigger.filename, table->filename); trigger.soundId = table->soundId; + trigger.hookId = table->hookId; trigger.volume = 127; + setTrigger(&trigger); } else { fadeOutMusic(table->fadeOutDelay); startMusic(table->filename, table->soundId, hookId, 127); diff --git a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp index 35eb421be6..1ef23e915d 100644 --- a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp +++ b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp @@ -567,6 +567,22 @@ int ImuseDigiSndMgr::getJumpIdByRegionAndHookId(SoundDesc *soundDesc, int region return -1; } +bool ImuseDigiSndMgr::checkForTriggerByRegionAndMarker(SoundDesc *soundDesc, int region, const char *marker) { + debug(5, "checkForTriggerByRegionAndMarker() region:%d, marker:%s", region, marker); + assert(checkForProperHandle(soundDesc)); + assert(region >= 0 && region < soundDesc->numRegions); + assert(marker); + int32 offset = soundDesc->region[region].offset; + for (int l = 0; l < soundDesc->numMarkers; l++) { + if (offset == soundDesc->marker[l].pos) { + if (!stricmp(soundDesc->marker[l].ptr, marker)) + return true; + } + } + + return false; +} + void ImuseDigiSndMgr::getSyncSizeAndPtrById(SoundDesc *soundDesc, int number, int32 &sync_size, byte **sync_ptr) { assert(checkForProperHandle(soundDesc)); assert(number >= 0); diff --git a/engines/scumm/imuse_digi/dimuse_sndmgr.h b/engines/scumm/imuse_digi/dimuse_sndmgr.h index 87d59095c2..099698b2a3 100644 --- a/engines/scumm/imuse_digi/dimuse_sndmgr.h +++ b/engines/scumm/imuse_digi/dimuse_sndmgr.h @@ -142,6 +142,7 @@ public: int getNumJumps(SoundDesc *soundDesc); int getRegionOffset(SoundDesc *soundDesc, int region); int getJumpIdByRegionAndHookId(SoundDesc *soundDesc, int region, int hookId); + bool checkForTriggerByRegionAndMarker(SoundDesc *soundDesc, int region, const char *marker); int getRegionIdByJumpId(SoundDesc *soundDesc, int jumpId); int getJumpHookId(SoundDesc *soundDesc, int number); int getJumpFade(SoundDesc *soundDesc, int number); diff --git a/engines/scumm/imuse_digi/dimuse_track.cpp b/engines/scumm/imuse_digi/dimuse_track.cpp index 98642b7d59..9176fdc696 100644 --- a/engines/scumm/imuse_digi/dimuse_track.cpp +++ b/engines/scumm/imuse_digi/dimuse_track.cpp @@ -322,6 +322,14 @@ void IMuseDigital::setHookIdForMusic(int hookId) { } } +void IMuseDigital::setTrigger(TriggerParams *trigger) { + Common::StackLock lock(_mutex, "IMuseDigital::setTrigger()"); + debug(5, "IMuseDigital::setTrigger"); + + memcpy(&_triggerParams, trigger, sizeof(TriggerParams)); + _triggerUsed = true; +} + IMuseDigital::Track *IMuseDigital::cloneToFadeOutTrack(Track *track, int fadeDelay) { assert(track); Track *fadeTrack; |