IBM-AT Keyboard Interface for the ZX-81

Author(s): Kai Fischer
Publication: ZXir QLive Alive!
Pub Details: ZXir QLive Alive! v6 n3 (Volume 6, Issue 3)
Date: Autumn 1996
Pages: 22
hand-drawn schematic "AT-Keyboard-Interface für ZX81 (80) / TS1000, Kai Fischer 07.04.1996" (MC 8049, two 2716 EPROMs E1 and E2, 74LS373, 74LS240, 74LS30, 10 MHz crystal)
hand-drawn schematic "AT-Keyboard-Interface für ZX81 (80) / TS1000, Kai Fischer 07.04.1996" (MC 8049, two 2716 EPROMs E1 and E2, 74LS373, 74LS240, 74LS30, 10 MHz crystal)
Adr.  Code      Befehl         Kommentar
      (dez.)
00    39        CLR A          (URSTART)
01    57        OUTL P1,A      Port löschen
02    20 08     CALL BYTE      Resetmeldg.
04    20 08     CALL BYTE      überlesen
06    04 40     JP HAUPT
08    186 00    MOV R2,0       (UP BYTE)
10    39        CLR A          auf Taste
11    54 11     JT0            warten
13    151       CLR C
14    70 17     JNT1           Datenbit
16    167       CPL C          einlesen
17    103       RRCA           und in
18    42        XCH A,R2       16 bit-Zahl
19    103       RRCA           schieben
20    42        XCH A,R2
21    38 21     JNT0           Clk=H ?
23    188 40    MOV R4,40      Timeout
25    38 13     JNT0           nächstes Bit
27    236 25    DJNZ R4        Schleife
29    42        XCH A,R2       12 bit zu
30    247       RLCA           8 bit
31    42        XCH A,R2       umformen
32    247       RLCA
33    170       MOV R2,A       Taste in R2
34    131       RET
Adr.  Code      Befehl         Kommentar
      (dez.)
40                             (HAUPTPROG.)
40    191 00    MOV R7,0       Shift löschen
42    20 08     CALL BYTE      Taste lesen
44    03 84     ADD A,84       Shift rechts?
46    150 52    JNZ
48    191 128   MOV R7,128     Shift setzen
50    04 85     JP
52    250       MOV A,R2
53    03 119    ADD A,119      Shift links?
55    198 48    JZ
57    250       MOV A,R2
58    03 08     ADD A,08       Taste losgelassen?
60    198 74    JZ
62    250       MOV A,R2
63    03 208    ADD A,208      Code>48?
65    246 68    JC             Code= alter Code-48
67    250       MOV A,R2
68    20 110    CALL MAKRO     Makro testen
70    111       ADD A,R7       Shift addieren
71    57        OUTL P1,A      Taste ausgeben
72    04 42     JP
74    20 08     CALL BYTE      Folgebyte
76    03 84     ADD A,84       Shift re.?
78    198 88    JZ
80    250       MOV A,R2
81    03 119    ADD A,119      Shift li.?
83    198 88    JZ
85    39        CLR A          norm. T. losgelassen
86    04 70     JP
88    191 00    MOV R7,0       Shift losgelassen
90    04 85     JP
Adr.  Code      Befehl         Kommentar
      (dez.)
95    39        CLR A          (WAITROUTINE)
96    98        MOV T,A
97    187 07    MOV R3,7       Ausgabefrequenz
99    85        START T
100   22 104    JTF
102   04 100    JP
104   235 100   DJNZ R3
106   131       RET
110   170       MOV R2,A       (MAKROAUSGABE)
111   03 174    ADD A,174      F1?
113   150 121   JNZ
115   184 200   MOV R0, 200    Tabelle
117   185 10    MOV R1, 10     10 Codes
119   04 160    JP OUT
121   250       MOV A,R2
122   03 173    ADD A, 173     F2?
124   150 132   JNZ
126   184 210   MOV R0, 210    Tabelle
128   185 04    MOV R1, 4      4 Codes
130   04 160    JP OUT
132   250       MOV A, R2
133   03 254    ADD A, 254     F3?
135   150 143   JNZ
137   184 215   MOV R0, 215    Tabelle
139   185 03    MOV R1, 3      3 Codes
141   04 160    JP OUT
143   250       MOV A, R2
144   03 170    ADD A, 170     F4?
146   150 172   JNZ
148   184 220   MOV R0, 220    Tabelle
150   185 03    MOV R1, 3      3 Codes
152   04 160    JP OUT
Adr.  Code      Befehl         Kommentar
      (dez.)
                               (UP Out)
160   39        Clr A          keine Taste
161   57        Outl P1,A      gedrückt (ZX)
162   20 95     Call Wait      warten
164   248       Mov A, R0      nächsten
165   163       Mov A, (A)     Code aus der
166   57        Outl P1,A      Tab. holen
167   20 95     Call Wait      warten
169   24        Inc R0         nächste Zelle
170   233 160   DJNZ R1        fertig?
172   250       Mov A, R2      alten Code
173   131       RET            herstellen

Makrotabellen:
F1 -> Adr.200: 118/253/117/11/95/95/31/31/112/246
Makro: PRINT/Shift Enter/USR/1/2/2/8/8/,/"
F2 -> Adr.210:22/253/117/31
Makro: RAND/Shift Enter/USR/8
F3 -> Adr.215: 114/31/112
Makro: POKE/8/,
F4 -> Adr.220: 118/253/114
Makro: PRINT/Shift Enter/PEEK

Any AT keyboard can be connected to the ZX81. The interface receives the 12-bit serial data from the keyboard and transforms it into 7-bit-Code plus one bit for Shiftkey. The 2716-EPROM E2 presents the ZX keyboard matrix and matches the ZX leads A8 … A15 with the 8-bit from the 8049 to data DO … D4. Remember, the ZX reads the keyboard by pulling one of A8 … A15 to low and reading the port SFE.

Just before finishing the AT-interface, I heard that a ZX-user from USA (see IKI by Jack Dohany, ZAQ! Spring ’96) developed a similar interface, but using XT-keyboards. Due to the 8049 microcontroller my interface is programmable; you can press one function key (F 1 … F12) at the keyboard and the interface gives a sequence of some keys to the ZX81!

Kai Fischer, [address omitted], Germany [phone number omitted]