|Fast Printout Routines|
The simplest character printout routine just copies the character bitmap
from a character set pointed to by CHARS to screen, keeping a note of
the screen output address in DFCC (Display File Current Character)
and incrementing it after each character.
A simple calculation converts the character output address to the address of
the corresponding attribute location, then the colours can be set for the
character just printed.
So far the code just indexes straight into the character definitions without
any checking for non-printable characters. Adding a check for character 32
lets control codes be ignored, and a check for characters over 127 lets
block graphics and User Defined Characters be used. As there is a bug in the
Spectrum's colour commands, if this code is attached to a stream it has to
exit with Carry clear when called with control codes. Also, this code treats
all characters from 144 to 255 as User Defined Characters pointed to by
There is a subroutine in the ROM that generates the block graphics bitmaps which can be called directly. Otherwise, the code can be duplicated and used inline in the code.
It is a simple addition is to preserve all the registers so the code doesn't
effect the calling code. This is not needed if the code is attached to a
Spectrum stream as the stream handler preserves the main register set.
We've now almost got a complete screen driver. It is simple to add movement
control characters which add or subtract 1 or 32 to the current output
position, character 13 to move to the start of the next line, and character
12 to clear the screen. These more than doubles the size of the code to
implement, though we save some code by using the CHR$9 code to update the
print position after printing a character.
All the previous code assumes the character output position was on the
screen and didn't check if it moved off the top or bottom. A few more bytes
adds a simple check which moves the output position back onto the screen if
it has moved off. A further improvement would be to scroll the screen when
the output position moved off.
Further improvements would be to implement colour control codes and the AT
position control code. This code includes a subroutine to set the character
Instead of storing the current print output position as the address in
the screen bitmap memory (DFCC), the method used by Jet Set Willy can
be used, storing the address in the attributes memory of the current
print output position. The advantage of this is that stepping from
once character cell to the next is a simple case of adding one, there
is are no steps over screen thirds. Also, converting from attribute
address to display address is slightly shorter and faster than the
other way around.
These two source files are the equivalent of their similar numbered DFCC-based source files, using the attribute memory address as the output address.