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.