2 REM ** JOYSTICK DEMONSTRATION by Warren Fricke
3
5 LET C=10: LET L=10
10 PRINT AT L,C;"*"
15 LET LL=L: LET CC=C
20 LET S= STICK (1,1)
25 LET FB= STICK (2,1)
30 LET C=C+(C<31 AND (S=8 OR S=9 OR S=10))-(C>0 AND (S=4 OR S=5 OR S=6))
35 LET L=L+(L<21 AND (S=2 OR S=6 OR S=10))-(L>0 AND (S=1 OR S=5 OR S=9))
40 PRINT AT 10,14;"FIRE" AND FB=1
45 PAUSE 5
50 PRINT AT LL,CC;" " AND (LL<>L OR CC<>C)
55 GO TO 10
In this demo routine it is assumed that the joystick is plugged into the port on the player’s left. Refer to Lines 20 and 25. RUN the routine. A “*” will appear at Row 10, Column 10. This asterisk can be moved in any one of eight directions by positioning the joystick. The action of the GOTO loop is fairly fast (hence Line 45), and the asterisk may repeat the movement too quickly. If so, a deliberate stepping action can be introduced by a line like…
17 IF STICK (1,1) [illegible] 0 THEN GOTO 17
Now we must jog the paddle for each step. We can’t use PAUSE 0 to step the action as STICK can not release PAUSE like a keystroke does.
In this demonstration routine the fire button will print the word FIRE near the center of the screen when pressed. You can erase the word by running the asterisk thru it.
The conventional joystick produces a diagonal motion if the paddle is so positioned, but there is a drawback. The first step, before a diagonal one is taken, must be either vertical or horizontal. This is an inherent flaw in joystick design. To get a diagonal motion, two electrical contacts must be closed inside the joystick, and it is generally not possible to close them simultaneously. Hence, the motion starts off either horizontally or vertically, depending upon which switch closed first.
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.