Path: utzoo!mnetor!uunet!portal!atari!jwt From: jwt@atari.UUCP (Jim Tittsler) Newsgroups: comp.sys.atari.8bit Subject: Re: Programming the Trak-Ball Message-ID: <994@atari.UUCP> Date: 25 Feb 88 16:32:39 GMT References: <1257@alliant.Alliant.COM> Organization: Atari Corp., Sunnyvale, CA Lines: 24 Keywords: Trak-Ball Summary: Atari Trak-Ball Programming In article <1257@alliant.Alliant.COM>, lackey@Alliant.COM (Stan Lackey) writes: > My question is, how do you program to the thing? It looks like it is one of > those things where rate of motion in one direction is determined by phasing > of two changing signals, and a driver counts transitions. That is correct. The joystick "switch" inputs are used in pairs to provide a "direction" and a "velocity" signal for each axis. The bit positions in PORTA are: XDIR = $01 YDIR = $04 XMOT = $02 YMOT = $08 The best way to monitor the trak-ball is to set up a periodic timer interrupt service routine that compares the ?MOT bits with those from the previous sample. If either of them has changed since the previous tick, increment or decrement the "mouse pointer" counter for that axis depending on the state of the ?DIR bit. In my code, I use one of the POKEY timers to generate an interrupt at approximately 1600 Hz which seems to be fast enough to not miss transistions at "reasonable" trak-ball speeds. When the switch on the Atari Trak-Ball is in the "joystick" position, the circuitry inside the Trak-Ball will "simulate" the switch closures of a joystick corresponding to the direction of ball motion. Jim Tittsler, Systems Engineer, Atari Corporation {portal, ames}!atari!jwt