Download Print this page

Atari CX70 Operator's Manual page 37

Light pen

Advertisement

ATARI Light Pen Operator's Manual
SECTION 6 - PROGRAMMING EXAMPLE 2:
Using PENBUF, a Light Pen Utilitu Program
To minimize noise and to preadjust the X and Y values for you>
ATARI
has developed a machine language program called PENBUF. A BASIC
program to load PENBUF into the correct memory locations is presented
in Figure 10. The use of a language other than BASIC mill work only if
its memory is similarly structured. Primarilyi Page 6 and locations
*CB - *D1 must be free.
PENBUF has two functions: To take the statistical median of a number
of X/ Y readings and to calculate the true Graphics equivalent
positions for X and Y as in lines 40 and 50 of Programming Example 1.
For details on how PENBUF works< see Appendices D< E> and F.
90 0 0
9010
9020
9030
9040
9050
9060
9070
9080
9090
F?EM "LOADEF?"
F^ESTORE 9020
DATA 104,162
24,105,
203,173
20,197,
169,117
74,74,1
DATA
DATA
DATA
DATA
DATA
LOADi>
"PENBUF" INTO PAGE
1536 TO 1652JREAD
''04,173,12,2
DATA
DATA
200,176
JFOR
X
,0,160,6,132,
154,160,117,132,203,32,86
,13,212,56,233,16,32,86,6
20.240.252.76.7.6.165.205
,133,203,177,203,133,206,
33.209.96.134.206.164.206
,14,136,133,206,177,203,2
,203,96
6
PJPOKE
12,201,
,6,165,
,232,22
,74,168
165,206
,192,0,
00,145,
X,PtNEXT X;RETURN
10,144,3,56,233,228
203,24,101,205,133
8,205,240,9,165
,177,203,133,207
,74,74,133,208,165,207
240,20,136,209,203
203,136,165,206,56,176
Figure 10
PENBUF Loader Program Listing
The data statements represent the decimal equivalent of the machine
language program. The assembly language listing is presented in
Appendix E. The PENBUF loader is to be appended to a BASIC program and
used as a subroutine.
By calculating the statistical median of a number of readings, a
random noise pulse is less likely to be accepted by the program as the
indicator of the exact pen position. The median calculation,
especially useful in rejecting noise, is discussed in Appendix F. The
user can control the number of readings to be taken by changing the
number in location 205 (decimal). Location 205 is an input parameter
for PENBUF. The routine will not work if this is not POKEd with a
number. The range of readings that may be taken is variable from 1
(min) to 69 (max). The number selected should be odd. The more
readings that are taken, the less noise will affect the peni however,
it will not respond as quickly. A minimum of three readings normally
provides a good response. See Appendix F for a more detailed
discussion.
Using PENBUF - 33

Advertisement

loading