Popular Computing Weekly 10/06/1982 Page 21

Spectrum Programming

In this new slot various contributors explore different aspects of the ZX
Spectrum.

Who's a bright little flasher then?

Nick Hampshire continues his discussion of the ZX Spectrum colour commands.

The commands used to set up the colour and display attributes were examined in
last week's article. Having used these commands to create a colour display
there are a series of commands which can be used to control the way particular
characters are displayed without actually altering the dot pattern of colours
of each character space.

The first three of these commands are BRIGHT, INVERSE and FLASH.

The BRIGHT command will display the background colour of the printed string
following the BRIGHT statement with an enhanced brightness. This means that it
will stand out in relation to other displayed strings which are used without
the BRIGHT command.

The number following the BRIGHT command determines whether it is turned on or
off. A 0 and the "bright" is off. A 1 and the "bright" is on. The following is
an example of a command using BRIGHT:

10 PRINT INK 0;PAPER 7;BRIGHT 1;"THIS IS IN BRIGHT MODE"
20 PRINT INK 0;PAPER 7;BRIGHT 0;"THE BRIGHT MODE IS TURNED OFF"

The INVERSE command simply reverses the foreground and background colours for
the characters in the printed string after the INVERSE command. It does this
without changing the dot pattern printed in the screen.

To turn the INVERSE command on it should be followed by a 1, and to turn it off
it should be followed by a 0. The following is and example of the INVERSE
command:

10 PRINT INK 0;PAPER 7;INVERSE 1;"CHARACTERS ARE INVERSED"
20 PRINT INK 0;PAPER 7;INVERSE 0;"CHARACTERS RETURNED TO NORMAL"

The FLASH command is used to set a following character string to flash on and
off between the normal screen display and the inverted display produced by the
INVERSE command. The rate of flashing is about three times a second.

This command, like the previous two command, is very useful in drawing
attention to a displayed statement of command. The following is an example of
the FLASH command:

10 INPUT FLASH 1;INK 1;PAPER 7;"INPUT DATA";N

The Spectrum has a very useful overprinting command called OVER which allows
the creation of new characters by over printing one or more characters over an
existing character. The most obvious use of this command is to add an accent to
a character.

Normally when a character is displayed, and another character previously
occupies that space then whatever is already written in that character space is
obliterated. In the OVER command the existing character is retained and the
dots of the new character added.

As with the previous commands following it with a 1 will turn it on and a 0
will turn it off. The following is an example of the OVER command:

10 OVER 1
20 PRINT "a";CHR$8;""";

The CHR$8 causes the cursor to back up one character space. All the commands
which control the attribute of a character can also be set using the character
codes which represent the command; the following command and codes are
identical:

CHR$ 16 - INK command
CHR$ 17 - PAPER command
CHR$ 18 - FLASH command
CHR$ 19 - BRIGHT command
CHR$ 20 - INVERSE command
CHR$ 21 - OVER command

Note:

None of the example programs listed in this article have any BRIGHT, INVERSE or
OVER commands in them, so I assume that the example programs are incorrect.

See programs:

"Rainbow 2" and "Kinetic Art"

Also see attached PDF image "PopularComputing_Weekly-Issue_1982-06-10_0020.jpeg"