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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Fri Mar 6 08:25:38 CET 2009


Revision: 39151
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39151&view=rev
Author:   fingolfin
Date:     2009-03-06 07:25:37 +0000 (Fri, 06 Mar 2009)

Log Message:
-----------
SCI: Some cleanup to the SongIteratorMessage code

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/savegame.cfsml
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/sfx/core.cpp
    scummvm/trunk/engines/sci/sfx/iterator.cpp
    scummvm/trunk/engines/sci/sfx/iterator.h

Modified: scummvm/trunk/engines/sci/engine/savegame.cfsml
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cfsml	2009-03-06 07:25:25 UTC (rev 39150)
+++ scummvm/trunk/engines/sci/engine/savegame.cfsml	2009-03-06 07:25:37 UTC (rev 39151)
@@ -1026,9 +1026,9 @@
 			ff = (SongIterator *)new_fast_forward_iterator(base, seeker->restore_time);
 		ff->init(ff);
 
-		msg = songit_make_message(seeker->handle, SIMSG_SET_LOOPS(seeker->loops));
+		msg = SongIteratorMessage(seeker->handle, SIMSG_SET_LOOPS(seeker->loops));
 		songit_handle_message(&ff, msg);
-		msg = songit_make_message(seeker->handle, SIMSG_SET_HOLD(seeker->hold));
+		msg = SongIteratorMessage(seeker->handle, SIMSG_SET_HOLD(seeker->hold));
 		songit_handle_message(&ff, msg);
 
 		oldstatus = seeker->status;

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2009-03-06 07:25:25 UTC (rev 39150)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2009-03-06 07:25:37 UTC (rev 39151)
@@ -5122,9 +5122,9 @@
 			ff = (SongIterator *)new_fast_forward_iterator(base, seeker->restore_time);
 		ff->init(ff);
 
-		msg = songit_make_message(seeker->handle, SIMSG_SET_LOOPS(seeker->loops));
+		msg = SongIteratorMessage(seeker->handle, SIMSG_SET_LOOPS(seeker->loops));
 		songit_handle_message(&ff, msg);
-		msg = songit_make_message(seeker->handle, SIMSG_SET_HOLD(seeker->hold));
+		msg = SongIteratorMessage(seeker->handle, SIMSG_SET_HOLD(seeker->hold));
 		songit_handle_message(&ff, msg);
 
 		oldstatus = seeker->status;

Modified: scummvm/trunk/engines/sci/sfx/core.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/core.cpp	2009-03-06 07:25:25 UTC (rev 39150)
+++ scummvm/trunk/engines/sci/sfx/core.cpp	2009-03-06 07:25:37 UTC (rev 39151)
@@ -124,7 +124,7 @@
 
 	if (player) {
 		fprintf(stderr, "Audio iterator:\n");
-		player->iterator_message(songit_make_message(0, SIMSG_PRINT(1)));
+		player->iterator_message(SongIteratorMessage(0, SIMSG_PRINT(1)));
 	}
 #endif
 }
@@ -306,7 +306,7 @@
 			}
 			if (player && oldseeker->it)
 				player->iterator_message
-				(songit_make_message(oldseeker->it->ID, SIMSG_STOP));
+				(SongIteratorMessage(oldseeker->it->ID, SIMSG_STOP));
 			oldseeker->next_playing = NULL; /* Clear this pointer; we don't need the tag anymore */
 		}
 
@@ -566,7 +566,7 @@
 	_dump_songs(self);
 
 	if (player)
