aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamieson Christian2002-12-01 15:51:29 +0000
committerJamieson Christian2002-12-01 15:51:29 +0000
commitcc6c37e1ad6434c7e0f4537d3753e20a39cc921a (patch)
treebaa5725fe0b2d78c565e67a7725477301b7aa4a7
parent885c0ac565d0117a3c8b11ac6978747f53d5b431 (diff)
downloadscummvm-rg350-cc6c37e1ad6434c7e0f4537d3753e20a39cc921a.tar.gz
scummvm-rg350-cc6c37e1ad6434c7e0f4537d3753e20a39cc921a.tar.bz2
scummvm-rg350-cc6c37e1ad6434c7e0f4537d3753e20a39cc921a.zip
Fixed Adlib instrument setup in old (GF_SMALL_HEADER) games.
Restored MT-32 emulation lost during restructuring. svn-id: r5786
-rw-r--r--backends/midi/adlib.cpp19
-rw-r--r--scumm/imuse.cpp24
-rw-r--r--sound/mididrv.h1
3 files changed, 30 insertions, 14 deletions
diff --git a/backends/midi/adlib.cpp b/backends/midi/adlib.cpp
index cf1b453e88..f19596ffd6 100644
--- a/backends/midi/adlib.cpp
+++ b/backends/midi/adlib.cpp
@@ -503,6 +503,8 @@ public:
void send(uint32 b);
void pause(bool p) { }
void set_stream_callback(void *param, StreamCallback *sc) { } // No streaming support. Use MidiStreamer wrapper
+ uint32 property (int prop, uint32 param);
+
void setPitchBendRange (byte channel, uint range);
void sysEx_customInstrument (byte channel, uint32 type, byte *instr);
@@ -520,6 +522,7 @@ public:
private:
int _mode;
+ bool _game_SmallHeader;
FM_OPL *_opl;
byte *_adlib_reg_cache;
@@ -726,6 +729,7 @@ MidiDriver_ADLIB::MidiDriver_ADLIB()
for (i = 0; i < ARRAYSIZE(_parts); ++i) {
_parts[i].init (this);
}
+ _game_SmallHeader = false;
}
int MidiDriver_ADLIB::open (int mode)
@@ -811,6 +815,17 @@ void MidiDriver_ADLIB::send (uint32 b)
}
}
+uint32 MidiDriver_ADLIB::property (int prop, uint32 param)
+{
+ switch (prop) {
+ case PROP_SMALLHEADER: // Indicates older game, use different operator volume algorithm
+ _game_SmallHeader = (param > 0);
+ return 1;
+ }
+
+ return 0;
+}
+
void MidiDriver_ADLIB::setPitchBendRange (byte channel, uint range)
{
MidiChannelAdl *mc;
@@ -1302,9 +1317,7 @@ void MidiDriver_ADLIB::adlib_setup_channel(int chan, Instrument * instr, byte vo
port = channel_mappings[chan];
adlib_write(port + 0x20, instr->flags_1);
- // FIXME: Without using g_scumm, this may make older games sound weird.
- // Gotta transform the volume *before* it gets sent here.
- if (/*!(g_scumm->_features & GF_SMALL_HEADER)*/true ||(instr->feedback & 1))
+ if (!_game_SmallHeader ||(instr->feedback & 1))
adlib_write(port + 0x40, (instr->oplvl_1 | 0x3F) - vol_1 );
else
adlib_write(port + 0x40, instr->oplvl_1);
diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp
index 1c529fc57a..25aba61c78 100644
--- a/scumm/imuse.cpp
+++ b/scumm/imuse.cpp
@@ -696,7 +696,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, bool mt32emulate);
+ void midiProgram(MidiChannel *mc, byte program, bool mt32emulate);
void midiPan(byte chan, int8 pan);
void midiNoteOn(byte chan, byte note, byte velocity);
void midiNoteOff(byte chan, byte note);
@@ -2501,7 +2501,7 @@ void Player::parse_sysex(byte *p, uint len)
case 33: /* param adjust */
a = *p++ & 0x0F;
- if (_se->_hardware_type != *p++)
+ if (_se->_hardware_type != *p++ && false)
break;
decode_sysex_bytes(p, buf, len - 3);
part = get_part(a);
@@ -2572,7 +2572,7 @@ void Player::parse_sysex(byte *p, uint len)
break;
default:
- debug(6, "unknown sysex %d", code);
+ warning ("Unknown SysEx command %d", (int) code);
}
}
@@ -4857,14 +4857,12 @@ void IMuseGM::midiControl0(byte chan, byte value)
}
-void IMuseGM::midiProgram(byte chan, byte program, bool mt32emulate)
+void IMuseGM::midiProgram(MidiChannel *mc, byte program, bool mt32emulate)
{
- if (mt32emulate) { /* Don't convert the percussion channel, it is the same in GM and MT32 */
- if (chan != PERCUSSION_CHANNEL)
- program = mt32_to_gmidi[program];
- }
-
- _md->send(program << 8 | 0xC0 | chan);
+ if (mt32emulate)
+ program = mt32_to_gmidi[program];
+ mc->programChange (program);
+// _md->send(program << 8 | 0xC0 | chan);
}
void IMuseGM::midiPan(byte chan, int8 pan)
@@ -5179,11 +5177,13 @@ void IMuseGM::part_changed(Part *part, uint16 what)
// midiProgram(mc->_chan, part->_program, part->_player->_mt32emulate);
// midiControl0(mc->_chan, 0);
mc->controlChange (0, part->_bank);
- mc->programChange (part->_program /*, part->_player->_mt32emulate*/);
+ midiProgram (mc, part->_program, part->_player->_mt32emulate);
+// mc->programChange (part->_program /*, part->_player->_mt32emulate*/);
mc->controlChange (0, 0);
} else {
// midiProgram(mc->_chan, part->_program, part->_player->_mt32emulate);
mc->programChange (part->_program /*, part->_player->_mt32emulate*/);
+ midiProgram (mc, part->_program, part->_player->_mt32emulate);
}
}
} else {
@@ -5227,6 +5227,8 @@ void IMuseGM::part_off(Part *part)
IMuse *IMuse::create(OSystem *syst, MidiDriver *midi, SoundMixer *mixer)
{
IMuse *engine = (IMuse *) IMuseInternal::create (syst, midi, mixer);
+ if (midi)
+ midi->property (MidiDriver::PROP_SMALLHEADER, (g_scumm->_features & GF_SMALL_HEADER) ? 1 : 0);
return (IMuse *) new IMuseMonitor (syst, engine);
}
diff --git a/sound/mididrv.h b/sound/mididrv.h
index 2c47344586..42aed4fcb5 100644
--- a/sound/mididrv.h
+++ b/sound/mididrv.h
@@ -69,6 +69,7 @@ public:
enum {
PROP_TIMEDIV = 1,
+ PROP_SMALLHEADER = 2,
};