THE PIA (6532)

5.0 Port A - Hand Controllers

Port A is under full software control to be configured as an input or an output port. It can then be used to read or control various hand-head controllers with the data bits defined differently depending on the type of controller used.

5.1 Setting for input or output

Port A has an 8 bit wide Data Direction Register (DDR) that is written to at SWACNT (HEX 281) to set each individual pin of Port A to either input or output. The Port A pins are labeled PA0 thru PA7, and writing a "0" to a pins' DDR bit sets that pin as input, and a "1" sets it as an output. For example, writing all 0's to SWACNT (the DDR for Port A) sets PA0 thru PA7 (all 8 pins of Port A) as inputs. If F0 (11110000) were written to SWACNT then PA7, PA6, PA5 & PA4 would be outputs, and PA3, PA2, PA1 & PA0 would be inputs.

5.2 Inputting and Outputting

Once the DDR has set the pins of Port A for input or output they may be read or written to by addressing SWCHA (HEX 280).

5.3 Joystick Controllers

Two joysticks can be read by configuring the entire port as input and reading the data at SWCHA according to the following table:

               Data Bit  Direction Player
               D7        right          P0
               D6        left      P0
               D5        down      P0
               D4        up        P0
               D3        right          P1
               D2        left      P1
               D1        down      P1
               D0        up        P1

               (P0 = left player, P1 = right player)

A "0" in a data bit indicates the joystick has been moved to close that switch. All "1's" in a player's nibble indicates that joystick is not moving.

5.4 Paddle (pot) controllers

Only the paddle triggers are read from the PIA. The paddles themselves are read at INP0 thru INPT3 of the TIA. The paddle triggers can be read at SWCHA according to the following table :

               Data Bit  Paddle #
               D7        P0
               D6        P1
               D5/D4          (not used)
               D3        P2
               D2        P3
               D1/D0          (not used)

5.5 Keyboard controllers

The keyboard controller has 12 buttons arranged into 4 rows and 3 columns. A signal is sent to a row, then the columns are checked to see if a button is pushed, then the next row is signaled and all columns sensed, etc. until the entire keyboard is scanned and sensed. The PIA sends the signals to the rows, and the columns are sensed by reading INPT0, INPT1, and INPT4 of the TIA. With Port A configured as an output port, the data bits will send a signal to the keyboard controller rows according to the following table :

               Data Bit  Keyboard Row   Player
               D7        bottom         P0
               D6        third          P0
               D5        second         P0
               D4        top       P0
               D3        bottom         P1
               D2        third          P1
               D1        second         P1
               D0        top       P1
               (P0 = left player, P1 = right player)

NOTE : a delay of 400 microseconds is necessary between writing to this port and reading the TIA input ports.

Back to Table of Contents

Back to '4.0 The I-O ports'
Forward to '6.0 Address summary table'