diff options
Diffstat (limited to 'engines/sci/sfx/iterator.cpp')
-rw-r--r-- | engines/sci/sfx/iterator.cpp | 95 |
1 files changed, 47 insertions, 48 deletions
diff --git a/engines/sci/sfx/iterator.cpp b/engines/sci/sfx/iterator.cpp index bc2d2f5a8c..3111cf5e40 100644 --- a/engines/sci/sfx/iterator.cpp +++ b/engines/sci/sfx/iterator.cpp @@ -25,9 +25,8 @@ /* Song iterators */ -#include "common/util.h" - #include <stdio.h> +#include "common/util.h" #include "sci/include/sfx_iterator_internal.h" #include "sci/include/sfx_player.h" #include "sci/include/resource.h" @@ -45,9 +44,9 @@ static const int MIDI_cmdlen[16] = {0, 0, 0, 0, 0, 0, 0, 0, void print_tabs_id(int nr, songit_id_t id) { while (nr-- > 0) - error("\t"); + fprintf(stderr, "\t"); - error("[%08lx] ", id); + fprintf(stderr, "[%08lx] ", id); } #ifndef HAVE_MEMCHR @@ -89,14 +88,14 @@ _common_init(base_song_iterator_t *self) { #define CHECK_FOR_END_ABSOLUTE(offset) \ if (offset > self->size) { \ - error(SIPFX "Reached end of song without terminator (%x/%x) at %d", offset, self->size, __LINE__); \ + fprintf(stderr, SIPFX "Reached end of song without terminator (%x/%x) at %d!\n", offset, self->size, __LINE__); \ return SI_FINISHED; \ } #define CHECK_FOR_END(offset_augment) \ if ((channel->offset + (offset_augment)) > channel->end) { \ channel->state = SI_STATE_FINISHED; \ - error(SIPFX "Reached end of track %d without terminator (%x+%x/%x) at %d", channel->id, channel->offset, offset_augment, channel->end, __LINE__); \ + fprintf(stderr, SIPFX "Reached end of track %d without terminator (%x+%x/%x) at %d!\n", channel->id, channel->offset, offset_augment, channel->end, __LINE__); \ return SI_FINISHED; \ } @@ -174,7 +173,7 @@ _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *buf, int *res } if (cmd == 0xfe) { - error("song iterator subsystem: Corrupted sound resource detected.\n"); + fprintf(stderr, "song iterator subsystem: Corrupted sound resource detected.\n"); return SI_FINISHED; } @@ -185,9 +184,9 @@ _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *buf, int *res #if 0 if (1) { - error("[IT]: off=%x, cmd=%02x, takes %d args ", + fprintf(stderr, "[IT]: off=%x, cmd=%02x, takes %d args ", channel->offset - 1, cmd, paramsleft); - error("[%02x %02x <%02x> %02x %02x %02x]\n", + fprintf(stderr, "[%02x %02x <%02x> %02x %02x %02x]\n", self->data[channel->offset-3], self->data[channel->offset-2], self->data[channel->offset-1], @@ -225,19 +224,19 @@ _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *buf, int *res if (cmd == SCI_MIDI_EOT) { /* End of track? */ _reset_synth_channels(self, channel); - /* error("eot; loops = %d, notesplayed=%d\n", self->loops, channel->notes_played);*/ + /* fprintf(stderr, "eot; loops = %d, notesplayed=%d\n", self->loops, channel->notes_played);*/ if (self->loops > 1 /* && channel->notes_played*/) { /* If allowed, decrement the number of loops */ if (!(flags & PARSE_FLAG_LOOPS_UNLIMITED)) *result = --self->loops; #ifdef DEBUG_DECODING - error("%s L%d: (%p):%d Looping ", __FILE__, __LINE__, self, channel->id); + fprintf(stderr, "%s L%d: (%p):%d Looping ", __FILE__, __LINE__, self, channel->id); if (flags & PARSE_FLAG_LOOPS_UNLIMITED) - error("(indef.)"); + fprintf(stderr, "(indef.)"); else - error("(%d)", self->loops); - error(" %x -> %x\n", + fprintf(stderr, "(%d)", self->loops); + fprintf(stderr, " %x -> %x\n", channel->offset, channel->loop_offset); #endif channel->offset = channel->loop_offset; @@ -245,12 +244,12 @@ _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *buf, int *res channel->state = SI_STATE_DELTA_TIME; channel->total_timepos = channel->loop_timepos; channel->last_cmd = 0xfe; - warning("Looping song iterator %08lx.", self->ID); + fprintf(stderr, "Looping song iterator %08lx.\n", self->ID); return SI_LOOP; } else { channel->state = SI_STATE_FINISHED; #ifdef DEBUG_DECODING - error("%s L%d: (%p):%d EOT because" + fprintf(stderr, "%s L%d: (%p):%d EOT because" " %d notes, %d loops\n", __FILE__, __LINE__, self, channel->id, channel->notes_played, self->loops); @@ -393,12 +392,12 @@ _sci_midi_process_state(base_song_iterator_t *self, unsigned char *buf, int *res channel->state = SI_STATE_FINISHED; delay = (size * 50 + format.rate - 1) / format.rate; /* number of ticks to completion*/ - error("delaying %d ticks\n", delay); + fprintf(stderr, "delaying %d ticks\n", delay); return delay; } case SI_STATE_UNINITIALISED: - error(SIPFX "Attempt to read command from uninitialized iterator"); + fprintf(stderr, SIPFX "Attempt to read command from uninitialized iterator!\n"); self->init((song_iterator_t *) self); return self->next((song_iterator_t *) self, buf, result); @@ -437,7 +436,7 @@ _sci_midi_process_state(base_song_iterator_t *self, unsigned char *buf, int *res if (self->active_channels) --(self->active_channels); #ifdef DEBUG_DECODING - error("%s L%d: (%p):%d Finished channel, %d channels left\n", + fprintf(stderr, "%s L%d: (%p):%d Finished channel, %d channels left\n", __FILE__, __LINE__, self, channel->id, self->active_channels); #endif @@ -454,7 +453,7 @@ _sci_midi_process_state(base_song_iterator_t *self, unsigned char *buf, int *res } default: - error(SIPFX "Invalid iterator state %d", + fprintf(stderr, SIPFX "Invalid iterator state %d!\n", channel->state); BREAKPOINT(); return SI_FINISHED; @@ -513,8 +512,8 @@ _sci0_get_pcm_data(sci0_song_iterator_t *self, self->size - offset); if (!fc) { - error(SIPFX "Warning: Playing unterminated" - " song"); + fprintf(stderr, SIPFX "Warning: Playing unterminated" + " song!\n"); return 1; } @@ -527,7 +526,7 @@ _sci0_get_pcm_data(sci0_song_iterator_t *self, } if (!found_it) { - error(SIPFX + fprintf(stderr, SIPFX "Warning: Song indicates presence of PCM, but" " none found (finally at offset %04x)\n", offset); @@ -546,9 +545,9 @@ _sci0_get_pcm_data(sci0_song_iterator_t *self, if (offset + SCI0_PCM_DATA_OFFSET + size != self->size) { int d = offset + SCI0_PCM_DATA_OFFSET + size - self->size; - error(SIPFX + fprintf(stderr, SIPFX "Warning: PCM advertizes %d bytes of data, but %d" - " bytes are trailing in the resource", + " bytes are trailing in the resource!\n", size, self->size - (offset + SCI0_PCM_DATA_OFFSET)); if (d > 0) @@ -585,7 +584,7 @@ _sci0_handle_message(sci0_song_iterator_t *self, song_iterator_message_t msg) { case _SIMSG_BASEMSG_PRINT: print_tabs_id(msg.args[0].i, self->ID); - error("SCI0: dev=%d, active-chan=%d, size=%d, loops=%d\n", + fprintf(stderr, "SCI0: dev=%d, active-chan=%d, size=%d, loops=%d\n", self->device_id, self->active_channels, self->size, self->loops); break; @@ -600,7 +599,7 @@ _sci0_handle_message(sci0_song_iterator_t *self, song_iterator_message_t msg) { memcpy(mem, self, tsize); sci_refcount_incref(mem->data); #ifdef DEBUG_VERBOSE - error("** CLONE INCREF for new %p from %p at %p\n", mem, self, mem->data); + fprintf(stderr, "** CLONE INCREF for new %p from %p at %p\n", mem, self, mem->data); #endif return (struct _song_iterator *) mem; /* Assume caller has another copy of this */ } @@ -696,7 +695,7 @@ _sci0_init(sci0_song_iterator_t *self) { static void _sci0_cleanup(sci0_song_iterator_t *self) { #ifdef DEBUG_VERBOSE - error("** FREEING it %p: data at %p\n", self, self->data); + fprintf(stderr, "** FREEING it %p: data at %p\n", self, self->data); #endif if (self->data) sci_refcount_decref(self->data); @@ -750,7 +749,7 @@ _sci1_sample_init(sci1_song_iterator_t *self, int offset) { sample->data = self->data + offset + 10; #ifdef DEBUG_VERBOSE - error("[SAMPLE] %x/%x/%x/%x l=%x\n", + fprintf(stderr, "[SAMPLE] %x/%x/%x/%x l=%x\n", offset + 10, begin, end, self->size, length); #endif @@ -1083,7 +1082,7 @@ _sci1_process_next_command(sci1_song_iterator_t *self, } } else if (retval == SI_FINISHED) { #ifdef DEBUG - error("FINISHED some channel\n"); + fprintf(stderr, "FINISHED some channel\n"); #endif } else if (retval > 0) { int sd ; @@ -1119,7 +1118,7 @@ static struct _song_iterator * playmask |= self->channels[i].playmask; print_tabs_id(msg.args[0].i, self->ID); - error("SCI1: chan-nr=%d, playmask=%04x\n", + fprintf(stderr, "SCI1: chan-nr=%d, playmask=%04x\n", self->channels_nr, playmask); } break; @@ -1233,7 +1232,7 @@ static struct _song_iterator * } default: - error(SIPFX "Unsupported command %d to" + fprintf(stderr, SIPFX "Unsupported command %d to" " SCI1 iterator", msg.type); } return (song_iterator_t *) self; @@ -1303,7 +1302,7 @@ _cleanup_iterator_handle_message(song_iterator_t *i, song_iterator_message_t msg if (msg.recipient == _SIMSG_BASEMSG_PRINT && msg.type == _SIMSG_BASEMSG_PRINT) { print_tabs_id(msg.args[0].i, i->ID); - error("CLEANUP\n"); + fprintf(stderr, "CLEANUP\n"); } return NULL; @@ -1406,7 +1405,7 @@ _ff_handle_message(fast_forward_song_iterator_t *self, case _SIMSG_BASEMSG_PRINT: print_tabs_id(msg.args[0].i, self->ID); - error("PLASTICWRAP:\n"); + fprintf(stderr, "PLASTICWRAP:\n"); msg.args[0].i++; songit_handle_message(&(self->delegate), msg); break; @@ -1479,7 +1478,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, int retid; #ifdef DEBUG_TEE_ITERATOR - error("[Tee] %02x\n", it->status); + fprintf(stderr, "[Tee] %02x\n", it->status); #endif if (!(it->status & (TEE_LEFT_ACTIVE | TEE_RIGHT_ACTIVE))) @@ -1494,7 +1493,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, /* Not all are is active? */ int which = 0; #ifdef DEBUG_TEE_ITERATOR - error("\tRequesting transformation...\n"); + fprintf(stderr, "\tRequesting transformation...\n"); #endif if (it->status & TEE_LEFT_ACTIVE) which = TEE_LEFT; @@ -1528,7 +1527,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, it->status |= ready_masks[i]; #ifdef DEBUG_TEE_ITERATOR - error("\t Must check %d: %d\n", i, + fprintf(stderr, "\t Must check %d: %d\n", i, it->children[i].retval); #endif @@ -1539,7 +1538,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, it->status &= ~active_masks[i]; /* Recurse to complete */ #ifdef DEBUG_TEE_ITERATOR - error("\t Child %d signalled completion, recursing w/ status %02x\n", i, it->status); + fprintf(stderr, "\t Child %d signalled completion, recursing w/ status %02x\n", i, it->status); #endif return _tee_read_next_command(it, buf, result); } else if (it->children[i].retval == SI_PCM) { @@ -1560,7 +1559,7 @@ _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf, retid = TEE_RIGHT; #ifdef DEBUG_TEE_ITERATOR - error("\tl:%d / r:%d / chose %d\n", + fprintf(stderr, "\tl:%d / r:%d / chose %d\n", it->children[TEE_LEFT].retval, it->children[TEE_RIGHT].retval, retid); #endif #if 0 @@ -1624,7 +1623,7 @@ _tee_handle_message(tee_song_iterator_t *self, song_iterator_message_t msg) { case _SIMSG_BASEMSG_PRINT: print_tabs_id(msg.args[0].i, self->ID); - error("TEE:\n"); + fprintf(stderr, "TEE:\n"); msg.args[0].i++; break; /* And continue with our children */ @@ -1755,7 +1754,7 @@ songit_new_tee(song_iterator_t *left, song_iterator_t *right, int may_destroy) { if (firstfree == MIDI_CHANNELS) { incomplete_map = 1; - error("[songit-tee <%08lx,%08lx>] " + fprintf(stderr, "[songit-tee <%08lx,%08lx>] " "Could not remap right channel #%d:" " Out of channels\n", left->ID, right->ID, i); @@ -1769,14 +1768,14 @@ songit_new_tee(song_iterator_t *left, song_iterator_t *right, int may_destroy) { #ifdef DEBUG_TEE_ITERATOR if (incomplete_map) { int c; - error("[songit-tee <%08lx,%08lx>] Channels:" + fprintf(stderr, "[songit-tee <%08lx,%08lx>] Channels:" " %04x <- %04x | %04x\n", left->ID, right->ID, it->channel_mask, left->channel_mask, right->channel_mask); for (c = 0 ; c < 2; c++) for (i = 0 ; i < 16; i++) - error(" map [%d][%d] -> %d\n", + fprintf(stderr, " map [%d][%d] -> %d\n", c, i, it->children[c].channel_remap[i]); } #endif @@ -1824,14 +1823,14 @@ songit_next(song_iterator_t **it, unsigned char *buf, int *result, int mask) { do { retval = (*it)->next(*it, buf, result); if (retval == SI_MORPH) { - printf(" Morphing %p (stored at %p)\n", (void *)*it, (void *)it); + fprintf(stderr, " Morphing %p (stored at %p)\n", (void *)*it, (void *)it); if (!SIMSG_SEND((*it), SIMSG_ACK_MORPH)) { BREAKPOINT(); - } else printf("SI_MORPH successful\n"); + } else fprintf(stderr, "SI_MORPH successful\n"); } if (retval == SI_FINISHED) - printf("[song-iterator] Song finished. mask = %04x, cm=%04x\n", + fprintf(stderr, "[song-iterator] Song finished. mask = %04x, cm=%04x\n", mask, (*it)->channel_mask); if (retval == SI_FINISHED && (mask & IT_READER_MAY_CLEAN) @@ -2007,7 +2006,7 @@ song_iterator_add_death_listener(song_iterator_t *it, void *client, void (*notify)(void *self, void *notifier)) { if (it->death_listeners_nr >= SONGIT_MAX_LISTENERS) { - error("FATAL: Too many death listeners for song" + fprintf(stderr, "FATAL: Too many death listeners for song" " iterator\n"); BREAKPOINT(); exit(1); @@ -2036,7 +2035,7 @@ song_iterator_remove_death_listener(song_iterator_t *it, } } - error("FATAL: Could not remove death listener from " + fprintf(stderr, "FATAL: Could not remove death listener from " "song iterator\n"); BREAKPOINT(); exit(1); |