10

Looking at the schematic and explanation of how the C64 joystick ports work, it seems clear that the stick direction and button lines (JOYA0, through JOYA3 for port 1 and JOYB0, through JOYB3 for port 2) can also be used as outputs by having the attached device sense the levels of those lines (5V and 0V) and programming the CIA to pull the levels high and low in the same way as is done for keyboard scanning. (Or, for that matter, manually pressing appropriate keys on the keyboard to bring the levels low.)

This should also work on the VIC-20, and perhaps other Commodore computers with joystick ports.

Were any devices that used this technique manufactured and sold? If so, what were they, and how did they deal with keyboard interference with the scanning?

(This question was inspired by a comment on the pagetable.com blog post NES and SNES Controllers on a 6502 (like the C64). It seems to me that you could use the same technique with NES/SNES controllers plugged into the joystick ports instead of the user port, albeit you'd need to deal with the issue of keys pressed on the keyboard interfering with the I/O.)

Ola Ström
  • 327
  • 1
  • 2
  • 9
cjs
  • 25,592
  • 2
  • 79
  • 179
  • 1
    I recall a digital audio sampler for the Amiga using the (C64 compatible) joystick port to record line level input using 8 bit samples at ~8KHz. Most likely the data were sent 4-bits at a time. – Brian H Aug 13 '19 at 13:14
  • Why not use the Userport instead? It was meant for that sort of things. – Janka Aug 14 '19 at 07:31
  • 1
    @Janka Well, that's a quite different question only tangentally related to this one. But some reasons could be: 1) leaving the user port free for other peripherals, such as a modem; 2) lower hardware cost (due to cheaper connector and PC board); 3) connector wear (the user port edge connector is more fragile than the joystick connectors); and 4) non-technical users may feel more comfortable plugging and unplugging with the less intimidating joystick port and connector. – cjs Aug 14 '19 at 07:44
  • 1
    I think the joystick ports are the ones you don't want to use for anything but joysticks as everyone had them. Plus, the internal circuitry didn't feature any EMI protection to the CIA, so most people outright refused to unplug their joysticks and expose the ports. (It was the same for the Userport, but a damaged joystick port meant the box was essentially bricked.) – Janka Aug 14 '19 at 08:09
  • 1
    @Janka Even if "everyone had joysticks," non-game software that was more likely to use a modem, A/D or other user port device was less likely to use a joystick. Further, even fewer programs needed two joysticks, so a joystick, user port device and "dongle" could all be used together. But this is really not on topic at all for this question; if you want answers about this you should ask a separate question. – cjs Aug 14 '19 at 08:14
  • I just gave a real-life example what was typical. You also had two joysticks always connected because of the brittleness of the ports. – Janka Aug 14 '19 at 11:34
  • @janka I'm not clear on what your comments have to do with this question. Perhaps you should be posting your own, separate, question, if you have one, or going to a discussion board rather than SE if you want to vent about how you feel certain things that exist are a bad idea? – cjs Aug 14 '19 at 11:42
  • Actually, giving reasons why such devices weren't plenty is helpful in the context of your question. – Janka Aug 14 '19 at 12:08
  • @janka Perhaps helpful for misdirecting things to what you want to talk about, but no, I have no interest in how common such things were (since they were obviously not) or why you think (or anybody else thinks) one should use the user port instead. I'm interested merely in what devices did use the joystick ports. – cjs Aug 14 '19 at 12:28
  • I get it. Though, readers of your question might be interested in it. – Janka Aug 14 '19 at 12:30
  • @Janka To clarify to you (again) how SE works: questions should be posted as questions using the "Ask Question" button at the upper right. If you believe it's an interesting question, post it as a question! Or don't, if you agree that it's a tedious side-rant not useful to anyone. – cjs Aug 14 '19 at 13:02
  • Comments are meant for improving the question. You'd let my comment pass, ranting about how much it discomforts you instead. – Janka Aug 14 '19 at 13:06
  • @Janka If you have any comments that involve improving this question, as opposed to mixing it up with a separate question, I welcome them. Is it not clear to you that "what devices exist that do this" is an entirely different question from "is it a bad idea to do this"? – cjs Aug 14 '19 at 13:09
  • Yes. I had made it clear it's by no means obvious one could use the joytick ports for general I/O. It can be done but there are reasons users would not want to do it (all posted above). The question should read: Taken that it sounds like a good idea, and knowing the mentioned problems, which devices do it anyways? – Janka Aug 14 '19 at 13:14
  • @Janka Your assertion that it's not generally obvious that this can be done is unsupported. (I do accept that it's not obvious to you, however, if you're arguing that.) Regardless, it's clear from both the first paragraph of my question and from an answer describing a commerical product that did this that it can be done. – cjs Aug 14 '19 at 15:19
  • @Janka Whether it's a good idea or not is your little crusade and nothing to do with my question; I am merely asking what products did this. The answers to that do not change based on anybody's theories about how good or bad an idea it is. As to whether or not it's a good idea, that's clearly so unimportant that nobody, not even you, feels it's worth posting a question about it. – cjs Aug 14 '19 at 15:22
  • I seriously doubt you know the meaning of crusade. – Janka Aug 14 '19 at 17:28

4 Answers4

10

The dongle for the PaperClip word processor plugged into joystick port 1. It read bits 0 and 1 from the dongle and wrote bits 2, 3 and 4 to control it.

Keyboard interference probably wasn't an issue with this use case.

Alan B
  • 4,235
  • 19
  • 30
  • It was imperative that the dongle avoid keyboard interference, but I would think that an alternative dongle design could have exploited the relationship between the joystick and keyboard port if it included a circuit to watch input 0 and briefly assert inputs 1-4 in sequence in response to a rising edge on input 0. Without the dongle installed, only four rows of the keyboard would work. – supercat Oct 22 '19 at 15:07
5

The Inception 8 joysticks adapter uses a joystick port for two-way communication between C64 and Inception board. Basically, a program at the C64 would send a command sequence via the joystick port, switches the port to listen and receives the Inception board's reply. In most cases, the information communicated is the state of the joysticks connected to the Inception board, but the board's FPGA can also act as an external math coprocessor.

Peter B.
  • 4,447
  • 15
  • 36
  • Since Inception uses only a single Joystick port, it should also work with a VIC-20, but I'm not aware of any software supporting this. For the C64 there are a couple of games supporting Inception8. – Peter B. Oct 19 '19 at 20:51
4

The amazing little AtariLab was actually ported to the C64. This included pretty complete I/O, although it was mostly used for input. I'm not sure how many, if any, actually shipped.

Maury Markowitz
  • 19,803
  • 1
  • 47
  • 138
4

One prominent example is the "homebrew" EPROM burner Tiny Eprommer, originally published 1984 in 64'er Magazine, Special Issue #84. (People are still building/using this device; it's often seen on fx eBay as both kit or assembled product.)

