Monday, April 27, 2009

Game Controller - Atari Joysticks

The Apple II computer was designed to use an analogue joystick (via the 16 pin game port then later a 9 pin port). This joystick uses two potentiometers to represent the position of the stick, one for the x-axis (8 bit analogue signal) and one of the y-axis (8 bit analogue signal). The joystick also contains two pushbuttons (digital signals). Many computers and game consoles from the 8 bit home computer era were designed to use digital joysticks instead ie these contain five digital signals, one signal for each of the four directions (Left, Right, Up and Down) plus one for the trigger button. The analogue joystick has a greater range of movement but at the expense of a fast response time. The digital and analogue joysticks are not compatible however it is possible to convert one to the other in a limited capacity. There are two main methods in converting an Atari style joystick on the Apple II computer and each method is only compatible with certain software applications.

The first method of converting an Atari style joystick involves making the four digital positions (Atari joystick - Left, Right, Up and Down) represent the extremities of the analogue ranges (Apple joystick - y-axis low / high and x-axis low / high). For this joystick to work the software must have been written to only look at the low/high analogue values and only use the first pushbutton. The WICO Command Control Joystick Adapter is a good example of a converter that uses this method. If you wish to build one yourself then see Chaptor 9 of the "Computer Controller Cookbook" by Tom & Kelda Riley (http://www.atariarchives.org/ccc/chapter9.php).

The second method of converting the Atari style joysticks involves reading the digital signals (Atari joystick) by using the digital pushbutton input lines on the Apple II's game port. The problem is that the digital joystick contains five digital signals (ten when you talk about two joysticks) but the Apple II's game port only contains three digital inputs. The answer is multiplexing. Since the Apple II's game port (16 pin version) has Annunciator lines (digital outputs) these can be used to multiplex the input signals. The software needs to be specifically written to perform this multiplexing and in fact a lot of software was. It is known as the "Atari Joyport" option.

The second method was able to deliver my aim which was to reproduce that arcade style game controller feeling. It makes quite a difference to how some games are played.

The converter allows two Atari style joysticks to be connected. I also decided to run the signals through the switch box so as to allow switching with my other paddles and joysticks.

The converter requires Annunciator signals from the game port and these are only available via the 16 pin connector. Therefore I did away with the 9 pin cable that connected the Apple II with the switch box and replaced it with two cables.

After building the converter I tested it on some games but it would not work. I manually tested it and found it functioned exactly how I wanted it too. Through trial and error I worked out that my logic was incorrect. All the software was written to accept the opposite of how the analogue joysticks functioned ie the joystick trigger was registered when the pushbutton zero line (PB0) went from active to low and not the other way around. It ended up being an easy fix. All I did was change the inverting multiplexer chip with it's a non-inverting version.

The operation of the "Atari Joyport", when the joystick is in it's steady state (no movement and no trigger), sets the Apple's three input lines (PB0, PB1 and PB2) high. These signals get driven low when a movement occurs or when the trigger is pressed. This operation worked well on the older Apple II models but there was a problem once the Apple IIe came out. This model had a few differences over the previous models. In particular it had a self test (Control + Open-Apple + Closed-Apple + Reset) and two extra keys, the Open-Apple and the Closed-Apple which were electrically tied to PB0 and PB1. This caused a problem for the "Atari Joyport" operation because when a reboot was actioned (PB1 was set high by default) a machine self test accompanied by a high pitched screech resulted. I work around this problem by using the switch box before rebooting or holding the joystick to the left while pressing the Control and Reset keys.

Thank-you Michael for pointing out that my Atari joystick converter needed signal diodes between the multiplexer and the PB inputs. The signal diodes are needed so that the Open-Apple, Close-Apple and Shift (if the Shift key mod is installed) keys do not result in a short circuit condition with the converter's multiplexer. Take note that the diode for PB2 needs to be in the opposite direction to the other two. This is because PB0 and PB1 switch to +5V while PB2 switches to ground. After adding the diodes I had problems getting the converter to work well. It wasn't until I added a pull-up resistor and two pull-downs that the converter functioned correctly again.

A switch was add to the converter's power supply line. I found this easier to use than performing the switching via the switch box.

The schematic was also changed in an attempt to make it less confusing ie the gameport connection was changed to show the Apple's 16 pin port instead of my custom 9 pin hack.

Some examples of software that use the "Atari Joyport" operation are :- Boulder Dash, Spy's Demise.


The circuit board (top and underside views).


The two custom cables and an overview of the setup.


Atari Joystick to Apple II's "Atari Joyport" Converter - Schematic.


17 comments:

Stephen said...

Hi,

Recently I had visit your post and I found many informative matter regarding custom cables which are beneficial for me.Thanks a lot.

Anonymous said...

Could you please tell me where in the world can i buy this? because my electrical knowledgement is very poor.

Thanks.


Alex Mena

Lukazi said...

Hi Alex,

My project is based on the functionality of the "Sirius Joyport" see http://en.wikipedia.org/wiki/Sirius_Joyport and http://www.atarimagazines.com/cva/v1n1/joysticks.php. These are very rare and since I have started up tinkering with he Apple IIs again (last five years) I have not seen one for sale. Currently I have no plans to sell my version as I have too many projects that I want to finish. Maybe you can find someone who can build it for you.

Regards,



Alex.

Stefano said...

Hello, may I ask you a question about the schematic you published? I see that you pubished two versions: 1 or 2 atari joystick to Apple Gameport.
But in all of them the only gameport is the one with 16 pin. How should it be a schematic ending to the 9 pin female gameport? (I saw you one made one in the pictures) The pinouts (and their signals are completely different) Can you tell me how to complete the schematic to the 9 pin port? Thank you very much!!!
Stefano, ITALY

Lukazi said...

Hi Stefano,

I am sorry but you can't use the "Atari Joyport" with the Apple II 9 pin game port. The "Atari Joyport" operation requires the use of the "Annunciator 0" and "Annunciator 1" signals which were only found on the 16 pin game port. You will notice in the pictures that I still use the 16 pin game port. I have hacked a cable and made my own 9 pin plug. I have replaced the Joystick 2 X and Y axis pins (pins 4 and 9) with "Annunciator 0" and "Annunciator 1". So even though my "Atari Joyport" has a 9 pin plug it will only work with my special cable and not the Apple II 9 pin game port.

Regards,



Alex.

Lukazi said...

Hi Stefano,

This is the special adapter cable that I made up. Warning - Do not attach any game peripherals to this cable that use the PDL2 or PDL3 signals as this may damage your motherboard.

16 Pin Dip to 9 Pin Female

1 +5V ------ 2 +5v
2 PB0 ------ 7 PB0
3 PB1 ------ 1 PB1
4 PB2 ------ 6 PB2
5 Strobe
6 PDL0 ------ 5 PDL0
7 PDL2
8 GND ------ 3 GND
9 PB3
10 PDL1 ------ 8 PDL1
11 PDL3
12 A3
13 A2
14 A1 ------ 9 PDL3
15 A0 ------ 4 PDL2
16 NC

Unless you are going to go through a 9 pin switch box like I did I don't see the need to use a 9 pin plug.

Regards,



Alex.

Anonymous said...

Thank you, Alex!!!

Regards!

Stefano

Anonymous said...

Hi,

I have a question. The schematic with one joystick, that is, one DB9 connector, only has the connection to the Annunciator 1. The truth table requires that there is also Annunciator 0 values be available, together with Annunicator #1's values, in order to determine the states of PB0, PB1, and PB2. But there is no connection for Annunciator #0. So, how the directions or button pressed determined?

Thank you!

Anonymous said...

>I have a question. The schematic with one joystick, that is, one DB9 connector, only has the >connection to the Annunciator 1. The truth table requires that there is also Annunciator 0 >values be available, together with Annunicator #1's values, in order to determine the states >of PB0, PB1, and PB2. But there is no connection for Annunciator #0. So, how the directions >or button pressed determined?

Never mind. I think I'be got it. Read Annunciator #1's address $C05A and $C05B to determine its value, 0 or 1. Then read for PB0, PB1, and PB2. Is that correct? Please clarify if it is not so. Thanks!

Lukazi said...

Yes you are correct.

Step 1 - you read $C05A to turn off Annunciator #1.
Step 2 - you read PB0, PB1 and PB2 (to determine state of trigger, left and right).
Step 3 - you read $C05B to turn on Annunciator #1.
Step 4 - you read PB0, PB1 and PB2 (to determine state of trigger, up and down).
Step 5 - go to step 1 and repeat over and over again.

Annunciator #0 is to switch between joystick 1 and joystick 2. Since you are using the single joystick circuit you do not need to turn this annunciator on or off.

Remember when reading PB0, PB1 and PB2 that it is negative logic. PB0 = 0 means trigger button is being pressed and PB0 = 1 means that trigger button is not being pressed.

Good luck.
Alex.

Anonymous said...

Thanks, Alex.

One more question:

I had a board made for single joystick/one DB9 connector. I've noticed that when I enable the 5V (via a jumper) from the 16-pin connector, my Apple IIe will not boot but only goes into Kernal testing mode and gets a "Kernel OK" message displayed. If disable the 5V (via the jumper), my Apple IIe boots OK with a prompt. Of course, by disabling the 5V, the IC (HC244) won't get its power.

Tips?

Thanks!

Anonymous said...

Sorry, for the previous post, I meant the 74HC157 logic chip NOT 74HC244. Thanks!

Anonymous said...

Anonymous wrote:
"I had a board made for single joystick/one DB9 connector. I've noticed that when I enable the 5V (via a jumper) from the 16-pin connector, my Apple IIe will not boot but only goes into Kernal testing mode and gets a "Kernel OK" message displayed. If disable the 5V (via the jumper), my Apple IIe boots OK with a prompt. Of course, by disabling the 5V, the IC (HC244) won't get its power."

Ok, I think I know what happens. So, I must have the 5V enabled to get things working. BUT I need to follow what you said below, so that my Apple IIe won't go into system test mode when CTRL+RESET is done. Am I correct?

"The operation of the "Atari Joyport", when the joystick is in it's steady state (no movement and no trigger), sets the Apple's three input lines (PB0, PB1 and PB2) high. These signals get driven low when a movement occurs or when the trigger is pressed. This operation worked well on the older Apple II models but there was a problem once the Apple IIe came out. This model had a few differences over the previous models. In particular it had a self test (Control + Open-Apple + Closed-Apple + Reset) and two extra keys, the Open-Apple and the Closed-Apple which were electrically tied to PB0 and PB1. This caused a problem for the "Atari Joyport" operation because when a reboot was actioned (PB1 was set high by default) a machine self test accompanied by a high pitched screech resulted."

Btw, I learned the hard way. I plugged the joystick board onto the 16-pin socket of my Apple IIe board with the 5V disabled. Then without turning off my Apple IIe, I jumpered the joystick board to have 5V enabled. Smoke coming off the joystick board and start burning the traces!!! Luckily I shut off the power quickly enough not to have my Apple IIe damaged!

Lukazi said...

Yes Rebooting the Apple IIe will not work while the Joyport is powered on. You have to turn on the Joyport after the Apple IIe has booted. That is, if you are still game enough to use the Joyport on your IIe. The designers would not have known Apple were going to change the circuitry in the newer Apple II models.

However it still sounds like your Joyport has issues. Having PB0 and PB1 tied directly to ground or PB2 tied directly to 5V will smoke / damage your Apple IIe. The diodes and pull-down / pull-up resistors are there to protect against that.

Check that your diodes are wired in the correct direction. Check that the pull-downs and pull-ups are wired correctly. Check that the pull-downs are 1k Ohm and not 1 Ohm resistors. Note that the diode direction for PB2 is different than for PB0 and PB1. Similarly PB2 has a pull-up while PB0 and PB1 have pull-downs. Check that the 74HS157 pinout is the same as the 74LS157 pinout and does not have some other configuration.

Hope that helps.
Alex.

Anonymous said...

>Check that your diodes are wired in the correct direction. Check that the pull-downs and pull-ups are wired correctly. Check that the pull-downs are 1k Ohm and not 1 Ohm resistors. Note that the diode direction for PB2 is different than for PB0 and PB1. Similarly PB2 has a pull-up while PB0 and PB1 have pull-downs. Check that the 74HS157 pinout is the same as the 74LS157 pinout and does not have some other configuration.

Haven't gott a chance to respond, no that I have time to get back to this project.

My schematic is at https://drive.google.com/file/d/1mKcIZvh1OW2lU1jgeccU5NZx9n8o3R0S/view?usp=sharing

All diodes are pointing to the right directions. Pull-up resistors are correct values. 74LS157 and 74HCT157 are pin compatible.

Thanks!

Lukazi said...

You have an error in your schematic. Pin 1 on the 74LS157 goes to the Annunciator #1 and not the STK2-Y as shown in your schematic. This may be just a printing error or it might be the issue you are having. Also I'm not sure what the J2 connection is being used for.

Cheers,
Alex.

Anonymous said...

>You have an error in your schematic. Pin 1 on the 74LS157 goes to the Annunciator #1 and not the STK2-Y as shown in your schematic. This may be just a printing error or it might be the issue you are having. Also I'm not sure what the J2 connection is being used for.

Thanks, Alex! I think I had the 16-pin Apple joystick connector mislabeled. Pine 1 of the 74LS157 does connect to pin #14 of the Apple joystick connector, but it's wrong labeled.