Joystick interface for C-16, C-116 and Plus/4

© 1999, 2000 Levente Hársfalvi

 

Abstract

 Do you have a C-16? A C-116? ...A Plus/4? ...Are you a proud owner of a CBM 264 or 364 prototype ;-) ? ...Then I suppose you know those pretty 8 pin mini DIN sockets on your computer with Joy 1 and Joy 2 label. I'd say it's just another blunder of Commodore (whoever on Earth knows what did motivate these lots of bad decisions?) not equipping these computers with a more or less 'standard' joystick connector. One could say anyway, that's just another small nuance of the features that make these computers not to fit into the series of other micros of Commodore. All in all - the joystick port of the Plus/4 differs from the 'standard' (Marko said: 'Atari VCS style') joystick port both in its shape and its inners.

 In this document I'll explain some possibilities on interfacing standard 9-pin digital joysticks to the Plus/4 and also some practical tips.
 
 This is V1.1 of this document; some re-writing was done, and correcting a mistake in the theory that I made in the first version.

Table of contents

Copyright

This article is © 1999, 2000  Levente Hársfalvi and this document is published under the General Public License by the Free Software Foundation. (Since GPL was designed for software, applying it to an article or hardware stuff is not as clear as applying it for a program; however, I'd like to publish this document with the spirit of this license.) All this is distributed in the hope that it will be useful, but WITHOUT WARRANTY and with all the usual disclaimer stuff. If you make an attempt to build an interface for your computer, or use anything from here for your own design, you do it at your own risk. Should anything here prove defective, all consequences are with you. For more, read GPL.

You can have this document in a zipfile together with all graphics here.

Credits

The article is based on the original User's Guides by Commodore and some practical experience. Schematics were drawn with CirCad 3.5 for DOS by Holophase Inc., converted with Image Alchemy V1.7.5 by Handmade Software and customized with Adobe Photoshop 4.01 (Win95). The HTML document was written in Arachnophilia 3.9 (Paul Lutus) (V1.1 was edited in Netscape Composer). Thanks for all creators of these programs.
 

Review

On figure 1. you can see both computers joystick ports.

 

Joystick connectors of C64 and Plus/4
Figure 1.
 
 

C64

 The socket is a male Canon Sub-D 9. There are two identical connectors (joy 1 and joy 2) on the computer. You can also find the same sockets and pin-outs on the VIC-20, the C-128 and the Amiga, and more or less the same on a lot of other computers. There are 9 lines, of which one is common ground (GND), one is supply voltage for the paddles and occassional external devices (like joysticks equipped with autofire) (+5v), four + one direction lines (left, right, up, down, fire) and two analogue potmeter lines for paddles (POTX, POTY).

 The joysticks contain small micro switches, connected between GND and the appropriate direction line. When pushing the joystick towards a direction, a switch shorts the appropriate direction line to ground. The scanning of the state is realised in several different ways in different computers; in the C64, the direction lines are connected parallel with the keyboard scanning lines and can be queried with a simple procedure through the CIA1 ports. Since there are two joystick ports on the C64, scanning them independently needs them to be connected to different CIA input lines (as it is seen in the C64's schematics).

 The POTX and POTY lines are for querying the paddles (the popular game devices of the early 80's - does anyone still have such gadgets?!). The paddles are in fact potentiometers inside (variable resistors). One end of the potmeter is connected to +5v while the other to the POTX or POTY line (the paddles used to appear in pairs wired to one common joystick port plug). In the computer, these input lines go to a simple integrating analogue to digital converter (counter type). By measuring the time needed to charge a capacitor by the current going from +5v through the paddle potentiometer, one can deduct where the wheel is currently positioned. In most computers, the position is measured with 8-bit precision.
 

Plus/4

 First of all, as you probably noticed (at least if you're rather a Commodore hacker and not a Plus/4 fanatic in particular), I refer to these computers as 'Plus/4' or     'Plus/4 line'. Well this is wrong. But I'm not gonna call them '264 line of computers', because even if it was the 'official' name of this line, it never made it to the common sense - and anyway this line has not much  to do with the 'C-64' as '264' would suggest. As I'm a longtime Plus/4 and C-16 user I rather decide with the 'wrong' but otherwise more sensible term. By the way, the members of this series are the same in the subject of this document.

 Commodore decided to equip these computers with new joystick ports. (Just to mention, only the Serial,the Video and the RF connectors are identical to the ones found on other Commodore computers). For the tape and joystick ports, Commodore introduced Mini DIN plugs. The reason, well - I guess it's out of the scope of this document. They probably wanted to lower their prices, and thus decided to use cheaper connectors. Or they were in lack of free place on their new model (the Plus/4 is relatively small; there is simply no free place on the rear of the computer, even if the sockets are mini DIN's and the RF modulator appears on the left side). The rest is history; they also introduced their own joysticks with the computer, but seems like it didn't help much. Joysticks were always a problem ever since the Plus/4 existed.

 Speaking of the specialities of the joystick port, at first we notice that no POTX and POTY lines can be found. It's not possible to hook a paddle (as easily as to the C64) to the Plus/4. We find the usual GND, +5v and the direction lines. There is one more line which was not present on the C64s joystick port, this is the Select' line.

 Going deeper to the inners of the port, the Plus/4 hardware schematics tell us some differences. In the Plus/4, the joystick lines are also connected parallel to the keyboard scanning lines, the same way as it is found in the C64. However, both joysticks are connected parallel to the same keyport scanning lines (except fire buttons, whose keyport lines are unique for each ports). Thinking it over, it would mean, that we cannot differentiate between the two joysticks from the computers side, since they're both free to pull the same keyboard line in the same moment.

 Now, the problem is solved by the last line named Select' which is unique for each joystick ports. The Plus/4 joysticks direction switches must be connected between the appropriate direction line and Select' (instead of GND). In the scanning process, the software on the computer can make each Select' line to go low in a particular moment, independently from each other, thus making possible to scan the state of just one joystick instead of both. (One more advantage of this method is, that it's also possible to prevent the keyboard scanning process from getting false keyboard data by the joystick, just by inhibiting both Select' outputs, which was anyway not possible on C64).

 In a more deep point of view, the Select' line comes from a standard LS-TTL gate output from the computer, whose input is hardwired to one dataline of the processor data bus (D2 for joy1 and D1 for joy2). One would suspect a static, well programmable selector line in such a subject, but this design seems to rather result in a heuristic 'oscillation' on the Select' line (as the computers databus changes cycle to cycle). Still, it is suitable for this task, because of the way it is used for the selection. The answer is in the TED, the TEDs keyport input latch which is sampled in a certain minute.

 The TED's keyboard port is available at $FF08. When the processor writes to this register, the TED samples the actual states of the keyboard lines (this value can then be read out next, reading from $ff08), right after receiving the writing statement. If we want the state of one joystick, we need first to make the appropriate Select' line to go low, making the joystick able to pull the keyport lines to low. Because of the above mentioned wiring of the Select' lines in the Plus/4, this is only possible if a certain data is found on the data bus when (or rather, shortly before) this sampling happens. Luckily, the 6502 architecture of the processor helps that it can be done. For getting a joysticks state, one must write to $FF08 a value whose 1st or 2nd bit is 0. Since the writing statements (for example, an STA $FF08) 'last' transferred byte on the data bus is just the value to be written, in the right minute the lines of the databus will reflect the bits of the data written to $FF08 - thus driving low the respective D, thus Select' line. The TED samples its inputs before the next cycle, so when the program reads the sampled value from $FF08, the register will reflect the state of the input lines when the joystick selection happened.

 There is one more difference that I haven't realised for a long time; it is indeed a really stupid overlook anyway, I don't know how did I miss it since it is also in the above facts. The Select' lines come from a standard LS-TTL gate output (a totem pole output). This means, it is either GND or (something less than) +5v but nevertheless both levels are active. It would mean, that the joystick can indeed pull an input line high in some moments (to be precise, whenever it is moved and it is not selected). And this fact makes sure that the series diodes on the joystick input lines, seen in the schematics of the Plus/4 must indeed be present in _all Plus/4 (else, the joysticks, if some direction switches are shorted, would interfere with the keyboard scanning process). As a consequence, this makes sure that it doesn't hurt if one drives the inputs to active high, as I previously suspected - since the original design does it so.
 

 

How to...

Some conlusions that may help in designing a joystick interface:
 

A simple interface

With this interface, you can use your C64 joystick with the Plus/4. This is just a pin-to-pin interface and thus it will be suitable for bare joysticks. Joysticks with autofire function may or may not work occassionally, depending on their construction.

 You'll need...

To create this interface, cut a short (about 10 cm) cable. Blank the wires at the end (about 1.5 - 2 cm from the cover, and about 1-2mm on the wires each). It makes sense to apply a few solder to these ends before trying to mount them on the connector pins (especially the mini-DIN). Take the mini-DIN plug. Solder wires to pins 1-6, 8. (You will notice that it is the most difficult stage in the process, because of the small pins and place). When finished, take the Sub-D plug ( DON'T FORGET TO PUT the cover of the mini-DIN plug to the cable before this!) Solder the appropriate wires to the Sub-D plug (DIN #1-4, 6 --> Sub-D #1-4, 6 (directions+fire), DIN #5 --> Sub-D #7 (+5v), DIN #7 --> Sub-D #8 (Select').

 You can verify the routes on Figure 1. All lines go straightforward to their equivalents. The only exception is the Select' line: this is connected to the joysticks GND pin. +5v is connected because some autofire circuits will still work if it's present, even if the 'GND' level is present just occassionally. Note that POTX and POTY (Sub-D #5,9) are unconnected.

 After soldering everything, check if there are no loose wires, shorts on the connectors. Then assemble the plugs together.

 You'll most probably have to adjust the mini-DINs cover, because there's so small place around the Plus/4's connectors that these replacement plugs don't always fit to the computer (the original, cable manufactured ones do, but they can't really be obtained).

 Try your work out. Connect the interface, the joystick and the computer together. Switch the computer on. Try to move the joystick. If you see 'A', '4', '3', 'W' characters on the screen (joy2) or '5', 'R', '6', 'D', 'T' (joy1), your interface is perfect. If you see '2', 'Q' or the cursor jumps to 'HOME', you'd most probably connected the GND lines together instead of connecting Select'.

 When you notice no effect, first check the cabling, the wires, the joystick etc. If nothing works, your Plus/4's TED is most probably broken. This interface doesn't work for you.
 

 I don't really know, how and why TED's input latches get burnt. It may well either be an effect of high current or static electricity. Would suspect the first. If you use the joystick port, your computer is also subject to this risk. I know, heavy shocks on the joystick input lines surely do - once I also did burn mine, about ten years ago :-( (I obtained a new TED since that). Don't make an attempt to solder something inside with an instant ('pistol...') soldering iron. Since Commodore's original joysticks contain keyboard-like rubber+charcoal bell sensors, whose resistance is relatively high, you can also put some resistors (of about 100 ohms) series to the direction lines (they fit into the Sub-D connector housing).

 

A full featured interface

 This interface is capable of faking a C64 joyport on the joysticks side (except POTX and POTY), and being able to forward the line-states to the Plus/4 in sampling times. Because of the nature of the Plus/4 joyport, this implies some gating logic.

 My interface is built around a 74LS244, a dual quad tristate bus-driver chip. But you can use several other chips too. In fact, five OR gates would do the trick (but unfortunately, simple OR chips contain only 4 gates). Here's the schematic diagram.

 

Full interface schematics
Figure 2.
 

It looks like spaghetti. However, the connections are simple, and this 'spaghetti' look is the consequence of drawing the schematic from the ready interface. All direction lines go to the bus driver chips inputs. The chips gate inputs are connected to the Plus/4 joystick ports Select' line. The gate inputs are low-active, so when Select' goes low, the chips outputs will reflect the respective inputs. Else, the outputs are in high impedance state - say, they don't even exist from the point of the Plus/4 joystick port. In theory, the joystick side would need 5 pull-up resistors of about 2-3K ohm each on the direction lines; I left them, since the TTL inputs are on a weak high state as default thus it works with or without those pull-ups. A bypass capacitor of 100 nF (between pin 10 and pin 20 of the chip) won't hurt either, but there was no place in the housing for one more ceramic capacitor. The series resistors limit current, as the original Commodore joystick does with its sensors.

(If you built my previous interface design with the diodes, don't worry - applying the diodes or using an open collector bus driver doesn't appear to be hurting, just more than neccessary.)

 What you'll need is...

Since I found no sense in creating a board for such a small circuit, I made everything fit into the Sub-D 9 housing. First take the 74LS244, bend all pins horizontally (or at least, 15-20 degrees from the horizontal state) :-O. Cut pins 8, 9, 12, 13 (you may even smooth the side of the chip). Cut all pins short, so you can still solder to them but they're much shorter than originally. Try if the chip fits into the housing, with its 'head' towards the connector and the 4 cut pins between the two screw-holes that keep the house halfs together. If fits, O.K.

 Here is the chip with its pin-out. The red arrows indicate the connections and data directions inside the chip

 

74LS244 shape
Figure 3.
 
  At the end, you'll get a complex that can be seated into the bottom of the Sub-D housing. Try it if it fits. Hopefully, it does. Take special care to the front of the chip, where it's really low on room. As final step, connect all remaining wires of the 8-wire cable to the resistors. When you think you're ready, once again verify all connections. Now it's time to try your work out. Connect the mini-DIN to the joystick port, and connect a joystick to the interface Sub-D connector. Then turn your computer on (turning the display on first seem to be reasonable, to be on the action right from the minute when you turn the computer on). The expectations are the same: when moving the joystick, you should see '3', 'W', '4', 'A' (joy2) or '5', 'R', '6', 'D', 'T' (joy1) characters on the screen. If it doesn't work, you should suspect...
  First you have to make sure that your Plus/4 is good. Try connecting, for example, the Select' and the Up line together on the joystick port, then switch the computer on. If it acts like constantly pressing '3' or '5' then the computer itselves is perfect. If not, the TED input latch is dead (as described above). If this is the case, for possible solutions see above.
  Hope you did all good. Seems like nothing will prevent your interface from surviving a few centuries ;-)

 

Contact

For contact, write to Levente@Terrasoft.Hu. Bug reports, improvements and comments are welcome.