diff options
Diffstat (limited to 'engines/scumm')
-rw-r--r-- | engines/scumm/he/intern_he.h | 17 | ||||
-rw-r--r-- | engines/scumm/he/script_v100he.cpp | 58 | ||||
-rw-r--r-- | engines/scumm/he/script_v70he.cpp | 40 | ||||
-rw-r--r-- | engines/scumm/he/sound_he.cpp | 28 | ||||
-rw-r--r-- | engines/scumm/he/sound_he.h | 6 | ||||
-rw-r--r-- | engines/scumm/scumm.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/sound.cpp | 12 | ||||
-rw-r--r-- | engines/scumm/sound.h | 7 |
8 files changed, 98 insertions, 72 deletions
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h index 7f7babc604..c6abac3ecc 100644 --- a/engines/scumm/he/intern_he.h +++ b/engines/scumm/he/intern_he.h @@ -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; @@ -168,7 +179,7 @@ protected: virtual void setDefaultCursor(); /* HE version 70 script opcodes */ - void o70_startSound(); + void o70_soundOps(); void o70_pickupObject(); void o70_getActorRoom(); void o70_resourceRoutines(); @@ -622,7 +633,7 @@ protected: void o100_redimArray(); void o100_roomOps(); void o100_setSystemMessage(); - void o100_startSound(); + void o100_soundOps(); void o100_setSpriteInfo(); void o100_startScript(); void o100_systemOps(); diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp index 4a4c340802..714f431188 100644 --- a/engines/scumm/he/script_v100he.cpp +++ b/engines/scumm/he/script_v100he.cpp @@ -184,7 +184,7 @@ void ScummEngine_v100he::setupOpcodes() { OPCODE(0x74, o6_delay); OPCODE(0x75, o6_delayMinutes); OPCODE(0x76, o6_delaySeconds); - OPCODE(0x77, o100_startSound); + OPCODE(0x77, o100_soundOps); /* 78 */ OPCODE(0x78, o80_sourceDebug); OPCODE(0x79, o100_setSpriteInfo); @@ -1742,69 +1742,69 @@ void ScummEngine_v100he::o100_setSystemMessage() { } } -void ScummEngine_v100he::o100_startSound() { +void ScummEngine_v100he::o100_soundOps() { byte filename[260]; int var, value; byte subOp = fetchScriptByte(); switch (subOp) { - case 6: - _heSndFlags |= 16; + case 6: // SO_AT + _heSndFlags |= HE_SND_OFFSET; _heSndOffset = pop(); break; - case 47: + case 47: // SO_LOAD copyScriptString(filename, sizeof(filename)); _heSndSoundId = pop(); if (_heSndSoundId) debug(0, "Load sound %d from file %s\n", _heSndSoundId, filename); break; - case 55: - _heSndFlags |= 8; + case 55: // SO_NOW + _heSndFlags |= HE_SND_QUICK_START; break; - case 83: + case 83: // SO_VARIABLE value = pop(); var = pop(); _heSndSoundId = pop(); ((SoundHE *)_sound)->setSoundVar(_heSndSoundId, var, value); break; - case 92: - _sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags); + case 92: // SO_END + _sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags, _heSndSoundFreq, _heSndPan, _heSndVol); break; - case 128: - _heSndFlags |= 2; + case 128: // SO_SOUND_ADD + _heSndFlags |= HE_SND_APPEND; break; - case 129: + case 129: // SO_SOUND_CHANNEL _heSndChannel = pop(); break; - case 130: - _heSndFlags |= 64; - pop(); + case 130: // SO_SOUND_FREQUENCY + _heSndFlags |= HE_SND_FREQUENCY; + _heSndSoundFreq = pop(); break; - case 131: - _heSndFlags |= 1; + case 131: // SO_SOUND_LOOPING + _heSndFlags |= HE_SND_LOOP; break; - case 132: // Music - case 134: // Sound + case 132: // SO_SOUND_MODIFY + case 134: // SO_SOUND_START _heSndSoundId = pop(); _heSndOffset = 0; _heSndSoundFreq = 11025; _heSndChannel = VAR(VAR_SOUND_CHANNEL); _heSndFlags = 0; break; - case 133: - _heSndFlags |= 128; - pop(); + case 133: // SO_SOUND_PAN + _heSndFlags |= HE_SND_PAN; + _heSndPan = pop(); break; - case 135: - _heSndFlags |= 4; + case 135: // SO_SOUND_SOFT + _heSndFlags |= HE_SND_SOFT_SOUND; break; - case 136: - _heSndFlags |= 32; - pop(); + case 136: // SO_SOUND_VOLUME + _heSndFlags |= HE_SND_VOL; + _heSndVol = pop(); break; default: - error("o100_startSound invalid case %d", subOp); + error("o100_soundOps invalid case %d", subOp); } } diff --git a/engines/scumm/he/script_v70he.cpp b/engines/scumm/he/script_v70he.cpp index b91943c685..0bdeb3211e 100644 --- a/engines/scumm/he/script_v70he.cpp +++ b/engines/scumm/he/script_v70he.cpp @@ -39,7 +39,7 @@ namespace Scumm { void ScummEngine_v70he::setupOpcodes() { ScummEngine_v60he::setupOpcodes(); - OPCODE(0x74, o70_startSound); + OPCODE(0x74, o70_soundOps); OPCODE(0x84, o70_pickupObject); OPCODE(0x8c, o70_getActorRoom); OPCODE(0x9b, o70_resourceRoutines); @@ -52,60 +52,60 @@ void ScummEngine_v70he::setupOpcodes() { OPCODE(0xfa, o70_setSystemMessage); } -void ScummEngine_v70he::o70_startSound() { +void ScummEngine_v70he::o70_soundOps() { int var, value; byte subOp = fetchScriptByte(); switch (subOp) { - case 9: - _heSndFlags |= 4; + case 9: // SO_SOUND_SOFT? + _heSndFlags |= HE_SND_SOFT_SOUND; break; - case 23: + case 23: // SO_VARIABLE value = pop(); var = pop(); _heSndSoundId = pop(); ((SoundHE *)_sound)->setSoundVar(_heSndSoundId, var, value); break; - case 25: + 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: - _heSndFlags |= 16; + case 56: // SO_NOW + _heSndFlags |= HE_SND_QUICK_START; break; - case 164: - _heSndFlags |= 2; + case 164: // SO_SOUND_ADD + _heSndFlags |= HE_SND_APPEND; break; case 222: // WORKAROUND: For errors in room script 240 (room 4) of maze break; - case 224: + case 224: // SO_SOUND_FREQUENCY _heSndSoundFreq = pop(); break; - case 230: + case 230: // SO_SOUND_CHANNEL _heSndChannel = pop(); break; - case 231: + case 231: // SO_AT _heSndOffset = pop(); break; - case 232: + case 232: // SO_SOUND_START _heSndSoundId = pop(); _heSndOffset = 0; _heSndSoundFreq = 11025; _heSndChannel = VAR(VAR_SOUND_CHANNEL); break; - case 245: - _heSndFlags |= 1; + case 245: // SO_SOUND_LOOPING + _heSndFlags |= HE_SND_LOOP; break; - case 255: - _sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags); + case 255: // SO_END + _sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags, _heSndSoundFreq); _heSndFlags = 0; break; default: - error("o70_startSound invalid case %d", subOp); + error("o70_soundOps invalid case %d", subOp); } } diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp index 8670116c68..9da3641064 100644 --- a/engines/scumm/he/sound_he.cpp +++ b/engines/scumm/he/sound_he.cpp @@ -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; diff --git a/engines/scumm/he/sound_he.h b/engines/scumm/he/sound_he.h index e0324d0753..d5a2817a0f 100644 --- a/engines/scumm/he/sound_he.h +++ b/engines/scumm/he/sound_he.h @@ -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); diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index d5727f2a7c..3b7dea194b 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -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)); diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp index 33b7c3108d..a62092f493 100644 --- a/engines/scumm/sound.cpp +++ b/engines/scumm/sound.cpp @@ -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; } } } diff --git a/engines/scumm/sound.h b/engines/scumm/sound.h index 7fdb16371c..bc1e88f76b 100644 --- a/engines/scumm/sound.h +++ b/engines/scumm/sound.h @@ -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); |