Commit 8914e7b6 authored by Richard Gobeille's avatar Richard Gobeille
Browse files

Revert "Update libxmp-lite"

This reverts commit dd86318e.
parent 60625fb3
......@@ -74,7 +74,6 @@ libxmplite_objs := \
scan.c \
smix.c \
virtual.c \
win32.c \
xm_load.c \
libxmplite_root := $(source)/$(libxmplite)
......
......@@ -66,7 +66,6 @@
<ClCompile Include="..\..\source\libxmp-lite\src\scan.c" />
<ClCompile Include="..\..\source\libxmp-lite\src\smix.c" />
<ClCompile Include="..\..\source\libxmp-lite\src\virtual.c" />
<ClCompile Include="..\..\source\libxmp-lite\src\win32.c" />
<ClCompile Include="..\..\source\libxmp-lite\src\xm_load.c" />
</ItemGroup>
<PropertyGroup Label="Globals">
......
......@@ -149,8 +149,5 @@
<ClCompile Include="..\..\source\libxmp-lite\src\xm_load.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\source\libxmp-lite\src\win32.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
</Project>
......@@ -5,30 +5,30 @@
extern "C" {
#endif
#define XMP_VERSION "4.5.0"
#define XMP_VERCODE 0x040500
#define XMP_VERSION "4.4.2"
#define XMP_VERCODE 0x040402
#define XMP_VER_MAJOR 4
#define XMP_VER_MINOR 5
#define XMP_VER_RELEASE 0
#define XMP_VER_MINOR 4
#define XMP_VER_RELEASE 2
#if defined(_WIN32) && !defined(__CYGWIN__)
# if defined(BUILDING_STATIC)
# define LIBXMP_EXPORT
# define EXPORT
# elif defined(BUILDING_DLL)
# define LIBXMP_EXPORT __declspec(dllexport)
# define EXPORT __declspec(dllexport)
# else
# define LIBXMP_EXPORT __declspec(dllimport)
# define EXPORT __declspec(dllimport)
# endif
#elif defined(__OS2__) && defined(__WATCOMC__) && defined(__SW_BD)
# define LIBXMP_EXPORT __declspec(dllexport)
# define EXPORT __declspec(dllexport)
#elif (defined(__GNUC__) || defined(__clang__) || defined(__HP_cc)) && defined(XMP_SYM_VISIBILITY)
# define LIBXMP_EXPORT __attribute__((visibility ("default")))
# define EXPORT __attribute__((visibility ("default")))
#elif defined(__SUNPRO_C) && defined(XMP_LDSCOPE_GLOBAL)
# define LIBXMP_EXPORT __global
# define EXPORT __global
#elif defined(EMSCRIPTEN)
# define LIBXMP_EXPORT EMSCRIPTEN_KEEPALIVE
# define EXPORT EMSCRIPTEN_KEEPALIVE
#else
# define LIBXMP_EXPORT
# define EXPORT
#endif
#define XMP_NAME_SIZE 64 /* Size of module name and type */
......@@ -172,36 +172,35 @@ struct xmp_envelope {
};
struct xmp_subinstrument {
int vol; /* Default volume */
int gvl; /* Global volume */
int pan; /* Pan */
int xpo; /* Transpose */
int fin; /* Finetune */
int vwf; /* Vibrato waveform */
int vde; /* Vibrato depth */
int vra; /* Vibrato rate */
int vsw; /* Vibrato sweep */
int rvv; /* Random volume/pan variation (IT) */
int sid; /* Sample number */
int vol; /* Default volume */
int gvl; /* Global volume */
int pan; /* Pan */
int xpo; /* Transpose */
int fin; /* Finetune */
int vwf; /* Vibrato waveform */
int vde; /* Vibrato depth */
int vra; /* Vibrato rate */
int vsw; /* Vibrato sweep */
int rvv; /* Random volume/pan variation (IT) */
int sid; /* Sample number */
#define XMP_INST_NNA_CUT 0x00
#define XMP_INST_NNA_CONT 0x01
#define XMP_INST_NNA_OFF 0x02
#define XMP_INST_NNA_FADE 0x03
int nna; /* New note action */
int nna; /* New note action */
#define XMP_INST_DCT_OFF 0x00
#define XMP_INST_DCT_NOTE 0x01
#define XMP_INST_DCT_SMP 0x02
#define XMP_INST_DCT_INST 0x03
int dct; /* Duplicate check type */
int dct; /* Duplicate check type */
#define XMP_INST_DCA_CUT XMP_INST_NNA_CUT
#define XMP_INST_DCA_OFF XMP_INST_NNA_OFF
#define XMP_INST_DCA_FADE XMP_INST_NNA_FADE
int dca; /* Duplicate check action */
int ifc; /* Initial filter cutoff */
int ifr; /* Initial filter resonance */
int dca; /* Duplicate check action */
int ifc; /* Initial filter cutoff */
int ifr; /* Initial filter resonance */
};
struct xmp_instrument {
char name[32]; /* Instrument name */
int vol; /* Instrument volume */
......@@ -216,7 +215,7 @@ struct xmp_instrument {
signed char xpo; /* Instrument transpose for each key */
} map[XMP_MAX_KEYS];
struct xmp_subinstrument *sub;
struct xmp_subinstrument *sub;
void *extra; /* Extra fields */
};
......@@ -280,19 +279,18 @@ struct xmp_module_info {
};
struct xmp_channel_info { /* Current channel information */
unsigned int period; /* Sample period (* 4096) */
unsigned int position; /* Sample position */
short pitchbend; /* Linear bend from base note*/
unsigned char note; /* Current base note number */
unsigned char instrument; /* Current instrument number */
unsigned char sample; /* Current sample number */
unsigned char volume; /* Current volume */
unsigned char pan; /* Current stereo pan */
unsigned char reserved; /* Reserved */
struct xmp_event event; /* Current track event */
unsigned int period; /* Sample period (* 4096) */
unsigned int position; /* Sample position */
short pitchbend; /* Linear bend from base note*/
unsigned char note; /* Current base note number */
unsigned char instrument; /* Current instrument number */
unsigned char sample; /* Current sample number */
unsigned char volume; /* Current volume */
unsigned char pan; /* Current stereo pan */
unsigned char reserved; /* Reserved */
struct xmp_event event; /* Current track event */
};
struct xmp_frame_info { /* Current frame information */
int pos; /* Current position */
int pattern; /* Current pattern */
......@@ -319,52 +317,51 @@ struct xmp_frame_info { /* Current frame information */
typedef char *xmp_context;
LIBXMP_EXPORT extern const char *xmp_version;
LIBXMP_EXPORT extern const unsigned int xmp_vercode;
EXPORT extern const char *xmp_version;
EXPORT extern const unsigned int xmp_vercode;
LIBXMP_EXPORT xmp_context xmp_create_context (void);
LIBXMP_EXPORT void xmp_free_context (xmp_context);
EXPORT xmp_context xmp_create_context (void);
EXPORT void xmp_free_context (xmp_context);
#ifdef EDUKE32_DISABLED
LIBXMP_EXPORT int xmp_test_module (char *, struct xmp_test_info *);
LIBXMP_EXPORT int xmp_load_module (xmp_context, char *);
EXPORT int xmp_test_module (char *, struct xmp_test_info *);
EXPORT int xmp_load_module (xmp_context, char *);
#endif
LIBXMP_EXPORT void xmp_scan_module (xmp_context);
LIBXMP_EXPORT void xmp_release_module (xmp_context);
LIBXMP_EXPORT int xmp_start_player (xmp_context, int, int);
LIBXMP_EXPORT int xmp_play_frame (xmp_context);
LIBXMP_EXPORT int xmp_play_buffer (xmp_context, void *, int, int);
LIBXMP_EXPORT void xmp_get_frame_info (xmp_context, struct xmp_frame_info *);
LIBXMP_EXPORT void xmp_end_player (xmp_context);
LIBXMP_EXPORT void xmp_inject_event (xmp_context, int, struct xmp_event *);
LIBXMP_EXPORT void xmp_get_module_info (xmp_context, struct xmp_module_info *);
LIBXMP_EXPORT const char **xmp_get_format_list (void);
LIBXMP_EXPORT int xmp_next_position (xmp_context);
LIBXMP_EXPORT int xmp_prev_position (xmp_context);
LIBXMP_EXPORT int xmp_set_position (xmp_context, int);
LIBXMP_EXPORT int xmp_set_row (xmp_context, int);
LIBXMP_EXPORT int xmp_set_tempo_factor(xmp_context, double);
LIBXMP_EXPORT void xmp_stop_module (xmp_context);
LIBXMP_EXPORT void xmp_restart_module (xmp_context);
LIBXMP_EXPORT int xmp_seek_time (xmp_context, int);
LIBXMP_EXPORT int xmp_channel_mute (xmp_context, int, int);
LIBXMP_EXPORT int xmp_channel_vol (xmp_context, int, int);
LIBXMP_EXPORT int xmp_set_player (xmp_context, int, int);
LIBXMP_EXPORT int xmp_get_player (xmp_context, int);
LIBXMP_EXPORT int xmp_set_instrument_path (xmp_context, char *);
LIBXMP_EXPORT int xmp_load_module_from_memory (xmp_context, void *, long);
EXPORT void xmp_scan_module (xmp_context);
EXPORT void xmp_release_module (xmp_context);
EXPORT int xmp_start_player (xmp_context, int, int);
EXPORT int xmp_play_frame (xmp_context);
EXPORT int xmp_play_buffer (xmp_context, void *, int, int);
EXPORT void xmp_get_frame_info (xmp_context, struct xmp_frame_info *);
EXPORT void xmp_end_player (xmp_context);
EXPORT void xmp_inject_event (xmp_context, int, struct xmp_event *);
EXPORT void xmp_get_module_info (xmp_context, struct xmp_module_info *);
EXPORT const char**xmp_get_format_list (void);
EXPORT int xmp_next_position (xmp_context);
EXPORT int xmp_prev_position (xmp_context);
EXPORT int xmp_set_position (xmp_context, int);
EXPORT void xmp_stop_module (xmp_context);
EXPORT void xmp_restart_module (xmp_context);
EXPORT int xmp_seek_time (xmp_context, int);
EXPORT int xmp_channel_mute (xmp_context, int, int);
EXPORT int xmp_channel_vol (xmp_context, int, int);
EXPORT int xmp_set_player (xmp_context, int, int);
EXPORT int xmp_get_player (xmp_context, int);
EXPORT int xmp_set_instrument_path (xmp_context, char *);
EXPORT int xmp_load_module_from_memory (xmp_context, void *, long);
#ifdef EDUKE32_DISABLED
LIBXMP_EXPORT int xmp_load_module_from_file (xmp_context, void *, long);
EXPORT int xmp_load_module_from_file (xmp_context, void *, long);
#endif
/* External sample mixer API */
LIBXMP_EXPORT int xmp_start_smix (xmp_context, int, int);
LIBXMP_EXPORT void xmp_end_smix (xmp_context);
LIBXMP_EXPORT int xmp_smix_play_instrument(xmp_context, int, int, int, int);
LIBXMP_EXPORT int xmp_smix_play_sample (xmp_context, int, int, int, int);
LIBXMP_EXPORT int xmp_smix_channel_pan (xmp_context, int, int);
EXPORT int xmp_start_smix (xmp_context, int, int);
EXPORT void xmp_end_smix (xmp_context);
EXPORT int xmp_smix_play_instrument(xmp_context, int, int, int, int);
EXPORT int xmp_smix_play_sample (xmp_context, int, int, int, int);
EXPORT int xmp_smix_channel_pan (xmp_context, int, int);
#ifdef EDUKE32_DISABLED
LIBXMP_EXPORT int xmp_smix_load_sample (xmp_context, int, char *);
EXPORT int xmp_smix_load_sample (xmp_context, int, char *);
#endif
LIBXMP_EXPORT int xmp_smix_release_sample (xmp_context, int);
EXPORT int xmp_smix_release_sample (xmp_context, int);
#ifdef __cplusplus
}
......
/* Extended Module Player
* Copyright (C) 1996-2018 Claudio Matsuoka and Hipolito Carraro Jr
* Copyright (C) 1996-2016 Claudio Matsuoka and Hipolito Carraro Jr
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
......
......@@ -145,7 +145,10 @@ void __inline CLIB_DECL D_(const char *text, ...) { do {} while (0); }
#define close _close
#define unlink _unlink
#endif
#if defined(_WIN32) || defined(__WATCOMC__) /* in win32.c */
#if defined(_MSC_VER)
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#elif defined(__WATCOMC__) /* in win32.c */
int libxmp_vsnprintf(char *, size_t, const char *, va_list);
int libxmp_snprintf (char *, size_t, const char *, ...);
#define snprintf libxmp_snprintf
......@@ -293,40 +296,28 @@ struct module_data {
};
struct pattern_loop {
int start;
int count;
int start;
int count;
};
struct flow_control {
int pbreak;
int jump;
int delay;
int jumpline;
int loop_chn;
struct pattern_loop *loop;
int num_rows;
int end_point;
int rowdelay; /* For IT pattern row delay */
int rowdelay_set;
int pbreak;
int jump;
int delay;
int jumpline;
int loop_chn;
struct pattern_loop *loop;
int num_rows;
int end_point;
int rowdelay; /* For IT pattern row delay */
int rowdelay_set;
};
struct virt_channel {
int count;
int map;
};
struct virt_control {
int num_tracks; /* Number of tracks */
int virt_channels; /* Number of virtual channels */
int virt_used; /* Number of voices currently in use */
int maxvoc; /* Number of sound card voices */
struct virt_channel *virt_channel;
struct mixer_voice *voice_array;
int count;
int map;
};
struct player_data {
......@@ -351,7 +342,7 @@ struct player_data {
int master_vol; /* Music volume */
int gvol;
struct flow_control flow;
struct flow_control flow;
struct {
int time; /* replay time in ms */
......@@ -365,7 +356,16 @@ struct player_data {
int channel_vol[XMP_MAX_CHANNELS];
char channel_mute[XMP_MAX_CHANNELS];
struct virt_control virt;
struct virt_control {
int num_tracks; /* Number of tracks */
int virt_channels; /* Number of virtual channels */
int virt_used; /* Number of voices currently in use */
int maxvoc; /* Number of sound card voices */
struct virt_channel *virt_channel;
struct mixer_voice *voice_array;
} virt;
struct xmp_event inject_event[XMP_MAX_CHANNELS];
......
/* Extended Module Player
* Copyright (C) 1996-2018 Claudio Matsuoka and Hipolito Carraro Jr
* Copyright (C) 1996-2016 Claudio Matsuoka and Hipolito Carraro Jr
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
......@@ -174,37 +174,6 @@ int xmp_set_position(xmp_context opaque, int pos)
return p->pos;
}
int xmp_set_row(xmp_context opaque, int row)
{
struct context_data *ctx = (struct context_data *)opaque;
struct player_data *p = &ctx->p;
struct module_data *m = &ctx->m;
struct xmp_module *mod = &m->mod;
struct flow_control *f = &p->flow;
int pos = p->pos;
int pattern = mod->xxo[pos];
if (pos < 0 || pos >= mod->len) {
pos = 0;
}
if (ctx->state < XMP_STATE_PLAYING)
return -XMP_ERROR_STATE;
if (row >= mod->xxp[pattern]->rows)
return -XMP_ERROR_INVALID;
/* See set_position. */
if (p->pos < 0)
p->pos = 0;
p->ord = p->pos;
p->row = row;
p->frame = -1;
f->num_rows = mod->xxp[mod->xxo[p->ord]]->rows;
return row;
}
void xmp_stop_module(xmp_context opaque)
{
struct context_data *ctx = (struct context_data *)opaque;
......@@ -306,12 +275,12 @@ int xmp_channel_vol(xmp_context opaque, int chn, int vol)
}
#ifdef USE_VERSIONED_SYMBOLS
LIBXMP_EXPORT extern int xmp_set_player_v40__(xmp_context, int, int);
LIBXMP_EXPORT extern int xmp_set_player_v41__(xmp_context, int, int)
EXPORT extern int xmp_set_player_v40__(xmp_context, int, int);
EXPORT extern int xmp_set_player_v41__(xmp_context, int, int)
__attribute__((alias("xmp_set_player_v40__")));
LIBXMP_EXPORT extern int xmp_set_player_v43__(xmp_context, int, int)
EXPORT extern int xmp_set_player_v43__(xmp_context, int, int)
__attribute__((alias("xmp_set_player_v40__")));
LIBXMP_EXPORT extern int xmp_set_player_v44__(xmp_context, int, int)
EXPORT extern int xmp_set_player_v44__(xmp_context, int, int)
__attribute__((alias("xmp_set_player_v40__")));
asm(".symver xmp_set_player_v40__, xmp_set_player@XMP_4.0");
......@@ -424,14 +393,14 @@ int xmp_set_player__(xmp_context opaque, int parm, int val)
}
#ifdef USE_VERSIONED_SYMBOLS
LIBXMP_EXPORT extern int xmp_get_player_v40__(xmp_context, int);
LIBXMP_EXPORT extern int xmp_get_player_v41__(xmp_context, int)
EXPORT extern int xmp_get_player_v40__(xmp_context, int);
EXPORT extern int xmp_get_player_v41__(xmp_context, int)
__attribute__((alias("xmp_get_player_v40__")));
LIBXMP_EXPORT extern int xmp_get_player_v42__(xmp_context, int)
EXPORT extern int xmp_get_player_v42__(xmp_context, int)
__attribute__((alias("xmp_get_player_v40__")));
LIBXMP_EXPORT extern int xmp_get_player_v43__(xmp_context, int)
EXPORT extern int xmp_get_player_v43__(xmp_context, int)
__attribute__((alias("xmp_get_player_v40__")));
LIBXMP_EXPORT extern int xmp_get_player_v44__(xmp_context, int)
EXPORT extern int xmp_get_player_v44__(xmp_context, int)
__attribute__((alias("xmp_get_player_v40__")));
asm(".symver xmp_get_player_v40__, xmp_get_player@XMP_4.0");
......@@ -558,25 +527,3 @@ int xmp_set_instrument_path(xmp_context opaque, char *path)
return 0;
}
int xmp_set_tempo_factor(xmp_context opaque, double val)
{
struct context_data *ctx = (struct context_data *)opaque;
struct player_data *p = &ctx->p;
struct module_data *m = &ctx->m;
struct mixer_data *s = &ctx->s;
int ticksize;
if (val <= 0.0) {
return -1;
}
val *= 10;
ticksize = s->freq * m->time_factor * m->rrate / p->bpm / 1000 * sizeof(int);
if (ticksize > XMP_MAX_FRAMESIZE) {
return -1;
}
m->time_factor = val;
return 0;
}
/* Extended Module Player
* Copyright (C) 1996-2018 Claudio Matsuoka and Hipolito Carraro Jr
* Copyright (C) 1996-2016 Claudio Matsuoka and Hipolito Carraro Jr
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
......
/* Extended Module Player
* Copyright (C) 1996-2018 Claudio Matsuoka and Hipolito Carraro Jr
* Copyright (C) 1996-2016 Claudio Matsuoka and Hipolito Carraro Jr
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
......@@ -540,11 +540,9 @@ void libxmp_process_fx(struct context_data *ctx, struct channel_data *xc, int ch
#ifndef LIBXMP_CORE_DISABLE_IT
case FX_IT_BPM: /* Set IT BPM */
if (MSN(fxp) == 0) {
if (MSN(fxp) == 0) { /* T0x - Tempo slide down by x */
SET(TEMPO_SLIDE);
if (LSN(fxp)) /* T0x - Tempo slide down by x */
xc->tempo.slide = -LSN(fxp);
/* T00 - Repeat previous slide */
} else if (MSN(fxp) == 1) { /* T1x - Tempo slide up by x */
SET(TEMPO_SLIDE);
xc->tempo.slide = LSN(fxp);
......@@ -588,11 +586,8 @@ void libxmp_process_fx(struct context_data *ctx, struct channel_data *xc, int ch
xc->vol.fslide2 = -fxp;
break;
case FX_IT_BREAK: /* Pattern break with hex parameter */
if (!f->loop_chn)
{
p->flow.pbreak = 1;
p->flow.jumpline = fxp;
}
break;
#endif
......@@ -689,10 +684,10 @@ void libxmp_process_fx(struct context_data *ctx, struct channel_data *xc, int ch
EFFECT_MEMORY_S3M(fxp);
if (fxp) {
xc->retrig.val = fxp;
xc->retrig.type = MSN(xc->retrig.val);
}
if (note) {
xc->retrig.count = LSN(xc->retrig.val) + 1;
xc->retrig.type = MSN(xc->retrig.val);
}
SET(RETRIG);
break;
......
/* Extended Module Player
* Copyright (C) 1996-2018 Claudio Matsuoka and Hipolito Carraro Jr
* Copyright (C) 1996-2016 Claudio Matsuoka and Hipolito Carraro Jr
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
......
/* Extended Module Player
* Copyright (C) 1996-2018 Claudio Matsuoka and Hipolito Carraro Jr
* Copyright (C) 1996-2016 Claudio Matsuoka and Hipolito Carraro Jr
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
......
/* Extended Module Player
* Copyright (C) 1996-2018 Claudio Matsuoka and Hipolito Carraro Jr
* Copyright (C) 1996-2016 Claudio Matsuoka and Hipolito Carraro Jr
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
......@@ -42,22 +42,19 @@ const struct format_loader libxmp_loader_it = {
it_load
};
#ifndef LIBXMP_CORE_PLAYER /* */
#if defined(__WATCOMC__)
#undef localtime_r
#define localtime_r _localtime
#elif !defined(HAVE_LOCALTIME_R) || defined(_WIN32)
#undef localtime_r
#define localtime_r libxmp_localtime_r
static struct tm *libxmp_localtime_r(const time_t * timep, struct tm *result)
struct tm *localtime_r(const time_t * timep, struct tm *result)
{
/* Note: Win32 localtime() is thread-safe */
memcpy(result, localtime(timep), sizeof(struct tm));
return result;
}
#endif
#endif /* ! LIBXMP_CORE_PLAYER */
static int it_test(HIO_HANDLE * f, char *t, const int start)
{
......@@ -283,7 +280,14 @@ static int read_envelope(struct xmp_envelope *ei, struct it_envelope *env,
}
env->flg = buf[0];
env->num = MIN(buf[1], 25); /* Clamp to IT max */
env->num = buf[1];
/* Sanity check */
if (env->num >= XMP_MAX_ENV_POINTS) {
env->flg = 0;
env->num = 0;
return -1;
}
env->lpb = buf[2];
env->lpe = buf[3];
......@@ -1136,6 +1140,7 @@ static int it_load(struct module_data *m, HIO_HANDLE *f, const int start)
}
if (ifh.chpan[i] & 0x80) { /* Channel mute */
ifh.chvol[i] = 0;
xxc->flg |= XMP_CHANNEL_MUTE;
}
......@@ -1343,7 +1348,7 @@ static int it_load(struct module_data *m, HIO_HANDLE *f, const int start)
D_(D_INFO "Message length : %d", ifh.msglen);
for (j = 0; j + 1 < ifh.msglen; j++) {
for (j = 0; j < ifh.msglen - 1; j++) {
int b = hio_read8(f);
if (b == '\r') {
b = '\n';
......@@ -1355,7 +1360,7 @@ static int it_load(struct module_data *m, HIO_HANDLE *f, const int start)
}
if (ifh.msglen > 0) {
m->comment[j] = 0;
m->comment[j-1] = 0;
}
}
}
......
/* Extended Module Player
* Copyright (C) 1996-2018 Claudio Matsuoka and Hipolito Carraro Jr
* Copyright (C) 1996-2016 Claudio Matsuoka and Hipolito Carraro Jr
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
......