jumps are now better handled

svn-id: r12260
This commit is contained in:
Paweł Kołodziejski 2004-01-08 18:25:30 +00:00
parent d1a80a659b
commit 7169da6ee1
4 changed files with 28 additions and 27 deletions

View File

@ -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;

View File

@ -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"); }

View File

@ -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;
}
}
}
}

View File

@ -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);