Would you like to make this site your homepage? It's fast and easy...
Yes, Please make this my home page!
Best viewed in 1024x768
TI-86 Keypad
The KeyPad is the set of all the keys on the TI-86 Graphic Calculator.
There are three ways to read keypresses of the TI-86:
-
_getky - Poll's for a keypress and returns the row/column code in OP2 (floating
point value). The key code diagram is in the TI-86 manual. For more information,
check out TI's Reading
Keypresses on the TI-86. The disadvantages are that the calculator
runs at full speed and that sucks the battery life out of the 86.
This was also called GET_KEY on the TI-85, and many programs use that name.
The name GET_KEY and the key codes (K_UP, K_ENTER, K_2ND, etc.) are defined
in asm86.h. This is the routine to use to detect 2nd and Alpha without
having to read the ports directly.
-
_getkey - Enters into low power mode and waits for a key press or for APD
(Auto Power Down). It returns the actual keypresses in the a register.
For more information, check out TI's
Reading Keypresses on the TI-86. The disadvantages are that the calculator
has the down-left bug. This the same input routine that used by the
ROM most of the time. It handles 2nd, alpha and the contrast changing
internally. I have had some problems using this routine, and I prefer
to use _getky. But this is the only routine to handle APD and
the other functions.
-
Using port #1 - By far the most efficient, if you want a key press all
you have to do is write one byte and read one byte. The whole program does
not stop waiting for the keypress either. Read below to find out
how to do this. Reading the ports directly is the only way to detect
multiple keypresses, which is essential to programming many games.
Note: Much of the info was derived from 86ports.txt by Alan
Bailey
Port 1
|
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
6 |
MORE |
EXIT |
2nd |
F1 |
F2 |
F3 |
F4 |
F5 |
5 |
ALPHA |
GRAPH |
LOG |
LN |
x^2 |
, |
STO |
-- |
4 |
x-var |
TABLE |
SIN |
EE |
7 |
4 |
1 |
0 |
3 |
DEL |
PRGM |
COS |
( |
8 |
5 |
2 |
. |
2 |
-- |
CUSTOM |
TAN |
) |
9 |
6 |
3 |
(-) |
1 |
-- |
CLEAR |
^ |
/ |
* |
- |
+ |
ENTER |
0 |
-- |
-- |
-- |
-- |
UP |
RIGHT |
LEFT |
DOWN |
This port can be represented as a 7x8 grid, as shown above.
-
First you must select which row you want by writing a byte to port 1. This
byte (bitmask) represents the ROWS. The corresponding row you want represents
the corresponding bit number. In this bitmask, Bit 7 is unused, and Bit
6-0 all contain 1's except for the row you want, in which case that bit
number would be 0. For example, if you want to select row 3, the bitmask
would be %011110111, where bit 3 is cleared and bit 7 is unused.
-
Next you wait a few T-states by using NOP, to give the port time to process
the information
-
Now you read a byte from the port. This byte represents the COLS. The cooresponding
bit that is set represents the corresponding column in the diagram. The
row and the column intersect to give you the correct status of that key.
Example:
#include "ti86asm.inc"
.org _asm_exec_ram
Start:
call _clrLCD
ld hl, $0000 ; Set up Pen row and column locations at 0,0
ld (_penCol), hl
ld HL, Prompt ; HL points to Prompt string
call _vputs ; Show string
Loop:
ld a,%01110111 ; Checking Row 3 (Bit 7 unused. Bit 3 represents row 3)
out (1),a ; Put bitmask into port
nop ; Give time for the port to acknowledge
nop
in a,(1) ; A = byte. Each bit corresponds to one column
bit 7,a ; Checking for bit 7, which is the Col 7
; Row 3, Col 7 is the DEL key
; Other code can be placed here while waiting!
jr nz, Loop ; The bit is cleared (thus zero flag set) if the key was pressed.
Continue:
ld HL, GoodBye ; HL points to GoodBye string
call _vputs ; Show string (15 pixels below the previous)
ret ; Return to TI-OS or shell
Prompt: .db "Waiting for DEL Key...", 0
GoodBye: .db "Pressed.", 0
.end