diff options
Diffstat (limited to 'engines/scumm/imuse/instrument.cpp')
-rw-r--r-- | engines/scumm/imuse/instrument.cpp | 100 |
1 files changed, 79 insertions, 21 deletions
diff --git a/engines/scumm/imuse/instrument.cpp b/engines/scumm/imuse/instrument.cpp index 955700fc2b..11bb4e7605 100644 --- a/engines/scumm/imuse/instrument.cpp +++ b/engines/scumm/imuse/instrument.cpp @@ -114,14 +114,15 @@ roland_to_gm_map[] = { // { "trickle4 ", ??? } }; +// This emulates the percussion bank setup LEC used with the MT-32, +// where notes 24 - 34 were assigned instruments without reverb. +// It also fixes problems on GS devices that map sounds to these +// notes by default. const byte Instrument::_gmRhythmMap[35] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 36, 37, 38, 39, 40, 41, 66, 47, - 65, 48, 56}; - // This emulates the percussion bank setup LEC used with the MT-32, - // where notes 24 - 34 were assigned instruments without reverb. - // It also fixes problems on GS devices that map sounds to these - // notes by default. + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 36, 37, 38, 39, 40, 41, 66, 47, + 65, 48, 56 +}; class Instrument_Program : public InstrumentInternal { private: @@ -136,15 +137,16 @@ public: void copy_to(Instrument *dest) { dest->program(_program, _mt32); } bool is_valid() { return (_program < 128) && - ((_native_mt32 == _mt32) || _native_mt32 - ? (MidiDriver::_gmToMt32[_program] < 128) - : (MidiDriver::_mt32ToGm[_program] < 128)); } + ((_native_mt32 == _mt32) || _native_mt32 + ? (MidiDriver::_gmToMt32[_program] < 128) + : (MidiDriver::_mt32ToGm[_program] < 128)); + } }; class Instrument_AdLib : public InstrumentInternal { private: -#include "common/pack-start.h" // START STRUCT PACKING +#include "common/pack-start.h" // START STRUCT PACKING struct AdLibInstrument { byte flags_1; @@ -159,13 +161,17 @@ private: byte waveform_2; byte feedback; byte flags_a; - struct { byte a,b,c,d,e,f,g,h; } extra_a; + struct { + byte a, b, c, d, e, f, g, h; + } extra_a; byte flags_b; - struct { byte a,b,c,d,e,f,g,h; } extra_b; + struct { + byte a, b, c, d, e, f, g, h; + } extra_b; byte duration; } PACKED_STRUCT; -#include "common/pack-end.h" // END STRUCT PACKING +#include "common/pack-end.h" // END STRUCT PACKING AdLibInstrument _instrument; @@ -181,7 +187,7 @@ public: class Instrument_Roland : public InstrumentInternal { private: -#include "common/pack-start.h" // START STRUCT PACKING +#include "common/pack-start.h" // START STRUCT PACKING struct RolandInstrument { byte roland_id; @@ -242,11 +248,11 @@ private: byte checksum; } PACKED_STRUCT; -#include "common/pack-end.h" // END STRUCT PACKING +#include "common/pack-end.h" // END STRUCT PACKING RolandInstrument _instrument; - char _instrument_name [11]; + char _instrument_name[11]; uint8 getEquivalentGM(); @@ -259,6 +265,19 @@ public: bool is_valid() { return (_native_mt32 ? true : (_instrument_name[0] != '\0')); } }; +class Instrument_PcSpk : public InstrumentInternal { +public: + Instrument_PcSpk(const byte *data); + Instrument_PcSpk(Serializer *s); + void saveOrLoad(Serializer *s); + void send(MidiChannel *mc); + void copy_to(Instrument *dest) { dest->pcspk((byte *)&_instrument); } + bool is_valid() { return true; } + +private: + byte _instrument[23]; +}; + //////////////////////////////////////// // // Instrument class members @@ -299,7 +318,15 @@ void Instrument::roland(const byte *instrument) { _instrument = new Instrument_Roland(instrument); } -void Instrument::saveOrLoad (Serializer *s) { +void Instrument::pcspk(const byte *instrument) { + clear(); + if (!instrument) + return; + _type = itPcSpk; + _instrument = new Instrument_PcSpk(instrument); +} + +void Instrument::saveOrLoad(Serializer *s) { if (s->isSaving()) { s->saveByte(_type); if (_instrument) @@ -319,6 +346,9 @@ void Instrument::saveOrLoad (Serializer *s) { case itRoland: _instrument = new Instrument_Roland(s); break; + case itPcSpk: + _instrument = new Instrument_PcSpk(s); + break; default: warning("No known instrument classification #%d", (int)_type); _type = itNone; @@ -333,8 +363,8 @@ void Instrument::saveOrLoad (Serializer *s) { //////////////////////////////////////// Instrument_Program::Instrument_Program(byte program, bool mt32) : -_program (program), -_mt32 (mt32) { + _program(program), + _mt32(mt32) { if (program > 127) _program = 255; } @@ -413,7 +443,7 @@ Instrument_Roland::Instrument_Roland(const byte *data) { Instrument_Roland::Instrument_Roland(Serializer *s) { _instrument_name[0] = '\0'; if (!s->isSaving()) - saveOrLoad (s); + saveOrLoad(s); else memset(&_instrument, 0, sizeof(_instrument)); } @@ -470,4 +500,32 @@ uint8 Instrument_Roland::getEquivalentGM() { return 255; } +//////////////////////////////////////// +// +// Instrument_PcSpk class members +// +//////////////////////////////////////// + +Instrument_PcSpk::Instrument_PcSpk(const byte *data) { + memcpy(_instrument, data, sizeof(_instrument)); +} + +Instrument_PcSpk::Instrument_PcSpk(Serializer *s) { + if (!s->isSaving()) + saveOrLoad(s); + else + memset(_instrument, 0, sizeof(_instrument)); +} + +void Instrument_PcSpk::saveOrLoad(Serializer *s) { + if (s->isSaving()) + s->saveBytes(_instrument, sizeof(_instrument)); + else + s->loadBytes(_instrument, sizeof(_instrument)); +} + +void Instrument_PcSpk::send(MidiChannel *mc) { + mc->sysEx_customInstrument('SPK ', (byte *)&_instrument); +} + } // End of namespace Scumm |