A small machine code routine which accomplishes the same task is as follows:

```1000 .PAGE (JOYSTICK.8/5)   JOYSTICK - BUTTON READ ROUTINE
1010 ;
1020 ; AUTHOR - BILL HINDORFF
1030 ;
1040 DX = \$C110
1050 DY = \$C111
1060 * = \$C200
1070 DJRR   LDA \$DC00     ; GET INPUT FROM PORT A ONLY
1080 DJRRB  LDY #0        ; THIS ROUTINE READS AND DECODES THE
1090        LDX #0        ; JOYSTICK/FIREBUTTON INPUT DATA IN
1100        LSR A         ; THE ACCUMULATOR. THIS LEAST SIGNIFICANT
1110        BCS DJR0      ; 5 BITS CONTAIN THE SWITCH CLOSURE
1120        DEY           ; INFORMATION. IF A SWITCH IS CLOSED THEN IT
1130 DJR0   LSR A         ; PRODUCES A ZERO BIT. IF A SWITCH IS OPEN THEN
1140        BCS DJR1      ; IT PRODUCES A ONE BIT. THE JOYSTICK DIR-
1150        INY           ; ECTIONS ARE RIGHT, LEFT, FORWARD, BACKWARD
1160 DJR1   LSR A         ; BIT3=RIGHT, BIT2=LEFT, BIT1=BACKWARD,
1170        BCS DJR2      ; BIT0=FORWARD AND BIT4=FIRE BUTTON.
1180        DEX           ; AT RTS TIME DX AND DY CONTAIN 2'S COMPLIMENT
1190 DJR2   LSR A         ; DIRECTION NUMBERS I.E. \$FF=-1, \$00=0, \$01=1.
1200        BCS DJR3      ; DX=1 (MOVE RIGHT), DX=-1 (MOVE LEFT),
1210        INX           ; DX=0 (NO X CHANGE). DY=-1 (MOVE UP SCREEN),
1220 DJR3   LSR A         ; DY=0 (MOVE DOWN SCREEN), DY=0 (NO Y CHANGE).
1230        STX DX        ; THE FORWARD JOYSTICK POSITION CORRESPONDS
1240        STY DY        ; TO MOVE UP THE SCREEN AND THE BACKWARD
1250        RTS           ; POSITION TO MOVE DOWN SCREEN.
1260 ;
1270 ; AT RTS TIME THE CARRY FLAG CONTAINS THE FIRE BUTTON STATE
1280 ; IF C=1 THEN BUTTON NOT PRESSED. IF C=0 THEN PRESSED.
1290 ;
1300 .END
```

 This page has been created by Sami Rautiainen. Read the small print. Last updated May 20, 1998.