Classic Computer Magazine Archive ANTIC VOL. 5, NO. 12 / APRIL 1987

BY BRUCE OWEN BLOSSER

All About [BREAK] Disabling

Short BASIC routine prevents crashes


If you have ever lost important information, or simply wasted time due to pressing the [BREAK] key by mistake, or if you would like to prevent your programs trom being "crashed" by pressing the [BREAK] key, read on. Your solution is in the following article. Included is a short BASIC program that works on all 8-bit Atari computers of any memory size, with disk or cassette.

Since about 1982, all 8-bit Atari computers have had an operating system feature called the Break Key Interrupt Vector. (OS. Revision A does not have it.) What this means is that there is a two-byte cell in memory (bytes 566 and 567) that stores the location of a small subroutine the computer jumps to and runs whenever the [BREAK] key is pressed.

To find out where this subroutine resides in memory, we do a PEEK at memory locations 566 and 567. If you have Microsoft BASIC or OSS BASIC XL/XE you can simply DPEEK(566) and get the answer. Otherwise you will need to PRINT PEEK(566) + 256 * PEEK(567).

If you have an Atari 800 you should get a vector handler location of 59220. If you have an 800XL or 130XE you should get a location of 49298. Although the routines are in different places they are exactly the same. This makes altering the handler much easier to do for either kind of computer.

Just exactly what does the subroutine do? It is in machine language, so if that doesn't interest you, skip a couple of paragraphs to where we learn about disabling the [BREAK] key.

Here is the source code:

LDA #0

STA $11

STA $02FF

STA $02F0

STA $4D

PLA

RTI

The program loads a zero into the Accumulator, which is the main register on the 6502 microprocessor. It then stores that value into four memory locations. The first location (BRKKEY, memory location $11) is a flag to indicate if the [BREAK] key has been pressed. The second (SSFLAG, location $02FF) is a flag to start scrolling on the screen. The third (CRSINH, location $02F0) is a flag to enable the cursor.

Fourth is a flag (ATRACT, location $4D) to reset or start the attract mode. That color-shifting onscreen when you leave your Atari keyboard for about seven minutes is the attract mode. It conserves your picture tube and has also been widely used in video arcades to "attract" customers.

Finally the routine returns control to your BASIC program. The whole process is actually pretty simple.


If you've ever lost important
in Formation or simply wasted
time due to pressing the
[BREAK] key accidentally,
try this short BASIC program.

BREAK DISABLE
What does this have to do with disabling the break key? Well, the last two instructions in our vector interrupt handler will, if called, simply return control back to the main calling program, in effect disabling the [BREAK] key! To do this, insert a POKE 566, PEEK(5 66) +12 instruction at the beginning of your BASIC program and you'll disable the [BREAK] key You better believe that's easier than POKEing two locations after every print statement.

It is also possible to keep prying eyes from examining your BASIC programs by disabling the [BREAK] key, hiding the variable table, and forcing a cold start on [SYSTEM RESET] See Tech Tips in the November, 1986 Antic for more details. This protection scheme will not prevent those rare persons with a thorough knowledge of BASIC tokens from deciphering your code, but it will keep out run-of-the-mill snoopers.

If for some bizarre reason you wanted the graphics screen to go into attract mode every time someone pressed the [BREAK] key you could simply add one line to the assembler program we looked at earlier, store this new version of the break interrupt handler below in a safe part of memory, say Page 6, and then POKE this new handler location into the 16 bit interrupt vector, at locations 566 and 567.

The short listing which follows is a BASIC subroutine that you can use in your own programs to alter the break interrupt handler. To use it, simply LOAD the main part of your program into memory, making sure that the first line of your main program does a GOSUB 31000. Then ENTER this routine from disk or cassette (having LISTed it there earlier) or type it in. Remember to SAVE your completed program after you add this routine.


Keep prying eyes away
from your BASIC programs:
disable [BREAK], hide the
variable table and force a cold
start on [SYSTEM RESET].

   The routine is on the monthly disk under the filename BREAK.LST.

Whenever the [BREAK] key is pressed while your program is running, the screen will go into attract mode and the program will continue running. To alter this program so that the [BREAK] key is ignored but the screen does not go into the attract mode, simply change the number POKEd into 567 from 0 to 4.

31000 REM * * Create New BREAK Handler

31010 REM * * and Point To New Location

31020 POKE 1536,169:POKE 1537,128

31030 POKE 1538,133:POKE 1539,77

31040 POKE 1540,104:POKE 1541,64

31050 POKE 567,INT(l536/256)

31060 POKE 566,1536-PEEK(567)*256

31070 RETURN

Listing 1   BREAK.LST Download / View