Topic : The GFA-Basic Compendium Author : GFA Systemtechnik GmbH Version : GFABasic.HYP v2.98 (12/31/2023) Subject : Documentation/Programming Nodes : 899 Index Size : 28056 HCP-Version : 3 Compiled on : Atari @charset : atarist @lang : @default : Document not found @help : Help @options : +g -i -s +z @width : 75 @hostname : STRNGSRV @hostname : CAB @hostname : HIGHWIRE @hostname : THING View Ref-FileSTICK m STICK(p) STRIG(p) m, p: iexp The Atari ST is provided with two interfaces (ports) for the attachment of mouse and joysticks. Port 0 can return mouse or joystick information, but port 1 can only return joystick data. STICK 0 causes port 0 to return mouse information, and STICK 1 causes it to return joystick information. Port 1 always reads a joystick. Normally it is not necessary to use the command STICK, since mouse queries (MOUSE, MOUSEK, etc.) and joystick queries (STICK(), etc.) cause STICK 0 and STICK 1 to be executed automatically. However, before using AES functions (ALERT, etc.) the mouse should be activated if necessary with STICK 0. Note: A program that uses STICK 1 must also use STICK 0 before it exits! The function STICK(p) returns the position of a joystick. For p=0 the joystick at port 0 is read, and for p=1, the joystick at port 1. The values returned correspond to the position of the stick as follows:The function STRIG(p) returns the state of the fire button on the joystick attached to port p as a logical value: TRUE (-1) if it is pressed, or FALSE (0) if not. Note: The values for 'p' on the STE can be in the range 0 to 5. 0 and 1 act the same as normally found on the ST but 2-5 are exclusively for the STE, and DO NOT check for the mouse at the same time. This effectively speeds up the joystick polling. Examples: STICK 1 ! Activates joystick if attached to port 0 REPEAT direction%=STICK(0) fire!=STRIG(0) SELECT direction% CASE 4 PRINT "Left" CASE 8 PRINT "Right" CASE 2 PRINT "Down" CASE 1 PRINT "Up ENDSELECT UNTIL fire! WHILE STRIG(0) WEND ! Waits for fire button to be released STICK 0 ! Deactivate joystick --> With movement of the joystick, appropriate messages are printed until the fire button is pressed. After waiting for it to be released, the program ends. Note the difference between the REPEAT and WHILE constructs: REPEAT ' program segment UNTIL condition WHILE condition ' program segment WEND With REPEAT, the program segment will certainly be executed at least once, whereas with WHILE the program segment might not be executed at all if the condition is false. Memo: STE STICK() and STRIG() options are incorrectly detected on some machines based on the '_SND' cookie. STICK(p)/STRIG(p) Hardware STICK m 0 mouse/joystick yes 1 joystick yes 2 ste only no 3 ste only no 4 ste only no 5 ste only no The editor steals the joystick vector in supervisor mode, but the library does not. Both the editor and library fail to disable/enable interrupts while stealing the joystick vector.