Автор: Ian Stewart
Год: 1984
Издатели: Sinclair User
Языки:
Английский
Формат:
TZX лента
Требования:
ZX Spectrum 16K,
ZX Spectrum 48K
Ссылки:
Страница на ZXArt
Страница на World Of Spectrum
Страница на Spectrum Computing
Скриншоты:
Год: 1984
Издатели: Sinclair User
Языки:
Формат:
Требования:
Ссылки:
Скриншоты:
Most displays are 64 characters wide.
Jon Ellis squeezes more into the Spectrum screen.
ZX Condenser
One of the many annoying features of the Spectrum is the
screen layout, 24 lines each of 32 characters, of which
only 22 lines are usually available to the user. Many
computers have the facility to put the more standard 40
characters - (or even 80 characters) - on a line. This
utility alters the pitch of the Spectrum printing to give
nine different character per line ratios. The routine also
enables you to position text on the screen and to give it
colour.
Although non-standard, 32 characters per line is a
logical development from the way in which Sinclair designed
the Spectrum screen. As you will know from user-definable
graphics, a character on the Spectrum can be represented by
a eight by eight grid of pixels. Since there are 256 pixels
in the x direction, we may fit 256 divided by eight, or 32,
of those pixel grids across the screen. What this utility
does is to alter the size of the pixel grid used to repre-
sent a character.
If we decide that a character is to be made up of a six
by eight pixel grid, then we will be able to fit 256 divi-
ded by six, or 42, characters per line, taking the integer
part of the division only. Table 1 shows the effect of let-
ting the size of the pixel grid from six by eight to 15 by
eight. Note that we are only altering the size of the grid
which defines a character, not the size of the shape with-
in the grid - i.e. what is being printed.
Table 1.
Size of grid Characters Value of
per line F
6 x 8 42 6
7 x 8 36 7
8 x 8 32 8
9 x 8 28 9
10 x 8 25 10
11 x 8 23 11
12 x 8 21 12
13 x 8 19 13
14 x 8 18 14
15 x 8 17 15
It is easy to print characters in grids larger than
eight by eight - all that needs to be done is to print each
character of the text as normal, but inserting a gap of
several pixels between successive characters. However, it
is slightly more difficult to condense print from the stan-
dard print. How do we make the grid smaller? The answer to
that can be found by looking at the design of the standard
Sinclair character set.
Taking a non-graphic character such as the letter 'm',
as in Figure 1, we see it has a border of blank pixels com-
pletely around the letter shape. What the program does is
to clip off the left and right hand edges for the six by
eight grid, or just the right hand edge for the seven by
eight grid. The routine prints the first character of the
text, and then moves along six, or seven, pixels before
printing the second character; that procedure is followed
for all the other characters in the text string.
+---+---+---+---+---+---+---+---+
| | | | | | | | |
+---+---+---+---+---+---+---+---+
| |###|###| |###| | | |
+---+---+---+---+---+---+---+---+
| |###| |###| |###| | |
+---+---+---+---+---+---+---+---+
| |###| |###| |###| | |
+---+---+---+---+---+---+---+---+
| |###| |###| |###| | |
+---+---+---+---+---+---+---+---+
| |###| |###| |###| | |
+---+---+---+---+---+---+---+---+
| |###| |###| |###| | |
+---+---+---+---+---+---+---+---+
| | | | | | | | |
+---+---+---+---+---+---+---+---+
Figure 1.
[This was followed by an explanation of how to enter and
save the code, including a short demo program. I've omitted
this, as it is all readily entered on the TZX. The Demo
program works on both 48K and 16K and loads the correct
CODE file. The code readers for both sets of code - identi-
cal except for quite a few hard-coded addresses, so they're
not relocatable - are on the TZX, as well.]
A brief explanation of the assembly language listing,
stage by stage follows. [The numbers are the addresses in
the 48K code. These were absent in the magazine. I haven't
copied the listing, as most good emulators will provide a
disassembly, but that does mean that the labels are not
much use as reference. Hence the addresses. For the 16K
addresses, subtract 32730.]
FINDX: Routine which uses SCAN to find the value of the
64810 variable x, providing that it can be found in
small integer form.
FINDY: Finds the value of small integer y.
64828
FINDF: Finds the value of small integer f, giving the
64842 report 'Q Parameter error' if the value is outside
the range 6 to 15.
FINDS: Finds the start address and length of the text
64866 string s$.
SCAN: Subroutine which searches the variable area for the
64880 variable specified in VARSC. If the variable speci-
fied is not found then the report '2 Variable not
found' is given. Note that the routine distinguishes
between, for example, x as the control variable of a
FOR-NEXT loop, and x as a simple numeric variable.
INIT: This calculates the maximum number of pixel grids on
64954 a line (the number of pixels in the x direction is
defined by the simple numeric variable f).
START: This takes the characters from the string s$ sequen-
64985 tially and prints them, such that the specified num-
ber of pixels occur between successive characters.
If there are more characters in the text string than
can fit on the line, then the routine will automati-
cally print to the end of that line and then carry
on printing on a line eight pixels down. The routine
ensures that a character may never straddle a line.
If the message was begun on line 0 (the bottom of
the screen) and has to be continued on the next
line, or indeed, if any message runs out of space
on the screen, the routine will automatically scroll
the screen up eight pixel lines with no 'scroll?'
prompt.
CHRS: The first part of this subroutine finds out which
65075 kind of character is to be printed: control charac-
ters, those with codes less than 32, are printed as
normal; keyword tokens, characters with codes great-
er than 164, are not printed at all; any remaining
characters are to be printed using the routine.
Before a character can be printed the routine must
find out where the data defining the character is
stored. If the character is part of the 'normal'
character set, i.e. its code is between 32 and 127
inclusive, then the bytes defining it are in the
area starting at the address given by the system
variable CHARS (23606)+256. If the character is a
user-definable character, then the defining bytes
are in the area pointed to by the system variable
UDG (23675). If the character is a block graphic
then the defining bytes are created by manipulating
its character code. In all cases the 8 defining
bytes are transferred to the workspace.
WHERE: This uses the current row and column values to find
65184 the correct address in the display file for each of
the eight bytes of the character. It also colours
the appropriate attribute squares.
The position at which text is started is defined by the
values of the simple numeric variables x and y. X is the
x coordinate of the pixel at the bottom left of the first
character, and y is the y coordinate. If y is greater than
167 then part or all of the start of the text will be
printed off the top of the screen.
The simple variable f contains the number of x pixels
per character grid. For the relation between f and the
characters printed per line, see Table 1.
The variables x and y follow the coordinate system for
high resolution plotting as opposed to the PRINT AT coordi-
nate system. That gives a range of 0 to 255 for x, and to
175 for y.
S$ contains the text to be printed and must be a simple
string. To print an element of a string array, for example,
element three of array x$, use LET s$=x$(3), and then
proceed.
To set the colours of the text a PRINT line may be in-
serted before the call to Multipitch:
PRINT PAPER 3; INK 7; FLASH 1; RANDOMIZE USR 64810/32080
would print the text in flashing white on magenta. If the
required attribute value is known then it may be POKEd
directly into ATTR T (23695).
Note that unless specified then the value will default to
that held in BORDCR (23624).
It is a good idea to ensure that the parameters x, y
and f are being held in small integer form, especially if
their values are derived by calculation, by inserting the
following line:
LET x=INT x: LET y=INT y: LET f=INT f
The colours of the text are always loaded into the
attribute file in such a way as to ensure that all charac-
ters in the text are affected.
Jon Ellis squeezes more into the Spectrum screen.
ZX Condenser
One of the many annoying features of the Spectrum is the
screen layout, 24 lines each of 32 characters, of which
only 22 lines are usually available to the user. Many
computers have the facility to put the more standard 40
characters - (or even 80 characters) - on a line. This
utility alters the pitch of the Spectrum printing to give
nine different character per line ratios. The routine also
enables you to position text on the screen and to give it
colour.
Although non-standard, 32 characters per line is a
logical development from the way in which Sinclair designed
the Spectrum screen. As you will know from user-definable
graphics, a character on the Spectrum can be represented by
a eight by eight grid of pixels. Since there are 256 pixels
in the x direction, we may fit 256 divided by eight, or 32,
of those pixel grids across the screen. What this utility
does is to alter the size of the pixel grid used to repre-
sent a character.
If we decide that a character is to be made up of a six
by eight pixel grid, then we will be able to fit 256 divi-
ded by six, or 42, characters per line, taking the integer
part of the division only. Table 1 shows the effect of let-
ting the size of the pixel grid from six by eight to 15 by
eight. Note that we are only altering the size of the grid
which defines a character, not the size of the shape with-
in the grid - i.e. what is being printed.
Table 1.
Size of grid Characters Value of
per line F
6 x 8 42 6
7 x 8 36 7
8 x 8 32 8
9 x 8 28 9
10 x 8 25 10
11 x 8 23 11
12 x 8 21 12
13 x 8 19 13
14 x 8 18 14
15 x 8 17 15
It is easy to print characters in grids larger than
eight by eight - all that needs to be done is to print each
character of the text as normal, but inserting a gap of
several pixels between successive characters. However, it
is slightly more difficult to condense print from the stan-
dard print. How do we make the grid smaller? The answer to
that can be found by looking at the design of the standard
Sinclair character set.
Taking a non-graphic character such as the letter 'm',
as in Figure 1, we see it has a border of blank pixels com-
pletely around the letter shape. What the program does is
to clip off the left and right hand edges for the six by
eight grid, or just the right hand edge for the seven by
eight grid. The routine prints the first character of the
text, and then moves along six, or seven, pixels before
printing the second character; that procedure is followed
for all the other characters in the text string.
+---+---+---+---+---+---+---+---+
| | | | | | | | |
+---+---+---+---+---+---+---+---+
| |###|###| |###| | | |
+---+---+---+---+---+---+---+---+
| |###| |###| |###| | |
+---+---+---+---+---+---+---+---+
| |###| |###| |###| | |
+---+---+---+---+---+---+---+---+
| |###| |###| |###| | |
+---+---+---+---+---+---+---+---+
| |###| |###| |###| | |
+---+---+---+---+---+---+---+---+
| |###| |###| |###| | |
+---+---+---+---+---+---+---+---+
| | | | | | | | |
+---+---+---+---+---+---+---+---+
Figure 1.
[This was followed by an explanation of how to enter and
save the code, including a short demo program. I've omitted
this, as it is all readily entered on the TZX. The Demo
program works on both 48K and 16K and loads the correct
CODE file. The code readers for both sets of code - identi-
cal except for quite a few hard-coded addresses, so they're
not relocatable - are on the TZX, as well.]
A brief explanation of the assembly language listing,
stage by stage follows. [The numbers are the addresses in
the 48K code. These were absent in the magazine. I haven't
copied the listing, as most good emulators will provide a
disassembly, but that does mean that the labels are not
much use as reference. Hence the addresses. For the 16K
addresses, subtract 32730.]
FINDX: Routine which uses SCAN to find the value of the
64810 variable x, providing that it can be found in
small integer form.
FINDY: Finds the value of small integer y.
64828
FINDF: Finds the value of small integer f, giving the
64842 report 'Q Parameter error' if the value is outside
the range 6 to 15.
FINDS: Finds the start address and length of the text
64866 string s$.
SCAN: Subroutine which searches the variable area for the
64880 variable specified in VARSC. If the variable speci-
fied is not found then the report '2 Variable not
found' is given. Note that the routine distinguishes
between, for example, x as the control variable of a
FOR-NEXT loop, and x as a simple numeric variable.
INIT: This calculates the maximum number of pixel grids on
64954 a line (the number of pixels in the x direction is
defined by the simple numeric variable f).
START: This takes the characters from the string s$ sequen-
64985 tially and prints them, such that the specified num-
ber of pixels occur between successive characters.
If there are more characters in the text string than
can fit on the line, then the routine will automati-
cally print to the end of that line and then carry
on printing on a line eight pixels down. The routine
ensures that a character may never straddle a line.
If the message was begun on line 0 (the bottom of
the screen) and has to be continued on the next
line, or indeed, if any message runs out of space
on the screen, the routine will automatically scroll
the screen up eight pixel lines with no 'scroll?'
prompt.
CHRS: The first part of this subroutine finds out which
65075 kind of character is to be printed: control charac-
ters, those with codes less than 32, are printed as
normal; keyword tokens, characters with codes great-
er than 164, are not printed at all; any remaining
characters are to be printed using the routine.
Before a character can be printed the routine must
find out where the data defining the character is
stored. If the character is part of the 'normal'
character set, i.e. its code is between 32 and 127
inclusive, then the bytes defining it are in the
area starting at the address given by the system
variable CHARS (23606)+256. If the character is a
user-definable character, then the defining bytes
are in the area pointed to by the system variable
UDG (23675). If the character is a block graphic
then the defining bytes are created by manipulating
its character code. In all cases the 8 defining
bytes are transferred to the workspace.
WHERE: This uses the current row and column values to find
65184 the correct address in the display file for each of
the eight bytes of the character. It also colours
the appropriate attribute squares.
The position at which text is started is defined by the
values of the simple numeric variables x and y. X is the
x coordinate of the pixel at the bottom left of the first
character, and y is the y coordinate. If y is greater than
167 then part or all of the start of the text will be
printed off the top of the screen.
The simple variable f contains the number of x pixels
per character grid. For the relation between f and the
characters printed per line, see Table 1.
The variables x and y follow the coordinate system for
high resolution plotting as opposed to the PRINT AT coordi-
nate system. That gives a range of 0 to 255 for x, and to
175 for y.
S$ contains the text to be printed and must be a simple
string. To print an element of a string array, for example,
element three of array x$, use LET s$=x$(3), and then
proceed.
To set the colours of the text a PRINT line may be in-
serted before the call to Multipitch:
PRINT PAPER 3; INK 7; FLASH 1; RANDOMIZE USR 64810/32080
would print the text in flashing white on magenta. If the
required attribute value is known then it may be POKEd
directly into ATTR T (23695).
Note that unless specified then the value will default to
that held in BORDCR (23624).
It is a good idea to ensure that the parameters x, y
and f are being held in small integer form, especially if
their values are derived by calculation, by inserting the
following line:
LET x=INT x: LET y=INT y: LET f=INT f
The colours of the text are always loaded into the
attribute file in such a way as to ensure that all charac-
ters in the text are affected.