Classic Computer Magazine Archive ANTIC VOL. 5, NO. 11 / MARCH 1987


Page 6 Grab Bag

Punch up your program with these useful routines

Plug one of these short but powerful USR routines into your own BASIC program to create a Joystick Enhancer or a Console Key Expander that operate at Assembly language speed. You do not need to know assembly language to use the routines. The BASIC programs work on all 8-bit Atari computers of any memory size, with disk or cassette.

After you are familiar with Atari BASIC, what next? Assembly language is the next logical step. Fortunately your Atari offers a bridge between these two languages-the USR (USeR) function. This function lets the programmer call fast, powerful machine language routines from a BASIC program.

To smooth the transition between BASIC and assembly language even more, Atari also has a "protected" area of memory known as Page 6. Page 6 occupies 256 bytes of memory from location 1536 to 1791 (0600 to 06FF in hexadecimal). And it is left untouched by the operating system and BASIC.

During the coming months, Antic will be presenting a number of short but effective Page 6 utility routines which were originally released in 1982 by Synapse Software, You do not need to know assembly language. Just type in these useful tools and make your programming sessions more productive.


Our first routine, Joystick Expander, greatly reduces programming effort. It lets you use a simple ON . . . GOTO instruction to handle the different joystick directions.

When Joystick Expander is used in your program, the values returned from a STICK(X) function will not be the standard ones. A centered joystick will return 0, forward returns a 1. (See Figure 1.) The values increase by one in a clockwise direction, with the forward/left combination returning 8.

To use Joystick Expander in your own program, type in Listing 1, JSTICK.LST, checking it with TYPO II. You do not need to type in Listing 2, JSTICK.M65, which is the assembly language source code (for MAC/65 or Atari Assembler/Editor) provided for the information of assembly language programmers. After you have an error-free copy of Listing 1, remove the TYPO II program and LIST JSTICK.LST to disk or cassette. Now, LOAD (or type in) your own program and then type ENTER "D:JSTICK.LST". (Cassette owners substitute "C: for "D:). This will merge JSTICK.LST with your program.

Make sure that your own program does not have any lines numbered higher than 30000, or they will be replaced by the Joystick Expander. Somewhere near the beginning of your program include the line below. (Change the sample line number, if needed)

101 GOSUB 30000: JUNK = USR(1536)

The USR call only needs to be made once. Thereafter, any joystick readings will produce the new values.


This month's second routine is a useful Console Key Enhancer. With this routine in place, you will double the number of possible values that can be returned from your console keys--[OPTION], [SELECT] or [START]. Normally, a statement such as Y=PEEK (53279) would indicate which key was pressed.

Using the Console Key Enhancer, you can also detect the [SHIFT] key used in combination with the console keys. You can even "latch" these key values, so they are remembered after the keys are released.

Type in Listing 3, CONSOLE.LST, checking it with TYPO II. Follow the instructions about LISTing and ENTERing programs, which were explained above for the Joystick Expander routine. You do not need to type in Listing 4, CONSOLE.M65, the assembly language source code.

Add the following line to your own program, changing the line number if necessary. This routine only needs to be called once, unless you switch in or out of latch mode: 101 GOSUB 31000:


Note that we are passing a second parameter to the routine. The variable CMD can have one of three values 0 to turn OFF the enhancer, 1 to turn it ON, or 128 to turn on the enhancer and latch the last key pressed. Now, whenever you wish to read the console keys, do a PEEK(BUTTON) instead of a PEEK(53279).

Refer to the following table to see the values you may expect:

Normal               Enhanced  
No press = 7         No press = 0
[START] = 6          [START] = 1 
[SELECT] = 5         [SELECT] = 2  
[OPTION] =3          [OPTION] = 4
n/a                  [SHIFT]-[START] = 9
n/a                  [SHIFT]-[SELECT] = 10 
n/a                  [SHIFT]-[OPTION] = 12


This article does not provide extensive technical explanations of the two routines, but the assembly source code is well documented and should provide interested readers sufficient information to understand how they work. These source programs can be assembled on either the Atari Assembler/Editor cartridge, or MAC/65 from Optimized Systems Software.

IMPORTANT: Because the Joystick Expander and the Console Key Enhancer run from the same part of Page 6, you should only use one of them in any program. For example, if you're using the joystick routine and decide to add any other routine which uses Page 6, the Joystick Expander will be over-written.

Cousins Matt Loveless and Mike Eggers were both in their mid-teens when Page 6 was origanly released on disk by Synapse Software in 1982.

Listing1:CONSOLE.LST Download / View

Listing2:CONSOLE.M65 Download / View

Listing3:JSTICK.LST Download / View

Listing4:JSTICK.M65 Download / View

Partial Dvorak Keyboard (DVORAK.BAS Download
) by Dave Yearke