SCUMM HE: Update sound flags and queue, for new settings.

This commit is contained in:
Kirben 2016-06-22 11:45:44 +10:00
parent 6b07163600
commit 87c5540c2a
8 changed files with 65 additions and 39 deletions

View File

@ -121,13 +121,24 @@ class ScummEngine_v70he : public ScummEngine_v60he {
friend class ResExtractor; friend class ResExtractor;
protected: 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; ResExtractor *_resExtractor;
byte *_heV7DiskOffsets; byte *_heV7DiskOffsets;
byte *_heV7RoomOffsets; byte *_heV7RoomOffsets;
uint32 *_heV7RoomIntOffsets; uint32 *_heV7RoomIntOffsets;
int32 _heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags, _heSndSoundFreq; int32 _heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags, _heSndSoundFreq, _heSndPan, _heSndVol;
int _numStoredFlObjects; int _numStoredFlObjects;
ObjectData *_storedFlObjects; ObjectData *_storedFlObjects;

View File

@ -1750,7 +1750,7 @@ void ScummEngine_v100he::o100_soundOps() {
switch (subOp) { switch (subOp) {
case 6: // SO_AT case 6: // SO_AT
_heSndFlags |= 16; _heSndFlags |= HE_SND_OFFSET;
_heSndOffset = pop(); _heSndOffset = pop();
break; break;
case 47: // SO_LOAD case 47: // SO_LOAD
@ -1760,7 +1760,7 @@ void ScummEngine_v100he::o100_soundOps() {
debug(0, "Load sound %d from file %s\n", _heSndSoundId, filename); debug(0, "Load sound %d from file %s\n", _heSndSoundId, filename);
break; break;
case 55: // SO_NOW case 55: // SO_NOW
_heSndFlags |= 8; _heSndFlags |= HE_SND_QUICK_START;
break; break;
case 83: // SO_VARIABLE case 83: // SO_VARIABLE
value = pop(); value = pop();
@ -1769,20 +1769,20 @@ void ScummEngine_v100he::o100_soundOps() {
((SoundHE *)_sound)->setSoundVar(_heSndSoundId, var, value); ((SoundHE *)_sound)->setSoundVar(_heSndSoundId, var, value);
break; break;
case 92: // SO_END case 92: // SO_END
_sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags); _sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags, _heSndSoundFreq, _heSndPan, _heSndVol);
break; break;
case 128: // SO_SOUND_ADD case 128: // SO_SOUND_ADD
_heSndFlags |= 2; _heSndFlags |= HE_SND_APPEND;
break; break;
case 129: // SO_SOUND_CHANNEL case 129: // SO_SOUND_CHANNEL
_heSndChannel = pop(); _heSndChannel = pop();
break; break;
case 130: // SO_SOUND_FREQUENCY case 130: // SO_SOUND_FREQUENCY
_heSndFlags |= 64; _heSndFlags |= HE_SND_FREQUENCY;
pop(); _heSndSoundFreq = pop();
break; break;
case 131: // SO_SOUND_LOOPING case 131: // SO_SOUND_LOOPING
_heSndFlags |= 1; _heSndFlags |= HE_SND_LOOP;
break; break;
case 132: // SO_SOUND_MODIFY case 132: // SO_SOUND_MODIFY
case 134: // SO_SOUND_START case 134: // SO_SOUND_START
@ -1793,15 +1793,15 @@ void ScummEngine_v100he::o100_soundOps() {
_heSndFlags = 0; _heSndFlags = 0;
break; break;
case 133: // SO_SOUND_PAN case 133: // SO_SOUND_PAN
_heSndFlags |= 128; _heSndFlags |= HE_SND_PAN;
pop(); _heSndPan = pop();
break; break;
case 135: // SO_SOUND_SOFT case 135: // SO_SOUND_SOFT
_heSndFlags |= 4; _heSndFlags |= HE_SND_SOFT_SOUND;
break; break;
case 136: // SO_SOUND_VOLUME case 136: // SO_SOUND_VOLUME
_heSndFlags |= 32; _heSndFlags |= HE_SND_VOL;
pop(); _heSndVol = pop();
break; break;
default: default:
error("o100_soundOps invalid case %d", subOp); error("o100_soundOps invalid case %d", subOp);

View File

@ -59,7 +59,7 @@ void ScummEngine_v70he::o70_soundOps() {
switch (subOp) { switch (subOp) {
case 9: // SO_SOUND_SOFT? case 9: // SO_SOUND_SOFT?
_heSndFlags |= 4; _heSndFlags |= HE_SND_SOFT_SOUND;
break; break;
case 23: // SO_VARIABLE case 23: // SO_VARIABLE
value = pop(); value = pop();
@ -70,13 +70,13 @@ void ScummEngine_v70he::o70_soundOps() {
case 25: // SO_SOUND_VOLUME case 25: // SO_SOUND_VOLUME
value = pop(); value = pop();
_heSndSoundId = pop(); _heSndSoundId = pop();
_sound->addSoundToQueue(_heSndSoundId, 0, 0, 8); _sound->addSoundToQueue(_heSndSoundId, 0, 0, HE_SND_VOL, 0, 0, value);
break; break;
case 56: // SO_NOW case 56: // SO_NOW
_heSndFlags |= 16; _heSndFlags |= HE_SND_QUICK_START;
break; break;
case 164: // SO_SOUND_ADD case 164: // SO_SOUND_ADD
_heSndFlags |= 2; _heSndFlags |= HE_SND_APPEND;
break; break;
case 222: case 222:
// WORKAROUND: For errors in room script 240 (room 4) of maze // 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); _heSndChannel = VAR(VAR_SOUND_CHANNEL);
break; break;
case 245: // SO_SOUND_LOOPING case 245: // SO_SOUND_LOOPING
_heSndFlags |= 1; _heSndFlags |= HE_SND_LOOP;
break; break;
case 255: // SO_END case 255: // SO_END
_sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags); _sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags, _heSndSoundFreq);
_heSndFlags = 0; _heSndFlags = 0;
break; break;

View File

@ -59,31 +59,29 @@ SoundHE::~SoundHE() {
delete[] _heSoundChannels; 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) if (_vm->VAR_LAST_SOUND != 0xFF)
_vm->VAR(_vm->VAR_LAST_SOUND) = sound; _vm->VAR(_vm->VAR_LAST_SOUND) = sound;
if ((_vm->_game.heversion <= 99 && (heFlags & 16)) || (_vm->_game.heversion >= 100 && (heFlags & 8))) { if (heFlags & 8) {
playHESound(sound, heOffset, heChannel, heFlags); playHESound(sound, heOffset, heChannel, heFlags, heFreq, hePan, heVol);
return;
} else { } else {
Sound::addSoundToQueue(sound, heOffset, heChannel, heFlags, heFreq, hePan, heVol);
Sound::addSoundToQueue(sound, heOffset, heChannel, heFlags);
} }
} }
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; int i = _soundQue2Pos;
while (i--) { while (i--) {
if (_soundQue2[i].sound == sound && !(heFlags & 2)) if (_soundQue2[i].sound == sound && !(heFlags & 2))
return; return;
} }
Sound::addSoundToQueue2(sound, heOffset, heChannel, heFlags); Sound::addSoundToQueue2(sound, heOffset, heChannel, heFlags, heFreq, hePan, heVol);
} }
void SoundHE::processSoundQueues() { void SoundHE::processSoundQueues() {
int snd, heOffset, heChannel, heFlags; int snd, heOffset, heChannel, heFlags, heFreq, hePan, heVol;
if (_vm->_game.heversion >= 72) { if (_vm->_game.heversion >= 72) {
for (int i = 0; i <_soundQue2Pos; i++) { for (int i = 0; i <_soundQue2Pos; i++) {
@ -91,8 +89,11 @@ void SoundHE::processSoundQueues() {
heOffset = _soundQue2[i].offset; heOffset = _soundQue2[i].offset;
heChannel = _soundQue2[i].channel; heChannel = _soundQue2[i].channel;
heFlags = _soundQue2[i].flags; heFlags = _soundQue2[i].flags;
heFreq = _soundQue2[_soundQue2Pos].freq;
hePan = _soundQue2[_soundQue2Pos].pan;
heVol = _soundQue2[_soundQue2Pos].vol;
if (snd) if (snd)
playHESound(snd, heOffset, heChannel, heFlags); playHESound(snd, heOffset, heChannel, heFlags, heFreq, hePan, heVol);
} }
_soundQue2Pos = 0; _soundQue2Pos = 0;
} else { } else {
@ -102,8 +103,11 @@ void SoundHE::processSoundQueues() {
heOffset = _soundQue2[_soundQue2Pos].offset; heOffset = _soundQue2[_soundQue2Pos].offset;
heChannel = _soundQue2[_soundQue2Pos].channel; heChannel = _soundQue2[_soundQue2Pos].channel;
heFlags = _soundQue2[_soundQue2Pos].flags; heFlags = _soundQue2[_soundQue2Pos].flags;
heFreq = _soundQue2[_soundQue2Pos].freq;
hePan = _soundQue2[_soundQue2Pos].pan;
heVol = _soundQue2[_soundQue2Pos].vol;
if (snd) 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; 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; Audio::RewindableAudioStream *stream = 0;
byte *ptr, *spoolPtr; byte *ptr, *spoolPtr;
int size = -1; int size = -1;

View File

@ -61,8 +61,8 @@ public:
SoundHE(ScummEngine *parent, Audio::Mixer *mixer); SoundHE(ScummEngine *parent, Audio::Mixer *mixer);
~SoundHE(); ~SoundHE();
virtual void addSoundToQueue(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); 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 int isSoundRunning(int sound) const;
virtual void stopSound(int sound); virtual void stopSound(int sound);
@ -75,7 +75,7 @@ public:
int getSoundPos(int sound); int getSoundPos(int sound);
int getSoundVar(int sound, int var); int getSoundVar(int sound, int var);
void setSoundVar(int sound, int var, int val); 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 processSoundCode();
void processSoundOpcodes(int sound, byte *codePtr, int *soundVars); void processSoundOpcodes(int sound, byte *codePtr, int *soundVars);
void setOverrideFreq(int freq); void setOverrideFreq(int freq);

View File

@ -805,6 +805,8 @@ ScummEngine_v70he::ScummEngine_v70he(OSystem *syst, const DetectorResult &dr)
_heSndChannel = 0; _heSndChannel = 0;
_heSndFlags = 0; _heSndFlags = 0;
_heSndSoundFreq = 0; _heSndSoundFreq = 0;
_heSndPan = 0;
_heSndVol = 0;
_numStoredFlObjects = 0; _numStoredFlObjects = 0;
_storedFlObjects = (ObjectData *)calloc(100, sizeof(ObjectData)); _storedFlObjects = (ObjectData *)calloc(100, sizeof(ObjectData));

View File

@ -110,7 +110,7 @@ Sound::~Sound() {
delete _talkChannelHandle; 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) if (_vm->VAR_LAST_SOUND != 0xFF)
_vm->VAR(_vm->VAR_LAST_SOUND) = sound; _vm->VAR(_vm->VAR_LAST_SOUND) = sound;
_lastSound = sound; _lastSound = sound;
@ -119,15 +119,18 @@ void Sound::addSoundToQueue(int sound, int heOffset, int heChannel, int heFlags)
if (sound <= _vm->_numSounds) if (sound <= _vm->_numSounds)
_vm->ensureResourceLoaded(rtSound, sound); _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)); assert(_soundQue2Pos < ARRAYSIZE(_soundQue2));
_soundQue2[_soundQue2Pos].sound = sound; _soundQue2[_soundQue2Pos].sound = sound;
_soundQue2[_soundQue2Pos].offset = heOffset; _soundQue2[_soundQue2Pos].offset = heOffset;
_soundQue2[_soundQue2Pos].channel = heChannel; _soundQue2[_soundQue2Pos].channel = heChannel;
_soundQue2[_soundQue2Pos].flags = heFlags; _soundQue2[_soundQue2Pos].flags = heFlags;
_soundQue2[_soundQue2Pos].freq = heFreq;
_soundQue2[_soundQue2Pos].pan = hePan;
_soundQue2[_soundQue2Pos].vol = heVol;
_soundQue2Pos++; _soundQue2Pos++;
} }
@ -806,6 +809,9 @@ void Sound::stopSound(int sound) {
_soundQue2[i].offset = 0; _soundQue2[i].offset = 0;
_soundQue2[i].channel = 0; _soundQue2[i].channel = 0;
_soundQue2[i].flags = 0; _soundQue2[i].flags = 0;
_soundQue2[i].freq = 0;
_soundQue2[i].pan = 0;
_soundQue2[i].vol = 0;
} }
} }
} }

View File

@ -67,6 +67,9 @@ protected:
int32 offset; int32 offset;
int16 channel; int16 channel;
int16 flags; int16 flags;
int16 freq;
int16 pan;
int16 vol;
} _soundQue2[10]; } _soundQue2[10];
Common::String _sfxFilename; Common::String _sfxFilename;
@ -101,8 +104,8 @@ public:
public: public:
Sound(ScummEngine *parent, Audio::Mixer *mixer); Sound(ScummEngine *parent, Audio::Mixer *mixer);
virtual ~Sound(); virtual ~Sound();
virtual void addSoundToQueue(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); 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 processSound();
void playSound(int soundID); void playSound(int soundID);