Readers Feedback
The Editors and Readers of COMPUTE!
If you have any questions, comments, or suggestions you would like to see addressed in this column, write to "Readers' Feedback," COMPUTE!, P.O. Box 5406, Greensboro, NC 27403. Due to the volume of mail we receive, we regret that we cannot provide personal answers to technical questions.
Reading The Atari Touch Tablet In BASIC
I am currently working on an Atari program that lets me create high-resolution drawings in graphics mode 15. However, the drawing should be done with the Atari Touch Tablet. How can a program read the Touch Tablet coordinates?
Peter HinzReading coordinates from the Atari Touch Tablet is very easy in Atari BASIC. The Touch Tablet returns the same values as paddle controllers, and Atari BASIC contains a function called PADDLE for reading these controllers. Use PADDLE(0) to read the horizontal position of the stylus on the tablet, and PADDLE(1) to read the vertical position (assuming that the tablet is plugged into controller port 1). Both functions return values ranging from 1 to 228. When nothing is touching the tablet surface, these functions return the value 228.
Reading the Touch Tablet buttons is just as easy. Use the PTRIG(0) function to read the left button, and PTRIG(1) to read the right button (again, assuming that the tablet is plugged into port 1). When a button is pressed, these functions return a value of 0. Otherwise, they return a value of 1.
The button on the Touch Tablet's stylus works a little differently. To detect this button press, use the STICK(0) function (normally intended for reading a joystick). If the stylus button is pressed, STICK(0) returns a value of 14. Otherwise, it returns the value 15.
The following example program prints the tablet coordinates on the screen along with messages when any of the buttons are pressed:
BN 10 X=PADDLE(0):Y=PADDLE(1) MM 20 PRINT X,Y ID 30 IF PTRIG(0)=0 THEN PRINT "LEFT BUTTON PRESSED" NI 40 IF PTRIG(1)=0 THEN PRINT "RIGHT BUTTON PRESSED" HL 50 IF STICK(0)=14 THEN PRINT "STYLUS BUTTON PRESSED" AA 60 GOTO 10