aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/sfx/seq
diff options
context:
space:
mode:
authorMax Horn2009-02-15 22:34:41 +0000
committerMax Horn2009-02-15 22:34:41 +0000
commit29611bc7ead4d3d5fc9df63c04dd9e2577805557 (patch)
tree42d26aab7ab2e7e97fe5b4763281d8071d878eed /engines/sci/sfx/seq
parent921e6ff5cf3944c1a62a3ad9a91c29bb21aa9942 (diff)
downloadscummvm-rg350-29611bc7ead4d3d5fc9df63c04dd9e2577805557.tar.gz
scummvm-rg350-29611bc7ead4d3d5fc9df63c04dd9e2577805557.tar.bz2
scummvm-rg350-29611bc7ead4d3d5fc9df63c04dd9e2577805557.zip
SCI: Run astyle to make the code be more compliant with our Code Formatting Guidelines: sfx dir
svn-id: r38322
Diffstat (limited to 'engines/sci/sfx/seq')
-rw-r--r--engines/sci/sfx/seq/gm.cpp42
-rw-r--r--engines/sci/sfx/seq/instrument-map.cpp102
-rw-r--r--engines/sci/sfx/seq/map-mt32-to-gm.cpp55
-rw-r--r--engines/sci/sfx/seq/mt32.cpp104
-rw-r--r--engines/sci/sfx/seq/oss-adlib.cpp104
-rw-r--r--engines/sci/sfx/seq/sequencers.cpp7
6 files changed, 179 insertions, 235 deletions
diff --git a/engines/sci/sfx/seq/gm.cpp b/engines/sci/sfx/seq/gm.cpp
index 4889e76ea8..ecd459236d 100644
--- a/engines/sci/sfx/seq/gm.cpp
+++ b/engines/sci/sfx/seq/gm.cpp
@@ -40,8 +40,7 @@
static midi_writer_t *writer = NULL;
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);
if (!instrument_map) {
@@ -61,17 +60,15 @@ midi_gm_open(int patch_len, byte *data, int patch2_len, byte *data2, void *devic
}
static int
-midi_gm_close(void)
-{
+midi_gm_close(void) {
return SFX_OK;
}
static int
-midi_gm_event(byte command, int argc, byte *argv)
-{
+midi_gm_event(byte command, int argc, byte *argv) {
byte data[4];
- assert (argc < 4);
+ assert(argc < 4);
data[0] = command;
memcpy(data + 1, argv, argc);
@@ -81,16 +78,14 @@ midi_gm_event(byte command, int argc, byte *argv)
}
static int
-midi_gm_delay(int ticks)
-{
+midi_gm_delay(int ticks) {
writer->delay(writer, ticks);
return SFX_OK;
}
static int
-midi_gm_reset_timer(GTimeVal ts)
-{
+midi_gm_reset_timer(GTimeVal ts) {
writer->reset_timer(writer);
return SFX_OK;
@@ -99,8 +94,7 @@ midi_gm_reset_timer(GTimeVal ts)
#define MIDI_MASTER_VOLUME_LEN 8
static int
-midi_gm_volume(guint8 volume)
-{
+midi_gm_volume(guint8 volume) {
byte data[MIDI_MASTER_VOLUME_LEN] = {
0xf0,
0x7f,
@@ -109,7 +103,8 @@ midi_gm_volume(guint8 volume)
0x01,
volume,
volume,
- 0xf7};
+ 0xf7
+ };
writer->write(writer, data, MIDI_MASTER_VOLUME_LEN);
if (writer->flush)
@@ -119,11 +114,11 @@ midi_gm_volume(guint8 volume)
}
static int
-midi_gm_allstop(void)
-{
+midi_gm_allstop(void) {
byte data[3] = { 0xb0,
- 0x78, /* all sound off */
- 0 };
+ 0x78, /* all sound off */
+ 0
+ };
int i;
/* All sound off on all channels */
@@ -138,11 +133,11 @@ midi_gm_allstop(void)
}
static int
-midi_gm_reverb(int reverb)
-{
+midi_gm_reverb(int reverb) {
byte data[3] = { 0xb0,
- 91, /* set reverb */
- reverb };
+ 91, /* set reverb */
+ reverb
+ };
int i;
/* Set reverb on all channels */
@@ -158,8 +153,7 @@ midi_gm_reverb(int reverb)
}
static int
-midi_gm_set_option(char *x, char *y)
-{
+midi_gm_set_option(char *x, char *y) {
return SFX_ERROR;
}
diff --git a/engines/sci/sfx/seq/instrument-map.cpp b/engines/sci/sfx/seq/instrument-map.cpp
index 204ecfdc34..65bab7a32f 100644
--- a/engines/sci/sfx/seq/instrument-map.cpp
+++ b/engines/sci/sfx/seq/instrument-map.cpp
@@ -32,9 +32,8 @@
#include "sfx_engine.h"
sfx_instrument_map_t *
-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_new(int velocity_maps_nr) {
+ sfx_instrument_map_t *map = (sfx_instrument_map_t *)sci_malloc(sizeof(sfx_instrument_map_t));
int i;
map->initialisation_block_size = 0;
@@ -47,7 +46,7 @@ sfx_instrument_map_new(int velocity_maps_nr)
map->velocity_map = NULL; /* Yes, this complicates control flow needlessly, but it avoids some of the pointless
** warnings that certain memory tools seem to find appropriate. */
else {
- map->velocity_map = (byte **)sci_malloc(sizeof (byte *) * velocity_maps_nr);
+ map->velocity_map = (byte **)sci_malloc(sizeof(byte *) * velocity_maps_nr);
for (i = 0; i < velocity_maps_nr; ++i)
map->velocity_map[i] = (byte *)sci_malloc(SFX_VELOCITIES_NR);
}
@@ -56,7 +55,7 @@ sfx_instrument_map_new(int velocity_maps_nr)
map->percussion_volume_adjust = 0;
for (i = 0; i < SFX_RHYTHM_NR; ++i)
- map->percussion_map[i] = i;
+ map->percussion_map[i] = i;
for (i = 0; i < SFX_INSTRUMENTS_NR; ++i) {
@@ -69,8 +68,7 @@ sfx_instrument_map_new(int velocity_maps_nr)
}
void
-sfx_instrument_map_free(sfx_instrument_map_t *map)
-{
+sfx_instrument_map_free(sfx_instrument_map_t *map) {
if (!map)
return;
@@ -106,21 +104,20 @@ sfx_instrument_map_free(sfx_instrument_map_t *map)
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];
-/* printf("timbres %d (post = %04x)\n",data[491], pos);*/
+ /* printf("timbres %d (post = %04x)\n",data[491], pos);*/
if ((length >= (pos + 386)) && (data[pos] == 0xAB) && (data[pos + 1] == 0xCD))
pos += 386;
-/* printf("pos = %04x (%02x %02x)\n", pos, data[pos], data[pos + 1]); */
+ /* printf("pos = %04x (%02x %02x)\n", pos, data[pos], data[pos + 1]); */
if ((length >= (pos + 267)) && (data[pos] == 0xDC) && (data[pos + 1] == 0xBA))
pos += 267;
-/* printf("pos = %04x %04x (%d)\n", pos, length, pos-length); */
+ /* printf("pos = %04x %04x (%d)\n", pos, length, pos-length); */
if (pos == length)
@@ -129,34 +126,31 @@ patch001_type0_length(byte *data, size_t length)
}
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) == length))
return 1;
return 0;
}
int
-sfx_instrument_map_detect(byte *data, size_t length)
-{
+sfx_instrument_map_detect(byte *data, size_t length) {
/* length test */
if (length < 1155)
return SFX_MAP_MT32;
if (length > 16889)
return SFX_MAP_MT32_GM;
if (patch001_type0_length(data, length) &&
- !patch001_type1_length(data, length))
+ !patch001_type1_length(data, length))
return SFX_MAP_MT32;
if (patch001_type1_length(data, length) &&
- !patch001_type0_length(data, length))
+ !patch001_type0_length(data, length))
return SFX_MAP_MT32_GM;
return SFX_MAP_UNKNOWN;
}
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;
int i, m;
@@ -230,45 +224,39 @@ typedef struct decorated_midi_writer {
static void
-init_decorated(struct _midi_writer *self_)
-{
+init_decorated(struct _midi_writer *self_) {
decorated_midi_writer_t *self = (decorated_midi_writer_t *) self_;
self->writer->init(self->writer);
}
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_;
self->writer->set_option(self->writer, name, value);
}
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_;
self->writer->delay(self->writer, ticks);
}
static void
-flush_decorated(struct _midi_writer *self_)
-{
+flush_decorated(struct _midi_writer *self_) {
decorated_midi_writer_t *self = (decorated_midi_writer_t *) self_;
if (self->writer->flush)
self->writer->flush(self->writer);
}
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_;
self->writer->reset_timer(self->writer);
}
static void
-close_decorated(decorated_midi_writer_t *self)
-{
+close_decorated(decorated_midi_writer_t *self) {
sfx_instrument_map_free(self->map);
self->map = NULL;
self->writer->close(self->writer);
@@ -280,8 +268,7 @@ close_decorated(decorated_midi_writer_t *self)
#define BOUND_127(x) (((x) < 0)? 0 : (((x) > 0x7f)? 0x7f : (x)))
static int
-bound_hard_127(int i, const char *descr)
-{
+bound_hard_127(int i, const char *descr) {
int r = BOUND_127(i);
if (r != i)
fprintf(stderr, "[instrument-map] Hard-clipping %02x to %02x in %s\n", i, r, descr);
@@ -289,8 +276,7 @@ bound_hard_127(int i, const char *descr)
}
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};
buf[0] |= channel & 0xf;
@@ -315,18 +301,18 @@ set_bend_range(midi_writer_t *writer, int channel, int range)
}
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;
int op = *buf & 0xf0;
int chan = *buf & 0x0f;
int patch = self->patches[chan].patch;
int rhythm = self->patches[chan].rhythm;
- assert (len >= 1);
+ assert(len >= 1);
if (op == 0xC0 && chan != MIDI_RHYTHM_CHANNEL) { /* Program change */
- /*int*/ patch = bound_hard_127(buf[1], "program change");
+ /*int*/
+ patch = bound_hard_127(buf[1], "program change");
int instrument = map->patch_map[patch].patch;
int bend_range = map->patch_bend_range[patch];
@@ -335,7 +321,7 @@ write_decorated(decorated_midi_writer_t *self, byte *buf, int len)
if (instrument == SFX_UNMAPPED || instrument == SFX_MAPPED_TO_RHYTHM)
return SFX_OK;
- assert (len >= 2);
+ assert(len >= 2);
buf[1] = bound_hard_127(instrument, "patch lookup");
if (self->writer->write(self->writer, buf, len) != SFX_OK)
@@ -367,7 +353,7 @@ write_decorated(decorated_midi_writer_t *self, byte *buf, int len)
if (instrument == SFX_UNMAPPED)
return SFX_OK;
- assert (len >= 3);
+ assert(len >= 3);
velocity = bound_hard_127(buf[2], "rhythm velocity");
velocity_map_index = map->percussion_velocity_map_index;
@@ -384,13 +370,14 @@ write_decorated(decorated_midi_writer_t *self, byte *buf, int len)
}
case 0xB0: { /* Controller change */
- assert (len >= 3);
+ assert(len >= 3);
if (buf[1] == 0x7) /* Volume change */
buf[2] = BOUND_127(buf[2] + map->percussion_volume_adjust);
break;
}
- default: break;
+ default:
+ break;
}
} else {
@@ -405,7 +392,7 @@ write_decorated(decorated_midi_writer_t *self, byte *buf, int len)
int note = bound_hard_127(buf[1], "note");
int velocity = bound_hard_127(buf[2], "velocity");
int velocity_map_index = map->velocity_map_index[patch];
- assert (len >= 3);
+ assert(len >= 3);
note += map->patch_key_shift[patch];
/* Not the most efficient solutions, but the least error-prone */
@@ -423,12 +410,13 @@ write_decorated(decorated_midi_writer_t *self, byte *buf, int len)
}
case 0xB0: /* Controller change */
- assert (len >= 3);
+ assert(len >= 3);
if (buf[1] == 0x7) /* Volume change */
buf[2] = BOUND_127(buf[2] + map->patch_volume_adjust[patch]);
break;
- default: break;
+ default:
+ break;
}
}
@@ -439,8 +427,7 @@ write_decorated(decorated_midi_writer_t *self, byte *buf, int len)
#define MAX_PER_TICK (MIDI_BYTES_PER_SECOND / 60) /* After this, we ought to issue one tick of pause */
static void
-init(midi_writer_t *writer, byte *data, size_t len)
-{
+init(midi_writer_t *writer, byte *data, size_t len) {
int offset = 0;
byte status = 0;
@@ -479,13 +466,13 @@ init(midi_writer_t *writer, byte *data, size_t len)
msg[0] = op;
switch (op & 0xf0) {
- case 0xc0:
- case 0xd0:
- args = 1;
- break;
- default:
- args = 2;
- }
+ case 0xc0:
+ case 0xd0:
+ args = 1;
+ break;
+ default:
+ args = 2;
+ }
if (args > len - offset) {
fprintf(stderr, "[instrument-map] Insufficient bytes remaining for MIDI command %02x\n", op);
@@ -506,8 +493,7 @@ init(midi_writer_t *writer, byte *data, size_t len)
#define NAME_SUFFIX "+instruments"
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;
decorated_midi_writer_t *retval;
diff --git a/engines/sci/sfx/seq/map-mt32-to-gm.cpp b/engines/sci/sfx/seq/map-mt32-to-gm.cpp
index b4c56f2602..d51e2a3391 100644
--- a/engines/sci/sfx/seq/map-mt32-to-gm.cpp
+++ b/engines/sci/sfx/seq/map-mt32-to-gm.cpp
@@ -176,7 +176,7 @@ static const char
/*10*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/*20*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/*30*/ 0, 0, 0, 0,
-/* The preceeding percussions are not covered by the GM standard */
+ /* The preceeding percussions are not covered by the GM standard */
/*34*/ "Acoustic Bass Drum",
/*35*/ "Bass Drum 1",
/*36*/ "Side Stick",
@@ -566,8 +566,7 @@ static struct {
};
static gint8
-lookup_instrument(const char *iname)
-{
+lookup_instrument(const char *iname) {
int i = 0;
while (MT32_MemoryTimbreMaps[i].name) {
@@ -579,8 +578,7 @@ lookup_instrument(const char *iname)
}
static gint8
-lookup_rhythm_key(const char *iname)
-{
+lookup_rhythm_key(const char *iname) {
int i = 0;
while (MT32_MemoryTimbreMaps[i].name) {
@@ -592,31 +590,29 @@ lookup_rhythm_key(const char *iname)
}
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
if (ins == SFX_UNMAPPED || (ins == SFX_MAPPED_TO_RHYTHM && rhythm == SFX_UNMAPPED)) {
sciprintf("[MT32-to-GM] No mapping available for [%i] `%s' (%i)\n",
- sci, MT32_PresetTimbreMaps[mt32].name, mt32);
+ sci, MT32_PresetTimbreMaps[mt32].name, mt32);
return;
}
if (ins == SFX_MAPPED_TO_RHYTHM) {
sciprintf("[MT32-to-GM] Mapping [%i] `%s' (%i) to `%s' [R] (%i)\n",
- sci, MT32_PresetTimbreMaps[mt32].name, mt32,
- GM_Percussion_Names[rhythm], rhythm);
+ sci, MT32_PresetTimbreMaps[mt32].name, mt32,
+ GM_Percussion_Names[rhythm], rhythm);
return;
}
sciprintf("[MT32-to-GM] Mapping [%i] `%s' (%i) to `%s' (%i)\n",
- sci, MT32_PresetTimbreMaps[mt32].name, mt32,
- GM_Instrument_Names[ins], ins);
+ sci, MT32_PresetTimbreMaps[mt32].name, mt32,
+ GM_Instrument_Names[ins], ins);
#endif
}
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
char name[11];
@@ -625,47 +621,45 @@ print_map_mem(int sci, int ins, int rhythm, char *mt32)
if (ins == SFX_UNMAPPED || (ins == SFX_MAPPED_TO_RHYTHM && rhythm == SFX_UNMAPPED)) {
sciprintf("[MT32-to-GM] No mapping available for [%i] `%s'\n",
- sci, name);
+ sci, name);
return;
}
if (ins == SFX_MAPPED_TO_RHYTHM) {
sciprintf("[MT32-to-GM] Mapping [%i] `%s' to `%s' [R] (%i)\n",
- sci, name, GM_Percussion_Names[rhythm], rhythm);
+ sci, name, GM_Percussion_Names[rhythm], rhythm);
return;
}
sciprintf("[MT32-to-GM] Mapping [%i] `%s' to `%s' (%i)\n",
- sci, name, GM_Instrument_Names[ins], ins);
+ sci, name, GM_Instrument_Names[ins], ins);
#endif
}
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
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",
- sci, MT32_RhythmTimbreMaps[mt32].name, mt32);
+ sci, MT32_RhythmTimbreMaps[mt32].name, mt32);
return;
}
if (ins == SFX_MAPPED_TO_RHYTHM) {
sciprintf("[MT32-to-GM] Mapping [%i] `%s' [R] (%i) to `%s' [R] (%i)\n",
- sci, MT32_RhythmTimbreMaps[mt32].name, mt32,
- GM_Percussion_Names[rhythm], rhythm);
+ sci, MT32_RhythmTimbreMaps[mt32].name, mt32,
+ GM_Percussion_Names[rhythm], rhythm);
return;
}
sciprintf("[MT32-to-GM] Mapping [%i] `%s' [R] (%i) to `%s' (%i)\n",
- sci, MT32_RhythmTimbreMaps[mt32].name, mt32,
- GM_Instrument_Names[ins], ins);
+ sci, MT32_RhythmTimbreMaps[mt32].name, mt32,
+ GM_Instrument_Names[ins], ins);
#endif
}
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
char name[11];
@@ -674,18 +668,17 @@ print_map_rhythm_mem(int sci, int rhythm, char *mt32)
if (rhythm == SFX_UNMAPPED) {
sciprintf("[MT32-to-GM] No mapping available for [%i] `%s'\n",
- sci, name);
+ sci, name);
return;
}
sciprintf("[MT32-to-GM] Mapping [%i] `%s' to `%s' (%i)\n",
- sci, name, GM_Percussion_Names[rhythm], rhythm);
+ sci, name, GM_Percussion_Names[rhythm], rhythm);
#endif
}
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;
guint8 group, number, keyshift, finetune, bender_range;
guint8 *patchpointer;
@@ -731,7 +724,7 @@ sfx_instrument_map_mt32_to_gm(byte *data, size_t size)
memtimbres = *(data + 0x1EB);
pos = 0x1EC + memtimbres * 0xF6;
- if (size > pos && ((0x100 * *(data + pos) + *(data +pos + 1)) == 0xABCD)) {
+ if (size > pos && ((0x100 * *(data + pos) + *(data + pos + 1)) == 0xABCD)) {
patches = 96;
pos += 2 + 8 * 48;
} else
diff --git a/engines/sci/sfx/seq/mt32.cpp b/engines/sci/sfx/seq/mt32.cpp
index de478cf4f6..0633d8b66b 100644
--- a/engines/sci/sfx/seq/mt32.cpp
+++ b/engines/sci/sfx/seq/mt32.cpp
@@ -40,7 +40,7 @@ static midi_writer_t *midi_writer = NULL;
static int midi_mt32_poke(guint32 address, guint8 *data, unsigned int n);
static int midi_mt32_poke_gather(guint32 address, guint8 *data1, unsigned int count1,
- guint8 *data2, unsigned int count2);
+ guint8 *data2, unsigned int count2);
static int midi_mt32_write_block(guint8 *data, unsigned int count);
static int midi_mt32_sysex_delay(void);
static int midi_mt32_volume(guint8 volume);
@@ -59,26 +59,27 @@ static int mt32_init_delay = 0; /* Used to count the number of ticks (1/60s of a
/* timbre, volume, panpot, reverb. keys 24-87 (64 keys)*/
static guint8 default_rhythm_keymap[256] = { /* MT-32 default */
- 0x7f,0x64,7,1, 0x7f,0x64,7,1, 0x7f,0x64,7,1, 0x7f,0x64,7,1, /* 24-27 */
- 0x7f,0x64,7,1, 0x7f,0x64,7,1, 0x7f,0x64,7,1, 0x7f,0x64,7,1,
- 0x7f,0x64,7,1, 0x7f,0x64,7,1, 0x7f,0x64,7,1, 0x40,0x64,7,1,
- 0x40,0x64,7,1, 0x4a,0x64,6,1, 0x41,0x64,7,1, 0x4b,0x64,8,1,
- 0x45,0x64,6,1, 0x44,0x64,11,1, 0x46,0x64,6,1, 0x44,0x64,11,1,
- 0x5d,0x64,6,1, 0x43,0x64,8,1, 0x47,0x64,6,1, 0x43,0x64,8,1,
- 0x42,0x64,3,1, 0x48,0x64,6,1, 0x42,0x64,3,1, 0x49,0x64,8,1,
- 0x7f,0x64,7,1, 0x7f,0x64,7,1, 0x56,0x64,9,1, 0x7f,0x64,7,1,
- 0x4c,0x64,7,1, 0x7f,0x64,7,1, 0x7f,0x64,7,1, 0x7f,0x64,7,1,
- 0x52,0x64,2,1, 0x53,0x64,4,1, 0x4d,0x64,8,1, 0x4e,0x64,9,1,
- 0x4f,0x64,10,1, 0x50,0x64,7,1, 0x51,0x64,5,1, 0x54,0x64,2,1,
- 0x55,0x64,2,1, 0x5b,0x64,9,1, 0x58,0x64,4,1, 0x5a,0x64,9,1,
- 0x59,0x64,9,1, 0x5c,0x64,10,1, 0x7f,0x64,7,1, 0x57,0x64,12,1,
- 0x7f,0x64,7,1, 0x7f,0x64,7,1, 0x7f,0x64,7,1, 0x7f,0x64,7,1,
- 0x7f,0x64,7,1, 0x7f,0x64,7,1, 0x7f,0x64,7,1, 0x7f,0x64,7,1,
- 0x7f,0x64,7,1, 0x7f,0x64,7,1, 0x7f,0x64,7,1, 0x7f,0x64,7,1 /* 84-87 */
+ 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1, /* 24-27 */
+ 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1,
+ 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1, 0x40, 0x64, 7, 1,
+ 0x40, 0x64, 7, 1, 0x4a, 0x64, 6, 1, 0x41, 0x64, 7, 1, 0x4b, 0x64, 8, 1,
+ 0x45, 0x64, 6, 1, 0x44, 0x64, 11, 1, 0x46, 0x64, 6, 1, 0x44, 0x64, 11, 1,
+ 0x5d, 0x64, 6, 1, 0x43, 0x64, 8, 1, 0x47, 0x64, 6, 1, 0x43, 0x64, 8, 1,
+ 0x42, 0x64, 3, 1, 0x48, 0x64, 6, 1, 0x42, 0x64, 3, 1, 0x49, 0x64, 8, 1,
+ 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1, 0x56, 0x64, 9, 1, 0x7f, 0x64, 7, 1,
+ 0x4c, 0x64, 7, 1, 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1,
+ 0x52, 0x64, 2, 1, 0x53, 0x64, 4, 1, 0x4d, 0x64, 8, 1, 0x4e, 0x64, 9, 1,
+ 0x4f, 0x64, 10, 1, 0x50, 0x64, 7, 1, 0x51, 0x64, 5, 1, 0x54, 0x64, 2, 1,
+ 0x55, 0x64, 2, 1, 0x5b, 0x64, 9, 1, 0x58, 0x64, 4, 1, 0x5a, 0x64, 9, 1,
+ 0x59, 0x64, 9, 1, 0x5c, 0x64, 10, 1, 0x7f, 0x64, 7, 1, 0x57, 0x64, 12, 1,
+ 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1,
+ 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1,
+ 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1, 0x7f, 0x64, 7, 1 /* 84-87 */
};
static guint8 default_partial_reserve[9] = { /* MT-32 DEFAULT */
- 3, 10, 6, 4, 3, 0, 0, 0, 6 };
+ 3, 10, 6, 4, 3, 0, 0, 0, 6
+};
static struct {
guint8 mode;
@@ -88,8 +89,7 @@ static struct {
static int
-midiout_write_block(byte *buf, int len, int delta)
-{
+midiout_write_block(byte *buf, int len, int delta) {
if (delta)
midi_writer->delay(midi_writer, delta);
@@ -101,7 +101,7 @@ midiout_write_block(byte *buf, int len, int delta)
static int
midiout_write_delayed_block(byte *buf, int len)
- /* Only used for initial programming */
+/* Only used for initial programming */
{
int rv = midiout_write_block(buf, len, 0);
int delay = 1 + (len / MAGIC_MIDIOUT_DELAY);
@@ -139,8 +139,7 @@ int midi_mt32_defaults(guint8 volume, guint8 reverb) {
return SFX_OK;
}
-int midi_mt32_open(int length, byte *data, int length2, byte *data2, void *dev)
-{
+int midi_mt32_open(int length, byte *data, int length2, byte *data2, void *dev) {
guint8 unknown_sysex[6] = {0x16, 0x16, 0x16, 0x16, 0x16, 0x16};
guint8 i, memtimbres;
unsigned int block2, block3;
@@ -181,8 +180,8 @@ int midi_mt32_open(int length, byte *data, int length2, byte *data2, void *dev)
printf("MT-32: Writing Patches #01 - #32\n");
midi_mt32_poke(0x050000, data + 107, 256);
if ((length > block2) &&
- data[block2] == 0xAB &&
- data[block2 + 1] == 0xCD) {
+ data[block2] == 0xAB &&
+ data[block2 + 1] == 0xCD) {
printf("MT-32: Writing Patches #33 - #64\n");
midi_mt32_poke_gather(0x050200, data + 363, 128, data + block2 + 2, 128);
printf("MT-32: Writing Patches #65 - #96\n");
@@ -201,14 +200,14 @@ int midi_mt32_open(int length, byte *data, int length2, byte *data2, void *dev)
}
/* Write Rhythm key map and Partial Reserve */
if ((length > block3) &&
- data[block3] == 0xDC &&
- data[block3 + 1] == 0xBA) {
+ data[block3] == 0xDC &&
+ data[block3 + 1] == 0xBA) {
printf("MT-32: Writing Rhythm key map\n");
midi_mt32_poke(0x030110, data + block3 + 2, 256);
printf("MT-32: Writing Partial Reserve\n");
midi_mt32_poke(0x100004, data + block3 + 258, 9);
} else {
- midi_mt32_defaults(0,0); /* send default keymap/reserve */
+ midi_mt32_defaults(0, 0); /* send default keymap/reserve */
}
/* Display MT-32 initialization done message */
printf("MT-32: Displaying Text: \"%.20s\"\n", data);
@@ -218,7 +217,7 @@ int midi_mt32_open(int length, byte *data, int length2, byte *data2, void *dev)
midi_mt32_poke(0x52000A, unknown_sysex, 6);
printf("MT-32: Setting up reverb levels\n");
default_reverb = data[0x3e];
- memcpy(mt32_reverb,data+ 0x4a, 3 * 11);
+ memcpy(mt32_reverb, data + 0x4a, 3 * 11);
midi_mt32_reverb(default_reverb);
printf("MT-32: Setting default volume (%d)\n", data[0x3c]);
midi_mt32_volume(data[0x3c]);
@@ -229,13 +228,12 @@ int midi_mt32_open(int length, byte *data, int length2, byte *data2, void *dev)
return 0;
} else {
midi_mt32_poke(0x200000, (guint8 *)" FreeSCI Rocks! ", 20);
- return midi_mt32_defaults(0x0c,1); /* send defaults in absence of patch data */
+ return midi_mt32_defaults(0x0c, 1); /* send defaults in absence of patch data */
}
return -1;
}
-int midi_mt32_close(void)
-{
+int midi_mt32_close(void) {
midi_mt32_allstop();
if (type == 0) {
printf("MT-32: Displaying Text: \"%.20s\"\n", shutdown_msg);
@@ -245,8 +243,7 @@ int midi_mt32_close(void)
return SFX_OK;
}
-int midi_mt32_volume(guint8 volume)
-{
+int midi_mt32_volume(guint8 volume) {
volume &= 0x7f; /* (make sure it's not over 127) */
if (midi_mt32_poke(0x100016, &volume, 1) < 0)
return -1;
@@ -254,8 +251,7 @@ int midi_mt32_volume(guint8 volume)
return 0;
}
-int midi_mt32_allstop(void)
-{
+int midi_mt32_allstop(void) {
byte buf[4];
int i;
@@ -270,14 +266,13 @@ int midi_mt32_allstop(void)
return 0;
}
-int midi_mt32_reverb(int param)
-{
+int midi_mt32_reverb(int param) {
guint8 buffer[3];
if (param == -1)
param = default_reverb;
- printf("MT-32: Sending reverb # %d (%d, %d, %d)\n",param, mt32_reverb[param].mode,
+ printf("MT-32: Sending reverb # %d (%d, %d, %d)\n", param, mt32_reverb[param].mode,
mt32_reverb[param].time,
mt32_reverb[param].level);
@@ -291,8 +286,7 @@ int midi_mt32_reverb(int param)
static int
-midi_mt32_poke(guint32 address, guint8 *data, unsigned int count)
-{
+midi_mt32_poke(guint32 address, guint8 *data, unsigned int count) {
guint8 checksum = 0;
unsigned int i;
@@ -319,8 +313,7 @@ midi_mt32_poke(guint32 address, guint8 *data, unsigned int count)
static int
midi_mt32_poke_gather(guint32 address, guint8 *data1, unsigned int count1,
- guint8 *data2, unsigned int count2)
-{
+ guint8 *data2, unsigned int count2) {
guint8 checksum = 0;
unsigned int i;
@@ -347,8 +340,7 @@ midi_mt32_poke_gather(guint32 address, guint8 *data1, unsigned int count1,
static int
-midi_mt32_write_block(guint8 *data, unsigned int count)
-{
+midi_mt32_write_block(guint8 *data, unsigned int count) {
unsigned int block_start = 0;
unsigned int i = 0;
@@ -366,7 +358,7 @@ midi_mt32_write_block(guint8 *data, unsigned int count)
}
if (count >= block_start) {
if (midiout_write_delayed_block(data + block_start, count - block_start
- ) != (count - block_start)) {
+ ) != (count - block_start)) {
fprintf(stderr, "midi_mt32_write_block(): midiout_write_block failed!\n");
return 1;
}
@@ -376,9 +368,8 @@ midi_mt32_write_block(guint8 *data, unsigned int count)
}
static int
-midi_mt32_sysex_delay(void)
-{
- /* Under Win32, we won't get any sound, in any case... */
+midi_mt32_sysex_delay(void) {
+ /* Under Win32, we won't get any sound, in any case... */
#ifdef HAVE_USLEEP
usleep(320 * 63); /* One MIDI byte is 320us, 320us * 63 > 20ms */
#elif defined (WIN32)
@@ -392,8 +383,7 @@ midi_mt32_sysex_delay(void)
}
static int
-midi_mt32_event(byte command, int argc, byte *argv)
-{
+midi_mt32_event(byte command, int argc, byte *argv) {
byte buf[8];
buf[0] = command;
@@ -407,8 +397,7 @@ midi_mt32_event(byte command, int argc, byte *argv)
static void
-delay_init(void)
-{/* Wait for MT-32 initialisation to complete */
+delay_init(void) {/* Wait for MT-32 initialisation to complete */
long endsec = mt32_init_sec, uendsec = mt32_init_usec;
long sec, usec;
int loopcount = 0;
@@ -430,8 +419,7 @@ delay_init(void)
}
static int
-midi_mt32_reset_timer(GTimeVal ts)
-{
+midi_mt32_reset_timer(GTimeVal ts) {
if (mt32_init_delay) { /* We might still have to wait for initialisation to complete */
delay_init();
mt32_init_delay = 0;
@@ -444,15 +432,13 @@ midi_mt32_reset_timer(GTimeVal ts)
static int
-midi_mt32_delay(int ticks)
-{
+midi_mt32_delay(int ticks) {
delta += ticks; /* Accumulate, write before next command */
return SFX_OK;
}
static int
-midi_mt32_set_option(char *name, char *value)
-{
+midi_mt32_set_option(char *name, char *value) {
return SFX_ERROR; /* No options are supported at this time */
}
diff --git a/engines/sci/sfx/seq/oss-adlib.cpp b/engines/sci/sfx/seq/oss-adlib.cpp
index 0406556f56..d2275fb9b5 100644
--- a/engines/sci/sfx/seq/oss-adlib.cpp
+++ b/engines/sci/sfx/seq/oss-adlib.cpp
@@ -50,8 +50,7 @@ static unsigned char oper_note[ADLIB_VOICES];
static unsigned char oper_chn[ADLIB_VOICES];
#if 1
-void seqbuf_dump(void) /* OSS upcall */
-{
+void seqbuf_dump(void) { /* OSS upcall */
if (_seqbufptr)
if (write(seqfd, _seqbuf, _seqbufptr) == -1) {
perror("ADLIB write ");
@@ -62,10 +61,9 @@ void seqbuf_dump(void) /* OSS upcall */
#endif
/* initialise note/operator lists, etc. */
-void adlib_init_lists(void)
-{
+void adlib_init_lists(void) {
int i;
- for(i = 0 ; i < ADLIB_VOICES ; i++) {
+ for (i = 0 ; i < ADLIB_VOICES ; i++) {
oper_note[i] = 255;
oper_chn[i] = 255;
note_time[i] = 0;
@@ -73,40 +71,38 @@ void adlib_init_lists(void)
free_voices = ADLIB_VOICES;
}
-int adlib_stop_note(int chn, int note, int velocity)
-{
- int i, op=255;
-
- for (i=0;i<ADLIB_VOICES && op==255;i++) {
+int adlib_stop_note(int chn, int note, int velocity) {
+ int i, op = 255;
+
+ for (i = 0;i < ADLIB_VOICES && op == 255;i++) {
if (oper_chn[i] == chn)
if (oper_note[i] == note)
- op=i;
+ op = i;
}
- if (op==255) {
- printf ("can't stop.. chn %d %d %d\n", chn, note, velocity);
+ if (op == 255) {
+ printf("can't stop.. chn %d %d %d\n", chn, note, velocity);
return 255; /* not playing */
}
-
+
SEQ_STOP_NOTE(dev, op, note, velocity);
SEQ_DUMPBUF();
oper_chn[op] = 255;
oper_note[op] = 255;
note_time[op] = 0;
-
+
free_voices++;
return op;
}
-int adlib_kill_one_note(int chn)
-{
+int adlib_kill_one_note(int chn) {
int oldest = 255, i = 255;
long time = 0;
-
+
if (free_voices >= ADLIB_VOICES) {
- printf("Free list empty but no notes playing\n");
+ printf("Free list empty but no notes playing\n");
return 255;
} /* No notes playing */
@@ -128,7 +124,7 @@ int adlib_kill_one_note(int chn)
/* printf("Killing chn %d, oper %d\n", chn, oldest); */
- if (oldest == 255)
+ if (oldest == 255)
return 255; /* Was already stopped. Why? */
SEQ_STOP_NOTE(dev, oldest, oper_note[oldest], 0);
@@ -143,9 +139,8 @@ int adlib_kill_one_note(int chn)
}
static void
-adlib_start_note(int chn, int note, int velocity)
-{
- int free;
+adlib_start_note(int chn, int note, int velocity) {
+ int free;
struct timeval now;
if (velocity == 0) {
@@ -153,11 +148,11 @@ adlib_start_note(int chn, int note, int velocity)
return;
}
- gettimeofday(&now, NULL);
+ gettimeofday(&now, NULL);
if (free_voices <= 0)
free = adlib_kill_one_note(chn);
- else
+ else
for (free = 0; free < ADLIB_VOICES ; free++)
if (oper_chn[free] == 255)
break;
@@ -176,27 +171,26 @@ adlib_start_note(int chn, int note, int velocity)
static int
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;
struct synth_info info;
struct sbi_instrument sbi;
if (data_length < 1344) {
- printf ("invalid patch.003");
+ printf("invalid patch.003");
return -1;
}
- for (i = 0; i < 48; i++)
- make_sbi((adlib_def *)(data_ptr+(28 * i)), adlib_sbi[i]);
+ for (i = 0; i < 48; i++)
+ make_sbi((adlib_def *)(data_ptr + (28 * i)), adlib_sbi[i]);
if (data_length > 1344)
- for (i = 48; i < 96; i++)
- make_sbi((adlib_def *)(data_ptr+2+(28 * i)), adlib_sbi[i]);
+ for (i = 48; i < 96; i++)
+ make_sbi((adlib_def *)(data_ptr + 2 + (28 * i)), adlib_sbi[i]);
memset(instr, 0, sizeof(instr));
-
- if (!IS_VALID_FD(seqfd=open("/dev/sequencer", O_WRONLY, 0))) {
+
+ if (!IS_VALID_FD(seqfd = open("/dev/sequencer", O_WRONLY, 0))) {
perror("/dev/sequencer");
return(-1);
}
@@ -204,9 +198,9 @@ midi_adlib_open(int data_length, byte *data_ptr, int data2_length,
perror("/dev/sequencer");
return(-1);
}
- for (i=0;i<nrdevs && dev==-1;i++) {
+ for (i = 0;i < nrdevs && dev == -1;i++) {
info.device = i;
- if (ioctl(seqfd, SNDCTL_SYNTH_INFO, &info)==-1) {
+ if (ioctl(seqfd, SNDCTL_SYNTH_INFO, &info) == -1) {
perror("info: /dev/sequencer");
return(-1);
}
@@ -227,7 +221,7 @@ midi_adlib_open(int data_length, byte *data_ptr, int data2_length,
for (i = 0; i < 96; i++) {
for (n = 0; n < 32; n++)
memcpy(sbi.operators, &adlib_sbi[i], sizeof(sbi_instr_data));
- sbi.channel=i;
+ sbi.channel = i;
SEQ_WRPATCH(&sbi, sizeof(sbi));
SEQ_DUMPBUF();
}
@@ -239,16 +233,14 @@ midi_adlib_open(int data_length, byte *data_ptr, int data2_length,
static int
-midi_adlib_close(void)
-{
+midi_adlib_close(void) {
SEQ_DUMPBUF();
return close(seqfd);
}
static int
-midi_adlib_allstop(void)
-{
+midi_adlib_allstop(void) {
int i;
for (i = 0; i < ADLIB_VOICES ; i++) {
if (oper_chn[i] == 255)
@@ -261,26 +253,24 @@ midi_adlib_allstop(void)
}
static int
-midi_adlib_reverb(int param)
-{
+midi_adlib_reverb(int param) {
printf("reverb NYI %04x \n", param);
return 0;
}
static inline int
-midi_adlib_event1(guint8 command, guint8 note, guint8 velocity)
-{
+midi_adlib_event1(guint8 command, guint8 note, guint8 velocity) {
guint8 channel, oper;
channel = command & 0x0f;
oper = command & 0xf0;
- switch (oper) {
+ switch (oper) {
case 0x80:
adlib_stop_note(channel, note, velocity);
return 0;
- case 0x90:
- adlib_start_note(channel,note,velocity);
+ case 0x90:
+ adlib_start_note(channel, note, velocity);
return 0;
case 0xe0: /* Pitch bend needs scaling? */
SEQ_BENDER(dev, channel, ((note << 8) & velocity));
@@ -291,23 +281,22 @@ midi_adlib_event1(guint8 command, guint8 note, guint8 velocity)
return 0;
case 0xd0: /* aftertouch */
SEQ_CHN_PRESSURE(dev, channel, note);
- SEQ_DUMPBUF();
+ SEQ_DUMPBUF();
return 0;
default:
printf("ADLIB: Unknown event %02x\n", command);
return 0;
}
-
+
SEQ_DUMPBUF();
return 0;
}
static inline int
-midi_adlib_event2(guint8 command, guint8 param)
-{
+midi_adlib_event2(guint8 command, guint8 param) {
guint8 channel;
guint8 oper;
-
+
channel = command & 0x0f;
oper = command & 0xf0;
switch (oper) {
@@ -327,8 +316,7 @@ midi_adlib_event2(guint8 command, guint8 param)
}
static int
-midi_adlib_event(byte command, int argc, byte *argv)
-{
+midi_adlib_event(byte command, int argc, byte *argv) {
if (argc > 1)
return midi_adlib_event1(command, argv[0], argv[1]);
else
@@ -336,15 +324,13 @@ midi_adlib_event(byte command, int argc, byte *argv)
}
static int
-midi_adlib_delay(int ticks)
-{
+midi_adlib_delay(int ticks) {
SEQ_DELTA_TIME(ticks);
return SFX_OK;
}
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 */
}
diff --git a/engines/sci/sfx/seq/sequencers.cpp b/engines/sci/sfx/seq/sequencers.cpp
index 3ba7f25a46..60752f624b 100644
--- a/engines/sci/sfx/seq/sequencers.cpp
+++ b/engines/sci/sfx/seq/sequencers.cpp
@@ -49,8 +49,7 @@ sfx_sequencer_t *sfx_sequencers[] = {
sfx_sequencer_t *
-sfx_find_sequencer(char *name)
-{
+sfx_find_sequencer(char *name) {
if (!name) {
/* Implement default policy for your platform (if any) here, or in a function
** called from here (if it's non-trivial). Try to use midi_devices[0], if
@@ -60,8 +59,8 @@ sfx_find_sequencer(char *name)
} else {
int n = 0;
while (sfx_sequencers[n]
- && strcasecmp(sfx_sequencers[n]->name, name))
- ++n;
+ && strcasecmp(sfx_sequencers[n]->name, name))
+ ++n;
return sfx_sequencers[n];
}