diff options
author | Jamieson Christian | 2003-05-25 03:19:21 +0000 |
---|---|---|
committer | Jamieson Christian | 2003-05-25 03:19:21 +0000 |
commit | 6cb01ce15c5cd120c041d607e17fddaba769c759 (patch) | |
tree | bdc82b963bb9a1b1f056345d961a8b7714e65726 /simon/midi.cpp | |
parent | be93277b65f38563f03fa9cc1cb8e6e33385c19e (diff) | |
download | scummvm-rg350-6cb01ce15c5cd120c041d607e17fddaba769c759.tar.gz scummvm-rg350-6cb01ce15c5cd120c041d607e17fddaba769c759.tar.bz2 scummvm-rg350-6cb01ce15c5cd120c041d607e17fddaba769c759.zip |
Added music support for simon1demo
svn-id: r7927
Diffstat (limited to 'simon/midi.cpp')
-rw-r--r-- | simon/midi.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/simon/midi.cpp b/simon/midi.cpp index b1129e15b8..663769ec55 100644 --- a/simon/midi.cpp +++ b/simon/midi.cpp @@ -27,6 +27,13 @@ #include "sound/mixer.h" #include "simon/simon.h" +// MidiParser_S1D is not considered part of the standard +// MidiParser suite, but we still try to mask its details +// and just provide a factory function. +extern MidiParser *MidiParser_createS1D(); + + + MidiPlayer::MidiPlayer (OSystem *system) { // Since initialize() is called every time the music changes, // this is where we'll initialize stuff that must persist @@ -448,3 +455,35 @@ void MidiPlayer::loadXMIDI (File *in, bool sfx) { p->parser = parser; // That plugs the power cord into the wall _system->unlock_mutex (_mutex); } + +void MidiPlayer::loadS1D (File *in, bool sfx) { + _system->lock_mutex (_mutex); + MusicInfo *p = sfx ? &_sfx : &_music; + clearConstructs (*p); + + uint32 size = in->readByte() | (in->readByte() << 8); + if (size != in->size() - 2) { + printf ("ERROR! Size mismatch in simon1demo MUS file (%ld versus reported %d)\n", (long) in->size() - 2, (long) size); + _system->unlock_mutex (_mutex); + return; + } + + p->data = (byte *) calloc (size, 1); + in->read (p->data, size); + + MidiParser *parser = MidiParser_createS1D(); + parser->setMidiDriver (this); + parser->setTimerRate (_driver->getBaseTempo()); + if (!parser->loadMusic (p->data, size)) { + printf ("Error reading track!\n"); + delete parser; + parser = 0; + } + + if (!sfx) { + _currentTrack = 255; + memset(_volumeTable, 127, sizeof(_volumeTable)); + } + p->parser = parser; // That plugs the power cord into the wall + _system->unlock_mutex (_mutex); +} |