Using the console keys

From: Michael Current (aa700@cleveland.Freenet.Edu)
Date: 01/28/92-10:34:28 PM Z


From: aa700@cleveland.Freenet.Edu (Michael Current)
Subject: Using the console keys
Date: Tue Jan 28 22:34:28 1992


Reprinted from the A.C.E.C. BBS (614)-471-8559

                          Bits of BASIC

            Using the console keys on your Atari XL/XE

Memory location CONSOL (53279, $D01F) is used to test the 
condition of the START, SELECT or OPTION keys.  By PEEKing into 
this location, you can tell if any combination of these keys are 
currently being depressed by the user.  NOTE: This DOES NOT 
include the RESET or HELP keys.

This little routine will demonstrate how to observe CONSOL from 
within your BASIC program:

     10 X=PEEK(53279)
     20 PRINT X
     30 GOTO 10

Running this program will make your computer repeatedly print "7" 
at the left margin of your screen.  Now, by pressing various 
combinations of the START, SELECT, and OPTION keys, you should see 
the following values returned from CONSOL:

  Values         Keys pressed

     0        OPTION/SELECT/START
     1          OPTION/SELECT
     2          OPTION/START
     3             OPTION
     4          SELECT/START
     5             SELECT
     6             START
     7             none

An example of how CONSOL is used from within a BASIC program might 
look like this:

     10 X=PEEK(53279):IF X=7 THEN GOTO 10:REM The program will 
             "loop" and appear to do nothing until a console key 
             is pressed.
     20 IF X=6 THEN GOTO 100:REM If START is pressed then proceed 
             to Main Program.
     30 IF X=3 THEN NEW:END:REM  If OPTION then program halts and 
             memory is cleared.
     40 IF X=5 THEN GOTO 200:REM  If SELECT then display Instructions.
     50 GOTO 10:REM If none of the above then try again.
     100 ***********************
     110 ** Main Program here **
     120 ***********************
     200 -------------------------------
     210 -- Instruction routines here --
     220 -------------------------------

It is important to note that CONSOL will not hold the values of 
the key(s) pressed after the keys are released.  Therefore the 
program MUST be prepared to deal with unexpected results.  This is 
accomplished in lines 10 and 50 above.

And that's all there is to it!



-- 
 Michael Current, Cleveland Free-Net 8-bit Atari SIGOp   -->>  go atari8  <<--
   The Cleveland Free-Net Atari SIG is the Central Atari Information Network
      Internet: currentm@carleton.edu / UUCP: ...!umn-cs!ccnfld!currentm
      BITNET: currentm%carleton.edu@interbit / Cleveland Free-Net: aa700


-----------------------------------------
Return to message index