Classic Computer Magazine Archive COMPUTE! ISSUE 37 / JUNE 1983 / PAGE 254

Atari Reset Run
Thomas A. Marshall

You can easily disable your BREAK key, but here's how to prevent accidental crashes caused by the system RESET key. This short routine also illustrates some uses of the "dynamic keyboard" technique.

This "RESET RUN" program was developed from a need to disable the system reset button. My two-year-old son kept stopping his alphabet teaching program by hitting the system reset button. I had disabled the break key with POKE 16,64: POKE 53774,64 (back on with POKE 16,192:POKE 53774,192).
    The program changes the system reset button vector so that the program merely reruns when the reset button is pressed. The program uses Atari's ability to vector (point) to where the computer should go when the system reset key is pressed. This is accomplished by POKEing the address of our machine language program at memory locations 12 and 13. The least significant byte goes to memory location 12, and the most significant byte goes to memory location 13. The program also uses Atari's ability to read from the screen with a POKE 842,13. With this POKE, the cursor will do continual RETURNS down the screen.
    The trick is to place a RUN statement on the screen so that the cursor will do a RETURN on it. Then a POKE 842,12 in the BASIC program will turn off the returning action. This dynamic programming technique has many applications.
    I decided to use this technique to convert the DATA statements into a single string and then delete the DATA statements. In this string form, the three lines can be easily entered at the beginning of any program. There are other ways to accomplish a program rerun, but the advantage of RESET RUN is that the machine language code is relocatable.
    To place the RUN statement on the screen, the machine language program first hides all the action by setting the character color and intensity the same as the background (lines 100 and 110). It then clears the screen (lines 120 and 130), sets the cursor row position (lines 140 and 150), reads "RUN two up arrows" and places it on the screen (lines 160 to 210). Finally, it turns on the dynamic programming with POKE 842,13 (lines 220 and 230), and jumps to the BASIC cartridge.
    The BASIC program POKES the disk boot initialization vector locations 12 and 13 with the address of the R$ string where the machine language routine resides and turns off Atari's dynamic programming feature with the POKE 842,12. At the end, the GRAPHICS 0 statement returns the character intensity to normal. If you do not want the program to delete the DATA statements, do not type in lines 330 to 370, and in line 320 type "RUN" instead of "GOTO 330".
    Note that once the system reset button is pressed, you cannot immediately use the SAVE command. When any disk operation is attempted, an ERROR 130, nonexistent device, results. To save the program, the initialization vector has to be reset with POKE12,64: POKE13,21. (If you have typed in the program, simply type GOTO 10 and press return.) Then press the system reset button and SAVE "D: filename". Also, note that if you immediately list the program after the initial run and then press the system reset button, the program will crash. In any case, it is always advisable to save any program prior to running it.

Reset Run
0 DIM R$(60)
1 GOTO 250
2 I=ADR(R$):H=INT(I/256):L=I-H*256:P
  OKE 12,L:POKE 13,H:POKE 842,12:GRA
  PHICS 0
5 ? "HI THERE, ATARI ENTHUSIAST!":EN
  D
10 POKE 12,64:POKE 13,21:? "NOW PRES
   S THE SYSTEM RESET BUTTON":? "AND
    SAVE THIS PROGRAM":END
100 DATA 169,148
110 DATA 141,197,2
120 DATA 169,125
130 DATA 32,164,246
140 DATA 169,2
150 DATA 133,84
160 DATA 169,0
170 DATA 32,164,246
180 DATA 169,28
190 DATA 32,164,246
200 DATA 169,28
210 DATA 32,164,246
220 DATA 169,13
230 DATA 141,74,3
240 DATA 76,0,160
250 DIM INSTR$(3):INSTR$="RUN"
260 S=LEN(INSTR$):FOR I=1 TO 16:READ
     T:R$(I,I)=CHR$(T):NEXT I
270 K=0:FOR I=17 TO 17+5*(S-1) STEP
    5:RESTORE 160
280 FOR J=0 TO 4:READ T:R$(I+J,I+J)=
    CHR$(T):NEXT J
290 K=K+1:R$(I+1,I+1)=INSTR$(K,K):NE
    XT I
300 FOR I=22+5*(S-1) TO 39+5*(S-1):R
    EAD T:R$(I,I)=CHR$(T):NEXT I
310 ? CHR$(125):POKE 766,1:POSITION
    2,5:? "1 R$(1,";I-1;")=";CHR$(34
    );R$;CHR$(34):POKE 766,0
320 ? "POKE 842,12:GOTO 330":POKE 76
    6,0:POSITION 0,0:POKE 842,13:END
330 IMAX=90:GOLINE=340:LMAX=360
340 IMIN=IMAX+10:IMAX=IMAX+140:IF IM
    AX>=LMAX THEN IMAX=LMAX:GOLINE=3
    70
350 ? CHR$(125):? :FOR I=IMIN TO IMA
    X STEP 10:? I:NEXT I
360 ? "POKE 842,12:? :? :GOTO";GOLIN
    E:POSITION 0,0:POKE 842,13:END
370 ? CHR$(125):? :? "370":? "POKE 8
    42,12:? :RUN":.POSITION 0,0:POKE_
    842,13: END