Brass (GRAPHICS 9 Demo)

Type
Graphics
Category
GTIA shading demo
Author
Unknown (early GTIA demonstration program, author not identified in the book)
Published in
The Creative Atari (Creative Computing Press, 1983), "Design Philosophy and GTIA Demos"
Year
1983
Language
Atari BASIC
Requirements
GTIA chip (any XL/XE or later 400/800); 16K RAM; Atari BASIC
Six shaded golden cylinders in a staggered row, drawn in GRAPHICS 9

About the program

The demos come from the "Design Philosophy and GTIA Demos" chapter of The Creative Atari. The column's writer explained that Atari had started fitting the new GTIA chip to all Atari 800s in January 1982, and that the chip added three graphics modes. He didn't know who had written these little demonstration programs. He guessed they came from somebody at Atari with an early sample of the chip, and he asked the author to get in touch so that he could give credit.

Brass is the shortest of the set and the only one that uses GRAPHICS 9. In that GTIA mode every pixel can have any of 16 luminances of a single hue. The program draws six polished brass cylinders standing in a staggered row, each one partly hiding the one behind it. Each has a bright highlight down the middle, darker edges and a rounded end cap shaded the opposite way. It is a good demonstration of the 3-D shading that the 16-shade mode makes possible.

What you need

  • A GTIA machine: any XL/XE, a 400/800 built from 1982 on, or an emulator such as Altirra. CTIA machines run the program but show the wrong colours.
  • 16K RAM, Atari BASIC.

Typing it in

This one is easy: 16 lines of plain ASCII and no machine code. Line 200 just loops for ever to hold the picture, so press BREAK when you're done.

How to use it

RUN it. When the picture is complete, the program waits in line 200.

How it works

  • GRAPHICS 9 gives a 80×192 screen with 16 shades. SETCOLOR 4,15,0 uses the background register to pick hue 15 for all of them.
  • Each cylinder is 25 pixels wide (X=0 TO 24). Line 40 makes the shade C rise towards the middle column and fall again. Line 45 adds 3 so that the edges are never black. So the centre is brightest, just like light on a real cylinder.
  • Line 55 works out the half-height D of a circle across the cylinder's width (SQR(144-(X-12)^2)/2). Lines 57–60 draw the elliptical end cap in the inverse shade (15-C). Then line 80 draws the long body down the screen in shade C.
  • Line 50 (Z=Y+X) offsets each cylinder sideways as Y changes. The first one drawn is the small one at the back right, and each new one is drawn further left and taller, overlapping the last, so the row steps diagonally across the screen.

Variations to try

  • Change the hue in line 15. Hue 0 gives grey steel, and hue 9 gives cool blue.
  • Change STEP -10 in line 20 to space the cylinders differently.
  • Replace line 200 with a loop that changes SETCOLOR 4,H,0, so that the metal shifts hue.

Listing

10 GRAPHICS 9
15 SETCOLOR 4,15,0
20 FOR Y=55 TO 0 STEP -10
30 FOR X=0 TO 24
40 C=X:IF X>11 THEN C=24-X
45 C=C+3
50 Z=Y+(X)
55 D=INT(SQR(144-(X-12)*(X-12)))/2
57 COLOR 15-C
58 PLOT Z,Y+7-D
60 DRAWTO Z,Y+7+D
70 COLOR C
80 DRAWTO Z,180-Y+D
180 NEXT X
190 NEXT Y
200 GOTO 200

Credits