Gemini Posted January 18, 2008 Share Posted January 18, 2008 (edited) 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 January 21, 2008 by Gemini Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted January 18, 2008 Share Posted January 18, 2008 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. 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. 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 Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted January 18, 2008 Share Posted January 18, 2008 Yep, it is possible. I have some source code you can check out. http://spiceware.org/dds/index.html Quote Link to comment Share on other sites More sharing options...
Gemini Posted January 18, 2008 Author Share Posted January 18, 2008 (edited) Awesome. Thanks, guys! ...I'm gonna need to check this Star Raiders game out... Edited January 21, 2008 by Gemini Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.