Controller Port Pinouts

Year
1979
Type
Interface
Category
Technical reference — joystick/controller ports
Manufacturer
Atari, Inc.
Side of an Atari 800XL showing its two 9-pin controller ports

Overview

The controller ports are the most versatile connectors on an 8-bit Atari. Each is a male DE-9 plug wired to three different chips: four general-purpose I/O bits on the PIA, two analogue "pot" inputs on POKEY, and one trigger input on GTIA (CTIA on early 400/800s), plus +5 V and ground. The same physical port is used by the Atari 2600, so its joysticks, paddles, driving controllers and keypads all work. Because the PIA bits can be switched to outputs, the ports also double as a small parallel interface — Atari's own XEP80 80-column box and countless home-built projects talk to the computer through them.

The 400 and 800 have four ports (1–4) on the front; every later model, including the XE Game System, has two.

Pin assignments (port 1)

Pin Signal Used by
1 PIA Port A bit 0 Joystick up; driving controller bit 0; trackball X direction; touch-tablet stylus button; light-pen button / light-gun trigger; XEP80 data out
2 PIA Port A bit 1 Joystick down; driving controller bit 1; trackball X motion; XEP80 data in
3 PIA Port A bit 2 Joystick left; trackball Y direction; touch-tablet left button; trigger of paddle 1
4 PIA Port A bit 3 Joystick right; trackball Y motion; touch-tablet right button; trigger of paddle 2
5 POKEY pot 1 (0–5 V analogue) Paddle 2 position; touch-tablet vertical
6 Trigger 0 (GTIA) Joystick / driving / trackball button; light-pen/light-gun detect to ANTIC (not on the 400)
7 +5 V Power for controllers and small devices
8 Ground
9 POKEY pot 0 (0–5 V analogue) Paddle 1 position; touch-tablet horizontal

(Pins 1–5 form the wider row of the DE-9 and pins 6–9 the narrower row.)

The other ports

Port Direction bits (pins 1–4) Pot lines (pins 9, 5) Trigger (pin 6) Models
1 PIA Port A bits 0–3 ($D300) POT0, POT1 TRIG0 All
2 PIA Port A bits 4–7 POT2, POT3 TRIG1 All
3 PIA Port B bits 0–3 ($D301) POT4, POT5 TRIG2 400/800 only
4 PIA Port B bits 4–7 POT6, POT7 TRIG3 400/800 only

On XL/XE machines, Port B is used for memory control (OS ROM, BASIC, Self Test and 130XE banking) instead, TRIG2 always reads "not pressed" (on the XEGS it senses the keyboard), and TRIG3 is the cartridge-present signal. On the 400, only port 4's trigger is wired to ANTIC's light-pen input, so a light pen works in port 4 alone; the 800 and later accept one in any port.

Reading the ports

The OS copies everything into shadow registers once per video frame, and Atari BASIC wraps them in functions:

BASIC Shadow (decimal) Hardware Meaning
STICK(0)–STICK(3) 632–635 PORTA/PORTB nibbles 15 = centred; 14 up, 13 down, 11 left, 7 right (bits are active-low)
STRIG(0)–STRIG(3) 644–647 TRIG0–3 0 = pressed
PADDLE(0)–PADDLE(7) 624–631 POT0–7 1–228
PTRIG(0)–PTRIG(7) 636–643 PORTA/PORTB bits 0 = pressed

So diagonal up-right is 14 AND 7 = 6, and so on. A quick tester:

10 PRINT STICK(0),STRIG(0),PADDLE(0)
20 GOTO 10

Using the ports as I/O

Each PIA port has a control register (PACTL $D302 for Port A, PBCTL $D303 for Port B). Clearing bit 2 of the control register exposes the data-direction register at the port address; a 1 bit there makes the matching pin an output. Atari's keyboard-controller routine and the XEP80 rely on this, as do many DIY projects such as MIDI interfaces, mice and EPROM programmers. Restore the default with POKE 54018,60 (PACTL) or SYSTEM RESET.

Tips

  • Pin 7 is a real +5 V supply that small devices can draw on; take care with home-made cables.
  • Trigger lines can be latched: setting bit 2 of GRACTL ($D01D) makes GTIA hold a trigger press so short taps are not missed (light-gun software uses this). On an XL/XE it also latches TRIG3, the cartridge sense line.
  • Phantom diagonals. Nothing stops a non-joystick device asserting "up" and "down" at once; software reading STICK should ignore impossible values.
  • Paddle timing. POKEY counts the pot lines once per frame, so paddle values lag the knob by a frame.

Credits