File Name: SPIN:D Documentation on the Spinwriter 5510/20 print driver: Written by Steve and Joe Maguire July, 1979 P.O. Box 3742 DT Anchorage, AK 99510 (Updated August 1980) This driver is a bi-directional and logic-seeking. It has two modes of operation: word processing and standard. In the WP mode, the driver will space-average. In the standard mode it can act as a normal device driver for general purpose printing. This document will explain how the driver works and how to use it with WordWizard, BASIC or other software. TWO MODES OF OPERATION: ********* Word-processing: ********* 1) The driver is fully compatible with WordWizard. It allows all features of WordWizard to be utilized. However, there are two restrictions. You may not set a ".pitch" of less than 8 or a ".vertical spacing" of more than 16. This is due to a limit- ation of the Spinwriter. If you send an illegal value it will be ignored. However, the driver will beep the alarm buzzer on the Spinwriter to inform you that an error has occured. Note that WordWizard uses integer math. Setting a ".pitch 11" will result in dividing 120 by 11 giving 10 cpi - not 11 as was desired. 2) In the word processing mode, the driver reacts to a formfeed (0CH) by printing linefeeds. It keeps track of the number of lines it has printed and prints linefeeds until it is at the top of the next page. If it detects that it is already at the top of the form, the formfeed is ignored. 3) The driver returns to the calling program in 1/10 of a second or less regardless of whether or not it has finished a complete print operation. This feature is available so that you can print one document and edit another simultaneously. This is accomplished by using a software interrupt. This interrupt is explained in the source code: TASK and YIELD (This process is sometimes called Spooling) 4) Vertical and horizontal spacing can be changed through the driver for special effects. You do this by calling the PTDOS Control/Status routine with the registers containing the correct values. This is explained the the driver source code. Note that WordWizard accepts spacing in characters-per-inch whereas the Spinwriter requires the value to be the number of 1/120ths per inch desired. WW converts this internally and sends it to the driver. (see #1 above) 5) A carriage return prints an automatic linefeed, and linefeeds are ignored. If a 0FFH is sent to the driver, the next carriage return does not issue a linefeed. This facility is available so that underlining and boldfacing are possible. 6) Space-averaging is performed on all lines except those ending in a 01H (that is, an inverted "L"). This improves the appearance of justified text by making each "gap" in the line of equal space. For example: This is a test. Will print: This is a test. The gaps will not necessarily be an integer number of blanks. Each gap could be 1 and 1/3 "blanks" wide. It does not change the size of the line, it fits the new line in exactly the same amount of space. The driver does this in a very simple manner as explained below: A) First, it counts the number of spaces between the first non-blank character and the last non-blank charcter. It also counts the number of gaps in the same area. For example: This is a test line. This has six spaces, but only four gaps. B) Next, it takes the number of spaces (6) and multi- plies this by the current horizontal pitch in 120ths. If the pitch were 10 (12 cpi) we would get 60. This is the total number of 1/120" increments that the blanks take up. Now we re-distribute those 60 increments equally into the four gaps. A little math tells us that 15 increments (1 and 1/2 spaces) will perfectly "space-average" this line. Then we print the first word "This" followed by 1.5 spaces, print the next word, and so on. To print the total space, we print a normal one then change the horizontal motion index of the print head to print the odd sized remaining part. Afterward, we change the HMI back to its original value; in this case 10. C) Look at this line: That is false. In this line, there are five spaces and two gaps. The average space would be 2 1/2 wide. If the HMI is 9 120ths, (13 cpi) then the total number of increments in the line is 45 (i.e., 5 x 9). Forty-five increments have to fit into two gaps. That means that the gaps won't be exactly equal. One must be 22 and the other 23. Behind the line buffer, the driver dimensions an array containing the length of each gap. Each element holds the number of increments for the given gap. That is, the third element has the number of increments for the third gap etc. The method of filling the array is quite simple. In the example above, there are two gaps. Therefore, the first step is to zero all the array elements. Once we clear the array, we add add one to each array element until the total number of increments (45) is used. If we hit the end of the array, we start at the beginning again. In this way, the first element will contain 23 and the second element 22. When printing, the driver picks these values out of the array and prints them. This method is the easiest and fastest way in which to space- average. It does not require the use of a floating point math routine such as is contained in some other drivers. The driver scans the array in the same direction as printing. This allows boldface and underlining to be printed bi-directionally with proper registration. This is much faster than another popular word processor which uses backspacing for these features. Note: After the gaps and spaces are counted, the line to be printed is compressed in memory, that is, all extra spaces are removed. This allows more efficient scanning of the buffer during printing. 7) A tilde is printed as a blank. Suppose you wanted to print the two blanks after the period in the following line. This is a line. This too. Normally, the driver would average the gaps and the two spaces would be reduced to one. By inserting the tilde character (~) into the text after the period, the driver is alerted that you want a double space in this position. The tilde is counted as a blank as well as a gap. The following lines would print a double space after the first period. This is a line. ~This too. This is a line.~~This too. This is a line.~ This too. This~is~a~line.~~This~too. 8) This driver contains a special feature not found in WordWizard. It is an absolute space character, the caret (^). An absolute space is one which is never "space-averaged". At times it is desirable to leave space in the printed text for special features. These could be special characters not printable with a single print thimble such as Greek letters or a portion of the text which the user would want printed with a red ribbon. Inserting the caret in the text will leave a space exactly equal to one printed character. The user can then change thimbles or ribbons and go back and print the desired characters. In addition, the caret allows underlining and boldface in space-averaged text. Look at the following example: .underline A) ~This is a paragraph which extends for many lines etc ^^ ~^^^^ ^^ ^ paragraph ^^^^^ ^^^^^^^ ^^^ ^^^^ ^^^^^ ^^^ If it were desired to boldface the word "paragraph" and have space averaged text, it would not normally be possible without the absolute space character. Further information is contained in the WordWizard manual but is summarized here for those who do not have a copy available. 9) The driver prints all non-recognized controls characters as questions marks ("?"). 10) The driver prints bi-directionally and seeks the fastest direction with which to print each line. ********* Non-word processing mode: ********* 1) In this mode, the driver retains control until all printing is done before returning to the calling program. 2) The driver prints a tilde as a tilde -- not as a blank. 3) The absolute space character (^) is printed as a caret. 4) Space-averaging is not performed. 5) Carriage returns do not issue automatic linefeeds. Linefeeds are not absorbed. However, sending an FF hex character will cause the next linefeed to be ignored. (required for underlining) 6) The driver will process most control codes which set various functions on the Spinwriter. Be careful about setting funtions via local control (5520 only) as the driver may become confused. It keeps track internally of functions in use. 7) A formfeed performs a hardware formfeed. That is, it prints the formfeed and scrolls to the top of the next page set by the Top Of Form button on the printer. The user should set this value before issuing any formfeeds. Note that unlike the word processing mode, a formfeed is issued regardless of whether or not the paper is at the top of a form. Bi-Directional Printing: This driver prints bi-directionally whenever possible. In addition to bi-directional printing, it does logic-seeking to determine the fastest method in which to print. For example, take these two lines: This is a test. This is a test line to explain the point in greater detail. If the driver were to print the first line forward, it would be more efficient to print the next line forward as well - not backward. The print head is positioned to the correct column for starting by sending out blanks. Because of a bug in the Spinwriter's internal software, we cannot use tabbing to position the print head properly. The effect of this restriction shows up only if low (below 1200) baud rates are used to communicate with the Spinwriter. The bug is that the Spinwriter reads the pitch value from it's front panel setting when tabbing - not the value currently stored in it's memory. (Software version G9CUR) This prevents the tabbing function from being used with a variable pitch driver. Printing with BASIC: This driver can be accessed like any other file from Basic but the special features enabled by control codes cannot be used. Control characters embedded in the character stream with the exception of CR, LF and FF are ignored. Control codes are only recognized after the CONTROL routine of the driver is called. It would be possible to write a machine language subroutine which could be called from Basic to do this. Printing with other word processors: Other word processing software does not support the function codes which are used by WordWizard. It should be possible to "fake" it by a scheme such as given below. Most word processors are unable to send control characters to the printer. In order to signal the driver that some special code is coming up, a normal ASCII character sequence can be used. A double dollar sign ($$) followed by control letters could be inserted into the text on a seperate line. The driver CONTROL routine could be modified to process various letters sent to it after the PROCESS routine detects the $$ sequence. The required software patch is left to the user. Spinwriter connections to the Sol serial port: This driver waits for a "ready" status signal from the printer before sending any output. There are several status lines available at the Sol's serial port. The driver waits for the CLEAR TO SEND signal at pin 5 to become high. (bit 5 of status word from port F8 (20 hex)) On the Spinwriter, set contact 5 of SW1 on the control panel curcuit board (G9BNF) to "ON" (up). This puts the Reverse Channel line (pin 19 on cable) in an active "LOW" condition. (buffer full = low) This results in a high signal from the printer when it can accept char- acters. If the printer is accidently disconnected or turned off, the Sol serial input pins are pulled high by internal circuitry. This makes WordWizard (or any other program which tries to use this driver) think everything is working fine and it continues sending characters. When the mistake is discovered the "Stop Printing" key can be used to halt output. Without this feature, some programs other than WordWizard could "hang" if the printer were not connected and attempts to recover could cause a program crash. Connections: Spinwriter pin Sol serial port pin TX DATA 2 3 RX DATA used on Model 5520 RX DATA 3 2 TX DATA GND 7 7 GND CTS 5| DSR 6| 20 DTR | denotes common connection CD 8| |6 DSR DTR 20 |8 CD REV CHA 19 5 CTS (#5 of SW 1 "ON" on G9BNF board)