Download Print this page

Atari CX70 Operator's Manual page 61

Light pen

Advertisement

ATARI Light Pen Operator's Manual
APPENDIX F - DESCRIPTION OF PENBUF OPERATION
The PENBUF assembly language subroutine performs tuio primary
operations. It converts the register values to a usable range* as
shown in Programming Example 1* and finds the statistical median of a
user-specified number of successive pen reads.
The median is defined as the number in a data set that is less than 50
percent of the data and greater than the other 50 percent of the data.
In other words* it is the number that is exactly in the center of a
group of numbers (with respect to value). A median is a perfect choice
for our purposes since values which are totally off target will not
affect the result.
Example:
97* 101* 112. . . . Median = 101
0* 101* 112. . . . Median = 101
In the example above note that the 0* although far off target* does
not affect the median. A statistical average would be inappropriate
since values far off target would move the perceived value off target
also. This is the downfall of an averaging technique. The light pen
should sense the central value that occurs most often to discover the
most likely true position of the pen.
This median value is found by sorting the data and reading the center
value* which is precisely what PENBUF is designed to do. The read
section of PENBUF reads the coordinates*
the convert section converts
those values to correct X and Y coordinates as described in
Programming Example 1. Then* by the technique described below* the
sprt section uses an "insert-sort" to position the values as they are
received.
When PENBUF completes the reading and sorting of the data* it moves
the medians (center values of the tables) to locations 206 and 207
(decimal) and then performs a (Graphics Mode 0 conversion of these
values by simply dividing both values by 4. The results are stored in
locations 208 and 209.
When PENBUF is done* it returns to BASIC. Now you only have to PEEK
locations 206* 207 for values of X* Y*
where X must be between 0 and
159 and Y must be between 0 and 95 (Graphics Mode 23)* or PEEK
locations 208* 209 for X*
Y*
where X lies between 0 and 39 and Y
between 0 and 23 for Graphics Mode 0.
Before PENBUF is called* you must POKE location 205 with the number
representing the desired accuracy of the pen. This number determines
the number of readings that PENBUF performs and also determines the
size of the data tables. The larger the number of reads* the more
accurate the readings will be* but the read process will be slower.
Thus* if the programmer desires fast response from the pen* this
number should be as small as possible. If higher accuracy is needed*
Description of PENBUF Operation - 57

Advertisement

loading