ref: cbff5cf07f67b6a20c1718b10fece652a62bdaa0
parent: 396caa4d31859045ccb5ef943fd430ca4026cce8
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Thu Mar 4 09:26:28 EST 2021
port the library and add "audio/moddec" to examples/
--- a/README.md
+++ b/README.md
@@ -84,6 +84,12 @@
## Installation
+### Plan 9
+
+ mk install
+
+### Other systems
+
Currently you need to compile libdumb yourself. For more details, please see
the file [COMPILING.md](COMPILING.md).
--- /dev/null
+++ b/examples/moddec.c
@@ -1,0 +1,91 @@
+#include <dumb.h>
+
+#pragma lib "./libdumb.a$O"
+
+#define MAX(a,b) ((a)>(b)?(a):(b))
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#define SRATE 44100.0f
+
+enum {
+ Nsamp = 4096,
+};
+
+static uchar b[Nsamp*2*2];
+
+static void
+usage(void)
+{
+ fprint(2, "usage: %s [FILE]\n", argv0);
+ exits("usage");
+}
+
+void
+main(int argc, char **argv)
+{
+ DUMB_IT_SIGRENDERER *itren;
+ DUH_SIGRENDERER *ren;
+ sample_t **samp;
+ char *data, *t;
+ int n, sz, r;
+ double pos;
+ long nsamp;
+ DUH *f;
+
+ setfcr(getfcr() & ~(FPINVAL|FPOVFL));
+
+ pos = 0.0;
+ ARGBEGIN{
+ case 's':
+ pos = atof(EARGF(usage()));
+ break;
+ default:
+ usage();
+ }ARGEND;
+
+ if(argc != 0)
+ usage();
+
+ sz = 32768;
+ data = nil;
+ for(n = 0;; n += r){
+ if(sz-n < 65536){
+ sz *= 2;
+ if((data = realloc(data, sz)) == nil)
+ sysfatal("memory");
+ }
+ if((r = read(0, data+n, sz-n)) < 0)
+ sysfatal("%r");
+ if(r == 0)
+ break;
+ }
+
+ if((f = dumb_read_any(dumbfile_open_memory(data, sz), 1, 0)) == nil)
+ sysfatal("unknown/invalid mod");
+ if((t = (char*)duh_get_tag(f, "TITLE")) != nil && *t)
+ fprint(2, "%s\n", t);
+ ren = duh_start_sigrenderer(f, 0, 2, 0);
+ itren = duh_get_it_sigrenderer(ren);
+ dumb_it_set_loop_callback(itren, dumb_it_callback_terminate, nil);
+ dumb_it_set_xm_speed_zero_callback(itren, dumb_it_callback_terminate, nil);
+ dumb_it_set_resampling_quality(itren, DUMB_RQ_CUBIC);
+ if(pos > 0.0)
+ fprint(2, "time: %g\n", pos);
+
+ n = 0;
+ for(;;){
+ if(pos > 0.0){
+ pos -= (double)n / SRATE;
+ n = MIN(pos*SRATE, Nsamp);
+ if(n < 1)
+ pos = 0.0;
+ }
+ memset(b, 0, sizeof(b));
+ n = duh_render_int(ren, &samp, &nsamp, 16, 0, 1.0, 65536.0f/SRATE, MAX(n, Nsamp), b);
+ if(n <= 0)
+ break;
+ if(pos <= 0.0 && write(1, b, n*2*2) != n*2*2)
+ break;
+ }
+
+ exits(nil);
+}
--- a/include/dumb.h
+++ b/include/dumb.h
@@ -20,6 +20,10 @@
#ifndef DUMB_H
#define DUMB_H
+#if !defined(__plan9__) && !defined(USED)
+#define USED(x) (void)(x)
+#endif
+
#include <stdlib.h>
#include <stdio.h>
@@ -198,6 +202,9 @@
} DUMBFILE_SYSTEM;
typedef struct DUMBFILE DUMBFILE;
+#ifdef __plan9__
+#pragma incomplete DUMBFILE
+#endif
void register_dumbfile_system(const DUMBFILE_SYSTEM *dfs);
@@ -244,6 +251,9 @@
/* DUH Management */
typedef struct DUH DUH;
+#ifdef __plan9__
+#pragma incomplete DUH
+#endif
#define DUH_SIGNATURE DUMB_ID('D', 'U', 'H', '!')
@@ -262,6 +272,9 @@
/* Signal Rendering Functions */
typedef struct DUH_SIGRENDERER DUH_SIGRENDERER;
+#ifdef __plan9__
+#pragma incomplete DUH_SIGRENDERER
+#endif
DUH_SIGRENDERER *duh_start_sigrenderer(DUH *duh, int sig, int n_channels,
long pos);
@@ -321,6 +334,10 @@
typedef struct DUMB_IT_SIGDATA DUMB_IT_SIGDATA;
typedef struct DUMB_IT_SIGRENDERER DUMB_IT_SIGRENDERER;
+#ifdef __plan9__
+#pragma incomplete DUMB_IT_SIGDATA
+#pragma incomplete DUMB_IT_SIGRENDERER
+#endif
DUMB_IT_SIGDATA *duh_get_it_sigdata(DUH *duh);
DUH_SIGRENDERER *
@@ -607,6 +624,9 @@
/* Click Removal Helpers */
typedef struct DUMB_CLICK_REMOVER DUMB_CLICK_REMOVER;
+#ifdef __plan9__
+#pragma incomplete DUMB_CLICK_REMOVER
+#endif
DUMB_CLICK_REMOVER *dumb_create_click_remover(void);
void dumb_record_click(DUMB_CLICK_REMOVER *cr, long pos, sample_t step);
--- a/src/core/register.c
+++ b/src/core/register.c
@@ -68,7 +68,7 @@
desc_link = desc_link->next;
} while (desc_link);
} else
- dumb_atexit(&destroy_sigtypes);
+ dumb_atexit(destroy_sigtypes);
desc_link = *sigtype_desc_tail = malloc(sizeof(DUH_SIGTYPE_DESC_LINK));
--- a/src/helpers/lpc.c
+++ b/src/helpers/lpc.c
@@ -56,8 +56,8 @@
Output: m lpc coefficients, excitation energy */
static float vorbis_lpc_from_data(float *data, float *lpci, long n, long m) {
- double *aut = alloca(sizeof(*aut) * (m + 1));
- double *lpc = alloca(sizeof(*lpc) * (m));
+ double *aut = malloc(sizeof(*aut) * (m + 1));
+ double *lpc = malloc(sizeof(*lpc) * (m));
double error;
double epsilon;
long i, j;
@@ -127,6 +127,9 @@
/* we need the error value to know how big an impulse to hit the
filter with later */
+ free(aut);
+ free(lpc);
+
return error;
}
@@ -139,7 +142,7 @@
long i, j, o, p;
float y;
- float *work = alloca(sizeof(*work) * (m + n));
+ float *work = malloc(sizeof(*work) * (m + n));
if (!prime)
for (i = 0; i < m; i++)
@@ -157,6 +160,8 @@
data[i] = work[o] = y;
}
+
+ free(work);
}
#include "dumb.h"
--- a/src/helpers/memfile.c
+++ b/src/helpers/memfile.c
@@ -73,12 +73,12 @@
}
static const DUMBFILE_SYSTEM memfile_dfs = {NULL,
- &dumb_memfile_skip,
- &dumb_memfile_getc,
- &dumb_memfile_getnc,
- &dumb_memfile_close,
- &dumb_memfile_seek,
- &dumb_memfile_get_size};
+ dumb_memfile_skip,
+ dumb_memfile_getc,
+ dumb_memfile_getnc,
+ dumb_memfile_close,
+ dumb_memfile_seek,
+ dumb_memfile_get_size};
DUMBFILE *dumbfile_open_memory(const char *data, size_t size) {
MEMFILE *m = malloc(sizeof(*m));
--- a/src/helpers/resamp2.inc
+++ b/src/helpers/resamp2.inc
@@ -123,6 +123,7 @@
volume_left = NULL; \
} else { \
lvol = 0; \
+ lvolr = 0; \
lvold = 0; \
lvolt = 0; \
lvolm = 0; \
@@ -137,6 +138,7 @@
volume_right = NULL; \
} else { \
rvol = 0; \
+ rvolr = 0; \
rvold = 0; \
rvolt = 0; \
rvolm = 0; \
--- a/src/helpers/stdfile.c
+++ b/src/helpers/stdfile.c
@@ -80,19 +80,19 @@
}
static const DUMBFILE_SYSTEM stdfile_dfs = {
- &dumb_stdfile_open, &dumb_stdfile_skip, &dumb_stdfile_getc,
- &dumb_stdfile_getnc, &dumb_stdfile_close, &dumb_stdfile_seek,
- &dumb_stdfile_get_size};
+ dumb_stdfile_open, dumb_stdfile_skip, dumb_stdfile_getc,
+ dumb_stdfile_getnc, dumb_stdfile_close, dumb_stdfile_seek,
+ dumb_stdfile_get_size};
void dumb_register_stdfiles(void) { register_dumbfile_system(&stdfile_dfs); }
static const DUMBFILE_SYSTEM stdfile_dfs_leave_open = {NULL,
- &dumb_stdfile_skip,
- &dumb_stdfile_getc,
- &dumb_stdfile_getnc,
- &dumb_stdfile_noclose,
- &dumb_stdfile_seek,
- &dumb_stdfile_get_size};
+ dumb_stdfile_skip,
+ dumb_stdfile_getc,
+ dumb_stdfile_getnc,
+ dumb_stdfile_noclose,
+ dumb_stdfile_seek,
+ dumb_stdfile_get_size};
DUMBFILE *dumbfile_open_stdfile(FILE *p) {
dumb_stdfile *file = (dumb_stdfile *)malloc(sizeof(dumb_stdfile));
--- a/src/it/itread.c
+++ b/src/it/itread.c
@@ -1246,7 +1246,7 @@
sigdata->flags &= IT_REAL_FLAGS;
- qsort(component, n_components, sizeof(IT_COMPONENT), &it_component_compare);
+ qsort(component, n_components, sizeof(IT_COMPONENT), it_component_compare);
buffer = malloc(65536);
if (!buffer) {
--- a/src/it/itrender.c
+++ b/src/it/itrender.c
@@ -41,7 +41,7 @@
// #define BIT_ARRAY_BULLSHIT
-static IT_PLAYING *new_playing() {
+static IT_PLAYING *new_playing(void) {
IT_PLAYING *r = (IT_PLAYING *)malloc(sizeof(*r));
if (r) {
r->resampler.fir_resampler_ratio = 0.0;
@@ -1219,7 +1219,8 @@
channel->xm_volslide = 0;
channel->panslide = 0;
channel->channelvolslide = 0;
- channel->arpeggio_table = (const unsigned char *)&arpeggio_mod;
+ channel->arpeggio_table = (const unsigned char *)arpeggio_mod;
+ channel->arpeggio_shift = 0;
memset(channel->arpeggio_offsets, 0, sizeof(channel->arpeggio_offsets));
channel->retrig = 0;
if (channel->xm_retrig) {
@@ -1226,6 +1227,7 @@
channel->xm_retrig = 0;
channel->retrig_tick = 0;
}
+ channel->tremor = 0;
channel->tremor_time &= 127;
channel->portamento = 0;
channel->toneporta = 0;
@@ -1235,6 +1237,7 @@
} else
channel->ptm_last_toneslide = 0;
channel->ptm_toneslide = 0;
+ channel->toneslide_retrig = 0;
channel->toneslide_tick = 0;
channel->okt_toneslide = 0;
if (channel->playing) {
@@ -1316,25 +1319,25 @@
playing->resampler.start = playing->sample->sus_loop_start;
playing->resampler.end = playing->sample->sus_loop_end;
if (playing->resampler.start == playing->resampler.end)
- playing->resampler.pickup = &it_pickup_stop_at_end;
+ playing->resampler.pickup = it_pickup_stop_at_end;
else if (playing->sample->flags & IT_SAMPLE_PINGPONG_SUS_LOOP)
- playing->resampler.pickup = &it_pickup_pingpong_loop;
+ playing->resampler.pickup = it_pickup_pingpong_loop;
else
- playing->resampler.pickup = &it_pickup_loop;
+ playing->resampler.pickup = it_pickup_loop;
} else if (playing->sample->flags & IT_SAMPLE_LOOP) {
playing->resampler.start = playing->sample->loop_start;
playing->resampler.end = playing->sample->loop_end;
if (playing->resampler.start == playing->resampler.end)
- playing->resampler.pickup = &it_pickup_stop_at_end;
+ playing->resampler.pickup = it_pickup_stop_at_end;
else if (playing->sample->flags & IT_SAMPLE_PINGPONG_LOOP)
- playing->resampler.pickup = &it_pickup_pingpong_loop;
+ playing->resampler.pickup = it_pickup_pingpong_loop;
else
- playing->resampler.pickup = &it_pickup_loop;
+ playing->resampler.pickup = it_pickup_loop;
} else if (playing->flags & IT_PLAYING_REVERSE) {
playing->resampler.start = 0;
playing->resampler.end = playing->sample->length;
playing->resampler.dir = -1;
- playing->resampler.pickup = &it_pickup_stop_after_reverse;
+ playing->resampler.pickup = it_pickup_stop_after_reverse;
} else {
if (playing->sample->flags & IT_SAMPLE_SUS_LOOP)
playing->resampler.start = playing->sample->sus_loop_start;
@@ -1341,7 +1344,7 @@
else
playing->resampler.start = 0;
playing->resampler.end = playing->sample->length;
- playing->resampler.pickup = &it_pickup_stop_at_end;
+ playing->resampler.pickup = it_pickup_stop_at_end;
}
ASSERT(playing->resampler.pickup_data == playing);
}
@@ -2463,12 +2466,12 @@
static void xm_envelope_calculate_value(IT_ENVELOPE *envelope,
IT_PLAYING_ENVELOPE *pe) {
- if (pe->next_node <= 0)
+ if (pe->next_node <= 0) {
pe->value = envelope->node_y[0] << IT_ENVELOPE_SHIFT;
- else if (pe->next_node >= envelope->n_nodes)
+ } else if (pe->next_node >= envelope->n_nodes) {
pe->value = envelope->node_y[envelope->n_nodes - 1]
<< IT_ENVELOPE_SHIFT;
- else {
+ } else {
int ys = envelope->node_y[pe->next_node - 1] << IT_ENVELOPE_SHIFT;
int ts = envelope->node_t[pe->next_node - 1];
int te = envelope->node_t[pe->next_node];
@@ -2841,8 +2844,8 @@
(const unsigned char *)(((sigdata->flags &
(IT_WAS_AN_XM | IT_WAS_A_MOD)) ==
IT_WAS_AN_XM)
- ? &arpeggio_xm
- : &arpeggio_mod);
+ ? arpeggio_xm
+ : arpeggio_mod);
} break;
case IT_SET_CHANNEL_VOLUME:
if (sigdata->flags & IT_WAS_AN_XM)
@@ -3357,10 +3360,10 @@
IT_PLAYING_ENVELOPE *pe =
&channel->playing->volume_envelope;
pe->tick = entry->effectvalue;
- if (pe->tick >= envelope->node_t[envelope->n_nodes - 1])
+ if (pe->tick >= (int)envelope->node_t[envelope->n_nodes - 1])
pe->tick = envelope->node_t[envelope->n_nodes - 1];
pe->next_node = 0;
- while (pe->tick > envelope->node_t[pe->next_node])
+ while (pe->tick > (int)envelope->node_t[pe->next_node])
pe->next_node++;
xm_envelope_calculate_value(envelope, pe);
}
@@ -3475,17 +3478,17 @@
switch (entry->effect) {
case IT_OKT_ARPEGGIO_3:
channel->arpeggio_table =
- (const unsigned char *)&arpeggio_okt_3;
+ (const unsigned char *)arpeggio_okt_3;
break;
case IT_OKT_ARPEGGIO_4:
channel->arpeggio_table =
- (const unsigned char *)&arpeggio_okt_4;
+ (const unsigned char *)arpeggio_okt_4;
break;
case IT_OKT_ARPEGGIO_5:
channel->arpeggio_table =
- (const unsigned char *)&arpeggio_okt_5;
+ (const unsigned char *)arpeggio_okt_5;
break;
}
} break;
@@ -4096,7 +4099,7 @@
static int envelope_get_y(IT_ENVELOPE *envelope, IT_PLAYING_ENVELOPE *pe) {
#if 1
- (void)envelope; // TODO: remove the parameter
+ USED(envelope); // TODO: remove the parameter
return pe->value;
#else
int ys, ye;
@@ -4130,7 +4133,7 @@
if (pe->next_node >= envelope->n_nodes)
return 1;
- if (pe->tick < envelope->node_t[pe->next_node]) return 0;
+ if (pe->tick < (int)envelope->node_t[pe->next_node]) return 0;
if ((envelope->flags & IT_ENVELOPE_LOOP_ON) &&
envelope->loop_end >= pe->next_node &&
@@ -4157,7 +4160,7 @@
if (pe->tick <= 0)
pe->value = envelope->node_y[0] << IT_ENVELOPE_SHIFT;
- else if (pe->tick >= envelope->node_t[envelope->n_nodes - 1]) {
+ else if (pe->tick >= (int)envelope->node_t[envelope->n_nodes - 1]) {
pe->value = envelope->node_y[envelope->n_nodes - 1]
<< IT_ENVELOPE_SHIFT;
} else {
@@ -4181,7 +4184,7 @@
if ((envelope->flags & IT_ENVELOPE_SUSTAIN_LOOP) &&
!(playing->flags & IT_PLAYING_SUSTAINOFF)) {
- if (pe->tick > envelope->node_t[envelope->sus_loop_end]) {
+ if (pe->tick > (int)envelope->node_t[envelope->sus_loop_end]) {
pe->next_node = envelope->sus_loop_start + 1;
ASSERT(pe->next_node <= envelope->n_nodes);
pe->tick = envelope->node_t[envelope->sus_loop_start];
@@ -4188,13 +4191,13 @@
return 0;
}
} else if (envelope->flags & IT_ENVELOPE_LOOP_ON) {
- if (pe->tick > envelope->node_t[envelope->loop_end]) {
+ if (pe->tick > (int)envelope->node_t[envelope->loop_end]) {
pe->next_node = envelope->loop_start + 1;
ASSERT(pe->next_node <= envelope->n_nodes);
pe->tick = envelope->node_t[envelope->loop_start];
return 0;
}
- } else if (pe->tick > envelope->node_t[envelope->n_nodes - 1])
+ } else if (pe->tick > (int)envelope->node_t[envelope->n_nodes - 1])
return 1;
return 0;
@@ -4234,13 +4237,13 @@
if (xm_envelope_is_sustaining(playing, envelope, pe))
return;
- if (pe->tick >= envelope->node_t[envelope->n_nodes - 1])
+ if (pe->tick >= (int)envelope->node_t[envelope->n_nodes - 1])
return;
pe->tick++;
/* pe->next_node must be kept up to date for envelope_get_y(). */
- while (pe->tick > envelope->node_t[pe->next_node])
+ while (pe->tick > (int)envelope->node_t[pe->next_node])
pe->next_node++;
if ((envelope->flags & IT_ENVELOPE_LOOP_ON) &&
@@ -4250,7 +4253,6 @@
pe->tick = envelope->node_t[pe->next_node];
}
}
-
xm_envelope_calculate_value(envelope, pe);
}
@@ -5040,7 +5042,6 @@
volume *= 1.0f / (128.0f * 1024.0f);
}
}
-
return volume;
}
@@ -5389,7 +5390,7 @@
}
if (volume != 0)
- qsort(to_mix, n_to_mix, sizeof(IT_TO_MIX), &it_to_mix_compare);
+ qsort(to_mix, n_to_mix, sizeof(IT_TO_MIX), it_to_mix_compare);
for (i = 0; i < n_to_mix; i++) {
IT_PLAYING *playing = to_mix[i].playing;
@@ -5531,9 +5532,9 @@
}
if (volume != 0) {
- qsort(to_mix, n_to_mix, sizeof(IT_TO_MIX), &it_to_mix_compare);
+ qsort(to_mix, n_to_mix, sizeof(IT_TO_MIX), it_to_mix_compare);
qsort(to_mix_surround, n_to_mix_surround, sizeof(IT_TO_MIX),
- &it_to_mix_compare);
+ it_to_mix_compare);
}
sigrenderer->n_channels = 2;
@@ -5997,7 +5998,7 @@
DUMB_IT_SIGDATA *sigdata = vsigdata;
DUMB_IT_SIGRENDERER *sigrenderer;
- (void)duh;
+ USED(duh);
{
IT_CALLBACKS *callbacks = create_callbacks();
@@ -6195,17 +6196,17 @@
DUH_SIGTYPE_DESC _dumb_sigtype_it = {SIGTYPE_IT,
NULL,
- &it_start_sigrenderer,
+ it_start_sigrenderer,
NULL,
- &it_sigrenderer_get_samples,
- &it_sigrenderer_get_current_sample,
+ it_sigrenderer_get_samples,
+ it_sigrenderer_get_current_sample,
#ifdef BIT_ARRAY_BULLSHIT
- &it_sigrenderer_get_position,
+ it_sigrenderer_get_position,
#else
NULL,
#endif
- &_dumb_it_end_sigrenderer,
- &_dumb_it_unload_sigdata};
+ _dumb_it_end_sigrenderer,
+ _dumb_it_unload_sigdata};
DUH_SIGRENDERER *
duh_encapsulate_it_sigrenderer(DUMB_IT_SIGRENDERER *it_sigrenderer,
@@ -6270,15 +6271,15 @@
}
int dumb_it_callback_terminate(void *data) {
- (void)data;
+ USED(data);
return 1;
}
int dumb_it_callback_midi_block(void *data, int channel,
unsigned char midi_byte) {
- (void)data;
- (void)channel;
- (void)midi_byte;
+ USED(data);
+ USED(channel);
+ USED(midi_byte);
return 1;
}
@@ -6309,11 +6310,11 @@
free(checkpoint);
return 0;
}
- checkpoint->sigrenderer->callbacks->loop = &dumb_it_callback_terminate;
+ checkpoint->sigrenderer->callbacks->loop = dumb_it_callback_terminate;
checkpoint->sigrenderer->callbacks->xm_speed_zero =
- &dumb_it_callback_terminate;
+ dumb_it_callback_terminate;
checkpoint->sigrenderer->callbacks->global_volume_zero =
- &dumb_it_callback_terminate;
+ dumb_it_callback_terminate;
if (sigdata->checkpoint) {
IT_CHECKPOINT *checkpoint = sigdata->checkpoint;
@@ -6560,10 +6561,10 @@
bit_array_destroy(ba_played);
return -1;
}
- sigrenderer->callbacks->loop = &dumb_it_callback_terminate;
- sigrenderer->callbacks->xm_speed_zero = &dumb_it_callback_terminate;
+ sigrenderer->callbacks->loop = dumb_it_callback_terminate;
+ sigrenderer->callbacks->xm_speed_zero = dumb_it_callback_terminate;
sigrenderer->callbacks->global_volume_zero =
- &dumb_it_callback_terminate;
+ dumb_it_callback_terminate;
length = 0;
--- a/src/it/readmtm.c
+++ b/src/it/readmtm.c
@@ -451,7 +451,7 @@
version[6] = '.';
version[7] = hexdigit(ver & 15);
version[8] = 0;
- tag[1][1] = (const char *)&version;
+ tag[1][1] = version;
return make_duh(-1, 2, (const char *const(*)[2])tag, 1, &descptr,
&sigdata);
}
--- a/src/it/readoldpsm.c
+++ b/src/it/readoldpsm.c
@@ -67,7 +67,7 @@
*num = true_num;
}
- qsort(buffer, count, 64, &psm_sample_compare);
+ qsort(buffer, count, 64, psm_sample_compare);
for (n = 0; n < *num; n++) {
(*sample)[n].flags = 0;
@@ -636,7 +636,7 @@
goto error_fc;
qsort(component, n_components, sizeof(PSM_COMPONENT),
- &psm_component_compare);
+ psm_component_compare);
memset(sigdata->channel_volume, 64, DUMB_IT_N_CHANNELS);
--- a/src/it/readpsm.c
+++ b/src/it/readpsm.c
@@ -1261,7 +1261,7 @@
}
}
- qsort(order_list, n_patterns, sizeof(*order_list), &it_order_compare);
+ qsort(order_list, n_patterns, sizeof(*order_list), it_order_compare);
for (n = 0, o = 0; n < n_patterns; n++) {
if (order_list[n] != order_list[o]) {
@@ -1339,7 +1339,7 @@
}
/* Eww */
-int pattcmp(const unsigned char *a, const unsigned char *b, size_t l) {
+static int pattcmp(const unsigned char *a, const unsigned char *b, size_t l) {
long i, j;
unsigned long na, nb;
char *p;
@@ -1409,7 +1409,7 @@
tag[2][0] = "FORMATVERSION";
snprintf(version, 15, "%d", ver);
version[15] = 0;
- tag[2][1] = (const char *)&version;
+ tag[2][1] = version;
++n_tags;
}
return make_duh(-1, n_tags, (const char *const(*)[2])tag, 1, &descptr,
--- a/src/it/readptm.c
+++ b/src/it/readptm.c
@@ -471,7 +471,7 @@
}
qsort(component, n_components, sizeof(PTM_COMPONENT),
- &ptm_component_compare);
+ ptm_component_compare);
{
int i;
--- a/src/it/reads3m.c
+++ b/src/it/reads3m.c
@@ -611,7 +611,7 @@
}
qsort(component, n_components, sizeof(S3M_COMPONENT),
- &s3m_component_compare);
+ s3m_component_compare);
/* I found a really dumb S3M file that claimed to contain default pan
* data but didn't contain any. Programs would load it by reading part of
@@ -773,7 +773,7 @@
version[2] = hexdigit((cwtv >> 4) & 15);
version[3] = hexdigit(cwtv & 15);
version[4] = 0;
- tag[2][1] = (const char *)&version;
+ tag[2][1] = version;
return make_duh(-1, 3, (const char *const(*)[2])tag, 1, &descptr,
&sigdata);
}
--- a/src/it/readstm.c
+++ b/src/it/readstm.c
@@ -397,7 +397,7 @@
version[8] = '0' + ((ver & 255) % 10);
version[9] = 0;
}
- tag[1][1] = (const char *)&version;
+ tag[1][1] = version;
return make_duh(-1, 2, (const char *const(*)[2])tag, 1, &descptr,
&sigdata);
}
--- a/src/it/readxm.c
+++ b/src/it/readxm.c
@@ -305,7 +305,6 @@
static int it_xm_make_envelope(IT_ENVELOPE *envelope,
const unsigned short *data, int y_offset) {
int i, pos, val;
-
if (envelope->n_nodes > 12) {
/* XXX
TRACE("XM error: wrong number of envelope nodes (%d)\n",
@@ -419,23 +418,23 @@
/* These two can be stubs since this implementation doesn't use seeking */
static int limit_xm_seek(void *f, dumb_off_t n) {
- (void)f;
- (void)n;
+ USED(f);
+ USED(n);
return 1;
}
static dumb_off_t limit_xm_get_size(void *f) {
- (void)f;
+ USED(f);
return 0;
}
DUMBFILE_SYSTEM limit_xm_dfs = {NULL,
- &limit_xm_skip,
- &limit_xm_getc,
- &limit_xm_getnc,
- &limit_xm_close,
- &limit_xm_seek,
- &limit_xm_get_size};
+ limit_xm_skip,
+ limit_xm_getc,
+ limit_xm_getnc,
+ limit_xm_close,
+ limit_xm_seek,
+ limit_xm_get_size};
static DUMBFILE *dumbfile_limit_xm(DUMBFILE *f) {
LIMITED_XM *lx = malloc(sizeof(*lx));
@@ -565,7 +564,6 @@
if (instrument->volume_envelope.flags & IT_ENVELOPE_ON)
return -1;
}
-
if (it_xm_make_envelope(&instrument->pan_envelope, pan_points, -32) !=
0) {
TRACE("XM error: pan envelope\n");
@@ -1424,7 +1422,7 @@
version[6] = hexdigit((ver >> 4) & 15);
version[7] = hexdigit(ver & 15);
version[8] = 0;
- tag[1][1] = (const char *)&version;
+ tag[1][1] = (const char *)version;
return make_duh(-1, 2, (const char *const(*)[2])tag, 1, &descptr,
&sigdata);
}
--- /dev/null
+++ b/src/plan9/assert.h
@@ -1,0 +1,1 @@
+#include "plan9.h"
--- /dev/null
+++ b/src/plan9/dumb.h
@@ -1,0 +1,1 @@
+#include "plan9.h"
--- /dev/null
+++ b/src/plan9/limits.h
@@ -1,0 +1,1 @@
+#include "plan9.h"
--- /dev/null
+++ b/src/plan9/malloc.h
@@ -1,0 +1,1 @@
+#include "plan9.h"
--- /dev/null
+++ b/src/plan9/math.h
@@ -1,0 +1,1 @@
+#include "plan9.h"
--- /dev/null
+++ b/src/plan9/plan9.h
@@ -1,0 +1,15 @@
+#ifndef __plan9_h__
+#define __plan9_h__
+
+#include <u.h>
+#include <libc.h>
+#include </sys/include/stdio.h>
+
+typedef long ssize_t;
+typedef ulong size_t;
+
+#define __attribute__(a)
+#define strcasecmp cistrcmp
+#define strncasecmp cistrncmp
+
+#endif
--- /dev/null
+++ b/src/plan9/signal.h
@@ -1,0 +1,1 @@
+#include "plan9.h"
--- /dev/null
+++ b/src/plan9/stdbool.h
@@ -1,0 +1,1 @@
+#include "plan9.h"
--- /dev/null
+++ b/src/plan9/stddef.h
@@ -1,0 +1,1 @@
+#include "plan9.h"
--- /dev/null
+++ b/src/plan9/stdint.h
@@ -1,0 +1,1 @@
+#include "plan9.h"
--- /dev/null
+++ b/src/plan9/stdio.h
@@ -1,0 +1,1 @@
+#include "plan9.h"
--- /dev/null
+++ b/src/plan9/stdlib.h
@@ -1,0 +1,1 @@
+#include "plan9.h"
--- /dev/null
+++ b/src/plan9/string.h
@@ -1,0 +1,1 @@
+#include "plan9.h"
--- /dev/null
+++ b/src/plan9/strings.h
@@ -1,0 +1,1 @@
+#include "plan9.h"
--- /dev/null
+++ b/src/plan9/sys/types.h
@@ -1,0 +1,1 @@
+#include "plan9.h"