[Scummvm-cvs-logs] SF.net SVN: scummvm: [21241] scummvm/trunk/dists/devcpp

Jamieson630 at users.sourceforge.net Jamieson630 at users.sourceforge.net
Sun Mar 12 10:07:02 CET 2006


Revision: 21241
Author:   Jamieson630
Date:     2006-03-12 10:06:22 -0800 (Sun, 12 Mar 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21241&view=rev

Log Message:
-----------
IMuse SysEx processing now handled by client-specified callbacks. This removes all game-specific references from the Player class. Bloodshed Dev-C++ project file updated.

Modified Paths:
--------------
    scummvm/trunk/dists/devcpp/scumm.dev
    scummvm/trunk/engines/scumm/imuse/imuse.cpp
    scummvm/trunk/engines/scumm/imuse/imuse.h
    scummvm/trunk/engines/scumm/imuse/imuse_internal.h
    scummvm/trunk/engines/scumm/imuse/imuse_player.cpp
    scummvm/trunk/engines/scumm/scumm.cpp

Added Paths:
-----------
    scummvm/trunk/engines/scumm/imuse/sysex.h
    scummvm/trunk/engines/scumm/imuse/sysex_samnmax.cpp
    scummvm/trunk/engines/scumm/imuse/sysex_scumm.cpp
Modified: scummvm/trunk/dists/devcpp/scumm.dev
===================================================================
--- scummvm/trunk/dists/devcpp/scumm.dev	2006-03-12 17:58:04 UTC (rev 21240)
+++ scummvm/trunk/dists/devcpp/scumm.dev	2006-03-12 18:06:22 UTC (rev 21241)
@@ -1,7 +1,7 @@
 [Project]
 FileName=scumm.dev
 Name=scumm
-UnitCount=139
+UnitCount=142
 Type=2
 Ver=1
 ObjFiles=
@@ -1437,3 +1437,33 @@
 OverrideBuildCmd=0
 BuildCmd=
 
+[Unit140]
+FileName=..\..\engines\scumm\imuse\sysex_scumm.cpp
+CompileCpp=1
+Folder=imuse
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit141]
+FileName=..\..\engines\scumm\imuse\sysex_samnmax.cpp
+CompileCpp=1
+Folder=imuse
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit142]
+FileName=..\..\engines\scumm\imuse\sysex.h
+CompileCpp=1
+Folder=imuse
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+

Modified: scummvm/trunk/engines/scumm/imuse/imuse.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse/imuse.cpp	2006-03-12 17:58:04 UTC (rev 21240)
+++ scummvm/trunk/engines/scumm/imuse/imuse.cpp	2006-03-12 18:06:22 UTC (rev 21241)
@@ -46,9 +46,10 @@
 _native_mt32(false),
 _enable_gs(false),
 _sc55(false),
-_midi_adlib(0),
-_midi_native(0),
-_base_sounds(0),
+_midi_adlib(NULL),
+_midi_native(NULL),
+_base_sounds(NULL),
+_sysex(NULL),
 _paused(false),
 _initialized(false),
 _tempoFactor(0),
@@ -451,6 +452,15 @@
 	return 0;
 }
 
+void IMuseInternal::addSysexHandler (byte mfgID, sysexfunc handler) {
+	// TODO: Eventually support multiple sysEx handlers and pay
+	// attention to the client-supplied manufacturer ID.
+	Common::StackLock lock(_mutex, "IMuseInternal::property()");
+	_sysex = handler;
+}
+
+
+
 ////////////////////////////////////////
 //
 // MusicEngine interface methods

