From: Alan Cox Date: Sun, 14 Dec 2014 23:04:43 +0000 (+0000) Subject: mtx512: Add tools for converting fuzix fs images into mfloppy disk format X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=8e3235c9f459da99385a9c2b8faad397ff1ef1f0;p=FUZIX.git mtx512: Add tools for converting fuzix fs images into mfloppy disk format --- diff --git a/Standalone/Makefile b/Standalone/Makefile index c94072fa..51b375e2 100644 --- a/Standalone/Makefile +++ b/Standalone/Makefile @@ -1,6 +1,6 @@ CC=gcc CCOPTS=-O2 -g -Wall -Wno-char-subscripts -Wno-deprecated-declarations -TARGETS=mkfs fsck ucp +TARGETS=mkfs fsck ucp raw2mfloppy UTILS=util.o devio.o xfs1.o xfs1a.o xfs1b.o xfs2.o all: $(TARGETS) @@ -17,5 +17,8 @@ fsck: fsck.o util.o ucp: ucp.o $(UTILS) $(CC) $(CCOPTS) -o $@ $< $(UTILS) +raw2mfloppy: raw2mfloppy.o + $(CC) $(CCOPTS) -o $@ $< + %.o: %.c $(CC) $(CCOPTS) -c -o $@ $< diff --git a/Standalone/raw2mfloppy.c b/Standalone/raw2mfloppy.c new file mode 100644 index 00000000..d0c31ad9 --- /dev/null +++ b/Standalone/raw2mfloppy.c @@ -0,0 +1,55 @@ +/* + * Shuffle a disk into the right order + * + * Converts the output of tools like ufs into an MTX512 mfloppy virtual + * disk (or vice versa) + */ +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + char buf[8192]; /* 16 sectors */ + int track; + int side; + int in, out; + + if (argc != 3) { + fprintf(stderr, "%s: in out\n", argv[0]); + exit(1); + } + + in = open(argv[1], O_RDONLY); + if (in == -1) { + perror(argv[1]); + exit(1); + } + out = open(argv[2], O_WRONLY|O_CREAT|O_TRUNC, 0666); + if (out == -1) { + perror(argv[2]); + exit(1); + } + + for (side = 0; side < 2; side++) { + for (track = 0; track < 40; track++) { + if (lseek(in, 16384 * track + 8192 * side, 0) == -1) { + perror(argv[1]); + exit(1); + } + if (read(in, buf, 8192) != 8192) { + perror(argv[1]); + exit(1); + } + if (write(out, buf, 8192) != 8192) { + perror(argv[2]); + exit(1); + } + } + } + close(in); + close(out); + exit(0); +}