EvanK
VCFed Founder
How do I program joystick input in GW-BASIC?
It's insanely easy in Applesoft: you use the PDL(0) and PDL(1) commands to determine where the stick is located along X/Y (0-255 on each scale) and then tell it what do based on those locations.
For example, in Applesoft, my Lego robot navigation code looks like this:
3000 REM NEVIGATION
3010 FB=PDL (1):LR=PDL (0)
3020 IF FB < 75 THEN M=5
3030 IF FB > 180 THEN M=10
3040 IF LR < 75 THEN M=9
3050 IF LR > 180 THEN M=6
3060 POKE L,M: REM SEND COMMANDS
(The variable L is the address of the interface card to the control box. The variable M gets translated into binary to turn the relevant bits on/off at the control box, which runs the motors, sensors, and lights.)
But I've never had to program for joystick control in a standard BASIC; obviously Apple customized theirs make it easier.
How do I do this kind of control in GW?
Also what about reading the button presses? Over in Applesoft land its IF PEEK (49249) > 127 and IF PEEK (49250) > 127 .... nice and simple for buttons 0 and 1.
It's insanely easy in Applesoft: you use the PDL(0) and PDL(1) commands to determine where the stick is located along X/Y (0-255 on each scale) and then tell it what do based on those locations.
For example, in Applesoft, my Lego robot navigation code looks like this:
3000 REM NEVIGATION
3010 FB=PDL (1):LR=PDL (0)
3020 IF FB < 75 THEN M=5
3030 IF FB > 180 THEN M=10
3040 IF LR < 75 THEN M=9
3050 IF LR > 180 THEN M=6
3060 POKE L,M: REM SEND COMMANDS
(The variable L is the address of the interface card to the control box. The variable M gets translated into binary to turn the relevant bits on/off at the control box, which runs the motors, sensors, and lights.)
But I've never had to program for joystick control in a standard BASIC; obviously Apple customized theirs make it easier.
How do I do this kind of control in GW?
Also what about reading the button presses? Over in Applesoft land its IF PEEK (49249) > 127 and IF PEEK (49250) > 127 .... nice and simple for buttons 0 and 1.