logoalt Hacker News

aidenn0yesterday at 11:04 PM1 replyview on HN

The port that was standardized on for PC joysticks was the dumbest possible one:

The joystick itself just had 1 potentiometer per axis, wired directly to the port. The port had no A/D, no timer, and no interrupt. Instead there was a GPIO and a capacitor. You discharged the capacitor with a GPIO write, and then polled the GPIO to measure when the capacitor was charged again. The number of iterations through your polling loop would be proportional to the position of the axis.

This is a pain to emulate if you aren't doing cycle-accurate emulation. IIRC Dosbox has a bunch of kludges and still doesn't get the joystick right for every game.

[edit]

To clarify the game port used a 558 (quad stripped-down version of a 555) as a schmitt trigger, so it generated pulses of a width proportional to the potentiometer position. I looked up the Apple II interface and it looks very similar, but with the caveat that accelerated versions (e.g. the IIgs) would always clock to 1MHz when reading the joystick port, compared to the PC that could run at a huge range of clocks (and CPI) over the lifetime of the port.


Replies

PunchyHamstertoday at 12:02 AM

I remember using similar trick to use LEDs to sense light. Basically, charge the (reverse biased) LED capacitance, then measure how long it takes to discharge. The lil circuit I had was LED bar, so I used it to sense finger position using that (other leds providing light, LED doing the sensing judging that light and comparing to rest