Автор: Tony Samuels
Год: 1985
Издатели: Your Spectrum
Языки:
Английский
Формат:
TAP лента
Требования:
ZX Spectrum 48K
Ссылки:
Страница на ZXArt
Страница на World Of Spectrum
Страница на Spectrum Computing
Скриншоты:
Год: 1985
Издатели: Your Spectrum
Языки:
Формат:
Требования:
Ссылки:
Скриншоты:
(from Your Spectrum 20, November 1985)
OUT OF ALL PROPORTION
Normal Speccy printing is ugly, ugly, ugly and
boring, boring, boring. Here's shaped crusader
Tony 'Slim' Samuels with a pretty neat
alternative!
No-one could say that the way the Speccy PRINTs is
the most beautiful in the world. The problem is
that the screen is divided into 32 character
columns and every character always takes up the
same amount of space on the screen. Hardly news
and not the kind of thing that bothers us hacks at
all. But it's a bit of a shock for all those poor
misdirected human beings out there in the real
world.
Now take a close look at these words in YS, You'll
see that thin characters like I and 1 take up a
lot less space than fat ones like M and W. This is
our secret way of making sure you can read and
re-read YS from cover to cover at no risk to your
eyesight. Who says we don't look after you?
So how's about a little bit of machine code to
print properly using this sneaky proportional
printing idea? Not only will any program you write
using it look really nice and be very pleasant to
use but you get the added benefit of printing at
any pixel position on the screen and so stuff far
more than 32 characters on every line. Choose thin
words and you'll get more than 100 characters per
line! Proportional printing is therefore ideal for
any program with lots of text in it - databases,
word processors and so on.
GOTO LPRINT
To make life even easier, the print program here
becomes part of Speccy Basic by taking over the
LPRINT command. The syntax is the same except you
can now use the AT command if you like. The
program doesn't like INK and PAPER control codes
but it will print in whatever permanent colours
you've set with INK and PAPER. Once you've got the
routine loaded, the command, LPRINT AT 0,0; "Your
Spectrum" will print "Your Spectrum"
proportionally spaced in the top left of your
screen. All proportional printing is done as if
OVER 1 was set so you've got to be careful only to
print on blank bits of screen or else the result
will be more of a mess than the usual PRINT
command!
GET LOADED
To get your own printing going, you're going to
have to type in the proportional print program and
either the character set given here or one of your
own design. If you've got an assembler, you can go
to work on the assembly listing. Otherwise, you'll
have to type in and use the hex loader provided.
Once that's in, use the hex loader to enter the
proportional character set itself. Done all that?
Wow, you're getting really quick! Okay, best
remember to save the whole shebang as one lump
with:
SAVE "PROPSYS" CODE 64200,1150.
Now, whenever you get the urge, you can set up the
whole thing with:
CLEAR 64199: LOAD "PROPSYS" CODE: RANDOMIZE USR
65000
LPRINT ; will go on working until you do a NEW.
You can get it back afterwards with another
RANDOMIZE USR 65000.
The Speccy's got 96 printing characters from space
(CHR$(32) to the copyright symbol CHR$(127)). Each
of these is defined just like a UDG using 8 bytes.
A proportional character set is done in a similar
way except the first byte of each definition is
used to tell the print program how wide the
character is, so that it can start the next
character just after it.
To work out this byte, just set those bits that
aren't used by the character to 1 and leave the
rest at 0. If your character is four bits wide,
the bits 8,7,6,5 and 4 should all be 0 (bit 4 is 0
so that there's a one pixel gap between this
character and the next) and bits 0,1 and 2 should
be 1. Simple really! And I've included a little
font designer listing opposite so you can get
started right away. There, who says I'm just a
pretty face?
SHAPIN' UP
You'll find here all the code you need to get
proportional printing up and running on your
Speccy. Tony's also provided a designer program,
so if you're not happy with his creative
characters then you can knock up your own. If
you're going for the minimum typing job, then
you'll only need to enter three parts. The Hex
Loader (which enters the code), the Proper Print
machine code listing (using either our Hex Loader
or your own assembler package) and finally the
Character Set code using the Hex Loader program.
A HEX FOR YOU
In case you're wondering, this is a hex loader - a
program to provide hours and hours of endless
entering fun for all the family. To use it, type
it in and SAVE it and then enter the print program
by typing in each line of hex in the second column
of the main listing (one byte at a time) starting
from address 65000. When you've finished type xx.
The checksum should come to 45760 if you've got it
right. Next, use the loader to enter the
proportional character set. It starts at 64200 and
the checksum should come to 64743. Don't forget to
save it all with SAVE "PROPSYS" CODE 64200,1150 .
PROPER PRINT
This is it - the machine code program that,
coupled with a character set at 64200, prints like
magic on your Speccy. If you've got an assembler
or monitor, you can start straight away. Otherwise
nip ahead and type in the hex loader and come back
when it's running.
Start the routine at 65000 and declare some
labels.
Reset the printing position to the top left of the
screen.
Change the pointer to the LPRINT routine in the
CHANS table to point to the proportional printing
routine.
Save all the registers, call the printing routine,
put back all the registers again and leap back to
the operating system.
Look to see if last character was a control code
22 - the code for AT.
If the current character is an AT control code,
set the ATFLG to indicate that the next two codes
dealt with will be the X and Y positions for the
print.
If the last character was an AT then fetch the X
and Y co-ordinates and move to the new printing
position.
If the current character is a Return control code,
move down 8 pixels and open channel 2 to deal with
nasty INK and PAPER control codes.
Burp! If the character is not between 32 and 127
then print a question mark instead.
Figure out where the character's definition is
stored in memory.
Store the first byte of the character (the width
indicator) and stick a zero byte in its place.
We're getting there! Load CRADD with the address
of the seventh byte of the character, check the
character will fit on the screen and calculate the
address in the display file where the character
will be printed.
Rotate the character definition into the correct
pixel position, place it on the screen one byte at
a time and make sure each byte is in the right
colour.
Get the width indicator byte and put it back at
the start of the character definition. Then move
right the correct number of pixels for the
character just printed.
Reserve a bit of space for some variables.
Here's a handy routine that sets HL to point to
the next pixel line up in the display file.
Restore the width indicator byte to the first byte
of the character definition and generate an Out of
Screen error.
Check if the character to be printed will fit on
this line - if it doesn't, move down 8 pixels and
back to the left hand side of the screen.
And another useful routine - it calculates the
relevant address in the attributes file from a
given display file address and stores the value of
ATTRP (the permanent PAPER and INK colours) in it.
That's all folks!
CHARACTER SET
Here's the info for proportionally spaces
characters - all 96 of them! Grab the hex loader
and get going ...
FONT DESIGNER
You can use this either for the proportional
printing program or for the Speccy's normal
characters. Q, A, O and P move the cursor around -
give Troubleshootin' Pete a ring if you can't work
out which does which direction! To set a pixel use
M and to turn one off use N. F stores the design
on the grid in memory as any particular character
you want, D displays any character, U shows the
whole character set and S and J save and load the
whole lot for you. Once you've saved a new set,
you can load it into the proportional print
program with LOAD "name" CODE 64200. Away you go
...
DEMO LISTING JOB
If you're still confused about life, death and the
meaning of proportional printing, try out this
major new adventure program once you've got
PROPSYS working. Cor, it's even harder than Castle
Rathbone! Just so you can see how awful Speccy
printing is, the magic word xyzzy will flip you
between the two types of printing.
Before ... and after. The difference, as you can
see, is quite dramatic. Not only is the
proportional text more pleasing to look at - it's
also easier to read!
OUT OF ALL PROPORTION
Normal Speccy printing is ugly, ugly, ugly and
boring, boring, boring. Here's shaped crusader
Tony 'Slim' Samuels with a pretty neat
alternative!
No-one could say that the way the Speccy PRINTs is
the most beautiful in the world. The problem is
that the screen is divided into 32 character
columns and every character always takes up the
same amount of space on the screen. Hardly news
and not the kind of thing that bothers us hacks at
all. But it's a bit of a shock for all those poor
misdirected human beings out there in the real
world.
Now take a close look at these words in YS, You'll
see that thin characters like I and 1 take up a
lot less space than fat ones like M and W. This is
our secret way of making sure you can read and
re-read YS from cover to cover at no risk to your
eyesight. Who says we don't look after you?
So how's about a little bit of machine code to
print properly using this sneaky proportional
printing idea? Not only will any program you write
using it look really nice and be very pleasant to
use but you get the added benefit of printing at
any pixel position on the screen and so stuff far
more than 32 characters on every line. Choose thin
words and you'll get more than 100 characters per
line! Proportional printing is therefore ideal for
any program with lots of text in it - databases,
word processors and so on.
GOTO LPRINT
To make life even easier, the print program here
becomes part of Speccy Basic by taking over the
LPRINT command. The syntax is the same except you
can now use the AT command if you like. The
program doesn't like INK and PAPER control codes
but it will print in whatever permanent colours
you've set with INK and PAPER. Once you've got the
routine loaded, the command, LPRINT AT 0,0; "Your
Spectrum" will print "Your Spectrum"
proportionally spaced in the top left of your
screen. All proportional printing is done as if
OVER 1 was set so you've got to be careful only to
print on blank bits of screen or else the result
will be more of a mess than the usual PRINT
command!
GET LOADED
To get your own printing going, you're going to
have to type in the proportional print program and
either the character set given here or one of your
own design. If you've got an assembler, you can go
to work on the assembly listing. Otherwise, you'll
have to type in and use the hex loader provided.
Once that's in, use the hex loader to enter the
proportional character set itself. Done all that?
Wow, you're getting really quick! Okay, best
remember to save the whole shebang as one lump
with:
SAVE "PROPSYS" CODE 64200,1150.
Now, whenever you get the urge, you can set up the
whole thing with:
CLEAR 64199: LOAD "PROPSYS" CODE: RANDOMIZE USR
65000
LPRINT ; will go on working until you do a NEW.
You can get it back afterwards with another
RANDOMIZE USR 65000.
The Speccy's got 96 printing characters from space
(CHR$(32) to the copyright symbol CHR$(127)). Each
of these is defined just like a UDG using 8 bytes.
A proportional character set is done in a similar
way except the first byte of each definition is
used to tell the print program how wide the
character is, so that it can start the next
character just after it.
To work out this byte, just set those bits that
aren't used by the character to 1 and leave the
rest at 0. If your character is four bits wide,
the bits 8,7,6,5 and 4 should all be 0 (bit 4 is 0
so that there's a one pixel gap between this
character and the next) and bits 0,1 and 2 should
be 1. Simple really! And I've included a little
font designer listing opposite so you can get
started right away. There, who says I'm just a
pretty face?
SHAPIN' UP
You'll find here all the code you need to get
proportional printing up and running on your
Speccy. Tony's also provided a designer program,
so if you're not happy with his creative
characters then you can knock up your own. If
you're going for the minimum typing job, then
you'll only need to enter three parts. The Hex
Loader (which enters the code), the Proper Print
machine code listing (using either our Hex Loader
or your own assembler package) and finally the
Character Set code using the Hex Loader program.
A HEX FOR YOU
In case you're wondering, this is a hex loader - a
program to provide hours and hours of endless
entering fun for all the family. To use it, type
it in and SAVE it and then enter the print program
by typing in each line of hex in the second column
of the main listing (one byte at a time) starting
from address 65000. When you've finished type xx.
The checksum should come to 45760 if you've got it
right. Next, use the loader to enter the
proportional character set. It starts at 64200 and
the checksum should come to 64743. Don't forget to
save it all with SAVE "PROPSYS" CODE 64200,1150 .
PROPER PRINT
This is it - the machine code program that,
coupled with a character set at 64200, prints like
magic on your Speccy. If you've got an assembler
or monitor, you can start straight away. Otherwise
nip ahead and type in the hex loader and come back
when it's running.
Start the routine at 65000 and declare some
labels.
Reset the printing position to the top left of the
screen.
Change the pointer to the LPRINT routine in the
CHANS table to point to the proportional printing
routine.
Save all the registers, call the printing routine,
put back all the registers again and leap back to
the operating system.
Look to see if last character was a control code
22 - the code for AT.
If the current character is an AT control code,
set the ATFLG to indicate that the next two codes
dealt with will be the X and Y positions for the
print.
If the last character was an AT then fetch the X
and Y co-ordinates and move to the new printing
position.
If the current character is a Return control code,
move down 8 pixels and open channel 2 to deal with
nasty INK and PAPER control codes.
Burp! If the character is not between 32 and 127
then print a question mark instead.
Figure out where the character's definition is
stored in memory.
Store the first byte of the character (the width
indicator) and stick a zero byte in its place.
We're getting there! Load CRADD with the address
of the seventh byte of the character, check the
character will fit on the screen and calculate the
address in the display file where the character
will be printed.
Rotate the character definition into the correct
pixel position, place it on the screen one byte at
a time and make sure each byte is in the right
colour.
Get the width indicator byte and put it back at
the start of the character definition. Then move
right the correct number of pixels for the
character just printed.
Reserve a bit of space for some variables.
Here's a handy routine that sets HL to point to
the next pixel line up in the display file.
Restore the width indicator byte to the first byte
of the character definition and generate an Out of
Screen error.
Check if the character to be printed will fit on
this line - if it doesn't, move down 8 pixels and
back to the left hand side of the screen.
And another useful routine - it calculates the
relevant address in the attributes file from a
given display file address and stores the value of
ATTRP (the permanent PAPER and INK colours) in it.
That's all folks!
CHARACTER SET
Here's the info for proportionally spaces
characters - all 96 of them! Grab the hex loader
and get going ...
FONT DESIGNER
You can use this either for the proportional
printing program or for the Speccy's normal
characters. Q, A, O and P move the cursor around -
give Troubleshootin' Pete a ring if you can't work
out which does which direction! To set a pixel use
M and to turn one off use N. F stores the design
on the grid in memory as any particular character
you want, D displays any character, U shows the
whole character set and S and J save and load the
whole lot for you. Once you've saved a new set,
you can load it into the proportional print
program with LOAD "name" CODE 64200. Away you go
...
DEMO LISTING JOB
If you're still confused about life, death and the
meaning of proportional printing, try out this
major new adventure program once you've got
PROPSYS working. Cor, it's even harder than Castle
Rathbone! Just so you can see how awful Speccy
printing is, the magic word xyzzy will flip you
between the two types of printing.
Before ... and after. The difference, as you can
see, is quite dramatic. Not only is the
proportional text more pleasing to look at - it's
also easier to read!