Prev: E21D Up: Map Next: E241
E239: Read Keyboard Port
Reads some rows of the keyboard. The row selector is also written to port FD (with the selector as the high byte of the address), which does nothing on a 48K Spectrum and is not part of any sound; the keyboard is read with the same selector straight afterwards.
Input
A Row selector (a bit which is reset selects the row)
Output
A Keys pressed, in bits 0 to 4 (a bit is set when a key is pressed)
F Zero flag set if no key is pressed
Write the selector, then read the keys.
ReadKeyboardPort E239 OUT ($FD),A Write the half-row selector to port FD. The ULA only responds to even port numbers, so this has no effect on the 48K Spectrum, but it leaves the selector in A for the next instruction.
E23B IN A,($FE) Read the rows of the keyboard.
Make the pressed keys into set bits, and return.
E23D CPL Invert the bits, so that a bit is set for a key which is pressed.
E23E AND %00011111 Keep only bits 0 to 4.
E240 RET Return.
View the equivalent code in;
Prev: E21D Up: Map Next: E241