Classic Computer Magazine Archive COMPUTE! ISSUE 29 / OCTOBER 1982 / PAGE 156

The VIC Keyboard Redefined

Amihai Glazer

Assistant Professor of Economics

University of California

Irvine, CA

With this short program for the 5K VIC, you can make any key on the keyboard represent any other key. This gives you the freedom to make an alphabetic keyboard, a numeric keypad, or any keyboard plan you need.

You might need to use a numeric keyboard on your VIC. As it is, all numerals are situated on the top row of the keyboard instead of being conveniently arranged in a square pattern which makes data entry easy. This program creates just such a keypad in the center of the keyboard, as shown in Figure 1. Thus, for example, hitting the space bar will be equivalent to hitting "0," and hitting the "R" key will have the same effect as hitting the "7" key.

Not only will the screen show numerals each time the appropriate keys are pressed, but the computer will actually interpret these alphabetic keys as the corresponding numerals. The program also allows the user to redefine any key as any other key. You can, for example, rearrange your keys in alphabetical order, or create any keyboard you like.

Type in the program and RUN it. To enable the new interpretation of the keys, type SYS 7424 and hit RETURN. You now have a numeric keypad. To return to a normal keyboard, just hit the RUN and RESTORE keys simultaneously (alternatively, you can execute the statement POKE 655, 220: POKE 656, 235). Executing a SYS 7424 will bring back the numeric keypad.

You can also redefine keys of your own choosing. Type GOTO 220 and hit RETURN. Now enter pairs of keys: the key you want changed, and then its new meaning. To stop the program, hit the Fl key. Thus, if you want the key labelled " = " to mean "*", hit the " = " key, then the "*" key, and then the "Fl" key. To turn on these new definitions, type SYS 7424 and hit RETURN.

What's Happening

The program works as follows. Normally, during interrupt processing every sixtieth of a second, the VIC calls the decode logic machine language program, whose address ($EBDC) is in the jump vector in locations $028F-$0290. Our machine language program in locations $1DOO-$1D14, however, sends the VIC to another machine language program we've put in locations $1D15-$1D24.

This program picks up the code for the key just pressed, given in location $CB. It then indexes into a recode table (beginning in location $1D27, decimal 7463), and puts the new code back into location $CB. Processing continues by jumping into the normal decode logic program in ROM, which is at location $EBDC.

The program's Lines 10-110 insert these two machine language programs into memory. Lines 120-140 initialize the recoding table, and lines 150-200 recode the keys in the form shown in Figure 1. Custom recoding by the user is provided for in lines 220-330. The recoding table is initialized in lines 230-250. CO$ and CN$ get the key that is being redefined, and its new definition. The codes the VIC uses for these keys are obtained from location 203 ($CB); CO and CN are assigned these values. A code of 39 (representing the "Fl" key) stops the program. The appropriate changes in the recoding table, which will be used by the machine language program, are performed in lines 310-320.

Figure 1.