Exemple #1
0
int CleanupSongIterator::nextCommand(byte *buf, int *result) {
	/* Task: Return channel-notes-off for each channel */
	if (channel_mask) {
		int bs = sci_ffs(channel_mask) - 1;

		channel_mask &= ~(1 << bs);
		buf[0] = 0xb0 | bs; /* Controller */
		buf[1] = SCI_MIDI_CHANNEL_NOTES_OFF;
		buf[2] = 0; /* Hmm... */
		*result = 3;
		return 0;
	} else
		return SI_FINISHED;
}
Exemple #2
0
int
vocab_print(void) {
	int b, words_nr, counter;
	word_t **words, **tracker;

	tracker = words = vocab_get_words(resmgr, &words_nr);

	counter = words_nr;

	if (vocab_sort == SORT_METHOD_GROUP)
		qsort(words, words_nr, sizeof(word_t *), _vocab_cmp_group); /* Sort entries */

	while (counter--) {
		printf("%s (class %03x, group %03x) ", &tracker[0]->word,
		       tracker[0]->w_class, tracker[0]->group);

		if ((tracker[0]->w_class >= 0xf00) ||
		        (tracker[0]->w_class == 0))
			printf("anyword\n");
		else
			while (tracker[0]->w_class) {
				b = sci_ffs(tracker[0]->w_class) - 1;
				tracker[0]->w_class &= ~(1 << b);
				printf("%s", class_names[b]);
				if (tracker[0]->w_class)
					printf("|");
				else
					printf("\n");
			}
		tracker++;
	}

	vocab_free_words(words, words_nr);

	return 0;
}
Exemple #3
0
SongIterator *Sci1SongIterator::handleMessage(Message msg) {
	if (msg._class == _SIMSG_BASE) { /* May extend this in the future */
		switch (msg._type) {

		case _SIMSG_BASEMSG_PRINT: {
			int playmask = 0;
			int i;

			for (i = 0; i < _numChannels; i++)
				playmask |= _channels[i].playmask;

			print_tabs_id(msg._arg.i, ID);
			debugC(2, kDebugLevelSound, "SCI1: chan-nr=%d, playmask=%04x\n",
			        _numChannels, playmask);
		}
		break;

		case _SIMSG_BASEMSG_STOP: {
			songit_id_t sought_id = msg.ID;
			int i;

			if (sought_id == ID) {
				ID = 0;

				for (i = 0; i < _numChannels; i++)
					_channels[i].state = SI_STATE_FINISHED;
			}
			break;
		}

		case _SIMSG_BASEMSG_SET_PLAYMASK:
			if (msg.ID == ID) {
				channel_mask = 0;

				_deviceId
				= sci0_to_sci1_device_map
				  [sci_ffs(msg._arg.i & 0xff) - 1]
				  [sfx_pcm_available()]
				  ;

				if (_deviceId == 0xff) {
					warning("[iterator] Device %d(%d) not supported",
					          msg._arg.i & 0xff, sfx_pcm_available());
				}
				if (_initialised) {
					int i;
					int toffset = -1;

					for (i = 0; i < _numChannels; i++)
						if (_channels[i].state != SI_STATE_FINISHED
						        && _channels[i].total_timepos > toffset) {
							toffset = _channels[i].total_timepos
							          + _channels[i].timepos_increment
							          - _channels[i].delay;
						}

					/* Find an active channel so that we can
					** get the correct time offset  */

					initSong();

					toffset -= _delayRemaining;
					_delayRemaining = 0;

					if (toffset > 0)
						return new_fast_forward_iterator(this, toffset);
				} else {
					initSong();
					_initialised = true;
				}

				break;

			}

		case _SIMSG_BASEMSG_SET_LOOPS:
			if (msg.ID == ID)
				_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._arg.i;
			break;
		case _SIMSG_BASEMSG_SET_RHYTHM:
			/* Ignore */
			break;

		case _SIMSG_BASEMSG_SET_FADE: {
			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;
			fade.step_size = fp->step_size;
			break;
		}

		default:
			warning("Unsupported command %d to SCI1 iterator", msg._type);
		}
		return this;
	}
	return NULL;
}