diff options
| author | Max Horn | 2002-05-04 00:20:39 +0000 | 
|---|---|---|
| committer | Max Horn | 2002-05-04 00:20:39 +0000 | 
| commit | c7002262bb8844d6ea5d6c8fbada4983475e2b49 (patch) | |
| tree | 5d0880f9ac35a07a0b180ddfa7136bc78f18975e | |
| parent | 711d994b9c4902d97dfe6ec4e7095f0a516011a4 (diff) | |
| download | scummvm-rg350-c7002262bb8844d6ea5d6c8fbada4983475e2b49.tar.gz scummvm-rg350-c7002262bb8844d6ea5d6c8fbada4983475e2b49.tar.bz2 scummvm-rg350-c7002262bb8844d6ea5d6c8fbada4983475e2b49.zip | |
automatic detecion of MT32 vs. GM midi; removed obsolete -r command line option
svn-id: r4193
| -rw-r--r-- | gameDetector.cpp | 12 | ||||
| -rw-r--r-- | gameDetector.h | 1 | ||||
| -rw-r--r-- | readme.txt | 1 | ||||
| -rw-r--r-- | scummvm.cpp | 1 | ||||
| -rw-r--r-- | sound/imuse.cpp | 132 | ||||
| -rw-r--r-- | sound/imuse.h | 1 | 
6 files changed, 81 insertions, 67 deletions
| diff --git a/gameDetector.cpp b/gameDetector.cpp index 0fcb5b36d8..917e7ccff1 100644 --- a/gameDetector.cpp +++ b/gameDetector.cpp @@ -53,7 +53,6 @@ static const char USAGE_STRING[] =  	"\t-m<num>    - set music volume to <num> (0-100)\n"  	"\t-s<num>    - set sfx volume to <num> (0-255)\n"  	"\t-e<mode>   - set music engine (see readme.txt for details)\n" -	"\t-r         - emulate roland mt32 instruments\n"  	"\t-f         - fullscreen mode\n"  	"\t-g<mode>   - graphics mode (normal,2x,3x,2xsai,super2xsai,supereagle,advmame2x)\n"  	"\t-a         - specify game is amiga version\n" @@ -93,12 +92,6 @@ void GameDetector::updateconfig()  	if ((val = scummcfg->get("sfx_volume")))  		_sfx_volume = atoi(val); -	if ((val = scummcfg->get("mt32emulate"))) -		if (!scumm_stricmp(val, "true")) -			_mt32emulate = true; -		else -			_mt32emulate = false; -	  	if ((val = scummcfg->get("nosubtitles")))  		if (!scumm_stricmp(val, "true"))  			_noSubtitles = true; @@ -210,9 +203,8 @@ void GameDetector::parseCommandLine(int argc, char **argv)  				scummcfg->set("path", _gameDataPath);  				break;  			case 'r': -				CHECK_OPTION(); -				_mt32emulate = true; -				scummcfg->set("mt32emulate", "true"); +				HANDLE_OPTION(); +				// Ignore -r for now, to ensure backward compatibility.  				break;  			case 's':  				HANDLE_OPTION(); diff --git a/gameDetector.h b/gameDetector.h index caf2427f02..6476a0c6bd 100644 --- a/gameDetector.h +++ b/gameDetector.h @@ -36,7 +36,6 @@ public:  	byte _music_volume;  	byte _sfx_volume; -	bool _mt32emulate;  	bool _amiga;  	uint16 _debugMode; diff --git a/readme.txt b/readme.txt index f170cd6cfb..e837a1f179 100644 --- a/readme.txt +++ b/readme.txt @@ -228,7 +228,6 @@ Command Line Options:          -g<mode>   - Select graphics scaler. See below.          -f         - Full-screen mode.          -n         - Disable subtitles. Use with games that have voice. -        -r         - Enable Roland conversion. Try if music sounds incorrect.          -a         - Enable amiga pal conversion, for playing Amiga versions          -d[<num>]  - Set debug verbosity to <num>          -w[<file>] - Write configuration file diff --git a/scummvm.cpp b/scummvm.cpp index 4a40d6cb13..701d1da602 100644 --- a/scummvm.cpp +++ b/scummvm.cpp @@ -1392,7 +1392,6 @@ Scumm *Scumm::createFromDetector(GameDetector *detector, OSystem *syst)  			imuse = IMuse::create_midi(syst, detector->createMidi());  		} -		imuse->property(IMuse::PROP_MT32_EMULATE, detector->_mt32emulate);  		if (detector->_gameTempo != 0)  			imuse->property(IMuse::PROP_TEMPO_BASE, detector->_gameTempo); diff --git a/sound/imuse.cpp b/sound/imuse.cpp index 7d609a9902..f702c7cedb 100644 --- a/sound/imuse.cpp +++ b/sound/imuse.cpp @@ -116,6 +116,8 @@ struct Player {  	HookDatas _hook; +	bool _mt32emulate; +  	/* Player part */  	void hook_clear();  	void clear(); @@ -320,8 +322,6 @@ private:  	byte _locked;  	byte _hardware_type; -public: -	bool _mt32emulate;  private: @@ -359,6 +359,7 @@ private:  	CommandQueue _cmd_queue[64];  	byte *findTag(int sound, char *tag, int index); +	bool isMT32(int sound);  	int get_queue_sound_status(int sound);  	Player *allocate_player(byte priority);  	void handle_marker(uint id, byte data); @@ -494,7 +495,7 @@ struct MidiChannelAdl : MidiChannel {  	Struct11 _s11b;  }; -struct IMuseAdlib : public IMuseDriver { +class IMuseAdlib : public IMuseDriver {  private:  	FM_OPL *_opl;  	byte *_adlib_reg_cache; @@ -592,7 +593,7 @@ class IMuseGM : public IMuseDriver {  	void midiEffectLevel(byte chan, byte level);  	void midiChorus(byte chan, byte chorus);  	void midiControl0(byte chan, byte value); -	void midiProgram(byte chan, byte program); +	void midiProgram(byte chan, byte program, bool mt32emulate);  	void midiPan(byte chan, int8 pan);  	void midiNoteOn(byte chan, byte note, byte velocity);  	void midiNoteOff(byte chan, byte note); @@ -774,7 +775,34 @@ byte *IMuseInternal::findTag(int sound, char *tag, int index)  	debug(1, "IMuseInternal::findTag failed finding sound %d", sound);  	return NULL; +} + +bool IMuseInternal::isMT32(int sound) +{ +	byte *ptr = NULL; +	uint32 tag; + +	if (_base_sounds) +		ptr = _base_sounds[sound]; + +	if (ptr == NULL) +		return false; +	tag = *(((uint32 *)ptr)+1); +	switch (tag) { +	case MKID('ADL '): +		return false; +	case MKID('ROL '): +		return true; +	case MKID('GMD '): +		return false; +	case MKID('MAC '): +		return true; +	case MKID('SPK '): +		return false; +	} +	 +	return false;  }  bool IMuseInternal::start_sound(int sound) @@ -922,46 +950,6 @@ void IMuseInternal::sequencer_timers()  	}  } -void Player::sequencer_timer() -{ -	byte *mtrk; -	uint32 counter; -	byte *song_ptr; - -	counter = _timer_counter + _timer_speed; -	_timer_counter = counter & 0xFFFF; -	_cur_pos += counter >> 16; -	_tick_index += counter >> 16; - -	if (_tick_index >= _ticks_per_beat) { -		_beat_index += _tick_index / _ticks_per_beat; -		_tick_index %= _ticks_per_beat; -	} -	if (_loop_counter && _beat_index >= _loop_from_beat -			&& _tick_index >= _loop_from_tick) { -		_loop_counter--; -		jump(_track_index, _loop_to_beat, _loop_to_tick); -	} -	if (_next_pos <= _cur_pos) { -		mtrk = _se->findTag(_song_index, "MTrk", _track_index); -		if (!mtrk) { -			warning("Sound %d was unloaded while active", _song_index); -			clear(); -		} else { -			song_ptr = mtrk + _song_offset; -			_abort = false; - -			while (_next_pos <= _cur_pos) { -				song_ptr = parse_midi(song_ptr); -				if (!song_ptr || _abort) -					return; -				_next_pos += get_delta_time(&song_ptr); -			} -			_song_offset = song_ptr - mtrk; -		} -	} -} -  void IMuseInternal::handle_marker(uint id, byte data)  {  	uint16 *p; @@ -1577,10 +1565,6 @@ uint32 IMuseInternal::property(int prop, uint32 value) {  	case IMuse::PROP_TEMPO_BASE:  		_game_tempo = value;  		break; - -	case IMuse::PROP_MT32_EMULATE: -		_mt32emulate = !!value; -		break;  	}  	return 0;  } @@ -1719,6 +1703,7 @@ bool Player::start_sound(int sound)  			return false;  		}  	} +	_mt32emulate = _se->isMT32(sound);  	_parts = NULL;  	_active = true;  	_id = sound; @@ -2728,6 +2713,46 @@ int Player::query_part_param(int param, byte chan)  	return 129;  } +void Player::sequencer_timer() +{ +	byte *mtrk; +	uint32 counter; +	byte *song_ptr; + +	counter = _timer_counter + _timer_speed; +	_timer_counter = counter & 0xFFFF; +	_cur_pos += counter >> 16; +	_tick_index += counter >> 16; + +	if (_tick_index >= _ticks_per_beat) { +		_beat_index += _tick_index / _ticks_per_beat; +		_tick_index %= _ticks_per_beat; +	} +	if (_loop_counter && _beat_index >= _loop_from_beat +			&& _tick_index >= _loop_from_tick) { +		_loop_counter--; +		jump(_track_index, _loop_to_beat, _loop_to_tick); +	} +	if (_next_pos <= _cur_pos) { +		mtrk = _se->findTag(_song_index, "MTrk", _track_index); +		if (!mtrk) { +			warning("Sound %d was unloaded while active", _song_index); +			clear(); +		} else { +			song_ptr = mtrk + _song_offset; +			_abort = false; + +			while (_next_pos <= _cur_pos) { +				song_ptr = parse_midi(song_ptr); +				if (!song_ptr || _abort) +					return; +				_next_pos += get_delta_time(&song_ptr); +			} +			_song_offset = song_ptr - mtrk; +		} +	} +} +  /*******************************************************************/  #define OFFS(type,item) ((int)(&((type*)0)->item)) @@ -2912,6 +2937,7 @@ void IMuseInternal::fix_players_after_load(Scumm *scumm)  		if (player->_active) {  			player->set_tempo(player->_tempo);  			scumm->getResourceAddress(rtSound, player->_id); +			player->_mt32emulate = isMT32(player->_id);  		}  	}  } @@ -4153,10 +4179,10 @@ void IMuseGM::midiControl0(byte chan, byte value)  } -void IMuseGM::midiProgram(byte chan, byte program) +void IMuseGM::midiProgram(byte chan, byte program, bool mt32emulate)  {  //	if ((chan + 1) != 10) {				/* Ignore percussion prededed by patch change */ -		if (_se->_mt32emulate) +		if (mt32emulate)  			program = mt32_to_gmidi[program];  		_md->send(program << 8 | 0xC0 | chan); @@ -4197,7 +4223,7 @@ void IMuseGM::part_key_on(Part *part, byte note, byte velocity)  		midiNoteOn(mc->_chan, note, velocity);  	} else if (part->_percussion) {  		midiVolume(SPECIAL_CHANNEL, part->_vol_eff); -		midiProgram(SPECIAL_CHANNEL, part->_bank); +		midiProgram(SPECIAL_CHANNEL, part->_bank, part->_player->_mt32emulate);  		midiNoteOn(SPECIAL_CHANNEL, note, velocity);  	}  } @@ -4408,10 +4434,10 @@ void IMuseGM::part_changed(Part *part, byte what)  	if (what & pcProgram) {  		if (part->_bank) {  			midiControl0(mc->_chan, part->_bank); -			midiProgram(mc->_chan, part->_program); +			midiProgram(mc->_chan, part->_program, part->_player->_mt32emulate);  			midiControl0(mc->_chan, 0);  		} else { -			midiProgram(mc->_chan, part->_program); +			midiProgram(mc->_chan, part->_program, part->_player->_mt32emulate);  		}  	} diff --git a/sound/imuse.h b/sound/imuse.h index b88177948a..2559b2a60a 100644 --- a/sound/imuse.h +++ b/sound/imuse.h @@ -26,7 +26,6 @@ class IMuse {  public:  	enum {  		PROP_TEMPO_BASE = 1, -		PROP_MT32_EMULATE = 2,  	};  	IMuse(); | 
