Thomas A Marshall
This utility allows you to GOTO any line in a program while it's running, simply by pressing a console key. See the "Automatic Proofreader" article on page 180 before typing in programs.
To access the OPTION, SELECT, and START keys on the Atari keyboard console, you can use the following BASIC program:
MK 0 GOTO 10 GC 1 ? "OPTION" : GOTO 20 EK 2 ? "SELECT" : GOTO 20 BJ 3 ? "START " : GOTO 20 FG 10 ? "This is a demonstration of the" GP 11 ? "use of Atari's console keys." HK 20 IF PEEK(53279) = 3 THEN GOTO 1 HO 30 IF PEEK(53279) = 5 THEN GOTO 2 IB 40 IF PEEK(53279) = 6 THEN GOTO 3 AA 50 GOTO 20
However, this requires that the computer be tied up in a loop, lines 20 to 50.
A much better way to accomplish the same thing is for a machine language program to check the console keys during the vertical blank period. (This is the time that the television's electron beam ends at the lower right corner of the screen until it begins again at the top left corner of the screen.) If a console key is pressed, the machine language program will execute a "GOTO line number" where the line number corresponds to the following keys pressed:
GOTO 1 for OPTION GOTO 2 for SELECT GOTO 3 for START GOTO 4 for SHIFT & OPTION GOTO 5 for SHIFT & SELECT GOTO 6 for SHIFT & START
Note that we have doubled the effective number of console keys by adding the SHIFT key. Using this technique, the BASIC programmer can go directly to any portion of his program without stopping the program and typing GOTO line number.
An Automatic RUN
If you are really lazy, you can have the BASIC line, 3 RUN, so that your BASIC program will RUN when the START key is pressed, regardless of whether the BASIC program was running beforehand or not.
Program 1 creates an AUTORUN.SYS file. Note that this file resets the memory location, MEMLO, that points to the beginning of a BASIC program. Thus, the vertical blank machine language routine resides safely below the BASIC program. The drawback to this technique is that the machine language program will be erased when you go to DOS.
An additional feature included in the disk version of "Atari Softkey" is the ability to autorun any BASIC program saved on the disk. Program 2 is a demonstration program which will be RUN automatically by the AUTORUN.SYS file. So, Program 2 should be saved on the disk with the filename as in the AUTORUN.SYS file. Program 2 currently has the filename GOTO.BAS, defined in line 40 of Program 1 by F$ = "RUN D:GOTO.BAS".
The Tape Version
For Atari owners who do not have a disk drive, Program 3 POKEs Softkey into page 6. You need to initialize the machine language (ML) routine with the USR statement in line 120. Program 3 is essentially the same as Program 1, but with the autorun feature removed. Again, whenever the console keys are pressed, lines 1–6 in Program 2 will be executed as described above.
However, remember that if there is no line number in the BASIC program corresponding to the console key pressed, an "ERROR 12", line not found, will occur.
The ML program is initialized by placing the low and high address of the start of the ML program into memory addresses 736–737 (RUNAD $2E0–$2E1). Upon completion of DOS.SYS load, the computer will run the ML program pointed to by this address. After resetting several vectors, the ML program sets the Vertical Blank Interrupt (VBI) vector using the deferred mode.
The Deferred Mode
I have used the deferred mode (accumulator = 7), since there are about 20,000 machine cycles available versus about 3800 cycles in the immediate mode (accumulator = 6). Thus, the ML routine checks whether the SHIFT and the console keys are pressed during the vertical blank period. Once the keys are pressed, the ML program jumps to the subroutine that sounds the keyboard click and resets the pointer to the editor routine so that the ML can perform the GOTO line number input. It then simulates a press of the BREAK key so that the editor buffer is emptied and the new editor pointers are executed. Once the BASIC G.line number is in the editor buffer, the editor pointer is reset. A RETURN, CHR$(155), is placed in the editor buffer to execute the GOTO line number statement.
Softkey has many applications. I have found it most useful in a program that required the modification of DATA statements. You can RUN the BASIC program simply by pressing the START key. Another application is to go directly to subroutines without going through a menu selection.