-		player->iterator_message(songit_make_message(handle, SIMSG_STOP));
+		player->iterator_message(SongIteratorMessage(handle, SIMSG_STOP));
 
 	if (song) {
 		_sfx_set_song_status(self, song, SOUND_STATUS_STOPPED);
@@ -663,8 +663,7 @@
 
 void sfx_song_set_loops(sfx_state_t *self, song_handle_t handle, int loops) {
 	song_t *song = song_lib_find(self->songlib, handle);
-	SongIteratorMessage msg
-	= songit_make_message(handle, SIMSG_SET_LOOPS(loops));
+	SongIteratorMessage msg = SongIteratorMessage(handle, SIMSG_SET_LOOPS(loops));
 	ASSERT_SONG(song);
 
 #ifdef DEBUG_SONG_API
@@ -672,7 +671,7 @@
 	        handle, loops);
 #endif
 	songit_handle_message(&(song->it), msg);
-	song->loops = ((BaseSongIterator *) song->it)->loops;
+	song->loops = ((BaseSongIterator *)song->it)->loops;
 
 	if (player/* && player->send_iterator_message*/)
 		/* FIXME: The above should be optional! */
@@ -682,7 +681,7 @@
 void sfx_song_set_hold(sfx_state_t *self, song_handle_t handle, int hold) {
 	song_t *song = song_lib_find(self->songlib, handle);
 	SongIteratorMessage msg
-	= songit_make_message(handle, SIMSG_SET_HOLD(hold));
+	= SongIteratorMessage(handle, SIMSG_SET_HOLD(hold));
 	ASSERT_SONG(song);
 
 	song->hold = hold;

Modified: scummvm/trunk/engines/sci/sfx/iterator.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/iterator.cpp	2009-03-06 07:25:25 UTC (rev 39150)
+++ scummvm/trunk/engines/sci/sfx/iterator.cpp	2009-03-06 07:25:37 UTC (rev 39151)
@@ -121,7 +121,7 @@
 
 
 static int _sci0_get_pcm_data(Sci0SongIterator *self,
-	sfx_pcm_config_t *format, int *xoffset, unsigned int *xsize);
+	sfx_pcm_config_t *format, int *xoffset, uint *xsize);
 
 #define PARSE_FLAG_LOOPS_UNLIMITED (1 << 0) /* Unlimited # of loops? */
 #define PARSE_FLAG_PARAMETRIC_CUE (1 << 1) /* Assume that cues take an additional "cue value" argument */
@@ -371,7 +371,7 @@
 	case SI_STATE_PCM_MAGIC_DELTA: {
 		sfx_pcm_config_t format;
 		int offset;
-		unsigned int size;
+		uint size;
 		int delay;
 		if (_sci0_get_pcm_data((Sci0SongIterator *) self, &format, &offset, &size))
 			return SI_FINISHED; /* 'tis broken */
@@ -470,12 +470,12 @@
 
 
 static int _sci0_get_pcm_data(Sci0SongIterator *self,
-	sfx_pcm_config_t *format, int *xoffset, unsigned int *xsize) {
+	sfx_pcm_config_t *format, int *xoffset, uint *xsize) {
 	int tries = 2;
 	int found_it = 0;
 	unsigned char *pcm_data;
 	int size;
-	unsigned int offset = SCI0_MIDI_OFFSET;
+	uint offset = SCI0_MIDI_OFFSET;
 
 	if (self->data[0] != 2)
 		return 1;
@@ -559,7 +559,7 @@
 Audio::AudioStream *Sci0SongIterator::get_pcm_feed() {
 	sfx_pcm_config_t conf;
 	int offset;
-	unsigned int size;
+	uint size;
 	if (_sci0_get_pcm_data(this, &conf, &offset, &size))
 		return NULL;
 
@@ -716,7 +716,7 @@
 	int begin;
 	int end;
 
-	CHECK_FOR_END_ABSOLUTE((unsigned int)offset + 10);
+	CHECK_FOR_END_ABSOLUTE((uint)offset + 10);
 	if (self->data[offset + 1] != 0)
 		sciprintf("[iterator-1] In sample at offset 0x04x: Byte #1 is %02x instead of zero\n",
 		          self->data[offset + 1]);
@@ -726,7 +726,7 @@
 	begin = getInt16(self->data + offset + 6);
 	end = getInt16(self->data + offset + 8);
 
-	CHECK_FOR_END_ABSOLUTE((unsigned int)(offset + 10 + length));
+	CHECK_FOR_END_ABSOLUTE((uint)(offset + 10 + length));
 
 	sample = new Sci1Sample();
 	sample->delta = begin;
@@ -759,7 +759,7 @@
 static int _sci1_song_init(Sci1SongIterator *self) {
 	Sci1Sample *seeker;
 	int last_time;
-	unsigned int offset = 0;
+	uint offset = 0;
 	self->channels_nr = 0;
 	self->next_sample = 0;
 //	self->device_id = 0x0c;
@@ -791,7 +791,7 @@
 	offset++;
 
 	while (SONGDATA(0) != 0xff) { /* End of list? */
-		unsigned int track_offset;
+		uint track_offset;
 		int end;
 		offset += 2;
 
@@ -1283,7 +1283,7 @@
 
 class CleanupSongIterator : public SongIterator {
 public:
-	CleanupSongIterator(unsigned int channels) {
+	CleanupSongIterator(uint channels) {
 		channel_mask = channels;
 		ID = 17;
 		flags = 0;
@@ -1299,7 +1299,7 @@
 	Audio::AudioStream *get_pcm_feed() { return NULL; }
 };
 
-SongIterator *new_cleanup_iterator(unsigned int channels) {
+SongIterator *new_cleanup_iterator(uint channels) {
 	CleanupSongIterator *it = new CleanupSongIterator(channels);
 	return it;
 }
@@ -1802,7 +1802,7 @@
 	return retval;
 }
 
-SongIterator *songit_new(unsigned char *data, unsigned int size, int type, songit_id_t id) {
+SongIterator *songit_new(unsigned char *data, uint size, int type, songit_id_t id) {
 	BaseSongIterator *it;
 	int i;
 
@@ -1882,26 +1882,26 @@
 	}
 }
 
-SongIteratorMessage songit_make_message(songit_id_t id, int recipient, int type, int a1, int a2) {
-	SongIteratorMessage rv;
-	rv.ID = id;
-	rv.recipient = recipient;
-	rv.type = type;
-	rv.args[0].i = a1;
-	rv.args[1].i = a2;
+SongIteratorMessage::SongIteratorMessage() {
+	ID = 0;
+	recipient = 0;
+	type = 0;
+}
 
-	return rv;
+SongIteratorMessage::SongIteratorMessage(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;
 }
 
-SongIteratorMessage songit_make_ptr_message(songit_id_t id, int recipient, int type, void * a1, int a2) {
-	SongIteratorMessage rv;
-	rv.ID = id;
-	rv.recipient = recipient;
-	rv.type = type;
-	rv.args[0].p = a1;
-	rv.args[1].i = a2;
-
-	return rv;
+SongIteratorMessage::SongIteratorMessage(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, SongIteratorMessage msg) {

Modified: scummvm/trunk/engines/sci/sfx/iterator.h
===================================================================
--- scummvm/trunk/engines/sci/sfx/iterator.h	2009-03-06 07:25:25 UTC (rev 39150)
+++ scummvm/trunk/engines/sci/sfx/iterator.h	2009-03-06 07:25:37 UTC (rev 39151)
@@ -59,20 +59,26 @@
 
 /* Helper defs for messages */
 /* Base messages */
-#define _SIMSG_BASE 0 /* Any base decoder */
-#define _SIMSG_BASEMSG_SET_LOOPS 0 /* Set loops */
-#define _SIMSG_BASEMSG_CLONE 1 /* Clone object and data. Must provide the
-** (possibly negative) number of ticks that have
-** passed since the last delay time started being
-** used  */
-#define _SIMSG_BASEMSG_SET_PLAYMASK 2 /* Set the current playmask for filtering */
-#define _SIMSG_BASEMSG_SET_RHYTHM 3 /* Activate/deactivate rhythm channel */
-#define _SIMSG_BASEMSG_ACK_MORPH 4 /* Acknowledge self-morph */
-#define _SIMSG_BASEMSG_STOP 5 /* Stop iterator */
-#define _SIMSG_BASEMSG_PRINT 6 /* Print self to stderr, after printing param1 tabs */
-#define _SIMSG_BASEMSG_SET_HOLD 7 /* Set value of hold parameter to expect */
-#define _SIMSG_BASEMSG_SET_FADE 8 /* Set fade parameters */
+enum {
+	_SIMSG_BASE = 0, /* Any base decoder */
+	_SIMSG_BASEMSG_SET_LOOPS = 0, /* Set loops */
 
+	/**
+	 * Clone object and data. Must provide the (possibly negative)
+	 * number of ticks that have passed since the last delay time
+	 * started being used.
+	 */
+	_SIMSG_BASEMSG_CLONE = 1,
+
+	_SIMSG_BASEMSG_SET_PLAYMASK = 2, /* Set the current playmask for filtering */
+	_SIMSG_BASEMSG_SET_RHYTHM = 3, /* Activate/deactivate rhythm channel */
+	_SIMSG_BASEMSG_ACK_MORPH = 4, /* Acknowledge self-morph */
+	_SIMSG_BASEMSG_STOP = 5, /* Stop iterator */
+	_SIMSG_BASEMSG_PRINT = 6, /* Print self to stderr, after printing param1 tabs */
+	_SIMSG_BASEMSG_SET_HOLD = 7, /* Set value of hold parameter to expect */
+	_SIMSG_BASEMSG_SET_FADE = 8 /* Set fade parameters */
+};
+
 /* "Plastic" (discardable) wrapper messages */
 #define _SIMSG_PLASTICWRAP 1 /* Any base decoder */
 #define _SIMSG_PLASTICWRAP_ACK_MORPH 4 /* Acknowledge self-morph */
@@ -89,8 +95,8 @@
 /*#define SIMSG_SET_FADE(x) _SIMSG_BASE,_SIMSG_BASEMSG_SET_FADE,(x),0*/
 
 /* Message transmission macro: Takes song reference, message reference */
-#define SIMSG_SEND(o, m) songit_handle_message(&(o), songit_make_message((o)->ID, m))
-#define SIMSG_SEND_FADE(o, m) songit_handle_message(&(o), songit_make_ptr_message((o)->ID, _SIMSG_BASE, _SIMSG_BASEMSG_SET_FADE, m, 0))
+#define SIMSG_SEND(o, m) songit_handle_message(&(o), SongIteratorMessage((o)->ID, m))
+#define SIMSG_SEND_FADE(o, m) songit_handle_message(&(o), SongIteratorMessage((o)->ID, _SIMSG_BASE, _SIMSG_BASEMSG_SET_FADE, m, 0))
 
 /* Event listener interface */
 struct listener_t {
@@ -102,12 +108,41 @@
 
 struct SongIteratorMessage {
 	songit_id_t ID;
-	unsigned int recipient; /* Type of iterator supposed to receive this */
-	unsigned int type;
+	uint recipient; /* Type of iterator supposed to receive this */
+	uint type;
 	union {
-		unsigned int i;
-		void * p;
+		uint i;
+		void *p;
 	} args[SONG_ITERATOR_MESSAGE_ARGUMENTS_NR];
+
+
+	SongIteratorMessage();
+
+	/**
+	 * Create a song iterator message.
+	 *
+	 * @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
+	 *
+	 * @note You should only use this with the SIMSG_* macros
+	 */
+	SongIteratorMessage(songit_id_t id, int recipient_class, int type, int a1, int a2);
+	
+	/**
+	 * Create a song iterator message, wherein the first parameter is a pointer.
+	 *
+	 * @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
+	 *
+	 * @note You should only use this with the SIMSG_* macros
+	 */
+	SongIteratorMessage(songit_id_t id, int recipient_class, int type, void *a1, int a2);
 };
 
 #define SONGIT_MAX_LISTENERS 2
@@ -117,7 +152,7 @@
 	songit_id_t ID;
 	uint16 channel_mask; /* Bitmask of all channels this iterator will use */
 	fade_params_t fade;
-	unsigned int flags;
+	uint flags;
 	int priority;
 
 	/* Death listeners */
@@ -269,10 +304,10 @@
 **                   or the number of loops remaining for SI_LOOP.
 */
 
-SongIterator *songit_new(unsigned char *data, unsigned int size, int type, songit_id_t id);
+SongIterator *songit_new(unsigned char *data, uint size, int type, songit_id_t id);
 /* Constructs a new song iterator object
 ** Parameters: (byte *) data: The song data to iterate over
-**             (unsigned int) size: Number of bytes in the song
+**             (uint) size: Number of bytes in the song
 **             (int) type: One of the SCI_SONG_ITERATOR_TYPEs
 **             (songit_id_t) id: An ID for addressing the song iterator
 ** Returns   : (SongIterator *) A newly allocated but uninitialized song
@@ -295,26 +330,7 @@
 ** Returns   : (void)
 */
 
-SongIteratorMessage songit_make_message(songit_id_t id,
-	int recipient_class, int type, int a1, int a2);
-/* Create a song iterator message
-** Parameters: (songit_id_t) id: song ID the message is targetted to
-**             (int) recipient_class: Message recipient class
-**             (int) type: Message type
-**             (int x int) a1, a2: Arguments
-** You should only use this with the SIMSG_* macros
-*/
 
-SongIteratorMessage songit_make_ptr_message(songit_id_t id,
-	int recipient_class, int type, void * a1, int a2);
-/* Create a song iterator message, wherein the first parameter is a pointer
-** Parameters: (songit_id_t) id: song ID the message is targetted to
-**             (int) recipient_class: Message recipient class
-**             (int) type: Message type
-**             (void* x int) a1, a2: Arguments
-** You should only use this with the SIMSG_* macros
-*/
-
 int songit_handle_message(SongIterator **it_reg, SongIteratorMessage msg);
 /* Handles a message to the song iterator
 ** Parameters: (SongIterator **): A reference to the variable storing the song iterator


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