mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-30 05:34:00 +00:00
SCUMM HE: Update sound flags and queue, for new settings.
This commit is contained in:
parent
6b07163600
commit
87c5540c2a
@ -121,13 +121,24 @@ class ScummEngine_v70he : public ScummEngine_v60he {
|
||||
friend class ResExtractor;
|
||||
|
||||
protected:
|
||||
enum HESndFlags {
|
||||
HE_SND_LOOP = 1,
|
||||
HE_SND_APPEND = 2,
|
||||
HE_SND_SOFT_SOUND = 4,
|
||||
HE_SND_QUICK_START = 8,
|
||||
HE_SND_OFFSET = 16,
|
||||
HE_SND_VOL = 32,
|
||||
HE_SND_FREQUENCY = 64,
|
||||
HE_SND_PAN = 128
|
||||
};
|
||||
|
||||
ResExtractor *_resExtractor;
|
||||
|
||||
byte *_heV7DiskOffsets;
|
||||
byte *_heV7RoomOffsets;
|
||||
uint32 *_heV7RoomIntOffsets;
|
||||
|
||||
int32 _heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags, _heSndSoundFreq;
|
||||
int32 _heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags, _heSndSoundFreq, _heSndPan, _heSndVol;
|
||||
|
||||
int _numStoredFlObjects;
|
||||
ObjectData *_storedFlObjects;
|
||||
|
@ -1750,7 +1750,7 @@ void ScummEngine_v100he::o100_soundOps() {
|
||||
|
||||
switch (subOp) {
|
||||
case 6: // SO_AT
|
||||
_heSndFlags |= 16;
|
||||
_heSndFlags |= HE_SND_OFFSET;
|
||||
_heSndOffset = pop();
|
||||
break;
|
||||
case 47: // SO_LOAD
|
||||
@ -1760,7 +1760,7 @@ void ScummEngine_v100he::o100_soundOps() {
|
||||
debug(0, "Load sound %d from file %s\n", _heSndSoundId, filename);
|
||||
break;
|
||||
case 55: // SO_NOW
|
||||
_heSndFlags |= 8;
|
||||
_heSndFlags |= HE_SND_QUICK_START;
|
||||
break;
|
||||
case 83: // SO_VARIABLE
|
||||
value = pop();
|
||||
@ -1769,20 +1769,20 @@ void ScummEngine_v100he::o100_soundOps() {
|
||||
((SoundHE *)_sound)->setSoundVar(_heSndSoundId, var, value);
|
||||
break;
|
||||
case 92: // SO_END
|
||||
_sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags);
|
||||
_sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags, _heSndSoundFreq, _heSndPan, _heSndVol);
|
||||
break;
|
||||
case 128: // SO_SOUND_ADD
|
||||
_heSndFlags |= 2;
|
||||
_heSndFlags |= HE_SND_APPEND;
|
||||
break;
|
||||
case 129: // SO_SOUND_CHANNEL
|
||||
_heSndChannel = pop();
|
||||
break;
|
||||
case 130: // SO_SOUND_FREQUENCY
|
||||
_heSndFlags |= 64;
|
||||
pop();
|
||||
_heSndFlags |= HE_SND_FREQUENCY;
|
||||
_heSndSoundFreq = pop();
|
||||
break;
|
||||
case 131: // SO_SOUND_LOOPING
|
||||
_heSndFlags |= 1;
|
||||
_heSndFlags |= HE_SND_LOOP;
|
||||
break;
|
||||
case 132: // SO_SOUND_MODIFY
|
||||
case 134: // SO_SOUND_START
|
||||
@ -1793,15 +1793,15 @@ void ScummEngine_v100he::o100_soundOps() {
|
||||
_heSndFlags = 0;
|
||||
break;
|
||||
case 133: // SO_SOUND_PAN
|
||||
_heSndFlags |= 128;
|
||||
pop();
|
||||
_heSndFlags |= HE_SND_PAN;
|
||||
_heSndPan = pop();
|
||||
break;
|
||||
case 135: // SO_SOUND_SOFT
|
||||
_heSndFlags |= 4;
|
||||
_heSndFlags |= HE_SND_SOFT_SOUND;
|
||||
break;
|
||||
case 136: // SO_SOUND_VOLUME
|
||||
_heSndFlags |= 32;
|
||||
pop();
|
||||
_heSndFlags |= HE_SND_VOL;
|
||||
_heSndVol = pop();
|
||||
break;
|
||||
default:
|
||||
error("o100_soundOps invalid case %d", subOp);
|
||||
|
@ -59,7 +59,7 @@ void ScummEngine_v70he::o70_soundOps() {
|
||||
|
||||
switch (subOp) {
|
||||
case 9: // SO_SOUND_SOFT?
|
||||
_heSndFlags |= 4;
|
||||
_heSndFlags |= HE_SND_SOFT_SOUND;
|
||||
break;
|
||||
case 23: // SO_VARIABLE
|
||||
value = pop();
|
||||
@ -70,13 +70,13 @@ void ScummEngine_v70he::o70_soundOps() {
|
||||
case 25: // SO_SOUND_VOLUME
|
||||
value = pop();
|
||||
_heSndSoundId = pop();
|
||||
_sound->addSoundToQueue(_heSndSoundId, 0, 0, 8);
|
||||
_sound->addSoundToQueue(_heSndSoundId, 0, 0, HE_SND_VOL, 0, 0, value);
|
||||
break;
|
||||
case 56: // SO_NOW
|
||||
_heSndFlags |= 16;
|
||||
_heSndFlags |= HE_SND_QUICK_START;
|
||||
break;
|
||||
case 164: // SO_SOUND_ADD
|
||||
_heSndFlags |= 2;
|
||||
_heSndFlags |= HE_SND_APPEND;
|
||||
break;
|
||||
case 222:
|
||||
// WORKAROUND: For errors in room script 240 (room 4) of maze
|
||||
@ -97,10 +97,10 @@ void ScummEngine_v70he::o70_soundOps() {
|
||||
_heSndChannel = VAR(VAR_SOUND_CHANNEL);
|
||||
break;
|
||||
case 245: // SO_SOUND_LOOPING
|
||||
_heSndFlags |= 1;
|
||||
_heSndFlags |= HE_SND_LOOP;
|
||||
break;
|
||||
case 255: // SO_END
|
||||
_sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags);
|
||||
_sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags, _heSndSoundFreq);
|
||||
_heSndFlags = 0;
|
||||
break;
|
||||
|
||||
|
@ -59,31 +59,29 @@ SoundHE::~SoundHE() {
|
||||
delete[] _heSoundChannels;
|
||||
}
|
||||
|
||||
void SoundHE::addSoundToQueue(int sound, int heOffset, int heChannel, int heFlags) {
|
||||
void SoundHE::addSoundToQueue(int sound, int heOffset, int heChannel, int heFlags, int heFreq, int hePan, int heVol) {
|
||||
if (_vm->VAR_LAST_SOUND != 0xFF)
|
||||
_vm->VAR(_vm->VAR_LAST_SOUND) = sound;
|
||||
|
||||
if ((_vm->_game.heversion <= 99 && (heFlags & 16)) || (_vm->_game.heversion >= 100 && (heFlags & 8))) {
|
||||
playHESound(sound, heOffset, heChannel, heFlags);
|
||||
return;
|
||||
if (heFlags & 8) {
|
||||
playHESound(sound, heOffset, heChannel, heFlags, heFreq, hePan, heVol);
|
||||
} else {
|
||||
|
||||
Sound::addSoundToQueue(sound, heOffset, heChannel, heFlags);
|
||||
Sound::addSoundToQueue(sound, heOffset, heChannel, heFlags, heFreq, hePan, heVol);
|
||||
}
|
||||
}
|
||||
|
||||
void SoundHE::addSoundToQueue2(int sound, int heOffset, int heChannel, int heFlags) {
|
||||
void SoundHE::addSoundToQueue2(int sound, int heOffset, int heChannel, int heFlags, int heFreq, int hePan, int heVol) {
|
||||
int i = _soundQue2Pos;
|
||||
while (i--) {
|
||||
if (_soundQue2[i].sound == sound && !(heFlags & 2))
|
||||
return;
|
||||
}
|
||||
|
||||
Sound::addSoundToQueue2(sound, heOffset, heChannel, heFlags);
|
||||
Sound::addSoundToQueue2(sound, heOffset, heChannel, heFlags, heFreq, hePan, heVol);
|
||||
}
|
||||
|
||||
void SoundHE::processSoundQueues() {
|
||||
int snd, heOffset, heChannel, heFlags;
|
||||
int snd, heOffset, heChannel, heFlags, heFreq, hePan, heVol;
|
||||
|
||||
if (_vm->_game.heversion >= 72) {
|
||||
for (int i = 0; i <_soundQue2Pos; i++) {
|
||||
@ -91,8 +89,11 @@ void SoundHE::processSoundQueues() {
|
||||
heOffset = _soundQue2[i].offset;
|
||||
heChannel = _soundQue2[i].channel;
|
||||
heFlags = _soundQue2[i].flags;
|
||||
heFreq = _soundQue2[_soundQue2Pos].freq;
|
||||
hePan = _soundQue2[_soundQue2Pos].pan;
|
||||
heVol = _soundQue2[_soundQue2Pos].vol;
|
||||
if (snd)
|
||||
playHESound(snd, heOffset, heChannel, heFlags);
|
||||
playHESound(snd, heOffset, heChannel, heFlags, heFreq, hePan, heVol);
|
||||
}
|
||||
_soundQue2Pos = 0;
|
||||
} else {
|
||||
@ -102,8 +103,11 @@ void SoundHE::processSoundQueues() {
|
||||
heOffset = _soundQue2[_soundQue2Pos].offset;
|
||||
heChannel = _soundQue2[_soundQue2Pos].channel;
|
||||
heFlags = _soundQue2[_soundQue2Pos].flags;
|
||||
heFreq = _soundQue2[_soundQue2Pos].freq;
|
||||
hePan = _soundQue2[_soundQue2Pos].pan;
|
||||
heVol = _soundQue2[_soundQue2Pos].vol;
|
||||
if (snd)
|
||||
playHESound(snd, heOffset, heChannel, heFlags);
|
||||
playHESound(snd, heOffset, heChannel, heFlags, heFreq, hePan, heVol);
|
||||
}
|
||||
}
|
||||
|
||||
@ -527,7 +531,7 @@ byte *findSoundTag(uint32 tag, byte *ptr) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags) {
|
||||
void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags, int heFreq, int hePan, int heVol) {
|
||||
Audio::RewindableAudioStream *stream = 0;
|
||||
byte *ptr, *spoolPtr;
|
||||
int size = -1;
|
||||
|
@ -61,8 +61,8 @@ public:
|
||||
SoundHE(ScummEngine *parent, Audio::Mixer *mixer);
|
||||
~SoundHE();
|
||||
|
||||
virtual void addSoundToQueue(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);
|
||||
virtual void addSoundToQueue2(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);
|
||||
virtual void addSoundToQueue(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0, int heFreq = 0, int hePan = 0, int heVol = 0);
|
||||
virtual void addSoundToQueue2(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0, int heFreq = 0, int hePan = 0, int heVol = 0);
|
||||
|
||||
virtual int isSoundRunning(int sound) const;
|
||||
virtual void stopSound(int sound);
|
||||
@ -75,7 +75,7 @@ public:
|
||||
int getSoundPos(int sound);
|
||||
int getSoundVar(int sound, int var);
|
||||
void setSoundVar(int sound, int var, int val);
|
||||
void playHESound(int soundID, int heOffset, int heChannel, int heFlags);
|
||||
void playHESound(int soundID, int heOffset, int heChannel, int heFlags, int heFreq, int hePan, int heVol);
|
||||
void processSoundCode();
|
||||
void processSoundOpcodes(int sound, byte *codePtr, int *soundVars);
|
||||
void setOverrideFreq(int freq);
|
||||
|
@ -805,6 +805,8 @@ ScummEngine_v70he::ScummEngine_v70he(OSystem *syst, const DetectorResult &dr)
|
||||
_heSndChannel = 0;
|
||||
_heSndFlags = 0;
|
||||
_heSndSoundFreq = 0;
|
||||
_heSndPan = 0;
|
||||
_heSndVol = 0;
|
||||
|
||||
_numStoredFlObjects = 0;
|
||||
_storedFlObjects = (ObjectData *)calloc(100, sizeof(ObjectData));
|
||||
|
@ -110,7 +110,7 @@ Sound::~Sound() {
|
||||
delete _talkChannelHandle;
|
||||
}
|
||||
|
||||
void Sound::addSoundToQueue(int sound, int heOffset, int heChannel, int heFlags) {
|
||||
void Sound::addSoundToQueue(int sound, int heOffset, int heChannel, int heFlags, int heFreq, int hePan, int heVol) {
|
||||
if (_vm->VAR_LAST_SOUND != 0xFF)
|
||||
_vm->VAR(_vm->VAR_LAST_SOUND) = sound;
|
||||
_lastSound = sound;
|
||||
@ -119,15 +119,18 @@ void Sound::addSoundToQueue(int sound, int heOffset, int heChannel, int heFlags)
|
||||
if (sound <= _vm->_numSounds)
|
||||
_vm->ensureResourceLoaded(rtSound, sound);
|
||||
|
||||
addSoundToQueue2(sound, heOffset, heChannel, heFlags);
|
||||
addSoundToQueue2(sound, heOffset, heChannel, heFlags, heFreq, hePan, heVol);
|
||||
}
|
||||
|
||||
void Sound::addSoundToQueue2(int sound, int heOffset, int heChannel, int heFlags) {
|
||||
void Sound::addSoundToQueue2(int sound, int heOffset, int heChannel, int heFlags, int heFreq, int hePan, int heVol) {
|
||||
assert(_soundQue2Pos < ARRAYSIZE(_soundQue2));
|
||||
_soundQue2[_soundQue2Pos].sound = sound;
|
||||
_soundQue2[_soundQue2Pos].offset = heOffset;
|
||||
_soundQue2[_soundQue2Pos].channel = heChannel;
|
||||
_soundQue2[_soundQue2Pos].flags = heFlags;
|
||||
_soundQue2[_soundQue2Pos].freq = heFreq;
|
||||
_soundQue2[_soundQue2Pos].pan = hePan;
|
||||
_soundQue2[_soundQue2Pos].vol = heVol;
|
||||
_soundQue2Pos++;
|
||||
}
|
||||
|
||||
@ -806,6 +809,9 @@ void Sound::stopSound(int sound) {
|
||||
_soundQue2[i].offset = 0;
|
||||
_soundQue2[i].channel = 0;
|
||||
_soundQue2[i].flags = 0;
|
||||
_soundQue2[i].freq = 0;
|
||||
_soundQue2[i].pan = 0;
|
||||
_soundQue2[i].vol = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +67,9 @@ protected:
|
||||
int32 offset;
|
||||
int16 channel;
|
||||
int16 flags;
|
||||
int16 freq;
|
||||
int16 pan;
|
||||
int16 vol;
|
||||
} _soundQue2[10];
|
||||
|
||||
Common::String _sfxFilename;
|
||||
@ -101,8 +104,8 @@ public:
|
||||
public:
|
||||
Sound(ScummEngine *parent, Audio::Mixer *mixer);
|
||||
virtual ~Sound();
|
||||
virtual void addSoundToQueue(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);
|
||||
virtual void addSoundToQueue2(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);
|
||||
virtual void addSoundToQueue(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0, int heFreq = 0, int hePan = 0, int heVol = 0);
|
||||
virtual void addSoundToQueue2(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0, int heFreq = 0, int hePan = 0, int heVol = 0);
|
||||
void processSound();
|
||||
|
||||
void playSound(int soundID);
|
||||
|
Loading…
Reference in New Issue
Block a user