Control Port

From C64-Wiki
(Redirected from joystick port)
Jump to navigationJump to search
Controlport 1 and 2 of C64

The Commodore 64 has two control ports on the rightmost side for attaching peripherial devices like joysticks, paddles, mouse, lightpen or dedicated hardware like sound digitizers.

The connector itself is a 9 pin d-sub male, most devices of that time used this connector for plugging in joysticks.

Pinout[edit | edit source]

(Looking onto the connector from outside of the computer)

Controlport 1 and 2 of C64

Port 1[edit | edit source]

Port 1Joystick

Pin Signal Remarks
1 Joy A0 up
2 Joy A1 down
3 Joy A2 left / paddle a fire x
4 Joy A3 right / paddle a fire y
5 Pot AY paddle a pot y
6 Button A / LP fire or lightpen
7 + 5V max. 100 mA
8 GND Ground
9 Pot AX paddle a pot x

Port 2[edit | edit source]

Port 2Joystick

Pin Signal Remarks
1 Joy B0 up
2 Joy B1 down
3 Joy B2 left / paddle b fire x
4 Joy B3 right / paddle b fire y
5 Pot BY paddle b pot y
6 Button B fire
7 + 5V max. 100 mA
8 GND Ground
9 Pot BX paddle b pot x

Internally the control ports are not read by dedicated inputs, instead they are attached to various points of the keyboard matrix, which goes to CIA#1. This causes some trouble when the joystick is set to autofire (random chars will be entered) or when a joystick is stuck in one direction it can lock out certain keys. Most games and programs make use of the Control port 2 as it is easier to handle - for example control port 1 joystick left direction is hardwired to the CTRL key and can cause trouble when scrolling out of the screen in basic programs (scrolling slows down).

The X/Y inputs for paddle controllers are read out by two A/D converters in the MOS6581/8580 sound interface device, as they are analog values that can go from 0 to 255. Every control port can have two paddles attached, and since the SID chip only has two A/D converters, there is a register for switching which port should be read. The paddle buttons are also attached to the keyboard matrix.

When a mouse is attached it is read similar to the paddles, the X/Y values are set by the mouse ball. other than with paddles - when the value exceeds 0 or 255 it wraps around and restarts, depending on the direction the mouse is pushed.

There are also curious applications for using the control port. The german 64'er magazine published a short tutorial that descibes how to plug the paddle wires into a potted plant's soil and read the input for generating "singing plant" sounds. depending on the water level, the resistance of soil changes and can be easily read out.

See the corresponding articles for joystick, paddles, mouse and lightpen for more information.

With the C64GS a second fire button was introduced, this connected +5V (pin7) to POTX (pin9), a third button could be hooked up by connecting +5V to POTY as well. A resistor of about 270-330 Ohm in between +5V and the button is recommended as a safety measure.