Fix code formatting

svn-id: r38930
This commit is contained in:
Eugene Sandulenko 2009-02-27 12:59:02 +00:00
parent 4042eb8259
commit d53c75fc8f
27 changed files with 194 additions and 358 deletions

View file

@ -55,8 +55,8 @@ static unsigned int get_next(heap_t *h, int block_pos) {
} }
// Allocates a new heap // Allocates a new heap
heap_t* heap_new() { heap_t *heap_new() {
heap_t* h; heap_t *h;
if ((h = (heap_t*)sci_malloc(sizeof(heap_t))) == 0) if ((h = (heap_t*)sci_malloc(sizeof(heap_t))) == 0)
return 0; return 0;
@ -248,7 +248,7 @@ void heap_dump_all(heap_t *h) {
} }
} }
/* #if 0
int main(int argc, char **argv) { int main(int argc, char **argv) {
heap_t *h = heap_new(); heap_t *h = heap_new();
int a, b, c, d, e; int a, b, c, d, e;
@ -281,6 +281,6 @@ int main(int argc, char **argv) {
return 0; return 0;
} }
*/ #endif
} // End of namespace Sci } // End of namespace Sci

View file

@ -91,8 +91,7 @@ namespace Sci {
#define SCRIPT_ASSERT_ZERO(fun) if (fun) script_debug_flag = script_error_flag = 1; #define SCRIPT_ASSERT_ZERO(fun) if (fun) script_debug_flag = script_error_flag = 1;
static void static void script_set_priority(EngineState *s, reg_t obj, int priority) {
script_set_priority(EngineState *s, reg_t obj, int priority) {
int song_nr = GET_SEL32V(obj, number); int song_nr = GET_SEL32V(obj, number);
resource_t *song = scir_find_resource(s->resmgr, sci_sound, song_nr, 0); resource_t *song = scir_find_resource(s->resmgr, sci_sound, song_nr, 0);
int flags = GET_SEL32V(obj, flags); int flags = GET_SEL32V(obj, flags);
@ -110,8 +109,7 @@ script_set_priority(EngineState *s, reg_t obj, int priority) {
PUT_SEL32V(obj, flags, flags); PUT_SEL32V(obj, flags, flags);
} }
song_iterator_t * song_iterator_t *build_iterator(EngineState *s, int song_nr, int type, songit_id_t id) {
build_iterator(EngineState *s, int song_nr, int type, songit_id_t id) {
resource_t *song = scir_find_resource(s->resmgr, sci_sound, song_nr, 0); resource_t *song = scir_find_resource(s->resmgr, sci_sound, song_nr, 0);
if (!song) if (!song)
@ -121,8 +119,7 @@ build_iterator(EngineState *s, int song_nr, int type, songit_id_t id) {
} }
void void process_sound_events(EngineState *s) { /* Get all sound events, apply their changes to the heap */
process_sound_events(EngineState *s) { /* Get all sound events, apply their changes to the heap */
int result; int result;
song_handle_t handle; song_handle_t handle;
int cue; int cue;
@ -174,8 +171,7 @@ process_sound_events(EngineState *s) { /* Get all sound events, apply their chan
} }
reg_t reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
reg_t obj = KP_ALT(1, NULL_REG); reg_t obj = KP_ALT(1, NULL_REG);
uint16 command = UKPV(0); uint16 command = UKPV(0);
song_handle_t handle = FROBNICATE_HANDLE(obj); song_handle_t handle = FROBNICATE_HANDLE(obj);
@ -362,12 +358,10 @@ kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
return s->r_acc; return s->r_acc;
} }
int int sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel,
sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel,
int command, int arg1, int arg2); int command, int arg1, int arg2);
reg_t reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
uint16 command = UKPV(0); uint16 command = UKPV(0);
reg_t obj = KP_ALT(1, NULL_REG); reg_t obj = KP_ALT(1, NULL_REG);
song_handle_t handle = FROBNICATE_HANDLE(obj); song_handle_t handle = FROBNICATE_HANDLE(obj);
@ -667,12 +661,10 @@ kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
return s->r_acc; return s->r_acc;
} }
int int sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel,
sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel,
int command, int arg1, int arg2); int command, int arg1, int arg2);
reg_t reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
uint16 command = UKPV(0); uint16 command = UKPV(0);
reg_t obj = KP_ALT(1, NULL_REG); reg_t obj = KP_ALT(1, NULL_REG);
song_handle_t handle = FROBNICATE_HANDLE(obj); song_handle_t handle = FROBNICATE_HANDLE(obj);
@ -979,8 +971,7 @@ kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
return s->r_acc; return s->r_acc;
} }
reg_t reg_t kDoSound(EngineState *s, int funct_nr, int argc, reg_t *argv) {
kDoSound(EngineState *s, int funct_nr, int argc, reg_t *argv) {
if (s->version >= SCI_VERSION_FTU_DOSOUND_VARIANT_2) if (s->version >= SCI_VERSION_FTU_DOSOUND_VARIANT_2)
return kDoSound_SCI1(s, funct_nr, argc, argv); return kDoSound_SCI1(s, funct_nr, argc, argv);
else if (s->version >= SCI_VERSION_FTU_DOSOUND_VARIANT_1) else if (s->version >= SCI_VERSION_FTU_DOSOUND_VARIANT_1)
@ -989,8 +980,7 @@ kDoSound(EngineState *s, int funct_nr, int argc, reg_t *argv) {
return kDoSound_SCI0(s, funct_nr, argc, argv); return kDoSound_SCI0(s, funct_nr, argc, argv);
} }
reg_t reg_t kDoAudio(EngineState *s, int funct_nr, int argc, reg_t *argv) {
kDoAudio(EngineState *s, int funct_nr, int argc, reg_t *argv) {
switch (UKPV(0)) { switch (UKPV(0)) {
case _K_SCI1_AUDIO_POSITION : case _K_SCI1_AUDIO_POSITION :
return make_reg(0, -1); /* Finish immediately */ return make_reg(0, -1); /* Finish immediately */

View file

@ -1917,10 +1917,10 @@ static int c_gfx_propagate_rect(EngineState *s) {
} }
#define GETRECT(ll, rr, tt, bb) \ #define GETRECT(ll, rr, tt, bb) \
ll = GET_SELECTOR(pos, ll); \ ll = GET_SELECTOR(pos, ll); \
rr = GET_SELECTOR(pos, rr); \ rr = GET_SELECTOR(pos, rr); \
tt = GET_SELECTOR(pos, tt); \ tt = GET_SELECTOR(pos, tt); \
bb = GET_SELECTOR(pos, bb); bb = GET_SELECTOR(pos, bb);
#if 0 #if 0
// Unreferenced - removed // Unreferenced - removed
@ -2207,7 +2207,8 @@ static int c_resource_id(EngineState *s) {
} }
static int c_listclones(EngineState *s) { static int c_listclones(EngineState *s) {
/* int i, j = 0; #if 0
int i, j = 0;
sciprintf("Listing all logged clones:\n"); sciprintf("Listing all logged clones:\n");
@ -2218,7 +2219,8 @@ static int c_listclones(EngineState *s) {
} }
} }
sciprintf("Total of %d clones.\n", j);*/ sciprintf("Total of %d clones.\n", j);
#endif
sciprintf("This function is temporarily disabled.\n"); sciprintf("This function is temporarily disabled.\n");
return 0; return 0;
@ -2445,10 +2447,10 @@ int c_simsoundcue(EngineState *s) {
} }
#define GETRECT(ll, rr, tt, bb) \ #define GETRECT(ll, rr, tt, bb) \
ll = GET_SELECTOR(pos, ll); \ ll = GET_SELECTOR(pos, ll); \
rr = GET_SELECTOR(pos, rr); \ rr = GET_SELECTOR(pos, rr); \
tt = GET_SELECTOR(pos, tt); \ tt = GET_SELECTOR(pos, tt); \
bb = GET_SELECTOR(pos, bb); bb = GET_SELECTOR(pos, bb);
#if 0 #if 0
#ifdef __GNUC__ #ifdef __GNUC__

View file

@ -45,8 +45,7 @@
namespace Sci { namespace Sci {
int int sci0_palette;
sci0_palette;
gfx_pixmap_color_t gfx_sci0_image_colors[1][16]; gfx_pixmap_color_t gfx_sci0_image_colors[1][16];
@ -55,8 +54,7 @@ gfxr_interpreter_get_static_palette(gfx_resstate_t *state, int version, int *col
return NULL; return NULL;
} }
int int sciprintf(const char *fmt, ...) {
sciprintf(const char *fmt, ...) {
va_list argp; va_list argp;
va_start(argp, fmt); va_start(argp, fmt);
vprintf(fmt, argp); vprintf(fmt, argp);
@ -65,8 +63,7 @@ sciprintf(const char *fmt, ...) {
} }
void * void *memdup(void *mem, size_t size) {
memdup(void *mem, size_t size) {
void *r = malloc(size); void *r = malloc(size);
if (r) if (r)
memcpy(r, mem, size); memcpy(r, mem, size);
@ -77,8 +74,7 @@ memdup(void *mem, size_t size) {
# include "../scicore/sci_memory.c" # include "../scicore/sci_memory.c"
#endif #endif
void void sci_gettime(long *seconds, long *useconds) {
sci_gettime(long *seconds, long *useconds) {
struct timeval tv; struct timeval tv;
#ifdef WIN32 #ifdef WIN32
@ -131,8 +127,7 @@ static struct {
{GFX_CAPABILITY_KEYTRANSLATE, "built-in keyboard translation"} {GFX_CAPABILITY_KEYTRANSLATE, "built-in keyboard translation"}
}; };
int int init_driver(gfx_driver_t *drv) {
init_driver(gfx_driver_t *drv) {
int i; int i;
state->driver = drv; state->driver = drv;
@ -177,21 +172,18 @@ int test_views[TEST_VIEWS_NR] = {0};
int test_fonts[TEST_FONTS_NR] = {0}; int test_fonts[TEST_FONTS_NR] = {0};
int test_cursors[TEST_CURSORS_NR] = {0, 1}; int test_cursors[TEST_CURSORS_NR] = {0, 1};
int int gfxr_interpreter_options_hash(gfx_resource_type_t type, int version, gfx_options_t *options, void *internal, int palette) {
gfxr_interpreter_options_hash(gfx_resource_type_t type, int version, gfx_options_t *options, void *internal, int palette) {
return 0; return 0;
} }
int * int *arrdup(int *src, int count) {
arrdup(int *src, int count) {
int *retval = sci_malloc(sizeof(int) * count); int *retval = sci_malloc(sizeof(int) * count);
memcpy(retval, src, sizeof(int) * count); memcpy(retval, src, sizeof(int) * count);
return retval; return retval;
} }
int * int *gfxr_interpreter_get_resources(gfx_resstate_t *resstate, gfx_resource_type_t type,
gfxr_interpreter_get_resources(gfx_resstate_t *resstate, gfx_resource_type_t type,
int version, int *entries_nr, void *internal) { int version, int *entries_nr, void *internal) {
switch (type) { switch (type) {
@ -254,8 +246,7 @@ gfx_pixmap_color_t pic_colors[PIC_COLORS_NR] = {
{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0xff} {GFX_COLOR_INDEX_UNMAPPED, 0x00, 0x00, 0xff}
}; };
gfxr_pic_t * gfxr_pic_t *gfxr_interpreter_init_pic(int version, gfx_mode_t *mode, int ID, void *internal) {
gfxr_interpreter_init_pic(int version, gfx_mode_t *mode, int ID, void *internal) {
gfxr_pic_t *pic = sci_malloc(sizeof(gfxr_pic_t)); gfxr_pic_t *pic = sci_malloc(sizeof(gfxr_pic_t));
pic->mode = mode; pic->mode = mode;
@ -284,8 +275,7 @@ gfxr_interpreter_init_pic(int version, gfx_mode_t *mode, int ID, void *internal)
void void gfxr_interpreter_clear_pic(int version, gfxr_pic_t *pic, void *internal) {
gfxr_interpreter_clear_pic(int version, gfxr_pic_t *pic, void *internal) {
memset(pic->visual_map->index_data, 0x00, 320 * 200); memset(pic->visual_map->index_data, 0x00, 320 * 200);
memset(pic->priority_map->index_data, 0, 320 * pic->mode->xfact * 200 * pic->mode->yfact); memset(pic->priority_map->index_data, 0, 320 * pic->mode->xfact * 200 * pic->mode->yfact);
memset(pic->control_map->index_data, 0, GFXR_AUX_MAP_SIZE); memset(pic->control_map->index_data, 0, GFXR_AUX_MAP_SIZE);
@ -293,8 +283,7 @@ gfxr_interpreter_clear_pic(int version, gfxr_pic_t *pic, void *internal) {
} }
int int gfxr_interpreter_calculate_pic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic,
gfxr_interpreter_calculate_pic(gfx_resstate_t *state, gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic,
int flags, int default_palette, int nr, void *internal) { int flags, int default_palette, int nr, void *internal) {
gfxr_pic_t *pic = scaled_pic; gfxr_pic_t *pic = scaled_pic;
int i, x, y, pos; int i, x, y, pos;
@ -367,8 +356,7 @@ gfx_pixmap_color_t view_colors[VIEW_COLORS_NR] = {
{GFX_COLOR_INDEX_UNMAPPED, 0x00, 0xff, 0x00} {GFX_COLOR_INDEX_UNMAPPED, 0x00, 0xff, 0x00}
}; };
gfxr_view_t * gfxr_view_t *gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int palette) {
gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int palette) {
gfxr_view_t *view; gfxr_view_t *view;
gfxr_loop_t *loop; gfxr_loop_t *loop;
int i; int i;
@ -434,8 +422,7 @@ gfxr_interpreter_get_view(gfx_resstate_t *state, int nr, void *internal, int pal
extern byte builtin_font[]; extern byte builtin_font[];
gfx_bitmap_font_t * gfx_bitmap_font_t *gfxr_interpreter_get_font(gfx_resstate_t *state, int nr, void *internal) {
gfxr_interpreter_get_font(gfx_resstate_t *state, int nr, void *internal) {
gfx_bitmap_font_t *font; gfx_bitmap_font_t *font;
int i; int i;
if (nr < 0 || nr > TEST_FONTS_NR) if (nr < 0 || nr > TEST_FONTS_NR)
@ -463,8 +450,7 @@ gfx_pixmap_color_t _cursor_colors[3] = {
{GFX_COLOR_INDEX_UNMAPPED, 0x80, 0x80, 0x80} {GFX_COLOR_INDEX_UNMAPPED, 0x80, 0x80, 0x80}
}; };
gfx_pixmap_t * gfx_pixmap_t *gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal) {
gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal) {
gfx_pixmap_t *cursor; gfx_pixmap_t *cursor;
int xl, yl, x, y; int xl, yl, x, y;
@ -535,20 +521,17 @@ gfxr_interpreter_get_cursor(gfx_resstate_t *state, int nr, void *internal) {
return cursor; return cursor;
} }
gfx_pixmap_color_t * gfx_pixmap_color_t *gfxr_interpreter_get_palette(gfx_resstate_t *state, int version, int *colors_nr, void *internal, int nr) {
gfxr_interpreter_get_palette(gfx_resstate_t *state, int version, int *colors_nr, void *internal, int nr) {
return NULL; return NULL;
} }
int int gfxr_interpreter_needs_multicolored_pointers(int version, void *internal) {
gfxr_interpreter_needs_multicolored_pointers(int version, void *internal) {
return multicolored_pointers; return multicolored_pointers;
} }
gfx_color_t red, green, blue, dblue, white, white8, white16, white24, black, transparent; gfx_color_t red, green, blue, dblue, white, white8, white16, white24, black, transparent;
void void init_colors() {
init_colors() {
gfxop_set_color(state, &red, 0xff, 0x00, 0x00, 0x00, -1, -1); gfxop_set_color(state, &red, 0xff, 0x00, 0x00, 0x00, -1, -1);
gfxop_set_color(state, &green, 0x00, 0xff, 0x00, 0x00, -1, -1); gfxop_set_color(state, &green, 0x00, 0xff, 0x00, 0x00, -1, -1);
gfxop_set_color(state, &blue, 0x00, 0x00, 0xff, 0x00, -1, -1); gfxop_set_color(state, &blue, 0x00, 0x00, 0xff, 0x00, -1, -1);
@ -569,8 +552,7 @@ init_colors() {
#define MESSAGE4(foo,a,b,c,d) { char buf[1024]; sprintf(buf,foo,a,b,c,d); if (message(buf)) { fprintf(stderr,"Message '%s' could not be print!\n", buf); return;}} #define MESSAGE4(foo,a,b,c,d) { char buf[1024]; sprintf(buf,foo,a,b,c,d); if (message(buf)) { fprintf(stderr,"Message '%s' could not be print!\n", buf); return;}}
int int waitkey(void) {
waitkey(void) {
int count = 100000; int count = 100000;
sci_event_t event; sci_event_t event;
@ -585,8 +567,7 @@ waitkey(void) {
return 1; return 1;
} }
int int wait_specific_key(int key) {
wait_specific_key(int key) {
int count = 20000; int count = 20000;
sci_event_t event; sci_event_t event;
@ -603,8 +584,7 @@ wait_specific_key(int key) {
} }
int int message(char *msg) {
message(char *msg) {
gfx_text_handle_t *handle; gfx_text_handle_t *handle;
rect_t text_rect = gfx_rect(0, 150, 320, 50); rect_t text_rect = gfx_rect(0, 150, 320, 50);
@ -623,32 +603,27 @@ message(char *msg) {
return 0; return 0;
} }
void void update(void) {
update(void) {
/* gfxop_update_box(state, gfx_rect(0, 0, 320, 150)); */ /* gfxop_update_box(state, gfx_rect(0, 0, 320, 150)); */
gfxop_update(state); gfxop_update(state);
} }
void void explicit_clear_buffer(void) {
explicit_clear_buffer(void) {
gfxop_clear_box(state, gfx_rect(0, 0, 320, 150)); gfxop_clear_box(state, gfx_rect(0, 0, 320, 150));
gfxop_update(state); gfxop_update(state);
} }
void void clear_buffer(void) {
clear_buffer(void) {
gfxop_disable_dirty_frames(state); gfxop_disable_dirty_frames(state);
gfxop_clear_box(state, gfx_rect(0, 0, 320, 150)); gfxop_clear_box(state, gfx_rect(0, 0, 320, 150));
gfxop_enable_dirty_frames(state); gfxop_enable_dirty_frames(state);
} }
void void clear(void) {
clear(void) {
gfxop_fill_box(state, gfx_rect(0, 0, 320, 150), black); gfxop_fill_box(state, gfx_rect(0, 0, 320, 150), black);
} }
void void identify_event(sci_event_t event) {
identify_event(sci_event_t event) {
switch (event.type) { switch (event.type) {
case SCI_EVT_NONE: case SCI_EVT_NONE:
@ -686,8 +661,7 @@ identify_event(sci_event_t event) {
} }
int int test_a(void) {
test_a(void) {
if (message("-- Test A --\nText display and basic input\nPlease press 'space' within 20 seconds")) if (message("-- Test A --\nText display and basic input\nPlease press 'space' within 20 seconds"))
return 1; return 1;
@ -725,8 +699,7 @@ int test_b_lines[LINES_NR][4] = {
{170, 90, 20, 10} {170, 90, 20, 10}
}; };
void void test_b(void) {
test_b(void) {
int i; int i;
MESSAGE("-- Test B --\nLines"); MESSAGE("-- Test B --\nLines");
@ -776,8 +749,7 @@ test_b(void) {
} }
void void test_c(void) {
test_c(void) {
int i; int i;
clear(); clear();
update(); update();
@ -831,8 +803,7 @@ test_c(void) {
} }
void void test_d(void) {
test_d(void) {
rect_t line; rect_t line;
int pressed = 0; int pressed = 0;
sci_event_t event; sci_event_t event;
@ -904,8 +875,7 @@ test_d(void) {
} }
void void test_e(void) {
test_e(void) {
int x; int x;
gfxop_set_pointer_cursor(state, 1); gfxop_set_pointer_cursor(state, 1);
@ -980,8 +950,7 @@ test_e(void) {
waitkey(); waitkey();
} }
void void test_wrap(int width, char *text) {
test_wrap(int width, char *text) {
rect_t rect = gfx_rect(0, 0, width, 120); rect_t rect = gfx_rect(0, 0, width, 120);
gfx_text_handle_t *handle = gfxop_new_text(state, 0, gfx_text_handle_t *handle = gfxop_new_text(state, 0,
text, text,
@ -993,8 +962,7 @@ test_wrap(int width, char *text) {
gfxop_free_text(state, handle); gfxop_free_text(state, handle);
} }
void void test_f(void) {
test_f(void) {
int i; int i;
int x, y; int x, y;
gfx_text_handle_t *handle; gfx_text_handle_t *handle;
@ -1047,8 +1015,7 @@ test_f(void) {
waitkey(); waitkey();
} }
void void do_tests(char *conf) {
do_tests(char *conf) {
init_colors(); init_colors();
@ -1072,14 +1039,12 @@ do_tests(char *conf) {
test_f(); test_f();
} }
int int c_quit(void *S) {
c_quit(void *S) {
exit(0); exit(0);
return 0; /* hahaha */ return 0; /* hahaha */
} }
int int main(int argc, char **argv) {
main(int argc, char **argv) {
gfx_driver_t *drv = NULL; gfx_driver_t *drv = NULL;
char c; char c;

View file

@ -128,7 +128,7 @@ static int _gfxwop_print_empty(gfxw_widget_t *widget, int indentation) {
return 0; return 0;
} }
gfxw_widget_t * _gfxw_new_widget(int size, gfxw_widget_type_t type) { gfxw_widget_t *_gfxw_new_widget(int size, gfxw_widget_type_t type) {
gfxw_widget_t *widget = (gfxw_widget_t*)sci_malloc(size); gfxw_widget_t *widget = (gfxw_widget_t*)sci_malloc(size);
#ifdef SATISFY_PURIFY #ifdef SATISFY_PURIFY
memset(widget, 0, size); memset(widget, 0, size);
@ -2039,7 +2039,7 @@ gfxw_dyn_view_t *gfxw_picviewize_dynview(gfxw_dyn_view_t *dynview) {
// Chrono-Ports (tm) // Chrono-Ports (tm)
gfxw_port_t * gfxw_get_chrono_port(gfxw_visual_t *visual, gfxw_list_t **temp_widgets_list, int flags) { gfxw_port_t *gfxw_get_chrono_port(gfxw_visual_t *visual, gfxw_list_t **temp_widgets_list, int flags) {
gfxw_port_t *result = NULL; gfxw_port_t *result = NULL;
gfx_color_t transparent = {{0, 0, 0, 0}, 0, 0, 0, 0}; gfx_color_t transparent = {{0, 0, 0, 0}, 0, 0, 0, 0};
int id = 0; int id = 0;

View file

@ -137,8 +137,7 @@ void gfxr_init_static_palette() {
} }
gfxr_pic_t * gfxr_pic_t *gfxr_init_pic(gfx_mode_t *mode, int ID, int sci1) {
gfxr_init_pic(gfx_mode_t *mode, int ID, int sci1) {
gfxr_pic_t *pic = (gfxr_pic_t*)sci_malloc(sizeof(gfxr_pic_t)); gfxr_pic_t *pic = (gfxr_pic_t*)sci_malloc(sizeof(gfxr_pic_t));
pic->mode = mode; pic->mode = mode;
@ -335,8 +334,7 @@ static void _gfxr_auxbuf_propagate_changes(gfxr_pic_t *pic, int bitmask) {
#endif #endif
static inline void static inline void _gfxr_auxbuf_tag_line(gfxr_pic_t *pic, int pos, int width) {
_gfxr_auxbuf_tag_line(gfxr_pic_t *pic, int pos, int width) {
int i; int i;
for (i = 0; i < width; i++) for (i = 0; i < width; i++)
pic->aux_map[i+pos] |= FRESH_PAINT; pic->aux_map[i+pos] |= FRESH_PAINT;

View file

@ -39,7 +39,7 @@ namespace Sci {
#undef SCI_REQUIRE_RESOURCE_FILES #undef SCI_REQUIRE_RESOURCE_FILES
//#define SCI_VERBOSE_RESMGR 1 //#define SCI_VERBOSE_RESMGR 1
const char* sci_version_types[] = { const char *sci_version_types[] = {
"SCI version undetermined (Autodetect failed / not run)", "SCI version undetermined (Autodetect failed / not run)",
"SCI version 0.xxx", "SCI version 0.xxx",
"SCI version 0.xxx w/ 1.000 compression", "SCI version 0.xxx w/ 1.000 compression",
@ -53,7 +53,7 @@ const char* sci_version_types[] = {
const int sci_max_resource_nr[] = {65536, 1000, 2048, 2048, 2048, 8192, 8192, 65536}; const int sci_max_resource_nr[] = {65536, 1000, 2048, 2048, 2048, 8192, 8192, 65536};
const char* sci_error_types[] = { const char *sci_error_types[] = {
"No error", "No error",
"I/O error", "I/O error",
"Resource is empty (size 0)", "Resource is empty (size 0)",
@ -67,7 +67,7 @@ const char* sci_error_types[] = {
"SCI version is unsupported" "SCI version is unsupported"
}; };
const char* sci_resource_types[] = {"view", "pic", "script", "text", "sound", const char *sci_resource_types[] = {"view", "pic", "script", "text", "sound",
"memory", "vocab", "font", "cursor", "memory", "vocab", "font", "cursor",
"patch", "bitmap", "palette", "cdaudio", "patch", "bitmap", "palette", "cdaudio",
"audio", "sync", "message", "map", "heap" "audio", "sync", "message", "map", "heap"

View file

@ -93,10 +93,10 @@ enum ResourceType {
#define RESSOURCE_ADDRESSING_EXTENDED 128 #define RESSOURCE_ADDRESSING_EXTENDED 128
#define RESSOURCE_ADDRESSING_MASK 128 #define RESSOURCE_ADDRESSING_MASK 128
extern const char* sci_error_types[]; extern const char *sci_error_types[];
extern const char* sci_version_types[]; extern const char *sci_version_types[];
extern const char* sci_resource_types[]; extern const char *sci_resource_types[];
extern const char* sci_resource_type_suffixes[]; /* Suffixes for SCI1 patch files */ extern const char *sci_resource_type_suffixes[]; /* Suffixes for SCI1 patch files */
extern const int sci_max_resource_nr[]; /* Highest possible resource numbers */ extern const int sci_max_resource_nr[]; /* Highest possible resource numbers */

View file

@ -36,7 +36,7 @@ namespace Sci {
int con_passthrough = 0; int con_passthrough = 0;
FILE *con_file = NULL; FILE *con_file = NULL;
static void(*_con_string_callback)(char*) = NULL; static void (*_con_string_callback)(char*) = NULL;
static void (*_con_pixmap_callback)(gfx_pixmap_t *) = NULL; static void (*_con_pixmap_callback)(gfx_pixmap_t *) = NULL;
int sciprintf(const char *fmt, ...) { int sciprintf(const char *fmt, ...) {

View file

@ -159,8 +159,7 @@ static int is_playing(sfx_state_t *self, song_t *song) {
return 0; return 0;
} }
static void static void _sfx_set_song_status(sfx_state_t *self, song_t *song, int status) {
_sfx_set_song_status(sfx_state_t *self, song_t *song, int status) {
switch (status) { switch (status) {
case SOUND_STATUS_STOPPED: case SOUND_STATUS_STOPPED:

View file

@ -43,8 +43,7 @@ static int subport_nr = 0;
static const char *seq_name = "default"; static const char *seq_name = "default";
static void static void _set_tempo(void) {
_set_tempo(void) {
int resolution = 60; int resolution = 60;
int tempo = 1; int tempo = 1;
snd_seq_queue_tempo_t *queue_tempo; snd_seq_queue_tempo_t *queue_tempo;
@ -72,8 +71,7 @@ _set_tempo(void) {
} }
static int static int am_subscribe_to_ports(void) {
am_subscribe_to_ports(void) {
if ((port_out = snd_seq_connect_to(seq, port_out, port_nr, subport_nr)) < 0) { if ((port_out = snd_seq_connect_to(seq, port_out, port_nr, subport_nr)) < 0) {
fprintf(stderr, "[SFX] Could not connect to ALSA sequencer port: %s\n", snd_strerror(port_out)); fprintf(stderr, "[SFX] Could not connect to ALSA sequencer port: %s\n", snd_strerror(port_out));
return SFX_ERROR; return SFX_ERROR;
@ -82,8 +80,7 @@ am_subscribe_to_ports(void) {
} }
static int static int aminit(midi_writer_t *self) {
aminit(midi_writer_t *self) {
int err; int err;
snd_midi_event_new(4096, &parser); snd_midi_event_new(4096, &parser);
@ -124,14 +121,12 @@ aminit(midi_writer_t *self) {
return SFX_OK; return SFX_OK;
} }
static int static int amsetopt(midi_writer_t *self, char *name, char *value) {
amsetopt(midi_writer_t *self, char *name, char *value) {
return SFX_ERROR; return SFX_ERROR;
} }
static int static int amwrite(midi_writer_t *self, unsigned char *buf, int len) {
amwrite(midi_writer_t *self, unsigned char *buf, int len) {
snd_seq_event_t evt; snd_seq_event_t evt;
#if 0 #if 0
@ -170,13 +165,11 @@ amwrite(midi_writer_t *self, unsigned char *buf, int len) {
return SFX_OK; return SFX_OK;
} }
static void static void amdelay(midi_writer_t *self, int ticks) {
amdelay(midi_writer_t *self, int ticks) {
delta += ticks; delta += ticks;
} }
static void static void amreset_timer(midi_writer_t *self) {
amreset_timer(midi_writer_t *self) {
snd_seq_drain_output(seq); snd_seq_drain_output(seq);
snd_seq_stop_queue(seq, queue, NULL); snd_seq_stop_queue(seq, queue, NULL);
@ -198,8 +191,7 @@ amreset_timer(midi_writer_t *self) {
snd_seq_start_queue(seq, queue, NULL); snd_seq_start_queue(seq, queue, NULL);
} }
static void static void amclose(midi_writer_t *self) {
amclose(midi_writer_t *self) {
snd_midi_event_free(parser); snd_midi_event_free(parser);
parser = NULL; parser = NULL;
} }

View file

@ -61,8 +61,7 @@ static struct MidiNode *midi_node = NULL;
return SFX_ERROR; \ return SFX_ERROR; \
} }
static int static int camd_init(midi_writer_t *self) {
camd_init(midi_writer_t *self) {
sciprintf("[SFX] Initialising CAMD raw MIDI backend, v%s\n", SCI_CAMD_MIDI_VERSION); sciprintf("[SFX] Initialising CAMD raw MIDI backend, v%s\n", SCI_CAMD_MIDI_VERSION);
CamdBase = IExec->OpenLibrary("camd.library", 36L); CamdBase = IExec->OpenLibrary("camd.library", 36L);
@ -86,15 +85,13 @@ camd_init(midi_writer_t *self) {
return SFX_OK; return SFX_OK;
} }
static int static int camd_set_option(midi_writer_t *self, char *name, char *value) {
camd_set_option(midi_writer_t *self, char *name, char *value) {
return SFX_ERROR; return SFX_ERROR;
} }
#define MAX_MIDI_LEN 3 #define MAX_MIDI_LEN 3
static int static int camd_write(midi_writer_t *self, unsigned char *buffer, int len) {
camd_write(midi_writer_t *self, unsigned char *buffer, int len) {
if (len == 0) if (len == 0)
return SFX_OK; return SFX_OK;
@ -123,16 +120,13 @@ camd_write(midi_writer_t *self, unsigned char *buffer, int len) {
return SFX_OK; return SFX_OK;
} }
static void static void camd_delay(midi_writer_t *self, int ticks) {
camd_delay(midi_writer_t *self, int ticks) {
} }
static void static void camd_reset_timer(midi_writer_t *self) {
camd_reset_timer(midi_writer_t *self) {
} }
static void static void camd_close(midi_writer_t *self) {
camd_close(midi_writer_t *self) {
#ifdef NO_OP #ifdef NO_OP
return; return;
#endif #endif

View file

@ -41,8 +41,7 @@ namespace Sci {
static int fd; static int fd;
static const char *devicename = "/dev/midi"; static const char *devicename = "/dev/midi";
static int static int unixraw_init(midi_writer_t *self) {
unixraw_init(midi_writer_t *self) {
sciprintf("[SFX] Initialising UNIX raw MIDI backend, v%s\n", SCI_UNIXRAW_MIDI_VERSION); sciprintf("[SFX] Initialising UNIX raw MIDI backend, v%s\n", SCI_UNIXRAW_MIDI_VERSION);
fd = open(devicename, O_WRONLY | O_SYNC); fd = open(devicename, O_WRONLY | O_SYNC);
@ -55,13 +54,11 @@ unixraw_init(midi_writer_t *self) {
return SFX_OK; return SFX_OK;
} }
static int static int unixraw_set_option(midi_writer_t *self, char *name, char *value) {
unixraw_set_option(midi_writer_t *self, char *name, char *value) {
return SFX_ERROR; return SFX_ERROR;
} }
static int static int unixraw_write(midi_writer_t *self, unsigned char *buffer, int len) {
unixraw_write(midi_writer_t *self, unsigned char *buffer, int len) {
if (write(fd, buffer, len) != len) { if (write(fd, buffer, len) != len) {
sciprintf("[SFX] MIDI write error\n"); sciprintf("[SFX] MIDI write error\n");
return SFX_ERROR; return SFX_ERROR;
@ -69,16 +66,13 @@ unixraw_write(midi_writer_t *self, unsigned char *buffer, int len) {
return SFX_OK; return SFX_OK;
} }
static void static void unixraw_delay(midi_writer_t *self, int ticks) {
unixraw_delay(midi_writer_t *self, int ticks) {
} }
static void static void unixraw_reset_timer(midi_writer_t *self) {
unixraw_reset_timer(midi_writer_t *self) {
} }
static void static void unixraw_close(midi_writer_t *self) {
unixraw_close(midi_writer_t *self) {
close(fd); close(fd);
} }

View file

@ -1062,8 +1062,7 @@ static int _sci1_process_next_command(sci1_song_iterator_t *self,
return retval; return retval;
} }
static song_iterator_t * static song_iterator_t *_sci1_handle_message(sci1_song_iterator_t *self,
_sci1_handle_message(sci1_song_iterator_t *self,
song_iterator_message_t msg) { song_iterator_message_t msg) {
if (msg.recipient == _SIMSG_BASE) { /* May extend this in the future */ if (msg.recipient == _SIMSG_BASE) { /* May extend this in the future */
switch (msg.type) { switch (msg.type) {

View file

@ -122,7 +122,7 @@ sfx_pcm_mixer_t *sfx_pcm_find_mixer(char *name);
extern sfx_pcm_mixer_t *mixer; /* _THE_ global pcm mixer */ extern sfx_pcm_mixer_t *mixer; /* _THE_ global pcm mixer */
sfx_pcm_mixer_t* getMixer(); sfx_pcm_mixer_t *getMixer();
} // End of namespace Sci } // End of namespace Sci

View file

@ -352,12 +352,11 @@ static inline void mix_swap_buffers(sfx_pcm_mixer_t *self) { /* Swap buffers */
P->writebuf = tmp; P->writebuf = tmp;
} }
static inline int mix_compute_buf_len(sfx_pcm_mixer_t *self, int *skip_frames) static inline int mix_compute_buf_len(sfx_pcm_mixer_t *self, int *skip_frames) {
/* Computes the number of frames we ought to write. It tries to minimise the number, /* Computes the number of frames we ought to write. It tries to minimise the number,
** in order to reduce latency. */ ** in order to reduce latency. */
/* It sets 'skip_frames' to the number of frames to assume lost by latency, effectively /* It sets 'skip_frames' to the number of frames to assume lost by latency, effectively
** skipping them. */ ** skipping them. */
{
int free_frames; int free_frames;
int played_frames = 0; /* since the last call */ int played_frames = 0; /* since the last call */
uint32 msecs; uint32 msecs;
@ -922,6 +921,6 @@ sfx_pcm_mixer_t sfx_pcm_mixer_soft_linear = {
NULL NULL
}; };
sfx_pcm_mixer_t* getMixer() { return &sfx_pcm_mixer_soft_linear; } sfx_pcm_mixer_t *getMixer() { return &sfx_pcm_mixer_soft_linear; }
} // End of namespace Sci } // End of namespace Sci

View file

@ -230,15 +230,13 @@ sample_feed_t sample_feeds[FEEDS_NR] = {
#endif #endif
}; };
void void feed_destroy(sfx_pcm_feed_t *self) {
feed_destroy(sfx_pcm_feed_t *self) {
int_struct *s = (int_struct *) self->internal; int_struct *s = (int_struct *) self->internal;
s->i = 0; /* reset */ s->i = 0; /* reset */
} }
int int feed_poll(sfx_pcm_feed_t *self, byte *dest, int size) {
feed_poll(sfx_pcm_feed_t *self, byte *dest, int size) {
int_struct *s = (int_struct *) self->internal; int_struct *s = (int_struct *) self->internal;
int sample_size = self->sample_size; int sample_size = self->sample_size;
sample_feed_t *data = &(sample_feeds[self->debug_nr]); sample_feed_t *data = &(sample_feeds[self->debug_nr]);
@ -292,8 +290,7 @@ extern FILE *con_file;
#define DELAY usleep((rand() / (RAND_MAX / 250L))) #define DELAY usleep((rand() / (RAND_MAX / 250L)))
int int main(int argc, char **argv) {
main(int argc, char **argv) {
int dev_nr; int dev_nr;
mix = sfx_pcm_find_mixer(NULL); mix = sfx_pcm_find_mixer(NULL);

View file

@ -55,8 +55,7 @@ static int play_it_done = 0;
static int play_writeahead = 0; static int play_writeahead = 0;
static int play_moredelay = 0; static int play_moredelay = 0;
static void static void play_song(song_iterator_t *it, uint32 *wakeup_time, int writeahead_time) {
play_song(song_iterator_t *it, uint32 *wakeup_time, int writeahead_time) {
unsigned char buf[8]; unsigned char buf[8];
int result; int result;
@ -106,13 +105,11 @@ play_song(song_iterator_t *it, uint32 *wakeup_time, int writeahead_time) {
} }
} }
static void static void rt_tell_synth(int buf_nr, byte *buf) {
rt_tell_synth(int buf_nr, byte *buf) {
seq->event(buf[0], buf_nr - 1, buf + 1); seq->event(buf[0], buf_nr - 1, buf + 1);
} }
static void static void rt_timer_callback(void) {
rt_timer_callback(void) {
if (play_it && !play_it_done) { if (play_it && !play_it_done) {
if (!play_moredelay) { if (!play_moredelay) {
int delta = delta_time(play_last_time, g_system->getMillis()); int delta = delta_time(play_last_time, g_system->getMillis());
@ -131,8 +128,7 @@ rt_timer_callback(void) {
} }
} }
static resource_t * static resource_t *find_patch(ResourceManager *resmgr, const char *seq_name, int patchfile) {
find_patch(ResourceManager *resmgr, const char *seq_name, int patchfile) {
resource_t *res = NULL; resource_t *res = NULL;
if (patchfile != SFX_SEQ_PATCHFILE_NONE) { if (patchfile != SFX_SEQ_PATCHFILE_NONE) {
@ -148,13 +144,11 @@ find_patch(ResourceManager *resmgr, const char *seq_name, int patchfile) {
/* API implementation */ /* API implementation */
static int static int rt_set_option(char *name, char *value) {
rt_set_option(char *name, char *value) {
return SFX_ERROR; return SFX_ERROR;
} }
static int static int rt_init(ResourceManager *resmgr, int expected_latency) {
rt_init(ResourceManager *resmgr, int expected_latency) {
resource_t *res = NULL, *res2 = NULL; resource_t *res = NULL, *res2 = NULL;
void *seq_dev = NULL; void *seq_dev = NULL;
@ -194,8 +188,7 @@ rt_init(ResourceManager *resmgr, int expected_latency) {
return SFX_OK; return SFX_OK;
} }
static int static int rt_add_iterator(song_iterator_t *it, uint32 start_time) {
rt_add_iterator(song_iterator_t *it, uint32 start_time) {
if (seq->reset_timer) /* Restart timer counting if possible */ if (seq->reset_timer) /* Restart timer counting if possible */
seq->reset_timer(start_time); seq->reset_timer(start_time);
@ -210,14 +203,12 @@ rt_add_iterator(song_iterator_t *it, uint32 start_time) {
return SFX_OK; return SFX_OK;
} }
static int static int rt_fade_out(void) {
rt_fade_out(void) {
fprintf(stderr, __FILE__": Attempt to fade out- not implemented yet\n"); fprintf(stderr, __FILE__": Attempt to fade out- not implemented yet\n");
return SFX_ERROR; return SFX_ERROR;
} }
static int static int rt_stop(void) {
rt_stop(void) {
song_iterator_t *it = play_it; song_iterator_t *it = play_it;
play_it = NULL; play_it = NULL;
@ -230,8 +221,7 @@ rt_stop(void) {
return SFX_OK; return SFX_OK;
} }
static int static int rt_send_iterator_message(song_iterator_message_t msg) {
rt_send_iterator_message(song_iterator_message_t msg) {
if (!play_it) if (!play_it)
return SFX_ERROR; return SFX_ERROR;
@ -239,8 +229,7 @@ rt_send_iterator_message(song_iterator_message_t msg) {
return SFX_OK; return SFX_OK;
} }
static int static int rt_pause(void) {
rt_pause(void) {
play_pause_started = g_system->getMillis(); play_pause_started = g_system->getMillis();
/* Also, indicate that we haven't modified the time counter /* Also, indicate that we haven't modified the time counter
** yet */ ** yet */
@ -254,14 +243,12 @@ rt_pause(void) {
return seq->allstop(); return seq->allstop();
} }
static int static int rt_resume(void) {
rt_resume(void) {
play_paused = 0; play_paused = 0;
return SFX_OK; return SFX_OK;
} }
static int static int rt_exit(void) {
rt_exit(void) {
int retval = SFX_OK; int retval = SFX_OK;
if (seq->close()) { if (seq->close()) {

View file

@ -32,8 +32,7 @@ namespace Sci {
static midi_writer_t *writer = NULL; static midi_writer_t *writer = NULL;
static int static int midi_gm_open(int patch_len, byte *data, int patch2_len, byte *data2, void *device) {
midi_gm_open(int patch_len, byte *data, int patch2_len, byte *data2, void *device) {
sfx_instrument_map_t *instrument_map = sfx_instrument_map_load_sci(data, patch_len); sfx_instrument_map_t *instrument_map = sfx_instrument_map_load_sci(data, patch_len);
if (!instrument_map) { if (!instrument_map) {
@ -52,13 +51,11 @@ midi_gm_open(int patch_len, byte *data, int patch2_len, byte *data2, void *devic
return SFX_OK; return SFX_OK;
} }
static int static int midi_gm_close(void) {
midi_gm_close(void) {
return SFX_OK; return SFX_OK;
} }
static int static int midi_gm_event(byte command, int argc, byte *argv) {
midi_gm_event(byte command, int argc, byte *argv) {
byte data[4]; byte data[4];
assert(argc < 4); assert(argc < 4);
@ -70,15 +67,13 @@ midi_gm_event(byte command, int argc, byte *argv) {
return SFX_OK; return SFX_OK;
} }
static int static int midi_gm_delay(int ticks) {
midi_gm_delay(int ticks) {
writer->delay(writer, ticks); writer->delay(writer, ticks);
return SFX_OK; return SFX_OK;
} }
static int static int midi_gm_reset_timer(uint32 ts) {
midi_gm_reset_timer(uint32 ts) {
writer->reset_timer(writer); writer->reset_timer(writer);
return SFX_OK; return SFX_OK;
@ -86,8 +81,7 @@ midi_gm_reset_timer(uint32 ts) {
#define MIDI_MASTER_VOLUME_LEN 8 #define MIDI_MASTER_VOLUME_LEN 8
static int static int midi_gm_volume(uint8 volume) {
midi_gm_volume(uint8 volume) {
byte data[MIDI_MASTER_VOLUME_LEN] = { byte data[MIDI_MASTER_VOLUME_LEN] = {
0xf0, 0xf0,
0x7f, 0x7f,
@ -106,8 +100,7 @@ midi_gm_volume(uint8 volume) {
return SFX_OK; return SFX_OK;
} }
static int static int midi_gm_allstop(void) {
midi_gm_allstop(void) {
byte data[3] = { 0xb0, byte data[3] = { 0xb0,
0x78, /* all sound off */ 0x78, /* all sound off */
0 0
@ -125,8 +118,7 @@ midi_gm_allstop(void) {
return SFX_OK; return SFX_OK;
} }
static int static int midi_gm_reverb(int reverb) {
midi_gm_reverb(int reverb) {
byte data[3] = { 0xb0, byte data[3] = { 0xb0,
91, /* set reverb */ 91, /* set reverb */
reverb reverb
@ -145,8 +137,7 @@ midi_gm_reverb(int reverb) {
return SFX_OK; return SFX_OK;
} }
static int static int midi_gm_set_option(char *x, char *y) {
midi_gm_set_option(char *x, char *y) {
return SFX_ERROR; return SFX_ERROR;
} }

View file

@ -31,8 +31,7 @@
namespace Sci { namespace Sci {
sfx_instrument_map_t * sfx_instrument_map_t *sfx_instrument_map_new(int velocity_maps_nr) {
sfx_instrument_map_new(int velocity_maps_nr) {
sfx_instrument_map_t *map = (sfx_instrument_map_t *)sci_malloc(sizeof(sfx_instrument_map_t)); sfx_instrument_map_t *map = (sfx_instrument_map_t *)sci_malloc(sizeof(sfx_instrument_map_t));
int i; int i;
@ -67,8 +66,7 @@ sfx_instrument_map_new(int velocity_maps_nr) {
return map; return map;
} }
void void sfx_instrument_map_free(sfx_instrument_map_t *map) {
sfx_instrument_map_free(sfx_instrument_map_t *map) {
if (!map) if (!map)
return; return;
@ -103,8 +101,7 @@ sfx_instrument_map_free(sfx_instrument_map_t *map) {
#define PATCH_MIN_SIZE PATCH_INIT_DATA #define PATCH_MIN_SIZE PATCH_INIT_DATA
static int static int patch001_type0_length(byte *data, size_t length) {
patch001_type0_length(byte *data, size_t length) {
unsigned int pos = 492 + 246 * data[491]; unsigned int pos = 492 + 246 * data[491];
/* printf("timbres %d (post = %04x)\n",data[491], pos);*/ /* printf("timbres %d (post = %04x)\n",data[491], pos);*/
@ -125,15 +122,13 @@ patch001_type0_length(byte *data, size_t length) {
return 0; return 0;
} }
static int static int patch001_type1_length(byte *data, size_t length) {
patch001_type1_length(byte *data, size_t length) {
if ((length >= 1155) && (((data[1154] << 8) + data[1153] + 1155) == (int)length)) if ((length >= 1155) && (((data[1154] << 8) + data[1153] + 1155) == (int)length))
return 1; return 1;
return 0; return 0;
} }
int int sfx_instrument_map_detect(byte *data, size_t length) {
sfx_instrument_map_detect(byte *data, size_t length) {
/* length test */ /* length test */
if (length < 1155) if (length < 1155)
return SFX_MAP_MT32; return SFX_MAP_MT32;
@ -149,8 +144,7 @@ sfx_instrument_map_detect(byte *data, size_t length) {
} }
sfx_instrument_map_t * sfx_instrument_map_t *sfx_instrument_map_load_sci(byte *data, size_t size) {
sfx_instrument_map_load_sci(byte *data, size_t size) {
sfx_instrument_map_t * map; sfx_instrument_map_t * map;
int i, m; int i, m;
@ -220,40 +214,34 @@ struct decorated_midi_writer_t : public midi_writer_t {
}; };
static void static void init_decorated(struct _midi_writer *self_) {
init_decorated(struct _midi_writer *self_) {
decorated_midi_writer_t *self = (decorated_midi_writer_t *) self_; decorated_midi_writer_t *self = (decorated_midi_writer_t *) self_;
self->writer->init(self->writer); self->writer->init(self->writer);
} }
static void static void set_option_decorated(struct _midi_writer *self_, char *name, char *value) {
set_option_decorated(struct _midi_writer *self_, char *name, char *value) {
decorated_midi_writer_t *self = (decorated_midi_writer_t *) self_; decorated_midi_writer_t *self = (decorated_midi_writer_t *) self_;
self->writer->set_option(self->writer, name, value); self->writer->set_option(self->writer, name, value);
} }
static void static void delay_decorated(struct _midi_writer *self_, int ticks) {
delay_decorated(struct _midi_writer *self_, int ticks) {
decorated_midi_writer_t *self = (decorated_midi_writer_t *) self_; decorated_midi_writer_t *self = (decorated_midi_writer_t *) self_;
self->writer->delay(self->writer, ticks); self->writer->delay(self->writer, ticks);
} }
static void static void flush_decorated(struct _midi_writer *self_) {
flush_decorated(struct _midi_writer *self_) {
decorated_midi_writer_t *self = (decorated_midi_writer_t *) self_; decorated_midi_writer_t *self = (decorated_midi_writer_t *) self_;
if (self->writer->flush) if (self->writer->flush)
self->writer->flush(self->writer); self->writer->flush(self->writer);
} }
static void static void reset_timer_decorated(struct _midi_writer *self_) {
reset_timer_decorated(struct _midi_writer *self_) {
decorated_midi_writer_t *self = (decorated_midi_writer_t *) self_; decorated_midi_writer_t *self = (decorated_midi_writer_t *) self_;
self->writer->reset_timer(self->writer); self->writer->reset_timer(self->writer);
} }
static void static void close_decorated(decorated_midi_writer_t *self) {
close_decorated(decorated_midi_writer_t *self) {
sfx_instrument_map_free(self->map); sfx_instrument_map_free(self->map);
self->map = NULL; self->map = NULL;
self->writer->close(self->writer); self->writer->close(self->writer);
@ -264,16 +252,14 @@ close_decorated(decorated_midi_writer_t *self) {
#define BOUND_127(x) (((x) < 0)? 0 : (((x) > 0x7f)? 0x7f : (x))) #define BOUND_127(x) (((x) < 0)? 0 : (((x) > 0x7f)? 0x7f : (x)))
static int static int bound_hard_127(int i, const char *descr) {
bound_hard_127(int i, const char *descr) {
int r = BOUND_127(i); int r = BOUND_127(i);
if (r != i) if (r != i)
fprintf(stderr, "[instrument-map] Hard-clipping %02x to %02x in %s\n", i, r, descr); fprintf(stderr, "[instrument-map] Hard-clipping %02x to %02x in %s\n", i, r, descr);
return r; return r;
} }
static int static int set_bend_range(midi_writer_t *writer, int channel, int range) {
set_bend_range(midi_writer_t *writer, int channel, int range) {
byte buf[3] = {0xb0, 0x65, 0x00}; byte buf[3] = {0xb0, 0x65, 0x00};
buf[0] |= channel & 0xf; buf[0] |= channel & 0xf;
@ -297,8 +283,7 @@ set_bend_range(midi_writer_t *writer, int channel, int range) {
return SFX_OK; return SFX_OK;
} }
static int static int write_decorated(decorated_midi_writer_t *self, byte *buf, int len) {
write_decorated(decorated_midi_writer_t *self, byte *buf, int len) {
sfx_instrument_map_t *map = self->map; sfx_instrument_map_t *map = self->map;
int op = *buf & 0xf0; int op = *buf & 0xf0;
int chan = *buf & 0x0f; int chan = *buf & 0x0f;
@ -423,8 +408,7 @@ write_decorated(decorated_midi_writer_t *self, byte *buf, int len) {
#define MIDI_BYTES_PER_SECOND 3250 /* This seems to be the minimum guarantee by the standard */ #define MIDI_BYTES_PER_SECOND 3250 /* This seems to be the minimum guarantee by the standard */
#define MAX_PER_TICK (MIDI_BYTES_PER_SECOND / 60) /* After this, we ought to issue one tick of pause */ #define MAX_PER_TICK (MIDI_BYTES_PER_SECOND / 60) /* After this, we ought to issue one tick of pause */
static void static void init(midi_writer_t *writer, byte *data, size_t len) {
init(midi_writer_t *writer, byte *data, size_t len) {
size_t offset = 0; size_t offset = 0;
byte status = 0; byte status = 0;
@ -489,8 +473,7 @@ init(midi_writer_t *writer, byte *data, size_t len) {
#define NAME_SUFFIX "+instruments" #define NAME_SUFFIX "+instruments"
midi_writer_t * midi_writer_t *sfx_mapped_writer(midi_writer_t *writer, sfx_instrument_map_t *map) {
sfx_mapped_writer(midi_writer_t *writer, sfx_instrument_map_t *map) {
int i; int i;
decorated_midi_writer_t *retval; decorated_midi_writer_t *retval;

View file

@ -75,21 +75,18 @@ struct sfx_instrument_map_t {
byte *initialisation_block; /* Initial MIDI commands to set up the device */ byte *initialisation_block; /* Initial MIDI commands to set up the device */
}; };
sfx_instrument_map_t * sfx_instrument_map_t *sfx_instrument_map_new(int velocity_maps_nr);
sfx_instrument_map_new(int velocity_maps_nr);
/* Constructs a new default-initialised velocity map /* Constructs a new default-initialised velocity map
** Parameters: (int) velocity_maps_nr: Number of velocity maps to allocate ** Parameters: (int) velocity_maps_nr: Number of velocity maps to allocate
** Returns : (sfx_instrument_map *) an initialised instrument map ** Returns : (sfx_instrument_map *) an initialised instrument map
*/ */
void void sfx_instrument_map_free(sfx_instrument_map_t *map);
sfx_instrument_map_free(sfx_instrument_map_t *map);
/* Deallocates an instrument map /* Deallocates an instrument map
** Parameters: (sfx_instrument_map *) map: The map to deallocate, or NULL for a no-op ** Parameters: (sfx_instrument_map *) map: The map to deallocate, or NULL for a no-op
*/ */
sfx_instrument_map_t * sfx_instrument_map_t *sfx_instrument_map_load_sci(byte *data, size_t length);
sfx_instrument_map_load_sci(byte *data, size_t length);
/* Allocate and initialise an instrument map from SCI data /* Allocate and initialise an instrument map from SCI data
** Parameters: (byte *) Pointer to the data to initialise from ** Parameters: (byte *) Pointer to the data to initialise from
** (size_t) Number of bytes to expect within ** (size_t) Number of bytes to expect within
@ -98,8 +95,7 @@ sfx_instrument_map_load_sci(byte *data, size_t length);
** If `data' is null, the function will return NULL quietly. ** If `data' is null, the function will return NULL quietly.
*/ */
sfx_instrument_map_t * sfx_instrument_map_t *sfx_instrument_map_mt32_to_gm(byte *data, size_t size);
sfx_instrument_map_mt32_to_gm(byte *data, size_t size);
/* Allocate and initialise an instrument map from MT-32 patch data /* Allocate and initialise an instrument map from MT-32 patch data
** Parameters: (byte *) Pointer to the MT-32 patch data to initialise from ** Parameters: (byte *) Pointer to the MT-32 patch data to initialise from
** (size_t) Number of bytes to expect within ** (size_t) Number of bytes to expect within
@ -107,8 +103,7 @@ sfx_instrument_map_mt32_to_gm(byte *data, size_t size);
** If `data' is null or invalid, the function will return a default MT-32 to GM map. ** If `data' is null or invalid, the function will return a default MT-32 to GM map.
*/ */
int int sfx_instrument_map_detect(byte *data, size_t size);
sfx_instrument_map_detect(byte *data, size_t size);
/* Detects the type of patch data /* Detects the type of patch data
** Parameters: (byte *) Pointer to the patch data ** Parameters: (byte *) Pointer to the patch data
** (size_t) Number of bytes to expect within ** (size_t) Number of bytes to expect within
@ -116,8 +111,7 @@ sfx_instrument_map_detect(byte *data, size_t size);
** or SFX_MAP_UNKNOWN for unknown. ** or SFX_MAP_UNKNOWN for unknown.
*/ */
midi_writer_t * midi_writer_t *sfx_mapped_writer(midi_writer_t *writer, sfx_instrument_map_t *map);
sfx_mapped_writer(midi_writer_t *writer, sfx_instrument_map_t *map);
/* Wrap a midi_writer_t into an instrument map /* Wrap a midi_writer_t into an instrument map
** Parameters: (midi_writer_t *) writer: The writer to wrap ** Parameters: (midi_writer_t *) writer: The writer to wrap
** (sfx_instrument_map_t *) map: The map to apply to all commands going into the writer, or NULL ** (sfx_instrument_map_t *) map: The map to apply to all commands going into the writer, or NULL

View file

@ -32,8 +32,7 @@ namespace Sci {
#define DEBUG_MT32_TO_GM #define DEBUG_MT32_TO_GM
static const char static const char *GM_Instrument_Names[] = {
*GM_Instrument_Names[] = {
/*000*/ "Acoustic Grand Piano", /*000*/ "Acoustic Grand Piano",
/*001*/ "Bright Acoustic Piano", /*001*/ "Bright Acoustic Piano",
/*002*/ "Electric Grand Piano", /*002*/ "Electric Grand Piano",
@ -165,8 +164,7 @@ static const char
}; };
/* The GM Percussion map is downwards compatible to the MT32 map, which is used in SCI */ /* The GM Percussion map is downwards compatible to the MT32 map, which is used in SCI */
static const char static const char *GM_Percussion_Names[] = {
*GM_Percussion_Names[] = {
/*00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*00*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/*10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/*20*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*20*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -398,8 +396,7 @@ static struct {
/*29*/ {"OpenHiHat2", SFX_MAPPED_TO_RHYTHM, 43} /*29*/ {"OpenHiHat2", SFX_MAPPED_TO_RHYTHM, 43}
}; };
static int8 static int8 MT32_PresetRhythmKeymap[] = {
MT32_PresetRhythmKeymap[] = {
SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED,
SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED,
SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED, SFX_UNMAPPED,
@ -560,8 +557,7 @@ static struct {
{0, 0, 0} {0, 0, 0}
}; };
static int8 static int8 lookup_instrument(const char *iname) {
lookup_instrument(const char *iname) {
int i = 0; int i = 0;
while (MT32_MemoryTimbreMaps[i].name) { while (MT32_MemoryTimbreMaps[i].name) {
@ -572,8 +568,7 @@ lookup_instrument(const char *iname) {
return SFX_UNMAPPED; return SFX_UNMAPPED;
} }
static int8 static int8 lookup_rhythm_key(const char *iname) {
lookup_rhythm_key(const char *iname) {
int i = 0; int i = 0;
while (MT32_MemoryTimbreMaps[i].name) { while (MT32_MemoryTimbreMaps[i].name) {
@ -584,8 +579,7 @@ lookup_rhythm_key(const char *iname) {
return SFX_UNMAPPED; return SFX_UNMAPPED;
} }
static void static void print_map(int sci, int ins, int rhythm, int mt32) {
print_map(int sci, int ins, int rhythm, int mt32) {
#ifdef DEBUG_MT32_TO_GM #ifdef DEBUG_MT32_TO_GM
if (ins == SFX_UNMAPPED || (ins == SFX_MAPPED_TO_RHYTHM && rhythm == SFX_UNMAPPED)) { if (ins == SFX_UNMAPPED || (ins == SFX_MAPPED_TO_RHYTHM && rhythm == SFX_UNMAPPED)) {
sciprintf("[MT32-to-GM] No mapping available for [%i] `%s' (%i)\n", sciprintf("[MT32-to-GM] No mapping available for [%i] `%s' (%i)\n",
@ -606,8 +600,7 @@ print_map(int sci, int ins, int rhythm, int mt32) {
#endif #endif
} }
static void static void print_map_mem(int sci, int ins, int rhythm, char *mt32) {
print_map_mem(int sci, int ins, int rhythm, char *mt32) {
#ifdef DEBUG_MT32_TO_GM #ifdef DEBUG_MT32_TO_GM
char name[11]; char name[11];
@ -631,8 +624,7 @@ print_map_mem(int sci, int ins, int rhythm, char *mt32) {
#endif #endif
} }
static void static void print_map_rhythm(int sci, int ins, int rhythm, int mt32) {
print_map_rhythm(int sci, int ins, int rhythm, int mt32) {
#ifdef DEBUG_MT32_TO_GM #ifdef DEBUG_MT32_TO_GM
if (ins == SFX_UNMAPPED || (ins == SFX_MAPPED_TO_RHYTHM && rhythm == SFX_UNMAPPED)) { if (ins == SFX_UNMAPPED || (ins == SFX_MAPPED_TO_RHYTHM && rhythm == SFX_UNMAPPED)) {
sciprintf("[MT32-to-GM] No mapping available for [%i] `%s' [R] (%i)\n", sciprintf("[MT32-to-GM] No mapping available for [%i] `%s' [R] (%i)\n",
@ -653,8 +645,7 @@ print_map_rhythm(int sci, int ins, int rhythm, int mt32) {
#endif #endif
} }
static void static void print_map_rhythm_mem(int sci, int rhythm, char *mt32) {
print_map_rhythm_mem(int sci, int rhythm, char *mt32) {
#ifdef DEBUG_MT32_TO_GM #ifdef DEBUG_MT32_TO_GM
char name[11]; char name[11];
@ -672,8 +663,7 @@ print_map_rhythm_mem(int sci, int rhythm, char *mt32) {
#endif #endif
} }
sfx_instrument_map_t * sfx_instrument_map_t *sfx_instrument_map_mt32_to_gm(byte *data, size_t size) {
sfx_instrument_map_mt32_to_gm(byte *data, size_t size) {
int memtimbres, patches; int memtimbres, patches;
uint8 group, number, keyshift, finetune, bender_range; uint8 group, number, keyshift, finetune, bender_range;
uint8 *patchpointer; uint8 *patchpointer;

View file

@ -143,8 +143,7 @@ int adlib_kill_one_note(int chn) {
return oldest; return oldest;
} }
static void static void adlib_start_note(int chn, int note, int velocity) {
adlib_start_note(int chn, int note, int velocity) {
int free; int free;
struct timeval now; struct timeval now;
@ -174,8 +173,7 @@ adlib_start_note(int chn, int note, int velocity) {
SEQ_DUMPBUF(); SEQ_DUMPBUF();
} }
static int static int midi_adlib_open(int data_length, byte *data_ptr, int data2_length,
midi_adlib_open(int data_length, byte *data_ptr, int data2_length,
byte *data2_ptr, void *seq) { byte *data2_ptr, void *seq) {
int nrdevs, i, n; int nrdevs, i, n;
struct synth_info info; struct synth_info info;
@ -237,15 +235,13 @@ midi_adlib_open(int data_length, byte *data_ptr, int data2_length,
} }
static int static int midi_adlib_close(void) {
midi_adlib_close(void) {
SEQ_DUMPBUF(); SEQ_DUMPBUF();
return close(seqfd); return close(seqfd);
} }
static int static int midi_adlib_allstop(void) {
midi_adlib_allstop(void) {
int i; int i;
for (i = 0; i < ADLIB_VOICES ; i++) { for (i = 0; i < ADLIB_VOICES ; i++) {
if (oper_chn[i] == 255) if (oper_chn[i] == 255)
@ -257,14 +253,12 @@ midi_adlib_allstop(void) {
return 0; return 0;
} }
static int static int midi_adlib_reverb(int param) {
midi_adlib_reverb(int param) {
printf("reverb NYI %04x \n", param); printf("reverb NYI %04x \n", param);
return 0; return 0;
} }
static inline int static inline int midi_adlib_event1(uint8 command, uint8 note, uint8 velocity) {
midi_adlib_event1(uint8 command, uint8 note, uint8 velocity) {
uint8 channel, oper; uint8 channel, oper;
channel = command & 0x0f; channel = command & 0x0f;
@ -297,8 +291,7 @@ midi_adlib_event1(uint8 command, uint8 note, uint8 velocity) {
return 0; return 0;
} }
static inline int static inline int midi_adlib_event2(uint8 command, uint8 param) {
midi_adlib_event2(uint8 command, uint8 param) {
uint8 channel; uint8 channel;
uint8 oper; uint8 oper;
@ -320,22 +313,19 @@ midi_adlib_event2(uint8 command, uint8 param) {
return 0; return 0;
} }
static int static int midi_adlib_event(byte command, int argc, byte *argv) {
midi_adlib_event(byte command, int argc, byte *argv) {
if (argc > 1) if (argc > 1)
return midi_adlib_event1(command, argv[0], argv[1]); return midi_adlib_event1(command, argv[0], argv[1]);
else else
return midi_adlib_event2(command, argv[0]); return midi_adlib_event2(command, argv[0]);
} }
static int static int midi_adlib_delay(int ticks) {
midi_adlib_delay(int ticks) {
SEQ_DELTA_TIME(ticks); SEQ_DELTA_TIME(ticks);
return SFX_OK; return SFX_OK;
} }
static int static int midi_adlib_set_option(char *name, char *value) {
midi_adlib_set_option(char *name, char *value) {
return SFX_ERROR; /* No options are supported at this time */ return SFX_ERROR; /* No options are supported at this time */
} }

View file

@ -50,18 +50,15 @@ static int rpn[16];
/* MIDI writer */ /* MIDI writer */
static int static int fluidsynth_midi_init(struct _midi_writer *self) {
fluidsynth_midi_init(struct _midi_writer *self) {
return SFX_OK; return SFX_OK;
} }
static int static int fluidsynth_midi_set_option(struct _midi_writer *self, char *name, char *value) {
fluidsynth_midi_set_option(struct _midi_writer *self, char *name, char *value) {
return SFX_ERROR; return SFX_ERROR;
} }
static int static int fluidsynth_midi_write(struct _midi_writer *self, unsigned char *buf, int len) {
fluidsynth_midi_write(struct _midi_writer *self, unsigned char *buf, int len) {
if (buf[0] == 0xf0) if (buf[0] == 0xf0)
sciprintf("FluidSynth: Skipping sysex message.\n"); sciprintf("FluidSynth: Skipping sysex message.\n");
else if (len == 2) { else if (len == 2) {
@ -124,16 +121,13 @@ fluidsynth_midi_write(struct _midi_writer *self, unsigned char *buf, int len) {
return SFX_OK; return SFX_OK;
} }
static void static void fluidsynth_midi_delay(struct _midi_writer *self, int ticks) {
fluidsynth_midi_delay(struct _midi_writer *self, int ticks) {
} }
static void static void fluidsynth_midi_reset_timer(struct _midi_writer *self) {
fluidsynth_midi_reset_timer(struct _midi_writer *self) {
} }
static void static void fluidsynth_midi_close(struct _midi_writer *self) {
fluidsynth_midi_close(struct _midi_writer *self) {
} }
static midi_writer_t midi_writer_fluidsynth = { static midi_writer_t midi_writer_fluidsynth = {
@ -149,13 +143,11 @@ static midi_writer_t midi_writer_fluidsynth = {
/* Software sequencer */ /* Software sequencer */
static void static void fluidsynth_poll(sfx_softseq_t *self, byte *dest, int count) {
fluidsynth_poll(sfx_softseq_t *self, byte *dest, int count) {
fluid_synth_write_s16(synth, count, dest, 0, 2, dest + 2, 0, 2); fluid_synth_write_s16(synth, count, dest, 0, 2, dest + 2, 0, 2);
} }
static int static int fluidsynth_init(sfx_softseq_t *self, byte *data_ptr, int data_length,
fluidsynth_init(sfx_softseq_t *self, byte *data_ptr, int data_length,
byte *data2_ptr, int data2_length) { byte *data2_ptr, int data2_length) {
int sfont_id; int sfont_id;
double min, max; double min, max;
@ -198,31 +190,26 @@ fluidsynth_init(sfx_softseq_t *self, byte *data_ptr, int data_length,
return SFX_OK; return SFX_OK;
} }
static void static void fluidsynth_exit(sfx_softseq_t *self) {
fluidsynth_exit(sfx_softseq_t *self) {
delete_fluid_synth(synth); delete_fluid_synth(synth);
delete_fluid_settings(settings); delete_fluid_settings(settings);
} }
static void static void fluidsynth_allstop(sfx_softseq_t *self) {
fluidsynth_allstop(sfx_softseq_t *self) {
if (gmseq->allstop) if (gmseq->allstop)
gmseq->allstop(); gmseq->allstop();
} }
static void static void fluidsynth_volume(sfx_softseq_t *self, int volume) {
fluidsynth_volume(sfx_softseq_t *self, int volume) {
if (gmseq->volume) if (gmseq->volume)
gmseq->volume(volume); gmseq->volume(volume);
} }
static int static int fluidsynth_set_option(sfx_softseq_t *self, const char *name, const char *value) {
fluidsynth_set_option(sfx_softseq_t *self, const char *name, const char *value) {
return SFX_ERROR; return SFX_ERROR;
} }
static void static void fluidsynth_event(sfx_softseq_t *self, byte cmd, int argc, byte *argv) {
fluidsynth_event(sfx_softseq_t *self, byte cmd, int argc, byte *argv) {
gmseq->event(cmd, argc, argv); gmseq->event(cmd, argc, argv);
} }

View file

@ -170,8 +170,7 @@ static inline int opl_write(int a, int v) {
} }
/* /*
static inline uint8 opl_read (int a) static inline uint8 opl_read (int a) {
{
OPLWrite (ym3812_L, 0x388, a); OPLWrite (ym3812_L, 0x388, a);
return OPLRead (ym3812_L, 0x389); return OPLRead (ym3812_L, 0x389);
} }

View file

@ -37,8 +37,7 @@ using namespace Sci;
int errors = 0; int errors = 0;
void void error(char *fmt, ...) {
error(char *fmt, ...) {
va_list ap; va_list ap;
fprintf(stderr, "[ERROR] "); fprintf(stderr, "[ERROR] ");
@ -61,8 +60,7 @@ struct simple_it_struct {
int cues_nr; int cues_nr;
} simple_iterator; } simple_iterator;
int int simple_it_next(song_iterator_t *_self, unsigned char *buf, int *result) {
simple_it_next(song_iterator_t *_self, unsigned char *buf, int *result) {
struct simple_it_struct *self = (struct simple_it_struct *) _self; struct simple_it_struct *self = (struct simple_it_struct *) _self;
if (self->lifetime_remaining == -1) { if (self->lifetime_remaining == -1) {
@ -106,23 +104,19 @@ simple_it_next(song_iterator_t *_self, unsigned char *buf, int *result) {
} }
} }
sfx_pcm_feed_t * sfx_pcm_feed_t *simple_it_pcm_feed(song_iterator_t *_self) {
simple_it_pcm_feed(song_iterator_t *_self) {
error("No PCM feed!\n"); error("No PCM feed!\n");
return NULL; return NULL;
} }
void void simple_it_init(song_iterator_t *_self) {
simple_it_init(song_iterator_t *_self) {
} }
song_iterator_t * song_iterator_t *simple_it_handle_message(song_iterator_t *_self, song_iterator_message_t msg) {
simple_it_handle_message(song_iterator_t *_self, song_iterator_message_t msg) {
return NULL; return NULL;
} }
void void simple_it_cleanup(song_iterator_t *_self) {
simple_it_cleanup(song_iterator_t *_self) {
} }
/* Initialises the simple iterator. /* Initialises the simple iterator.
@ -131,8 +125,7 @@ simple_it_cleanup(song_iterator_t *_self) {
** (int) cues_nr: Number of cues in ``cues'' ** (int) cues_nr: Number of cues in ``cues''
** The first cue is emitted after cues[0] ticks, and it is 1. After cues[1] additional ticks ** The first cue is emitted after cues[0] ticks, and it is 1. After cues[1] additional ticks
** the next cue is emitted, and so on. */ ** the next cue is emitted, and so on. */
song_iterator_t * song_iterator_t *setup_simple_iterator(int delay, char *cues, int cues_nr) {
setup_simple_iterator(int delay, char *cues, int cues_nr) {
simple_iterator.lifetime_remaining = delay; simple_iterator.lifetime_remaining = delay;
simple_iterator.cues = cues; simple_iterator.cues = cues;
simple_iterator.cue_counter = 0; simple_iterator.cue_counter = 0;
@ -161,8 +154,7 @@ setup_simple_iterator(int delay, char *cues, int cues_nr) {
#define ASSERT_RESULT(n) ASSERT(result == n) #define ASSERT_RESULT(n) ASSERT(result == n)
#define ASSERT_CUE(n) ASSERT_NEXT(SI_ABSOLUTE_CUE); ASSERT_RESULT(n) #define ASSERT_CUE(n) ASSERT_NEXT(SI_ABSOLUTE_CUE); ASSERT_RESULT(n)
void void test_simple_it() {
test_simple_it() {
song_iterator_t *it; song_iterator_t *it;
song_iterator_t *simple_it = (song_iterator_t *) & simple_iterator; song_iterator_t *simple_it = (song_iterator_t *) & simple_iterator;
unsigned char data[4]; unsigned char data[4];
@ -193,8 +185,7 @@ test_simple_it() {
puts("[TEST] Test OK."); puts("[TEST] Test OK.");
} }
void void test_fastforward() {
test_fastforward() {
song_iterator_t *it; song_iterator_t *it;
song_iterator_t *simple_it = (song_iterator_t *) & simple_iterator; song_iterator_t *simple_it = (song_iterator_t *) & simple_iterator;
song_iterator_t *ff_it; song_iterator_t *ff_it;
@ -297,8 +288,7 @@ static unsigned char simple_song[SIMPLE_SONG_SIZE] = {
ASSERT(data[1] == arg0); \ ASSERT(data[1] == arg0); \
ASSERT(data[2] == arg1); ASSERT(data[2] == arg1);
void void test_iterator_sci0() {
test_iterator_sci0() {
song_iterator_t *it = songit_new(simple_song, SIMPLE_SONG_SIZE, SCI_SONG_ITERATOR_TYPE_SCI0, 0l); song_iterator_t *it = songit_new(simple_song, SIMPLE_SONG_SIZE, SCI_SONG_ITERATOR_TYPE_SCI0, 0l);
unsigned char data[4]; unsigned char data[4];
int result; int result;
@ -322,8 +312,7 @@ test_iterator_sci0() {
void void test_iterator_sci0_loop() {
test_iterator_sci0_loop() {
song_iterator_t *it = songit_new(simple_song, SIMPLE_SONG_SIZE, SCI_SONG_ITERATOR_TYPE_SCI0, 0l); song_iterator_t *it = songit_new(simple_song, SIMPLE_SONG_SIZE, SCI_SONG_ITERATOR_TYPE_SCI0, 0l);
unsigned char data[4]; unsigned char data[4];
int result; int result;
@ -379,8 +368,7 @@ unsigned char loop_song[LOOP_SONG_SIZE] = {
}; };
void void test_iterator_sci0_mark_loop() {
test_iterator_sci0_mark_loop() {
song_iterator_t *it = songit_new(loop_song, LOOP_SONG_SIZE, SCI_SONG_ITERATOR_TYPE_SCI0, 0l); song_iterator_t *it = songit_new(loop_song, LOOP_SONG_SIZE, SCI_SONG_ITERATOR_TYPE_SCI0, 0l);
unsigned char data[4]; unsigned char data[4];
int result; int result;
@ -424,8 +412,7 @@ test_iterator_sci0_mark_loop() {
int int main(int argc, char **argv) {
main(int argc, char **argv) {
test_simple_it(); test_simple_it();
test_fastforward(); test_fastforward();
test_iterator_sci0(); test_iterator_sci0();

View file

@ -31,8 +31,7 @@ using namespace Sci;
sfx_timestamp_t a, b, c; sfx_timestamp_t a, b, c;
int int main(int argc, char **argv) {
main(int argc, char **argv) {
int i; int i;
a = sfx_new_timestamp(10, 0, 1000); a = sfx_new_timestamp(10, 0, 1000);
b = sfx_new_timestamp(10, 1000, 1000); b = sfx_new_timestamp(10, 1000, 1000);