JOYSTICK CURSOR
by TED STOCKWELL
KEYJOY is a short routine that lets you use the joystick to move your onscreen cursor. Or, you can hook up a trackball and pretend you have an upside-down mouse.
Type in Listing 1, KEYJOY.BAS, check it with TYPO II and SAVE a copy before you RUN it. Listing 2 is the assembly language source code for the routine. It is presented for your information and you do not need to type it in. KEYJOY is a BASIC program that works on all 8-bit Atari computers of any memory size, with disk or cassette.
To use KEYJOY from BASIC, just RUN the program before you begin working with your main program. The joystick will now move the cursor like the arrow keys do. Normal operations are not affected by this routine and you can include it in any of your BASIC programs.
You may change the cursor speed by POKEing location 0 with any value from 0 to 255. The larger the value is, the slower the cursor will move when the joystick is used.
ODDS AND ENDS
You don't have to understand the program to use it. But knowledge is power. So...
An understanding of KEYJOY requires an understanding of assembly language. The routine is designed to be as short as possible, and it has been placed in the lower part of the 6502 stack area. (Antic altered the program slightly and placed it in the stack to free Page Six. Don't panic. Through experience, we have found that the stack will rarely grow large enough to endanger this area.--
KEYJOY has two parts. The first, INSTALL, sets up the Vertical Blank Interrupt (VBI) for MAIN, and only needs to be called once to initialize the interrupt vector. After it has been installed, it will run in the background and can be be ignored. However, pressing the [RESET] key will knock it out.
There is nothing special about why the immediate VBI was used. You may change it to a deferred VBI if you wish. In either case, KEYJOY should remain transparent to your BASIC programs--even if they contain their own VBIs. Of course, if the program is used outside BASIC, the PLA in line 420 of Listing 2 may not be necessary.
Ted Stockwell of Burnsville, Minnesota programs the Atari in assembly language, ACTION!, and BASIC.
Listing1:KEYJOY.BAS Download