Graphics Modes Tour (New Owners Column, Lesson 12)
- Type
- Graphics
- Category
- Beginner's BASIC lesson program (graphics modes demo)
- Author
- David Plotkin (lesson) and Charles Jackson (program)
- Published in
- Antic, March 1987 (Vol. 5, No. 11), New Owners Column, Lesson 12: Graphics Modes
- Year
- 1987
- Language
- Atari BASIC
- Requirements
- Any Atari 8-bit, Atari BASIC; a GTIA chip for GRAPHICS 9–11
About the program
By Lesson 12 (Antic, March 1987), David Plotkin's New Owners Column had reached the subject many readers had been waiting for: graphics. The article introduces the twelve modes you get with a simple GRAPHICS command. It covers the three text modes and the nine "dot" modes, and the trade-off between resolution, number of colours and memory, from GRAPHICS 3's 40 × 24 to GRAPHICS 8's 320 × 192 and the 16-shade and 16-hue GTIA modes 9 and 11. It also explains adding 16 to remove the text window and 32 to keep the screen from clearing, POSITION and PRINT #6, and the trick of getting four colours of text in GRAPHICS 1 and 2 from capitals, lower case and inverse.
The demo was written by Antic Technical Editor Charles Jackson, and the article calls it "a flashy visual demonstration". It begins with a colour-cycling GRAPHICS 1 text screen and a GRAPHICS 2 screen, then steps through modes 3 to 11, drawing a bouncing, rotating line in each one. While it draws, the text window shows the mode, its size in pixels, the number of colours and the colour being used.
Typing it in
Short and almost entirely plain BASIC. The GRAPHICS 1 and 2 title text deliberately mixes capitals, lower case and inverse letters ({inv}…{/inv}, Atari key), because each kind appears in a different colour. That's the lesson's four-colour-text trick. Line 812 starts with {CLEAR} (ESC then SHIFT-CLEAR). The listing's REM says © 1986, though it appeared in the March 1987 issue.
How to use it
Press any key to go from the GRAPHICS 1 screen to GRAPHICS 2, where the text window flashes on and off. Press a key again for the graphics modes. A beep tells you each drawing is finished. Then press START to draw another line in the same mode with a new colour, or SELECT to move on to the next mode. GRAPHICS 9, 10 and 11 have no text window, so you'll have to remember the keys. After GRAPHICS 11 the program ends.
How it works
- Colour rotation. Lines 70–90 shift the values of colour registers 708–711 round in a circle, so the GRAPHICS 1 letters seem to change colour.
X=SIN(4)is a deliberate time-waster: the trigonometry is slow, so it makes a neat short delay. - Flashing text window. Lines 120–140 switch between
GRAPHICS 2+32(with a text window, without clearing the screen) andGRAPHICS 2+16+32(full screen, still not clearing). The big text stays put while the window comes and goes. - One drawing routine for every mode. Lines 150–230 set
GMODE,WIDTH,HEIGHTandMAXKLRfor each mode and call line 800. That routine chooses two random phase angles and, for each row, works out two points on sine waves. It plots one, thenDRAWTOs the other, mirrored. The changing angles make the line appear to bounce and twist. In modes 9 and 11, the colour is chosen from even numbers only (line 910). - GRAPHICS 10 colours. Line 35
POKEs 704–707, the four extra colour registers that only GRAPHICS 10 uses, becauseSETCOLORcan't reach them. - Line 1000 is a short pause. It zeroes the real-time clock at location 20 and waits for 50 ticks (one tick per TV frame).
Variations to try
Change the STEP in line 840 for denser or sparser line patterns, or replace SIN with COS in one of lines 850–860 and watch the shapes change.
Listing
10 REM THE NEW OWNERS COLUMN #12
20 REM BY DAVE PLOTKIN
25 REM (DEMO PROGRAM BY CHARLES JACKSON)
30 REM (c) 1986, ANTIC PUBLISHING
35 POKE 704,50:POKE 705,180:POKE 706,30:POKE 707,146
40 GRAPHICS 1+16
50 POSITION 5,4:? #6;"Th{inv}Is{/inv} Is"
60 POSITION 3,8:? #6;"{inv}G{/inv}rA{inv}pH{/inv}iC{inv}s{/inv} {inv}O{/inv}nE"
65 POSITION 2,15:? #6;"Pr{inv}Es{/inv}S a{inv}Ny{/inv} Ke{inv}Y{/inv}";CHR$(129):POKE 764,255
70 TEMP=PEEK(711):POKE 711,PEEK(710):X=SIN(4)
80 POKE (710),PEEK(709):X=SIN(4):POKE 709,PEEK(708):X=SIN(4)
90 POKE 708,TEMP:X=SIN(4):IF PEEK(764)=255 THEN 70
100 POKE 764,255:GRAPHICS 2+16
110 POSITION 4,4:? #6;"Gr{inv}Ap{/inv}Hi{inv}Cs{/inv} 2"
120 GOSUB 1000:GRAPHICS 2+32:? CHR$(125);"(HERE'S THE TEXT WINDOW)"
130 ? :? " -> Press any key <- "
140 GOSUB 1000:GRAPHICS 2+16+32:IF PEEK(764)=255 THEN 120
145 REM NOW LET'S SEE GR. 3-11
150 GMODE=3:WIDTH=39:HEIGHT=19:MAXKLR=4:GOSUB 800
160 GMODE=4:WIDTH=79:HEIGHT=39:MAXKLR=2:GOSUB 800
170 GMODE=5:WIDTH=79:HEIGHT=39:MAXKLR=4:GOSUB 800
180 GMODE=6:WIDTH=159:HEIGHT=79:MAXKLR=2:GOSUB 800
190 GMODE=7:WIDTH=159:HEIGHT=79:MAXKLR=4:GOSUB 800
200 GMODE=8:WIDTH=319:HEIGHT=159:MAXKLR=2:GOSUB 800
210 GMODE=9:WIDTH=79:HEIGHT=191:MAXKLR=16:GOSUB 800
220 GMODE=10:WIDTH=79:HEIGHT=191:MAXKLR=9:GOSUB 800
230 GMODE=11:WIDTH=79:HEIGHT=191:MAXKLR=16:GOSUB 800
240 END
799 REM RANDOMLY SELECT TWO SINE WAVES AND DRAW A LINE BETWEEN CORRESPONDING POINTS
800 GRAPHICS GMODE:K=1:DEG :IF GMODE>8 THEN K=8
810 COLOR K:IF GMODE>8 THEN 820
812 ? "{CLEAR}GRAPHICS ";GMODE;" (";WIDTH+1;" x ";HEIGHT+1;", ";MAXKLR;
815 ? " colors)":? :? " Drawing in COLOR ";K
820 FACT=INT(RND(0)*180):POKE 764,255
830 FACT2=INT(RND(0)*180)
840 FOR X=(HEIGHT*-1) TO HEIGHT STEP 2+INT(RND(0)*GMODE)
850 Y1=ABS(SIN(FACT+X)*WIDTH)
860 Y2=ABS(SIN(FACT2+X)*WIDTH)
870 PLOT Y1,ABS(X):DRAWTO Y2,HEIGHT-ABS(X)
880 NEXT X:SOUND 0,75,14,14:GOSUB 1000:SOUND 0,0,0,0:POKE 77,0
890 IF GMODE<9 THEN ? "{CLEAR}Press [SELECT] to change GR. modes.":? :? "Press [START] to continue."
900 ON (PEEK(53279)) GOTO 900,900,900,900,920,910,900
910 K=INT(RND(0)*MAXKLR):IF MAXKLR=16 AND K/2<>INT(K/2) THEN 910
915 GOTO 810
920 RETURN
999 END
1000 POKE 20,0:REM GENERIC TIMER ROUTINE
1010 IF PEEK(20)<50 THEN 1010
1020 RETURN
Download
The original program from the Antic disk, to LOAD or ENTER instead of typing it: NEWOWN12.BAS.
Credits
- Program listing: Graphics Modes Tour (New Owners Column, Lesson 12) — program listing (Antic, March 1987 (Vol. 5, No. 11), New Owners Column, Lesson 12: Graphics Modes) — David Plotkin (lesson) and Charles Jackson (program)
- Picture: The bouncing line in GRAPHICS 8, the 320 × 192 high-resolution mode. — David Plotkin (lesson) and Charles Jackson (program) (program); screenshot by the site
- Antic, March 1987 (Vol. 5 No. 11): New Owners Column, Lesson 12 - Graphics Modes, article by David Plotkin, program by Charles Jackson (atarimagazines.com) — David Plotkin (lesson) and Charles Jackson (program), 1987
- Antic Software Archive — March 1987 - Vol. 5 No. 11 disk: NEWOWN12.BAS — AtariMagazines.com (Kevin Savetz), 1987
