Classic Computer Magazine Archive COMPUTE! ISSUE 8 / JANUARY 1981 / PAGE 77

Using the Atari Console Switches

James L. Bruun

The colored console switches to the right of the typewriter keyboard are just the ticket for programs with special features. The names seem to indicate just the kind of things one might wish to do in a program. OPTION - What better key to step through a choice of options. SELECT - After stepping through the options, this key could be used to select the current option. START - This key might be used to transfer control back to the beginning of a sequence or to start the program over again.

The problem is, how does one read these keys? Well, read on, here is a method that works well for me. First, we note that memory location 53279 is used to indicate the condition of all three switches. It's done like this. If we just PEEK(53279) with no switches pressed, we find a seven. Holding down one or more of the keys while doing our PEEK returns us a different number. The table below summarizes the values returned when a console key is pressed. X means that the key or keys are pressed.

Table 1
KEY VALUE 0 1 2 3 4 5 6 7
OPTION X X X X
SELECT X X X X
START X X X X

Now lets use this knowledge in a program.

10 DIM DISPLAY$(23)
20 PRINT "(CLEAR)" : POKE 752, 1
30 POSITION 5, 5
40 KEYS = PEEK(53279)
50 ON KEYS + 1 GOSUB 100, 110, 120, 130, 140, 150, 160, 170
60 PRINT DISPLAY$
70 GOTO 30
100 DISPLAY$ = "OPTION + SELECT + START" : RETURN
110 DISPLAY$ = "OPTION + SELECT  " : RETURN
120 DISPLAY$ = "OPTION + START " : RETURN
130 DISPLAY$ = "OPTION " : RETURN
140 DISPLAY$ = "SELECT + START " : RETURN
150 DISPLAY$ = "SELECT " : RETURN
160 DISPLAY$ = "START " : RETURN
170 DISPLAY$ = "NO KEYS ARE PRESSED " : RETURN

Of course the subroutines here are very simple, but this method can easily be expanded to fit your needs.