Modified: scummvm/trunk/engines/scumm/imuse/imuse.h
===================================================================
--- scummvm/trunk/engines/scumm/imuse/imuse.h	2006-03-12 17:58:04 UTC (rev 21240)
+++ scummvm/trunk/engines/scumm/imuse/imuse.h	2006-03-12 18:06:22 UTC (rev 21241)
@@ -34,9 +34,12 @@
 namespace Scumm {
 
 class IMuseInternal;
+class Player;
 class ScummEngine;
 class Serializer;
 
+typedef void (*sysexfunc) (Player *, const byte *, uint16);
+
 /**
  * iMuse implementation interface.
  * MusicEngine derivative for state-tracked, interactive,
@@ -66,6 +69,7 @@
 	virtual int clear_queue() = 0;
 	virtual void setBase(byte **base) = 0;
 	virtual uint32 property(int prop, uint32 value) = 0;
+	virtual void addSysexHandler (byte mfgID, sysexfunc handler) = 0;
 
 public:
 	// MusicEngine base class methods.

Modified: scummvm/trunk/engines/scumm/imuse/imuse_internal.h
===================================================================
--- scummvm/trunk/engines/scumm/imuse/imuse_internal.h	2006-03-12 17:58:04 UTC (rev 21240)
+++ scummvm/trunk/engines/scumm/imuse/imuse_internal.h	2006-03-12 18:06:22 UTC (rev 21241)
@@ -154,6 +154,16 @@
 //////////////////////////////////////////////////
 
 class Player : public MidiDriver {
+/*
+ * External SysEx handler functions shall each be defined in
+ * a separate file. This header file shall be included at the
+ * top of the file immediately following this special #define:
+ * #define SYSEX_CALLBACK_FUNCTION nameOfHandlerFunction
+ */
+#ifdef SYSEX_CALLBACK_FUNCTION
+	friend void SYSEX_CALLBACK_FUNCTION (Player *, const byte *, uint16);
+#endif
+
 protected:
 	// Moved from IMuseInternal.
 	// This is only used by one player at a time.
@@ -367,6 +377,16 @@
 	friend class Player;
 	friend struct Part;
 
+/*
+ * External SysEx handler functions shall each be defined in
+ * a separate file. This header file shall be included at the
+ * top of the file immediately following this special #define:
+ * #define SYSEX_CALLBACK_FUNCTION nameOfHandlerFunction
+ */
+#ifdef SYSEX_CALLBACK_FUNCTION
+	friend void SYSEX_CALLBACK_FUNCTION (Player *, const byte *, uint16);
+#endif
+
 protected:
 	bool _native_mt32;
 	bool _enable_gs;
@@ -379,6 +399,12 @@
 	uint32 _game_id;
 	byte **_base_sounds;
 
+	// Plug-in SysEx handling. Right now this only supports one
+	// custom SysEx handler for the hardcoded IMUSE_SYSEX_ID
+	// manufacturer code. TODO: Expand this to support multiple
+	// SysEx handlers for client-specified manufacturer codes.
+	sysexfunc _sysex;
+
 	OSystem *_system;
 	Common::Mutex _mutex;
 
@@ -488,6 +514,7 @@
 	int32 doCommand (int numargs, int args[]);
 	void setBase(byte **base);
 	uint32 property(int prop, uint32 value);
+	virtual void addSysexHandler (byte mfgID, sysexfunc handler);
 
 public:
 	// MusicEngine interface

Modified: scummvm/trunk/engines/scumm/imuse/imuse_player.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse/imuse_player.cpp	2006-03-12 17:58:04 UTC (rev 21240)
+++ scummvm/trunk/engines/scumm/imuse/imuse_player.cpp	2006-03-12 18:06:22 UTC (rev 21241)
@@ -58,10 +58,10 @@
 //////////////////////////////////////////////////
 
 Player::Player() :
-	_midi(0),
-	_parser(0),
+	_midi(NULL),
+	_parser(NULL),
 	_passThrough(0),
-	_parts(0),
+	_parts(NULL),
 	_active(false),
 	_scanning(false),
 	_id(0),
@@ -393,180 +393,7 @@
 		debugC(DEBUG_IMUSE, "[%02d] SysEx:%s", _id, buf);
 	}
 
