_rowread Function* (tigcc.a)

kbd.h

unsigned short _rowread (unsigned short row);

Low-level keyboard reading.

_rowread is a function for low-level keyboard reading. It is implemented for simultaneous reading of more than one key (useful in games), or for reading keys when interrupts are disabled (useful if you want to avoid displaying status line indicators, which are displayed from Auto-Int 1).

Setting a bit in row masks the corresponding row of the keyboard from being read, so if row is zero, all rows are read at the same time. Take a look at _rowread_inverted as well. In the result, all bits (cols) corresponding to keys which are being held down are set. See below for some examples.

Here is a table which describes how the keyboard matrix is organized on both the TI-89 and TI-92 Plus:

TI-89:
  C o l u m n
R
o
w
   Bit 7     Bit 6     Bit 5     Bit 4     Bit 3     Bit 2     Bit 1     Bit 0  
Bit 0alphaDiamndShift2ndRightDownLeftUp
Bit 1F5CLEAR^/*-+ENTER
Bit 2F4BckSpcT,963(-)
Bit 3F3CATLGZ)852.
Bit 4F2MODEY(7410
Bit 5F1HOMEX=|EESTOAPPS
Bit 6       ESC

TI-92 Plus:
  C o l u m n
R
o
w
   Bit 7     Bit 6     Bit 5     Bit 4     Bit 3     Bit 2     Bit 1     Bit 0  
Bit 0DownRightUpLeftHandShiftDiamnd2nd
Bit 1321F8WSZ 
Bit 2654F3EDX 
Bit 3987F7RFCSTO
Bit 4,)(F2TGVSpace
Bit 5TANCOSSINF6YHB/
Bit 6PENTER2LNF1UJN^
Bit 7*APPSCLEARF5IKM=
Bit 8 ESCMODE+OLqBckSpc
Bit 9(-).0F4QAENTER1-

Note for TI-92+: ENTER1 is on the alphabetic and numeric keypads. ENTER2 is next to the cursor pad.

You can use binary numbers as implemented in TIGCC v0.91 (or higher) to mask out the rows you need. Note, however, that this is not recommended since programs written this way will not be compatible with other C dialects and previous versions of TIGCC.
Instead, you can make use of the fact that a value where only bit i is set equals 1<<i.
Use the bitwise NOT operator ('~') to invert the value.

These four expressions all check whether '9' on the TI-89 or 'E' on the TI-92+ is held down. In fact, they are all equal:

_rowread(~((short)(1<<2))) & (1<<3)
_rowread(~0b100) & 0b1000
_rowread(~0x4) & 0x8
_rowread(0xFFFB) & 0x8
But generally it is much easier to use the _keytest macro instead.

Because of the way the TI-89 and TI-92+'s keyboard is wired, if you hold down three keys that form the corners of a rectangle, the calculator will think you are also holding down the key at the fourth corner. The ON key is special. It is not part of the keyboard matrix and therefore cannot be read with _rowread. It triggers a special interrupt instead.

Note: It is recommended to redirect Auto-Int 1 and 5 while reading the keyboard using _rowread, because keyboard reading routines implemented in these two interrupts may interfere with _rowread if an interrupt occurs just while _rowread is executing. See DUMMY_HANDLER from intr.h for information on how to do this.

About the internal implementation: _rowread sends row to the I/O port 0x600018 (keyboard row mask), waits a while to allow the I/O to recover, then returns the byte read from 0x60001B (inverted for easier testing in C programs).


Used by: _keytest, _keytest_optimized, _rowread_internal, _rowread_inverted


See also: _rowread_internal, _rowread_inverted, _keytest