Tape Header Reader

Date: 198x
Type: Program
Platform(s): TS 2068
Tags: Header

Tape Header Reader waits for you to start a tape and reads the next header block. For a BASIC program it shows the name, the program and variables lengths and the auto-start line; for code it shows the load address and length; arrays are named as numeric or character arrays. If the block it read was not a header it says so, and you can read another.

The program has no author’s name. It was on several of Bob Swoger’s disks.

Program Analysis

A 44-byte routine POKEd from DATA at 29000 switches in the TS2068’s extension ROM through ports 255 and 244, calls its tape-loading routine at 00FCh to read 17 bytes into a buffer at 29044, and switches the home ROM back. BASIC then decodes the buffer with DEF FN f(x)=PEEK x+256*PEEK (x+1).

Notable Techniques

  • The type byte is preset to 4 before reading, so a block that was not a header is recognised when it is still 4 afterwards.
  • The name is printed over a row of underscores with OVER 1.

This copy came from a Larken disk; only its disk save and menu lines were removed. Tested in ZEsarUX on a stock TS2068, reading BASIC and code headers.

Image Gallery

Source Code

   10 POKE 23658,0: BORDER 1: PAPER 1: INK 9: CLS 
   20 CLEAR 28999
   30 LET s=29000
   40 LET d=s+44
   50 DEF FN f(x)=PEEK x+256*PEEK (x+1)
   60 LET dh=INT (d/256)
   70 LET dl=d-256*dh
   80 DATA 175,55,221,33,116,113,17,17,0,243
   82 DATA 245,219,255,203,255,211,255,219,244,50
   84 DATA 115,113,62,1,211,244,241,205,252,0
   86 DATA 58,115,113,211,244,219,255,203,191,211
   88 DATA 255,251,201,0
   90 FOR n=0 TO 43: READ c: POKE s+n,c: NEXT n
  100 CLS 
  110 POKE d,4
  120 PRINT AT 10,8;"START THE TAPE-"
  130 RANDOMIZE USR s
  140 CLS 
  150 LET type=PEEK d: IF type=4 THEN GO TO 400
  160 LET a$=""
  170 FOR n=1 TO 10
  180 LET a$=a$+CHR$ PEEK (d+n)
  190 NEXT n
  200 PRINT "Name: __________"; OVER 1;AT 0,6;a$''
  210 LET len=FN f(d+11): LET start=FN f(d+13): LET pa=FN f(d+15)
  220 LET va=len-pa
  230 IF type THEN GO SUB 300: GO TO 410
  240 PRINT "Program type: BASIC."''
  250 PRINT "Program area: ";pa;"bytes."''
  260 PRINT "Variables area: ";va;" bytes."''
  270 IF start>9999 THEN PRINT "No auto-start.": GO TO 410
  280 PRINT "Auto-start at line ";start;"."
  290 GO TO 410
  300 LET t$="Code Block."
  310 IF type=1 THEN LET t$="Numerical Array."
  320 IF type=2 THEN LET t$="Character Array."
  330 PRINT "Program type: ";t$''
  340 IF type=3 THEN PRINT "Destination Address: ";start;"."''
  350 PRINT "Length: ";len;" bytes."
  360 RETURN 
  400 PRINT FLASH 1;AT 10,6;"THIS WAS NO HEADER!"
  410 PRINT AT 20,1;"Do you want another go (y/n)? "
  420 PAUSE 0: IF INKEY$="y" THEN GO TO 100
  430 STOP 
 9992 SAVE "HEADER.B1" LINE 10
 9998 CLEAR 6e4

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