From 0327cf8217900174041d4f14a19aace4098dd8a6 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sat, 12 Nov 2011 21:19:25 +0100 Subject: Initial import --- .gitignore | 3 + Makefile | 12 +++ maestropond.c | 282 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 297 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 maestropond.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f6f12a9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +maestropond +maestropond.o + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..facb0e4 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +OBJS=maestropond.o + +maestropond: ${OBJS} + gcc -g ${OBJS} -o maestropond + +maestropond.o: maestropond.c + gcc -g -W -Wall -c maestropond.c -o maestropond.o + +clean: + rm -f ${OBJS} maestropond + +.PHONY: clean diff --git a/maestropond.c b/maestropond.c new file mode 100644 index 0000000..0ac0de6 --- /dev/null +++ b/maestropond.c @@ -0,0 +1,282 @@ +/* + * maestropond.c + * + * Convert Acorn Maestro files to LilyPond files + * + * (c) 2011 Thomas White + * + */ + + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +static void show_syntax(const char *s) +{ + printf("Syntax: %s [options]\n", s); +} + + +static void show_help(const char *s) +{ + show_syntax(s); + printf( +"\nConvert Acorn Maestro files to LilyPond files.\n" +"\n" +" -h, --help Display this help message.\n" +"\n" +); +} + + +static unsigned int get_basic_int(unsigned char *f, size_t *pptr) +{ + unsigned int v; + size_t ptr = *pptr; + int sig; + + v = 0; + sig = f[ptr++]; + if ( sig != 0x40 ) { + fprintf(stderr, "Not a BASIC integer (sig %i, val %i)\n", + sig, v); + goto out; + } + + v += f[ptr++] << 24; + v += f[ptr++] << 16; + v += f[ptr++] << 8; + v += f[ptr++]; + +out: + *pptr = ptr; + return v; +} + + +static size_t process_music_data(unsigned char *f, size_t ptr, size_t len) +{ + unsigned int n_gates; + unsigned int i; + unsigned int lengths[8]; + + n_gates = get_basic_int(f, &ptr); + printf("%i gates\n", n_gates); + + for ( i=0; i<8; i++ ) { + lengths[i] = get_basic_int(f, &ptr); + printf("Channel %i, length %i\n", i+1, lengths[i]); + } + + for ( i=0; i= argc ) { + show_syntax(argv[0]); + return 1; + } + + infile = argv[optind++]; + printf("Input: '%s'\n", infile); + convert_file(infile); + + return 0; +} -- cgit v1.2.3