MEMOTECH Centronics Type Parallel Printer Interface Hello User, With this pack we launch you into the world of commercial computer printing and out of the world of silver bus-tickets ! There are now a number of low-cost but powerful commercial printers on the market which can print 80 characters per line or more; we are making a substantial choice of them available with this interface. You can now print in upper or lower case, single or double width, in character o. graphics mode. Which printers can be used with the Centronics Interface? The first point to make is that "Centronics" refers not to the Centronics printers themselves but to the type of parallel interface common to Centronics and other printers. This has become an industry standard generally referred to as the 'Centronics Interface' and it works with most parallel interface printers. One parallel interface which is not of the Centronics type is the IEEE standard, of which the Commodore Pet printer's interface is the best known example. Our pack cannot be used for the iEEE type interface, but it makes available a good range of printers of the dotmatrix and daisy-wheel types. For the sake of clarityt all the examples in this booklet were written and tested on a Seikosha GP-100A dot-matrix printer. How do I set up the Centronics Interface pack? There's nothing to it. Place it behind your ZX81 and plug in. The larger connector is for a memory pack or other standard add-ons. The smaller connector is for the Centronics type printer. You should not try to run a ZX81 printer at the same time. You will have to connect the ribbon cable and plug you require. For a diagram illustrating the pin connections see the back of the booklet. It is also advisable to re-set the printer before running a program, or to include a blank LPRINT at the start. First, we'll talk about using LPRINT. The interface uses space addressed from 10K up and is therefore compatible with our Hi-Res Graphics pack. With a MEMOPAK 64K you will have to make sure switch 3 is OFF and operate in MODE B or D. Information about ZX81-ASCII conversion, lower-case, single and double width characters, graphics printing (for example with the MEMOPAK HRG) and COPY and LLIST functions comes later. How do I use LPRINT? LPRINT may be used in a number of ways, so we will talk about these separately. Note however that by consulting your printer manual you may find machine- specific ways to control your output. LPRINT with single strings and LET At the simplest level, you can LPRINT a line at a time, with each line set up in a string with a LET statement. It's best to set the printer initially with a blank LPRINT to clear the buffer. At the end, the print command (in this case for a Seikosha), will ensure that you have printed everything in your buffer. 10 LPRINT 20 LET X$= "DEAR JOHN," 30 LPRINT X$ 40 LET Y$ = "I HOPE YOU ARE WELL." 50 LPRINT Y$ 60 LPRINT CHR$ 155;"K" Lines of up to 80 characters can be printed in this way, and any longer strings will continue on the next line. Note. To ensure single spacing with more than 64 characters on a line, key in LPRINT Y$; CHR$ 155; "A" This will avoid a double line feed. Actually this example is a wasteful way of coding, because the LET statements cause the characters of the text to be stored twice - once in the instruction file and once in the array file. So let's try INPUT. LPRINT with single strings and INPUT INPUT allows you the freedom to decide your text as the program goes along. You need to let the program know when you are finished, so we will use an asterisk as terminator: 10 LPRINT 20 INPUT X$ 30 IF X$="*" THEN GOTO 60 40 LPRINT X$ 50 GOTO 20 60 LPRINT CHR$ 155; " K" LPRINT with a string table and INPUT From here it's a small step to setting up a whole page in your array. The advantage is that you can keep all your text lines simultaneously in memory, and so edit them later. Suppose you want to print 40 lines per page with up to 80 characters per line. 10 DIMX$(40,80) 20 LPRINT 30 PRINT"WHICH JOB?" 40 PRINT "1 = ENTER" 50 PRINT "2 = ALTER" 60 PRINT "3 = PRINT" 70 PRINT "4 = QUIT" 80 INPUT Y 90 CLS 100 IF Y = 1 THEN GOSUB 200 110 IF Y = 2 THEN GOSUB 300 120 IF Y = 3 THEN GOSUB 400 130 IF Y< >4 THEN GOTO 30 140 STOP 200 FOR X=1 TO 40 210 INPUT X$(X) 220 IF X$(X,1)="*" THEN GOTO 240 230 NEXT X 240 RETURN 300 PRINT"LINE NUMBER" 310 INPUT X 320 PRINT "NEW VERSION" 330 INPUT X$(X) 340 CLS 350 RETURN 400 FOR X = 1 TO 40 410 IF X$(X,1 ) = "*" THEN GOTO 440 420LPRINT X$(X); CHR$ 155;"A"; 430 NEXT X 440 LPRINT CHR$ 155; "K" 450 RETURN LPRINT with a giant single string An excellent method is to set up all your text as one long string. The value of this is that you can use the Sinclair EDIT functions to give yourself a simple word processing capability for a whole page. So if you take out or put in an early word in the text, the rest of the text will move along to accommodate the change. The text can also be chopped up for you into sausage-lengths as required. In this case you may also like to include in your program a routine which will prevent your words being split up in an unreadable way. Try the following program. 10 LET X$= "TEXT ETC" 20 PRINT "ENTER MAXIMUM LINE LENGTH " 30 INPUT Z 40 CLS 50 LPR I NT 60 IF LEN X$>Z THEN GOTO 100 70 LPRINT X$; 80 LPRINT CHR$ 155; "K" 90 STOP 100 LET Y = 0 110 IF Y = Z THEN GOTO 60 120 LET Y$= X$(Z-Y) 130 IF X$(Z+1-Y) =" " OR X$(Z+1-Y) = "inv " OR Y$="," OR Y$="." OR Y$=";" OR Y$="?" OR Y$=CHR$11 THEN GOTO 170 140 LET Y=Y+ 1 150 GOTO 110 160 LET Y=0 170 LPRINT X$(TO Z-Y); CHR$ 155;"A" 180 LET X$ = X$(Z + 1-Y TO) 190 IF X$(1) = " " OR X$(1)="inv "THEN LET X$= X$(2 TO) 200 GOTO 60 Why not adapt this program to handle multi-page texts? LPRINT with TAB The problem with TAB is that it still reduces the column number modulo 32 (divides by 32 and takes the remainder). If you would like to TAB a higher column number, split your TAB functions into two or more, bein careful not to use a column number above 31. So, to get the equivalent o TAB 40 you could key in: LPRINT TAB 31; TAB 9; "HELLO USER" Well, no doubt you can think of other ways to tailor a program to suit your needs. Will the pack automatically convert from ZX81 code to ASCII code? Yes. See back of the booklet for conversion tables for both normal or inverse characters. Can I use the Sinclair COPY and LLIS functions without any special routines? Yes. Naturally these will only take up the leftmost 32 print positions, unless you use the double-width character option (see below). Can l print in lower-case? Yes. The inverse alpha characters of the Sinclair set will appear on the printed output as lower-case. To save changing mode for the spaces between words, the Sinclair 'inverse' space is printed out as an ordinary blank space. Can I print double-size characters? Yes. It will be necessary to precede your Sinclair instructions with the appropriate control code. For example with a Seikosha, Epsom or NEC printer you could use: LPRINT CHR$ 155; "E" To return to single-size characters use the control characters CHR$ 155 "F". Other printers may have different control codes. What is ASCII? ASCII stands for the American Standard Code for Information Interchange and is the code expected by commercial printers. For example the byte code 65 will cause the printer to print "A"; 66 will cause "B" etc. See table at the back of the booklet. Exceptionally, the ZX81 has its own code which is not directly compatible with ASCII printers. Does the Memopak Centronics Interface provide automatic conversion? Yes. It will convert to most of the standard characters, including all alpha-numerics (including lower-case) and most symbols. Lower-case characters can be obtained from the ZX81 inverse alpha character set. Standard symbols not available in the ZX81 code can be obtained by referring to the required output symbol on the conversion table. For example to print "'Hello User!" you would need to key in LPRINT "H{inv}E{inv}L{inv}L{inv}O U{inv}S{inv}E{inv}R{inv}?" What about control codes? ASCII codes 0-31 are usually used as control codes (e.g. carriage return, line feed etc). These control codes need to be sent to the printer in a different format. So to send ASCII code 10 (LF) you would need to key: LPRINT CHR$ 155;"A"' as shown in the table. Similarlyr to send ASCII 27 (ESC) and ASCII 10 (LF) you need: LPRINT CHR$ 155;"R"; CHR$ 155; "A" CHR$ 155 tells the conversion routine that we are dealing with a control code not a literal character. Using control characters without affecting the print-line Normally, using a semi-colon or a comma after these LPRINT statements has the same effect as any other LPRINT statement. That is to say, a carriage return or TAB will be automatically generated. You may wish to send control codes but avoid the generation of a carriage return or TAB. In this case, you can terminate the sequence of control characters with a double CHR$ 155: 10 LPRINT CHR$ 155 ; "E";CHR$ 155; CHR$ 155 20 LPRINT "ABC" CHR$ 155;"E" in line 10 tells a Seikosha and similarly organised printers to print in double-width characters. Normally a carriage return would be generated since there is no comma or semi-colon, but in this case only ASCII code 14 is sent to the printer to be followed by "ABC". Warning: when using any of the CHR$ 155 functions, both characters must be in the Sinclair buffer at the same ti e. J st occasionalIy when the buffer is full the pair will be split between buffers and in this case the function will not work. How can I send code to the Printer without converting it to ASCII? There is an alternative way of sending code to the printer. In the example, we're going to send the message "HELLO BADGER". '8 BADGERt' will be sent in the usual way, but it will be preceded by the "HELLO" sent in the alternative way. For the new method, the numeric code must be POKEd into a REM statement which must be the first line in the program. 16514 is always the first byte following a first REM statement in a program. The sequence of numbers being POKEd must be terminated by a zero. 10 REM AAAAAA 20 POKE 16514,72 30 POKE 16515,69 40 POKE 16516,76 50 POKE 16517,76 60 POKE 16518,79 70 POKE 16519,0 80 LPRINT CHR$ 6; " BADGER" The POKE statements replace the A's In the REM statement with the code values for the string '"HELLO". This code is then sent to the printer by the graphics control character CHR$ 6 (found on the T key). This method is especially useful for sending the machine-specific codes which are associated with values above 127. These will differ from printer to printer and you will need to consult your printer manual. Remember, however, that the Sinclair printer buffer isn't necessarily transferred to the printer at each LPRINT statement. To ensure printing of characters the double CHR$ 155 terminator should be used: 10 REM AA 20 POKE 16515, 0 30 FOR X = 32 TO 255 40 POKE 16514,X 50 LPRINT CHR$ 6; CHR$ 155; CHR$ 155 60 NEXT X I've also got the Memopak HRG There are some functions in the MEMOPAK Centronics Interface fimware which are for use with the MEMOPAK High Resolution Graphics Pack. If you want to print out the contents of an HRG video page you need to code as follows: 10 LET V = 19000 20 LPRINT CHR$ 155; "8" 30 LPRINT CHR$ 136 40 LPRINT CHR$ 155; "F" V is the parameter variable for the start of the video page in memory, as described in the MEMOPAK HRG booklet. CHR$ 155; "8" informs the Seikosha printer that it is now to print in graphics mode. CHR$ 136 tells it to print out a video page. CHR$ 155; "F" returns it to normal printing mode. There is another speciaI function which is a general purpose HRG printing routine. It allows all or part of an HRG page to be printed on any graphics printer. It requires six parameters: V = Start address of video page. X = Horizontal HRG co-ordinate in range 0-247 of the top left-hand corner of block to be printed.This value will automatically be rounded to the start of the byte area in which it falls. Y = Vertical HRG co-ordinate in range 0-191 of the top left-hand corner of the block to be printed, counted from base of screen. E = Width of the block to be printed in bytes, range 1-32. S = Number of horizontal dot-lines to be printed (counting down from and including Y). Maximum value is the number of dots in depth of the graphics characters of the particular printer - probably 6, 7 or 8 (7 for Seikosha). Q = Constant that needs to be added to a code to produce the graphics character, usually 0, 32 or 128 (seikosha = 128). The special character is CHR$ 137, so your code might be, after setting the parameters: 100 LPRINT CHR$ 155; "8" 110 LPRINT CHR$ 137 120 LPRINT CHR$155; "F" With this function, no carriage return is generated and so it is possible to mix HRG graphics and Sinclair output on the same line. Note. You may find it quicker to use the graphics character instead of the CHR$ + value mode. For example, LPRINT "inv.K" instead of LPRINT CHR$ 155; "K". A table of those used in this booklet appears below. However, the use of these characters will prevent the normal functioning of LLIST and COPY, since they will activate the printer. CHR$ 155 CHR$ 6 CHR$ 136 CHR$ 137 MEMOTECH CONNECTOR /STROBE 1 2 TO GND DATA1 3 4 TO GND DATA2 5 6 TO GND DATA3 7 8 TO GND DATA4 9 10 TO GND DATA5 11 12 TO GND DATA6 13 14 TO GND DATA7 15 16 TO GND DATA8 17 18 TO GND /ACK 19 20 TO GND BUSY 21 22 TO GND NC 23 24 TO GND NC 25 26 NC NC 27 28 /ERROR NC 29 30 GND GND 31 32 NC GND 33 34 NC A typical Commercial Printer Connector Seikosha GP100-A Use a connector, AMP CHAMP 36 BAIL LOCK TYPE, to input data into the Printer. Pin configuration and its signals of the receptacle in left rear of the Printer are described below. Pins 18 and 36 are not linked. \ 18.................1 / \ / \ 36................19 / PIN SIGNAL PIN SIGNAL 1 STROBE 19 TGP(PAIR WITH 1 PIN) 2 DATA 1 20 TGP(PAIR WITH 2 PIN) 3 DATA 2 21 TGP(PAIR WITH 3 PIN) 4 DATA 3 22 TGP(PAIR WITH 4 PIN) 5 DATA 4 23 TGP(PAIR WITH 5 PIN) 6 DATA 5 24 TGP(PAIR WITH 6 PIN) 7 DATA 6 25 TGP(PAIR WITH 7 PIN) 8 DATA 7 26 TGP(PAIR WITH 8 PIN) 9 DATA 8 27 TGP(PAIR WITH 9 PIN) 10 ACK 28 TGP(PAIR WITH 10 PIN) 11 BUSY 29 TGP(PAIR WITH 11 PIN) 12 GND 30 GND 13 NC 31 /INITIAL (PAIR WITH 14 PIN) 14 GND 32 /ERROR (PAIR WITH 15 PIN) 15 GND 33 GND 16 GND 34 /CLK (PAIR WITH 33 PIN) 17 CHASSIS GND 35 /TEST (PAIR WITH 16 PIN) l8 + 5V 80mA Max. 36 + 5V NOTES: 1. The combined output of pins 18 and 36 is 80 mA maximum. 2. NC stands for no connection. 3. TPG stands for twisted pair ground. Connecting the MEMOPAK to the printer The most convenient cable is an Insulation Displacement Cable (IDC) ribbon made up as in the diagram above, where: A is a 36-way delta-type plug to the printer (3M part number 336S1001) B is a 34-way low profile header socket to the MEMOPAK interface (3M part number 3414-6000) The ribbon cable is 34-way with pins 18 and 36 omitted on plug A. Socket B is connected to J1 on the Centronics Interface ( pin 1 to pin 1). Plug A is connected to the printer. The above configuration gives a tidy connection which allows other packs to plug on the back with the ribbon cable passing beneath them.