[ The programs described in this article, and entered on

  the accompanying tape, are the most basic of Basic.

  However, the very early date of the article makes it

  a fascinating read, and certainly worth preserving from

  a historical point of view. ]



                   Spectrum Hue and Cry



     The rumpus caused by the Spectrum's graphics and

      sound follows hot on the heels of the micro's

    release. Even those usually blind to the charms of

       Sinclair machines could well succumb to the

   attractions of these low-cost machines. Reviewer Tim

  Hartnell shares the fruits of his graphics session at

                  the Spectrum keyboard.



The new ZX Spectrum is equipped with powerful graphics

commands which can greatly enhance your programs. They are

simple to use, and capable of producing a wide range of

effects.

  The colour command controls the border around the main

display area - accessed by the command Border - the main

display area itself - known as the Paper - and the colour

in which printing is carries out - the Ink.

  Eight colours are available if you include black and

white, and these are numbered from 0 to 7. The colours, and

their corresponding numbers, are:

        0 black

        1 blue

        2 red

        3 purple or magenta

        4 green

        5 pale blue, or cyan

        6 yellow

        7 white

On a black and white television this order represents a

transition of tones of grey, from black 0, through to

white 7.

  When you first turn the Spectrum on, you will have white

Paper, a white Border and black Ink. That is, the screen is

completely white, and any program you enter appears in

black. Ink and Paper can be used globally. If a line in the

program says Paper 6, followed by CLS, clear screen, the

entire background within the border will turn yellow.

Similarly, the program line Ink 2 will ensure that all

printing from that point on appears in red.

  The colours can also be used "locally". If you enter

      PRINT INK 1;PAPER 7;"HI THERE"

the Spectrum will print the words "Hi there" in white[sic]

in a little blue[sic] strip. The same local control is

possible within Input statements. If you want a string

input, you could enter 

INPUT (INK 2;PAPER 6;"What is your name");a$

and the question would be printed in red on a little yellow

strip.

  Entering program 1 will allow you to try out the colour

commands. This goes through all the combinations of Border,

Paper and Ink. It takes quite a long time to run because

there are 512 (8^3) possible combinations, although several

are not very interesting. White ink on white paper with a

white border is not particularly easy to read.

  The clear-screen line, 46 CLS, makes the paper colour

global. With[sic] it, the paper only changes underneath the

words being printed - try the program without line 46. Ink

commands used within a program are automatically local if

coupled directly with a Print or Input statement. A global

Ink command such as Ink 2 for red printing is not changed

by a local Ink command such as

        PRINT INK 1;"test"

as the ink colour reverts to the one which was globally

defined as soon as a Print statement without an ink

parameter appears in the program.

  Program 2 shows how effectively the colours can mix when

they are chosen randomly. The program draws a pyramid of

little coloured blocks. The border flashes alarmingly all

through the program, and finally, line 155, turns blue.

Line 160, which just calls itself, is designed to suppress

the OK report code which would otherwise spoil the display.

Break to escape.

  The little black square at the end of line 100 is

available directly from the keyboard in the graphics mode,

white shift key, then press key 9, and then pressing the

8 key, still holding down the white shift key. Inverses of

other characters are available by simply pressing the Inv

video, white shift key, then the 4 key. You revert to what

is called True video, by pressing the white shift key, and

the 3 key. The black background behind inverse letters

turns into the Ink colour, and the letters themselves turn

into the paper colour, which can look most effective, as

program 3 indicates.

  The Plot commands allow very high-resolution graphics, as

can be seen by running the Galaxy and Solid Sine programs.

Solid Sine is the basis of the program used on the front

cover of this issue of /Your Computer/. YOu will notice

that while the dot resolution is 256 by 192, the colour

resolution is only 32 by 22. In effect, the colour is

mapped on to the Plotted screen.

  Despite this, high-resolution designs can still be

created. You can prove this by entering and running the

next program, Broken Glass, which uses the Draw command.

The paper is set to white in line 30, then the border,

line 50, and the ink colours, line 60, are chosen at

random. Line 70 checks these are different - and if not

chooses a new ink colour.

  The screen is cleared in line 100 and a pair of co-ordi-

nates are chosen randomly. A point is plotted in the

centre of the sccreen, line 130, and a line is drawn from

this point to the previously chosen co-ordinates. The Draw

statement works out how long the line has to be, and at

what angle, but Plot must give it a starting point.

  The Draw command draws lines when the word Draw is fol-

lowed by two numbers. These numbers are the plot co-ordi-

nate of the finishing point of the line. If you add a third

number, the Draw command will draw part of a circle, with

the third number specifying an angle to be turned through.

Broken curves is the same as Broken Glass except for the

end of line 140. This draws a wind-swept version of Broken

Glass, by turning the line through P1/2[sic] radians as it

is plotted.

  The Circle command draws quite good circles. Tunnel

Vision sets a pale blue background, and white paper, then

draws a series of circles in a random colour, around a

centre point which changes a little from circle to circle,

with a random radius. The first number after the word

Circle is the x co-ordinate of the centre, the second is

the y co-ordinate, and the third is the radius.

  If you want to combine colour and sound, enter and run

the Random Music program. Access Beep by pressing both

shift keys, then holding down the red shift while pressing

the Z/Copy key. The first number after the word Beep

controls the duration of the note in seconds, while the

second number is the pitch. The Spectrum has a range of

around 130 semi-tones, with middle-C at 0, C-sharp at 1,

and -1 is the B below middle-C.

  This is just an introduction to some of the graphics

commands on the ZX Spectrum. Experiment with them, enter

and modify the sample programs given, and you are sure to

find many ways of enhancing your own programs.