Give Your Printer A Right Turn

Your ZX printout can be broader than it's long. David Nowotnik
describes two programs to turn around the printer's character
set and use it for word processing.


For producing program listings and hard copies of the screen display, the ZX
printer is fine. But for more ambitious applications such as word processing
or printing out large tables of results, the 32-character line width is a
serious restriction.

Do not despair, though - there is a way to increase the printer's line width
to any size you like. Imagine that you could turn the printer on its side to
convert character columns to rows and rows to columns. Then you could have any
character width you wanted, with a fixed number of 32 rows.

My Right Turn program, written for the 16K Spectrum, does just that. It is so
called because the original characters are rotated through 90 degrees to lie
on their right sides. An example of output produced using this program is
shown in Figure 1. If you want more than 32 rows, of course, several 32-row
"pages" have to be pieced together.

To load the new character set to a higher RAM address in the 48K Spectrum,
just substitute the values in square brackets for those appearing earlier in
the line (line numbers 40, 50, and 270). The new character set is stored
above a lowered RAMTOP to allow it to be transferred from one program to
another.

Right Turn takes several minutes to run, as 768 decimal-to-binary-to-decimal
conversions are carried out. Once the program has finished, you can save the
new character set on tape with the direct command:
	SAVE "chars" CODE 31488,768 (48K version; 64512,768)
To keep you amused while the new character set is created, the original and
new characters are shown on the screen in an enlarged form. Finally, a screen
message appears which uses the new character set, to show you that it has
worked. The new character set is brought into use by altering the value held
by the system variable CHARS (line 270, see p.173 of the handbook); CHARS is
reset to its original value (line 390) before the program stops.

The program could be modified to turn characters anti-clockwise, or upside-
down, by altering lines 170-210. Those changes that are necessary are shown
in Listing 2.

An example of the use of this new character set is the word processor program
in Listing 3. First, use Right Turn to create the new character set starting
at address 31488 (for both 16 and 48K Spectrums). After using NEW, type in
the program in listing 3.

The program requires one user defined graphic (UDG) symbol. This is the "<-"
in lines 3050 and 8010, and is used as an end of paragraph marker. Type this
is as "a" in graphic mode. The UDG is created with the following direct
commands:
	POKE 23676,127
	POKE USR "a",0
	POKE USR "a"+1,16
	POKE USR "a"+2,64
	POKE USR "a"+3,127
	POKE USR "a"+4,64
	POKE USR "a"+5,16
	POKE USR "a"+6,0
	POKE USR "a"+7,0

Save the program with the direct command: SAVE "word" LINE 10. Once
saved, stop the tape and enter the direct command to save the character set
and UDGs: SAVE "chars" CODE 31488,1120. Press Record on your tape recorder,
and save the character set so that it follows immediately after the program
on the tape. This allows the character set to be loaded automatically when
the program is re-loaded.

The printout in Figure 1 describes how the program is used. The program just
fits a 16K Spectrum and is limited to one printed page only. If you have a
48K Spectrum, it is possible to expand the text file (b$) to hold several
pages, although the output routine (line 3000-) will have to be modified to
deal with more than one page. Figure 2 lists the main routines and variables
used in the program.


Figure 1

Once loaded into your Spectrum, the word processor program
starts automatically in text mode. The black-on-white cursor
indicates the position of the next character to be entered.
This can be any alphabetical, numeric or punctuation
character, but not any obtained in graphics mode. Enter text as
you would using a typewriter, but do not worry about words
overflowing from one line to the next; this will be corrected
on printout. Press ENTER to indicate the end of a paragraph.
  Certain numeric keys used with CAPS SHIFT have control
functions. They are:
  1. LOAD  A text file previously saved on tape will be
re-loaded into the computer.
  2. SAVE the text file.
  3. OUTPUT  The text file is printed with the ZX printer using
a 64-column format.
  5. Cursor left.
  6. Cursor down.
  7. Cursor up.
  8. Cursor right.
  Use the cursor control keys to edit the text.
  Printer output is slow due to the formatting routine, which
is in BASIC.


Figure 2 - summary of the main routines and variables used in the word processor program

Routines
 100-180   Initialise main variables
 500-640   Main routine
 530-540   Wait for a key-press
 550-580   Check for a valid key-press (alphabetic, number, control or ENTER)
 600-640   Print a character and enter in the text file; move cursor to next
           position, checking for end of text file, end of line, and end of
           display file
 700-740   Forward SCROLL (by overprinting)
 750-780   Reverse SCROLL
1000-1050  Load a text file from tape
2000-2030  Save a text file
3000-3500  Print text file; the routine involves line justification, then
           placing strings of up to 64 characters into a$ for printing
4000-4040  Move cursor left
5000-5060  Move cursor down
6000-6070  Move cursor up
7000-7040  Move cursor right
8000-8070  End of paragraph marker; place on the screen, and move print
           position to the next line

Variables
a$    Formatted text
b$    Unformatted text
cur   Cursor position in attribute file
c(8)  Command key CODE numbers
mk    Used in formatting; marks the position reached in a$
x,y   Cursor co-ordinates on the screen
