ZX Interface-1: Connection and Design

ZX Revija #04

ZX Hardware: ZX Interface-1

Interface-1 connects to the user port at the back of the computer. In addition, the Interface is mechanically attached with several screws. Installed this way, Interface-1 sits underneath the computer, causing the back of the computer to be raised slightly.

The keyboard will sit at a slight angle, making typing easier. The Microdrive connects to the Interface on the left, using a short ribbon cable. For these expansions to work, the computer’s operating system had to be extended. This additional ROM is built into Interface-1.

It contains an 8 KB ROM and a special integrated circuit, the ULA, which controls the operation of the whole assembly. The new, additional ROM contains a program for interpreting new commands. The new commands are:

CAT, ERASE, FORMAT, SAVE!, LOAD!, VERIFY!, MERGE!, OPEN#, CLOSE#, MOVE, CLS#, CLEAR#.

Although these commands are present on the keyboard, a computer with the original ROM does not recognize them.

The additional ROM works in parallel with the original. It occupies the address space from 0 to 8191. Only one of them can be active at a time: either the original 16K ROM or the additional 8K ROM. The logic built into the Interface itself determines which ROM should be active by monitoring the state of the address bus and the M1 line. The additional ROM can be active only in the following cases:

  • If the RST 8 instruction is executed (in machine code) in the original 16K ROM, followed by an error code. (As you probably know, this is where the routine for analyzing the error code begins, and printing the error message on the screen based on that code.) If you try to execute the command CAT 1 from BASIC without Interface-1 connected, for example, you will get the error message:
0 Invalid stream, 0:1

However, if Interface-1 and a Microdrive are connected, this will not happen; instead, the contents of the Microdrive cartridge’s catalogue will be displayed on the screen.

What actually happened, which you could not follow with your own eyes? First, an error occurred because the original ROM does not recognize this command. The ROM was about to report the error using RST 8. The address decoder in Interface-1 detected this, switched off the original ROM, thereby preventing the error from being displayed, and at the same instant switched on the additional ROM. The error code was analyzed there, and the operating system determined that this was no longer an error but a legal command. The program cleared the error indicator and handed control to the command’s execution routine.

At the end of the routine, control is passed back to the original ROM.

  • If the CLOSE routine in the original ROM, at address 5896, transfers control to the additional ROM, the execution routine in this ROM cannot work with commands used by Interface-1. Control never remains in the additional ROM permanently. After the new command has been executed, control returns to the original ROM by jumping to address 1792.

Interface-1, like the Spectrum, underwent several modifications and improvements as its designers corrected errors in the ROM of earlier versions. As a result, some routines became considerably faster. Programmers using these routines in their programs should take this into account, since the addresses of most routines have also changed.

Interface-1 also has a built-in RS 232 interface for exchanging data with a printer. RS 232 enables serial data transmission.

One byte of data sent or received via RS 232 contains:

  • one start bit
  • eight data bits
  • two stop bits

The standard transmission speed ranges from 50 to 19200 bits per second. After the computer is switched on, it is automatically set to 9600 bit/sec.

Sir Clive Sinclair would not be Sir Clive if he had not made an exception when designing Interface-1, too. Namely, its serial output is non-standard.

The difference between the standard and serial outputs on Interface-1 lies in two details.

ZX Hardware: ZX Interface-1

First, a minor deviation is the use of a non-standard nine-pin connector instead of the standard 25-pin one.

Second, the signal levels at the input and output are non-standard. Because of these deviations, only the signals strictly required for correct data transmission and reception are used.

This part of the Interface-1 is used mainly for sending data to a printer with a serial input. It can also be used to connect to other computers and devices that have a serial input/output for sending data. The Spectrum can use two channels. The first is the text channel (/T or t channel/), and the second is the binary channel (/B or b channel/).

Channel /T/ is used mainly for sending data to a printer. You can use channel /B/ to connect to other computers and devices that have a serial input/output.

