15. JOYSTICK STRIG and STICK Here is an example of the use of STRIG and STICK if your joystick is connected to Port 1 (your mouse is connected to Port 0): STICK 1 ! joystick-mode (your mouse is now dead) REPEAT IF STRIG(1) joy&=3 ! fire ELSE joy&=STICK(1) ! joystick movement (0 if not moved) ENDIF ON joy& GOSUB n,s,fire,w,nw,sw,dummy,e,ne,se PAUSE 5 (...) UNTIL condition! STICK 0 ! back to mouse-mode You need eight Procedures for the eight possible directions (see below) and one Procedure for the fire-button. By the way, if you press the fire- button, MOUSEK will return '2'. The value 7 ('dummy') never occurs. If you don't touch the joystick, the value of joy& will be 0, and this means no Procedure will be called. A short pause (PAUSE 5) is advisable, because GFA-Basic is too fast. NW N NE 5 1 9 \|/ Directions: W 4-0-8 E In other words: North = bit 0 /|\ South = bit 1 6 2 10 West = bit 2 SW S SE East = bit 3 If you desperately need an active mouse while using the joystick, you could try the following 'dirty' method which uses XBIOS 34 (Kbdvbase) to find the joystick-data: joy.adr%=ADD(XBIOS(34),61) REPEAT IF BTST(BYTE{SUB(joy.adr%,11)},0) joy&=3 ! fire ELSE joy&=BYTE{joy.adr%} ! stick; 0 if no movement ENDIF ON joy& GOSUB n,s,fire,w,nw,sw,dummy,e,ne,se PAUSE 5 (...) UNTIL condition! Functions (CHAPTER.15) Joystick (page 15-1) JOYSTICK Returns status of joystick (usually Port 1): STICK 1 ! joystick-mode (your mouse is now dead) REPEAT ON @joystick(1) GOSUB n,s,fire,w,nw,sw,dummy,e,ne,se PAUSE 5 (...) UNTIL condition! STICK 0 ! back to mouse-mode Joystick_1 (page 15-1) JOYSTCK1 Illegal method to get joystick-status while mouse is still active: REPEAT ON @joystick_1 GOSUB n,s,fire,w,nw,sw,dummy,e,ne,se PAUSE 5 (...) UNTIL condition!