The Key Manager


&BB00KM INITIALISE
ActionInitialises the Key Manager and sets up everything as it is when the computer is first switched on; the key buffer is emptied, Shift and Caps lock are tumed off amd all the expansion and translation tables are reset to normal; also see the routine KM RESET below
EntryNo entry conditions
ExitAF, BC, DE and HL corrupt, and all other registers are preserved
&BB03KM RESET
ActionResets the Key Manager; the key buffer is emptied and all current keys/characters are ignored
EntryNo entry conditions
ExitAF, BC, DE and HL are corrupt and all other registers are preserved
NotesSee also KM INITIALISE above. On the 664 or 6128, the key buffer can also be cleared separately by calling the KM FLUSH routine
&BB06KM WAIT CHAR
ActionWaits for the next character from the keyboard buffer
EntryNo entry conditions
ExitCarry is true, A holds the character value, the other flags are corrupt, and all other registers are preserved
&BB09KM READ CHAR
ActionTests to see if a character is available from the keyboard buffer, but doesn't wait for one to become available
EntryNo entry conditions
ExitIf a character was available, then Carry is true, and A contains the character; otherwise Carry is false, and A is corrupt; in both cases, the other registers are preserved
&BB0CKM CHAR RETURN
ActionSaves a character for the next use of KM WAIT CHAR or KM READ CHAR
EntryA contains the ASCII code of the character to be put back
ExitAll registers are preserved
&BB0FKM SET EXPAND
ActionAssigns a string to a key code
EntryB holds the key code; C holds the length of the string; HL contains the address of the string (must be in RAM)
ExitIf it is OK, then Carry is true; otherwise Carry is false; in either case, A, BC, DE and HL are corrupt, and all other registers rlre preserved
&BB12KM GET EXPAND
ActionReads a character from an expanded string of characters
EntryA holds an expansion token (ie a key code) and L holds the character position number (starts from 0)
ExitIf it is OK, then Carry is true, and A holds the character; otherwise Carry is false, and A is corrupt; in either case, DE and flags are corrupt, and the other registers are preserved
&BB15KM EXP BUFFER
ActionSets aside a buffer area for character expansion strings
EntryDE holds the address of the buffer and HL holds the length of the buffer
ExitIf it is OK, then Carry is true; otherwise Carry is false; in either case, A, BC, DE and HL are corrupt
NotesThe buffer must be in the central 32K of RAM and must be at least 49 bytes long
&BB18KM WAIT KEY
ActionWaits for a key to be pressed - this routine does not expand any expansion tokens
EntryNo entry conditions
ExitCarry is true, A holds the character or expansion token, and all other registers are preserved
&BB1BKM READ KEY
ActionTests whether a key is available from the keyboard
EntryNo entry conditions
ExitIf a key is available, then Carry is true, and A contains the character; otherwise Carry is false, and A is corrupt; in either case, the other registers are preserved
NotesAny expansion tokens are not expanded
&BB1EKM TEST KEY
ActionTests if a particular key (or joystick direction or button) is pressed
EntryA contains the key/joystick nurnber
ExitIf the requested key is pressed, then Zero is false; otherwise Zero is true for both, Carry is false A and HL are corrupt. C holds the Sbift and Control status and others are preserved
NotesAfter calling this, C will hold the state of shift and control - if bit 7 is set then Control was pressed, and if bit 5 is set then Shift was pressed
&BB21KM GET STATE
ActionGets the state of the Shift and Caps locks
EntryNo entry conditions
ExitIf L holds &FF then the shift lock is on, but if L holds &00 then the Shift lock is off; if H holds &FF then the caps lock is on, and if H holds &00 then the Caps lock is off; whatever the outcome, all the other registers are preserved
&BB24KM GET JOYSTICK
ActionReads the present state of any joysticks attached
EntryNo entry conditions
ExitH and A contains the state of joystick 0, L holds that state of joystick 1, and all others are preserved
NotesThe joystick states are bit significant and are as follows
Bit 0 - Up Bit
1 - Down Bit
2 - Left Bit
3 - Right Bit
4 - Fire2 Bit
5 - Fire1 Bit
6 - Spare Bit
7 - Always zero
The bits are set when the corresponding buttons or directions are operated
&BB27KM SET TRANSLATE
ActionSets the token or character that is assigned to a key when neither Shift nor Control are pressed
EntryA contains the key number and B contains the new token or character
ExitAF and HL are corrupt, and all other registers are preserved
NotesSpecial values for B are as follows
&80 to &9F - these values correspond to the expansion tokens
&FD - this causes the caps lock to toggle on and off
&FE - this causes the shift lock to toggle on and off
&FF - causes this key to be ignored
&BB2AKM GET TRANSLATE
ActionFinds out what token or character will be assigned to a key when neither Shift nor Control are pressed
EntryA contains the key number
ExitA contains the token/character that is assigned, HL and flags are corrupt, and all others are preserved
NotesSee KM SET TRANSLATE for special values that can be returned
&BB2DKM SET SHIFT
ActionSets the token or character that will be assigned to a key when Shift is pressed as well
EntryA contains the key number and B contains the new token or character
ExitAF and HL are corrupt, and all others are preserved
NotesSee KM SET TRANSLATE for special values that can be set
&BB30KM GET SHIFT
ActionFinds out what token/character will be assigned to a key when Shift is pressed as well
EntryA contains the key number
ExitA contains the token/character that is assigned, HL and flags are corrupt, and all others are preserved
NotesSee KM SET TRANSLATE for special values that can be returned
&BB33KM SET CONTROL
ActionSets the token or character that will be assigned to a key when Control is pressed as well
EntryA contains the key number and B contains the new token/character
ExitAF and HL are corrupt, and all others are preserved
NotesSee KM SET TRANSLATE for special values that can be set
&BB36KM GET CONTROL
ActionFinds out what token or character will be assigned to a key when Control is pressed as well
EntryA contains the key number
ExitA contains the token/character that is assigned, HL and flags are corrupt and all others are preserved
NotesSee KM SET TRANSLATE for special values that can be set
&BB39KM SET REPEAT
ActionSets whether a key may repeat or not
EntryA contains the key number B contains &00 if there is no repeat and &FF is it is to repeat
ExitAF, BC and HL are corrupt, and all others are preserved
&BB3CKM GET REPEAT
ActionFinds out whether a key is set to repeat or not
EntryA contains a key number
ExitIf the key repeats, then Zero is false; if the key does not repeat, then Zero is true; in either case, A, HL and flags are corrupt, Carry is false, and all other registers are preserved
&BB3FKM SET DELAY
ActionSets the time that elapses before the first repeat, and also set the repeat speed
EntryH contains the time before the first repeat, and L holds the time between repeats (repeat speed)
ExitAF is corrupt, and all others are preserved
NotesThe values for the times are given in 1/5Oth seconds, and a value of 0 counts as 256
&BB42KM GET DELAY
ActionFinds out the time that elapses before the first repeat and also the repeat speed
EntryNo entry conditions
ExitH contains the time before the first repeat, and L holds the time between repeats, and all others are preserved
&BB45KM ARM BREAK
ActionArms the Break mechanism
EntryDE holds the address of the Break handling routine, C holds the ROM select address for this routine
ExitAF, BC, DE and HL are corrupt, and all the other registers are preserved
&BB48KM DISARM BREAK
ActionDisables the Break mechanism
EntryNo entry conditions
ExitAF and HL are corrupt, and all the other registers are preserved
&BB4BKM BREAK EVENT
ActionGenerates a Break interrupt if a Break routine has been specified by KM ARM BREAK
EntryNo entry conditions
ExitAF and HL are corrupt, and all other registers are preserved


David Cantrell, March 1996