Melons (GTIA Demo)
- Type
- Graphics
- Category
- GTIA graphics 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
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.
Melons draws a still life rather than an abstract pattern: two halves of a melon, mirrored left and right with their cut faces towards the middle. Each half has curved stripes of rind in seven shades and a purple cut face scattered with dark seeds. It shows how GRAPHICS 10's nine freely chosen colours (one background colour plus eight drawing colours) let you shade a solid-looking object.
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
The listing is plain ASCII, and ? is the usual shorthand for PRINT. Line 9 is long but stays inside Atari BASIC's limit if you type it exactly as shown. There is one small difference from the printed book. Line 1000 here begins 226,223,230, but the original printed page has 226,228,230. The values go up and down in steps of two, so 228 is almost certainly what was meant. Either value works, because it only sets one shade. Lines 30000–31010 are the same machine-language loader used by the other demos in the chapter. Type the DATA carefully.
How to use it
RUN it. The screen counts from 0 to 90 while the program builds its sine table. Then the GRAPHICS 10 picture is drawn. The program then sits in an endless loop (lines 900–920). Press BREAK to stop.
How it works
DEGputs the trig functions into degrees. Line 9 works outSINfor 0–90 degrees only, and uses symmetry to fill the arraySINE()up to 450 degrees. After that, a cosine is justSINE(ANG+90). Table lookups are much faster than callingSINrepeatedly.- Lines 30–110 draw a family of quarter-ellipse arcs.
Ashrinks the vertical radius step by step from 30 to −29, so the arcs sweep from one side of the fruit to the other, and line 95 changes colour for each arc. On the second pass (P=2),Z=79-Xmirrors everything to make the right-hand half. - Lines 200–260 fill a narrow ellipse at the inner end of each half with
COLOR 8, which makes the cut face. Lines 300–350 plot 25 random background-coloured pixels as seeds. - Line 15 loads registers 705–712 from line 1000: hue 14 at rising and falling luminances, with 70 for colour 8.
Variations to try
The routine that spins the colours is loaded in line 3 but never used, because line 900 starts with REM. Remove the REM and the melon stripes will shimmer. You can also change line 1000 to recolour the fruit (each value is hue×16+luminance).
Listing
2 DIM A$(30),SINE(450)
3 GOSUB 30000
4 DEG
9 FOR I=0 TO 90:? I:A=SIN(I):SINE(I)=A:SINE(180-I)=A:SINE(180+I)=-A:SINE(360-I)=-A:SINE(360+I)=A:NEXT I
10 GRAPHICS 10
15 RESTORE :FOR I=1 TO 8:READ A:POKE 704+I,A:NEXT I
18 FOR P=1 TO 2
20 Q=1
25 A=30
30 FOR ANG=180 TO 270 STEP 8
40 X=20*SINE(ANG+90)+25
50 Y=A*SINE(ANG)
55 Z=X:IF P=2 THEN Z=79-X
60 COLOR Q
65 IF ANG=180 THEN OLDX=Z:OLDY=Y
70 PLOT OLDX,96+OLDY
75 DRAWTO Z,96+Y
77 OLDX=Z:OLDY=Y
80 REM
90 NEXT ANG
95 Q=Q+1:IF Q>7 THEN Q=1
100 A=A-1
110 IF A>-30 THEN 30
200 FOR ANG=0 TO 180 STEP 10
210 COLOR 8
220 X=4*SINE(ANG+90)+25
225 Z=X:IF P=2 THEN Z=79-X
230 Y=30*SINE(ANG)
240 PLOT Z,96+Y
250 DRAWTO Z,96-Y
260 NEXT ANG
300 FOR I=1 TO 25
310 X=RND(0)*6+23
315 Z=X:IF P=2 THEN Z=79-X
320 Y=RND(0)*50+71
330 COLOR 0
340 PLOT Z,Y
350 NEXT I
400 NEXT P
900 REM X=USR(ADR(A$))
910 FOR J=1 TO 10:NEXT J
920 GOTO 900
1000 DATA 226,223,230,232,230,228,226,70
30000 REM *** SET UP ASSI PROGRAM
30010 RESTORE 31000
30020 FOR Z=1 TO 27
30030 READ X:A$(Z)=CHR$(X)
30040 NEXT Z
30050 RESTORE
30060 RETURN
31000 DATA 104,162,0,172,193,2,189,194,2,157,193,2,232,224,8,144,245,140,200
31010 DATA 2,96,65,65,65,65,65,65
Credits
- Program listing: Melons (GTIA Demo) — program listing (The Creative Atari (Creative Computing Press, 1983), "Design Philosophy and GTIA Demos") — Unknown (early GTIA demonstration program, author not identified in the book)
- Picture: Melons: the finished still life. — Unknown (early GTIA demonstration program, author not identified in the book) (program); screenshot by the site
- The Creative Atari — Design Philosophy and GTIA Demos (atariarchives.org) — Unknown (early GTIA demonstration program, author not identified in the book)
- The Creative Atari — book index (atariarchives.org) — AtariArchives.org
- COMPUTE!'s Second Book of Atari Graphics — GTIA: An Illustrated Overview — AtariArchives.org
