3D HISTOGRAM

------------

by Peter Shaw

from ZX Computing, October/November 1983



Peter Shaw holds tutorial on the subject of graphics on the ZX Spectrum. Pull

up a chair, plug in your computer and read on ...





There are a number of different methods to define characters on the Spectrum

 some easy to understand, others totally incomprehensible. I saw one very

interesting method POKEd, line by line. This is obviously not satisfactory

when you have 21 characters to define. You would need 168 lines to POKE

everything into the memory  that's lines 10 to 1680 using the conventional

spacing system! There has to be a better method than that.



To cut down on the amount of typing we have to do, we can change the way we

define our characters. To start with I will deal with the use of BIN. The

Sinclair manual suggests that you use BIN when defining but I think this is a

very long-winded way of doing it.



A binary number can be thought of as eight on/off switches each with a value;

when the switch is on, it takes the value and when the switch off, it becomes

zero. The value of each switch is worked out from a power; ie. 6^2 is six to

the power two, or 36.



For example, take a look at the binary number 00110101. The value of BIN

00110101 0 + 0 + 32 + 16 + 0 + 4 + 0 + 1 = 53. This can be seen fully

illustrated in Fig.1.



And next ...



To turn a binary number into decimal all you need remember is the number in

the top left-hand corner of the boxes so that you can add the 'on' ones

together to get the result. Having converted all your BIN numbers into

decimal you can now move onto the next part of this character generation

method.



The Sinclair manual suggests you use a FOR...NEXT loop of zero to seven for

some characters. I also use a FOR...NEXT loop, but I use it to cover all the

characters to be defined; ie. FOR A=USR "a" TO USR "(last character to be

defined)" + 7. Inside the loop I READ all the decimal values and POKE them

into the variable 'a'.



10 FOR a=USR "a" TO USR "a"+7 : REM this will require eight numbers in DATA statements

20 READ user: POKE a,user

30 NEXT a

40 DATA 255,0,255,0,255,0,255,0



Try this program above. As you can see, the FOR...NEXT loop can be anything

from one to 21 characters long. The DATA statement at the end contains the

eight numbers required to create a striped character.



At the bar



Enough said about user-definable graphics  what about programs which

demonstrate high resolution graphics on the Spectrum? Well, first up is a 3D

Histogram program, which although not really very useful in any practical

way, is a good demonstraton of colour and Hi-res in action. The program

surprisingly only uses two UDG characters, which have been POKEd in using the

method shown previously.



Quick on the draw



Once you've tried the Histogram program, you can move onto the next program,

Sketch, which is a very sophisticated sketchpad. The controls you'll need to

operate this program are:



F - Flashing cursor

N - Draw mode cursor

D - Draw a line

M - Move cursor

S - Save SCREEN$

V - CLS

C - Circle

O - Change INK colour

P - Change PAPER colour

B - Change BORDER colour

I - Help

