diff options
| author | D G Turner | 2012-06-05 01:00:01 +0100 | 
|---|---|---|
| committer | D G Turner | 2012-06-05 01:00:01 +0100 | 
| commit | 7d29e4017d37f7aee4035b3d7288c8c5478633be (patch) | |
| tree | 61a48d4b5887780863dcafc3d54d4e9428c5fe6a | |
| parent | b8989cafc725a262d6f3c941c44f2e1a54d6818d (diff) | |
| download | scummvm-rg350-7d29e4017d37f7aee4035b3d7288c8c5478633be.tar.gz scummvm-rg350-7d29e4017d37f7aee4035b3d7288c8c5478633be.tar.bz2 scummvm-rg350-7d29e4017d37f7aee4035b3d7288c8c5478633be.zip | |
DREAMWEB: Modify Sound code to better match original behaviour.
This fixes bug #3531635 - "DREAMWEB: doors don't play "open" sound when
opening".
In addition, the resultant code is simpler and should better match the
original behaviour and a basic playtest has not shown any regressions.
| -rw-r--r-- | engines/dreamweb/sound.cpp | 42 | ||||
| -rw-r--r-- | engines/dreamweb/sound.h | 3 | 
2 files changed, 12 insertions, 33 deletions
| diff --git a/engines/dreamweb/sound.cpp b/engines/dreamweb/sound.cpp index 76c734e932..570f76f2f9 100644 --- a/engines/dreamweb/sound.cpp +++ b/engines/dreamweb/sound.cpp @@ -35,14 +35,12 @@ DreamWebSound::DreamWebSound(DreamWebEngine *vm) : _vm(vm) {  	_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));  	_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume")); -	_channel0 = 0; -	_channel1 = 0; -  	_currentSample = 0xff; -	_channel0Playing = 0; +	_channel0Playing = 255;  	_channel0Repeat = 0;  	_channel0NewSound = false;  	_channel1Playing = 255; +	_channel1NewSound = false;  	_volume = 0;  	_volumeTo = 0; @@ -82,13 +80,9 @@ void DreamWebSound::volumeAdjust() {  void DreamWebSound::playChannel0(uint8 index, uint8 repeat) {  	debug(1, "playChannel0(index:%d, repeat:%d)", index, repeat); -	if (index == _channel0Playing) { -		warning("playChannel0(index: %d) already playing! Forcing restart...", index); -		_channel0NewSound = true; -	} -  	_channel0Playing = index;  	_channel0Repeat = repeat; +	_channel0NewSound = true;  }  void DreamWebSound::playChannel1(uint8 index) { @@ -97,6 +91,7 @@ void DreamWebSound::playChannel1(uint8 index) {  		return;  	_channel1Playing = index; +	_channel1NewSound = true;  }  void DreamWebSound::cancelCh0() { @@ -186,10 +181,6 @@ void DreamWebSound::stopSound(uint8 channel) {  	debug(1, "stopSound(%u)", channel);  	assert(channel == 0 || channel == 1);  	_vm->_mixer->stopHandle(_channelHandle[channel]); -	if (channel == 0) -		_channel0 = 0; -	else -		_channel1 = 0;  }  bool DreamWebSound::loadSpeech(const Common::String &filename) { @@ -229,35 +220,24 @@ void DreamWebSound::soundHandler() {  	volume = (8 - volume) * Audio::Mixer::kMaxChannelVolume / 8;  	_vm->_mixer->setChannelVolume(_channelHandle[0], volume); -	uint8 ch0 = _channel0Playing; -	if (ch0 == 255) -		ch0 = 0; -	uint8 ch1 = _channel1Playing; -	if (ch1 == 255) -		ch1 = 0; -	uint8 ch0loop = _channel0Repeat; - -	if (_channel0 != ch0 || _channel0NewSound) { -		_channel0 = ch0; +	if (_channel0NewSound) {  		_channel0NewSound = false; -		if (ch0) { -			playSound(0, ch0, ch0loop); +		if (_channel0Playing != 255) { +			playSound(0, _channel0Playing, _channel0Repeat);  		}  	} -	if (_channel1 != ch1) { -		_channel1 = ch1; -		if (ch1) { -			playSound(1, ch1, 1); +	if (_channel1NewSound) { +		_channel1NewSound = false; +		if (_channel1Playing != 255) { +			playSound(1, _channel1Playing, 1);  		}  	}  	if (!_vm->_mixer->isSoundHandleActive(_channelHandle[0])) {  		_channel0Playing = 255; -		_channel0 = 0;  	}  	if (!_vm->_mixer->isSoundHandleActive(_channelHandle[1])) {  		_channel1Playing = 255; -		_channel1 = 0;  	}  } diff --git a/engines/dreamweb/sound.h b/engines/dreamweb/sound.h index a38dbf3c1a..1ab06dc694 100644 --- a/engines/dreamweb/sound.h +++ b/engines/dreamweb/sound.h @@ -68,13 +68,12 @@ private:  	Audio::SoundHandle _channelHandle[2]; -	uint8 _channel0, _channel1; -  	uint8 _currentSample;  	uint8 _channel0Playing;  	uint8 _channel0Repeat;  	bool _channel0NewSound;  	uint8 _channel1Playing; +	bool _channel1NewSound;  	uint8 _volume;  	uint8 _volumeTo; | 
