Skip to content

Commit

Permalink
SCUMM: Clean-up of Roland GS code
Browse files Browse the repository at this point in the history
1. Remove _sc55 bool. All Roland GS-capable devices have MT-32 sound/drum maps, so they should always be used when _enable_gs is set.
2. Always enable _native_mt32 if Roland GS mode is selected. I don't know why I never did this originally, since _enable_gs is automatically disabled for SCUMM v6+ games that use General MIDI tracks instead of MT-32 music.
3. Set master tune for GS devices to 442.0kHz. This is the master tune setting for the MT-32.
  • Loading branch information
tcarey authored and bluegr committed May 11, 2013
1 parent 27346f8 commit dc6b39d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 30 deletions.
52 changes: 23 additions & 29 deletions engines/scumm/imuse/imuse.cpp
Expand Up @@ -46,7 +46,6 @@ namespace Scumm {
IMuseInternal::IMuseInternal() :
_native_mt32(false),
_enable_gs(false),
_sc55(false),
_midi_adlib(NULL),
_midi_native(NULL),
_sysex(NULL),
Expand Down Expand Up @@ -495,12 +494,9 @@ uint32 IMuseInternal::property(int prop, uint32 value) {
case IMuse::PROP_GS:
_enable_gs = (value > 0);

// If True Roland MT-32 is not selected, run in GM or GS mode.
// If it is selected, change the Roland GS synth to MT-32 mode.
if (_midi_native && !_native_mt32)
initGM(_midi_native);
else if (_midi_native && _native_mt32 && _enable_gs) {
_sc55 = true;
// GS Mode emulates MT-32 on a GS device, so _native_mt32 should always be true
if (_midi_native && _enable_gs) {
_native_mt32 = true;
initGM(_midi_native);
}
break;
Expand Down Expand Up @@ -1499,7 +1495,7 @@ void IMuseInternal::initGM(MidiDriver *midi) {

if (_enable_gs) {
// All GS devices recognize the GS Reset command,
// even with Roland's ID. It is impractical to
// even using Roland's ID. It is impractical to
// support other manufacturers' devices for
// further GS settings, as there are limitless
// numbers of them out there that would each
Expand All @@ -1513,30 +1509,28 @@ void IMuseInternal::initGM(MidiDriver *midi) {
midi->sysEx(buffer, 9);
debug(2, "GS SysEx: GS Reset");
_system->delayMillis(200);

// Set global Master Tune to 442.0kHz, as on the MT-32
memcpy(&buffer[4], "\x40\x00\x00\x00\x04\x04\x0F\x29", 8);
midi->sysEx(buffer, 12);
debug(2, "GS SysEx: Master Tune set to 442.0kHz");

if (_sc55) {
// This mode is for GS devices that support an MT-32-compatible
// Map, such as the Roland Sound Canvas line of modules. It
// will allow them to work with True MT-32 mode, but will
// obviously still ignore MT-32 SysEx (and thus custom
// instruments).

// Set Channels 1-16 to SC-55 Map, then CM-64/32L Variation
for (i = 0; i < 16; ++i) {
midi->send((127 << 16) | (0 << 8) | (0xB0 | i));
midi->send((1 << 16) | (32 << 8) | (0xB0 | i));
midi->send((0 << 16) | (0 << 8) | (0xC0 | i));
}
debug(2, "GS Program Change: CM-64/32L Map Selected");

// Set Percussion Channel to SC-55 Map (CC#32, 01H), then
// Switch Drum Map to CM-64/32L (MT-32 Compatible Drums)
midi->getPercussionChannel()->controlChange(0, 0);
midi->getPercussionChannel()->controlChange(32, 1);
midi->send(127 << 8 | 0xC0 | 9);
debug(2, "GS Program Change: Drum Map is CM-64/32L");
// Note: All Roland GS devices support CM-64/32L maps

// Set Channels 1-16 to SC-55 Map, then CM-64/32L Variation
for (i = 0; i < 16; ++i) {
midi->send((127 << 16) | (0 << 8) | (0xB0 | i));
midi->send((1 << 16) | (32 << 8) | (0xB0 | i));
midi->send((0 << 16) | (0 << 8) | (0xC0 | i));
}
debug(2, "GS Program Change: CM-64/32L Map Selected");

// Set Percussion Channel to SC-55 Map (CC#32, 01H), then
// Switch Drum Map to CM-64/32L (MT-32 Compatible Drums)
midi->getPercussionChannel()->controlChange(0, 0);
midi->getPercussionChannel()->controlChange(32, 1);
midi->send(127 << 8 | 0xC0 | 9);
debug(2, "GS Program Change: Drum Map is CM-64/32L");

// Set Master Chorus to 0. The MT-32 has no chorus capability.
memcpy(&buffer[4], "\x40\x01\x3A\x00\x05", 5);
Expand Down
1 change: 0 additions & 1 deletion engines/scumm/imuse/imuse_internal.h
Expand Up @@ -390,7 +390,6 @@ class IMuseInternal : public IMuse {
protected:
bool _native_mt32;
bool _enable_gs;
bool _sc55;
MidiDriver *_midi_adlib;
MidiDriver *_midi_native;
TimerCallbackInfo _timer_info_adlib;
Expand Down

0 comments on commit dc6b39d

Please sign in to comment.