Loading...
 

IO Ports

The two ports (Port A and Port B) are 8 bits wide and can be set for either input or output. Port A is used to interface to various hand-held controllers (such as joysticks), but Port B is dedicated (with provisos) to reading the status of the Stella console switches.

Input or Output

The direction (input or output) for each pin (bit) on each port is controlled by a data direction register (DDR) for that port. The data direction register for Port A is SWACNT and for Port B it is SWBCNT. Writing a 0 to a pin's DDR bit sets that pin as input, and a 1 sets it as output.

Once the DDR has set the input/output direction of the pins of the port, they may be accessed - SWCHA for Port A and SWCHB for Port B.

Joysticks

Use SWCHA to read the joystick controllers.

Registers

For further details on the registers, click on the register name.

SWCHA (Port A, Joysticks/Paddles/Controllers)

Name
D7
D6
D5
D4
D3
D2
D1
D0
$282SWCHA
D7
D6
D5
D4
D3
D2
D1
D0

SWACNT (Data Direction Register for Port A)

Name
D7
D6
D5
D4
D3
D2
D1
D0
$281SWACNT
PA7
PA6
PA5
PA4
PA3
PA2
PA1
PA0

SWCHB (Port B, Console Switches)

Name
D7
D6
D5
D4
D3
D2
D1
D0
$282SWCHB
P1 DIFF
P0 DIFF
·
·
COL/B&W
·
SELECT
RESET

SWBCNT (Data Direction Register for Port B)

Name
D7
D6
D5
D4
D3
D2
D1
D0
$283SWBCNT
PB7
PB6
PB5
PB4
PB3
PB2
PB1
PB0

SWCHA
SWCHB
SWACNT
SWBCNT