Check sound queue for music in HE games.
Avoid extra sound channel. svn-id: r16706
This commit is contained in:
parent
0199bf70fe
commit
bebad400d6
10 changed files with 36 additions and 40 deletions
|
@ -211,7 +211,6 @@ void ScummEngine::akos_decodeData(Actor *a, int frame, uint usemask) {
|
||||||
while (size--) {
|
while (size--) {
|
||||||
if (READ_LE_UINT32(akst) == 0) {
|
if (READ_LE_UINT32(akst) == 0) {
|
||||||
a->cost.seq3[i] = READ_LE_UINT32(akst + 4);
|
a->cost.seq3[i] = READ_LE_UINT32(akst + 4);
|
||||||
akst += 8;
|
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -243,7 +242,6 @@ void ScummEngine::akos_decodeData(Actor *a, int frame, uint usemask) {
|
||||||
if (READ_LE_UINT16(aksf) == start) {
|
if (READ_LE_UINT16(aksf) == start) {
|
||||||
a->cost.seq1[i] = READ_LE_UINT16(aksf + 2);
|
a->cost.seq1[i] = READ_LE_UINT16(aksf + 2);
|
||||||
a->cost.seq2[i] = READ_LE_UINT16(aksf + 4);
|
a->cost.seq2[i] = READ_LE_UINT16(aksf + 4);
|
||||||
aksf += 6;
|
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -268,7 +266,6 @@ void ScummEngine::akos_decodeData(Actor *a, int frame, uint usemask) {
|
||||||
while (size--) {
|
while (size--) {
|
||||||
if (READ_LE_UINT32(akst) == start) {
|
if (READ_LE_UINT32(akst) == start) {
|
||||||
a->cost.seq3[i] = READ_LE_UINT32(akst + 4);
|
a->cost.seq3[i] = READ_LE_UINT32(akst + 4);
|
||||||
akst += 8;
|
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -759,7 +759,7 @@ protected:
|
||||||
void o72_captureWizImage();
|
void o72_captureWizImage();
|
||||||
void o72_getTimer();
|
void o72_getTimer();
|
||||||
void o72_setTimer();
|
void o72_setTimer();
|
||||||
void o72_unknown5A();
|
void o72_getSoundElapsedTimeOfSound();
|
||||||
void o72_startScript();
|
void o72_startScript();
|
||||||
void o72_startObject();
|
void o72_startObject();
|
||||||
void o72_drawObject();
|
void o72_drawObject();
|
||||||
|
|
|
@ -311,7 +311,7 @@ void ScummEngine_v100he::setupOpcodes() {
|
||||||
OPCODE(o6_isScriptRunning),
|
OPCODE(o6_isScriptRunning),
|
||||||
OPCODE(o90_sin),
|
OPCODE(o90_sin),
|
||||||
/* D8 */
|
/* D8 */
|
||||||
OPCODE(o72_unknown5A),
|
OPCODE(o72_getSoundElapsedTimeOfSound),
|
||||||
OPCODE(o6_isSoundRunning),
|
OPCODE(o6_isSoundRunning),
|
||||||
OPCODE(o80_getSoundVar),
|
OPCODE(o80_getSoundVar),
|
||||||
OPCODE(o100_unknown25),
|
OPCODE(o100_unknown25),
|
||||||
|
|
|
@ -155,7 +155,7 @@ void ScummEngine_v72he::setupOpcodes() {
|
||||||
/* 58 */
|
/* 58 */
|
||||||
OPCODE(o72_getTimer),
|
OPCODE(o72_getTimer),
|
||||||
OPCODE(o72_setTimer),
|
OPCODE(o72_setTimer),
|
||||||
OPCODE(o72_unknown5A),
|
OPCODE(o72_getSoundElapsedTimeOfSound),
|
||||||
OPCODE(o6_wordArrayDec),
|
OPCODE(o6_wordArrayDec),
|
||||||
/* 5C */
|
/* 5C */
|
||||||
OPCODE(o6_if),
|
OPCODE(o6_if),
|
||||||
|
@ -714,13 +714,10 @@ void ScummEngine_v72he::o72_setTimer() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScummEngine_v72he::o72_unknown5A() {
|
void ScummEngine_v72he::o72_getSoundElapsedTimeOfSound() {
|
||||||
// Seems to get length of sound already played
|
|
||||||
int snd = pop();
|
int snd = pop();
|
||||||
int r = _mixer->getSoundElapsedTime(_sound->_musicChannelHandle);
|
push(_mixer->getSoundElapsedTimeOfSoundID(snd) * 10);
|
||||||
|
debug(1,"o72_getSoundElapsedTimeOfSound (%d)", snd);
|
||||||
push(r * 10);
|
|
||||||
debug(1,"o72_unknown5A stub (%d)", snd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScummEngine_v72he::o72_startScript() {
|
void ScummEngine_v72he::o72_startScript() {
|
||||||
|
|
|
@ -153,7 +153,7 @@ void ScummEngine_v80he::setupOpcodes() {
|
||||||
/* 58 */
|
/* 58 */
|
||||||
OPCODE(o72_getTimer),
|
OPCODE(o72_getTimer),
|
||||||
OPCODE(o72_setTimer),
|
OPCODE(o72_setTimer),
|
||||||
OPCODE(o72_unknown5A),
|
OPCODE(o72_getSoundElapsedTimeOfSound),
|
||||||
OPCODE(o6_wordArrayDec),
|
OPCODE(o6_wordArrayDec),
|
||||||
/* 5C */
|
/* 5C */
|
||||||
OPCODE(o6_if),
|
OPCODE(o6_if),
|
||||||
|
|
|
@ -153,7 +153,7 @@ void ScummEngine_v90he::setupOpcodes() {
|
||||||
/* 58 */
|
/* 58 */
|
||||||
OPCODE(o72_getTimer),
|
OPCODE(o72_getTimer),
|
||||||
OPCODE(o72_setTimer),
|
OPCODE(o72_setTimer),
|
||||||
OPCODE(o72_unknown5A),
|
OPCODE(o72_getSoundElapsedTimeOfSound),
|
||||||
OPCODE(o6_wordArrayDec),
|
OPCODE(o6_wordArrayDec),
|
||||||
/* 5C */
|
/* 5C */
|
||||||
OPCODE(o6_if),
|
OPCODE(o6_if),
|
||||||
|
|
|
@ -164,7 +164,6 @@ void Sound::playSound(int soundID, int heOffset, int heChannel, int heFlags) {
|
||||||
int size = -1;
|
int size = -1;
|
||||||
int rate;
|
int rate;
|
||||||
byte flags = SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE;
|
byte flags = SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE;
|
||||||
bool music = false;
|
|
||||||
|
|
||||||
if (_vm->_heversion >= 70 && soundID > _vm->_numSounds) {
|
if (_vm->_heversion >= 70 && soundID > _vm->_numSounds) {
|
||||||
debug(0, "playSound #%d", soundID);
|
debug(0, "playSound #%d", soundID);
|
||||||
|
@ -199,16 +198,15 @@ void Sound::playSound(int soundID, int heOffset, int heChannel, int heFlags) {
|
||||||
if (skip > tracks - 1)
|
if (skip > tracks - 1)
|
||||||
skip = 0;
|
skip = 0;
|
||||||
|
|
||||||
musicFile.seek(+28, SEEK_CUR);
|
if (_vm->_heversion >= 80) {
|
||||||
if (musicFile.readUint32LE() == TO_LE_32(MKID('SGEN'))) {
|
// Skip to offsets
|
||||||
|
musicFile.seek(+40, SEEK_CUR);
|
||||||
|
|
||||||
// Skip to correct music header
|
// Skip to correct music header
|
||||||
skip *= 21;
|
skip *= 21;
|
||||||
|
|
||||||
// Skip to offsets
|
|
||||||
musicFile.seek(+8, SEEK_CUR);
|
|
||||||
} else {
|
} else {
|
||||||
// Rewind
|
// Skip to offsets
|
||||||
musicFile.seek(-28, SEEK_CUR);
|
musicFile.seek(+4, SEEK_CUR);
|
||||||
|
|
||||||
// Skip to correct music header
|
// Skip to correct music header
|
||||||
skip *= 25;
|
skip *= 25;
|
||||||
|
@ -229,12 +227,10 @@ void Sound::playSound(int soundID, int heOffset, int heChannel, int heFlags) {
|
||||||
musicFile.read(ptr, size);
|
musicFile.read(ptr, size);
|
||||||
musicFile.close();
|
musicFile.close();
|
||||||
|
|
||||||
|
_vm->_mixer->stopID(_currentMusic);
|
||||||
_currentMusic = soundID;
|
_currentMusic = soundID;
|
||||||
music = true;
|
|
||||||
if (_vm->_heversion == 70) {
|
if (_vm->_heversion == 70) {
|
||||||
// Allocate a sound buffer, copy the data into it, and play
|
_vm->_mixer->playRaw(NULL, ptr, size, 11025, flags, soundID);
|
||||||
_vm->_mixer->stopHandle(_musicChannelHandle);
|
|
||||||
_vm->_mixer->playRaw(&_musicChannelHandle, ptr, size, 11025, flags, soundID);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -299,18 +295,12 @@ void Sound::playSound(int soundID, int heOffset, int heChannel, int heFlags) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Set sound channel based on heChannel
|
// TODO: Set sound channel based on heChannel
|
||||||
if (heFlags & 1)
|
// Set sound looping based on heFlags
|
||||||
flags |= SoundMixer::FLAG_LOOP;
|
|
||||||
|
|
||||||
// Allocate a sound buffer, copy the data into it, and play
|
// Allocate a sound buffer, copy the data into it, and play
|
||||||
sound = (char *)malloc(size);
|
sound = (char *)malloc(size);
|
||||||
memcpy(sound, ptr + heOffset + 8, size);
|
memcpy(sound, ptr + heOffset + 8, size);
|
||||||
|
_vm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID);
|
||||||
if (music == true) {
|
|
||||||
_vm->_mixer->stopHandle(_musicChannelHandle);
|
|
||||||
_vm->_mixer->playRaw(&_musicChannelHandle, sound, size, rate, flags, soundID);
|
|
||||||
} else
|
|
||||||
_vm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID);
|
|
||||||
}
|
}
|
||||||
else if (READ_UINT32(ptr) == MKID('MRAW')) {
|
else if (READ_UINT32(ptr) == MKID('MRAW')) {
|
||||||
// pcm music in 3DO humongous games
|
// pcm music in 3DO humongous games
|
||||||
|
@ -325,9 +315,9 @@ void Sound::playSound(int soundID, int heOffset, int heChannel, int heFlags) {
|
||||||
// Allocate a sound buffer, copy the data into it, and play
|
// Allocate a sound buffer, copy the data into it, and play
|
||||||
sound = (char *)malloc(size);
|
sound = (char *)malloc(size);
|
||||||
memcpy(sound, ptr + 8, size);
|
memcpy(sound, ptr + 8, size);
|
||||||
|
_vm->_mixer->stopID(_currentMusic);
|
||||||
_currentMusic = soundID;
|
_currentMusic = soundID;
|
||||||
_vm->_mixer->stopHandle(_musicChannelHandle);
|
_vm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID);
|
||||||
_vm->_mixer->playRaw(&_musicChannelHandle, sound, size, rate, flags, soundID);
|
|
||||||
}
|
}
|
||||||
// Support for sampled sound effects in Monkey Island 1 and 2
|
// Support for sampled sound effects in Monkey Island 1 and 2
|
||||||
else if (READ_UINT32(ptr) == MKID('SBL ')) {
|
else if (READ_UINT32(ptr) == MKID('SBL ')) {
|
||||||
|
@ -673,7 +663,7 @@ void Sound::startTalkSound(uint32 offset, uint32 b, int mode, PlayingSoundHandle
|
||||||
_sfxFile->seek(offset + 32, SEEK_SET);
|
_sfxFile->seek(offset + 32, SEEK_SET);
|
||||||
|
|
||||||
if (_sfxFile->readUint32LE() == TO_LE_32(MKID('SBNG'))) {
|
if (_sfxFile->readUint32LE() == TO_LE_32(MKID('SBNG'))) {
|
||||||
warning("startTalkSound: Skipped SBNG block");
|
debug(2, "startTalkSound: Skipped SBNG block");
|
||||||
// Skip the SBNG, so we end up at the SDAT chunk
|
// Skip the SBNG, so we end up at the SDAT chunk
|
||||||
extra = _sfxFile->readUint32BE();
|
extra = _sfxFile->readUint32BE();
|
||||||
_sfxFile->seek(extra - 4, SEEK_CUR);
|
_sfxFile->seek(extra - 4, SEEK_CUR);
|
||||||
|
@ -821,8 +811,8 @@ int Sound::isSoundRunning(int sound) const {
|
||||||
// getSoundStatus(), with a -1, will return the
|
// getSoundStatus(), with a -1, will return the
|
||||||
// ID number of the first active music it finds.
|
// ID number of the first active music it finds.
|
||||||
if (_vm->_heversion >= 70 || _currentMusic)
|
if (_vm->_heversion >= 70 || _currentMusic)
|
||||||
return (_musicChannelHandle.isActive());
|
sound = _currentMusic;
|
||||||
else if (_vm->_imuse)
|
if (_vm->_imuse)
|
||||||
return (_vm->_imuse->getSoundStatus(sound));
|
return (_vm->_imuse->getSoundStatus(sound));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,6 @@ protected:
|
||||||
int16 _currentMusic;
|
int16 _currentMusic;
|
||||||
public:
|
public:
|
||||||
PlayingSoundHandle _talkChannelHandle; // Handle of mixer channel actor is talking on
|
PlayingSoundHandle _talkChannelHandle; // Handle of mixer channel actor is talking on
|
||||||
PlayingSoundHandle _musicChannelHandle; // Handle of mixer channel music is on
|
|
||||||
|
|
||||||
bool _soundsPaused;
|
bool _soundsPaused;
|
||||||
byte _sfxMode;
|
byte _sfxMode;
|
||||||
|
|
|
@ -333,6 +333,14 @@ void SoundMixer::setChannelBalance(PlayingSoundHandle handle, int8 balance) {
|
||||||
_channels[index]->setBalance(balance);
|
_channels[index]->setBalance(balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32 SoundMixer::getSoundElapsedTimeOfSoundID(int id) {
|
||||||
|
Common::StackLock lock(_mutex);
|
||||||
|
for (int i = 0; i != NUM_CHANNELS; i++)
|
||||||
|
if (_channels[i] && _channels[i]->getId() == id)
|
||||||
|
return _channels[i]->getElapsedTime();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
uint32 SoundMixer::getSoundElapsedTime(PlayingSoundHandle handle) {
|
uint32 SoundMixer::getSoundElapsedTime(PlayingSoundHandle handle) {
|
||||||
Common::StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
|
|
|
@ -232,6 +232,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void setChannelBalance(PlayingSoundHandle handle, int8 balance);
|
void setChannelBalance(PlayingSoundHandle handle, int8 balance);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get approximation of for how long the Sound ID has been playing.
|
||||||
|
*/
|
||||||
|
uint32 getSoundElapsedTimeOfSoundID(int id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get approximation of for how long the channel has been playing.
|
* Get approximation of for how long the channel has been playing.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue