SCI: Replaced fake struct 'inheritance' (using #defines) with regular C++ subclassing

svn-id: r39005
This commit is contained in:
Max Horn 2009-03-01 06:01:48 +00:00
parent 6742caa87a
commit 6454a3dee1
3 changed files with 20 additions and 46 deletions

View File

@ -106,21 +106,6 @@ struct song_iterator_message_t {
} args[SONG_ITERATOR_MESSAGE_ARGUMENTS_NR];
};
#define INHERITS_SONG_ITERATOR \
songit_id_t ID; \
uint16 channel_mask; \
fade_params_t fade; \
unsigned int flags; \
int priority; \
int (*next) (song_iterator_t *self, unsigned char *buf, int *buf_size); \
sfx_pcm_feed_t * (*get_pcm_feed) (song_iterator_t *s); \
song_iterator_t * (* handle_message)(song_iterator_t *self, song_iterator_message_t msg); \
void (*init) (song_iterator_t *self); \
void (*cleanup) (song_iterator_t *self); \
int (*get_timepos) (song_iterator_t *self); \
listener_t death_listeners[SONGIT_MAX_LISTENERS]; \
int death_listeners_nr \
#define SONGIT_MAX_LISTENERS 2
struct song_iterator_t {

View File

@ -75,33 +75,27 @@ struct song_iterator_channel_t {
byte last_cmd; /* Last operation executed, for running status */
};
#define INHERITS_BASE_SONG_ITERATOR \
INHERITS_SONG_ITERATOR; /* aka "extends song iterator" */ \
\
int polyphony[MIDI_CHANNELS]; /* # of simultaneous notes on each */ \
int importance[MIDI_CHANNELS]; /* priority rating for each channel, 0 means unrated. */ \
\
\
int ccc; /* Cumulative cue counter, for those who need it */ \
unsigned char resetflag; /* for 0x4C -- on DoSound StopSound, do we return to start? */ \
int device_id; /* ID of the device we generating events for */ \
int active_channels; /* Number of active channels */ \
unsigned int size; /* Song size */ \
unsigned char *data; \
\
int loops; /* Number of loops remaining */ \
int recover_delay
struct base_song_iterator_t : public song_iterator_t {
int polyphony[MIDI_CHANNELS]; /* # of simultaneous notes on each */
int importance[MIDI_CHANNELS]; /* priority rating for each channel, 0 means unrated. */
struct base_song_iterator_t {
INHERITS_BASE_SONG_ITERATOR;
int ccc; /* Cumulative cue counter, for those who need it */
unsigned char resetflag; /* for 0x4C -- on DoSound StopSound, do we return to start? */
int device_id; /* ID of the device we generating events for */
int active_channels; /* Number of active channels */
unsigned int size; /* Song size */
unsigned char *data;
int loops; /* Number of loops remaining */
int recover_delay;
};
/********************************/
/*--------- SCI 0 --------------*/
/********************************/
struct sci0_song_iterator_t {
INHERITS_BASE_SONG_ITERATOR;
struct sci0_song_iterator_t : public base_song_iterator_t {
song_iterator_channel_t channel;
int delay_remaining; /* Number of ticks that haven't been polled yet */
};
@ -122,8 +116,7 @@ struct sci1_sample_t {
sci1_sample_t *next;
};
struct sci1_song_iterator_t {
INHERITS_BASE_SONG_ITERATOR;
struct sci1_song_iterator_t : public base_song_iterator_t {
song_iterator_channel_t channels[MIDI_CHANNELS];
/* Invariant: Whenever channels[i].delay == CHANNEL_DELAY_MISSING,
@ -163,8 +156,7 @@ int is_cleanup_iterator(song_iterator_t *it);
/*--------- Fast Forward ---------*/
/**********************************/
struct fast_forward_song_iterator_t {
INHERITS_SONG_ITERATOR;
struct fast_forward_song_iterator_t : public song_iterator_t {
song_iterator_t *delegate;
int delta; /* Remaining time */
};
@ -197,9 +189,7 @@ song_iterator_t *new_fast_forward_iterator(song_iterator_t *it, int delta);
#define TEE_MORPH_NONE 0 /* Not waiting to self-morph */
#define TEE_MORPH_READY 1 /* Ready to self-morph */
struct tee_song_iterator_t {
INHERITS_SONG_ITERATOR;
struct tee_song_iterator_t : public song_iterator_t {
int status;
int may_destroy; /* May destroy song iterators */

View File

@ -51,17 +51,16 @@ void error(char *fmt, ...) {
/* The simple iterator will finish after a fixed amount of time. Before that,
** it emits (absolute) cues in ascending order. */
struct simple_it_struct {
INHERITS_SONG_ITERATOR;
struct simple_iterator : public song_iterator_t {
int lifetime_remaining;
char *cues;
int cue_counter;
int cue_progress;
int cues_nr;
} simple_iterator;
};
int simple_it_next(song_iterator_t *_self, unsigned char *buf, int *result) {
struct simple_it_struct *self = (struct simple_it_struct *) _self;
simple_iterator *self = (simple_iterator *)_self;
if (self->lifetime_remaining == -1) {
error("Song iterator called post mortem");