Prev: B938 Up: Map Next: B95A
B952: Read a half-row of the keyboard
Used by the routines at PAUSE, MENU, READ_CONTROLS and PLAY_TUNE_ONCE.
Knight Lore's routine, byte for byte. The IN does the selecting on its own: IN A,($FE) puts A on the top half of the address bus, so each 0 bit in A selects a half-row. The CPL turns the keys' active-low bits the right way up.
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 the first such write comes as soon as the keyboard is read: $7F from the keyboard read in READ_CONTROLS (RAM page 7), or $7E from a joystick's (READ_BOTTOM_ROW) and from PAUSE every turn (page 6). In 128 mode that would put another RAM page at the top 16K, where much of the game lives, show the other screen and lock the paging. Tried on the emulator's 128K, from a 128K snapshot: at the first turn of play $7F went to the paging port, bank 7 appeared at the top, the paging locked, and the machine reset (the menu tune's key test had already paged the editor ROM in).
Input
A the half-rows to read, as the port's high byte
Output
A the keys pressed, bits 0-4, a set bit for a key down
READ_KEYS B952 OUT ($FD),A
B954 IN A,($FE)
B956 CPL
B957 AND $1F
B959 RET
Prev: B938 Up: Map Next: B95A