The main board is attached to the user port but as the device needs more GPIO than what the user port provides, a daughter board is connected, with a cable, to the 2 joystick ports, each of which maps to 4 data bus pins on the EPROM. Thus, the device both reads and writes the EPROM's data bus using the control ports.

The keyboard scanning routine does not interfere as long as the host software refrains from calling the kernal routine for keyboard scanning ($EA86, typically invoked from the standard $EA31 interrupt handler), or disables interrupts. However, typing on the keyboard while using CIA1 for I/O is going to cause trouble, as "random" connections between inputs/outpus are being made.

(As a side note, the control ports are neither better or worse protected than the user port - if you check the schematic, you'll find they both connect directly to a CIA chip. There is nothing inherently wrong with interfacing devices through the control ports, but apart from the inconvenience to the user of having to remove controllers, there is also the limitation of keyboard interference, which for some scenarios - like the EPROM burner - can be acceptable. And of course, if you do blow a CIA, you're more likely to notice if it's the one handling the keyboard/control ports. :)

Retrograde
  • 4,506
  • 1
  • 17
  • 40
  • I wonder why the designers of such a device wouldn't use 74LS373 and/or 74LS374 or equivalent chips for I/O expansion? Adding one of each such chips would provide 16 extra I/O pins easily, and I would think that would be easier than adding an extra connector and cable. Wire the main 8 data pins of the user port to the EPROM data bus and the inputs of the 74LS373/374 chips. Wire one control output wire to the clock/latch inputs of the 74LS373/374 chips, and wire another to the EPROM chip-select. – supercat Sep 15 '20 at 16:28