KeypadTI-89 KeypadgetkeyThere 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.PortsThe 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:
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 keyThe 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.
|