Purpose: Scan the keyboard
Call address: $FF9F (hex) 65439 (decimal)
Preparation:
Registers: none Memory: system map Flags: none Calls: noneResults:
Registers: none Memory: keyboard buffer keyboard flags Flags: none
Description: SCNKEY is an Editor routine that scans the entire C128 keyboard
(except the 40/80 key). It distinguishes between ASCII keys, control keys, and programmable keys,
setting keyboard status bytes and managing the keyboard buffer. After decoding the key, SCNKEY will manage
such features as toggling cases, pauses or delays, and key repeats. It is normally called by the operating
system during the 60Hz IRQ processing. Upon conclusion, SCNKEY leaves the keyboard hardware driving the
keyline on which the STOP key is located.
There are two indirect RAM jumps encountered during a keyscan: KEYVEC ($33A) and KEYCHK ($33C).
KEYVEC (alias KEYLOG) is taken whenever a key depression is discovered, before the key in .A has
been decoded. KEYCHK is taken after the key has been decoded, just before putting it into the key buffer.
KEYCHK carries the ASCII character in .A, the keycode in .Y, and the skiftkey status in .X.
The keyboard decode matrices are addressed via indirect RAM vectors as well, located at DECODE ($33E).
The following table describes them:
$33E | Mode 1 | -> | normal keys | |
$340 | Mode 2 | -> | SHIFT keys | |
$342 | Mode 3 | -> | C= keys | |
$344 | Mode 4 | -> | CONTROL keys | |
$346 | Mode 5 | -> | CAPS LOCK keys | |
$348 | Mode 6 | -> | ALT keys |
ROWS | $DC01 | -> | I/O port outputting keys | |
COLM | $DC00 | -> | I/O port driving C64 keys | |
VIC #47 | $D02F | -> | I/O port driving new keys | |
8502 P6 | $0001 | -> | I/O port sensing CAPS key | |
NDX | $D0 | -> | keyboard buffer index | |
KEYD | $34A | -> | keyboard buffer | |
XMAX | $A20 | -> | keyboard buffer size | |
SHFLAG | $D3 | -> | shift key status | |
RPTFLG | $A22 | -> | repeat key enables | |
LOCKS | $F7 | -> | pause, mode disables |
JSR $FF9F ;scan the keyboard