[Scummvm-cvs-logs] SF.net SVN: scummvm:[39290] scummvm/trunk/engines/sci/sfx

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Tue Mar 10 03:57:30 CET 2009


Revision: 39290
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39290&view=rev
Author:   fingolfin
Date:     2009-03-10 02:57:30 +0000 (Tue, 10 Mar 2009)

Log Message:
-----------
SCI: SongIterator::Message only needs to transfer a single argument, so get rid of the second slot

Modified Paths:
--------------
    scummvm/trunk/engines/sci/sfx/iterator.cpp
    scummvm/trunk/engines/sci/sfx/iterator.h

Modified: scummvm/trunk/engines/sci/sfx/iterator.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/iterator.cpp	2009-03-10 02:42:22 UTC (rev 39289)
+++ scummvm/trunk/engines/sci/sfx/iterator.cpp	2009-03-10 02:57:30 UTC (rev 39290)
@@ -589,17 +589,17 @@
 }
 
 SongIterator *Sci0SongIterator::handleMessage(Message msg) {
-	if (msg.recipient == _SIMSG_BASE) {
-		switch (msg.type) {
+	if (msg._class == _SIMSG_BASE) {
+		switch (msg._type) {
 
 		case _SIMSG_BASEMSG_PRINT:
-			print_tabs_id(msg.args[0].i, ID);
+			print_tabs_id(msg._arg.i, ID);
 			fprintf(stderr, "SCI0: dev=%d, active-chan=%d, size=%d, loops=%d\n",
 			        _deviceId, active_channels, _size, loops);
 			break;
 
 		case _SIMSG_BASEMSG_SET_LOOPS:
-			loops = msg.args[0].i;
+			loops = msg._arg.i;
 			break;
 
 		case _SIMSG_BASEMSG_STOP: {
@@ -612,7 +612,7 @@
 
 		case _SIMSG_BASEMSG_SET_PLAYMASK: {
 			int i;
-			_deviceId = msg.args[0].i;
+			_deviceId = msg._arg.i;
 
 			/* Set all but the rhytm channel mask bits */
 			channel.playmask &= ~(1 << MIDI_RHYTHM_CHANNEL);
@@ -626,12 +626,12 @@
 
 		case _SIMSG_BASEMSG_SET_RHYTHM:
 			channel.playmask &= ~(1 << MIDI_RHYTHM_CHANNEL);
-			if (msg.args[0].i)
+			if (msg._arg.i)
 				channel.playmask |= (1 << MIDI_RHYTHM_CHANNEL);
 			break;
 
 		case _SIMSG_BASEMSG_SET_FADE: {
-			fade_params_t *fp = (fade_params_t *) msg.args[0].p;
+			fade_params_t *fp = (fade_params_t *) msg._arg.p;
 			fade.action = fp->action;
 			fade.final_volume = fp->final_volume;
 			fade.ticks_per_step = fp->ticks_per_step;
@@ -1076,8 +1076,8 @@
 }
 
 SongIterator *Sci1SongIterator::handleMessage(Message msg) {
-	if (msg.recipient == _SIMSG_BASE) { /* May extend this in the future */
-		switch (msg.type) {
+	if (msg._class == _SIMSG_BASE) { /* May extend this in the future */
+		switch (msg._type) {
 
 		case _SIMSG_BASEMSG_PRINT: {
 			int playmask = 0;
@@ -1086,7 +1086,7 @@
 			for (i = 0; i < _numChannels; i++)
 				playmask |= _channels[i].playmask;
 
-			print_tabs_id(msg.args[0].i, ID);
+			print_tabs_id(msg._arg.i, ID);
 			fprintf(stderr, "SCI1: chan-nr=%d, playmask=%04x\n",
 			        _numChannels, playmask);
 		}
@@ -1111,13 +1111,13 @@
 
 				_deviceId
 				= sci0_to_sci1_device_map
-				  [sci_ffs(msg.args[0].i & 0xff) - 1]
+				  [sci_ffs(msg._arg.i & 0xff) - 1]
 				  [sfx_pcm_available()]
 				  ;
 
 				if (_deviceId == 0xff) {
 					sciprintf("[iterator-1] Warning: Device %d(%d) not supported",
-					          msg.args[0].i & 0xff, sfx_pcm_available());
+					          msg._arg.i & 0xff, sfx_pcm_available());
 				}
 				if (_initialised) {
 					int i;
@@ -1152,20 +1152,20 @@
 
 		case _SIMSG_BASEMSG_SET_LOOPS:
 			if (msg.ID == ID)
-				loops = (msg.args[0].i > 32767) ? 99 : 0;
+				loops = (msg._arg.i > 32767) ? 99 : 0;
 			/* 99 is arbitrary, but we can't use '1' because of
 			** the way we're testing in the decoding section.  */
 			break;
 
 		case _SIMSG_BASEMSG_SET_HOLD:
-			_hold = msg.args[0].i;
+			_hold = msg._arg.i;
 			break;
 		case _SIMSG_BASEMSG_SET_RHYTHM:
 			/* Ignore */
 			break;
 
 		case _SIMSG_BASEMSG_SET_FADE: {
-			fade_params_t *fp = (fade_params_t *) msg.args[0].p;
+			fade_params_t *fp = (fade_params_t *) msg._arg.p;
 			fade.action = fp->action;
 			fade.final_volume = fp->final_volume;
 			fade.ticks_per_step = fp->ticks_per_step;
@@ -1174,7 +1174,7 @@
 		}
 
 		default:
-			warning(SIPFX "Unsupported command %d to SCI1 iterator", msg.type);
+			warning(SIPFX "Unsupported command %d to SCI1 iterator", msg._type);
 		}
 		return this;
 	}
@@ -1247,8 +1247,8 @@
 };
 
 SongIterator *CleanupSongIterator::handleMessage(Message msg) {
-	if (msg.recipient == _SIMSG_BASEMSG_PRINT && msg.type == _SIMSG_BASEMSG_PRINT) {
-		print_tabs_id(msg.args[0].i, ID);
+	if (msg._class == _SIMSG_BASEMSG_PRINT && msg._type == _SIMSG_BASEMSG_PRINT) {
+		print_tabs_id(msg._arg.i, ID);
 		fprintf(stderr, "CLEANUP\n");
 	}
 
@@ -1300,8 +1300,8 @@
 }
 
 SongIterator *FastForwardSongIterator::handleMessage(Message msg) {
-	if (msg.recipient == _SIMSG_PLASTICWRAP) {
-		assert(msg.type == _SIMSG_PLASTICWRAP_ACK_MORPH);
+	if (msg._class == _SIMSG_PLASTICWRAP) {
+		assert(msg._type == _SIMSG_PLASTICWRAP_ACK_MORPH);
 
 		if (_delta <= 0) {
 			SongIterator *it = _delegate;
@@ -1313,10 +1313,10 @@
 		return this;
 	}
 
-	if (msg.recipient == _SIMSG_BASE && msg.type == _SIMSG_BASEMSG_PRINT) {
-		print_tabs_id(msg.args[0].i, ID);
+	if (msg._class == _SIMSG_BASE && msg._type == _SIMSG_BASEMSG_PRINT) {
+		print_tabs_id(msg._arg.i, ID);
 		fprintf(stderr, "FASTFORWARD:\n");
-		msg.args[0].i++;
+		msg._arg.i++;
 	}
 
 	// And continue with the delegate
@@ -1600,8 +1600,8 @@
 }
 
 SongIterator *TeeSongIterator::handleMessage(Message msg) {
-	if (msg.recipient == _SIMSG_PLASTICWRAP) {
-		assert(msg.type == _SIMSG_PLASTICWRAP_ACK_MORPH);
+	if (msg._class == _SIMSG_PLASTICWRAP) {
+		assert(msg._type == _SIMSG_PLASTICWRAP_ACK_MORPH);
 
 		SongIterator *old_it;
 		if (!(_status & (TEE_LEFT_ACTIVE | TEE_RIGHT_ACTIVE))) {
@@ -1625,10 +1625,10 @@
 		return this;
 	}
 
-	if (msg.recipient == _SIMSG_BASE && msg.type == _SIMSG_BASEMSG_PRINT) {
-		print_tabs_id(msg.args[0].i, ID);
+	if (msg._class == _SIMSG_BASE && msg._type == _SIMSG_BASEMSG_PRINT) {
+		print_tabs_id(msg._arg.i, ID);
 		fprintf(stderr, "TEE:\n");
-		msg.args[0].i++;
+		msg._arg.i++;
 	}
 
 	// And continue with the children
@@ -1674,7 +1674,8 @@
 			fprintf(stderr, "  Morphing %p (stored at %p)\n", (void *)*it, (void *)it);
 			if (!SIMSG_SEND((*it), SIMSG_ACK_MORPH)) {
 				BREAKPOINT();
-			} else fprintf(stderr, "SI_MORPH successful\n");
+			} else
+				fprintf(stderr, "SI_MORPH successful\n");
 		}
 
 		if (retval == SI_FINISHED)
@@ -1704,8 +1705,7 @@
 	             || (retval == SI_FINISHED)
 	         ));
 
-	if (retval == SI_FINISHED
-	        && (mask & IT_READER_MAY_FREE)) {
+	if (retval == SI_FINISHED && (mask & IT_READER_MAY_FREE)) {
 		delete *it;
 		*it = NULL;
 	}
@@ -1763,28 +1763,6 @@
 	return it;
 }
 
-SongIterator::Message::Message() {
-	ID = 0;
-	recipient = 0;
-	type = 0;
-}
-
-SongIterator::Message::Message(songit_id_t id, int r, int t, int a1, int a2) {
-	ID = id;
-	recipient = r;
-	type = t;
-	args[0].i = a1;
-	args[1].i = a2;
-}
-
-SongIterator::Message::Message(songit_id_t id, int r, int t, void *a1, int a2) {
-	ID = id;
-	recipient = r;
-	type = t;
-	args[0].p = a1;
-	args[1].i = a2;
-}
-
 int songit_handle_message(SongIterator **it_reg_p, SongIterator::Message msg) {
 	SongIterator *it = *it_reg_p;
 	SongIterator *newit;

Modified: scummvm/trunk/engines/sci/sfx/iterator.h
===================================================================
--- scummvm/trunk/engines/sci/sfx/iterator.h	2009-03-10 02:42:22 UTC (rev 39289)
+++ scummvm/trunk/engines/sci/sfx/iterator.h	2009-03-10 02:57:30 UTC (rev 39290)
@@ -81,18 +81,17 @@
 };
 
 /* Messages */
-#define SIMSG_SET_LOOPS(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_LOOPS,(x),0
-#define SIMSG_SET_PLAYMASK(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_PLAYMASK,(x),0
-#define SIMSG_SET_RHYTHM(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_RHYTHM,(x),0
-#define SIMSG_ACK_MORPH _SIMSG_PLASTICWRAP,_SIMSG_PLASTICWRAP_ACK_MORPH,0,0
-#define SIMSG_STOP _SIMSG_BASE,_SIMSG_BASEMSG_STOP,0,0
-#define SIMSG_PRINT(indentation) _SIMSG_BASE,_SIMSG_BASEMSG_PRINT,(indentation),0
-#define SIMSG_SET_HOLD(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_HOLD,(x),0
-/*#define SIMSG_SET_FADE(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_FADE,(x),0*/
+#define SIMSG_SET_LOOPS(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_LOOPS,(x)
+#define SIMSG_SET_PLAYMASK(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_PLAYMASK,(x)
+#define SIMSG_SET_RHYTHM(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_RHYTHM,(x)
+#define SIMSG_ACK_MORPH _SIMSG_PLASTICWRAP,_SIMSG_PLASTICWRAP_ACK_MORPH,0
+#define SIMSG_STOP _SIMSG_BASE,_SIMSG_BASEMSG_STOP,0
+#define SIMSG_PRINT(indentation) _SIMSG_BASE,_SIMSG_BASEMSG_PRINT,(indentation)
+#define SIMSG_SET_HOLD(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_HOLD,(x)
 
 /* Message transmission macro: Takes song reference, message reference */
 #define SIMSG_SEND(o, m) songit_handle_message(&(o), SongIterator::Message((o)->ID, m))
-#define SIMSG_SEND_FADE(o, m) songit_handle_message(&(o), SongIterator::Message((o)->ID, _SIMSG_BASE, _SIMSG_BASEMSG_SET_FADE, m, 0))
+#define SIMSG_SEND_FADE(o, m) songit_handle_message(&(o), SongIterator::Message((o)->ID, _SIMSG_BASE, _SIMSG_BASEMSG_SET_FADE, m))
 
 typedef unsigned long songit_id_t;
 
@@ -105,14 +104,14 @@
 public:
 	struct Message {
 		songit_id_t ID;
-		uint recipient; /* Type of iterator supposed to receive this */
-		uint type;
+		uint _class; /* Type of iterator supposed to receive this */
+		uint _type;
 		union {
 			uint i;
 			void *p;
-		} args[SONG_ITERATOR_MESSAGE_ARGUMENTS_NR];
+		} _arg;
 
-		Message();
+		Message() : ID(0), _class(0xFFFF), _type(0xFFFF) {}
 
 		/**
 		 * Create a song iterator message.
@@ -120,12 +119,14 @@
 		 * @param id: song ID the message is targeted to
 		 * @param recipient_class: Message recipient class
 		 * @param type	message type
-		 * @param a1	first message argument
-		 * @param a2	second message argument
+		 * @param a		argument
 		 *
 		 * @note You should only use this with the SIMSG_* macros
 		 */
-		Message(songit_id_t id, int recipient_class, int type, int a1, int a2);
+		Message(songit_id_t id, int recipient_class, int type, int a)
+			: ID(id), _class(recipient_class), _type(type) {
+			_arg.i = a;
+		}
 
 		/**
 		 * Create a song iterator message, wherein the first parameter is a pointer.
@@ -133,12 +134,14 @@
 		 * @param id: song ID the message is targeted to
 		 * @param recipient_class: Message recipient class
 		 * @param type	message type
-		 * @param a1	first message argument
-		 * @param a2	second message argument
+		 * @param a		argument
 		 *
 		 * @note You should only use this with the SIMSG_* macros
 		 */
-		Message(songit_id_t id, int recipient_class, int type, void *a1, int a2);
+		Message(songit_id_t id, int recipient_class, int type, void *a)
+			: ID(id), _class(recipient_class), _type(type) {
+			_arg.p = a;
+		}
 	};
 
 public:


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