Joysticks are probably the most important input device for the Dragon for a number of applications from graphics to games. The Dragon supports two joysticks and they are named the left and right joysticks according to the port they are plugged into.

The Dragon's BASIC has functions for reading the joystick position. Oddly we are left peeking memory directly to decipher whether the button has been pressed.

10 CLS
20 PRINT @1, "right joystick"
30 PRINT @32, JOYSTK(0)
40 PRINT @64, JOYSTK(1)
50 RB=1:IF PEEK(65280)AND2 THEN RB=0
60 PRINT @97, "button";RB
70 REM
80 PRINT @161, "left joystick"
90 PRINT @192, JOYSTK(2)
100 PRINT @224, JOYSTK(3)
110 LB=1:IF PEEK(65280)AND1 THEN LB=0
120 PRINT @257, "button";LB
130 GOTO 20
The JOYSTK function returns a value from 0 to 63. 0 and 1 cover the right joystick position horizontal and vertical respectively. Similarly 2 and 3 the left. Value 31 is the centred position. Please note the above screenshot was from an emulator and my XBox controller does not quite match a regular Dragon 32 joystick in the values it returns! Thanks to zephyr for the simplified button code!