Classic Computer Magazine Archive ANTIC VOL. 6, NO. 6 / OCTOBER 1987

Tech Tips


LOOP TOGGLE

This routine from Ken Cox of Fayetteville, Arkansas lets you toggle a programming loop with the [SPACEBAR] key:

10 FOR DELAY=1 TO 200:NEXT DELAY
100 REM START ROUTINE
110 IF PEEK(764)=33 THEN POKE 764,255:CLOSE #2:OPEN #2,4,0,"K:":GET #2,KEY:CLOSE #2
120 REM END ROUTINE
130 PRINT "WHAT A TIP!"
140 GOTO 10


SINGLE KEY INPUT ROUTINE

Carl Evans says be uses this neat little routine in just about every BASIC program be writes. You will find that it provides quite a programming convenience when you want to use a single key to answer a prompt or a question displayed on the screen. Subroutine KEY.LST simply tells the computer to wait for the operator to press a key on the keyboard. Upon RETURN from the subroutine, you will have the ATASCII value of the character, corresponding to the key that was pressed, stored in KEY. Here's the subroutine:

20440 REM KEY.LST
20441 OPEN #6,4,0,"K:"
20442 GET #6,KEY
20443 REM PUT SPECIAL EXIT #1 HERE
20444 REM PUT SPECIAL EXIT #2 HERE
20445 CLOSE #6:RETURN

Essentially, this routine OPENs the keyboard as a "device," just as if it was a printer or disk drive. In this particular routine the device number is 6. If the program you want to put this routine into is already using tbis device number for something else, you can change it to 4, 5, or some other legal number. Avoid using device 0 or 7, because the operating system uses them and results could be unpredictable. The screen editor uses device 0, and 7 is used by LIST, LOAD, PRINT and RUN. Caution: always CLOSE a device when you are through with it.

When this routine is called, the ATASCII code for the key you hit is stored in the variable KEY. Any special exit conditions must test KEY against the proper ATASCII codes.


AUTOBOOT SANS BASIC

This self-booting routine disables XL/XE internal BASIC and frees 8K of RAM. It does not disable external cartridges, disturb Atari 400s or 800s or require re-execution when you press [RESET], nor will it execute if BASIC is already disabled. This tip comes from Chris Richardson of Warren, Indiana. When RUN, this file creates BASDIS.EXE, which you can rename to AUTORUN.SYS.

10 OPEN #1,8,0,"D:BASDIS.EXE"
20 FOR Z=1 TO 90:READ D:PUT #1,D:CK=CK+D:NEXT Z
30 IF CK<>8790 THEN ?:?"CHECK TYPING OF DATA STATEMENTS"
40 CLOSE #1:END
1000 DATA 255,255,0,6,77,6,173,31,208,41,4,240,68,173,19,208,208,63,173,248,3,208,58
1001 DATA 173,1,211,9,2,141,1,211,169,192,133,106
1002 DATA 141,248,3,169,12,141,66,3,162,0,32,86
1003 DATA 228,169,3,141,66,3,169,12,141,74,3,169,6,141,69,3,169,76,141,68,3
1004 DATA 169,2,141,72,3,162,0,142,73,3,32,86,228,96,69,58,226,2,227,2,0,6


FUNCTION KEY VALUE CHART

You can use this handy chart by Carl Evans to help your program keep track of which console key is being pressed.

Keys Pressed PEEK(53279) Binary Code
None 7 00000111
START 6 00000110
SELECT 5 00000101
START and SELECT 4 00000100
OPTION 3 00000011
START and OPTION 2 00000010
SELECT and OPTION 1 00000001
All Three 0 00000000


INSTANT SCREEN FILL

Instantly filling your screen with a character is an old programming trick. Here's how Carl Evans, author of Atari BASIC, Faster and Better, does it on the 8-bit Atari.

The DATA statements in lines 110-150 contain the decimal number "translation" of a 34-byte USR routine. Lines 170-180 put the values into the first 34 bytes of Page Six—a 256-byte block of memory starting at location 1536($0600) which BASIC and DOS leave free for your use. The screen fill routine is relocatable, so you can replace the addresses in line 160. Just make sure that the location is safe and the value of MLEND is 33 more than MLSTART.

100 REM SFILL.DEM—SCREEN FILL FROM BASIC
110 DATA 104,201,1,208,254,104,104,170
120 DATA 165,88,133,204,165,89,133,205
130 DATA 138,160,0,145,204,230,204,208
140 DATA 250,230,205,166,205,224,160,208
150 DATA 242,96
160 MLSTART=1536:MLEND=1569
170 FOR X=MLSTART TO MLEND
180 READ Y:POKE X,Y:NEXT X
200 PRINT CHR$(125):PRINT
210 PRINT "SFILL.DEM—SCREEN FILL FROM BASIC"
220 PRINT:PRINT:PRINT "ENTER CHARACTER: ";
230 OPEN #2,4,0,"K:":TRAP 230
240 GET #2,KEY:CLOSE #2
250 X=USR(1536,KEY—32)
260 GOTO 260


If you have a Tech Tip that you would like to share with other readers, send it along to Antic Tech Tips, 544 Second Street, San Francisco, CA 94107. You might get your name in print. We always welcome very short programs that demonstrate the Atari's powers, simple hardware modifications, or useful macros for popular software.