Fix for Bug [810564] ALL: missing instruments with native MT-32

As defined in Patch [811623] MT-32 patch for Bug 810564

Added a channel mask to MPU-401 devices so that --native-mt32
may force the device to use only the subset of MIDI channels
actually supported by the MT-32. Also added a best-guess
interpretation of iMuse Part priority in the SysEx 0x00 msg,
since part priorities become more of an issue when the
channel count is cramped.

svn-id: r10409
This commit is contained in:
Jamieson Christian 2003-09-25 22:32:05 +00:00
parent f5d8300043
commit a30eb131bb
6 changed files with 23 additions and 5 deletions

View file

@ -39,7 +39,6 @@ private:
bool _isOpen;
void check_error(MMRESULT result);
uint32 property(int prop, uint32 param) { return 0; }
public:
MidiDriver_WIN() : _isOpen (false) { }

View file

@ -374,6 +374,7 @@ void Player::sysEx(byte *p, uint16 len) {
// as follows:
// BYTE 00: Channel #
// BYTE 02: BIT 01(0x01): Part on?(1 = yes)
// BYTE 04: Priority adjustment [guessing]
// BYTE 05: Volume(upper 4 bits) [guessing]
// BYTE 06: Volume(lower 4 bits) [guessing]
// BYTE 09: BIT 04(0x08): Percussion?(1 = yes)
@ -382,6 +383,7 @@ void Player::sysEx(byte *p, uint16 len) {
part = getPart(p[0] & 0x0F);
if (part) {
part->set_onoff(p[2] & 0x01);
part->set_pri (p[4]);
part->setVolume((p[5] & 0x0F) << 4 |(p[6] & 0x0F));
part->_percussion = _isGM ?((p[9] & 0x08) > 0) : false;
if (part->_percussion) {

View file

@ -738,7 +738,10 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
} else if (((_midiDriver == MD_PCJR) || (_midiDriver == MD_PCSPK)) && ((_version > 2) && (_version < 5))) {
_musicEngine = _playerV2 = new Player_V2(this);
} else if (_version > 2) {
_musicEngine = _imuse = IMuse::create(syst, _mixer, detector->createMidi());
MidiDriver *driver = detector->createMidi();
if (driver && detector->_native_mt32)
driver->property (MidiDriver::PROP_CHANNEL_MASK, 0x03FE);
_musicEngine = _imuse = IMuse::create(syst, _mixer, driver);
if (_imuse) {
if (detector->_gameTempo != 0)
_imuse->property(IMuse::PROP_TEMPO_BASE, detector->_gameTempo);

View file

@ -44,7 +44,8 @@ public:
enum {
// PROP_TIMEDIV = 1,
PROP_OLD_ADLIB = 2
PROP_OLD_ADLIB = 2,
PROP_CHANNEL_MASK = 3
};
// Open the midi driver.

View file

@ -85,7 +85,8 @@ MidiDriver_MPU401::MidiDriver_MPU401() :
_started_thread (false),
_mutex (0),
_timer_proc (0),
_timer_param (0)
_timer_param (0),
_channel_mask (0xFFFF) // Permit all 16 channels by default
{
uint i;
@ -106,12 +107,22 @@ void MidiDriver_MPU401::close() {
send (0x7B << 8 | 0xB0 | i);
}
uint32 MidiDriver_MPU401::property (int prop, uint32 param) {
switch (prop) {
case PROP_CHANNEL_MASK:
_channel_mask = param & 0xFFFF;
return 1;
}
return 0;
}
MidiChannel *MidiDriver_MPU401::allocateChannel() {
MidiChannel_MPU401 *chan;
uint i;
for (i = 0; i < ARRAYSIZE(_midi_channels); ++i) {
if (i == 9)
if (i == 9 || !(_channel_mask & (1 << i)))
continue;
chan = &_midi_channels[i];
if (!chan->_allocated) {

View file

@ -85,6 +85,7 @@ private:
OSystem::MutexRef _mutex; // Concurrent shutdown barrier
volatile TimerCallback _timer_proc;
void *_timer_param;
uint16 _channel_mask;
static int midi_driver_thread (void *param);
@ -94,6 +95,7 @@ public:
virtual void close();
void setTimerCallback(void *timer_param, TimerCallback timer_proc);
uint32 getBaseTempo(void) { return 10000; }
uint32 property(int prop, uint32 param);
MidiChannel *allocateChannel();
MidiChannel *getPercussionChannel() { return &_midi_channels [9]; }