ref: 1ea45f339a2046b608a05417c2a124eedd82f384
parent: f4bd018e6acf92993397223e2d2fffff1dd1dbdb
author: kemal <kemalinanc8@gmail.com>
date: Fri Apr 23 17:31:01 EDT 2021
very simple amiga mod parser
--- a/README.md
+++ b/README.md
@@ -16,6 +16,7 @@
| IT | yes | no | ??? |
| XM | yes | no | ??? |
| S3M | yes | no | ??? |
+| MOD | yes | no | ??? |
| replay gain | yes | no | ??? |
| size | tiny | bloated | more bloated |
| license | MIT | LGPL | LGPL/MPL |
--- a/mkfile
+++ b/mkfile
@@ -16,6 +16,7 @@
vorbis.$O\
wav.$O\
xm.$O\
+ mod.$O\
HFILES=\
/sys/include/tags.h\
--- /dev/null
+++ b/mod.c
@@ -1,0 +1,46 @@
+#include "tagspriv.h"
+
+/* insane. */
+static char* variants[] =
+{
+ "M.K.",
+ "M!K!",
+ "M&K!",
+ "N.T.",
+ "NSMS",
+ "FLT4",
+ "M\0\0\0",
+ "8\0\0\0",
+ "FEST",
+ "FLT8",
+ "CD81",
+ "OCTA",
+ "OKTA",
+ "16CN",
+ "32CN",
+ nil,
+};
+
+int
+tagmod(Tagctx *ctx)
+{
+ char d[20+1];
+ int i;
+
+ if (ctx->seek(ctx, 1080, 0) != 1080)
+ return -1;
+ if (ctx->read(ctx, d, 4) != 4)
+ return -1;
+ for (i = 0; ; i++)
+ if (variants[i] == nil)
+ return -1;
+ else if (memcmp(d, variants[i], 4) == 0)
+ break;
+ memset(d, 0, sizeof d);
+ if (ctx->seek(ctx, 0, 0) != 0)
+ return -1;
+ if (ctx->read(ctx, d, 20) != 20)
+ return -1;
+ txtcb(ctx, Ttitle, "", d);
+ return 0;
+}
--- a/tags.c
+++ b/tags.c
@@ -18,6 +18,7 @@
extern int tagvorbis(Tagctx *ctx);
extern int tagwav(Tagctx *ctx);
extern int tagxm(Tagctx *ctx);
+extern int tagmod(Tagctx *ctx);
static const Getter g[] =
{
@@ -31,6 +32,7 @@
{tagit, Fit},
{tagxm, Fxm},
{tags3m, Fs3m},
+ {tagmod, Fmod},
};
void
--- a/tags.h
+++ b/tags.h
@@ -35,6 +35,7 @@
Fit,
Fxm,
Fs3m,
+ Fmod,
Fmax,
};