Classic Computer Magazine Archive COMPUTE! ISSUE 30 / NOVEMBER 1982 / PAGE 196

Programming VIC's Function Keys

Jim Wilcox
Vienna WV

It would be nice if you could just touch one key and then a BASIC program would immediately begin execution. Or if, when debugging a program, you could press the first function key and get a LISTing. Here's how to do it.

Although the program that allows the function keys to be programmable is in machine language, no knowledge of machine language is needed to use it.

Once this program is typed in, double check the DATA statements, since one error can result in a catastrophe. RUN the program after SAVEing it, and wait for about five seconds. The following should then appear: "F1 = ? ". Type in the BASIC command or statement you would like the function one key to equal. For every carriage return you would like, type in the back arrow located on the upper left-hand corner of the VIC. Once you are sure the function key has been defined properly, press the RETURN key. The program will then ask for the rest of the function keys' definitions. After you have defined the eighth function key, the computer will print READY. The function keys are now ready to be used. Just press the appropriate function key, and the characters for which it was programmed will be printed.

What If It Doesn't Work?

If the VIC just locks up or if you don't get the READY message, turn the VIC off and reLOAD the program. Recheck the program with the listing provided, from the beginning to line 65, especially the DATA statements.

When the READY message occurs after all eight keys have been defined and the VIC doesn't print the characters corresponding to the function key, check the program from lines 70 to 95.

If it still doesn't work, check the subroutine in lines 100 through 115.

How The Program Works

The BASIC program will POKE two machine language programs into your VIC. One goes into the cassette buffer, the other in the uppermost memory position. The program in the cassette buffer asks for the definition of each function key.

Once the RETURN key is pressed, the program will store the ASCII value of the characters pressed in the uppermost portion of memory. After all eight keys have been programmed, the program will tell the computer to go to the other program in the top of memory every sixtieth of a second. The original program is not needed once the above operations have been performed and will be erased after any command for the cassette recorder is given. This is done to save 147 bytes of VIC's memory.

The second program will constantly check for a function key pressed. If one is pressed, the program will print the characters for which the function key was defined.

How To Save Memory

The longer each command for a function key, the more memory will be used up. If the commands are short, only about 200 bytes will be used up. The maximum amount of memory that can be used by this routine is about 800 bytes. To use the least amount of bytes, the commands can be typed in the shorthand method shown on pages 133–134 in the VIC Owners Manual.

Having programmable keys can be a great aid to a computer operator. The VIC is equipped with eight keys which you can use for whatever purpose you want. Time can be saved in writing and debugging programs. Here's an example:

F1 = ? LIST ←
F2 = ? POKE
F3 = ? RUN ←
F4 = ? PEEK(
F5 = ? GOTO
F6 = ? GOSUB
F7 = ? PRINT PEEK(7680)←
F8 = ? LOAD← LIST ←