[A89] _rowread()


[Prev][Next][Index][Thread]

[A89] _rowread()




> is the _rowread() function the only way to get keyboard input if auto int
1
> is disabled?

Yes

> can someone please give me
> an explanation of how to properly use _rowread()?

Look at the TIGCC docs for kbd.h.  Scroll down toward the bottom and you'll
see a pair of tables (you want the big ones that say Column on top, not the
small ones with arrow keycodes).

Now, say you're looking for a certain key (I'll use the 89's Enter as an
example) -- you want to input the "mask out" that key's bit in the "row".
That means that you want a word (two bytes) in which every bit BUT the bit
for that row is set.  Just use this formula to get that, where x is the
number of the row bit corresponding to that key (2 for 89's Enter):

~((short)(1<<x)

after calling _rowread() with this input, you'll get back a byte.  This byte
has 8 bits, each of which corresponds to the number of a key's "column"
within that "row".  89's Enter is in row zero, so you want to check if bit
zero of the output is set.  To do this, mask out all the other bits.  You'll
want a binary AND of the output with (1<<x), where x here is the column.

In summary, use this formula:

_rowread(~((short)(1<<r)))&(1<<c)

where r and c are the row and column of the key you're looking for in that
table.  It'll return true if they key is down, false if it is up.

    -Scott




Follow-Ups: