Your Spectrum
Issue 1, January 1984 - Communications
Home Contents KwikPik
Communication is a two way process. If you want to communicate through your Spectrum you'll have to find out how it 'talks' to the outside world - a world made up of local (in-house) communication and distant (tele) communication. Over to John McNulty.
If you want to take the 'easy' way out and run the risk of ripoffs, then ignore this article. If you really want to 'know' then you'll need to put in a little effort to get a great deal out - communications people have generated jargon which is daunting. Newcomers try to fake their way through, so terms become degenerate and no one knows for certain what someone means when they use a 'standard' name for an interface or a device. There's no quick way round this primary communications problem. I can offer you a guide - the Datacomms mini-Bible - but you'll still have to work at it if you want to succeed in communications.
This is the land of LANs ( local area networks ), line drivers and base band modems. The simplest link is point-to-point, and anything else - tree and branch, ring or star - is much more complicated. One thing is certain, the cost of installing the cabling ( not the cost of the cable itself) is high. Another problem is interference - any kind of wire is acting as an aerial and will pick up all sorts of rubbish you never asked for (screened cable is a partial answer). Finally, you can bet on McNulty's 5th Law of Communications: "The more complex the net, the greater the probability of an extremely simple result - zero".
Those of you who now wish to boldly split infinitives and tele-trek out amongst the networks definitely need McNulty's 'Glitch-Hiders Guide to the Galaxy'. But beware the bit-battering BT Beastie, with more heads than arms. At the far end of the tele universe are rare delights, treasure houses of information, the fabled electronic mail, new friends and Richard (Micronet) Hease.
Between you and those riches is a living, twitching nervous system.
When you pick up your phone, thousands of robots dance to your digit's bidding. The swift swirl of your finger will send them scurrying, sometimes falling over in their enthusiasm, to connect you to the number of your choice. It's a noisy voice network and it's a tribute to the power of the human brain that you are able to understand the degraded voice signal which reaches your ear. Your computer isn't as bright as you and doesn't have a 'voice'. To give it a
McNulty's 5th Law of

"The more complex the net, the greater the probability of an extremely simple result - zero. "

