Visit Atarimax Store

Free-Net Logo
The Atari SIG Historical Archive
Created and hosted by:

Article #6 (51 is last):
Newsgroups: freenet.sci.comp.atari.product.8bit.tricks
From: aa700@cleveland.Freenet.Edu (Michael Current)
Subject: Using the console keys
Posted-By: xx004 (aa700 - Michael Current)
Reply-To: aa700@cleveland.Freenet.Edu (Michael Current)
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

     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: / UUCP: ...!umn-cs!ccnfld!currentm
      BITNET: / Cleveland Free-Net: aa700

Visit Atarimax Store