The Keyboard

The keyboard is read by outputting a row on the address line A8 to A15 and reading the KBD ($B2) register in BLINK. The keyboard matrix looks like this:

------------------------------------------------------------------------- 
         | D7     D6      D5      D4      D3      D2      D1      D0 
------------------------------------------------------------------------- 
A15 (#7) | RSH    SQR     ESC     INDEX   CAPS    .       /       £ 
A14 (#6) | HELP   LSH     TAB     DIA     MENU    ,       ;       ' 
A13 (#5) | [      SPACE   1       Q       A       Z       L       0 
A12 (#4) | ]      LFT     2       W       S       X       M       P 
A11 (#3) | -      RGT     3       E       D       C       K       9 
A10 (#2) | =      DWN     4       R       F       V       J       O 
A9  (#1) | \      UP      5       T       G       B       U       I 
A8  (#0) | DEL    ENTER   6       Y       H       N       7       8 
------------------------------------------------------------------------- 
 

DIA         <DIAMOND> key
SQR         <SQUARE> key
LSH         Left <SHIFT> key
RSH         Right <SHIFT> key
LFT         <LEFT> arrow key
RGT         <RIGHT> arrow key
DWN         <DOWN> arrow key
UP          <UP> arror key

 

The keyboard can be read directly using a piece of code like below, although note that while reading the keyboard, BLINK will stop the processor for up to 40us:

            ld   c, $B2             ; I/O port $B2
            ld   b, row             ; one row of A15-8
            in   a, (c)             ; get column data in A

To check for the escape key being pressed.

            ld   c, $B2                                               
            ld   b, @01111111       ;Detect keys in matrix top row.
            in   a, (c)                                               
            cp   @11011111          ;Bit pattern returned if only the escape key is pressed.

If KWAIT (in INT) is set then performing a key read read will send the machine into Snooze state. When a key press is made the machine will wake up and if KEY (in INT) is set then a keyboard interrupt will occur.

web analytics