Compare commits

..

No commits in common. "main" and "v2.0" have entirely different histories.
main ... v2.0

6 changed files with 17 additions and 39 deletions

5
.gitignore vendored
View File

@ -1,5 +1,4 @@
*.tap *.tap
*.block *bin
body *bincs
header
ttttt ttttt

View File

@ -2,15 +2,15 @@ program.tap: header.block body.block
cat header.block body.block > program.tap cat header.block body.block > program.tap
header.block: header ttttt header.block: header ttttt
./ttttt header header ./ttttt header
header: header.asm body.block header: header.asm body.block
pasmo header.asm headerlong pasmo header.asm headerlong
dd if=headerlong of=header bs=17 count=1 dd if=headerlong of=header bs=18 count=1
rm -f headerlong rm -f headerlong
body.block: body ttttt body.block: body ttttt
./ttttt body data ./ttttt body
body: remload.asm code.asm body: remload.asm code.asm
pasmo remload.asm body pasmo remload.asm body

View File

@ -4,7 +4,7 @@ Sometimes it would be useful to run machine code directly from ZX BASIC without
This Makefile will generate a ZX BASIC .tap file with a REM statement containing the machine code, and will automatically run it. Simply amend the code in `code.asm` and run `make`. The file `program.tap` will be created which can be loaded in an emulator or real Spectrum. This Makefile will generate a ZX BASIC .tap file with a REM statement containing the machine code, and will automatically run it. Simply amend the code in `code.asm` and run `make`. The file `program.tap` will be created which can be loaded in an emulator or real Spectrum.
The included BASIC routine will CLEAR 32767 and set BORDER and PAPER to black and INK to white. Amend the `remload.asm` routine if this is not desired. The included BASIC routine will CLEAR 59999 and set BORDER and PAPER to black and INK to white. Amend the `remload.asm` routine if this is not desired.
## Requirements ## Requirements

View File

@ -1,3 +1,6 @@
headerflag:
db 0
blocktype: blocktype:
db 0 ;basic program db 0 ;basic program

View File

@ -1,5 +1,7 @@
org #5ccb org #5cca
bodyformat:
db #ff
linenumber: linenumber:
db #00 ;MSB db #00 ;MSB
db #00 ;LSB db #00 ;LSB
@ -31,10 +33,10 @@ ink:
db ':' db ':'
clear: clear:
db #fd, "32767" ;CLEAR 32767 - presumably code will be loaded somewhere? db #fd, "59999" ;CLEAR 59999 - presumably code will be loaded somewhere?
db #0e db #0e
db 0,0 db 0,0
dw 32767 dw 59999
db 0 db 0
db ':' db ':'

32
ttttt.c
View File

@ -15,31 +15,13 @@ int main(int argc, char *argv[])
int fdin, fdout; int fdin, fdout;
char outfilename[PATH_MAX]; char outfilename[PATH_MAX];
unsigned int count = 0; unsigned int count = 0;
unsigned char flagopt = 0;
unsigned char tally = 0; unsigned char tally = 0;
unsigned char next = 0; unsigned char next = 0;
if ((argc<2) || (argc>3)) { if (argc!=2) {
printf("Please specify file to read.\n"); printf("Please specify file to read.\n");
return -1; 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); fdin = open(argv[1], O_RDONLY);
if (fdin<0) { if (fdin<0) {
printf("Couldn't open %s. for reading\n", argv[1]); printf("Couldn't open %s. for reading\n", argv[1]);
@ -67,18 +49,10 @@ int main(int argc, char *argv[])
}; };
lseek(fdin, 0, SEEK_SET); lseek(fdin, 0, SEEK_SET);
if (flagopt) count++;
char lsb = (count+1)&255; char lsb = (count+1)&255;
char msb = ((count+1)>>8)&255; char msb = ((count+1)>>8)&255;
write(fdout, &lsb, 1); write(fdout, &lsb, 1);
write(fdout, &msb, 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)) { while (read(fdin, &next, 1)) {
write(fdout, &next, 1); write(fdout, &next, 1);
} }
@ -88,8 +62,8 @@ int main(int argc, char *argv[])
close(fdin); close(fdin);
printf("File %s written.\n", outfilename); printf("File %s written.\n", outfilename);
count--; printf("Code length including first byte is %d (0x%.4X).\n", count, count);
printf("Code length is %d (0x%.4X).\n", count, count); printf("Removing first byte gives 0x%.4X.\n", count-1);
return 0; return 0;
} }