Atari Keypad
R. Alan Belke
Here's an alternative to buying an add-on numeric keypad—simply emulate one in software. This machine language utility redefines part of your existing keyboard as a numeric keypad which you can turn on and off at will. It works on all Atari 400/800, XL, and XE computers with a disk drive.
Because I type in lots of programs from magazine listings, I'm constantly looking for shortcuts. Some of the toughest programs to type are those which consist of hundreds of numbers—data for machine language routines or character sets. Although you can buy a plug-in numeric keypad, there is a more economical alternative.
The solution came to me when I first saw a TRS-80 Model 100 computer. Pressing the NUM key on that portable lap computer turns part of the keyboard (keys M, J-K-L, and U-I-O) into number keys (0, 1- 2-3, and 4-5-6, respectively). Since keys 7-8-9 lie right above U-I-O, this lets you enter numbers 0ndash;9 and press RETURN using only the fingers on your right hand. The makeshift keypad is a little slanted, but it's easy to adapt to. Also, notice that the D, A, and T keys are unaffected. You can type DATA statements all day without having to switch off the keypad to type the keyword DATA.
"Atari Keypad" duplicates the Model 100's arrangement on Atari computers. The program works by intercepting the keyboard interrupt routine and redirecting it to a new routine. You can toggle the keypad on and off by simultaneously pressing SHIFT-CTRL-N.
There was one major problem with carrying out this idea. Since Atari Keypad is most useful when entering BASIC programs—or when used in combination with other programs—it has to sit somewhere in memory without interfering with anything else. My original version of Atari Keypad locates itself in the upper half of page 6, a fairly safe section of memory which starts at location 1536 (hex $600). This protects it from the meanderings of Atari BASIC. But realizing that page 6 is used by a host of other programs and routines, including computers "Automatic Proofreader," I've provided another version that hides in low memory. One version or the other should cover most situations.
Automatic Keypad
Program 1 creates an AUTORUN.SYS file on disk that loads Atari Keypad into page 6 when you boot the system. Program 2 creates an AUTORUN.SYS file that loads Atari Keypad into low memory when you boot. Since the exact location of MEMLO, the low-memory pointer, can vary, the version of Atari Keypad created by Program 2 automatically modifies itself for any value of MEMLO. That explains all the IF-THEN statements which make the program look so strange.
To use Atari Keypad, try the version created by Program 1 first. If that doesn't work, try the other version. Use the second version with the Automatic Proofreader.
If you already have an AUTO-RUN. SYS file on your disk that you regularly use, you can append it to the Atari Keypad AUTORUN. SYS file so both will boot automatically.
Follow these steps:
- Boot up Atari DOS 2.0 or 2.5.
- Rename your existing AUTORUN. SYS file. For example, call it OLDAUTO.
- Exit to BASIC and run either Program 1 or Program 2 to create the keypad AUTORUN. SYS file on disk.
- Enter DOS and select the COPY option. When the prompt appears, type OLDAUTO,AUTO-RUN. SYS/A. Don't forget the /A or you'll end up with your old AUTORUN.SYS file and have to start over again.
If your existing AUTORUN. SYS file happens to use the same memory as Atari Keypad, it would be overwritten when the keypad is booted. Another problem could crop up if your present AUTORUN.SYS file installs a routine at MEMLO and the routine isn't relocatable. If the keypad is installed at MEMLO first, the second routine would wind up at a different address than it was designed for. This would most likely cause the system to crash. Most of the time there's no trouble, however.
If you can touch-type on a keypad, you'll find Atari Keypad a great aid when entering DATA statements. But don't forget it can also be useful with other programs that call for numeric input.
For instructions on entering these listings, please refer to "COMPUTE!'s Guide to Typing In Programs" published bimonthly in COMPUTE!.
Program 1: Atarl Keypad For Page 6
PA 10 OPEN # 1, 8, 0 "D : AUTORUN.SYS" EK 20 FOR X = l TO 170 LE 30 READ A : PUT #1, A PL 40 NEXT X CP 50 CLOSE #1 DN 60 END AM 1000 DATA 255, 255, 128, 6, 238, 6, 32, 128, 6, 120 MB 1010 DATA 173, 8, 2, 141, 165, 6, 173, 9, 2, 141 DE 1020 DATA 166, 6, 169, 156, 141, 8, 2, 169, 6, 141 JK 1030 DATA 9, 2, 88, 96, 169, 6, 72, 169, 167, 72 KN 1040 DATA 8, 8, 76, 164, 6, 173, 252, 2, 201, 227 AH 1050 DATA 208, 12, 174, 238, 6, 208, 3, 232, 208, 1 GJ 1060 DATA 202, 142, 238, 6, 174, 238, 6, 240, 42, 201 NJ 1070 DATA 37, 208, 2, 169, 50, 201, 1, 208, 2, 169 MH 1080 DATA 31, 201, 5, 208, 2, 169, 30, 201, 0, 208 AE 1090 DATA 2, 169, 26, 201, 11, 208, 2, 169, 24, 201 NK 1100 DATA 13, 208, 2, 169, 29, 201, 8, 208, 2, 169 CO 1110 DATA 27, 141, 252, 2, 104, 64, 0, 0, 6, 42 DB 1120 DATA 6, 165, 12, 141, 129, 6, 165, 13, 141, 130 DK 1130 DATA 6, 169, 128, 133, 12, 169, 6, 133, 13, 120 HF 1140 DATA 173, 8, 2, 141, 165, 6, 173, 9, 2, 141 DI 1150 DATA 166, 6, 169, 156, 141, 8, 2, 169, 6, 141 LH 1160 DATA 9, 2, 88, 96, 226, 2, 227, 2, 0, 6
Program 2: Atari Keypad For Low Memory
KG 10 START = 4 + PEEK (743) + PEEK (744) * 256 PB 20 OPEN #1, 8, 0, "D : AUTORUN.SYS" DO 30 FOR I = 1 TO 190 DG 40 READ X : IF I = 3 THEN X = START - INT (START/256) * 256 AI 50 IF I = 4 THEN X = INT (START/256) KK 60 IF I = 5 THEN X = (START + 120) - INT ((START + 120)/256) * 256 BL 70 IF I = 6 THEN X = INT ((START + 120)/256) IN 80 IF I = 15 THEN X = (START + 47) - INT ((START + 47)/256) * 256 CG 90 IF I = 16 THEN X = INT ((START + 47)/256) LF 100 IF I = 21 THEN X = (START + 48) - INT ((START + 48)/256) * 256 EN 110 IF I = 22 THEN X = INT ((START + 48)/256) LI 120 IF I = 24 THEN X = (START + 38) - INT ((START + 38)/256) * 256 FF 130 IF I = 29 THEN X = INT ((START + 38)/256) BM 140 IF I = 35 THEN X = (START + 128) - INT ((START + 128)/2S6) * 256 IA 150 IF I = 40 THEN X = INT ((START + 128)/256) FJ 160 IF I = 46 THEN X = INT ((START + 49)/256) MI 170 IF I = 49 THEN X = (START + 49) - INT ((START + 49)/256) * 256 HN 180 IF I = 135 THEN X = (START + l) - INT ((START + 1) /256) * 256 FA 190 IF I = 136 THEN X = INT ((START + 1)/256) HE 200 IF I = 140 THEN X = (START + 2) - INT ((START + 2)/256) * 256 EG 210 IF I = 141 THEN X = INT((START + 2)/256) BN 220 IF I = 143 THEN X = START - INT (START/256) * 256 KA 230 IF I = 147 THEN X = INT (START/256) PA 240 IF I = 155 THEN X = (START + 47) - INT ((START + 47)/256) * 256 IJ 250 IF I = 156 THEN X = INT ((START + 47)/256) PB 260 IF I = 161 THEN X = (START + 48) - INT ((START + 48) / 256) * 256 IJ 270 IF I = 162 THEN X = INT ((START + 48)/256) PE 280 IF I = 164 THEN X = (START + 38) - INT ((START + 38)/256) * 256 JB 290 IF I = 169 THEN X = INT ((START + 38)/256) EP 300 IF I = 175 THEN X = (START + 128) - INT ((START + 12B)/256) * 256 LD 310 IF I = 180 THEN X = INT ((START + 128)/256) CI 320 PUT #1, X : NEXT I GA 330 CLOSE #1 G0 340 END ML 1000 DATA 255, 255, 0, 29, 120, 29, 32, 0, 29, 120 HF 1010 DATA 173, 8, 2, 141, 47, 29, 173, 9, 2, 141 OM 1020 DATA 48, 29, 169, 38, 141, 8, 2, 169, 29, 141 OJ 1030 DATA 9, 2, 88, 169, 128, 141, 231, 2, 169, 29 CD 1040 DATA 141, 232, 2, 96, 169, 29, 72, 169, 49, 72 LC 1050 DATA 8, 8, 76, 46, 29, 173, 252, 2, 201, 227 DD 1060 DATA 208, 12, 174, 120, 29, 208, 3, 232, 208, 1 MA 1070 DATA 202, 142, 120, 29, 174, 120, 29, 240, 42, 201 NK 1080 DATA 37, 208, 2, 169, 50, 201, 1, 208, 2, 169 MI 1090 DATA 31, 201, 5, 208, 2, 169, 30, 201, 0, 208 PM 1100 DATA 2, 169, 26, 201, 11, 208, 2, 169, 24, 201 NL 1110 DATA 13, 208, 2, 169, 29, 201, 8, 208, 2, 169 DA 1120 DATA 27, 141, 252, 2, 104, 64, 0, 0, 6, 52 JK 1130 DATA 6, 165, 12, 141, 1, 29, 165, 13, 141, 2 DK 1140 DATA 29, 169, 0, 133, 12, 169, 29, 133, 13, 120 HK 1150 DATA 173, 8, 2, 141, 47, 29, 173, 9, 2, 141 PB 1160 DATA 48, 29, 169, 38, 141, 8, 2, 169, 29, 141 OO 1170 DATA 9, 2, 88, 169, 128, 141, 231, 2, 169, 29 DN 1180 DATA 141, 232, 2, 96, 22 6, 2, 227, 2, 0, 6