Jump to content



0

Keypad + Joystick Together; Is it Possible?


3 replies to this topic

#1 Gemini OFFLINE  

Gemini

    Chopper Commander

  • 100 posts
  • Location:Canada

Posted Thu Jan 17, 2008 8:55 PM

I've been reading through the Stella programming guide and one thing that puzzles me is if it's possible to read both one keypad and one joystick at the same time. (One of my game ideas hinges on the answer to this question.)

From what I've read, in order to make such a concept work, the keypad would have to be plugged into the left P0 port, the joystick would go into the right P1 port, and before any game loops are entered, $F0 (11110000) would be written to SWACNT so that the keypad is set for output on the SWACNT I/O port and the joystick is set for input.

Then, reading the keypad should be easy enough, if annoying. Write the D7 bit to SWCHA, wait seven scanlines (400 us = 6.288 scanlines, gotta round up), read the INPT0, INPT1 and INPT4 values from the TIA, then repeat for D6, D5 and D4 to get the whole keypad. To read the joystick, just read bits D3 through D0 from SWCHA and INPT5 for the fire button state.

So my simple question is, will this work?

Edited by Gemini, Mon Jan 21, 2008 11:26 AM.


#2 SeaGtGruff OFFLINE  

SeaGtGruff

    River Patroller

  • 4,543 posts
  • Location:Georgia, USA

Posted Thu Jan 17, 2008 10:01 PM

View PostGemini, on Thu Jan 17, 2008 9:55 PM, said:

I've been reading through the Stella programming guide and one thing that puzzles me is if it's possible to read both one keypad and one joystick at the same time. (One of my game ideas hinges on the answer to this question.)
Yes, you can use a keypad and a joystick together-- e.g., "Star Raiders" did just that.

View PostGemini, on Thu Jan 17, 2008 9:55 PM, said:

From what I've read, in order to make such a concept work, the keypad would have to be plugged into the left P0 port, the joystick would go into the right P1 port, and before any game loops are entered, $F0 (11110000) would be written to SWACNT so that the keypad is set for output on the SWACNT I/O port and the joystick is set for input.
You could also plug the keypad into the right P1 port, and plug the joystick into the left P0 port. Or you can have a keypad plugged into each port (i.e., two keypads).

Be warned that the "Stella Programmer's Guide" doesn't give a very complete explanation of programming for the keypad controllers. The left keypad is read using INPT0, INPT1, and INPT4, as mentioned in the guide. But what it doesn't tell you is that the right keypad is read using INPT2, INPT3, and INPT5. That might be why you apparently haven't been able to get it to work with the keypad plugged into the right P1 port.

View PostGemini, on Thu Jan 17, 2008 9:55 PM, said:

Then, reading the keypad should be easy enough, if annoying. Write the D7 bit to SWCHA, wait seven scanlines (400 us = 6.288 scanlines, gotta round up), read the INPT0, INPT1 and INPT4 values from the TIA, then repeat for D6, D5 and D4 to get the whole keypad. To read the joystick, just read bits D3 through D0 from SWCHA and INPT5 for the fire button state.

So my simple question is, will this work?

--- Kris Asick (Gemini)
--- http://www.pixelships.com
Michael Rideout

#3 SpiceWare ONLINE  

SpiceWare

    Quadrunner

  • 5,986 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Thu Jan 17, 2008 11:27 PM

Yep, it is possible. I have some source code you can check out.

http://spiceware.org/dds/index.html

#4 Gemini OFFLINE  

Gemini

    Chopper Commander

  • 100 posts
  • Location:Canada

Posted Fri Jan 18, 2008 7:38 AM

Awesome. Thanks, guys!

...I'm gonna need to check this Star Raiders game out...

Edited by Gemini, Mon Jan 21, 2008 11:31 AM.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users