[Scummvm-cvs-logs] SF.net SVN: scummvm: [21344] scummvm/trunk/engines/kyra/sound_adlib.cpp

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Fri Mar 17 04:04:09 CET 2006


Revision: 21344
Author:   eriktorbjorn
Date:     2006-03-17 04:03:24 -0800 (Fri, 17 Mar 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21344&view=rev

Log Message:
-----------
The opcode functions are not allowed to modify their own channel.dataptr
directly. If they want a new data pointer, they have to use the dataptr
parameter. This fixes a subtle bug that would cause the wrong music to play
when getting the quill in Kyra 1.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/sound_adlib.cpp
Modified: scummvm/trunk/engines/kyra/sound_adlib.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_adlib.cpp	2006-03-17 01:55:43 UTC (rev 21343)
+++ scummvm/trunk/engines/kyra/sound_adlib.cpp	2006-03-17 12:03:24 UTC (rev 21344)
@@ -693,16 +693,26 @@
 				if (channel.duration == channel.spacing1 && _curChannel != 9)
 					noteOff(channel);
 			} else {
-				while (channel.dataptr) {
-					uint8 opcode = *channel.dataptr++;
-					uint8 param = *channel.dataptr++;
+				// An opcode is not allowed to modify its own
+				// data pointer except through the 'dataptr'
+				// parameter. To enforce that, we have to work
+				// on a copy of the data pointer.
+				//
+				// This fixes a subtle music bug where the
+				// wrong music would play when getting the
+				// quill in Kyra 1.
+				uint8 *dataptr = channel.dataptr;
+				while (dataptr) {
+					uint8 opcode = *dataptr++;
+					uint8 param = *dataptr++;
 
 					if (opcode & 0x80) {
 						opcode &= 0x7F;
 						if (opcode >= _parserOpcodeTableSize)
 							opcode = _parserOpcodeTableSize - 1;
 						debugC(9, kDebugLevelSound, "Calling opcode '%s' (%d) (channel: %d)", _parserOpcodeTable[opcode].name, opcode, _curChannel);
-						result = (this->*(_parserOpcodeTable[opcode].function))(channel.dataptr, channel, param);
+						result = (this->*(_parserOpcodeTable[opcode].function))(dataptr, channel, param);
+						channel.dataptr = dataptr;
 						if (result)
 							break;
 					} else {
@@ -710,8 +720,10 @@
 						setupNote(opcode, channel);
 						noteOn(channel);
 						setupDuration(param, channel);
-						if (param)
+						if (param) {
+							channel.dataptr = dataptr;
 							break;
+						}
 					}
 				}
 			}
@@ -1219,6 +1231,7 @@
 		channel2.duration = 1;
 		unkOutput2(chan);
 	}
+
 	return 0;
 }
 


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