From 7169da6ee18b90dd5f1a24d686fbabef0ef4e66a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Ko=C5=82odziejski?= Date: Thu, 8 Jan 2004 18:25:30 +0000 Subject: [PATCH] jumps are now better handled svn-id: r12260 --- scumm/imuse_digi/dimuse.cpp | 27 +++++++++++++-------------- scumm/imuse_digi/dimuse.h | 7 +++---- scumm/imuse_digi/dimuse_sndmgr.cpp | 17 ++++++++++------- scumm/imuse_digi/dimuse_sndmgr.h | 4 ++-- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/scumm/imuse_digi/dimuse.cpp b/scumm/imuse_digi/dimuse.cpp index c0784485e4a..e7231dd6c22 100644 --- a/scumm/imuse_digi/dimuse.cpp +++ b/scumm/imuse_digi/dimuse.cpp @@ -127,8 +127,12 @@ void IMuseDigital::callback() { byte *data = NULL; int32 result = 0; - if (_track[l].stream->endOfData()) + if (_track[l].stream->endOfData()) { mixer_size *= 2; + } + + if (_track[l].curRegion == -1) + switchToNextRegion(l); int bits = _sound->getBits(_track[l].soundHandle); do { @@ -182,14 +186,6 @@ void IMuseDigital::callback() { } } -int IMuseDigital::checkJumpByRegion(int track, int region) { - int num_jumps = _sound->getNumJumps(_track[track].soundHandle); - for (int l = 0; l < num_jumps; l++) { - return _sound->getJumpDestRegionId(_track[track].soundHandle, l); - } - return -1; -} - void IMuseDigital::switchToNextRegion(int track) { int num_regions = _sound->getNumRegions(_track[track].soundHandle); int num_jumps = _sound->getNumJumps(_track[track].soundHandle); @@ -203,14 +199,17 @@ void IMuseDigital::switchToNextRegion(int track) { return; } - int hookid = _sound->getJumpIdByRegion(_track[track].soundHandle, _track[track].curRegion); + int hookid = _sound->getJumpIdByRegionId(_track[track].soundHandle, _track[track].curRegion); if (hookid == _track[track].curHookId) { - int region = checkJumpByRegion(track, _track[track].curRegion); - if (region != -1) + int region = _sound->getRegionIdByHookId(_track[track].soundHandle, hookid); + if (region != -1) { _track[track].curRegion = region; - _track[track].curHookId = 0; + _track[track].curHookId = 0; + debug(5, "switchToNextRegion-sound(%d) jump to %d region", _track[track].idSound, _track[track].curRegion); + } } + debug(5, "switchToNextRegion-sound(%d) select %d region", _track[track].idSound, _track[track].curRegion); _track[track].regionOffset = 0; } @@ -230,7 +229,7 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, _track[l].started = false; _track[l].soundGroup = soundGroup; _track[l].curHookId = 0; - _track[l].curRegion = 0; + _track[l].curRegion = -1; _track[l].regionOffset = 0; _track[l].trackOffset = 0; _track[l].mod = 0; diff --git a/scumm/imuse_digi/dimuse.h b/scumm/imuse_digi/dimuse.h index c21e04d4704..497fefc82f4 100644 --- a/scumm/imuse_digi/dimuse.h +++ b/scumm/imuse_digi/dimuse.h @@ -76,7 +76,6 @@ private: static void timer_handler(void *refConf); void callback(); void switchToNextRegion(int track); - int checkJumpByRegion(int track, int region); void startSound(int soundId, const char *soundName, int soundType, int soundGroup, AudioStream *input); public: @@ -88,13 +87,13 @@ public: void startVoice(int soundId) { debug(5, "startVoiceBundle(%d)", soundId); startSound(soundId, NULL, IMUSE_BUNDLE, IMUSE_VOICE, NULL); } void startVoice(int soundId, const char *soundName) - { debug(5, "startVoiceBundle(%s)", soundName); startSound(soundId, soundName, IMUSE_BUNDLE, IMUSE_VOICE, NULL); } + { return;}//debug(5, "startVoiceBundle(%s)", soundName); startSound(soundId, soundName, IMUSE_BUNDLE, IMUSE_VOICE, NULL); } void startMusic(int soundId) { debug(5, "startMusicResource(%d)", soundId); startSound(soundId, NULL, IMUSE_RESOURCE, IMUSE_MUSIC, NULL); } void startMusic(const char *soundName, int soundId) - { debug(5, "startMusicBundle(%s)", soundName); startSound(soundId, soundName, IMUSE_BUNDLE, IMUSE_MUSIC, NULL); } + { debug(0, "startMusicBundle(%s)", soundName); startSound(soundId, soundName, IMUSE_BUNDLE, IMUSE_MUSIC, NULL); } void startSfx(int soundId) - { debug(5, "startSfx(%d)", soundId); startSound(soundId, NULL, IMUSE_RESOURCE, IMUSE_SFX, NULL); } + { return;}//debug(5, "startSfx(%d)", soundId); startSound(soundId, NULL, IMUSE_RESOURCE, IMUSE_SFX, NULL); } void startSound(int soundId) { error("MusicEngine::startSound() Should be never called"); } diff --git a/scumm/imuse_digi/dimuse_sndmgr.cpp b/scumm/imuse_digi/dimuse_sndmgr.cpp index a34a9b4450a..18db14f6f61 100644 --- a/scumm/imuse_digi/dimuse_sndmgr.cpp +++ b/scumm/imuse_digi/dimuse_sndmgr.cpp @@ -324,12 +324,12 @@ int ImuseDigiSndMgr::getNumMarkers(soundStruct *soundHandle) { return soundHandle->numMarkers; } -int ImuseDigiSndMgr::getJumpIdByRegion(soundStruct *soundHandle, int number) { +int ImuseDigiSndMgr::getJumpIdByRegionId(soundStruct *soundHandle, int number) { Common::StackLock tmpLock(_mutex); assert(soundHandle && checkForProperHandle(soundHandle)); assert(number >= 0 && number < soundHandle->numRegions); for (int l = 0; l < soundHandle->numJumps; l++) { - if (soundHandle->jump[number].offset == soundHandle->region[l].offset) { + if (soundHandle->jump[l].offset == soundHandle->region[number].offset) { return l; } } @@ -337,13 +337,16 @@ int ImuseDigiSndMgr::getJumpIdByRegion(soundStruct *soundHandle, int number) { return -1; } -int ImuseDigiSndMgr::getJumpDestRegionId(soundStruct *soundHandle, int number) { +int ImuseDigiSndMgr::getRegionIdByHookId(soundStruct *soundHandle, int number) { Common::StackLock tmpLock(_mutex); assert(soundHandle && checkForProperHandle(soundHandle)); - assert(number >= 0 && number < soundHandle->numJumps); - for (int l = 0; l < soundHandle->numRegions; l++) { - if (soundHandle->jump[number].dest == soundHandle->region[l].offset) { - return l; + for (int l = 0; l < soundHandle->numJumps; l++) { + if (soundHandle->jump[l].hookId == number) { + for (int r = 0; r < soundHandle->numRegions; r++) { + if (soundHandle->jump[l].dest == soundHandle->region[r].offset) { + return r; + } + } } } diff --git a/scumm/imuse_digi/dimuse_sndmgr.h b/scumm/imuse_digi/dimuse_sndmgr.h index 32ccdf14660..8e27d5693e2 100644 --- a/scumm/imuse_digi/dimuse_sndmgr.h +++ b/scumm/imuse_digi/dimuse_sndmgr.h @@ -117,8 +117,8 @@ public: int getNumRegions(soundStruct *soundHandle); int getNumJumps(soundStruct *soundHandle); int getNumMarkers(soundStruct *soundHandle); - int getJumpIdByRegion(soundStruct *soundHandle, int number); - int getJumpDestRegionId(soundStruct *soundHandle, int number); + int getJumpIdByRegionId(soundStruct *soundHandle, int number); + int getRegionIdByHookId(soundStruct *soundHandle, int number); int getJumpHookId(soundStruct *soundHandle, int number); int getJumpFade(soundStruct *soundHandle, int number); char *getMarker(soundStruct *soundHandle, int number);