Classic Computer Magazine Archive COMPUTE! ISSUE 89 / OCTOBER 1987 / PAGE 86

Smooth Out For The Atari

James Hague

This sophisticated graphics technique lets you smooth out of the rough lines of your graphics screens in mere seconds. For the Atari 400, 800 XL, and XE with 48K or more of RAM.

One of the strangest of the many graphics modes of the Atari eight-bit computers is GRAPHICS 9. It allows as many as 16 different shades of each color. That's twice the number of intensities available on the Atari ST. But that doesn't mean that you can get ST-quality pictures on the eight-bit machines—the resolution simply isn't high enough. While an ST's "low-resolution" screen offers 320×200 pixels, GRAPHICS 9 is limited to 80×192 pixels.

When you draw on such a low-resolution screen, you're likely to see jaggies, the stairstep effects you see on lines that are drawn at an angle (nonhorizontal or nonvertical lines). One common method used to eliminate jaggies is antiliasing, a complex smoothing method used in advanced paint programs such as Deluxe Paint II. In "Smooth Out," a related method—pixel averaging—is used to smooth the entire screen at once.

Pixel averaging smooths pictures by blurring them. As a result, the process is better suited to landscapes and portraits than to bar charts and boxes.

Typing It In

Type in Program 1 and save it to tape or disk. Do not run the program yet—it is not a complete program until you add the lines from either Program 2 or Program 3.

Program 2 is a very short demonstration of Smooth Out. Load Program 1, type in the lines from Program 2 and then save the resulting program with a unique filename. Program 3 draws an alien landscape. Follow the same procedure with Program 3 as you did with Program 2.

When you're ready to try one of the sample programs, load it and type RUN. A picture is drawn on then screen. When the picture is finished, you'll hear a tone. Press START, and Smooth Out will Smooth the screen with a machine language subroutine. Press START again to end the program.

Behind The Scene

Pixel averaging can be done in many ways. The smoothing algorithm used here adds up the values of the surrounding eight pixels and divides the total by 8 to find the new value of the pixel. This must be done for each pixel on the screen. In machine language, the task takes seconds. If i had used BASIC, it would have taken more than 30 minutes.

If you want to use this program with your own graphics screens, insert the lines to draw your GRAPHICS 9 screen between lines 100 and 5000 of Program 1. (Be sure not to remove line 100.)

For an interesting effect, try changing the GRAPHICS 9 statements in the programs to GRAPHICS 11.(See lines 100 and 5040.)

For Instructions on entering these programs, please refer to "COMPUTE!'s Guide to Typing in Programs" elsewhere in this issue.

Program 1: Smooth Out

BG	90	 REM COPYRIGHT 1987 COMPUTE! PUBLICATIONS, INC. ALL RIGHTS RESERVED.
JI	92	 PRINT "{CLEAR} COPYRIGHT 1987 " : PRINT "COMPUTE! PUBLICATIONS, INC." : PRINT "ALL RIGHTS RESERVED."
FE	94	 FOR X = 1 TO 1500 : NEXT X
Ln	96	 PRINT "{CLEAR}"
HB	100	 MEMTOP = PEEK (106) : GRAPHICS 9
CJ	5000	 IF PEEK (1540) <> 205 AND PEEK (1542) <>39 THEN RESTORE 5200 : FOR A = 0 TO 153 : READ B : POKE 1536 + A, B : NEXT A
AM	5010	 GOSUB 5100
KP	5020	 POKE 203, PEEK (88) : POKE 204, PEEK (89)
GA	5030	 POKE 106, PEEK (106)-48
FD	5040	 GRAPHICS 9
GC	5050	 A = USR (1536)
BB	5060	 GOSUB 5100
EL	5070	 POKE 106, MEMTOP : GRAPHICS 0
KE	5080	 END
GC	5100	 FOR A = 15 TO 0 STEP –1 : SOUND 0, 100, 10, A : NEXT A
HM	5110	 IF PEEK (53279)<> 6 THEN 5110
KI	5120	 RETURN
OH	5200	 DATA 104, 169, 0, 133, 205, 160
AC	5210	 DATA 39, 177, 203, 145, 88, 136
PE	5220	 DATA 16, 249, 160, 40, 177, 203
AF	5230	 DATA 145, 88, 160, 79, 177, 203
AD	5240	 DATA 145, 88, 169, 81, 133, 203
JC	5250	 DATA 169, 0, 133, 207, 162, 7
MB	5260	 DATA 165, 206, 24, 125, 146, 6
ND	5270	 DATA 74, 144, 8, 168, 177, 203DI	5280	DATA 41, 15, 76, 60, 6,1 6B
KB	5290	DATA 177, 203, 74, 74, 7, 4, 74
BD	5300	DATA 24, 101, 207, 133, 207, 202
PB	5310	DATA 16, 224, 165, 206, 74, 144
KD	5320	DATA 9, 168, 165, 207, 7, 4, 74
HK	5330	DATA 74, 76, 88, 6, 168, 165
IP	5340	DATA 207, 10, 41, 240, 1, 7, 88
CO	5350	DATA 145, 88, 230, 206, 165, 206
BA	5360	DATA 201,159, 208, 186, 165, 203
DN	5370	DATA 24, 105, 40, 133, 2, 03, 165
DL	5380	DATA 204, 105, 0, 133, 2, 04, 165
JD	5390	DATA 88, 24, 105, 40, 13, 3, 88
JK	5400	DATA 165, 89, 105, 0, 13, 3, 89
EM	5410	DATA 230, 205, 165, 205, 201, 190
CE	5420	DATA 208, 136, 160, 40, 177, 203
PM	5430	DATA 145, 88, 200, 192, B0, 20B
EF	5440	DATA 247, 96, 175, 176, 177, 255
ND	5450	DATA 1, 79, 80, 81

Program 2: Smooth Out Demo

DC	110	FOR A = 1 To 25
LL	120	X = INT (RND (0) * 57)+1
DH	130	Y = INT (RND (0) * 150)+1
EG	140	COLOR INT (RND (0) * 16)
DE	150	FOR B = X TO X+19
KI	160	PLOT X+10, Y :DRAWTO B, Y+39
ND	170	NEXT B :NEXT A
Program 3: Alien Landscape
CL	110	COLOR 12 :PLOT 0, 0 :DRAWTO 79, 0 :DRAWTO 79, 191 :DRAWTO 0, 191 :DRAWTO 0,0
PO	120	FOR A = 1 TO 2
DF	130	IF A = 1 THEN X=30 :Y=30 :GOTO 150
MI	140	X = 55:Y = 40
DP	150	FOR B=1 TO 78
NL	160	COLOR INT (RND (0) * 5)+2 :PLOT X, Y :DRAWTO B,135
ND	170	NEXT B :NEXT A
DI	180	FOR A = 130 TO 190 :COLOR INT (RND (0) * 7) +5 :PLOT 1, A :DRAWTO 39, A—5 : DRAWTO78, A :NEXT A
AF	190	FOR A = 1 TO 2
DN	200	IF A = 1 THEN X=55 :Y=80 :GOTO 220
NC	210	X = 39 : Y = 95
KL	220	FOR B = 1 TO 78 STEP 2
AI	230	COLOR INT (RND(0) * 10)+4 : PLOT X, Y : DRAWTO B,190
NB	240	NEXT B : NEXT A
DH	250	FOR A = 1 TO 25
KM	260	COLOR INT (RND (0) * 10) + 5 : PLOT 1, 70 : DRAWTO A, 190 : NEXT A