some changes to digital imuse

svn-id: r11907
This commit is contained in:
Paweł Kołodziejski 2003-12-25 13:56:22 +00:00
parent 1abfe5d63f
commit 35cbe8d3a0
5 changed files with 56 additions and 63 deletions

View File

@ -719,7 +719,7 @@ static uint32 decode12BitsSample(byte *src, byte **dst, uint32 size, bool stereo
void IMuseDigital::timer_handler(void *refCon) {
IMuseDigital *imuseDigital = (IMuseDigital *)refCon;
imuseDigital->mixerCallback();
imuseDigital->callback();
}
IMuseDigital::IMuseDigital(ScummEngine *scumm)
@ -746,7 +746,7 @@ IMuseDigital::~IMuseDigital() {
delete _bundle;
}
void IMuseDigital::mixerCallback() {
void IMuseDigital::callback() {
int l = 0;
if (_pause || !_scumm)
@ -756,7 +756,7 @@ void IMuseDigital::mixerCallback() {
if (_channel[l].used) {
if (_channel[l].toBeRemoved) {
_scumm->_mixer->endStream(_channel[l].handle);
debug(5, "IMuseDigital::mixerCallback(): stop sound: %d", _channel[l].idSound);
debug(0, "IMuseDigital::mixerCallback(): stop sound: %d", _channel[l].idSound);
free(_channel[l].data);
_channel[l].used = false;
@ -784,7 +784,7 @@ void IMuseDigital::mixerCallback() {
}
}
}
debug(5, "Fade: sound(%d), Vol(%d)", _channel[l].idSound, _channel[l].vol / 1000);
debug(0, "Fade: sound(%d), Vol(%d)", _channel[l].idSound, _channel[l].vol / 1000);
}
int32 mixer_size = _channel[l].mixerSize;
@ -808,7 +808,7 @@ void IMuseDigital::mixerCallback() {
}
void IMuseDigital::startSound(int sound) {
debug(5, "IMuseDigital::startSound(%d)", sound);
debug(0, "IMuseDigital::startSound(%d)", sound);
int l, r;
for (l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
@ -965,7 +965,7 @@ void IMuseDigital::startSound(int sound) {
}
void IMuseDigital::stopSound(int sound) {
debug(5, "IMuseDigital::stopSound(%d)", sound);
debug(0, "IMuseDigital::stopSound(%d)", sound);
for (int l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
if ((_channel[l].idSound == sound) && _channel[l].used) {
_channel[l].toBeRemoved = true;
@ -974,7 +974,7 @@ void IMuseDigital::stopSound(int sound) {
}
void IMuseDigital::stopAllSounds() {
debug(5, "IMuseDigital::stopAllSounds");
debug(0, "IMuseDigital::stopAllSounds");
for (int l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
if (_channel[l].used) {
_channel[l].toBeRemoved = true;
@ -992,7 +992,7 @@ void IMuseDigital::pause(bool p) {
pauseBundleMusic(p);
}
void IMuseDigital::parseScriptQues(int a, int b, int c, int d, int e, int f, int g, int h) {
void IMuseDigital::parseScriptCmds(int a, int b, int c, int d, int e, int f, int g, int h) {
int cmd = a;
int sample = b;
int sub_cmd = c;
@ -1004,7 +1004,7 @@ void IMuseDigital::parseScriptQues(int a, int b, int c, int d, int e, int f, int
switch (cmd) {
case 10: // ImuseStopAllSounds
debug(5, "ImuseStopAllSounds()");
debug(0, "ImuseStopAllSounds()");
stopAllSounds();
return;
case 12: // ImuseSetParam
@ -1012,7 +1012,7 @@ void IMuseDigital::parseScriptQues(int a, int b, int c, int d, int e, int f, int
case 0x500: // set priority - could be ignored
return;
case 0x600: // set volume
debug(5, "ImuseSetParam (%x), sample(%d), volume(%d)", sub_cmd, sample, d);
debug(0, "ImuseSetParam (%x), sample(%d), volume(%d)", sub_cmd, sample, d);
for (l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
if ((_channel[l].idSound == sample) && _channel[l].used) {
chan = l;
@ -1028,7 +1028,7 @@ void IMuseDigital::parseScriptQues(int a, int b, int c, int d, int e, int f, int
_channel[chan].volFadeStep = (_channel[chan].volFadeDest - _channel[chan].vol) / (((1000 * _channel[chan].volFadeDelay) / 60) / 40);
return;
case 0x700: // set pan
debug(5, "ImuseSetParam (0x700), sample(%d), pan(%d)", sample, d);
debug(0, "ImuseSetParam (0x700), sample(%d), pan(%d)", sample, d);
for (l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
if ((_channel[l].idSound == sample) && _channel[l].used) {
chan = l;
@ -1036,7 +1036,7 @@ void IMuseDigital::parseScriptQues(int a, int b, int c, int d, int e, int f, int
}
}
if (chan == -1) {
debug(5, "ImuseSetParam (0x700), sample(%d) not exist in channels", sample);
debug(0, "ImuseSetParam (0x700), sample(%d) not exist in channels", sample);
return;
}
_channel[chan].pan = d;
@ -1048,7 +1048,7 @@ void IMuseDigital::parseScriptQues(int a, int b, int c, int d, int e, int f, int
case 14: // ImuseFadeParam
switch (sub_cmd) {
case 0x600: // set new volume with fading
debug(5, "ImuseFadeParam - fade sample(%d), to volume(%d) with 60hz ticks(%d)", sample, d, e);
debug(0, "ImuseFadeParam - fade sample(%d), to volume(%d) with 60hz ticks(%d)", sample, d, e);
if ((_scumm->_gameId == GID_DIG) && (_scumm->_features & GF_DEMO)) {
stopSound(sample);
return;
@ -1060,21 +1060,21 @@ void IMuseDigital::parseScriptQues(int a, int b, int c, int d, int e, int f, int
}
}
if (chan == -1) {
debug(5, "ImuseFadeParam (0x600), sample %d not exist in channels", sample);
debug(0, "ImuseFadeParam (0x600), sample %d not exist in channels", sample);
return;
}
_channel[chan].volFadeDelay = e;
_channel[chan].volFadeDest = d * 1000;
_channel[chan].volFadeStep = (_channel[chan].volFadeDest - _channel[chan].vol) / (((1000 * e) / 60) / 40);
_channel[chan].volFadeUsed = true;
debug(5, "ImuseFadeParam: vol %d, volDest %d, step %d", _channel[chan].vol, d * 1000, _channel[chan].volFadeStep);
debug(0, "ImuseFadeParam: vol %d, volDest %d, step %d", _channel[chan].vol, d * 1000, _channel[chan].volFadeStep);
return;
default:
warning("IMuseDigital::doCommand FadeParam DEFAULT sub command %d", sub_cmd);
return;
}
case 0x1000: // ImuseSetState
debug(5, "ImuseSetState (%d)", b);
debug(0, "ImuseSetState (%d)", b);
if ((_scumm->_gameId == GID_DIG) && (_scumm->_features & GF_DEMO)) {
if (b == 1)
startSound(1);
@ -1095,7 +1095,7 @@ void IMuseDigital::parseScriptQues(int a, int b, int c, int d, int e, int f, int
}
if (_digStateMusicMap[l].room == b) {
int music = _digStateMusicMap[l].table_index;
debug(5, "Play imuse music: %s, %s, %s", _digStateMusicTable[music].name, _digStateMusicTable[music].title, _digStateMusicTable[music].filename);
debug(0, "Play imuse music: %s, %s, %s", _digStateMusicTable[music].name, _digStateMusicTable[music].title, _digStateMusicTable[music].filename);
if ((_digStateMusicTable[music].filename[0] != 0) &&
(strcmp(_digStateMusicTable[_digStateMusicTable[music].unk3].filename, _nameBundleMusic) != 0) ) {
playBundleMusic(_digStateMusicTable[music].filename);
@ -1128,7 +1128,7 @@ void IMuseDigital::parseScriptQues(int a, int b, int c, int d, int e, int f, int
return;
}
if ((_comiStateMusicTable[l].id == b)) {
debug(5, "Play imuse music: %s, %s, %s", _comiStateMusicTable[l].name, _comiStateMusicTable[l].title, _comiStateMusicTable[l].filename);
debug(0, "Play imuse music: %s, %s, %s", _comiStateMusicTable[l].name, _comiStateMusicTable[l].title, _comiStateMusicTable[l].filename);
if (_comiStateMusicTable[l].filename[0] != 0) {
playBundleMusic(_comiStateMusicTable[l].filename);
}
@ -1141,12 +1141,12 @@ void IMuseDigital::parseScriptQues(int a, int b, int c, int d, int e, int f, int
return;
}
if (_ftStateMusicTable[l].index == b) {
debug(5, "Play imuse music: %s, %s", _ftStateMusicTable[l].name, _ftStateMusicTable[l].audioname);
debug(0, "Play imuse music: %s, %s", _ftStateMusicTable[l].name, _ftStateMusicTable[l].audioname);
if (_ftStateMusicTable[l].audioname[0] != 0) {
for (r = 0; r < _scumm->_numAudioNames; r++) {
if (strcmp(_ftStateMusicTable[l].audioname, &_scumm->_audioNames[r * 9]) == 0) {
startSound(r);
parseScriptQues(12, r, 1536, _ftStateMusicTable[l].volume, 0, 0, 0, 0);
parseScriptCmds(12, r, 1536, _ftStateMusicTable[l].volume, 0, 0, 0, 0);
}
}
}
@ -1155,14 +1155,14 @@ void IMuseDigital::parseScriptQues(int a, int b, int c, int d, int e, int f, int
}
return;
case 0x1001: // ImuseSetSequence
debug(5, "ImuseSetSequence (%d)", b);
debug(0, "ImuseSetSequence (%d)", b);
if (_scumm->_gameId == GID_DIG) {
for (l = 0;; l++) {
if (_digSeqMusicTable[l].room == -1) {
return;
}
if ((_digSeqMusicTable[l].room == b)) {
debug(5, "Play imuse music: %s, %s, %s", _digSeqMusicTable[l].name, _digSeqMusicTable[l].title, _digSeqMusicTable[l].filename);
debug(0, "Play imuse music: %s, %s, %s", _digSeqMusicTable[l].name, _digSeqMusicTable[l].title, _digSeqMusicTable[l].filename);
if (_digSeqMusicTable[l].filename[0] != 0) {
playBundleMusic(_digSeqMusicTable[l].filename);
}
@ -1175,7 +1175,7 @@ void IMuseDigital::parseScriptQues(int a, int b, int c, int d, int e, int f, int
return;
}
if ((_comiSeqMusicTable[l].id == b)) {
debug(5, "Play imuse music: %s, %s, %s", _comiSeqMusicTable[l].name, _comiSeqMusicTable[l].title, _comiSeqMusicTable[l].filename);
debug(0, "Play imuse music: %s, %s, %s", _comiSeqMusicTable[l].name, _comiSeqMusicTable[l].title, _comiSeqMusicTable[l].filename);
if (_comiSeqMusicTable[l].filename[0] != 0) {
playBundleMusic(_comiSeqMusicTable[l].filename);
}
@ -1188,12 +1188,12 @@ void IMuseDigital::parseScriptQues(int a, int b, int c, int d, int e, int f, int
return;
}
if (_ftSeqMusicTable[l].index == b) {
debug(5, "Play imuse music: %s, %s", _ftSeqMusicTable[l].name, _ftSeqMusicTable[l].audioname);
debug(0, "Play imuse music: %s, %s", _ftSeqMusicTable[l].name, _ftSeqMusicTable[l].audioname);
if (_ftSeqMusicTable[l].audioname[0] != 0) {
for (r = 0; r < _scumm->_numAudioNames; r++) {
if (strcmp(_ftSeqMusicTable[l].audioname, &_scumm->_audioNames[r * 9]) == 0) {
startSound(r);
parseScriptQues(12, r, 1536, _ftSeqMusicTable[l].volume, 0, 0, 0, 0);
parseScriptCmds(12, r, 1536, _ftSeqMusicTable[l].volume, 0, 0, 0, 0);
}
}
}
@ -1202,19 +1202,19 @@ void IMuseDigital::parseScriptQues(int a, int b, int c, int d, int e, int f, int
}
return;
case 0x1002: // ImuseSetCuePoint
debug(5, "ImuseSetCuePoint (%d)", b);
debug(0, "ImuseSetCuePoint (%d)", b);
return;
case 0x1003: // ImuseSetAttribute
debug(5, "ImuseSetAttribute (%d, %d)", b, c);
debug(0, "ImuseSetAttribute (%d, %d)", b, c);
return;
case 0x2000: // ImuseSetMasterSFXVolume
debug(5, "ImuseSetMasterSFXVolume (%d)", b);
debug(0, "ImuseSetMasterSFXVolume (%d)", b);
return;
case 0x2001: // ImuseSetMasterVoiceVolume
debug(5, "ImuseSetMasterVoiceVolume (%d)", b);
debug(0, "ImuseSetMasterVoiceVolume (%d)", b);
return;
case 0x2002: // ImuseSetMasterMusicVolume
debug(5, "ImuseSetMasterMusicVolume (%d)", b);
debug(0, "ImuseSetMasterMusicVolume (%d)", b);
return;
default:
warning("IMuseDigital::doCommand DEFAULT command %d", cmd);
@ -1222,7 +1222,7 @@ void IMuseDigital::parseScriptQues(int a, int b, int c, int d, int e, int f, int
}
int IMuseDigital::getSoundStatus(int sound) const {
debug(5, "IMuseDigital::getSoundStatus(%d)", sound);
debug(0, "IMuseDigital::getSoundStatus(%d)", sound);
for (int l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
if ((_channel[l].idSound == sound) && _channel[l].used) {
return 1;

View File

@ -95,7 +95,7 @@ private:
bool _pause;
static void timer_handler(void *refConf);
void mixerCallback();
void callback();
//
// Bundle music
@ -141,7 +141,7 @@ public:
void stopSound(int sound);
void stopAllSounds();
void pause(bool pause);
void parseScriptQues(int a, int b, int c, int d, int e, int f, int g, int h);
void parseScriptCmds(int a, int b, int c, int d, int e, int f, int g, int h);
int getSoundStatus(int sound) const;
};

View File

@ -2399,9 +2399,6 @@ void ScummEngine_v6::o6_kernelSetFunctions() {
grabCursor(args[1], args[2], args[3], args[4]);
break;
case 6: {
// if (_imuseDigital) {
// _imuseDigital->stopAllSounds();
// }
uint32 speed;
assert(getStringAddressVar(VAR_VIDEONAME));
if (strcmp((char *)getStringAddressVar(VAR_VIDEONAME), "sq3.san") == 0)

View File

@ -5945,7 +5945,7 @@ bool Insane::smlayer_startSound2(int32 sound) {
}
void Insane::smlayer_soundSetPan(int32 soundid, int32 pan) {
_scumm->_imuseDigital->parseScriptQues(12, soundid, 0x700, pan, 0, 0, 0, 0);
_scumm->_imuseDigital->parseScriptCmds(12, soundid, 0x700, pan, 0, 0, 0, 0);
}
void Insane::smlayer_soundSetPriority(int32 sound, int32 priority) {

View File

@ -80,7 +80,10 @@ void Sound::processSoundQues() {
int i = 0, d, num;
int data[16];
processSfxQueues();
// processSfxQueues();
if (_scumm->_features & GF_DIGI_IMUSE)
return;
while (_soundQue2Pos) {
d = _soundQue2[--_soundQue2Pos];
@ -104,11 +107,7 @@ void Sound::processSoundQues() {
data[0] >> 8, data[0] & 0xFF,
data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
if (_scumm->_features & GF_DIGI_IMUSE) {
if (_scumm->_imuseDigital)
_scumm->_imuseDigital->parseScriptQues(data[0], data[1], data[2], data[3], data[4],
data[5], data[6], data[7]);
} else if (_scumm->_imuse) {
if (_scumm->_imuse) {
_scumm->VAR(_scumm->VAR_SOUNDRESULT) = (short)_scumm->_imuse->doCommand (num, data);
}
}
@ -129,14 +128,11 @@ void Sound::playSound(int soundID) {
return;
}
if (READ_UINT32(ptr) == MKID('iMUS')){
assert(_scumm->_musicEngine);
_scumm->_musicEngine->startSound(soundID);
}
else if (READ_UINT32(ptr) == MKID('Crea')) {
assert(_scumm->_musicEngine);
if (_scumm->_features & GF_DIGI_IMUSE) {
_scumm->_musicEngine->startSound(soundID);
return;
}
// Support for SFX in Monkey Island 1, Mac version
// This is rather hackish right now, but works OK. SFX are not sounding
// 100% correct, though, not sure right now what is causing this.
@ -594,6 +590,9 @@ bool Sound::isMouthSyncOff(uint pos) {
int Sound::isSoundRunning(int sound) const {
if (_scumm->_imuseDigital)
return (_scumm->_imuseDigital->getSoundStatus(sound) != 0);
if (sound == _currentCDSound)
return pollCD();
@ -636,15 +635,15 @@ bool Sound::isSoundInUse(int sound) const {
if (sound == _currentCDSound)
return pollCD() != 0;
if (_scumm->_imuseDigital)
return (_scumm->_imuseDigital->getSoundStatus(sound) != 0);
if (isSoundInQueue(sound))
return true;
if (!_scumm->isResourceLoaded(rtSound, sound))
return false;
if (_scumm->_imuseDigital)
return (_scumm->_imuseDigital->getSoundStatus(sound) != 0);
if (_scumm->_imuse)
return _scumm->_imuse->get_sound_active(sound);
@ -687,7 +686,9 @@ void Sound::stopSound(int a) {
stopCDTimer();
}
_scumm->_mixer->stopID(a);
if (!(_scumm->_features & GF_DIGI_IMUSE))
_scumm->_mixer->stopID(a);
if (_scumm->_musicEngine)
_scumm->_musicEngine->stopSound(a);
@ -725,19 +726,14 @@ void Sound::stopAllSounds() {
void Sound::soundKludge(int *list, int num) {
int i;
if (list[0] == -1) {
processSoundQues();
if (_scumm->_imuseDigital) {
_scumm->_imuseDigital->parseScriptCmds(list[0], list[1], list[2], list[3], list[4],
list[5], list[6], list[7]);
return;
}
if ((_soundQuePos + num) > 0x100) {
// FIXME: temporarily changed this to an error to help track down what
// is causing the sound queue overflows(in particular, to figure out
// the room/script/offset where the bug occurs). Please report your
// findings to Fingolfin.
// Reverting to warning for now room 11, script 2016 offset 0x7Af9 was
// what it error'd on here
warning("Sound queue buffer overflow (%d + %d = %d)", _soundQuePos, num, _soundQuePos+num);
if (list[0] == -1) {
processSoundQues();
return;
}