diff --git a/.gitignore b/.gitignore index fe93128..3d3cb35 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.tap -*bin -*bincs +*.block +body +header ttttt diff --git a/Makefile b/Makefile index d255a68..69235f3 100644 --- a/Makefile +++ b/Makefile @@ -2,15 +2,15 @@ program.tap: header.block body.block cat header.block body.block > program.tap header.block: header ttttt - ./ttttt header + ./ttttt header header header: header.asm body.block pasmo header.asm headerlong - dd if=headerlong of=header bs=18 count=1 + dd if=headerlong of=header bs=17 count=1 rm -f headerlong body.block: body ttttt - ./ttttt body + ./ttttt body data body: remload.asm code.asm pasmo remload.asm body diff --git a/header.asm b/header.asm index 6d13bfa..468b85c 100644 --- a/header.asm +++ b/header.asm @@ -1,6 +1,3 @@ -headerflag: - db 0 - blocktype: db 0 ;basic program diff --git a/remload.asm b/remload.asm index 14eaae6..07640dd 100644 --- a/remload.asm +++ b/remload.asm @@ -1,7 +1,5 @@ -org #5cca +org #5ccb -bodyformat: - db #ff linenumber: db #00 ;MSB db #00 ;LSB diff --git a/ttttt.c b/ttttt.c index 60c81cc..aded03f 100644 --- a/ttttt.c +++ b/ttttt.c @@ -15,13 +15,31 @@ int main(int argc, char *argv[]) int fdin, fdout; char outfilename[PATH_MAX]; unsigned int count = 0; + unsigned char flagopt = 0; unsigned char tally = 0; unsigned char next = 0; - if (argc!=2) { + if ((argc<2) || (argc>3)) { printf("Please specify file to read.\n"); return -1; } + if (3==argc) { + if (!strcmp(argv[2], "header")) flagopt = 1; + if (!strcmp(argv[2], "data")) flagopt = 2; + if (!flagopt) { + printf("Optional flags are \"header\" or \"data\"\n"); + return -1; + } + } + + if (! flagopt) { + printf("*** WARNING ***\n"); + printf("*** ttttt is running in RAW mode.\n"); + printf("*** Have you manually included the format flag as the first byte of the block?\n"); + printf("*** If not, run again passing 'header' or 'data' as the second parameter.\n"); + printf("*** WARNING ***\n\n"); + } + fdin = open(argv[1], O_RDONLY); if (fdin<0) { printf("Couldn't open %s. for reading\n", argv[1]); @@ -49,10 +67,18 @@ int main(int argc, char *argv[]) }; lseek(fdin, 0, SEEK_SET); + if (flagopt) count++; + char lsb = (count+1)&255; char msb = ((count+1)>>8)&255; write(fdout, &lsb, 1); write(fdout, &msb, 1); + next = 0; + if (flagopt == 2) next = 255; + if (flagopt) { + write(fdout, &next, 1); + tally ^= next; + } while (read(fdin, &next, 1)) { write(fdout, &next, 1); } @@ -62,8 +88,8 @@ int main(int argc, char *argv[]) close(fdin); printf("File %s written.\n", outfilename); - printf("Code length including first byte is %d (0x%.4X).\n", count, count); - printf("Removing first byte gives 0x%.4X.\n", count-1); + count--; + printf("Code length is %d (0x%.4X).\n", count, count); return 0; }