Prev: E200 Up: Map Next: E241
E239: Read a half-row of the keyboard
Used by the routines at PLAY_TUNE_ONCE, MENU, READ_CONTROLS and PAUSE.
Knight Lore's, Alien 8's and Pentagram's routine, byte for byte. IN A,($FE) puts A on the top half of the address bus, so each 0 bit in A selects a half-row, and two or more can be read at once; the CPL turns the active-low bits the right way up, so a key held is a 1, and Z is set when none of the five is held.
The OUT before it is not needed for the read. It writes A to port A*256+$FD, which nothing on a 48K Spectrum answers. A 128K machine's paging port would decode it whenever A has bit 7 clear, and READ_CONTROLS sends $7F with the keyboard and $7E with every method, every turn, as PAUSE does: in 128 mode that would page RAM 7 or 6 over the top 16K, where the game's code and tables are, show the other screen and lock the paging. Read, not tried on a 128K; Pentagram's identical routine was tried and reset the machine at the first turn of play.
Input
A The half-rows to read: a 0 bit for each
Output
A Bits 0-4 the keys held, 1 for held
F Z set if none is held
READ_KEYS E239 OUT ($FD),A The OUT that a 128K would take for paging (see above)
E23B IN A,($FE) Read the half-rows; held keys as 1s
E23D CPL
E23E AND $1F
E240 RET
Prev: E200 Up: Map Next: E241