Example Programs Joystick Routine
5 PRINT CHR$(17) :REM SWITCH CURSOR OFF
10 X=10: Y=10:P=0: I=1
15 PAPER P: INKI:CLS
20 A= PEEK (784) :REM READ PORT 1
25 B= PEEK (800) :REM READ PORT 2
30 IF A=1 OR B=1 THENGOTO100
40 IF A=2 OR B=2 THEN GOTO 200
50 IF A=8 OR B=8 THEN GOTO 300
60 IF A= l6 OR B=16THENGOTO400
70 IF A= 4 OR B= 4 THEN GOTO 500
80 GOTO 700
100 REM JOYSTICK UP
110 IF Y=0 THEN GOTO20:REM TOP LINE
120 GOSUB600
130 Y=Y-1:REM MOVE UP 1 SPACE
140 GOTO 700
200 REM JOYSTICK DOWN
210 IF Y=24 THEN GOTO 20: REM BOTTOM LINE
220 GOSUB 600
230 Y=Y+1:REM MOVE DOWN 1 SPACE
240 GOTO 700
300 REM JOYSTICK LEFT
310 IF X=2 THEN GOTO 20:REM LEFT EDGE
320 GOSUB 600
330 X=X-1 :RF.M MOVE LEFT 1 SPACE
340 GOTO 700
400 REM JOYSTICK RIGHT
410 IF X=39 THEN GOTO 20:REM RIGHT EDGE
420 GOSUB600
430 X=X+1:REM MOVE RIGHT 1 SPACE
440 GOTO 700
500 REM FIRE BUTTON PRESSED
510 P=P+1 :REM NEXT PAPER COLOUR
520 IF P=8 THENP=0:REM RESET
530 I=I+1:REM NEXT INK COLOUR
540 IF I=8THEN I=0:REM RESET
550 GOTO 15
600 REMOVE OLD CHARACTER
610 PLOTX,Y," ":RETURN
700 REM DISPLAY NEW CHARACTER
710 PLOTX,Y,"A":GOTO20
|
Joystick Hires Draw Program
5 HIRES
10 PRINT CHR$( 17) :REM SWITCH CURSOR OFF
15 X=100:Y=100:I=1
20 A = PEEK (784):REM READ PORT 1
25 B= PEEK (800) :REM READ PORT 2
30 IF A=1 OR B= 1 THEN GOTO 100
40 IF A=2 OR B= 2 THEN GOTO 200
50 IF A=8 OR B= 8 THEN GOTO 300
60 IF A=16 OR B=16 THEN GOTO 400
70 IF A= 17 OR B=17 THEN GOTO 500
75 IF A= 18 OR B=18 THEN GOTO 600
80 IF A= 9 OR B= 9 THEN GOTO 700
85 IF A= 10 OR B=10 THEN GOTO 800
90 IF A= 4 OR B= 4 THEN GOTO 900
95 GOTO 1000
100 REM JOYSTICK UP
110 IF Y=0 THEN GOTO 20:REM TOP LINE
120 Y=Y-1:REM MOVE UP1 SPACE
130 GOTO 1000
200 REM JOYSTICK DOWN
210 IF Y= 199 THEN GOTO 20 :REM BOTTON LINE
220 Y=Y+1 : REM MOVE DOWN 1 SPACE
230 GOTO 1000
300 REM JOYSTICK LEFT
310 1FX=0 THEN GOTO20:REM LEFT EDGE
320 X=X-1 :REM MOVE LEFT 1 SPACE
330 GOTO 1000
400 REM JOYSTICK RIGHT
410 IF X= 239 THEN GOTO 20: REM RIGHT EDGE
420 X=X+1:REM MOVE RIGHT 1 SPACE
430 GOTO 1000
500 REM JOYSTICK UP/RIGHT
510 IFX=239 0RY=0THENGOTO20:REM EDGE HIT
520 X=X+1:Y-Y 1 :REM MOVE IN DIRECTION
530 GOTO 1000
600 REM JOYSTICK DOWN/RIGHT
610 IF X= 239 OR Y= 199 THEN GOTO 20:REM EDGE HIT
620 X=X+1:Y=Y+1:REM MOVE IN DIRECTION
630 GOTO 1000
700 REM JOYSTICK UP/LEFT
710 IF X=0 OR Y=0THEN GOTO 20:REM EDGE HIT
720 X=X-1:Y=Y-1 :REM MOVE IN DIRECTION
730 GOTO 1000
800 REM JOYSTICK DOWN/LEFT
810 IF X= 239 OR Y=0 THEN GOTO 20:REM EDGE HIT
820 X= X+ 1 :Y= Y-1 :REM MOVE IN DIRECTION
830 GOTO1000
900 REM FIRE BUTTON PRESSED
910 I=I+1: REM NEXT INK
920 IF I=2THENI=0:REM RESET
1000 REM DRAW
1010 CURSETX,Y,1:GOTO20
|