Machine Language Program to Read T/S 2068 Tape Headers

Author(s): Ed Shaughnessy
Pub Details: Time Designs Magazine v2 n4 (Volume 2, Issue 4)
Date: May/June 1986
Pages: 24-25

The T/S 2068 program presented here reads the header of a program or code that is stored on tape, and tells what command was used to save it. Suppose you have a BASIC program on tape that was saved for automatic start. This program will tell you at what line number the program will begin execution when it is loaded. Or suppose, you have a machine language routine on tape. This program will tell you its length and what location it was saved from. In each case, the information is shown by displaying the complete command that was used when the SAVE was done.

When the BASIC program shown in the listing is run for the first time, it saves itself and then saves machine language code it has created. You can then rewind the tape, and run the program so it will read the headers of its own two backups. In this way, the program demonstrates itself.

Let’s look at the program. Line 20 calls the subroutine that POKE’s the machine language program into RAM. Line 40 saves the BASIC program. Notice that it is saved so that it will automatically start at line 90 when it is loaded. Line 60 saves the machine language code. Line 110 and 120 will repeatedly execute the ML program that finds and reads header information. At this point, when you are running the program for the first time, rewind the tape and press the play button. Press any key to continue execution of the ML program. Soon you will see the familiar loading pattern on your screen. Eventually the following will be displayed:

SAVE "HEADER" LINE 90
SAVE "HEADER"CODE 40000,176

Compare these lines with lines 40 and 60 in the program, the two lines that did the saves. Press BREAK to terminate or the program will continue to search for another header.

You now have two versions of the program on tape; the BASIC program and the ML program. In the future, the quickest way to investigate a tape is to load just the ML program.

LOAD "HEADER" CODE

Since you are not specifying any location or length, it will be loaded into the location it was saved from. Execute the machine language code.

RANDOMIZE USR 40000

A message will prompt you to start playing the tape that contains the program you wish to investigate. Then press any key so the ML routine will continue execution. The program will read the tape until it finds the first header. It will display the command that was used to do the SAVE and then it will terminate. The 17 bytes of the header area will be in a workspace in RAM, starting at location 40200. You may examine this area with HOT Z or PEEK into it with a BASIC program.

Page 237 of the T/S 2068 User’s Manual shows the different formats of the SAVE command. Notice on page 238, that the result SAVE filename CODE 16384,6912 was actually accomplished with the command SAVE filename SCREEN$. For a detailed explanation of what information is contained in the tape header, see P.H. Skipper‘s article in Vol.3 No.2 issue of SyncWare News.

As long as your computer is in T/S 2068 mode, you can use this program to read Spectrum tapes as well as 2068 tapes. If you have the SOFTAID tape, try that. If you encounter strange results, it is due to copy protection schemes. To search through an entire tape, you may find it more convenient to load the BASIC program, since it will continue reading successive headers on a tape until you press BREAK.

  10 REM THIS TS2068 PROGRAM CREATES AN ML ROUTINE TO READ TAPE HEADERS. IT WILL READ A TAPE CONTAINING A PROGRAM OR CODE AND TELL WHICH FORMAT OF THE "SAVE" COMMAND (PAGE 237 OF THE USER'S MANUAL) WAS USED.
20 GO SUB 200
30 PRINT "Prepare to save BASIC program"
40 SAVE "HEADER" LINE 90
50 CLS : PRINT "Prepare to save ML code"
60 SAVE "HEADER"CODE 40000,176
70 CLS : PRINT "Rewind the tape and press PLAY."
80 GO TO 100
90 CLS : GO SUB 200
100 PRINT " (Press BREAK when finished)"
110 RANDOMIZE USR 40000: PRINT
120 RANDOMIZE USR 40014: PRINT : GO TO 120
200 LET CSUM=0
210 FOR I=40000 TO 40175
220 READ X: POKE I,X: LET CSUM=CSUM+X
230 NEXT I
240 DATA 62,253,205,48,18,17,137,60,205,63
250 DATA 7,205,217,17,219,255,203,255,211,255
260 DATA 219,244,50,195,92,62,1,211,244,221
270 DATA 33,8,157,221,229,17,17,0,175,55
280 DATA 205,252,0,221,225,48,242,58,195,92
290 DATA 211,244,219,255,203,191,211,255,62,254
300 DATA 205,48,18,221,229,225,126,254,0,40
310 DATA 14,254,3,40,27,17,168,60,205,63
320 DATA 7,205,190,156,201,205,183,156,126,230
330 DATA 192,192,62,32,215,17,13,1,205,215
340 DATA 156,201,205,183,156,17,190,0,205,215
350 DATA 156,62,44,215,43,205,228,156,201,175
360 DATA 17,226,1,205,63,7,62,32,215,62
370 DATA 34,215,6,10,35,126,254,32,40,3
380 DATA 215,16,247,62,34,215,38,157,46,22
390 DATA 201,175,229,205,63,7,225,62,32,215
400 DATA 205,228,156,201,70,43,78,229,205,233
410 DATA 48,205,161,49,225,201
420 IF CSUM<>23687 THEN PRINT "Error in DATA statements": STOP
430 RETURN

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.