aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2010-05-20 17:22:45 +0000
committerMatthew Hoops2010-05-20 17:22:45 +0000
commitf76f64774aa5c7d9669196c0258767d1e9f43cfb (patch)
tree94e4efcb9df421e4755edbbe9716c7f59cc91cc0
parentfd5000fb7907cc401197cb84d2ae39559e82c7ac (diff)
downloadscummvm-rg350-f76f64774aa5c7d9669196c0258767d1e9f43cfb.tar.gz
scummvm-rg350-f76f64774aa5c7d9669196c0258767d1e9f43cfb.tar.bz2
scummvm-rg350-f76f64774aa5c7d9669196c0258767d1e9f43cfb.zip
Add initial support for T7G Mac MIDIs. Compressed MIDI is not yet supported.
svn-id: r49119
-rw-r--r--engines/groovie/music.cpp45
1 files changed, 34 insertions, 11 deletions
diff --git a/engines/groovie/music.cpp b/engines/groovie/music.cpp
index 3f08ea19ad..f6670da716 100644
--- a/engines/groovie/music.cpp
+++ b/engines/groovie/music.cpp
@@ -23,10 +23,12 @@
*
*/
+#include "groovie/lzss.h"
#include "groovie/music.h"
#include "groovie/resource.h"
#include "common/config-manager.h"
+#include "common/macresman.h"
#include "sound/audiocd.h"
namespace Groovie {
@@ -674,25 +676,46 @@ void MusicPlayerXMI::setTimbreMT(byte channel, const Timbre &timbre) {
// MusicPlayerMac
-MusicPlayerMac::MusicPlayerMac(GroovieEngine *vm) :
- MusicPlayerMidi(vm) {
+MusicPlayerMac::MusicPlayerMac(GroovieEngine *vm) : MusicPlayerMidi(vm) {
+ // Create the parser
+ _midiParser = MidiParser::createParser_SMF();
+
+ // Create the driver
+ MidiDriverType driver = detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI);
+ _driver = createMidi(driver);
+ this->open();
+
+ // Set the parser's driver
+ _midiParser->setMidiDriver(this);
+
+ // Set the timer rate
+ _midiParser->setTimerRate(_driver->getBaseTempo());
+
+ // Sanity check
+ assert(_vm->_macResFork);
}
bool MusicPlayerMac::load(uint32 fileref, bool loop) {
debugC(1, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Starting the playback of song: %04X", fileref);
- debug("Groovie::Music: Starting the playback of song: %04X %d", fileref, fileref);
- // Open the song resource
- /*
- Common::SeekableReadStream *file = _vm->_resMan->open(fileref);
- if (!file) {
- error("Groovie::Music: Couldn't find resource 0x%04X", fileref);
+ // First try for compressed MIDI
+ Common::SeekableReadStream *file = _vm->_macResFork->getResource(MKID_BE('cmid'), fileref & 0x3FF);
+
+ if (file) {
+ // TODO: A form of LZSS, not supported by the current Groovie decoder.
+ // The offset/length uint16 is BE, but not sure the amount of length bits
+ // nor whether the offset is absolute/relative.
+ warning("TODO: Mac Compressed MIDI: cmid 0x%04x", fileref & 0x3FF);
+ delete file;
return false;
}
- */
- //return loadParser(file, loop);
- return false;
+ // Otherwise, it's uncompressed
+ file = _vm->_macResFork->getResource(MKID_BE('Midi'), fileref & 0x3FF);
+ if (!file)
+ error("Groovie::Music: Couldn't find resource 0x%04X", fileref);
+
+ return loadParser(file, loop);
}
} // End of Groovie namespace