First Steps

by Mark Hutchinson

 

Issue 27

May/Jun 87

Next Article >>

<< Prev Article

 

 

Mark Hutchinson's regular column for beginners

CONTINUING GRAPHICS

This issue I will continue with a look at the Graphics modes but we will leave the text modes and have a quick look around the modes available for proper graphics.

As I explained in the last issue, all the modes are basically the same but they are utilised by the computer in different ways. Have a look at figure 1. This will show you each mode with its related colour, co-ordinates and memory size. This should be self explanatory, the only point of interest is GR.8 which has one plot colour, but has two luminances.

COLOR and SETCOLOR

These commands tend to cause a bit of confusion in the graphic modes so let's have a closer look at them.
SETCOLOR does not change screen colours directly but changes the colour stored in a certain COLOR register. There can be up to four of these COLOR registers used in each graphic mode (see figure 2). Colour can also be changed by POKEing the appropriate memory location. For instance, SETCOLOR 0,hue,luminance or its equivalent POKE 708,16*hue + luminance will do the same job. So, if hue = 4 and luminance = 10, you would use POKE 708,74. Figure 2 shows the SETCOLOR command and the equivalent memory location.

COLOR in a graphics mode will define the register to be used for drawing points; in a text mode it will give the ASCII character. For a four colour mode, such as GR.7, COLOR will be 0 for background colour and 1 to 3 for points. If the value is 4 then the real value for the register is set to 0 again, i.e. the value will cycle from 0 to 3 then start off at 0 again. In a two colour mode, such as GR.4, the values are 0 and 1 only. Above that the cycling begins.

GR.8 is a one colour mode so COLOR is used to set the luminance of the plotted point. The colour of this point will be the same as the background, and luminance will either show or hide the point.

To recap, COLOR 1, 2, 3 or 4 will display a point in a certain colour and SETCOLOR will change this colour. COLOR 0 will set the point colour to that of the background, effectively erasing the point. Figure 3 shows the modes and associated COLOR/SETCOLOR commands.

A DEMONSTRATION

To demonstrate the differences between all of the graphics modes, I wrote LISTING 2. This program will set up all of the modes and flip between each. I had hoped to write about page flipping during the summer but I was beaten to it by Allan Knopp in issue 25! As can be seen from figure 1, graphics 8 uses a massive amount of memory. This is because it uses very fine points (pixels or picture elements) to draw lines. Each point will have its value stored in RAM and this is termed a memory mapped screen. Because the screen is so finely drawn, a strange effect occurs known as artifacting. Listing 2 should should demonstrate this effect nicely.

GR. MODE

HORIZ COLMS

VERT ROWS

No.of COLRS

LINE TYPE

MEM

SIZE

0

40

24

2

TEXT

993

1 20 24 5 TEXT 543
2 20 12 5 TEXT 261
3 40 24 4 PLOT 273
4 80 48 2 PLOT 537
5 80 48 4 PLOT 1017
6 160 96 2 PLOT 2025
7 160 96 4 PLOT 3945
8 320 192 1/2 PLOT 7900

Figure 1 - GRAPHICS MODES

If you find that the program will not run due to memory constraints, GRAPHICS 8 (lines 639 to 660 and line 1050) can be deleted and if necessary GRAPHICS 7 (lines 609 to 630 and line 1040). Remember to set counter G (line 710) to the appropriate value.

THANKS FOR WRITING

I would like to thank Brian Trevett for his kind letter. I am glad that I was able to be of such help. If any beginners need some advice that would take too long to explain here, I can be reached (with an SAE please) at the following new address.

1, HOLLYMOUNT,

ERINVALE, FINAGHY

BELFAST
BT10 OGL

Finally, a couple of tips from Mr. Robinson of Cumbria. You may know that LIST will display the complete listing of a program, but did you know that you can display a series of line numbers? LIST 100,120 will display all line numbers from 100 to 120 inclusive. This will also apply to a single line, eg. LIST 100.

When you use the TAB key to move the cursor across the screen, the default is 10. This is stored in location 201, so POKE any suitable number in here to change the TAB spacing. Hands up who knew that a comma causes tabbing. Try the following line to see what I mean.

PRINT "A","B""C"

See you next issue when we might take a look at animation.

___________

 

SETCOLOR NUMBER MEMORY LOCATION
0 708
1 709
2 710
3 711
4 712

Figure 2 - SETCOLOR EQUIVALENTS

MODE No. SETCOLOR NUMBER COLOR NO. USE
0 0 0-255 -
  1 GIVES CHARACTER LUM
ALSO 2 CHAR- BACKGROUND
TEXT 3 ACTER -
WINDOWS 4   BORDER
       
1,2 0 0-255 CHARACTER
  1 GIVES CHARACTER
TEXT 2 CHAR- CHARACTER
MODES 3 ACTER CHARACTER
  4   BACKGROUND, BORDER
       
3,5,7 0 1 POINT
  1 2 POINT
FOUR 2 3 POINT
COLOR 3 - -
MODES 4 0 BACKGROUND, BORDER
       
4,6 0 1 POINT
  1 - -
TWO 2 - -
COLOUR 3 - -
MODES 4 0 BACKGROUND, BORDER
       
8 0 - -
  1 1 POINT (LUM)
1 COLOR 2 0 BACKGROUND
2 LUM. 3 - -
  4 - BORDER
       
The COLOR number defines the point to be used (with its associated SETCOLOR statement) in a graphics mode. In a text mode, COLOR defines the character to be plotted

Where background is stated in graphic modes, any point using that colour number takes the background colour, effectively disappearing.

Mode 8 has one colour, that of the background, but has two luminances. One makes the point stand-out,-the other makes it disappear.

Figure 3

AtariLister - requires Java

Listing 1

AtariLister - requires Java

Listing 2

top