![]() Independent Key-Scanning on SHARP's
written by Maurice Hawes / SUC/UK
Source: SUC-magazine July 2001, Volume 21, Number 2, p. 7 |
||||||||||||||||||||||||||||||||||||
Independent Key Scanning on Sharp MZ-Computers |
||||||||||||||||||||||||||||||||||||
An Overview compiled by Maurice Hawes |
||||||||||||||||||||||||||||||||||||
In other words, if there are no keys down in the scanned row the software returns $FF; but in any other case the software returns a value less than $FF and the positions of the low bits indicate the positions of the depressed keys in that row of the matrix. On most early MZ-machines, a matrix containing 10 rows of 8 keys is enough; but the MZ-80B needs 12 rows, and the MZ-2500 needs 14 rows ( though with a lot of positions unused ). This does not affect the above principles; it merely means that, in order to scan the whole keyboard, 10 software loops will cover early machines, but 12 are needed on the MZ-80B, and 14 are needed on the MZ-2500. On all machines, the scanning process is controlled by an 8255 chip, which is connected to certain ports on the master Z80 CPU. And this is where differences of detail start to occur; on the MZ-80K, MZ-80A, MZ-700, and MZ-800 in MZ-700 Mode these ports are 'memory-mapped to addresses $E000 - $E001, and are accessed, as far as key-scanmng is concerned, by writing the strobe row to address $E000, and reading the key data from address $E001. But on the MZ-80B, the MZ-2500, and the MZ-800 in MZ-800 Mode, the relevant ports are not memory-mapped, and they have to be addressed directly by the appropriate Z80 IN and OUT codes, sending the strobe row OUT to one port, and reading the key data IN from another port. The full details are as follows:
* N.B. On the MZ-80B and MZ-2500, bits 7 - 6 - 5 of $E8 are used to control other devices and bit 4 high opens the keystrobe gate. Therefore the value at PORT $E8 must first be READ IN, and then sent back OUT with bits 7 - 6 - 5 unaltered, bit 4 set high, and bits 3 - 2 - 1 - 0 set to the selected Strobe Row No. Volumes 5/2, 6/2 and 18/1 carried detailed articles all the above machines
except the MZ-800, with full key matrix diagrams. In order to bring
them all under one roof and include the MZ-800, these articles are updated
and reprinted on the following pages. |