Reading the Joysticks

Authors

Publication

Pub Details

Date

Pages

BASIC Terms

See all articles from CATS v2 n10

The two joysticks are controlled via Register 14 (I/O Port A) of the Programmable Sound Generator Chip (see Sections 2.1.6 and 2.1.7 of the TS2068 Technical Manual). Address and data are passed via Ports 0F5H and 0F6H respectively. The joysticks are read by first addressing Register l4 in the PSG by writing a 14 (0EH) to Port OFSH. The data is then read by executing an IN from Port 0F6H, having the port address in Z80 Register C and the joystick (player) number in Register B (number = 1 or 2). Note that PSG Register 7, Bit 6 is assumed to be zero, enabling I/O Port A for input. If you ever use I/O Port A for output (R7,B6=1), you will want to clear Bit 6 prior to any input operation.

Sample routine

GETJOY  LD A,0E        Load A=14
OUT A,(0F5) Address the joystick port
LD B,playerno
LD C,0F6 Data port address to C
IN A,(C) Joystick data to A
CPL Complement to High Active
AND 8F Get significant bits

The data read is LOW ACTIVE, i.e. all bits = 1 (byte=FFH) when the stick is at center and the button is not depressed. The figure below shows the interpretation of the data byte.

Products

 

Media

 

Image Gallery

Source Code

Scroll to Top