Classic Computer Magazine Archive CREATIVE COMPUTING VOL. 9, NO. 6 / JUNE 1983 / PAGE 196

Printer control from Apple Writer. Charles L. Hearn.

Printer Control From Apple Writer

When I began investigating text editors for my Apple II, I found that there was no single program that was ideal for my needs. My final choice was the Apple Writer Text Editing System marketed by Apple Conputer, Inc. This system is simple to use, performs the most common word processing functions, and is relatively inexpensive.

Perhaps most important in my case, however, is the fact that Apple Writer is supplied on a disk that is not copy protected. This means that not only can backup copies easily be made, but the program can be modified to provide features not in the original program. Indeed, several articles have appeared in Creative Computing describing modifications to Apple Writer.

One feature not provided by Apple Writer is the ability to send special control characters to the printer or printer interface. My printer, an IDS 460 Paper Tiger, uses control characters to change the number of characters per inch and to change from normal to expanded type. This provides the ability to emphasize portions of the text such as headings.

Since I use this feature frequently, I decided to modify Apple Writer to send any ASCII character to the printer. This article describes how you can make this modification to you Apple Writer.

Apple Writer consists of two machine language programs: TEDITOR and PRINTER. The TEDITOR program allows entry and editing of text. The PRINTER program formats and prints the text; this is the program that must be modified to send printer control characters.

I began by disassembling the PRINTER program using the Apple disassembler (monitor L command). I was greatly assisted in understanding the operation of the program (at least the part that needed modification) by John E. Stith's excellent article in Creative Computing ("Lower-Case Display for Apple Writer,' February 1981, page 124). The key to the modification is a JMP instruction at location $0F59 in the PRINTER program.

Apple Writer uses special commands embedded in the text to change the format of a page while it is being printed. A format command is signalled by an ! in the first column of a new line. The JMP instruction at $0F59 branches to a routine which processes the formatting commands.

All that was necessary was to change this instruction to branch to a new routine located at the end of the original program. This new routine intercepts all text-embedded format commands. If the command is for printer control, it is deciphered and the proper ASCII character is output. If the command is not for printer control the program branches to the original processing routine.

The new text-embedded printer command has the form:

s(number)

where (number) stands for the decimal ASCII code of the character that is to be output. Any ASCII character can be output. Normally, this feature would be used only to output single characters or character sequences that are intercepted by the printer interface or the printer. For example, to output a control-A, the command is

s1 The number 1 is the decimal ASCII code for control-A. As another example, to output the sequence (CTRL-I)80N (used by some printer interfaces to set the number of output columns to 80) the sequence of commands is

s9

s56

s48

s78

Here 9 is the ASCII code for control-I, 56 is the code for 8, etc.

This means that you cannot change the character density in the middle of a line to emphasize a single word or phrase. In general this is not desirable, however, since changing the character density also changes the number of characters per inch. The resulting shift in margin locations is easy to compensate for in headings or individual paragraphs, but difficult when the change occurs in the middle of a line.

Listing 1 contains the modifications that must be made to PRINTER to include this feature. The modifications consist of changing the JMP instructions at $OF59 to branch to the new routine, which begins at $1865, and adding the new routine to the end of the program. Listing 2 is a disassembled listing of the new routine. The modifications are made as follows:

1. Use a copy program to make a copy of your Apple Writer disk. Do not modify the original disk! Make the modifications on the copy.

2. Boot a DOS master disk, and insert the Apple Writer copy in drive 1.

3. BLOAD PRINTER, then enter the monitor with CALL -151.

4. Enter the modifications as shown in Listing 1.

5. Enter $0F59L. The first line of the listing should be JMP $1865.

6. Enter $1865LL and compare the listing with Listing 2.

7. If steps 5 and 6 don't check, go back to step 3.

8. UNLOCK PRINTER

9. BSAVE PRINTER, A2051, L4250

10. LOCK PRINTER

I have not attempted to decipher the entire PRINTER program and cannot guarantee that the portion of memory that contains this patch will never be overwritten, or that the routine will not fail under some circumstances. "However,' I have been using it for some time and have had no problems. Let me emphasize again that the patches should be made to a copy and not to the original Apple Writer disk.

If you have made previous modifications to the PRINTER program, such as those necessary to display lowercase text using an adapter, you should be careful that the modifications do not use the same memory as those of Listing 2. This would require relocation of one of the routines.

I have installed a Videx Keyboard and Display Enhancer on my Apple; this allows both lowercase display on the monitor and use of the shift key for upper- and lowercase. Videx supplies patches for Apple Writer for use with the Keyboard Enhancer. The routine presented here does not interfere with these patches.

There is one additional caution in installing this modification. Apple Writer does not store text in normal ASCII representation. At least one published Apple Writer modification, that of John E. Stith mentioned previously, converts the stored text to normal ASCII with the most significant bit set on. If you have installed Mr. Stith's modifications, you will need to change byte $186A of my routine from $C1 to $E1 (ASCII for a) and byte $1874 from $D3 to $F3 (ASCII for s).

Table: Listing 1. Patches to Apple Writer PRINTER Program. used for the other Apple Writer text-embedded commands. As with the original commands, this new command must be preceded and followed by a RETURN, i.e., it must appear on a line by itself and must be the first characters on the line.

Table: Listing 2. Printer Control Routine.