TS2068 Tape Formats

See all articles from QZX v11 n4
Author(s): Alex Burr (K5XY)
Publication: QZX
Pub Details: QZX v11 n4 (Volume 11, Issue 4)
Date: March 1993
Pages: 5-7

Tape I/O is done via Port 0FEH. An I/O read of Port 0FEH pulls in the cassette input on Bit 6. An I/O write of Port 0FEH Bit 3 controls the tape output with Bit 3 = 1 genrating a high output and Bit 3 = 0 generating a low output.

Data is written to the tape under software control creating the following frequencies and format:

  • Sync Pattern of 4032 cycles at 806.5 Hz. (5 sec.)
  • Header: 17 bytes of data identifying the following data block as either Program, Number Array, Character Array, or Binary Code and containing other control information.

The header is written as Data, i.e. the Most Significant Bit first in each byte, 1 cycle at 2040 Hz. for a Zero and 1 cycle at 1020 Hz. for a One. The first byte is zero identifying the header. The final byte is a Checksum calculated by XOR of all preceding data bytes.

  • Software delay of approximately 835 milliseconds.
  • Sync Pattern of 1612 cycles at 806.5 Hz. (2 secs.)
  • Transition Pattern of 1 cycle at 2400 Hz.
  • Data Block: Written as Data (see above) with first byte = -1 (FFH) and a final Checksum byte.

The Figure shows the header formats for the various types of data.

The routines used to actually write and read the tape (W_TAPE and R_TAPE) are in the TAPE Module of the Extension ROM (see map in Appendix A). They are accessible via the Extension ROM Interface Routine listed in Figure 3.2.2-2. The general flow required to write a header and data block is:

1. Call W_TAPE with A=0. IX contains the address of the header and DE contains the length.
2. Delay loop approximately 1 second.
3. Call W__TAPE with A=FFH. IX contains the address of the data block and DE contains the length.

The R_TAPE routine performs either a LOAD (transfers data from tape to memory) or VERIFY (compare data from tape against data in memory) operation, based on the status at entry: Carry Set for Load and No Carry if Verify. As for the Write, A=Block Type (0 for Header and -1 (FFH) for Data Block). IX contains the memory address.

The tape routines return Carry=1 for successful completion and No Carry for error or Break Key detected. Both W_TAPE and R_TAPE exit via the routine W_BORD which restores the Border color based on bits 3-5 of the system variable BORDCR. If the Break Key is detected during this exit routine, a RESTART 8 (ERROR) is executed.

NOTE: The write to Port 0FEH in the exit routine restoring the Border Color has bit 3 = 0. This creates a final transition on the tape following a write operation. This transition is necessary in order to successfully read back the final data bit from some tape recording devices. If you are calling the W_TAPE routine so as to bypass the normal exit path, you must perform this final write to Port 0FEH with Bit 3 = 0 within a similar timeframe.

TAPE HEADER FORMATS

                HDTYPE(1)  HDNAME(10)   HDLEN          HDADD           HDVARS
                                        (LSB/MSB)      (LSB/MSB)       (LSB/MSB)

PROGRAM            0       Up to 10     Length of      Starting        Length of Pro-
                           ASCII Chars. Program        Line No.        gram = Offset
                                        + Variables    or 8000H        to Variables)
                                        (E_LINE -      E.G.:           (VARS) - (PROG)
                                        (PROG)         0500=Line 5
                                                       or 0080H if
                                                       no Line No.

NO.ARRAY           1          "         Length         LSB=00          N/A(=0)
                                        Field from     MSB=Array ID
                                        Data           7..........0
                                        Structure      100 . . . . .
                                                          (ASCII -
                                                           60H)

CHAR.ARRAY         2          "         Length         LSB=00          N/A(=0)
                                        Field from     MSB=Array ID
                                        Data           7..........0
                                        Structure      110 . . . . .
                                                          (ASCII -
                                                           60H)

CODE (BINARY)      3          "         Length         Address         N/A (=0)
                                        Specified      Specified
                                        in SAVE        in SAVE

Source: TS2068 Technical Manual