-	switch (code = *p++) {
-	case 0:
-		if (_se->_game_id != GID_SAMNMAX) {
-			// There are 17 bytes of useful information beyond
-			// what we've read so far. All we know about them is
-			// as follows:
-			//   BYTE 00: Channel #
-			//   BYTE 02: BIT 01(0x01): Part on?(1 = yes)
-			//            BIT 02(0x02): Reverb? (1 = yes) [bug #1088045]
-			//   BYTE 04: Priority adjustment [guessing]
-			//   BYTE 05: Volume(upper 4 bits) [guessing]
-			//   BYTE 06: Volume(lower 4 bits) [guessing]
-			//   BYTE 07: Pan(upper 4 bits) [bug #1088045]
-			//   BYTE 08: Pan(lower 4 bits) [bug #1088045]
-			//   BYTE 09: BIT 04(0x08): Percussion?(1 = yes)
-			//   BYTE 13: Pitchbend range(upper 4 bits) [bug #1088045]
-			//   BYTE 14: Pitchbend range(lower 4 bits) [bug #1088045]
-			//   BYTE 15: Program(upper 4 bits)
-			//   BYTE 16: Program(lower 4 bits)
-			part = getPart(p[0] & 0x0F);
-			if (part) {
-				part->set_onoff(p[2] & 0x01);
-				part->effectLevel ((p[2] & 0x02) ? 127 : 0);
-				part->set_pri(p[4]);
-				part->volume((p[5] & 0x0F) << 4 |(p[6] & 0x0F));
-				part->set_pan((p[7] & 0x0F) << 4 | (p[8] & 0x0F));
-				part->_percussion = _isMIDI ? ((p[9] & 0x08) > 0) : false;
-				part->pitchBendFactor ((p[13] & 0x0F) << 4 | (p[14] & 0x0F));
-				if (part->_percussion) {
-					if (part->_mc) {
-						part->off();
-						_se->reallocateMidiChannels(_midi);
-					}
-				} else {
-					// Even in cases where a program does not seem to be specified,
-					// i.e. bytes 15 and 16 are 0, we send a program change because
-					// 0 is a valid program number. MI2 tests show that in such
-					// cases, a regular program change message always seems to follow
-					// anyway.
-					if (_isMIDI)
-						part->_instrument.program((p[15] & 0x0F) << 4 |(p[16] & 0x0F), _isMT32);
-					part->sendAll();
-				}
-			}
-		} else {
-			// Sam & Max: Trigger Event
-			// Triggers are set by doCommand(ImSetTrigger).
-			// When a SysEx marker is encountered whose sound
-			// ID and marker ID match what was set by ImSetTrigger,
-			// something magical is supposed to happen....
-			for (a = 0; a < ARRAYSIZE(_se->_snm_triggers); ++a) {
-				if (_se->_snm_triggers[a].sound == _id &&
-				    _se->_snm_triggers[a].id == *p)
-				{
-					_se->_snm_triggers[a].sound = _se->_snm_triggers[a].id = 0;
-					_se->doCommand(8, _se->_snm_triggers[a].command);
-					break;
-				}
-			}
-		} // end if
-		break;
-
-	case 1:
-		if (_se->_game_id != GID_SAMNMAX) {
-			// Shut down a part. [Bug 1088045, comments]
-			part = getPart (p[0]);
-			if (part != NULL) part->uninit();
-		} else {
-			// Sam & Max: maybe_jump.
-			if (_scanning)
-				break;
-			maybe_jump(p[0], p[1] - 1, (READ_BE_UINT16(p + 2) - 1) * 4 + p[4], ((p[5] * TICKS_PER_BEAT) >> 2) + p[6]);
-		}
-		break;
-
-	case 2: // Start of song. Ignore for now.
-		break;
-
-	case 16: // Adlib instrument definition(Part)
-		a = *p++ & 0x0F;
-		++p; // Skip hardware type
-		part = getPart(a);
-		if (part) {
-			if (len == 63) {
-				decode_sysex_bytes(p, buf, len - 3);
-				part->set_instrument((byte *)buf);
-			} else {
-				// SPK tracks have len == 49 here, and are not supported
-				part->programChange(254); // Must be invalid, but not 255 (which is reserved)
-			}
-		}
-		break;
-
-	case 17: // Adlib instrument definition(Global)
-		p += 2; // Skip hardware type and... whatever came right before it
-		a = *p++;
-		decode_sysex_bytes(p, buf, len - 4);
-		_se->setGlobalAdlibInstrument(a, buf);
-		break;
-
-	case 33: // Parameter adjust
-		a = *p++ & 0x0F;
-		++p; // Skip hardware type
-		decode_sysex_bytes(p, buf, len - 3);
-		part = getPart(a);
-		if (part)
-			part->set_param(READ_BE_UINT16(buf), READ_BE_UINT16(buf + 2));
-		break;
-
-	case 48: // Hook - jump
-		if (_scanning)
-			break;
-		decode_sysex_bytes(p + 1, buf, len - 2);
-		maybe_jump(buf[0], READ_BE_UINT16(buf + 1), READ_BE_UINT16(buf + 3), READ_BE_UINT16(buf + 5));
-		break;
-
-	case 49: // Hook - global transpose
-		decode_sysex_bytes(p + 1, buf, len - 2);
-		maybe_set_transpose(buf);
-		break;
-
-	case 50: // Hook - part on/off
-		buf[0] = *p++ & 0x0F;
-		decode_sysex_bytes(p, buf + 1, len - 2);
-		maybe_part_onoff(buf);
-		break;
-
-	case 51: // Hook - set volume
-		buf[0] = *p++ & 0x0F;
-		decode_sysex_bytes(p, buf + 1, len - 2);
-		maybe_set_volume(buf);
-		break;
-
-	case 52: // Hook - set program
-		buf[0] = *p++ & 0x0F;
-		decode_sysex_bytes(p, buf + 1, len - 2);
-		maybe_set_program(buf);
-		break;
-
-	case 53: // Hook - set transpose
-		buf[0] = *p++ & 0x0F;
-		decode_sysex_bytes(p, buf + 1, len - 2);
-		maybe_set_transpose_part(buf);
-		break;
-
-	case 64: // Marker
-		p++;
-		len -= 2;
-		while (len--) {
-			_se->handle_marker(_id, *p++);
-		}
-		break;
-
-	case 80: // Loop
-		decode_sysex_bytes(p + 1, buf, len - 2);
-		setLoop(READ_BE_UINT16(buf), READ_BE_UINT16(buf + 2),
-		        READ_BE_UINT16(buf + 4), READ_BE_UINT16(buf + 6),
-		        READ_BE_UINT16(buf + 8));
-		break;
-
-	case 81: // End loop
-		clearLoop();
-		break;
-
-	case 96: // Set instrument
-		part = getPart(p[0] & 0x0F);
-		b = (p[1] & 0x0F) << 12 |(p[2] & 0x0F) << 8 |(p[4] & 0x0F) << 4 |(p[4] & 0x0F);
-		if (part)
-			part->set_instrument(b);
-		break;
-
-	default:
-		error("Unknown SysEx command %d", (int)code);
-	}
+	if (_se->_sysex) (*_se->_sysex) (this, p, len);
 }
 
 void Player::decode_sysex_bytes(const byte *src, byte *dst, int len) {

Added: scummvm/trunk/engines/scumm/imuse/sysex.h
===================================================================
--- scummvm/trunk/engines/scumm/imuse/sysex.h	                        (rev 0)
+++ scummvm/trunk/engines/scumm/imuse/sysex.h	2006-03-12 18:06:22 UTC (rev 21241)
@@ -0,0 +1,39 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001  Ludvig Strigeus
+ * Copyright (C) 2001-2006 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#ifndef DEFINED_SYSEX_H
+#define DEFINED_SYSEX_H
+
+#include "common/stdafx.h"
+#include "common/util.h"
+
+namespace Scumm {
+
+class Player;
+
+extern void sysexHandler_Scumm (Player *, const byte *, uint16);
+extern void sysexHandler_SamNMax (Player *, const byte *, uint16);
+
+} // End of namespace Scumm
+
+#endif
+


Property changes on: scummvm/trunk/engines/scumm/imuse/sysex.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Added: scummvm/trunk/engines/scumm/imuse/sysex_samnmax.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse/sysex_samnmax.cpp	                        (rev 0)
+++ scummvm/trunk/engines/scumm/imuse/sysex_samnmax.cpp	2006-03-12 18:06:22 UTC (rev 21241)
@@ -0,0 +1,78 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001  Ludvig Strigeus
+ * Copyright (C) 2001-2006 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#include "common/stdafx.h"
+#include "common/util.h"
+
+/*
+ * SysEx command handlers must have full access to the
+ * internal IMuse implementation classes. Before including
+ * the relevant header file, two things must happen:
+ *   1. A function declaration must be made.
+ *   2. The following #define must be established:
+ *      #define SYSEX_CALLBACK_FUNCTION functionName
+ */
+#define SYSEX_CALLBACK_FUNCTION sysexHandler_SamNMax
+#include "scumm/imuse/imuse_internal.h"
+
+namespace Scumm {
+
+extern void sysexHandler_Scumm (Player *, const byte *, uint16);
+
+void sysexHandler_SamNMax (Player *player, const byte *msg, uint16 len) {
+	Part *part;
+	byte a;
+
+	IMuseInternal *se = player->_se;
+	const byte *p = msg;
+
+	switch (*p++) {
+	case 0:
+		// Trigger Event
+		// Triggers are set by doCommand(ImSetTrigger).
+		// When a SysEx marker is encountered whose sound
+		// ID and marker ID match what was set by ImSetTrigger,
+		// something magical is supposed to happen....
+		for (a = 0; a < ARRAYSIZE(se->_snm_triggers); ++a) {
+			if (se->_snm_triggers[a].sound == player->_id &&
+			    se->_snm_triggers[a].id == *p)
+			{
+				se->_snm_triggers[a].sound = se->_snm_triggers[a].id = 0;
+				se->doCommand(8, se->_snm_triggers[a].command);
+				break;
+			}
+		}
+		break;
+
+	case 1:
+		// maybe_jump.
+		if (player->_scanning)
+			break;
+		player->maybe_jump(p[0], p[1] - 1, (READ_BE_UINT16(p + 2) - 1) * 4 + p[4], ((p[5] * TICKS_PER_BEAT) >> 2) + p[6]);
+		break;
+
+	default:
+		sysexHandler_Scumm (player, msg, len);
+	}
+}
+
+} // End of namespace Scumm


Property changes on: scummvm/trunk/engines/scumm/imuse/sysex_samnmax.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Added: scummvm/trunk/engines/scumm/imuse/sysex_scumm.cpp
===================================================================
--- scummvm/trunk/engines/scumm/imuse/sysex_scumm.cpp	                        (rev 0)
+++ scummvm/trunk/engines/scumm/imuse/sysex_scumm.cpp	2006-03-12 18:06:22 UTC (rev 21241)
@@ -0,0 +1,200 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001  Ludvig Strigeus
+ * Copyright (C) 2001-2006 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#include "common/stdafx.h"
+#include "common/util.h"
+
+/*
+ * SysEx command handlers must have full access to the
+ * internal IMuse implementation classes. Before including
+ * the relevant header file, two things must happen:
+ *   1. A function declaration must be made.
+ *   2. The following #define must be established:
+ *      #define SYSEX_CALLBACK_FUNCTION functionName
+ */
+#define SYSEX_CALLBACK_FUNCTION sysexHandler_Scumm
+#include "scumm/imuse/imuse_internal.h"
+
+namespace Scumm {
+
+void sysexHandler_Scumm (Player *player, const byte *msg, uint16 len) {
+	Part *part;
+	byte a;
+	byte buf[128];
+
+	IMuseInternal *se = player->_se;
+	const byte *p = msg;
+
+	switch (byte code = *p++) {
+	case 0:
+		// Allocate new part.
+		// There are 17 bytes of useful information here.
+		// Here is what we know about them so far:
+		//   BYTE 00: Channel #
+		//   BYTE 02: BIT 01(0x01): Part on?(1 = yes)
+		//            BIT 02(0x02): Reverb? (1 = yes) [bug #1088045]
+		//   BYTE 04: Priority adjustment [guessing]
+		//   BYTE 05: Volume(upper 4 bits) [guessing]
+		//   BYTE 06: Volume(lower 4 bits) [guessing]
+		//   BYTE 07: Pan(upper 4 bits) [bug #1088045]
+		//   BYTE 08: Pan(lower 4 bits) [bug #1088045]
+		//   BYTE 09: BIT 04(0x08): Percussion?(1 = yes)
+		//   BYTE 13: Pitchbend range(upper 4 bits) [bug #1088045]
+		//   BYTE 14: Pitchbend range(lower 4 bits) [bug #1088045]
+		//   BYTE 15: Program(upper 4 bits)
+		//   BYTE 16: Program(lower 4 bits)
+		part = player->getPart(p[0] & 0x0F);
+		if (part) {
+			part->set_onoff(p[2] & 0x01);
+			part->effectLevel ((p[2] & 0x02) ? 127 : 0);
+			part->set_pri(p[4]);
+			part->volume((p[5] & 0x0F) << 4 |(p[6] & 0x0F));
+			part->set_pan((p[7] & 0x0F) << 4 | (p[8] & 0x0F));
+			part->_percussion = player->_isMIDI ? ((p[9] & 0x08) > 0) : false;
+			part->pitchBendFactor ((p[13] & 0x0F) << 4 | (p[14] & 0x0F));
+			if (part->_percussion) {
+				if (part->_mc) {
+					part->off();
+					se->reallocateMidiChannels(player->_midi);
+				}
+			} else {
+				// Even in cases where a program does not seem to be specified,
+				// i.e. bytes 15 and 16 are 0, we send a program change because
+				// 0 is a valid program number. MI2 tests show that in such
+				// cases, a regular program change message always seems to follow
+				// anyway.
+				if (player->_isMIDI)
+					part->_instrument.program((p[15] & 0x0F) << 4 |(p[16] & 0x0F), player->_isMT32);
+				part->sendAll();
+			}
+		}
+		break;
+
+	case 1:
+		// Shut down a part. [Bug 1088045, comments]
+		part = player->getPart (p[0]);
+		if (part != NULL) part->uninit();
+		break;
+
+	case 2: // Start of song. Ignore for now.
+		break;
+
+	case 16: // Adlib instrument definition(Part)
+		a = *p++ & 0x0F;
+		++p; // Skip hardware type
+		part = player->getPart(a);
+		if (part) {
+			if (len == 63) {
+				player->decode_sysex_bytes(p, buf, len - 3);
+				part->set_instrument((byte *)buf);
+			} else {
+				// SPK tracks have len == 49 here, and are not supported
+				part->programChange(254); // Must be invalid, but not 255 (which is reserved)
+			}
+		}
+		break;
+
+	case 17: // Adlib instrument definition(Global)
+		p += 2; // Skip hardware type and... whatever came right before it
+		a = *p++;
+		player->decode_sysex_bytes(p, buf, len - 4);
+		se->setGlobalAdlibInstrument(a, buf);
+		break;
+
+	case 33: // Parameter adjust
+		a = *p++ & 0x0F;
+		++p; // Skip hardware type
+		player->decode_sysex_bytes(p, buf, len - 3);
+		part = player->getPart(a);
+		if (part)
+			part->set_param(READ_BE_UINT16(buf), READ_BE_UINT16(buf + 2));
+		break;
+
+	case 48: // Hook - jump
+		if (player->_scanning)
+			break;
+		player->decode_sysex_bytes(p + 1, buf, len - 2);
+		player->maybe_jump(buf[0], READ_BE_UINT16(buf + 1), READ_BE_UINT16(buf + 3), READ_BE_UINT16(buf + 5));
+		break;
+
+	case 49: // Hook - global transpose
+		player->decode_sysex_bytes(p + 1, buf, len - 2);
+		player->maybe_set_transpose(buf);
+		break;
+
+	case 50: // Hook - part on/off
+		buf[0] = *p++ & 0x0F;
+		player->decode_sysex_bytes(p, buf + 1, len - 2);
+		player->maybe_part_onoff(buf);
+		break;
+
+	case 51: // Hook - set volume
+		buf[0] = *p++ & 0x0F;
+		player->decode_sysex_bytes(p, buf + 1, len - 2);
+		player->maybe_set_volume(buf);
+		break;
+
+	case 52: // Hook - set program
+		buf[0] = *p++ & 0x0F;
+		player->decode_sysex_bytes(p, buf + 1, len - 2);
+		player->maybe_set_program(buf);
+		break;
+
+	case 53: // Hook - set transpose
+		buf[0] = *p++ & 0x0F;
+		player->decode_sysex_bytes(p, buf + 1, len - 2);
+		player->maybe_set_transpose_part(buf);
+		break;
+
+	case 64: // Marker
+		p++;
+		len -= 2;
+		while (len--) {
+			se->handle_marker(player->_id, *p++);
+		}
+		break;
+
+	case 80: // Loop
+		player->decode_sysex_bytes(p + 1, buf, len - 2);
+		player->setLoop
+			(READ_BE_UINT16(buf), READ_BE_UINT16(buf + 2),
+			 READ_BE_UINT16(buf + 4), READ_BE_UINT16(buf + 6),
+			 READ_BE_UINT16(buf + 8));
+		break;
+
+	case 81: // End loop
+		player->clearLoop();
+		break;
+
+	case 96: // Set instrument
+		part = player->getPart(p[0] & 0x0F);
+		a = (p[1] & 0x0F) << 12 |(p[2] & 0x0F) << 8 |(p[4] & 0x0F) << 4 |(p[4] & 0x0F);
+		if (part)
+			part->set_instrument(a);
+		break;
+
+	default:
+		error("Unknown SysEx command %d", (int)code);
+	}
+}
+
+} // End of namespace Scumm


Property changes on: scummvm/trunk/engines/scumm/imuse/sysex_scumm.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/trunk/engines/scumm/scumm.cpp
===================================================================
--- scummvm/trunk/engines/scumm/scumm.cpp	2006-03-12 17:58:04 UTC (rev 21240)
+++ scummvm/trunk/engines/scumm/scumm.cpp	2006-03-12 18:06:22 UTC (rev 21241)
@@ -56,6 +56,7 @@
 #include "scumm/he/resource_he.h"
 #include "scumm/scumm.h"
 #include "scumm/sound.h"
+#include "scumm/imuse/sysex.h"
 #include "scumm/he/sprite_he.h"
 #include "scumm/util.h"
 #include "scumm/verbs.h"
@@ -1703,6 +1704,9 @@
 
 		_musicEngine = _imuse = IMuse::create(_system, nativeMidiDriver, adlibMidiDriver);
 		if (_imuse) {
+			_imuse->addSysexHandler
+				(/*IMUSE_SYSEX_ID*/ 0x7D,
+				 (_game.id == GID_SAMNMAX) ? sysexHandler_SamNMax : sysexHandler_Scumm);
 			_imuse->property(IMuse::PROP_GAME_ID, _game.id);
 			if (ConfMan.hasKey("tempo"))
 				_imuse->property(IMuse::PROP_TEMPO_BASE, ConfMan.getInt("tempo"));


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