+Ryan Witmer Posted May 30, 2020 Share Posted May 30, 2020 I'm wrapping up my new game, Magical Fairy Force, which supports the mighty 5200 trak-ball controller. I had a bit of an adventure getting this thing to work, so I'd like to post everything I figured out about this controller in order help anyone else that might be considering a project that supports it. I will disclaim that my methods may not be the best, but they seem to be working for me and are giving consistent results for the two trak-balls that I own. First, I'd like to highlight this thread: The information in this thread pointed me in the right direction, but some of the details were not quite right. Building on what I found here, I came up with the following procedure: First, it must be stated that in general you cannot uniformly handle the joystick and the trak-ball. You first need to figure out which controller you're looking at so you know how to interpret the POT values later on. Here is the procedure I used for this: Disable pot scanning by writing 0 to CONSOL. Wait for the POT shadows to update. You might also be able to manually trigger a pot scan and read the values straight from POKEY, but I opted to use the shadows. Read one of the POT values and compare it to $e4. When scanning is disabled, the joysticks report $e4 when read. I believe this same value is also produced by an empty controller jack and I'm not aware of any way to discern between a joystick and no controller at all. If the value is not $e4, this is a trak-ball. The value that was read is the rest value for that axis on the trak-ball. Save this value somewhere, you'll need it. Read the POT for the other axis. This is the rest value for that axis, the two axes can have different rest values. Again, save this value. Repeat for each controller that you're interested in. Re-enable POT scanning by writing 4 to CONSOL. When it comes time to handle input, you need to check each POT on the ball and compare the value to the rest value for that axis. The difference from the rest value indicates the speed and direction of the ball's spin on that axis. Values lower than the rest value are left/up, greater are right/down. The values that you get tend to be in a very small range. My game handles values +/-10 from the rest values. Once my game is finalized, which should be within a couple of weeks, I'll release the complete source so any interested people can examine how I did this in detail. 1 Quote Link to comment Share on other sites More sharing options...
Rybags Posted May 30, 2020 Share Posted May 30, 2020 I don't have a 5200 so can only speculate: Joystick detection - maybe there's different behaviour of empty vs populated port for the keyboard code using different values in SKCTL? On the computer you normally want 3 in there but with the 5200 it's 2 isn't it? Maybe values 1 and 3 produce different keycode reporting if the port is empty or not. Alternately - an inserted joystick would only produce value 228 on both POTs if pushed to a diagonal limit. Quote Link to comment Share on other sites More sharing options...
_The Doctor__ Posted July 9, 2020 Share Posted July 9, 2020 How'd it turn out? Quote Link to comment Share on other sites More sharing options...
Airshack Posted July 20, 2020 Share Posted July 20, 2020 I saw a YouTube video yet no other info on this game. Searched AtariAge and only found this thread. Quote Link to comment Share on other sites More sharing options...
+DrVenkman Posted July 21, 2020 Share Posted July 21, 2020 12 hours ago, Airshack said: I saw a YouTube video yet no other info on this game. Searched AtariAge and only found this thread. https://atariage.com/forums/topic/307426-magical-fairy-force-release-thread/ Quote Link to comment Share on other sites More sharing options...
SoundGammon Posted August 15, 2020 Share Posted August 15, 2020 On 5/29/2020 at 6:29 PM, Ryan Witmer said: I'm wrapping up my new game, Magical Fairy Force, which supports the mighty 5200 trak-ball controller. I had a bit of an adventure getting this thing to work, so I'd like to post everything I figured out about this controller in order help anyone else that might be considering a project that supports it. I will disclaim that my methods may not be the best, but they seem to be working for me and are giving consistent results for the two trak-balls that I own. First, I'd like to highlight this thread: The information in this thread pointed me in the right direction, but some of the details were not quite right. Building on what I found here, I came up with the following procedure: First, it must be stated that in general you cannot uniformly handle the joystick and the trak-ball. You first need to figure out which controller you're looking at so you know how to interpret the POT values later on. Here is the procedure I used for this: Disable pot scanning by writing 0 to CONSOL. Wait for the POT shadows to update. You might also be able to manually trigger a pot scan and read the values straight from POKEY, but I opted to use the shadows. Read one of the POT values and compare it to $e4. When scanning is disabled, the joysticks report $e4 when read. I believe this same value is also produced by an empty controller jack and I'm not aware of any way to discern between a joystick and no controller at all. If the value is not $e4, this is a trak-ball. The value that was read is the rest value for that axis on the trak-ball. Save this value somewhere, you'll need it. Read the POT for the other axis. This is the rest value for that axis, the two axes can have different rest values. Again, save this value. Repeat for each controller that you're interested in. Re-enable POT scanning by writing 4 to CONSOL. When it comes time to handle input, you need to check each POT on the ball and compare the value to the rest value for that axis. The difference from the rest value indicates the speed and direction of the ball's spin on that axis. Values lower than the rest value are left/up, greater are right/down. The values that you get tend to be in a very small range. My game handles values +/-10 from the rest values. Once my game is finalized, which should be within a couple of weeks, I'll release the complete source so any interested people can examine how I did this in detail. I'm curious about how Centipede & Missile Command know if only one or two trak-balls are plugged in. With only one trak-ball plugged in, you can play a two player game passing the controller back and forth. Quote Link to comment Share on other sites More sharing options...
+Ryan Witmer Posted August 15, 2020 Author Share Posted August 15, 2020 1 hour ago, SoundGammon said: I'm curious about how Centipede & Missile Command know if only one or two trak-balls are plugged in. With only one trak-ball plugged in, you can play a two player game passing the controller back and forth. You can detect the trak-ball on a per-port basis using the method I listed. My game does this, since it allows two players. Those games probably just switch to two-player-one-ball mode if they detect the ball in port 1 but not port 2. Only a disassembly can tell for sure. 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.