This routine does not change the codes it sends. The Spectrum sends data over the RX DATA line if the DTR line is at a high level. Data is received over the TX DATA line if the CTS line is at a high level.

A high level means that the logical state of the line is 1, that is, the voltage on the corresponding lines is equal to or greater than 2.8 V.

Local Area Network (LAN)

The Spectrum is connected to the network using the two connectors on the I-1 and the appropriate cable. In this network, computers exchange data at a speed of 4 Kb/sec. They also share connected peripherals (Microdrive, printer, disk drives, etc.). The maximum number of computers in the network is 64.

Each computer in the network has an identification number and priority, which you must set yourself. Connecting the I-1 to the Spectrum also causes some changes in the system variables area. Starting at address 23734, another 58 bytes are added for the I-1 to operate, as well as two bytes at locations 23728 and 23729, which are free on an unexpanded computer.

Streams and Channels

A part of the system to or from which data can be sent or received is called a channel (screen output, keyboard input). However, data is sent or received through a stream. We denote it with the # sign (HASH MARK, or popularly, “pound sign”). A Spectrum without an I-1 has three channels available from BASIC. A channel is identified by a single letter. The channels available from BASIC are:

  • K — connected to the keyboard and the lower part of the screen.
  • S — connected to the upper part of the screen.
  • P — connected to the ZX Printer.

A channel can also be used for two-way data transfer: for the same channel, we can connect both an input and an output device.

If we expand the system with an I-1, we have four more channels:

  • M or m — for the Microdrive
  • N or n — for the local network
  • B or b / T or t — for RS 232

The Spectrum has 16 streams available from BASIC, four of which are automatically connected to specific channels. After switching on the power or executing the NEW command, they look like this:

STREAM  CHANNEL  OUTPUT       INPUT
0       K         lower screen keyboard
1       K         lower screen keyboard
2       S         upper screen none
3       P         ZX Printer   none

Streams 0 and 1 are permanently connected to channel K. They read characters from the keyboard or send characters to the lower part of the screen (error messages).

Stream 2 sends characters (writes) to the upper part of the screen.

Stream 3 sends characters to the printer. There is no input on streams 2 and 3.

If you enter the command:

INPUT #3;Ač

You will get the error message:

INVALID I/O DEVICE

The commands of the expanded system are:

CAT, ERASE, FORMAT, SAVE!, LOAD!, VERIFY!, MERGE!, OPEN#, CLOSE#, MOVE, CLS#, CLEAR#

The CAT and ERASE commands can only be used when working with the Microdrive. The FORMAT, SAVE!, LOAD!, VERIFY! and MERGE! commands can be used with all three devices.

The OPEN# command connects a stream to a channel and has the following syntax:

ZX Hardware: ZX Interface-1

Fragment 3/3.

OPEN #S,C$ where: S is the stream number (0–15), C$ is the channel letter (K-S-P-M-N-B-T).

The MOVE # command has the following syntax:

MOVE #S TO D

where S and D are stream designators, and MOVE is a BASIC keyword. This command reads one character from stream S and sends it to stream D.

This cycle is repeated as long as there is data in stream S, or until an error occurs.

You can simulate a typewriter with the following command:

MOVE #0 TO #2

The following BASIC program replaces the previous command:

100 IF INKEY$<>"" THEN GO TO 100
110 IF INKEY$="" THEN GO TO 110
120 PRINT INKEY$;
130 GO TO 100

You can stop the above program (and command) with BREAK only when the screen is completely full and the SCROLL? message appears.

CLS # is a new BASIC command. It works just like the old CLS command, but also sets the attributes to:

INK 0:PAPER 7:BORDER 7:
INVERSE 0:BRIGHT 0:OVER 0:
FLASH 0

The # character must be typed separately after the CLS command.

Prepared by:

Brada Jožef
Bajmočka 18
24220 čantivar

Share your thoughts about the article