[Scummvm-cvs-logs] CVS: scummvm/sound midiparser.h,1.17,1.18 midiparser.cpp,1.13,1.14

Jamieson Christian jamieson630 at users.sourceforge.net
Wed Jul 9 21:35:07 CEST 2003


Update of /cvsroot/scummvm/scummvm/sound
In directory sc8-pr-cvs1:/tmp/cvs-serv9147a/scummvm/sound

Modified Files:
	midiparser.h midiparser.cpp 
Log Message:
Fix for Bug [766426]: V5 Games: Adlib SFX not looped

Modified Smart Jump logic to deal with active notes
whose Note On and Note Off events BOTH occur OUTSIDE
the range of the jump. While this is not a thorough
way to deal with Note On events that occur outside
jump points, it at least deals with the issue of
long, unchanging Adlib SFX used by some earlier
SCUMM games.

Index: midiparser.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/midiparser.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- midiparser.h	18 Jun 2003 22:46:17 -0000	1.17
+++ midiparser.h	10 Jul 2003 04:34:44 -0000	1.18
@@ -182,7 +182,7 @@
 	virtual void parseNextEvent (EventInfo &info) = 0;
 
 	void activeNote (byte channel, byte note, bool active);
-	void hangingNote (byte channel, byte note, uint32 ticks_left);
+	void hangingNote (byte channel, byte note, uint32 ticks_left, bool recycle = true);
 	void hangAllActiveNotes();
 
 	//! Platform independent BE uint32 read-and-advance.

Index: midiparser.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/midiparser.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- midiparser.cpp	18 Jun 2003 21:10:05 -0000	1.13
+++ midiparser.cpp	10 Jul 2003 04:34:44 -0000	1.14
@@ -100,7 +100,7 @@
 	}
 }
 
-void MidiParser::hangingNote (byte channel, byte note, uint32 time_left) {
+void MidiParser::hangingNote (byte channel, byte note, uint32 time_left, bool recycle) {
 	NoteTimer *best = 0;
 	NoteTimer *ptr = _hanging_notes;
 	int i;
@@ -112,11 +112,11 @@
 
 	for (i = ARRAYSIZE(_hanging_notes); i; --i, ++ptr) {
 		if (ptr->channel == channel && ptr->note == note) {
-			if (ptr->time_left && ptr->time_left < time_left)
+			if (ptr->time_left && ptr->time_left < time_left && recycle)
 				return;
 			best = ptr;
 			if (ptr->time_left) {
-				_driver->send (0x80 | channel | note << 8);
+				if (recycle) _driver->send (0x80 | channel | note << 8);
 				--_hanging_notes_count;
 			}
 			break;
@@ -272,28 +272,32 @@
 void MidiParser::hangAllActiveNotes() {
 	// Search for note off events until we have
 	// accounted for every active note.
+	uint16 temp_active [128];
+	memcpy (temp_active, _active_notes, sizeof (temp_active));
+
 	uint32 advance_tick = _position._last_event_tick;
 	while (true) {
 		int i, j;
 		for (i = 0; i < 128; ++i)
-			if (_active_notes[i] != 0) break;
+			if (temp_active[i] != 0) break;
 		if (i == 128) break;
 		parseNextEvent (_next_event);
 		advance_tick += _next_event.delta;
 		if (_next_event.command() == 0x8) {
-			if (_active_notes [_next_event.basic.param1] & (1 << _next_event.channel())) {
-				hangingNote (_next_event.channel(), _next_event.basic.param1, (advance_tick - _position._last_event_tick) * _psec_per_tick);
-				_active_notes [_next_event.basic.param1] &= ~ (1 << _next_event.channel());
+			if (temp_active[_next_event.basic.param1] & (1 << _next_event.channel())) {
+				hangingNote (_next_event.channel(), _next_event.basic.param1, (advance_tick - _position._last_event_tick) * _psec_per_tick, false);
+				temp_active[_next_event.basic.param1] &= ~ (1 << _next_event.channel());
 			}
 		} else if (_next_event.event == 0xFF && _next_event.ext.type == 0x2F) {
 			// printf ("MidiParser::hangAllActiveNotes(): Hit End of Track with active notes left!\n");
 			for (i = 0; i < 128; ++i) {
 				for (j = 0; j < 16; ++j) {
-					if (_active_notes[i] & (1 << j))
+					if (temp_active[i] & (1 << j)) {
+						activeNote (j, i, false);
 						_driver->send (0x80 | j | i << 8);
+					}
 				}
 			}
-			memset (_active_notes, 0, sizeof (_active_notes));
 			break;
 		}
 	}





More information about the Scummvm-git-logs mailing list