On Wed, May 5, 2010 at 3:54 PM, Tony Duell <ard at p850ug1.demon.co.uk> wrote:
Those were
gimmicks, too, in their day - we used to spend quite a bit
of effort to adapt Atari joysticks to PET User Ports (one is easy, two
joysticks takes a bit of effort because there are five switches and
eight primary bits - mostly folks used diodes, but I think there was
I am wondering how you did this...
The wiring diagram is reproduced in the PET FAQ. Note that there was
not a lot of software that supported joysticks since not that many PET
owners had them.
http://www.zimmers.net/cbmpics/cbm/PETx/petfaq.html
IIRC, there are 5 swithces for the joystick, up, down,
left, right
Yep.
OK, up and down can't be actuated simultaneously,
nor can left and right.
This becomes important later...
But
combinations such as up-and-right are possible, at least on any decent
joystick.
That is not strictly correct - there were and are "4 way" and "8 way"
joysticks. Pacman shipped with 4-way" joysticks, and many MAME
enthusiasts have learned that trying to play with 8-way joysticks is
more frustrating than playing with the original type. It's now
possible to buy arcade-quality joysticks that can be swapped from the
top (with some sort of push and rotation move) so that you can buy one
set that plays either way without opening up your MAME cabinet.
And the fire button is independant of the joystick
position.
Yes.
That means there are 9 states for the joystick
(centre, U, D, L, R, UL,
UR, DL, DR -- using the obvious abbreviations). That takes 4 bits to
encode. Exactly the same number as if you fed each switch into its own
port line.
So you would still need 10 port lines...
You are making an assumption here - that it's required to support 18
unique states (9 joystick states with button up, 9 with button down).
To do that, yes, you need 10 port lines to support two joysticks.
What the aforementioned diode trick does is to activate up and down
simultaneously, an "impossible" 10th state for a regular mechanical
joystick. The joystick scanner routine must be checking for that
first, acting on the fire button being pressed, then *not* treating it
like the combination of an up event and a down event.
I I had to do it on an 8 bit user port, I think I
would use a '157 mux to
select between the 2 joysticks (4 bits each, going to 4 bits on the
port). And an port line configured as an output to switch between them.
And finally 2 more port inputs (a totla of 7 of the 8 user prot lines
used) for the fire buttons.
I think the Sega Genesis did something like that; at least I recall a
'157 in the game controller I dismantled years ago. By contrast, the
NES used one or two 4021 shift registers to pump bits in (the standard
NES controllers had 8 buttons and used 1 shift register, but the
"power pad" had 12 sensor spots and used two shift registers). That's
how they did eight buttons with a 7-pin connector - Vcc, ground,
latch, clock, D0, D3, D4, where a regular controller sends back its
data on D0, and the power pad sends back its data on D3 and D4
simultaneously.
-ethan