I'm running a parallel approach here. I try to create the keyboard controller either in TTL logic or by a microcontroller.
From
what I can read, the computer pulls address lines A8 - A15 LOW, one at a time when port $FE is read. The keyboard data is bit 0 - 4 in the response. The key pressed is pulled LOW for the key in one of the 8 groups corresponds to the address lines.
To make it easier on myself, I will connect the microcontroller to my existing keyboard controller,
Wilf Rigter's ZXKBDv3. Then I don't have address decoding, but just the keyboard matrix. The rows are connected to the address line (row 0 - 7), and the columns are connected to the response on the data bus (column 0 - 4).
I have received an oscilloscope for Christmas. It's a Hantek 2C72 with 2 channels at 70 MHz. I think that should be fast enough for a microcomputer at 3.25 MHz.
I'm trying to understand the signals to interpret and send from the microcontroller.
I assumed I would have 8 inputs which were mostly HIGH, and occasionally LOW, when the computer wanted to read one of the 8 groups of 5 keys. But when I measure with the oscilloscope I see a different picture. On the screenshot above, I have pressed the X key on the keyboard. The oscilloscope's channel 1 (yellow) is connected to row 0 (which behind the controller's circuitry is connected to A8). The oscilloscope's channel 1 (green) is connected to column 2 (which behind the controller's circuitry is connected to D2).
The picture is taken just as I press X. Before X is pressed row 0 is constantly at 0V, and column 2 is constantly at 5V. I had expected row 0 to be at 5V, and occasionally drop to 0V.
When X is pressed then row 0 go to 5V, and row 0 and column 2 are shorted and follow each other. But now the signal drop to 0V occasionally whenever the computer polls for the key.
I don't know how to code this in the microcontroller, as there is no signal, I can test before the key is pressed.
So I assume I can set all rows and columns to HIGH-Z, and when I want to send a key press, I set column 2 to HIGH, and read row 0, and detect when it is pulled LOW. Then I pull column 2 LOW until row 0 is HIGH again. Then I set all rows and columns back to HIGH-Z.
Please correct me if I have misunderstood.