Add support for MTM modules.

git-svn-id: https://svn.eduke32.com/eduke32@6475 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2017-10-15 23:09:59 +00:00
parent a14d427359
commit 64d76db260
5 changed files with 36 additions and 9 deletions

View File

@ -59,6 +59,7 @@ libxmplite_objs := \
itsex.c \
it_load.c \
mod_load.c \
mtm_load.c \
s3m_load.c \
sample.c \
xm_load.c \

View File

@ -216,10 +216,10 @@ LIBXMPLITE_OBJS=$(LIBXMPLITE_OBJ)\control.$o \
$(LIBXMPLITE_OBJ)\itsex.$o \
$(LIBXMPLITE_OBJ)\it_load.$o \
$(LIBXMPLITE_OBJ)\mod_load.$o \
$(LIBXMPLITE_OBJ)\mtm_load.$o \
$(LIBXMPLITE_OBJ)\s3m_load.$o \
$(LIBXMPLITE_OBJ)\sample.$o \
$(LIBXMPLITE_OBJ)\xm_load.$o
$(LIBXMPLITE_OBJ)\xm_load.$o \
AUDIOLIB_OBJS=$(AUDIOLIB_OBJ)\drivers.$o \
$(AUDIOLIB_OBJ)\fx_man.$o \

View File

@ -249,7 +249,7 @@ int32_t MV_PlayXMP3D(char *ptr, uint32_t ptrlength, int32_t loophow, int32_t pit
#endif
// KEEPINSYNC libxmp-lite/src/loaders/*_load.c
// KEEPINSYNC libxmp-lite/src/*_load.c
static int it_test_memory(char const *ptr, uint32_t ptrlength)
{
@ -312,10 +312,33 @@ static int xm_test_memory(char const *ptr, uint32_t ptrlength)
return 0;
}
static int mtm_test_memory(char const *ptr, uint32_t ptrlength)
{
static char const mtm_magic[] = "MTM\x10";
if (ptrlength < sizeof(mtm_magic)-1 ||
memcmp(ptr, mtm_magic, sizeof(mtm_magic)-1))
return -1;
return 0;
}
int MV_IdentifyXMP(char const *ptr, uint32_t ptrlength)
{
return it_test_memory(ptr, ptrlength) == 0 ||
mod_test_memory(ptr, ptrlength) == 0 ||
s3m_test_memory(ptr, ptrlength) == 0 ||
xm_test_memory(ptr, ptrlength) == 0;
static decltype(mod_test_memory) * const module_test_functions[] =
{
it_test_memory,
mod_test_memory,
s3m_test_memory,
xm_test_memory,
mtm_test_memory,
};
for (auto const test_module : module_test_functions)
{
if (test_module(ptr, ptrlength) == 0)
return 1;
}
return 0;
}

View File

@ -31,21 +31,23 @@ extern const struct format_loader libxmp_loader_xm;
extern const struct format_loader libxmp_loader_mod;
extern const struct format_loader libxmp_loader_it;
extern const struct format_loader libxmp_loader_s3m;
extern const struct format_loader libxmp_loader_mtm;
extern const struct pw_format *const pw_format[];
extern const struct format_loader *const format_loader[];
const struct format_loader *const format_loader[5] = {
const struct format_loader *const format_loader[] = {
&libxmp_loader_xm,
&libxmp_loader_mod,
#ifndef LIBXMP_CORE_DISABLE_IT
&libxmp_loader_it,
#endif
&libxmp_loader_s3m,
&libxmp_loader_mtm,
NULL
};
static const char *_farray[5] = { NULL };
static const char *_farray[sizeof(format_loader)/sizeof(struct format_loader *)] = { NULL };
const char **format_list()
{

View File

@ -50,6 +50,7 @@ struct mtm_instrument_header {
static int mtm_test(HIO_HANDLE *, char *, const int);
static int mtm_load(struct module_data *, HIO_HANDLE *, const int);
extern const struct format_loader libxmp_loader_mtm;
const struct format_loader libxmp_loader_mtm = {
"Multitracker",
mtm_test,