Keypad

TI-89 Keypad

getkey

There are two ways to read keypresses from the TI-89 keypad. The first is to read the getkey value from RAM. The TI-OS interrupt handler will poll the keypad every auto interrupt 1 and create an 8-bit value that it will store to ($75a0). This value, for the most part, is identical to the getkey value used in TI-BASIC whose equates are defined in the 89 User's Manual. The problem with using this getkey value, though, is that it requires the auto interrupt 1 handler to be enabled. For this reason, most people in creating a game will write their own getkey using the keypad port directly.

Ports

The keypad port is located at $600019 (write) and $60001b (read). The keypad is organized as a matrix: the row number of the matrix row is put out $600018, and then all the pressed keys in that column will have a reset bit when $60001b is read from. The keyboard matrix is as follows:

Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
%1111110AlphaDiam. Shift2ndRightDownLeftUp
%1111101F5 Clear ^ / * - + Enter
%1111011F4 BackspcT , 9 6 3 (-)
%1110111F3 CatalogZ ( 8 5 2 .
%1101111F2 Mode Y ) 7 4 1 0
%1011111F1 Home X = | EE STO Apps
%0111111 Esc

For example, to check the 2nd keypress, we would do the following:


 move.b #%11111110,($600019)  ;set the row with 2nd in it

 move.b #5,d0

\wait:

 nop

 dbra.b d0,\wait              ;wait for this to take effect

 move.b ($60001b),d0          ;read back keypress data

 btst.b #4,d0                 ;bit 4 is column 4

 beq p2nd                     ;if bit reset, 2nd is pressed

It is necessary to wait between writing to ($600018) and reading from ($60001b) in order for the bitmask to take effect.

ON key

The ON key is not included in the keypad matrix and has its own port, $60001a. Bit 1 is reset when the ON key is held down, set when it is not. A bitmask is not needed to enable this bit as was needed for the keypad.

© 1998 - 1999 ACZ