diff options
| author | Max Horn | 2003-09-07 19:28:45 +0000 | 
|---|---|---|
| committer | Max Horn | 2003-09-07 19:28:45 +0000 | 
| commit | 1dbab0237f253f2427e8218b3c5a2c97fdfb3f62 (patch) | |
| tree | 8586e18d708106b7ebdbe50d2ace44633e967274 | |
| parent | 361c3b95d52babd23b78864e6679334ed1c9e316 (diff) | |
| download | scummvm-rg350-1dbab0237f253f2427e8218b3c5a2c97fdfb3f62.tar.gz scummvm-rg350-1dbab0237f253f2427e8218b3c5a2c97fdfb3f62.tar.bz2 scummvm-rg350-1dbab0237f253f2427e8218b3c5a2c97fdfb3f62.zip  | |
cleanup/refactoring
svn-id: r10070
| -rw-r--r-- | scumm/dialogs.cpp | 4 | ||||
| -rw-r--r-- | scumm/imuse.cpp | 10 | ||||
| -rw-r--r-- | scumm/imuse.h | 4 | ||||
| -rw-r--r-- | scumm/imuse_digi.cpp | 4 | ||||
| -rw-r--r-- | scumm/imuse_digi.h | 2 | ||||
| -rw-r--r-- | scumm/imuse_internal.h | 2 | ||||
| -rw-r--r-- | scumm/music.h | 9 | ||||
| -rw-r--r-- | scumm/player_v2.cpp | 4 | ||||
| -rw-r--r-- | scumm/player_v2.h | 2 | ||||
| -rw-r--r-- | scumm/player_v3a.cpp | 8 | ||||
| -rw-r--r-- | scumm/player_v3a.h | 2 | ||||
| -rw-r--r-- | scumm/saveload.cpp | 13 | ||||
| -rw-r--r-- | scumm/script_v6.cpp | 2 | ||||
| -rw-r--r-- | scumm/sound.cpp | 28 | ||||
| -rw-r--r-- | scumm/sound.h | 3 | 
15 files changed, 43 insertions, 54 deletions
diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp index 421482f2a6..4470d2a530 100644 --- a/scumm/dialogs.cpp +++ b/scumm/dialogs.cpp @@ -536,10 +536,10 @@ void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data  		if (_scumm->_imuse) {  			_scumm->_imuse->set_music_volume(_soundVolumeMusic); -			_scumm->_imuse->set_master_volume(_soundVolumeMaster); +			_scumm->_imuse->setMasterVolume(_soundVolumeMaster);  		}  		if (_scumm->_playerV2) { -			_scumm->_playerV2->set_master_volume(_soundVolumeMaster); +			_scumm->_playerV2->setMasterVolume(_soundVolumeMaster);  		}  		_scumm->_mixer->setVolume(_soundVolumeSfx * _soundVolumeMaster / 255); diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp index 5d436d24ff..677f33ff2d 100644 --- a/scumm/imuse.cpp +++ b/scumm/imuse.cpp @@ -588,7 +588,7 @@ int IMuseInternal::set_music_volume(uint vol) {  	return 0;  } -int IMuseInternal::set_master_volume(uint vol) { +int IMuseInternal::setMasterVolume(uint vol) {  	if (vol > 255)  		vol = 255;  	if (_master_volume == vol) @@ -689,7 +689,7 @@ int32 IMuseInternal::doCommand (int numargs, int a[]) {  			if (a[1] > 127)  				return -1;  			else -				return set_master_volume((a[1] << 1) |(a[1] ? 0 : 1)); // Convert from 0-127 to 0-255 +				return setMasterVolume((a[1] << 1) |(a[1] ? 0 : 1)); // Convert from 0-127 to 0-255  		case 7:  			return _master_volume >> 1; // Convert from 0-255 to 0-127  		case 8: @@ -1359,7 +1359,7 @@ int IMuseInternal::save_or_load(Serializer *ser, Scumm *scumm) {  		// Load all sounds that we need  		fix_players_after_load(scumm);  		fix_parts_after_load(); -		set_master_volume(_master_volume); +		setMasterVolume(_master_volume);  		if (_midi_native)  			reallocateMidiChannels(_midi_native); @@ -1752,11 +1752,11 @@ void IMuse::pause(bool paused) { in(); _target->pause(paused); out(); }  int IMuse::save_or_load(Serializer *ser, Scumm *scumm) { in(); int ret = _target->save_or_load(ser, scumm); out(); return ret; }  int IMuse::set_music_volume(uint vol) { in(); int ret = _target->set_music_volume(vol); out(); return ret; }  int IMuse::get_music_volume() { in(); int ret = _target->get_music_volume(); out(); return ret; } -int IMuse::set_master_volume(uint vol) { in(); int ret = _target->set_master_volume(vol); out(); return ret; } +int IMuse::setMasterVolume(uint vol) { in(); int ret = _target->setMasterVolume(vol); out(); return ret; }  int IMuse::get_master_volume() { in(); int ret = _target->get_master_volume(); out(); return ret; }  void IMuse::startSound(int sound) { in(); _target->startSound(sound); out(); }  void IMuse::stopSound(int sound) { in(); _target->stopSound(sound); out(); } -int IMuse::stopAllSounds() { in(); int ret = _target->stopAllSounds(); out(); return ret; } +void IMuse::stopAllSounds() { in(); _target->stopAllSounds(); out(); }  int IMuse::getSoundStatus(int sound) const { in(); int ret = _target->getSoundStatus(sound, true); out(); return ret; }  bool IMuse::get_sound_active(int sound) const { in(); bool ret = _target->getSoundStatus(sound, false) ? 1 : 0; out(); return ret; }  int IMuse::getMusicTimer() { in(); int ret = _target->getMusicTimer(); out(); return ret; } diff --git a/scumm/imuse.h b/scumm/imuse.h index 78b75829dc..e1ffb084d7 100644 --- a/scumm/imuse.h +++ b/scumm/imuse.h @@ -61,11 +61,11 @@ public:  	int save_or_load(Serializer *ser, Scumm *scumm);  	int set_music_volume(uint vol);  	int get_music_volume(); -	int set_master_volume(uint vol); +	int setMasterVolume(uint vol);  	int get_master_volume();  	void startSound(int sound);  	void stopSound(int sound); -	int stopAllSounds(); +	void stopAllSounds();  	int getSoundStatus(int sound) const;  	bool get_sound_active(int sound) const;  	int getMusicTimer(); diff --git a/scumm/imuse_digi.cpp b/scumm/imuse_digi.cpp index 2603b2acda..cda19394bb 100644 --- a/scumm/imuse_digi.cpp +++ b/scumm/imuse_digi.cpp @@ -931,7 +931,7 @@ void IMuseDigital::stopSound(int sound) {  	}  } -void IMuseDigital::stopAll() { +void IMuseDigital::stopAllSounds() {  	for (int l = 0; l < MAX_DIGITAL_CHANNELS; l++) {  		if (_channel[l]._used) {  			_channel[l]._toBeRemoved = true; @@ -956,7 +956,7 @@ int32 IMuseDigital::doCommand(int a, int b, int c, int d, int e, int f, int g, i  	switch (cmd) {  	case 10:  		debug(5, "ImuseStopAllSounds()"); -		stopAll(); +		stopAllSounds();  		return 0;  	case 12: // ImuseSetParam  		switch (sub_cmd) { diff --git a/scumm/imuse_digi.h b/scumm/imuse_digi.h index 7756be415f..c059c6509b 100644 --- a/scumm/imuse_digi.h +++ b/scumm/imuse_digi.h @@ -69,7 +69,7 @@ public:  	void handler();  	void startSound(int sound);  	void stopSound(int sound); -	void stopAll(); +	void stopAllSounds();  	void pause(bool pause);  	int32 doCommand(int a, int b, int c, int d, int e, int f, int g, int h);  	int getSoundStatus(int sound) const; diff --git a/scumm/imuse_internal.h b/scumm/imuse_internal.h index 512e701ab2..b472ca8f65 100644 --- a/scumm/imuse_internal.h +++ b/scumm/imuse_internal.h @@ -457,7 +457,7 @@ public:  	int save_or_load(Serializer *ser, Scumm *scumm);  	int set_music_volume(uint vol);  	int get_music_volume(); -	int set_master_volume(uint vol); +	int setMasterVolume(uint vol);  	int get_master_volume();  	bool startSound(int sound);  	int stopSound(int sound); diff --git a/scumm/music.h b/scumm/music.h index 5f6b124f3d..f1c24f55e8 100644 --- a/scumm/music.h +++ b/scumm/music.h @@ -29,11 +29,14 @@  class MusicEngine {  public:  	virtual ~MusicEngine() {} -	 + +//	virtual void setMasterVolume(int vol) = 0; +  	virtual void startSound(int sound) = 0;  	virtual void stopSound(int sound) = 0; -//	virtual void stopAllSounds() = 0; -	virtual int getSoundStatus(int sound) const = 0; +	virtual void stopAllSounds() = 0; +	virtual int  getSoundStatus(int sound) const = 0; +//	virtual int  getMusicTimer() const = 0;  };  #endif diff --git a/scumm/player_v2.cpp b/scumm/player_v2.cpp index 0538631a87..78631f11c3 100644 --- a/scumm/player_v2.cpp +++ b/scumm/player_v2.cpp @@ -364,7 +364,7 @@ Player_V2::Player_V2(Scumm *scumm) {  	_RNG = NG_PRESET;  	set_pcjr(scumm->_midiDriver != MD_PCSPK); -	set_master_volume(255); +	setMasterVolume(255);  	_mixer->setupPremix(this, premix_proc);  } @@ -406,7 +406,7 @@ void Player_V2::set_pcjr(bool pcjr) {  	mutex_down();  } -void Player_V2::set_master_volume (int vol) { +void Player_V2::setMasterVolume (int vol) {  	if (vol > 255)  		vol = 255; diff --git a/scumm/player_v2.h b/scumm/player_v2.h index 54b98e426b..86218dda5a 100644 --- a/scumm/player_v2.h +++ b/scumm/player_v2.h @@ -76,7 +76,7 @@ public:  	Player_V2(Scumm *scumm);  	virtual ~Player_V2(); -	virtual void set_master_volume(int vol); +	virtual void setMasterVolume(int vol);  	virtual void startSound(int nr);  	virtual void stopSound(int nr); diff --git a/scumm/player_v3a.cpp b/scumm/player_v3a.cpp index 78c9391f27..adbafe74af 100644 --- a/scumm/player_v3a.cpp +++ b/scumm/player_v3a.cpp @@ -70,7 +70,7 @@ Player_V3A::~Player_V3A() {  	free(_wavetable);  } -void Player_V3A::set_master_volume (int vol) { +void Player_V3A::setMasterVolume (int vol) {  	_maxvol = vol;  } @@ -132,7 +132,8 @@ void Player_V3A::playSound (int nr, char *data, int size, int rate, int vol, int  	vol = (vol * _maxvol) / 255;  	if (looped)  		_mixer->playRaw(NULL, data, size, rate, SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_LOOP, nr, vol, 0, loopStart, loopEnd); -	else	_mixer->playRaw(NULL, data, size, rate, SoundMixer::FLAG_AUTOFREE, nr, vol, 0); +	else +		_mixer->playRaw(NULL, data, size, rate, SoundMixer::FLAG_AUTOFREE, nr, vol, 0);  }  void Player_V3A::startSound(int nr) { @@ -286,7 +287,8 @@ void Player_V3A::playMusic() {  		if (!_lastSample)  			_lastSample++;  		int id = (_curSong << 8) | _lastSample++; -		playSound(id,data,_wavetable[inst]->_ilen[oct] + _wavetable[inst]->_llen[oct],3579545 / _notefreqs[_wavetable[inst]->_oct[oct]][pit],255,dur,(_wavetable[inst]->_ldat[oct] != NULL),_wavetable[inst]->_ilen[oct],_wavetable[inst]->_ilen[oct] + _wavetable[inst]->_llen[oct]); +		playSound(id, data, _wavetable[inst]->_ilen[oct] + _wavetable[inst]->_llen[oct], 3579545 / _notefreqs[_wavetable[inst]->_oct[oct]][pit], 255, dur, +					(_wavetable[inst]->_ldat[oct] != NULL), _wavetable[inst]->_ilen[oct], _wavetable[inst]->_ilen[oct] + _wavetable[inst]->_llen[oct]);  	}  } diff --git a/scumm/player_v3a.h b/scumm/player_v3a.h index 57f17a8c36..d5b4692ff1 100644 --- a/scumm/player_v3a.h +++ b/scumm/player_v3a.h @@ -37,7 +37,7 @@ public:  	Player_V3A(Scumm *scumm);  	virtual ~Player_V3A(); -	virtual void set_master_volume(int vol); +	virtual void setMasterVolume(int vol);  	virtual void startSound(int nr);  	virtual void stopSound(int nr); diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp index 7cb699d4d0..5e06e851bd 100644 --- a/scumm/saveload.cpp +++ b/scumm/saveload.cpp @@ -117,7 +117,7 @@ bool Scumm::loadState(int slot, bool compat, SaveFileManager *mgr) {  	memcpy(_saveLoadName, hdr.name, sizeof(hdr.name));  	if (_imuseDigital) { -		_imuseDigital->stopAll(); +		_imuseDigital->stopAllSounds();  	}  	_sound->stopBundleMusic(); @@ -546,13 +546,6 @@ void Scumm::saveOrLoad(Serializer *s, uint32 savegameVersion) {  	if (!s->isSaving() && (_saveSound || !_saveLoadCompatible)) {  		_sound->stopAllSounds(); -		if (_mixer) { -			if (_imuseDigital) { -				_imuseDigital->stopAll(); -			} else { -				_mixer->stopAll(); -			} -		}  	}  	// Because old savegames won't fill the entire gfxUsageBits[] array, @@ -667,8 +660,8 @@ void Scumm::saveOrLoad(Serializer *s, uint32 savegameVersion) {  	if (_imuse && (_saveSound || !_saveLoadCompatible)) {  		_imuse->save_or_load(s, this); -		_imuse->set_master_volume (_sound->_sound_volume_master); -		_imuse->set_music_volume (_sound->_sound_volume_music); +		_imuse->setMasterVolume(_sound->_sound_volume_master); +		_imuse->set_music_volume(_sound->_sound_volume_music);  	}  } diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp index 5c02ac0e15..275cde4b51 100644 --- a/scumm/script_v6.cpp +++ b/scumm/script_v6.cpp @@ -2390,7 +2390,7 @@ void Scumm_v6::o6_kernelSetFunctions() {  			break;  		case 6: {  //				if (_imuseDigital) { -//					_imuseDigital->stopAll(); +//					_imuseDigital->stopAllSounds();  //				}  				uint32 speed;  				assert(getStringAddressVar(VAR_VIDEONAME)); diff --git a/scumm/sound.cpp b/scumm/sound.cpp index 4bedd38202..7aca2f3d9a 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -208,7 +208,6 @@ void Sound::playSound(int soundID) {  		int track = ptr[0];  		int loops = ptr[1];  		int start = (ptr[2] * 60 + ptr[3]) * 75 + ptr[4]; -		_scumm->VAR(_scumm->VAR_MUSIC_TIMER) = 0;  		playCDTrack(track, loops == 0xff ? -1 : loops, start, 0);  		_currentCDSound = soundID; @@ -772,13 +771,16 @@ void Sound::stopAllSounds() {  		_scumm->_playerV3A->stopAllSounds();  	} -	clearSoundQue(); -	stopSfxSound(); -} - -void Sound::clearSoundQue() { +	// Clear the (secondary) sound queue  	_soundQue2Pos = 0;  	memset(_soundQue2, 0, sizeof(_soundQue2)); + +	// Stop all SFX +	if (_scumm->_imuseDigital) { +		_scumm->_imuseDigital->stopAllSounds(); +	} else { +		_scumm->_mixer->stopAll(); +	}  }  void Sound::soundKludge(int *list, int num) { @@ -831,7 +833,7 @@ void Sound::setupSound() {  	if (_scumm->_imuse) {  		_scumm->_imuse->setBase(_scumm->res.address[rtSound]); -		_scumm->_imuse->set_master_volume(_sound_volume_master); +		_scumm->_imuse->setMasterVolume(_sound_volume_master);  		_scumm->_imuse->set_music_volume(_sound_volume_music);  	}  	_scumm->_mixer->setVolume(_sound_volume_sfx * _sound_volume_master / 255); @@ -1014,14 +1016,6 @@ File *Sound::openSfxFile() {  	return file;  } -void Sound::stopSfxSound() { -	if (_scumm->_imuseDigital) { -		_scumm->_imuseDigital->stopAll(); -	} else { -		_scumm->_mixer->stopAll(); -	} -} -  bool Sound::isSfxFinished() const {  	return !_scumm->_mixer->hasActiveSFXChannel();  } @@ -1625,9 +1619,9 @@ int Sound::updateMP3CD() {  	if (!_dig_cd.handle) {  		if (_dig_cd.numLoops == -1 || --_dig_cd.numLoops > 0) -			playMP3CDTrack(_dig_cd.track, _dig_cd.numLoops, _dig_cd.start, _dig_cd.duration); +			playCDTrack(_dig_cd.track, _dig_cd.numLoops, _dig_cd.start, _dig_cd.duration);  		else -			stopMP3CD(); +			stopCD();  	}  	return 0; diff --git a/scumm/sound.h b/scumm/sound.h index 9e82d2a6a0..a6d5254bb2 100644 --- a/scumm/sound.h +++ b/scumm/sound.h @@ -152,11 +152,8 @@ public:  	int getCurrentCDSound() const { return _currentCDSound; }  protected: -	void clearSoundQue(); -  	File *openSfxFile();  	void startSfxSound(File *file, int file_size, PlayingSoundHandle *handle); -	void stopSfxSound();  	bool isSfxFinished() const;  	void playSfxSound(void *sound, uint32 size, uint rate, bool isUnsigned, PlayingSoundHandle *handle);  	void playSfxSound_Vorbis(void *sound, uint32 size, PlayingSoundHandle *handle);  | 
