Download Print this page

Atari CX70 Operator's Manual page 38

Light pen

Advertisement

ATARI Light Pen Operator's Manual
The calculation of X and Y coordinates is done by PENBUF not only for
Graphics Mode 23»
but also for Graphics Mode 0. After executing
PENBUFi the Graphics 23 values for X and Y may be obtained from
locations 206 (X) and 207 (Y>. If you are working in Graphics 0>
the
positional values for X and Y are found in locations 208 (X) and 209
<Y>. By peeking at those locations! the program can determine the
coordinates of the pen tip. (Refer to Appendices D and E for the
PENBUF flow chart and assembly language listing.)
Type in and RUN the following program:
10 REM DEMO PROGRAM»SEC 1*3*5, LIGHT PEN IN GRAPHICS 23
30 GRAPHICS 23JCOLOR 2JSETC0L0R ^»0»12JREM LUMINANCE 12 BACKGROUND
"^0 GOSUB 9000JPENBUF='1536:POKE 205,3
50 REM IS PEN DOWN NOW?
60 PRESSED=(PEEK<632)=15)
70 IF
NOT PRESSED THEN 50
80 REM PEN IS PRESSED, SO GO GET A COORDINATE
90 JUNK=USR<PENBUF)
100 X=PEEK<206)
110 Y=PEEK(207>
120 REM PLOT IT
130 PLOT X,Y
140 GOTO 50
9000 REM "LOADER" LOADS "PENBUF" INTO PAGE 6
9010 RESTORE 9020:FOR X=1536 TO 1652:READ PJPOKE X,PJNEXT XJRETURN
9020 DATA 104,162,0,160,6,132,204,173,12,212,201,10,144,3,56,233,228
9030 DATA 24,105,154,160,117,132,203,32,86,6,165,203,24,101,205,133
9040 DATA 203,173,13,212,56,233,16,32,86,6,232,228,205,240,9,165
9050 DATA 20,197,20,240,252,76,7,6,165,205,74,168,177,203,133,207
9060 DATA 169,117,133,203,177,203,133,206,165,206,74,74,133,208,165,207
9070 DATA 74,74,133,209,96,134,206,164,206,192,0,240,20,136,209,203
9080 DATA 200,176,14,136,133,206,177,203,200,145,203,136,165,206,56,176
9090 DATA 232,145,203,96
Figure 11
Programming Example 2: Using PENBUF
Before you RUN the programi refer to the Note accompanying Programming
Example 1. If you go outside the boundaries of Graphics 23«
you will
get an ERROR 141 on LINE 30. To see the boundary* type the suggested
line 15 of Programming Example 1 as line 35 of this program.
When you RUN the program* the light pen will work exactly as in
Programming Example 1. However* the noise spots should now be missing
from the display. The differences between Programming Examples 1 and 2
are as follows:
Line 40 uses a logical (true/false) compare equivalent to line 20 in
Programming Example 1. Lines 50-70 loads PENBUF into the proper area*
defines the entry point to the USR function and sets the number of pen
Using PENBUF - 34

Advertisement

loading