Loading...
 

SWCHA

Port A is 8 bits wide and can be set for either input or output. It is used to interface to various hand-held controllers. Access to the controller is through SWCHA. The direction of data (input or output) must be set for each bit of the port, using the port's data direction register (DDR) SWACNT.

SWCHA (Port A, Joysticks/Paddles/Controllers)

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

Joysticks

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

Direction
Player #
D7
0 = RIGHT pressed
Player 0
D6
0 = LEFT pressed
Player 0
D5
0 = DOWN pressed
Player 0
D4
0 = UP pressed
Player 0
D3
0 = RIGHT pressed
Player 1
D2
0 = LEFT pressed
Player 1
D1
0 = DOWN pressed
Player 1
D0
0 = UP pressed
Player 1


(Player 0 = left player, Player 1 = 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.

IO Ports
SWACNT