[Scummvm-cvs-logs] SF.net SVN: scummvm: [22898] scummvm/trunk/engines/simon/midi.cpp

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Sat Jun 3 18:55:22 CEST 2006


Revision: 22898
Author:   eriktorbjorn
Date:     2006-06-03 09:55:17 -0700 (Sat, 03 Jun 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22898&view=rev

Log Message:
-----------
This is an attempt to set the correct tempo for the Simon 1 DOS music.

Modified Paths:
--------------
    scummvm/trunk/engines/simon/midi.cpp
Modified: scummvm/trunk/engines/simon/midi.cpp
===================================================================
--- scummvm/trunk/engines/simon/midi.cpp	2006-06-03 16:33:57 UTC (rev 22897)
+++ scummvm/trunk/engines/simon/midi.cpp	2006-06-03 16:55:17 UTC (rev 22898)
@@ -400,6 +400,8 @@
 	p->data = (byte *)calloc(size + 4, 1);
 	in->read(p->data, size);
 
+	uint32 timerRate = _driver->getBaseTempo();
+
 	if (!memcmp(p->data, "GMF\x1", 4)) {
 		// The GMF header
 		// 3 BYTES: 'GMF'
@@ -408,6 +410,20 @@
 		// 1 BYTE : Ticks (Ranges from 2 - 8, always 2 for SFX)
 		// 1 BYTE : Loop control. 0 = no loop, 1 = loop
 		if (!sfx) {
+			// In the original, the ticks value indicated how many
+			// times the music timer was called before it actually
+			// did something. The larger the value the slower the
+			// music.
+			//
+			// We, on the other hand, have a timer rate which is
+			// used to control by how much the music advances on
+			// each onTimer() call. The larger the value, the
+			// faster the music.
+			//
+			// It seems that 4 corresponds to our base tempo, so
+			// this should be the right way to calculate it.
+			timerRate = (4 * _driver->getBaseTempo()) / p->data[5];
+
 			// According to bug #1004919 calling setLoop() from
 			// within a lock causes a lockup, though I have no
 			// idea when this actually happens.
@@ -418,7 +434,7 @@
 	MidiParser *parser = MidiParser::createParser_SMF();
 	parser->property(MidiParser::mpMalformedPitchBends, 1);
 	parser->setMidiDriver(this);
-	parser->setTimerRate(_driver->getBaseTempo());
+	parser->setTimerRate(timerRate);
 	if (!parser->loadMusic(p->data, size)) {
 		printf("Error reading track!\n");
 		delete parser;
@@ -443,6 +459,7 @@
 	// treat them as separate tracks -- for the
 	// purpose of jumps, anyway.
 	Common::StackLock lock(_mutex);
+printf("loadMultipleSMF\n");
 
 	MusicInfo *p = sfx ? &_sfx : &_music;
 	clearConstructs(*p);


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