Many programs for the 2068 use MC to gain speed or functions not possible in BASIC–for example: “Flight Simulator” and “VU-File” as sold by Timex. It’s hard to make an archival copy of these programs (as approved by copyright laws) when they LOAD in several sections. Typically, these include a short, autorunning BASIC program to LOAD the remaining code and manage the housekeeping functions, then an MC section. Sometimes a title screen LOADs between the BASIC and MC. (Some also use two sequential BASIC loaders–KO)
Within the BASIC program, you often find a line like:
10 LOAD ""CODE
which LOADs the MC to the area from which it was SAVEd. To re-SAVE the MC, you need its start address and length in bytes.
Before each program, you find a 17-byte header that contains this information. A utility program to read this information would be very helpful. The UK magazine Sinclair User originally published a header utility, but it calls Spectrum ROM areas which differ from the 2068. I modified the program, guided by the 2068 Technical Manual, to call the read-tape routines of the 2068 extension ROM.
You can read Spectrum headers on your 2068 with this program, but the 2068 routine will not run on your Spectrum. See the notes to the assembly language listing for a machine-code routine for Spectrum computers.
According to section 4.2.1 of the 2068 Tech Manual, a 17-byte header is saved before each program SAVE. The first byte marks program type: 0 for BASIC, 1 for a numeric array, 2 for a string array, or 3 for machine code. Then 10 bytes contain the program name (that’s why you can have only 10 characters in a program name).
Bytes 12&13 represent the full length of the data to follow. They are recorded in routine fashion (byte 12+256*byte 13).
When the data reveal a BASIC program, then bytes 14&15 show the line number from which the program autoruns–if (byte 14+256*byte 15) is >0 and <9999. If the data is for MC, then (byte 14+256*byte 15) gives the start address of the code specified when it was SAVEd.
Bytes 16&17 reveal the BASIC program length without variables. (In terms of system variables, the value is VARS-PROG). These 2 bytes equal zero for all other possibilities.
Disassembly of the tape read routine reveals some interesting things. The IX register holds the address to which data is loaded from tape (starting at 64060 for this program). Since the Utility Function Dispatcher depends upon the IX register, we cannot call the tape routine via the UFD. Register DE holds the number of bytes to be loaded–011H=17D. Routines from FA0EH-FA34H are those given in the 2068 Technical Manual to call the read-tape area of extension ROM.
Our original goal was to make archival copies of MC programs. In all of the following LOAD and SAVE steps, stop the recorder as soon as you get the 0/0 or 0 OK report and remove or insert the tape without rewinding. This lets you make the copy section by section. To do so, perform the following steps:
1. RUN HEADSCAN and read the header information from the BASIC portion of your favorite program. This tells you the AUTO RUN line number of the BASIC.
Write this line number down.
2. Use HEADSCAN to read information from the header of the next part of the original program. This will usually be BYTES: “name”, then the data length, and start address. If the start address=16384 and data length=6912, then that code is a SCREEN$ (usually the title screen.) Write down the values for this part of your program to use in step 8.
3. Repeat step 2 for each part of your original program.
4. Type RAND USR 0 to completely reset your 2068.
5. Rewind your original MC program tape and type MERGE “” to load the BASIC portion of the program and block autorun. Stop the tape at the 0/0 code. Do not rewind.
6. Remove your original tape from the recorder and replace it with a rewound blank. Now you key in the command SAVE “name” LINE nn (where nn=autorun line number found in step 1). As soon as SAVE finishes, stop the recorder and remove the new tape without rewinding.
7. Replace the original tape in the recorder and load the code from the original by typing LOAD “” CODE. As soon as you get the 0/0 report at the bottom of your screen, stop the recorder and remove your original tape without rewinding.
8. Put the new tape in the recorder and save the code portion of your tape by typing:
SAVE "name" CODE aa,bb
where aa=start address and bb=data length from step 2. Stop the tape as soon as you get the 0 OK report. Remove your new tape. Don’t rewind.
9. Repeat steps 7 & 8 for each code section of your program.
After you complete these steps for each section of the original, rewind your copy. It should behave exactly as the original.
Careful reading of the TS2068 Technical Manual will reveal other information you could extract from the header, including variable names and sizes for arrays saved separately–KO.
LOAD A TAPE AND PRESS "PLAY" PROGRAM: header DATA LENGTH: 1233 AUTO START AT: 9970 PROG/VARS LENGTH: 1202 FOR ANOTHER TAPE, TOUCH ANY KEY
9970 CLEAR 63999: FOR a=64000 TO 64052: READ b: POKE a,b: NEXT a
9975 CLS : PRINT ''''"LOAD A TAPE AND PRESS ""PLAY"""''''
9980 DATA 55,62,0,221,33,60,250,17,17,0,205,14,250,201,33,252,0,205,34,250,58,33,250,211,244,219,255
9981 DATA 203,191,211,255,251,201,0,243,245,219,255,203,255,211,255,219,244,50,33,250,62,1,211,244,241,233
9982 RANDOMIZE USR 64000
9983 LET a=64060: LET b=PEEK a: LET s=b
9984 IF b=0 THEN PRINT "PROGRAM: ";
9985 IF b=1 THEN PRINT "NUMERIC ARRAY: ";
9986 IF b=2 THEN PRINT "CHARACTER ARRAY: ";
9987 IF b=3 THEN PRINT "BYTES: ";
9988 FOR a=64061 TO 64070: LET b=PEEK a: PRINT CHR$ b;: NEXT a: PRINT
9989 LET b=PEEK a+256*PEEK (a+1): PRINT "DATA LENGTH: ";b
9990 LET a=a+2: LET b=PEEK a+256*PEEK (a+1): IF s=3 THEN PRINT "START ADDRESS: ";b
9991 IF s<>0 THEN GO TO 9995
9992 IF b<1 OR b>9999 THEN GO TO 9994
9993 PRINT "AUTO START AT: ";b
9994 LET a=a+2: LET b=PEEK a+256*PEEK (a+1): PRINT "PROG/VARS LENGTH: ";b
9995 PRINT ''''"FOR ANOTHER TAPE, TOUCH ANY KEY"
9996 PAUSE 0: GO TO 9975
SYNTACTIC SUM: 63327, TS2068
ADDR HEXCODE LABEL MNEMONIC =========================== FA00 37 SCF FA01 3E00 LD A,00 FA03 DD213CFA LD IX,FA3C FA07 111100 LD DE,0011 FA0A CD0EFA CALL RTAP FA0D C9 RET FA0E 21FC00 RTAP LD HL,00FC FA11 CD22FA CALL IFRT FA14 3A21FA EXIT LD A,(HSAV) FA17 D3F4 OUT (F4),A FA19 DBFF IN A,(FF) FA1B CBBF RES 7,A FA1D D3FF OUT (FF),A FA1F FB EI FA20 C9 RET FA21 00 HSAV NOP FA22 F3 IFRT DI FA23 F5 PUSH AF FA24 DBFF IN A,(FF) FA26 CBFF SET 7,A FA28 D3FF OUT (FF),A FA2A DBF4 IN A,(F4) FA2C 3221FA LD (HSAV),A FA2F 3E01 LD A,01 FA31 D3F4 OUT (F4),A FA33 F1 POP AF FA34 E9 JP (HL)
In the machine code, the routine named IFRT calls the extension ROM as instructed in the 2068 Technical Manual, the code labelled RTAP says where to read the extension ROM.
Decimal addresses 64060 to 64076 contain the 17 bytes read from the header. You may PEEK them from those locations and examine them yourself.
To use the machine code on a Spectrum computer, change FA0AH to read CD5605, which calls 1366D, and forget all steps after FA0DH (=C9.) In the BASIC version, replace each number after the first 201 in line 9980 with either 201 or 0 (RETurn or NOP) and replace the first sequence 205,14,250,201 with the sequence 205,86,5,201. Line 9981 can be all 0’s. If your skill permits, you can shorten the code for the Spectrum dramatically.
Media
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.