[Scummvm-cvs-logs] CVS: scummvm/scumm imuse.cpp,2.83,2.84 imuse_internal.h,2.16,2.17 imuse_player.cpp,2.24,2.25 midiparser_ro.cpp,1.2,1.3 scummvm.cpp,2.342,2.343

Jamieson Christian jamieson630 at users.sourceforge.net
Sat Aug 16 10:09:07 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv27302/scummvm/scumm

Modified Files:
	imuse.cpp imuse_internal.h imuse_player.cpp midiparser_ro.cpp 
	scummvm.cpp 
Log Message:
More corrections to the VAR_MUSIC_TIMER
computations, mostly to produce the
exptected output with AD resources.

Index: imuse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse.cpp,v
retrieving revision 2.83
retrieving revision 2.84
diff -u -d -r2.83 -r2.84
--- imuse.cpp	16 Aug 2003 09:33:45 -0000	2.83
+++ imuse.cpp	16 Aug 2003 17:08:21 -0000	2.84
@@ -329,7 +329,7 @@
 				best_time = timer;
 		}
 	}
-	return best_time / 1000000;
+	return best_time;
 }
 
 void IMuseInternal::sequencer_timers(MidiDriver *midi) {

Index: imuse_internal.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_internal.h,v
retrieving revision 2.16
retrieving revision 2.17
diff -u -d -r2.16 -r2.17
--- imuse_internal.h	16 Aug 2003 09:33:45 -0000	2.16
+++ imuse_internal.h	16 Aug 2003 17:08:22 -0000	2.17
@@ -261,7 +261,7 @@
 	int    setTranspose(byte relative, int b);
 	int    setVolume(byte vol);
 	bool   startSound(int sound, MidiDriver *midi);
-	uint32  getMusicTimer();
+	int    getMusicTimer();
 
 public:
 	// MidiDriver interface

Index: imuse_player.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_player.cpp,v
retrieving revision 2.24
retrieving revision 2.25
diff -u -d -r2.24 -r2.25
--- imuse_player.cpp	16 Aug 2003 09:33:45 -0000	2.24
+++ imuse_player.cpp	16 Aug 2003 17:08:22 -0000	2.25
@@ -128,8 +128,8 @@
 	return true;
 }
 
-uint32 Player::getMusicTimer() {
-	return _parser ? _parser->getTime() : 0;
+int Player::getMusicTimer() {
+	return _parser ? (_parser->getTick() * 2 / _parser->getPPQN()) : 0;
 }
 
 bool Player::isFadingOut() {

Index: midiparser_ro.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/midiparser_ro.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- midiparser_ro.cpp	16 Aug 2003 09:33:45 -0000	1.2
+++ midiparser_ro.cpp	16 Aug 2003 17:08:22 -0000	1.3
@@ -33,7 +33,8 @@
 
 class MidiParser_RO : public MidiParser {
 protected:
-	int _markerCount; // Number of markers encountered in stream so far
+	int _markerCount;     // Number of markers encountered in stream so far
+	int _lastMarkerCount; // Cache markers until parsed event is actually consumed
 
 protected:
 	void compressToType0();
@@ -41,7 +42,7 @@
 
 public:
 	bool loadMusic (byte *data, uint32 size);
-	uint32 getTime() { return (uint32) _markerCount * 1000000; }
+	uint32 getTick() { return (uint32) _markerCount * _ppqn / 2; }
 };
 
 
@@ -53,16 +54,17 @@
 //////////////////////////////////////////////////
 
 void MidiParser_RO::parseNextEvent (EventInfo &info) {
+	_markerCount += _lastMarkerCount;
+	_lastMarkerCount = 0;
+
 	info.delta = 0;
 	do {
 		info.start = _position._play_pos;
 		info.event = *(_position._play_pos++);
 		if (info.command() == 0xA) {
-			++_markerCount;
-			continue;
-		} // end if
-
-		if (info.event == 0xF0) {
+			++_lastMarkerCount;
+			info.event = 0xF0;
+		} else if (info.event == 0xF0) {
 			byte delay = *(_position._play_pos++);
 			info.delta += delay;
 			continue;
@@ -71,9 +73,15 @@
 	} while (true);
 
 	// Seems to indicate EOT
-	if (info.event == 0)
-		info.event = 0xF0;
-	else if (info.event < 0x80)
+	if (info.event == 0) {
+		info.event = 0xFF;
+		info.ext.type = 0x2F;
+		info.length = 0;
+		info.ext.data = 0;
+		return;
+	}
+
+	if (info.event < 0x80)
 		return;
 
 	_position._running_status = info.event;
@@ -91,13 +99,16 @@
 		info.length = 0;
 		break;
 
-	case 0xF: // End of Track messages
-		if (info.event == 0xFF)
-			_autoLoop = true;
-		info.event = 0xFF;
-		info.ext.type = 0x2F;
+	case 0xF: // Marker and EOT messages
 		info.length = 0;
 		info.ext.data = 0;
+		if (info.event == 0xFF) {
+			_autoLoop = true;
+			info.ext.type = 0x2F;
+		} else {
+			info.ext.type = 0x7F; // Bogus META
+		}
+		info.event = 0xFF;
 		break;
 	}
 }
@@ -114,7 +125,7 @@
 	_num_tracks = 1;
 	_ppqn = 120;
 	_tracks[0] = pos + 2;
-	_markerCount = 0;
+	_markerCount = _lastMarkerCount = 0;
 
 	// Note that we assume the original data passed in
 	// will persist beyond this call, i.e. we do NOT

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.342
retrieving revision 2.343
diff -u -d -r2.342 -r2.343
--- scummvm.cpp	16 Aug 2003 14:24:17 -0000	2.342
+++ scummvm.cpp	16 Aug 2003 17:08:22 -0000	2.343
@@ -1207,7 +1207,7 @@
 		// Covered automatically by the Sound class
 	} else if (_playerV2) {
 		VAR(VAR_MUSIC_TIMER) = _playerV2->getMusicTimer();
-	} else if (_imuse && _midiDriver != MD_ADLIB) {
+	} else if (_imuse) {
 		VAR(VAR_MUSIC_TIMER) = _imuse->getMusicTimer();
 	} else if (_features & GF_SMALL_HEADER) {
 		// TODO: The music delay (given in milliseconds) might have to be tuned a little





More information about the Scummvm-git-logs mailing list