An interesting project.Bill B wrote: Cog 3
This cog reads the state of the MTX keyboard drive lines, and outputs the the selected row of the in-memory keyboard model to the sense lines. The MTX Z80 writes the drive lines with one instruction, and reads the sense lines with the very next instruction. With a real keyboard the sense lines update instantly (or at least at the speed of light). The Propeller is significantly faster than the Z80 but updating the sense lines in time is still a challenge. In order to achieve this, it has to be assumed that only one drive line is active at any one time. This is always true for the MTX ROM, but may not be true for all games that implement their own keyboard decoding. The Propeller code uses a binary search to identify the active drive line. This enables the required keyboard row to be selected using only three tests.
The Speculator used nine bytes of the 6116 SRAM for reading/writing data for the eight key rows, one byte for each individual row and the ninth for all rows selected at the same time, which is commonplace in Spectrum code for detecting any key press (followed by row testing). I don't know whether MTX games did this too, but if they did the software priority encoder in cog 3 is likely to miss key presses. A preliminary drive line zero test would solve this problem, if it really exists and there is time for the extra test.