Prev: FF0C Up: Map Next: FF95
FF2C: Waits for a fresh single keypress, rejecting ambiguous or empty scans
Services sound each poll via run_title_tune and scans via scan_keyboard_matrix, rejecting and retrying if the scan is an ambiguous multi-row press (NZ from scan_keyboard_matrix) or "no key held" (D still $FF).
Duplicate check ($FF3D-$FF48): compares the new key code against the C-1 entries already stored at $FFF7 (C is the 1-based control index from the caller); a match rejects and loops back to re-scan.
Store ($FF4C-$FF52): the new key code is written to $FFF6+C (i.e. $FFF7 for control 1, ... $FFFE for control 8) -- the growing list used by the duplicate check above and read back by FEE2-$FEF1.
Name lookup ($FF53-$FF68): the scan-matrix key code (bits 0-2 = column/bit-within-row 0-4, bits 3+ = row 0-7, from scan_keyboard_matrix) is unpacked into row and bit, then re-combined as index = 5*bit + row (a column-major layout, not row-major) to index the 2-bytes/entry name table at FF95. Print ($FF6D-$FF7F): the looked-up entry's two characters are copied into a 2-character scratch buffer at $FD97-$FD9B alongside the caller's screen address (DE), with bit 7 forced on the second (the string terminator consumed by print_character's own BIT 7 test -- see FF95: usually a space, but a real second letter for the spelled-out SYMBOL SHIFT/SPACE/ENTER/CAPS SHIFT codes), then print_character prints it. Column advance ($FF82-$FF94): restores the caller's screen address and steps it on by $20 (one label column); on overflow (E wraps past $FF) also bumps D by 8 to drop down a pixel row. The same step is applied unconditionally once more when the caller's remaining loop count B is exactly 4 (FF87-$FF8A) -- the extra step that wraps from the first row of 4 control labels to the second row of 4. Used by the routine at redefine_keys_screen.
read_new_key_definition FF2C PUSH DE
FF2D PUSH BC
read_new_key_definition_0 FF2E CALL run_title_tune
FF31 CALL scan_keyboard_matrix
FF34 JR NZ,read_new_key_definition_0
FF36 INC D
FF37 JR Z,read_new_key_definition_0
FF39 DEC D
FF3A LD A,D
FF3B POP BC
FF3C PUSH BC
FF3D LD HL,$FFF7
FF40 LD B,C
FF41 DEC B
FF42 JR Z,read_new_key_definition_2
read_new_key_definition_1 FF44 CP (HL)
FF45 JR Z,read_new_key_definition_0
FF47 INC HL
FF48 DJNZ read_new_key_definition_1
read_new_key_definition_2 FF4A POP BC
FF4B PUSH BC
FF4C LD HL,$FFF6
FF4F LD B,$00
FF51 ADD HL,BC
FF52 LD (HL),A
FF53 LD HL,$FF95
FF56 LD D,$00
FF58 LD B,A
FF59 AND $07
FF5B LD C,A
FF5C ADD A,A
FF5D ADD A,A
FF5E ADD A,C
FF5F SRL B
FF61 SRL B
FF63 SRL B
FF65 ADD A,B
FF66 ADD A,A
FF67 LD E,A
FF68 ADD HL,DE
FF69 POP BC
FF6A POP DE
FF6B PUSH BC
FF6C PUSH DE
FF6D LD ($FD98),DE
FF71 LD A,(HL)
FF72 LD ($FD9A),A
FF75 INC HL
FF76 LD A,(HL)
FF77 SET 7,A
FF79 LD ($FD9B),A
FF7C LD HL,$FD97
FF7F CALL print_character
FF82 POP DE
FF83 CALL advance_key_label_column
FF86 POP BC
FF87 LD A,B
FF88 CP $04
FF8A RET NZ
advance_key_label_column FF8B LD A,E
FF8C ADD A,$20
FF8E LD E,A
FF8F RET NC
FF90 LD A,D
FF91 ADD A,$08
FF93 LD D,A
FF94 RET
Prev: FF0C Up: Map Next: FF95