diff --git a/audio/mt32gm.cpp b/audio/mt32gm.cpp index c5df819ba11..98e416c21ff 100644 --- a/audio/mt32gm.cpp +++ b/audio/mt32gm.cpp @@ -75,6 +75,9 @@ const uint8 MidiDriver_MT32GM::GS_DRUMKIT_FALLBACK_MAP[128] = { 0, 0, 0, 0, 0, 0, 0, 127 // No drumkit defined; CM-64/32L (127) }; +const uint8 MidiDriver_MT32GM::MT32_DISPLAY_NUM_CHARS; +const uint32 MidiDriver_MT32GM::MT32_DISPLAY_MEMORY_ADDRESS; + // Callback hooked up to the driver wrapped by the MIDI driver // object. Executes onTimer and the external callback set by // the setTimerCallback function. diff --git a/audio/mt32gm.h b/audio/mt32gm.h index 0bb471de640..5410be3491e 100644 --- a/audio/mt32gm.h +++ b/audio/mt32gm.h @@ -118,6 +118,9 @@ public: // Map for correcting Roland GS drumkit numbers. static const uint8 GS_DRUMKIT_FALLBACK_MAP[128]; + static const uint8 MT32_DISPLAY_NUM_CHARS = 20; + static const uint32 MT32_DISPLAY_MEMORY_ADDRESS = 0x20 << 14; + protected: static const uint8 MAXIMUM_MT32_ACTIVE_NOTES = 48; static const uint8 MAXIMUM_GM_ACTIVE_NOTES = 96; diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index f24a8e3f226..2da968c5b66 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -44,6 +44,8 @@ namespace Saga { +const uint8 Music::MT32_GOODBYE_MSG[] = { 0x47, 0x6F, 0x6F, 0x64, 0x62, 0x79, 0x65, 0x21, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; + Music::Music(SagaEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer), _parser(0), _driver(0), _driverPC98(0), _musicContext(0) { _currentVolume = 0; _currentMusicBuffer = NULL; @@ -173,6 +175,18 @@ Music::~Music() { } } +void Music::close() { + if (_parser) + _parser->stopPlaying(); + + if (_vm->getGameId() == GID_ITE && _vm->getPlatform() == Common::kPlatformDOS && _driver) { + MidiDriver_MT32GM *mt32Driver = dynamic_cast(_driver); + if (mt32Driver) + mt32Driver->sysExMT32(MT32_GOODBYE_MSG, MidiDriver_MT32GM::MT32_DISPLAY_NUM_CHARS, + MidiDriver_MT32GM::MT32_DISPLAY_MEMORY_ADDRESS, false, false); + } +} + void Music::musicVolumeGaugeCallback(void *refCon) { ((Music *)refCon)->musicVolumeGauge(); } diff --git a/engines/saga/music.h b/engines/saga/music.h index 29e10c4a2b5..c888541dadf 100644 --- a/engines/saga/music.h +++ b/engines/saga/music.h @@ -27,6 +27,7 @@ #include "audio/mididrv.h" #include "audio/mididrv_ms.h" +#include "audio/mt32gm.h" #include "audio/midiparser.h" #include "audio/mixer.h" #include "audio/softsynth/fmtowns_pc98/towns_pc98_driver.h" @@ -43,10 +44,12 @@ enum MusicFlags { class Music { private: static const uint8 MUSIC_SUNSPOT = 26; + static const uint8 MT32_GOODBYE_MSG[MidiDriver_MT32GM::MT32_DISPLAY_NUM_CHARS]; public: Music(SagaEngine *vm, Audio::Mixer *mixer); ~Music(); + void close(); bool isPlaying(); bool hasDigitalMusic() { return _digitalMusic; } diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp index 070173ce0ac..ddc2eb066ea 100644 --- a/engines/saga/saga.cpp +++ b/engines/saga/saga.cpp @@ -366,6 +366,8 @@ Common::Error SagaEngine::run() { _system->delayMillis(10); } + _music->close(); + return Common::kNoError; }