EasyManua.ls Logo

Sinclair ZX Spectrum

Sinclair ZX Spectrum
82 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 5
45
Joystick socket
The SPECTRA interface includes a Kempston compatible joystick socket, which is the
most widely supported standard by Spectrum games. The socket provides a +5V
output allowing it to drive the auto-fire mode found on many popular joysticks. To use
the joystick socket, it must first be enabled by setting configuration switch 5 to the on
position.
If a separate Kempston joystick interface or a peripheral which includes a Kempston
joystick socket is used then it is necessary to disable the one built into the SPECTRA
interface to prevent a conflict and potential damage to the hardware.
The Kempston joystick socket is read using input port 31 and returns a byte that
decodes as follows:
7
6
5
4
3
2
1
0
1=Right
1=Left
1=Down
1=Up
1=Fire
0=Not used (always 0)
0=Not used (always 0)
0=Not used (always 0)
Each joystick direction bit and the fire button bit is set to 1 when its corresponding
function is activated. The Kempston standard specifies that the upper 3 bits should
always return 0, although it is best not to rely on this since some 3
rd
party Kempston
joystick interfaces do not bother to set these bits.
The joystick socket can be read from BASIC using the IN function, as the following
program demonstrates:
10 PRINT AT 0,0;IN 31;" "
20 GOTO 10
When the joystick socket is disabled via configuration switch 5, reading the port may
return apparently random values instead of the expected value of $FF (for an idle data
bus). It is due to screen bytes appearing on the data bus as a result of the ULA
reading the display RAM during construction of the TV picture.

Table of Contents

Other manuals for Sinclair ZX Spectrum

Related product manuals