[Scummvm-cvs-logs] SF.net SVN: scummvm:[49119] scummvm/trunk/engines/groovie/music.cpp

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Thu May 20 19:22:47 CEST 2010


Revision: 49119
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49119&view=rev
Author:   mthreepwood
Date:     2010-05-20 17:22:45 +0000 (Thu, 20 May 2010)

Log Message:
-----------
Add initial support for T7G Mac MIDIs. Compressed MIDI is not yet supported.

Modified Paths:
--------------
    scummvm/trunk/engines/groovie/music.cpp

Modified: scummvm/trunk/engines/groovie/music.cpp
===================================================================
--- scummvm/trunk/engines/groovie/music.cpp	2010-05-20 15:23:55 UTC (rev 49118)
+++ scummvm/trunk/engines/groovie/music.cpp	2010-05-20 17:22:45 UTC (rev 49119)
@@ -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 @@
 
 // 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


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list