Jump to content
IGNORED

Hardware assisted trackball polling


Crispy
 Share

Recommended Posts

It's unfortunate that many of the games that would benefit from trackball control are designed to use the joystick instead, and there's a good reason for this. Polling the trackball requires a huge amount of CPU time. In order to get an accurate picture of what the trackball is doing, it has to be polled every few scan lines, and preferably, every scan line. Doing this incurs a lot of overhead, and would simply be impossible to implement in a game that employs a lot of graphical embellishment.

 

I started thinking about this subject the other night when I was getting annoyed by the sluggish response of the joystick control in Centipede. At first I was looking for a way to improve the joystick response in Centipede, which I found, and then a thought occurred to me. If the trackball polling can be offloaded to external hardware, a lot of games that could benefit from trackball control would be able to have it.

 

My first idea was to design a cartridge that includes the polling hardware and a connector for the trackball on the cartridge itself. I still like this idea, but I came up with another one that I implemented as a proof of concept. Using one of my FPGA dev boards that I had laying around, I created a design that polls the trackball, and then outputs the results to the two joystick connectors on the 2600. The drawback with this design is that it uses both joystick ports which makes it possible to plug in only one trackball.

 

Theory of operation
The method described here for polling the trackball only works with trackballs that use the CX-22 type of signaling. Fortunately both of my CX-80 trackballs fall into this category.

The idea is fairly straight forward. The signals from the trackball drives two 4-bit counters: one for the X axis, and one for the Y axis. The pulse train from pins 2 and 4 of the trackball connector drive the clock inputs of the two counters, and the direction signals from pins 1 and 3 are used to determine whether the counters count up or down. The outputs from the two counters are fed into the two joystick connectors on the 2600, and these values are read by software from address $280 once every frame during blanking. The 4-bit values are formatted as two's-complement signed numbers, and indicate the number of trackball ticks that have occured since the last time the counters were read. A negative value indictes that the trackball was moving left or up, and a positive value indicates rightward or downward movement. The counters are cleared by setting the joystick port pins as outputs, and then writing a $00 to $280. From there it's up to the game designer to decide what to do with the count values read from the joystick ports.

 

As I mentioned earlier, my current design is implemented in an FPGA, but this solution is much too expensive for this type of product. Instead, this design could be implemented with a handful of discrete logic, or even a PLD.

 

For those who are interested, I have a video on Youtube that demonstrates my hardware with a hacked version of Centipede.

 

https://www.youtube.com/watch?v=C59hY8XhsfY

 

I'm not sure how much interest there would be in a product like this, so for now I'm just treating as a fun exercise in interfacing to the 2600.

 

 

  • Like 1
Link to comment
Share on other sites

Very interesting!

You could use one of the paddle lines as an output pin as well, by putting a pullup resistor on it and setting/unsetting bit 1 of VBLANK (normally used to discharge the paddle line caps). You could use that as an alternate method to clear the counters, or as a select line to switch between two trackballs.

See this post about a 4-joystick interface:

http://atariage.com/forums/topic/105756-four-player-joystick-games/?do=findComment&comment=1282180

Link to comment
Share on other sites

Very interesting!

 

You could use one of the paddle lines as an output pin as well, by putting a pullup resistor on it and setting/unsetting bit 1 of VBLANK (normally used to discharge the paddle line caps). You could use that as an alternate method to clear the counters, or as a select line to switch between two trackballs.

That's a good idea, but not without a couple of drawbacks. First, because of the large capacitance on the line, I would have to use a small value resistor in order to get a reasonable rise time. If I chose 330 ohms, then the rise time would be about 23 us, which is pretty slow. I don't like driving logic with such long rise times, so I'd definitely want to run it through a Schmitt trigger before it hits the clear input of the counter. The other concern is the high current due to the small value pull-up resistor. If the pull-down FET in the TIA has an on resistance of a few ohms, then the current through the resistor is a little over 15 mA when the FET is on. I know it's not a big deal, but I usually like to keep the current in pull-up circuits in the 1 mA range. On the upside, it reduces the component count in the design. Using the dump signal from the TIA would remove the need for the octal open-collector buffer and the two quad AND gate chips that the current design uses.

 

Two 4 bit values is what I did with the PS2 adapter and the PS mouse. :)

I'd like to know more about this.

 

Cool! 8)

 

Would it be possible to poll paddles that way too?

 

I believe it would. I think in the case of paddles you would want to use an 8-bit counter instead of a 4-bit counter in order to get a reasonable sample of the paddle position. Going with Alex's suggestion, the dump line could be used to select between the upper and lower nibbles of the 8-bit word. Doing this would provide the ability to read an 8-bit value over the 4 bits on one joystick port, and would allow for supporting two paddles.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...