diff options
Diffstat (limited to 'scumm')
| -rw-r--r-- | scumm/debugger.cpp | 77 | ||||
| -rw-r--r-- | scumm/dialogs.cpp | 5 | ||||
| -rw-r--r-- | scumm/imuse.cpp | 2 | ||||
| -rw-r--r-- | scumm/imuse.h | 2 | ||||
| -rw-r--r-- | scumm/imuse_digi.cpp | 10 | ||||
| -rw-r--r-- | scumm/imuse_digi.h | 7 | ||||
| -rw-r--r-- | scumm/music.h | 2 | ||||
| -rw-r--r-- | scumm/scummvm.cpp | 7 | ||||
| -rw-r--r-- | scumm/sound.cpp | 35 | 
9 files changed, 62 insertions, 85 deletions
| diff --git a/scumm/debugger.cpp b/scumm/debugger.cpp index 1f7f48d8ed..8b9703b6cf 100644 --- a/scumm/debugger.cpp +++ b/scumm/debugger.cpp @@ -364,76 +364,63 @@ bool ScummDebugger::Cmd_Restart(int argc, const char **argv) {  	return false;  } -bool ScummDebugger::Cmd_IMuse (int argc, const char **argv) { +bool ScummDebugger::Cmd_IMuse(int argc, const char **argv) {  	if (!_s->_imuse && !_s->_playerV2) { -		Debug_Printf ("No iMuse engine is active.\n"); +		Debug_Printf("No iMuse engine is active.\n");  		return true;  	}  	if (argc > 1) { -		if (!strcmp (argv[1], "panic")) { -			if (_s->_imuse) -				_s->_imuse->stopAllSounds(); -			if (_s->_playerV2) -				_s->_playerV2->stopAllSounds(); -			Debug_Printf ("AAAIIIEEEEEE!\n"); -			Debug_Printf ("Shutting down all music tracks\n"); +		if (!strcmp(argv[1], "panic")) { +			_s->_musicEngine->stopAllSounds(); +			Debug_Printf("AAAIIIEEEEEE!\n"); +			Debug_Printf("Shutting down all music tracks\n");  			return true;  		} else if (!strcmp (argv[1], "multimidi")) { -			if (argc > 2 && (!strcmp (argv[2], "on") || !strcmp (argv[2], "off"))) { +			if (argc > 2 && (!strcmp(argv[2], "on") || !strcmp(argv[2], "off"))) {  				if (_s->_imuse) -					_s->_imuse->property (IMuse::PROP_MULTI_MIDI, !strcmp (argv[2], "on")); -				Debug_Printf ("MultiMidi mode switched %s.\n", argv[2]); +					_s->_imuse->property(IMuse::PROP_MULTI_MIDI, !strcmp(argv[2], "on")); +				Debug_Printf("MultiMidi mode switched %s.\n", argv[2]);  			} else { -				Debug_Printf ("Specify \"on\" or \"off\" to switch.\n"); +				Debug_Printf("Specify \"on\" or \"off\" to switch.\n");  			}  			return true; -		} else if (!strcmp (argv[1], "play")) { -			if (argc > 2 && (!strcmp (argv[2], "random") || atoi (argv[2]) != 0)) { -				int sound = atoi (argv[2]); -				if (!strcmp (argv[2], "random")) { -					Debug_Printf ("Selecting from %d songs...\n", _s->getNumSounds()); -					sound = _s->_rnd.getRandomNumber (_s->getNumSounds()); +		} else if (!strcmp(argv[1], "play")) { +			if (argc > 2 && (!strcmp(argv[2], "random") || atoi(argv[2]) != 0)) { +				int sound = atoi(argv[2]); +				if (!strcmp(argv[2], "random")) { +					Debug_Printf("Selecting from %d songs...\n", _s->getNumSounds()); +					sound = _s->_rnd.getRandomNumber(_s->getNumSounds());  				}  				_s->ensureResourceLoaded(rtSound, sound); -				if (_s->_imuse) -					_s->_imuse->startSound(sound); -				if (_s->_playerV2) { -					_s->_playerV2->startSound(sound); -				} +				_s->_musicEngine->startSound(sound); -				Debug_Printf ("Attempted to start music %d.\n", sound); +				Debug_Printf("Attempted to start music %d.\n", sound);  			} else { -				Debug_Printf ("Specify a music resource # from 1-255.\n"); +				Debug_Printf("Specify a music resource # from 1-255.\n");  			}  			return true; -		} else if (!strcmp (argv[1], "stop")) { -			if (argc > 2 && (!strcmp (argv[2], "all") || atoi (argv[2]) != 0)) { -				if (!strcmp (argv[2], "all")) { -					if (_s->_imuse) -						_s->_imuse->stopAllSounds(); -					if (_s->_playerV2) -						_s->_playerV2->stopAllSounds(); -					Debug_Printf ("Shutting down all music tracks.\n"); +		} else if (!strcmp(argv[1], "stop")) { +			if (argc > 2 && (!strcmp(argv[2], "all") || atoi(argv[2]) != 0)) { +				if (!strcmp(argv[2], "all")) { +					_s->_musicEngine->stopAllSounds(); +					Debug_Printf("Shutting down all music tracks.\n");  				} else { -					if (_s->_imuse) -						_s->_imuse->stopSound(atoi (argv[2])); -					if (_s->_playerV2) -						_s->_playerV2->stopSound(atoi (argv[2])); -					Debug_Printf ("Attempted to stop music %d.\n", atoi (argv[2])); +					_s->_musicEngine->stopSound(atoi(argv[2])); +					Debug_Printf("Attempted to stop music %d.\n", atoi(argv[2]));  				}  			} else { -				Debug_Printf ("Specify a music resource # or \"all\".\n"); +				Debug_Printf("Specify a music resource # or \"all\".\n");  			}  			return true;  		}  	} -	Debug_Printf ("Available iMuse commands:\n"); -	Debug_Printf ("  panic - Stop all music tracks\n"); -	Debug_Printf ("  multimidi on/off - Toggle dual MIDI drivers\n"); -	Debug_Printf ("  play # - Play a music resource\n"); -	Debug_Printf ("  stop # - Stop a music resource\n"); +	Debug_Printf("Available iMuse commands:\n"); +	Debug_Printf("  panic - Stop all music tracks\n"); +	Debug_Printf("  multimidi on/off - Toggle dual MIDI drivers\n"); +	Debug_Printf("  play # - Play a music resource\n"); +	Debug_Printf("  stop # - Stop a music resource\n");  	return true;  } diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp index 4470d2a530..edfa8f5d41 100644 --- a/scumm/dialogs.cpp +++ b/scumm/dialogs.cpp @@ -536,10 +536,9 @@ void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data  		if (_scumm->_imuse) {  			_scumm->_imuse->set_music_volume(_soundVolumeMusic); -			_scumm->_imuse->setMasterVolume(_soundVolumeMaster);  		} -		if (_scumm->_playerV2) { -			_scumm->_playerV2->setMasterVolume(_soundVolumeMaster); +		if (_scumm->_musicEngine) { +			_scumm->_musicEngine->setMasterVolume(_soundVolumeMaster);  		}  		_scumm->_mixer->setVolume(_soundVolumeSfx * _soundVolumeMaster / 255); diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp index 677f33ff2d..515a6be117 100644 --- a/scumm/imuse.cpp +++ b/scumm/imuse.cpp @@ -1752,7 +1752,7 @@ 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::setMasterVolume(uint vol) { in(); int ret = _target->setMasterVolume(vol); out(); return ret; } +void IMuse::setMasterVolume(int vol) { in(); _target->setMasterVolume(vol); out(); }  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(); } diff --git a/scumm/imuse.h b/scumm/imuse.h index e1ffb084d7..3337f08b5e 100644 --- a/scumm/imuse.h +++ b/scumm/imuse.h @@ -61,7 +61,7 @@ public:  	int save_or_load(Serializer *ser, Scumm *scumm);  	int set_music_volume(uint vol);  	int get_music_volume(); -	int setMasterVolume(uint vol); +	void setMasterVolume(int vol);  	int get_master_volume();  	void startSound(int sound);  	void stopSound(int sound); diff --git a/scumm/imuse_digi.cpp b/scumm/imuse_digi.cpp index fb1e958c4a..8f5aa64a60 100644 --- a/scumm/imuse_digi.cpp +++ b/scumm/imuse_digi.cpp @@ -689,11 +689,11 @@ static byte *readCreativeVocFile(byte *ptr, int32 &size, int &rate) {  	return ret_sound;  } -static void imus_digital_handler(void *engine) { +void IMuseDigital::timer_handler(void *engine) {  	// Avoid race condition  	Scumm *scumm = (Scumm *)engine;  	if (scumm && scumm->_imuseDigital) -		scumm->_imuseDigital->handler(); +		scumm->_imuseDigital->musicTimer();  }  IMuseDigital::IMuseDigital(Scumm *scumm) @@ -702,19 +702,19 @@ IMuseDigital::IMuseDigital(Scumm *scumm)  	for (int l = 0; l < MAX_DIGITAL_CHANNELS; l++) {  		_channel[l]._mixerChannel = 0;  	} -	_scumm->_timer->installProcedure(imus_digital_handler, 200000); +	_scumm->_timer->installProcedure(timer_handler, 200000);  	_pause = false;  }  IMuseDigital::~IMuseDigital() { -	_scumm->_timer->releaseProcedure(imus_digital_handler); +	_scumm->_timer->releaseProcedure(timer_handler);  	for (int l = 0; l < MAX_DIGITAL_CHANNELS; l++) {  		_scumm->_mixer->stopChannel(_channel[l]._mixerChannel);  	}  } -void IMuseDigital::handler() { +void IMuseDigital::musicTimer() {  	int l = 0;  	if (_pause) diff --git a/scumm/imuse_digi.h b/scumm/imuse_digi.h index c059c6509b..21f685f5a6 100644 --- a/scumm/imuse_digi.h +++ b/scumm/imuse_digi.h @@ -63,10 +63,15 @@ private:  	Scumm *_scumm;  	bool _pause; +	static void timer_handler(void *engine); +	void musicTimer(); +  public:  	IMuseDigital(Scumm *scumm);  	~IMuseDigital(); -	void handler(); + +	void setMasterVolume(int vol) {} +  	void startSound(int sound);  	void stopSound(int sound);  	void stopAllSounds(); diff --git a/scumm/music.h b/scumm/music.h index f1c24f55e8..ff08d18e89 100644 --- a/scumm/music.h +++ b/scumm/music.h @@ -30,7 +30,7 @@ class MusicEngine {  public:  	virtual ~MusicEngine() {} -//	virtual void setMasterVolume(int vol) = 0; +	virtual void setMasterVolume(int vol) = 0;  	virtual void startSound(int sound) = 0;  	virtual void stopSound(int sound) = 0; diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index d3f6b35026..35ecd61ea5 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -700,7 +700,7 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)  	} else if ((_features & GF_AMIGA) && (_version == 3)) {  		_musicEngine = _playerV3A = new Player_V3A(this);  	} else if ((_features & GF_AMIGA) && (_version < 5)) { -		_playerV2 = NULL; +		_musicEngine = NULL;  	} else if (((_midiDriver == MD_PCJR) || (_midiDriver == MD_PCSPK)) && ((_version > 2) && (_version < 5))) {  		_musicEngine = _playerV2 = new Player_V2(this);  	} else if (_version > 2) { @@ -787,10 +787,7 @@ Scumm::~Scumm () {  	delete _confirmExitDialog;  	delete _sound; -	delete _imuse; -	delete _imuseDigital; -	delete _playerV2; -	delete _playerV3A; +	delete _musicEngine;  	free(_languageBuffer);  	free(_audioNames); diff --git a/scumm/sound.cpp b/scumm/sound.cpp index c9c2bde8ed..37e3699ffd 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -672,17 +672,8 @@ int Sound::isSoundRunning(int sound) const {  	if (!_scumm->isResourceLoaded(rtSound, sound))  		return 0; -	if (_scumm->_imuseDigital) -		return _scumm->_imuseDigital->getSoundStatus(sound); - -	if (_scumm->_imuse) -		return _scumm->_imuse->getSoundStatus(sound); - -	if (_scumm->_playerV2) -		return _scumm->_playerV2->getSoundStatus(sound); - -	if (_scumm->_playerV3A) -		return _scumm->_playerV3A->getSoundStatus(sound); +	if (_scumm->_musicEngine) +		return _scumm->_musicEngine->getSoundStatus(sound);  	return 0;  } @@ -770,23 +761,21 @@ void Sound::stopAllSounds() {  		stopCD();  	} -	if (_scumm->_imuse) { -		_scumm->_imuse->stopAllSounds(); -		_scumm->_imuse->clear_queue(); -	} else if (_scumm->_playerV2) { -		_scumm->_playerV2->stopAllSounds(); -	} else 	if (_scumm->_playerV3A) { -		_scumm->_playerV3A->stopAllSounds(); -	} -  	// Clear the (secondary) sound queue  	_soundQue2Pos = 0;  	memset(_soundQue2, 0, sizeof(_soundQue2)); +	if (_scumm->_musicEngine) { +		_scumm->_musicEngine->stopAllSounds(); +	} +	if (_scumm->_imuse) { +		// FIXME: Maybe we could merge this call to clear_queue() +		// into IMuse::stopAllSounds() ? +		_scumm->_imuse->clear_queue(); +	} +  	// Stop all SFX -	if (_scumm->_imuseDigital) { -		_scumm->_imuseDigital->stopAllSounds(); -	} else { +	if (!_scumm->_imuseDigital) {  		_scumm->_mixer->stopAll();  	}  } | 
