1
/* This program converts a gt7 magtape dump to a SIMH magtape
3
Copyright (c) 2002, Robert M. Supnik
5
Permission is hereby granted, free of charge, to any person obtaining a
6
copy of this software and associated documentation files (the "Software"),
7
to deal in the Software without restriction, including without limitation
8
the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
and/or sell copies of the Software, and to permit persons to whom the
10
Software is furnished to do so, subject to the following conditions:
12
The above copyright notice and this permission notice shall be included in
13
all copies or substantial portions of the Software.
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
Except as contained in this notice, the name of Robert M Supnik shall not
23
be used in advertising or otherwise to promote the sale, use or other dealings
24
in this Software without prior written authorization from Robert M Supnik.
32
unsigned char fzero[4] = { 0 };
34
int dump_rec (FILE *of, int bc, char *buf)
38
if (((bc == 1) && (buf[0] == 0xF)) ||
39
((bc == 2) && (buf[0] == 0xF) && (buf[1] == 0xF))) {
40
fwrite (fzero, sizeof (char), 4, of);
43
buc[1] = (bc >> 8) & 0xFF;
44
buc[2] = (bc >> 16) & 0xFF;
45
buc[3] = (bc >> 24) & 0xFF;
46
fwrite (buc, sizeof (char), 4, of);
47
fwrite (buf, sizeof (char), (bc + 1) & ~1, of);
48
fwrite (buc, sizeof (char), 4, of);
52
int main (int argc, char *argv[])
54
int i, ch, bc, rc, fc;
55
unsigned char buf[FLPSIZ];
56
char *ppos, oname[256];
59
if ((argc < 2) || (argv[0] == NULL)) {
60
printf ("Usage is: verb file [file...]\n");
63
for (i = 1; i < argc; i++) {
64
strcpy (oname, argv[i]);
65
if (ppos = strrchr (oname, '.')) strcpy (ppos, ".tap");
66
else strcat (oname, ".tap");
67
ifile = fopen (argv[i], "rb");
69
printf ("Error opening file: %s\n", argv[i]);
71
ofile = fopen (oname, "wb");
73
printf ("Error opening file: %s\n", oname);
76
printf ("Processing file %s\n", argv[i]);
77
for (bc = rc = fc = 0;;) {
82
if (dump_rec (ofile, bc, buf))
83
printf ("End of file %d\n", ++fc);
84
else printf ("Record %d size %d\n", ++rc, bc);
87
buf[bc++] = ch & 0x3F;
90
if (bc) dump_rec (ofile, bc, buf);
91
fwrite (fzero, sizeof (char), 4, ofile);
92
printf ("End of file %d\n", ++fc);