'voice' which will carry, you have to give it a translator which converts bits into whistles and back again. This device is known as a modulator/demodulator - or modem. Modems have to conform to certain standards (CCITT and BT) and have to have a standard data interface. The interface into which you poke your signals and from which you get them out again is known by most as the RS232 - or CCITT V24 (more of which later).
There is another interface and that's the connection to the telephone line. The PO monopoly hasn't really gone away yet and there are still stringent regulations about what you can connect and how. There are two methods of connection: by direct connect - just
plugging straight into the phone; and acoustic coupling - sending the whistles into the mouth-piece and picking out the returning whistles with a little microphone stuck to the earpiece. You still need BT approval for this - in case your computer says "Boo" and frightens Buzby. Acoustic coupling is 'kludgy' and capricious. The telephone transmitter (microphone to you, sack of coal to me - no, I'm not kidding) distorts the signal. The returning signal is mixed with local noise which your microphone picks up - it's marginally better than a forked stick. The only good thing about acoustic coupling is that you don't have to worry about how to connect (unless you come across a funny phone).
Direct connect is far superior. Not only is your data cleaner but you can run faster, and more important, you can start to do clever tricks like automatic answering and dialling. The connection is very simple if you have a BT jack socket and even simpler (ie. dispensing with a team of union engineers) if you haven't since it involves connecting two wires.
Interface 1 is a module which connects the Spectrum to the outside world. There are two 'portals' (disregarding the Microdrive which it also controls). One is a local area network interface, the other is an RS232 interface.
With Interface 1, using the leads supplied you can connect to up to 64 Spectrums. You can share programs, data and devices so that one person could have a posh printer, one a set of Microdrives and so on. Messages can be sent from any one station to any other, or they can be broadcast. The printer server program allows one Spectrum on the net to control an RS232 printer. This printer can then be used by all the

other computers on the net (for a group which has one higher quality printer to share).
All simple symbols (letters, digits, etc) and compound tokens (keywords, function names, etc) can be sent and received by the RS232 interface to and from any compatible serial device (eg. printers, modems, or other RS232 interfaces connected to other kinds of computers). The Spectrum RS232 uses two different channels - the T (or text) channel for sending listings, and the B (or binary) channel for sending the full 8-bit codes used by the the Spectrum, so you can send control codes for printers and so on.
The bit (or baud) rate can be set to any speed from 50 to 19200 bits per second (although 19.2K bit modems are slightly thin on the ground). For more detailed information about this, see "Broadening your communications Spectrum" at the end of this article.
Richard (Micronet) Hease has been doing his bit to try and rescue Prestel. He's ofFering a specially adapted V23 modem and software to connect to Micronet. Micronet is Prestel for micro users. The most ambitious project is the downloading of software. This sounds great but ... if you go on-line, you will catch occasional glitches - character errors. If you know of any randomly fault tolerant software, please let me know. There are special error catching schemes, but then, there's also this ship called the Titanic ...
The rest of Micronet seems fine but you need to check the real costs of online browsing.
Micro-Myte is something you myte come across, and 'myte' is the operative word. It mite be useful and it myte work. However, calling it a modem myte even nibble at trades description. Micro-Myte is totally non-standard (and possibly non-approvable), uses the tape recorder outputs on your machine, uses the most precarious acoustic coupler I've ever seen, and inspires great confidence by saying that it operates in simplex mode (actually it's half duplex). One other minor point - you'll only be able to ring up someone else who's bought another Micro-Myte, so no global connections for you.
The great thing about modems in general is to learn before you buy. Failing that, check if your
intended purchase is compatible with the system you want to call up. Make sure it can operate in call (originate) and answer modes (some cheapos only do one - which is OK so long as you know the limitations). Check the speed and frequencies because you can't just stick go-faster stripes on.
Lastly, it's worth mentioning that the RS232 is actually the EIA RS232C and is an American interface standard. It's near as dammit international equivalent is the CCITT V24/28. There are 25 pins on the usual interface but not all of them are used. The interface is supposed to be standard but most manufacturers have their own idiosyncrasies.
If you ask me nicely I'll send you a list of the standard connections with a diagram, and further McNulty info from the Datacomms mini-Bible will explain the CCITT 'V' series and all the modem modulation schemes. SAEs all round, please.
Contact John McNulty via Interchange Ltd, xx xxx nnn, xxxxxxx nxx.
(An adventurer's guide to the Spectrum Interface 1 )

The network allows for the linking of 2-64 Spectrum computers. The linkage between computers is a two wire system - signal wire and ground wire. Each Spectrum constitutes a station and by using the FORMAT 'n';x command it is possible to assign the required station number (x) to a given computer. The range of station numbers is 1-64.
Data is transmitted and received on the network in packets. The transmit process is as follows:

1. Wait for the network to be free for between 2-3mS.
2. Try to claim the network by sending a 'scout' signal. Check that there is no contention. Repeat from (1) if there is a collision.
3. Send out a 'header' comprising eight
bytes of data (a copy of bytes 11-18 in the network channel area).
4. Wait for an acknowledgement. Repeat from (1) if nothing found with 1 mS.
5. Send out the data block comprising 1-255 bytes of data (a copy of the data buffer).
6. Wait for an acknowledgement. Repeat from (1) if nothing is found within 1 mS.

The receive process is as follows:

1. Wait for the network to be free for at least 2mS.
2. Wait for the network to become active ('scout').
3. Collect the 'header' block, compute the checksum and acknowledge if it is correct. Repeat from (1) if not. It is correct if it has the correct source and destination station numbers and has the correct sequence number.
4. Collect the data block, compute the checksum and acknowledge if correct. Repeat from (1) if not.

Messages may be broadcast to more than one station. The protocol is as above, but no acknowledgments are required. The receiver must be expecting a broadcast. A 'scout' and 'header' pair take about 1.6mS and are repeated about once every 8mS if not acknowledged. A 'scout', 'header' and data block containing 255 bytes takes about 37mS. Stations wait a random interval after the network has become free before transmitting packets. This scheme avoids time consuming collisions.
To make the job of writing application software easier, procedures in the new ROM have been made available. These are called with the following two byte call:


where N is the code for a particular procedure.

The procedures, their codes and parameters are described below. All registers are corrupted. If the procedure cannot complete the request or if it is interrupted (if the BREAK key is pressed) it makes an error return. This means that it loads SP from ERR SP and returns. This allows the caller to handle errors. The reader should note that the new system variables should be created before they can be set up prior to calling any procedure. This is achieved by calling procedure code 49 first. Register IY should point into the system variables at 5C3Ah when any of the procedures are called.

Console input (Code 27): This procedure waits for a character to be typed in on the Spectrum keyboard and returns it to the A register. Nothing is printed on the screen.
Console output (Code 28): This procedure prints the character in the A register in the upper part of the screen.
RS232 input (Code 29): This procedure waits for a character received on the RS232 serial interface. The baud rate is specified by BAUD in the system variables. The format is eight data bits, one stop bit. No framing error is generated if the stop bit is missing. The byte is returned in register A.
RS232 output (code 30): This procedure outputs the byte in A on to the RS232 serial interface. The baud rate is specified by BAUD in the system variables. The transmission format is eight data bits, two stop bits, no parity.
ZX printer output (code 31 ): This procedure outputs the byte in the A register to the ZX printer.
Keyboard test (code 32): This procedure tests to see if a key has been pressed. The carry flag is set if a character is available.
Open network channel (code 45): This procedure opens a network channel to the station whose number is stored in D_STR1. Our current station number should be stored in NTSTAT. A network area is created in CHANS; everything else in memory up to STKEND is pushed up. The address of the channel is returned to IX.
Close network channel (code 46): This procedure closes the network channel specified by IX. If the buffer contains data yet to be seen (NCOBL>0) then this is sent in a final packet before the channel is deleted.
Get packet (Code 47): This procedure gets the next packet for the network channel identified by IX. NCNUMB identifies the required block number. (Both this block and the previous one will be
acknowledged in case our acknowledgement to the last block was lost.) The procedure returns within 12mS if there is no packet available. If an appropriate packet arrives the procedure may take a further 37mS. If the procedure is waiting for a broadcast (NCIRIS=0) then it does not return until a packet is received. The carry flag is set if no packet is available or if the received packet was erroneous in some way. The packet 'header' and data block can be found in the channel starting at NCIRIS and NCB respectively. NCNUMB is incremented.
Send packet (Code 48): This procedure sends a packet from the network channel identified by IX. The number of bytes in the data buffer is specified by NCOBL (must be>0). The byte in A is stored in NCTYPE. NCNUMB is incremented. The procedure does not return until the packet has been sent and an acknowledgement received (no acknowledgement is necessary in the case of a broadcast, ie. NTDEST=0).
Create system variables (code 49): This procedure creates a space for and initialises the new system variables described above. This should be called before attempting to set up any of these variables prior to calling any of the above procedures.
When a stream is opened to the network a channel is created in the area designated CHANS in the Basic reference manual. This area is usually addressed by the IX register in the software. The channel has a length of 276 bytes. The con- tents of the channel are described as follows:
0 Address 8
2 Address 9
4 'N'
5 Address of output subroutine in ROM
7 Address of input subroutine in ROM
9 Address 276
11 NCIRIS The destination station number
12 NCSELF This is the Spectrum's station number
13 NCNUMB The block number
15 NCTYPE The packet type code ... 0 data, 1 EDF
16 NCOBL The number of bytes in the data block
17 NCDCS The data checksum
18 NCHCS The header checksum
19 NCBL The position of the last character taken from the buffer
20 NCB The number of bytes in the input buffer
21 A 255 byte data buffer
Temporary network channels are created and deleted afterwards during SAVE, LOAD, VERIFY and MERGE commands. They may also be created from machine code.
The Microdrive, LAN and RS232 software uses more system variables; these are described as follows:
23734FLAGS3 Flags
23735VECTOR Address used to extend the Basic interpreter
23737SBRT ROM paging subroutine
23747BAUD Two byte number determining the baud rate, calculated as follows: BAUD=(3500000/(26 x baud rate))-2
23749NTSTAT Own network station number 1-64
23750IOBORD Border colour used during I/0
23751SER_FL Two byte workspace used by RS232
23753SECTOR Two byte workspace used by Microdrive
23755CHADD_ Temporary store for CH_ADD
23757NTRESP Store for network response code
23758NTDEST Beginning of network buffer, contains destination station number 0-64
23759NTSRCE Source station number 1-64
23760NTNUMB Network block number 0-65535
23762NTTYPE Header type code
23763NTLEN Data block length 0-255
23764NTDCS Data block checksum
23765NTHCS Header block checksum
23766D_STR1 Start of eight byte file specifier, two byte drive number 1-8
23768S_STR1 Stream number 1-15
23769L_STR1 Device type ... 'M', 'N', 'T' or 'B'
23770N_STR1 Length of filename
23772 Start of filename
23774D_STR2 Second eight byte file specifier used by MOVE and LOAD commands
23782HD_00 Start of workspace for SAVE, LOAD, VERIFY and MERGE. Data type code
23783HD_0B Length of data 0-65535
23785HD_0D Start of data 0-65535
23787HD_0F Program length 0-65535
23789H_11 Line number
23791COPIES Number of copies made by next SAVE command
23792 Start of Microdrive MAPs or CHANS
Home Contents KwikPik