Function Keys For The Apple
IIan Reuben
Frequently used commands (or sequences of commands) can be input more easily by function keys defined by the programmer. This machine language program lets you define up to five function keys for the Apple; you can enter the program using the Apple's monitor or the BASIC loader provided.
A standard feature of many newer computers (for example, the Commodore 64, the VIC-20, and many Japanese computers) is the function key. It allows the user to easily enter frequently used commands, or even sequences of commands, and get it right every time. (How many times have you rushed your fingers over the keyboard, only to see you've typed CATALOF or LISY?)
Since the Apple has no special function keys, the only way to get them is through software. "Function Keys" is a machine language utility which provides up to five programmable function keys. A little over half a page (128 bytes) in length, the program resides at location $300 (decimal 768). It also uses a range of memory from $9000 to $94FF. It can be entered directly using the Apple's built-in monitor (Program 1) or with a BASIC loader (Program 2).
Defining Functions
Function Keys allows you to define or use up to five function keys in direct mode. Each function can represent a series of commands of up to 256 characters in length. When you press CTRL-F, the computer will wait for you to press the number of the function you would like to use (1 through 5) or press 0 to define a function. Pressing any other number will produce a CTRL-X.
Once you have indicated what function you want to use, press RETURN and the computer will act as if you'd typed in the function you used. Pressing the key of an undefined function will just give a carriage return.
To define a function, press 0. The computer will respond with the message FN#? (1-5, 0 = EXIT). It is asking you what function number you would like to define. Pressing 0 here will abort the define procedure. When the appropriate function number is pressed, the computer will input what you want it to record as that function. Type it in as if you were actually giving the computer that command. When you are done, press RETURN. If you wish to abort while you are typing it in, just press RESET.
Here is a step-by-step example of how to use function keys. Suppose you want to turn CATALOG into a function key:
- Type CTRL-F.
- Press 0 since you want to define a function.
- When you see the computer's prompt (FN#?…), press 1, since you want to define function number one.
- Type CATALOG and press RETURN.
- Now, whenever you press <CTRL-F> 1 <RETURN> you should get a disk catalog.
Putting The Program On Disk
Entering Function Keys through the monitor will be a lot quicker than typing in the whole BASIC loader. In any case, when you are done, save it by typing:
BSAVE FUNCTION KEYS 1.2, A$300, L$9C
However, if you do use the BASIC loader, make sure you SAVE it before trying it out, in case you made any mistakes.
Once you have the machine language for "Function Keys 1.2" saved on disk, enter the setup routine (Program 3) and save it. Now, whenever you want to use Function Keys, run the setup program. It's a good idea to use the setup program as part of a HELLO program so that every time you boot that disk, Function Keys will be automatically enabled. If for some reason you want to disable Function Keys, enter 9D04:BD 9E from the monitor if DOS is enabled, and if it isn't, enter 36:F0 FD. You might need to disable Function Keys before running certain programs.
Program 1: Data For Function Keys
0300- C9 86 00 1C 18 20 5B 03 0308- B0 19 A0 FF C8 C0 FF F0 0310- 42 B1 06 99 00 02 C9 80 0318- D0 F2 84 06 A6 06 CA 60 0320- 4C BD 9E A0 10 B9 8B 03 0328- 20 F0 FD 88 10 F7 38 20 0330- 5B 03 A9 F0 8D 04 9D A9 0338- FD BD 05 9D 20 67 FD A9 0340- 00 8D 04 9D A9 03 8D 05 0348- 9D A0 00 B9 00 02 91 06 0350- CS D0 F8 A2 00 A9 88 8D 0358- 00 02 60 08 20 0C FD C9 0360- B6 B0 10 C9 B0 90 0C F0 0368- 18 E9 21 85 07 A9 00 85 0370- 06 28 60 28 A9 87 20 F0 0378- FD A9 98 9D 00 02 68 68 0380- 60 28 B0 02 38 60 68 68 0388- 4C 53 03 A9 D4 C9 D8 C5 0390- BD B0 AC B5 AD B1 A8 A0 0398- BF A3 CE C6
Program 2: BASIC Loader
10 FOR ADDR = 768 TO 923 20 READ BYTE 30 POKE ADDR, BYTE 40 NEXT 50 DATA 201, 134, 208, 28, 24, 32, 91 60 DATA 3, 176, 25, 160, 255, 200, 192 70 DATA 255, 240, 66, 177, 6, 153, 0, 2 80 DATA 201, 141, 208, 242, 132, 6 90 DATA 166, 6, 202, 96, 76, 189, 158 100 DATA 160, 16, 185, 139, 3, 32, 240 110 DATA 253, 136, 16, 247, 56, 32, 91 120 DATA 3, 169, 240, 141, 4, 157, 169 130 DATA 253, 141, 5, 157, 32, 103 140 DATA 253, 169, 0, 141, 4, 157, 169 150 DATA 3, 141, 5, 157, 160, 0, 185, 0 160 DATA 2, 145, 6, 200, 208, 248, 162 170 DATA 0, 169, 136, 141, 0, 2, 96, 8 180 DATA 32, 12, 253, 201 185 DATA 182, 176, 16 190 DATA 201, 176, 144, 12, 240, 24 200 DATA 233, 33, 133, 7, 169, 0, 133 210 DATA 6, 40, 96, 40, 169, 135, 32 220 DATA 240, 253, 169, 152, 157, 0, 2 230 DATA 104, 104, 96, 40, 176, 2, 56 240 DATA 96, 104, 104, 76, 83, 3, 169 250 DATA 212, 201, 216, 197, 189, 176 260 DATA 172, 181, 173, 177, 168, 160 270 DATA 191, 163, 206, 198
Program 3: Setup Routine
10 D$ = CHR$ (4): REM CTRL-D 20 PRINT D$"BLOADFUNCTION KEYS 1.2" 30 OUTVEC = 9 * 4096 + 13 * 256 + 4: REM $9D04 40 POKE OUTVEC,0: POKE OUTVEC +1,3 50 PRINT : PRINT "FUNCTION KEYS ENABLE D."