5200H - Entry: the Banner and the SET Test
The SET library command, given the keyboard device KI and the file KI/DVR, loads KI/DVR at 5200H-573CH and jumps to 5200H with Register Pair DE pointing at the device control block of the device named (4015H, KIDCB$, for the keyboard device KI) and Register Pair HL at the rest of the command line. KI/DVR shows its banner and refuses to run unless SET ran it: SET sets bit 3 of 4758H.
5200
PUSH DE D5
Save Register Pair DE, the address of the device control block SET passes (4015H for the keyboard device KI), to the stack.
5201
PUSH HL E5
Save Register Pair HL, the pointer to the parameters on the command line, to the stack.
5202
LD HL,562DH 21 2D 56
Point Register Pair HL to 562DH, the banner: the name and version of the driver and the copyright, two lines ended by 0DH.
5205
GOSUB to 4467H, @DSPLY, to display the text at Register Pair HL (562DH) up to its 0DH.
5208
LD A,(4758H) 3A 58 47
Fetch the byte at 4758H into Register A: the status byte of the command interpreter, whose bit 3 the SET and FILTER commands set before they run a driver or a filter.
520B
BIT 3,A CB 5F
Test bit 3 of Register A (the byte from 4758H): set when SET runs the program.
520D
If the Z FLAG is set (bit 3 is clear: KI/DVR was run as a command), JUMP to 5613H to display Must be installed via: SET! and end at @ABORT.
5210H - The Parameters: DELAY and RATE
@PARAM stores each parameter given into the operand its table entry names (56FCH): TYPE into 5404H, JKL into 5548H, RATE into 522CH and DELAY into 521DH. DELAY (the ticks before the first repeat, at least 10, 20 in the file) and RATE (the ticks between repeats, at least 1, 2 in the file) are then put into the operands of the driver that use them. A tick is one count of TIMER$ (4040H), 40 a second.
5210
POP HL E1
Restore Register Pair HL from the stack: the pointer to the parameters.
5211
POP IX DD E1
Restore Index Register IX from the stack: the address of the device control block that Register Pair DE held at entry (4015H).
5213
LD DE,56FCH 11 FC 56
Point Register Pair DE to 56FCH, the table of the parameters: TYPE (T), JKL (J), RATE (R) and DELAY (D), each with the address of its operand.
5216
GOSUB to 4476H, @PARAM, to parse the parameters at Register Pair HL against the table at Register Pair DE (56FCH): a parameter given alone stores FFFFH, a parameter with =n stores n. The Z FLAG on success.
5219
If the NZ FLAG is set (a parameter @PARAM does not know, or a bad value), JUMP to 5628H to give error 2CH, Parameter error, and end at @ABORT.
521C
LD BC,0014H 01 14 00
Load Register Pair BC with the DELAY value: the operand 521DH-521EH, 0014H (20 ticks) in the file, or the value of DELAY=d stored by @PARAM.
521F
LD A,0AH 3E 0A
Load Register A with 0AH, 10 ticks, the least delay accepted.
5221
CP C B9
Compare Register A (10) against Register C, the low byte of the DELAY value: the NC FLAG when Register C is 10 or less.
5222
If the NC FLAG is set (DELAY 10 or less), JUMP to 5225H with Register A = 10.
5224
LD A,C 79
Copy Register C (the low byte of the DELAY value, above 10) into Register A.
5225
LD (52EAH),A 32 EA 52
Store Register A (the delay in ticks) at 52EAH, the operand of SUB 14H at 52E9H in the driver's repeat test.
5228
LD (53C4H),A 32 C4 53
Store Register A (the delay in ticks) at 53C4H, the operand of ADD A,14H at 53C3H, where the driver works out the tick of the first repeat of a new key.
522B
LD BC,0002H 01 02 00
Load Register Pair BC with the RATE value: the operand 522CH-522DH, 0002H (2 ticks) in the file, or the value of RATE=r stored by @PARAM.
522E
LD A,01H 3E 01
Load Register A with 01H, 1 tick, the least rate accepted.
5230
CP C B9
Compare Register A (1) against Register C, the low byte of the RATE value: the NC FLAG when Register C is 1 or less.
5231
If the NC FLAG is set (RATE 1 or less), JUMP to 5234H with Register A = 1.
5233
LD A,C 79
Copy Register C (the low byte of the RATE value, above 1) into Register A.
5234
LD (5353H),A 32 53 53
Store Register A (the rate in ticks) at 5353H, the operand of ADD A,02H at 5352H, where the driver works out the tick of the next repeat.
5237
LD (5512H),A 32 12 55
Store Register A (the rate in ticks) at 5512H, the operand of ADD A,02H at 5511H in the type ahead task's repeat test.
523A
LD (5519H),A 32 19 55
Store Register A (the rate in ticks) at 5519H, the operand of ADD A,02H at 5518H in the type ahead task.
523DH - Where the $KI Module Goes
The keyboard driver, the module $KI, is the 363 bytes 5298H-5402H. When an earlier SET put it into memory, 4DF8H holds the address of its first byte and the module's link word (+02H-+03H) the address of its last byte, and that place is used again. Otherwise HIGH$ (4049H) is lowered by 016BH and the module goes just above the new HIGH$; 4DF8H keeps its address. Its link word gets the address of its last byte, and the four absolute operands named by the table at 528CH are moved by the distance from the file to that place.
523D
LD BC,016BH 01 6B 01
Load Register Pair BC with 016BH, 363, the length of the module $KI (5298H-5402H).
5240
LD HL,(4DF8H) 2A F8 4D
Fetch the word at 4DF8H-4DF9H into Register Pair HL: the address of the $KI module put into memory by an earlier SET, or 0000H when there was none since the boot.
5243
PUSH HL E5
Save Register Pair HL (the address from 4DF8H) to the stack.
5244
INC HL 23
INCrement Register Pair HL by 1, to the module's +01H.
5245
INC HL 23
INCrement Register Pair HL by 1, to the module's +02H, the low byte of its link word.
5246
LD E,(HL) 5E
Fetch the byte at Register Pair HL (the module's +02H) into Register E.
5247
INC HL 23
INCrement Register Pair HL to the module's +03H.
5248
LD D,(HL) 56
Fetch the byte at Register Pair HL (the module's +03H) into Register D: Register Pair DE = the link word of the module in memory, the address of its last byte. With no module (Register Pair HL 0000H) these are ROM bytes and are not used.
5249
POP HL E1
Restore Register Pair HL from the stack: the address from 4DF8H.
524A
LD A,H 7C
Copy Register H (the high byte of the address) into Register A.
524B
OR L B5
OR Register L (the low byte of the address) into Register A: the Z FLAG when 4DF8H held 0000H.
524C
If the NZ FLAG is set (a module is in memory from an earlier SET), JUMP to 525DH to put the module there again, its last byte at Register Pair DE.
524E
LD HL,(4049H) 2A 49 40
Fetch the word at 4049H-404AH, HIGH$, the highest address free for programs, into Register Pair HL.
5251
LD E,L 5D
Copy Register L (the low byte of HIGH$) into Register E.
5252
LD D,H 54
Copy Register H into Register D: Register Pair DE = HIGH$, where the last byte of the module goes.
5253
XOR A AF
Clear Register A and the CARRY FLAG for the subtraction below.
5254
SBC HL,BC ED 42
SUBtract Register Pair BC (016BH, the length of the module) from Register Pair HL (HIGH$).
5256
LD (4049H),HL 22 49 40
Store Register Pair HL (HIGH$ less 016BH) at 4049H-404AH: the new HIGH$, just below the module.
5259
INC HL 23
INCrement Register Pair HL by 1: the address of the module's first byte.
525A
LD (4DF8H),HL 22 F8 4D
Store Register Pair HL (the module's first byte) at 4DF8H-4DF9H, for a later SET.
525D
LD (529AH),DE ED 53 9A 52
Store Register Pair DE (the address of the module's last byte in memory) at 529AH-529BH, the link word of the module's header.
5261
PUSH BC C5
Save Register Pair BC (016BH, the length) to the stack.
5262
PUSH DE D5
Save Register Pair DE (the address of the module's last byte) to the stack.
5263
LD IY,528CH FD 21 8C 52
Point Index Register IY to 528CH, the table of the operands of the module that hold absolute addresses.
5267
LD HL,5402H 21 02 54
Point Register Pair HL to 5402H, the module's last byte in the file.
526A
GOSUB to 55F5H to add the distance from Register Pair HL (5402H) to Register Pair DE (where that byte goes) to every word the table at Index Register IY (528CH) names.
526D
POP DE D1
Restore Register Pair DE from the stack: the address of the module's last byte.
526E
POP BC C1
Restore Register Pair BC from the stack: 016BH, the length.
526FH - Copy the Module and Make It the Keyboard Driver
Bit 4 of DFLAG$ (441FH) says that KI/DVR is in place; a second SET is refused. The module is copied, the device control block becomes an input device with the module as its driver, and the program goes on to the TYPE parameter.
526F
LD HL,441FH 21 1F 44
Point Register Pair HL to 441FH, DFLAG$, the device flags.
5272
BIT 4,(HL) CB 66
Test bit 4 of DFLAG$ at Register Pair HL (441FH): set while the KI/DVR driver is in place.
5274
If the NZ FLAG is set (the driver is already in place), JUMP to 561BH to display KI/dvr is already active! and end at @ABORT.
5277
SET 4,(HL) CB E6
Set bit 4 of DFLAG$ at Register Pair HL (441FH): the driver is in place.
5279
LD HL,5402H 21 02 54
Point Register Pair HL to 5402H, the module's last byte in the file.
527C
LDDR ED B8
Copy Register Pair BC (016BH) bytes from Register Pair HL (5402H) down to Register Pair DE (the module's last byte in memory) and below: the whole module 5298H-5402H. Afterwards Register Pair DE is one below the module's first byte and Register Pair BC is 0000H.
527E
DI F3
Disable interrupts while the device control block changes.
527F
LD (IX+00H),01H DD 36 00 01
Store 01H at +00H of the device control block at Index Register IX: the type byte, an input device.
5283
INC DE 13
INCrement Register Pair DE to the module's first byte in memory.
5284
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the module's first byte, the JR to its driver.
5285
GOSUB to 5484H to make Register Pair HL (the module) the driver of the device control block at Index Register IX, or, during a JCL job, the driver kept at KIJCL$ (43BEH).
5288
EI FB
Enable interrupts: the keyboard device has its new driver.
5289
JUMP to 5403H to see to the TYPE parameter, the type ahead module.
528CH - The Table of Absolute Operands
The words 55F5H changes when the module $KI goes into memory: each is the address of an operand that holds an address inside the module. 0000H ends the table.
528C-528D
DEFW 52DAH DA 52
528CH-528DH: 52DAH, the operand of JP P,52D0H at 52D9H, the loop over the keyboard rows.
528E-528F
DEFW 5342H 42 53
528EH-528FH: 5342H, the operand of LD HL,52A0H at 5341H, the table of the keys of row 6.
5290-5291
DEFW 53DFH DF 53
5290H-5291H: 53DFH, the operand of LD HL,52C0H at 53DEH, the table of the keys that CLEAR and SHIFT DOWN change.
5292-5293
DEFW 54F3H F3 54
5292H-5293H: 54F3H, the operand of LD HL,53BDH at 54F2H in the type ahead module: it points at the CALL 0060H of the $KI module, so it moves with $KI.
5294-5295
DEFW 0000H 00 00
5294H-5295H: 0000H, the end of the table (55FBH-5603H stop at it).
5296-5297
DEFB 00H, 00H 00 00
5296H-5297H: two bytes of 00H between the table and the module. No code of KI/DVR reads them and they are not copied.
5298H - The Module $KI: Header and Key Tables
The 363 bytes 5298H-5402H are copied into memory (526FH) and work there. Its header: a JR over the header and the tables to the driver, the link word (the address of the module's last byte), the length of the name and the name $KI. Then the tables of the keys of row 6 of the keyboard (ENTER, CLEAR, BREAK, the four arrows, SPACE), two bytes a key (without and with SHIFT), and the keys that CLEAR and SHIFT DOWN change.
5298
JUMP to 52C5H, the driver: the device control block names the module's first byte, and this JR (18H, the mark of a module header) passes over the header and the tables.
529A-529B
DEFW 0000H 00 00
529AH-529BH: the link word of the header, 0000H in the file: 525DH stores the address of the module's last byte in memory here before the copy.
529C
DEFB 03H 03
529CH: 03H, the length of the module's name, which follows it.
529D-529F
DEFM "$KI" 24 4B 49
529DH-529FH: the name of the module, $KI, by which a program can find it in the chain of modules above HIGH$.
52A0-52A1
DEFB 0DH, 1DH 0D 1D
52A0H-52A1H: the first table (bit 6 of KFLAG$ clear), ENTER: 0DH, with SHIFT 1DH.
52A2-52A3
DEFB 1FH, 1FH 1F 1F
52A2H-52A3H: CLEAR: 1FH, with SHIFT 1FH. The driver then sets bit 7 for CLEAR held (5372H): CLEAR alone gives no key, SHIFT CLEAR gives 1FH (53B2H).
52A4-52A5
DEFB 01H, 00H 01 00
52A4H-52A5H: BREAK: 01H, with SHIFT 00H. The driver passes 01H through 4BEFH, which gives 00H while BREAK is off.
52A6-52A7
DEFB 5BH, 1BH 5B 1B
52A6H-52A7H: the up arrow: 5BH, with SHIFT 1BH.
52A8-52A9
DEFB 0AH, 1AH 0A 1A
52A8H-52A9H: the down arrow: 0AH, with SHIFT 1AH. 1AH is given only when the Z key is down too (5362H-5367H): SHIFT DOWN alone gives no key.
52AA-52AB
DEFB 08H, 18H 08 18
52AAH-52ABH: the left arrow: 08H, with SHIFT 18H.
52AC-52AD
DEFB 09H, 19H 09 19
52ACH-52ADH: the right arrow: 09H, with SHIFT 19H.
52AE-52AF
DEFB 20H, 20H 20 20
52AEH-52AFH: SPACE: 20H, with SHIFT 20H (5394H-53AAH tell SHIFT SPACE from SHIFT 0).
52B0-52B1
DEFB 0DH, 1DH 0D 1D
52B0H-52B1H: the second table (bit 6 of KFLAG$ set, toggled by SHIFT CLEAR SPACE), ENTER: 0DH, with SHIFT 1DH.
52B2-52B3
DEFB 1FH, 1FH 1F 1F
52B2H-52B3H: CLEAR: 1FH, with SHIFT 1FH, as in the first table.
52B4-52B5
DEFB 01H, 00H 01 00
52B4H-52B5H: BREAK: 01H, with SHIFT 00H, as in the first table.
52B6-52B7
DEFB 82H, 92H 82 92
52B6H-52B7H: the up arrow in the second table: 82H, with SHIFT 92H.
52B8-52B9
DEFB 88H, 1AH 88 1A
52B8H-52B9H: the down arrow in the second table: 88H, with SHIFT 1AH as in the first.
52BA-52BB
DEFB 81H, 91H 81 91
52BAH-52BBH: the left arrow in the second table: 81H, with SHIFT 91H.
52BC-52BD
DEFB 84H, 94H 84 94
52BCH-52BDH: the right arrow in the second table: 84H, with SHIFT 94H.
52BE-52BF
DEFB 20H, 20H 20 20
52BEH-52BFH: SPACE in the second table: 20H, with SHIFT 20H.
52C0
DEFB 2CH 2C
52C0H: 2CH, the comma, the first key 53DDH-53F6H look for: with CLEAR 5BH, with CLEAR SHIFT 7BH, with SHIFT DOWN 1BH.
52C1
DEFB 2FH 2F
52C1H: 2FH, the slash: with CLEAR 5CH, with CLEAR SHIFT 7CH, with SHIFT DOWN 1CH.
52C2
DEFB 2EH 2E
52C2H: 2EH, the period: with CLEAR 5DH, with CLEAR SHIFT 7DH, with SHIFT DOWN 1DH.
52C3
DEFB 3BH 3B
52C3H: 3BH, the semicolon: with CLEAR 5EH, with CLEAR SHIFT 7EH, with SHIFT DOWN 1EH.
52C4
DEFB 0DH 0D
52C4H: 0DH, ENTER: with CLEAR 5FH, with CLEAR SHIFT 7FH; SHIFT DOWN looks only at the first four keys.
52C5H - The Driver: Find a Key That Went Down
The device control block names the module, so the ROM's keyboard routine (002BH) and every request to the keyboard device KI comes here with Index Register IX at the block (4015H). Register C holds the byte of a request: CARRY means a key is asked for. The driver compares the seven rows of the keyboard (3801H-3840H) with the picture of them at 4036H-403CH. A row that changed is stored, and the lowest key that went down becomes the new key. With no change, the key still held (+03H of the block) repeats when its tick (+04H) comes.
52C5
GOSUB to 4300H, @KITSK, the hook called on every key request: a RET unless a program put a JP there.
52C8
LD HL,4036H 21 36 40
Point Register Pair HL to 4036H, the picture of keyboard row 0 (4036H-403CH, rows 0-6), the state of the keys when the driver last looked.
52CB
LD BC,3801H 01 01 38
Load Register Pair BC with 3801H, the address of keyboard row 0: reading 3800H + a row bit (01H-40H) gives the keys of that row, bit set for a key down.
52CE
LD D,00H 16 00
Load Register D with 00H, the number of the row.
52D0
LD A,(BC) 0A
Fetch the keys of the row at Register Pair BC into Register A.
52D1
LD E,A 5F
Copy Register A (the keys of the row now) into Register E.
52D2
XOR (HL) AE
XOR Register A with the picture of the row at Register Pair HL: the bits of the keys that changed.
52D3
If the NZ FLAG is set (a key of the row went down or up), JUMP to 52EFH.
52D5
INC D 14
INCrement Register D, the number of the row, to the next row.
52D6
INC L 2C
INCrement Register L, to the picture of the next row (Register Pair HL 4037H-403CH).
52D7
RLC C CB 01
Rotate Register C (the row bit) left: the next row, 02H-40H, then 80H after row 6.
52D9
If the P FLAG is set (Register C below 80H: rows 0-6), JUMP back to 52D0H to look at the next row. The operand 52DAH is moved with the module (528CH).
52DC
LD A,(IX+03H) DD 7E 03
No key changed. Fetch +03H of the device control block at Index Register IX into Register A: the key last given and still held, 00H for none.
52DF
OR A B7
OR Register A with itself to set the flags: the Z FLAG for 00H.
52E0
RET Z C8
If the Z FLAG is set (no key held), RETURN with Register A = 00H and the Z FLAG: no key.
52E1
LD A,(4040H) 3A 40 40
Fetch TIMER$ at 4040H into Register A: the tick counter.
52E4
SUB (IX+04H) DD 96 04
SUBtract +04H of the device control block at Index Register IX, the tick of the next repeat, from Register A (TIMER$).
52E7
If the Z FLAG is set (the tick has come), JUMP to 534FH to give the key again.
52E9
SUB 14H D6 14
SUBtract the delay (the operand 52EAH, set at 5225H; 14H in the file) from Register A: the CARRY FLAG when the tick passed less than the delay ago.
52EB
If the CARRY FLAG is set (the tick passed a short time ago), JUMP to 534FH to give the key again.
52ED
XOR A AF
Clear Register A to 00H: no key, with the Z FLAG for the caller.
52EE
RET C9
RETURN with Register A = 00H and the Z FLAG: the tick of the repeat has not come.
52EF
LD (HL),E 73
Store Register E (the keys of the row now) into the picture of the row at Register Pair HL.
52F0
AND E A3
AND Register A (the keys that changed) with Register E (the keys down now): the keys that went down.
52F1
If the Z FLAG is set (keys only came up), JUMP to 5367H, whose JR Z,53B6H (the flags unchanged) clears the key held.
52F3
LD E,A 5F
Copy Register A (the keys that went down) into Register E.
52F4
LD A,D 7A
Copy Register D (the number of the row) into Register A.
52F5
RLCA 07
Rotate Register A (the row number) left: the row number x 2.
52F6
RLCA 07
Rotate Register A (the row number x 2) left: the row number x 4.
52F7
RLCA 07
Rotate Register A left: the row number x 8, the number of the row's first key.
52F8
LD D,A 57
Copy Register A (the number of the row's first key) into Register D.
52F9
LD C,01H 0E 01
Load Register C with 01H, the bit of the row's first key.
52FB
LD A,C 79
Copy Register C (the bit of the key being tested) into Register A.
52FC
AND E A3
AND Register A with Register E (the keys that went down).
52FD
If the NZ FLAG is set (this key went down), JUMP to 5318H with Register D = its number (row x 8 + bit).
52FF
INC D 14
INCrement Register D to the number of the next key of the row.
5300
RLC C CB 01
Rotate Register C (the bit) left, to the next key of the row.
5302
JUMP back to 52FBH to test the key of the row at the new bit.
5304H - The Code of the Key
Register D holds the number of the key, 00H-37H. Rows 0-3 give 40H-5FH (@ and the letters), rows 4-5 the digits and the signs, row 6 comes from the tables at 52A0H. SHIFT is bit 0 of 3880H. SHIFT DOWN with a letter gives a control code 00H-1FH.
5304
SUB 70H D6 70
SUBtract 70H from Register A (the number of the key + 40H, 60H or more): the NC FLAG for row 6 (keys 30H-37H), and Register A = the bit of the key.
5306
If the NC FLAG is set (row 6), JUMP to 5339H to take the code from the tables.
5308
ADD A,40H C6 40
ADD 40H to Register A: the number of the key + 10H, 30H-3FH for rows 4 and 5 (0-9, colon, semicolon, comma, minus, period, slash).
530A
CP 3CH FE 3C
Compare Register A (the code) against 3CH: the CARRY FLAG for 30H-3BH (0-9, colon, semicolon).
530C
If the CARRY FLAG is set (30H-3BH), JUMP to 5310H: the code is right.
530E
XOR 10H EE 10
XOR 10H into Register A: 3CH-3FH become 2CH-2FH, the comma, minus, period and slash.
5310
RRC B CB 08
Rotate Register B (the SHIFT row from 3880H) right: bit 0, SHIFT, into the CARRY FLAG.
5312
If the NC FLAG is set (no SHIFT), JUMP to 5357H with the code in Register A.
5314
XOR 10H EE 10
XOR 10H into Register A: the code with SHIFT (0 gives 20H, 1-9 give 21H-29H, colon 2AH, semicolon 2BH, comma 3CH, minus 3DH, period 3EH, slash 3FH).
5316
JUMP to 5357H with the code of the key with SHIFT in Register A.
5318
LD A,(3880H) 3A 80 38
Fetch the SHIFT row at 3880H into Register A: bit 0 SHIFT.
531B
LD B,A 47
Copy Register A (the SHIFT row) into Register B.
531C
LD A,D 7A
Copy Register D (the number of the key) into Register A.
531D
ADD A,40H C6 40
ADD 40H to Register A: 40H-5FH for rows 0-3 (@, A-Z), 60H and up for rows 4-6.
531F
CP 60H FE 60
Compare Register A against 60H: the NC FLAG for rows 4-6.
5321
If the NC FLAG is set (rows 4-6), JUMP to 5304H.
5323
RRC B CB 08
Rotate Register B (the SHIFT row) right: bit 0, SHIFT, into the CARRY FLAG.
5325
If the NC FLAG is set (no SHIFT), JUMP to 5357H with Register A = 40H-5FH.
5327
ADD A,20H C6 20
ADD 20H to Register A: 60H-7FH, the code with SHIFT.
5329
LD D,A 57
Copy Register A (the code with SHIFT) into Register D.
532A
LD A,(3840H) 3A 40 38
Fetch keyboard row 6 at 3840H into Register A: bit 4 the down arrow.
532D
AND 10H E6 10
Keep only bit 4 of Register A (AND 10H), the down arrow.
532F
If the Z FLAG is set (the down arrow is not held), JUMP to 5356H with the code from Register D.
5331
LD A,D 7A
Copy Register D (the code with SHIFT, 60H-7FH) into Register A.
5332
SUB 60H D6 60
SUBtract 60H from Register A: SHIFT DOWN with @ or a letter gives 00H-1FH, the control codes.
5334
If the NZ FLAG is set (01H-1FH), JUMP to 5357H with the control code in Register A.
5336
CP FFH FE FF
Compare Register A (00H, SHIFT DOWN @) against FFH: the NZ FLAG (and the CARRY FLAG), so that the caller sees a key 00H.
5338
RET C9
RETURN with Register A = 00H and the NZ FLAG: the key 00H.
5339
RRC B CB 08
Rotate Register B (the SHIFT row) right: bit 0, SHIFT, into the CARRY FLAG.
533B
ADC A,A 8F
ADD Register A to itself with the CARRY FLAG: Register A = the bit of the key x 2 + 1 with SHIFT, the place of the code in the table.
533C
LD HL,4423H 21 23 44
Point Register Pair HL to 4423H, KFLAG$, the keyboard flags.
533F
BIT 6,(HL) CB 76
Test bit 6 of KFLAG$ at Register Pair HL (4423H): set to use the second table of row 6.
5341
LD HL,52A0H 21 A0 52
Point Register Pair HL to 52A0H, the first table. LD does not change the flags; the operand 5342H is moved with the module (528CH).
5344
If the Z FLAG is set (bit 6 clear), JUMP to 5348H to use the first table.
5346
ADD A,10H C6 10
ADD 10H to Register A, the place in the second table (52B0H).
5348
LD C,A 4F
Copy Register A (the place in the table) into Register C.
5349
LD B,00H 06 00
Load Register B with 00H: Register Pair BC = the place in the table.
534B
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL (52A0H): the code's byte in the table.
534C
LD A,(HL) 7E
Fetch the code from the table at Register Pair HL into Register A.
534D
JUMP to 5357H with the code of the row 6 key in Register A.
534F
LD A,(4040H) 3A 40 40
The repeat: fetch TIMER$ at 4040H into Register A.
5352
ADD A,02H C6 02
ADD the rate (the operand 5353H, set at 5234H; 02H in the file) to Register A: the tick of the repeat after this one.
5354
JUMP to 53C5H to store it at +04H and give the key held again.
5356
LD A,D 7A
Copy Register D (the code with SHIFT, 60H-7FH) into Register A.
5357H - BREAK, CLEAR, the Case of a Letter, CAPS
The code in Register A is checked against the keys that change it: BREAK is passed only while BREAK is on, CLEAR held adds 80H to the code, a letter changes its case (lower case without SHIFT) unless CAPS (bit 5 of KFLAG$) is on, SHIFT 0 toggles CAPS, SHIFT CLEAR SPACE toggles bit 6 of KFLAG$, SHIFT CLEAR gives 1FH, CLEAR alone gives nothing.
5357
CP 01H FE 01
Compare Register A (the code) against 01H, the code of BREAK.
5359
If the Z FLAG is set (BREAK), GOSUB to 4BEFH, the request code 01H handler of SYS0/SYS: it returns Register A = 01H, or 00H while BREAK is off (4BF0H holds C8H, RET Z).
535C
LD BC,1A9FH 01 9F 1A
Load Register Pair BC with 1A9FH: Register B = 1AH, the number of letters; Register C = 9FH, the code of CLEAR held with CLEAR.
535F
LD HL,4039H 21 39 40
Point Register Pair HL to 4039H, the picture of keyboard row 3, whose bit 2 is the Z key.
5362
CP B B8
Compare Register A (the code) against Register B (1AH, SHIFT DOWN or control Z).
5363
If the NZ FLAG is set (not 1AH), JUMP to 5369H.
5365
BIT 2,(HL) CB 56
Test bit 2 of the picture at Register Pair HL (4039H): the Z key down.
5367
If the Z FLAG is set (1AH without the Z key: SHIFT DOWN alone), JUMP to 53B6H to give no key.
5369
LD L,3CH 2E 3C
Load Register L with 3CH: Register Pair HL = 403CH, the picture of keyboard row 6.
536B
BIT 1,(HL) CB 4E
Test bit 1 of the picture at Register Pair HL (403CH): the CLEAR key down.
536D
LD HL,3880H 21 80 38
Point Register Pair HL to 3880H, the SHIFT row. LD does not change the flags.
5370
If the Z FLAG is set (CLEAR is not held), JUMP to 5373H.
5372
OR L B5
OR Register L (80H) into Register A: with CLEAR held the code gets bit 7.
5373
LD D,A 57
Copy Register A (the code) into Register D, to be fetched back at 5379H.
5374
RES 5,A CB AF
Clear bit 5 of Register A: a lower case letter becomes upper case for the test below.
5376
SUB 41H D6 41
SUBtract 41H, the letter A, from Register A: 00H-19H for a letter.
5378
CP B B8
Compare Register A against Register B (1AH): the CARRY FLAG for a letter A-Z (with bit 7 clear).
5379
LD A,D 7A
Copy Register D (the code) back into Register A. LD does not change the flags.
537A
If the NC FLAG is set (not a letter), JUMP to 5389H.
537C
XOR 20H EE 20
XOR 20H into Register A: a letter changes its case, so a letter without SHIFT is lower case and with SHIFT upper case.
537E
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE keeps 3880H.
537F
LD HL,4423H 21 23 44
Point Register Pair HL to 4423H, KFLAG$, the keyboard flags.
5382
BIT 5,(HL) CB 6E
Test bit 5 of KFLAG$ at Register Pair HL (4423H): CAPS.
5384
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = 3880H again. EX does not change the flags.
5385
If the Z FLAG is set (CAPS off), JUMP to 5389H with the letter as it is.
5387
RES 5,A CB AF
Clear bit 5 of Register A: with CAPS on every letter is upper case.
5389
BIT 0,(HL) CB 46
Test bit 0 of the SHIFT row at Register Pair HL (3880H): SHIFT.
538B
If the NZ FLAG is set (SHIFT held), JUMP to 5391H.
538D
BIT 1,(HL) CB 4E
Test bit 1 of the SHIFT row at Register Pair HL (3880H).
538F
If the Z FLAG is set (neither bit 0 nor bit 1 of the SHIFT row), JUMP to 53B3H.
5391
CP C B9
Compare Register A (the code) against Register C (9FH, CLEAR held with CLEAR).
5392
If the Z FLAG is set (SHIFT CLEAR), JUMP to 53B2H to give 1FH.
5394
LD HL,403AH 21 3A 40
Point Register Pair HL to 403AH, the picture of keyboard row 4, whose bit 0 is the 0 key.
5397
CP A0H FE A0
Compare Register A (the code) against A0H: CLEAR with SHIFT 0 or SHIFT SPACE.
5399
If the NZ FLAG is set (not A0H), JUMP to 53A3H.
539B
BIT 0,(HL) CB 46
Test bit 0 of the picture at Register Pair HL (403AH): the 0 key down.
539D
If the NZ FLAG is set (CLEAR SHIFT 0), JUMP to 53B7H to give A0H.
539F
LD A,40H 3E 40
Load Register A with 40H, bit 6: CLEAR SHIFT SPACE toggles bit 6 of KFLAG$, the second table of row 6.
53A1
JUMP to 53ABH to toggle bit 6 of KFLAG$ with Register A (40H).
53A3
CP 20H FE 20
Compare Register A (the code) against 20H: SHIFT 0 or SHIFT SPACE.
53A5
If the NZ FLAG is set (another code), JUMP to 53B7H to give it.
53A7
BIT 0,(HL) CB 46
Test bit 0 of the picture at Register Pair HL (403AH): the 0 key down.
53A9
If the Z FLAG is set (SHIFT SPACE), JUMP to 53B7H to give 20H, a space.
53AB
LD HL,4423H 21 23 44
Point Register Pair HL to 4423H, KFLAG$. Register A holds 20H (SHIFT 0) or 40H (CLEAR SHIFT SPACE).
53AE
XOR (HL) AE
XOR the bit in Register A with KFLAG$ at Register Pair HL (4423H): bit 5, CAPS, or bit 6 changes.
53AF
LD (HL),A 77
Store Register A (the new KFLAG$) at Register Pair HL (4423H).
53B0
JUMP to 53B6H to give no key: the toggle is not a key.
53B2
XOR L AD
XOR Register L (80H; Register Pair HL = 3880H) into Register A: 9FH becomes 1FH.
53B3
CP C B9
Compare Register A (the code) against Register C (9FH): CLEAR alone.
53B4
If the NZ FLAG is set (another code), JUMP to 53B7H to give it.
53B6
XOR A AF
Clear Register A to 00H: no key, for SHIFT DOWN alone and the toggles.
53B7H - Store the Key, Wait, and Give It
The key (00H for none) is kept at +03H of the device control block for the repeat, the driver waits a moment for the contacts of the keys to settle, and the tick of the first repeat goes to +04H. A code of 80H or more (CLEAR), and a key with SHIFT DOWN, go through the table at 52C0H.
53B7
LD (IX+03H),A DD 77 03
Store Register A (the key, or 00H) at +03H of the device control block at Index Register IX: the key held, which repeats.
53BA
LD BC,0333H 01 33 03
Load Register Pair BC with 0333H, the count of the wait.
53BD
GOSUB to 0060H, the ROM's delay, which counts Register Pair BC down to zero (it changes Register A). The type ahead task stores 01H over this CALL (LD BC,0060H) while it calls the driver, so that it does not wait (54F2H).
53C0
LD A,(4040H) 3A 40 40
Fetch TIMER$ at 4040H into Register A, the tick counter.
53C3
ADD A,14H C6 14
ADD the delay (the operand 53C4H, set at 5228H; 14H in the file) to Register A: the tick of the first repeat.
53C5
LD (IX+04H),A DD 77 04
Store Register A (the tick of the next repeat) at +04H of the device control block at Index Register IX.
53C8
LD A,(IX+03H) DD 7E 03
Fetch +03H of the device control block at Index Register IX into Register A: the key.
53CB
OR A B7
OR Register A with itself to set the flags: the Z FLAG for 00H.
53CC
RET Z C8
If the Z FLAG is set (no key), RETURN with Register A = 00H and the Z FLAG.
53CD
LD HL,3840H 21 40 38
Point Register Pair HL to 3840H, keyboard row 6.
53D0
BIT 4,(HL) CB 66
Test bit 4 of the row at Register Pair HL (3840H): the down arrow.
53D2
If the Z FLAG is set (the down arrow is not held), JUMP to 53DBH.
53D4
LD L,80H 2E 80
Load Register L with 80H: Register Pair HL = 3880H, the SHIFT row.
53D6
BIT 0,(HL) CB 46
Test bit 0 of the row at Register Pair HL (3880H): SHIFT.
53D8
SCF 37
Set the CARRY FLAG, the mark of SHIFT DOWN for 53DDH. SCF does not change the Z FLAG.
53D9
If the NZ FLAG is set (SHIFT DOWN with the key), JUMP to 53DDH with the CARRY FLAG.
53DB
OR A B7
OR Register A (the key) with itself: the flags of the key, the NC FLAG, the M FLAG for 80H or more.
53DC
RET P F0
If the P FLAG is set (the key is below 80H), RETURN with the key in Register A and the NZ FLAG.
53DD
PUSH AF F5
Save Register Pair AF (the key and the CARRY FLAG: set for SHIFT DOWN, clear for a CLEAR code) to the stack.
53DE
LD HL,52C0H 21 C0 52
Point Register Pair HL to 52C0H, the five keys CLEAR and SHIFT DOWN change. The operand 53DFH is moved with the module (528CH).
53E1
RES 7,A CB BF
Clear bit 7 of Register A: the code without CLEAR.
53E3
LD B,05H 06 05
Load Register B with 05H, the number of keys in the table.
53E5
If the NC FLAG is set (a CLEAR code), JUMP to 53E8H to look at all five.
53E7
DEC B 05
DECrement Register B to 04H: SHIFT DOWN looks only at the first four (not ENTER).
53E8
LD C,5BH 0E 5B
Load Register C with 5BH, the code for the first key of the table with CLEAR.
53EA
CP (HL) BE
Compare Register A (the code) against the key of the table at Register Pair HL.
53EB
If the Z FLAG is set (the key without SHIFT), JUMP to 53FCH with its code in Register C.
53ED
XOR 10H EE 10
XOR 10H into Register A: the code of the key with SHIFT turns into the code without it (3CH to 2CH, 3FH to 2FH, 3EH to 2EH, 2BH to 3BH, 1DH to 0DH).
53EF
CP (HL) BE
Compare Register A against the key of the table at Register Pair HL.
53F0
If the Z FLAG is set (the key with SHIFT), JUMP to 53FAH.
53F2
XOR 10H EE 10
XOR 10H into Register A: the code as it was before 53EDH.
53F4
INC HL 23
INCrement Register Pair HL to the next key of the table.
53F5
INC C 0C
INCrement Register C to the code for the next key (5BH-5FH).
53F6
DECrement Register B and, while it is not zero, JUMP back to 53EAH to try the next key.
53F8
POP AF F1
Restore Register Pair AF from the stack: the key as it was, with its flags (the CARRY FLAG for SHIFT DOWN, the NZ FLAG).
53F9
RET C9
RETURN with the key in Register A and the flags restored at 53F8H.
53FA
SET 5,C CB E9
Set bit 5 of Register C: the code with SHIFT, 7BH-7FH.
53FC
POP AF F1
Restore Register Pair AF from the stack: the CARRY FLAG says SHIFT DOWN.
53FD
LD A,C 79
Copy Register C (5BH-5FH or 7BH-7FH) into Register A.
53FE
If the NC FLAG is set (a CLEAR code), JUMP to 53DBH to return Register A (5BH-5FH, 7BH-7FH) with the NZ FLAG.
5400
AND 1FH E6 1F
Keep only bits 4-0 of Register A (AND 1FH): SHIFT DOWN with the comma, slash, period or semicolon gives 1BH-1EH.
5402
RET C9
RETURN with the control code in Register A and the NZ FLAG. This is the last byte of the module.
5403H - TYPE: Install the Type Ahead Module
With TYPE given, the module $TA (5496H-5546H, 177 bytes) goes below a buffer of 256 bytes and its three control bytes, all at the top of free memory: when an earlier SET put them there, 4DF2H holds the address of their last byte and they are used again; otherwise HIGH$ is lowered by 01B4H and 4DF2H gets the old HIGH$. $TA becomes the driver of the keyboard device, in front of $KI, and its task is put into task slot 10, which runs on every tick. Bit 1 of DFLAG$ (441FH) says that type ahead is on.
5403
LD BC,0000H 01 00 00
Load Register Pair BC with the TYPE value: the operand 5404H-5405H, 0000H in the file, FFFFH when @PARAM found TYPE (or T).
5406
LD A,B 78
Copy Register B (the high byte of the TYPE value) into Register A.
5407
OR C B1
OR Register C (the low byte) into Register A: the Z FLAG when TYPE was not given.
5408
If the Z FLAG is set (no TYPE), JUMP to 5547H to see to the JKL parameter.
540B
LD HL,441FH 21 1F 44
Point Register Pair HL to 441FH, DFLAG$, the device flags.
540E
BIT 1,(HL) CB 4E
Test bit 1 of DFLAG$ at Register Pair HL (441FH): set while type ahead is on.
5410
If the NZ FLAG is set (type ahead is already on), JUMP to 561FH to display Type-ahead is already active! and end at @ABORT.
5413
SET 1,(HL) CB CE
Set bit 1 of DFLAG$ at Register Pair HL (441FH): type ahead on. The task of $TA does nothing while this bit is clear.
5415
LD HL,(4DF2H) 2A F2 4D
Fetch the word at 4DF2H-4DF3H into Register Pair HL: the top of the type ahead area from an earlier SET, or 0000H.
5418
LD A,H 7C
Copy Register H (the high byte) into Register A.
5419
OR L B5
OR Register L (the low byte) into Register A: the Z FLAG when 4DF2H held 0000H.
541A
PUSH AF F5
Save Register Pair AF (the Z FLAG: no earlier area) to the stack, for 5455H.
541B
If the NZ FLAG is set (an area from an earlier SET), JUMP to 5423H to use it again.
541D
LD HL,(4049H) 2A 49 40
Fetch HIGH$ at 4049H-404AH into Register Pair HL: the top of the new area.
5420
LD (4DF2H),HL 22 F2 4D
Store Register Pair HL (the top of the area) at 4DF2H-4DF3H, for a later SET.
5423
LD (5498H),HL 22 98 54
Store Register Pair HL (the top of the area, the buffer's last byte) at 5498H-5499H, the link word of the header of $TA.
5426
DEC H 25
DECrement Register H: Register Pair HL = the top less 100H, the control byte +02H, the place in the buffer of the next key to give.
5427
LD (HL),00H 36 00
Store 00H at +02H, the place of the next key to give, at Register Pair HL.
5429
DEC HL 2B
DECrement Register Pair HL to the control byte +01H, the place in the buffer of the next key to store.
542A
LD (HL),00H 36 00
Store 00H at +01H, the place of the next key to store, at Register Pair HL: the buffer is empty.
542C
DEC HL 2B
DECrement Register Pair HL to the control byte +00H, the busy flag.
542D
LD (HL),00H 36 00
Store 00H at +00H, the busy flag, at Register Pair HL: not busy.
542F
LD (54A4H),HL 22 A4 54
Store Register Pair HL (the control bytes, the top less 102H) at 54A4H, the operand of LD HL,0000H at 54A3H in the driver of $TA.
5432
LD (54E7H),HL 22 E7 54
Store Register Pair HL (the control bytes) at 54E7H, the operand of LD HL,0000H at 54E6H in the task of $TA.
5435
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE keeps the address of the control bytes.
5436
LD HL,(4016H) 2A 16 40
Fetch the driver address of KIDCB$ at 4016H-4017H into Register Pair HL: the first byte of the $KI module just installed.
5439
LD A,(430FH) 3A 0F 43
Fetch SFLAG$ at 430FH, the system flags, into Register A.
543C
BIT 5,A CB 6F
Test bit 5 of Register A (SFLAG$): set while a JCL job runs.
543E
If the Z FLAG is set (no JCL job), JUMP to 5443H with the driver from 4016H.
5440
LD HL,(43BEH) 2A BE 43
Fetch KIJCL$ at 43BEH-43BFH into Register Pair HL: during a JCL job the keyboard driver is kept there (5484H put $KI there).
5443
LD BC,002DH 01 2D 00
Load Register Pair BC with 002DH, the distance from the first byte of $KI to its driver code (52C5H less 5298H).
5446
ADD HL,BC 09
ADD Register Pair BC to Register Pair HL: the address of the driver code of $KI in memory.
5447
LD (54F9H),HL 22 F9 54
Store Register Pair HL (the driver code of $KI) at 54F9H, the operand of CALL 0000H at 54F8H in the task of $TA.
544A
LD (54D8H),HL 22 D8 54
Store Register Pair HL (the driver code of $KI) at 54D8H, the operand of CALL 0000H at 54D7H in the driver of $TA.
544D
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the control bytes.
544E
LD BC,00B1H 01 B1 00
Load Register Pair BC with 00B1H, 177, the length of the module $TA.
5451
DEC HL 2B
DECrement Register Pair HL: the byte below the control bytes, the last byte of $TA.
5452
XOR A AF
Clear Register A and the CARRY FLAG for the subtraction below.
5453
SBC HL,BC ED 42
SUBtract Register Pair BC (00B1H) from Register Pair HL: one below the first byte of $TA, the top less 01B4H.
5455
POP AF F1
Restore Register Pair AF from the stack: the Z FLAG when the area is new (541AH).
5456
If the NZ FLAG is set (an area used again), JUMP to 545BH and leave HIGH$ as it is.
5458
LD (4049H),HL 22 49 40
Store Register Pair HL (the top less 01B4H) at 4049H-404AH: the new HIGH$, below $TA.
545B
INC HL 23
INCrement Register Pair HL to the first byte of $TA in memory.
545C
PUSH HL E5
Save Register Pair HL (the first byte of $TA) to the stack.
545D
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the first byte of $TA.
545E
LD HL,5496H 21 96 54
Point Register Pair HL to 5496H, the first byte of $TA in the file.
5461
LDIR ED B0
Copy Register Pair BC (00B1H) bytes from Register Pair HL (5496H) to Register Pair DE: the module $TA goes into memory.
5463
DI F3
Disable interrupts while the device control block changes.
5464
LD (IX+00H),05H DD 36 00 05
Store 05H at +00H of the device control block at Index Register IX: the type byte, an input device (bit 0) that also takes control requests (bit 2), which $TA uses to empty its buffer.
5468
POP HL E1
Restore Register Pair HL from the stack: the first byte of $TA.
5469
PUSH HL E5
Save Register Pair HL (the first byte of $TA) to the stack again.
546A
GOSUB to 5484H to make Register Pair HL ($TA) the driver of the device control block at Index Register IX, or the driver kept at KIJCL$ during a JCL job.
546D
EI FB
Enable interrupts: the keyboard device now goes through $TA.
546E
POP HL E1
Restore Register Pair HL from the stack: the first byte of $TA.
546F
LD DE,0048H 11 48 00
Load Register Pair DE with 0048H, the distance from the first byte of $TA to its task block (54DEH in the file).
5472
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the task block of $TA in memory.
5473
LD D,H 54
Copy Register H (the high byte of the task block) into Register D.
5474
LD E,L 5D
Copy Register L into Register E: Register Pair DE = the task block.
5475
INC DE 13
INCrement Register Pair DE by 1, to the second byte of the block.
5476
INC DE 13
INCrement Register Pair DE by 1: the task routine, just after the block's word (54E0H in the file).
5477
LD (HL),E 73
Store Register E (the low byte of the task routine) at the block at Register Pair HL.
5478
INC HL 23
INCrement Register Pair HL to the high byte of the block's word.
5479
LD (HL),D 72
Store Register D (the high byte of the task routine) at Register Pair HL: the block's word is the address of the routine.
547A
DEC HL 2B
DECrement Register Pair HL back to the task block.
547B
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the task block.
547C
LD A,0AH 3E 0A
Load Register A with 0AH, task slot 10, one of the slots run on every tick (40 a second).
547E
GOSUB to 4410H, @ADTSK, to put the task block at Register Pair DE into slot Register A (10).
5481
JUMP to 5547H to see to the JKL parameter, the screen print module.
5484H - Make Register Pair HL the Keyboard Driver
Outside a JCL job the driver address goes to +01H-+02H of the device control block at Index Register IX. During a JCL job the keyboard device is driven by the job's reader, which keeps the keyboard driver it replaced at KIJCL$ (43BEH): the new driver goes there.
5484
LD A,(430FH) 3A 0F 43
Fetch SFLAG$ at 430FH, the system flags, into Register A.
5487
BIT 5,A CB 6F
Test bit 5 of Register A (SFLAG$): set while a JCL job runs.
5489
If the NZ FLAG is set (a JCL job), JUMP to 5492H.
548B
LD (IX+01H),L DD 75 01
Store Register L (the low byte of the new driver) at +01H of the device control block at Index Register IX.
548E
LD (IX+02H),H DD 74 02
Store Register H (the high byte of the new driver) at +02H of the device control block at Index Register IX.
5491
RET C9
RETURN to the caller with the device control block's driver set to Register Pair HL.
5492
LD (43BEH),HL 22 BE 43
Store Register Pair HL (the new driver) at 43BEH-43BFH, KIJCL$, the keyboard driver of a JCL job.
5495
RET C9
RETURN to the caller with KIJCL$ set to Register Pair HL.
5496H - The Module $TA: the Type Ahead Driver
The 177 bytes 5496H-5546H are copied into memory (5461H). Its header is the JR to its driver, the link word (the buffer's last byte), the length of the name and the name $TA. The driver takes the requests to the keyboard device. The control bytes below the buffer: +00H busy (FFH while the driver works on the buffer, so the task leaves it alone), +01H the place of the next key to store, +02H the place of the next key to give; the buffer from +03H holds two bytes a key, the code and the flags the $KI driver returned with it. A key request (CARRY) takes the next key from the buffer, or asks $KI when it is empty. A control request with Register C = 00H empties the buffer.
5496
JUMP to 549EH, the driver: the device control block names the module's first byte, and this JR (18H) passes over the header.
5498-5499
DEFW 0000H 00 00
5498H-5499H: the link word of the header, 0000H in the file: 5423H stores the address of the buffer's last byte here before the copy.
549A
DEFB 03H 03
549AH: 03H, the length of the module's name, which follows it.
549B-549D
DEFM "$TA" 24 54 41
549BH-549DH: the name of the module, $TA, by which a program can find it in the chain of modules above HIGH$.
549E
PUSH AF F5
Save Register Pair AF (the flags of the request: CARRY for a key request, Z for a byte sent, NZ and NC for a control request) to the stack.
549F
GOSUB to 4300H, @KITSK, the hook called on every key request: a RET unless a program put a JP there.
54A2
POP AF F1
Restore Register Pair AF from the stack: the flags of the request.
54A3
LD HL,0000H 21 00 00
Load Register Pair HL with the address of the control bytes: the operand 54A4H, set at 542FH (0000H in the file).
54A6
LD (HL),FFH 36 FF
Store FFH at +00H, the busy flag, at Register Pair HL: the task must not change the buffer now.
54A8
If the CARRY FLAG is set (a key request), JUMP to 54B0H.
54AA
If the Z FLAG is set (a byte sent to the keyboard device), JUMP to 54B0H as well.
54AC
LD A,C 79
Copy Register C (the code of the control request) into Register A.
54AD
OR A B7
OR Register A with itself to set the flags: the Z FLAG for control code 00H.
54AE
If the Z FLAG is set (control code 00H), JUMP to 551EH to empty the buffer.
54B0H - Give the Next Key
When the place of the next key to give (+02H) equals the place of the next key to store (+01H) the buffer is empty and the $KI driver is asked directly. Otherwise the code and the flags at that place are taken, +02H moves on by 2 (and wraps at 256), and bit 7 of KFLAG$ is cleared when the buffer is now empty. The busy flag is cleared on the way out.
54B0
PUSH HL E5
Save Register Pair HL (the control bytes, +00H) to the stack.
54B1
INC HL 23
INCrement Register Pair HL to +01H, the place of the next key to store.
54B2
LD A,(HL) 7E
Fetch +01H at Register Pair HL into Register A.
54B3
INC HL 23
INCrement Register Pair HL to +02H, the place of the next key to give.
54B4
CP (HL) BE
Compare Register A (+01H) against +02H at Register Pair HL: the Z FLAG when the buffer is empty.
54B5
If the Z FLAG is set (the buffer is empty), JUMP to 54D3H to ask $KI.
54B7
PUSH HL E5
Save Register Pair HL (+02H, the place of the next key to give) to the stack.
54B8
LD E,(HL) 5E
Fetch +02H at Register Pair HL into Register E: the place of the next key to give.
54B9
INC HL 23
INCrement Register Pair HL to +03H, the start of the buffer.
54BA
LD D,00H 16 00
Load Register D with 00H: Register Pair DE = the place in the buffer.
54BC
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the key's two bytes in the buffer.
54BD
LD B,(HL) 46
Fetch the code of the key at Register Pair HL into Register B.
54BE
INC HL 23
INCrement Register Pair HL to the key's second byte.
54BF
LD C,(HL) 4E
Fetch the flags of the key at Register Pair HL into Register C.
54C0
POP HL E1
Restore Register Pair HL from the stack: +02H.
54C1
INC (HL) 34
INCrement +02H, the place of the next key to give, at Register Pair HL by 1.
54C2
INC (HL) 34
INCrement +02H at Register Pair HL by 1 again: the place of the next key to give moves on by 2, 00H after FEH.
54C3
LD A,(HL) 7E
Fetch +02H at Register Pair HL (the new place) into Register A.
54C4
DEC HL 2B
DECrement Register Pair HL to +01H, the place of the next key to store.
54C5
CP (HL) BE
Compare Register A (+02H) against +01H at Register Pair HL: the Z FLAG when the buffer is now empty.
54C6
If the NZ FLAG is set (keys remain), JUMP to 54CDH.
54C8
LD HL,4423H 21 23 44
Point Register Pair HL to 4423H, KFLAG$, the keyboard flags.
54CB
RES 7,(HL) CB BE
Clear bit 7 of KFLAG$ at Register Pair HL (4423H): no keys wait in the type ahead buffer.
54CD
POP HL E1
Restore Register Pair HL from the stack: the control bytes, +00H.
54CE
LD (HL),00H 36 00
Store 00H at +00H, the busy flag, at Register Pair HL: the task may change the buffer again.
54D0
PUSH BC C5
Save Register Pair BC (Register B the code, Register C the flags) to the stack.
54D1
POP AF F1
Restore Register Pair AF from the stack: Register A = the code of the key, the flags as $KI returned them.
54D2
RET C9
RETURN with the key from the buffer in Register A and its flags.
54D3
LD IX,4015H DD 21 15 40
Point Index Register IX to 4015H, KIDCB$, the device control block whose +03H and +04H the $KI driver uses.
54D7
CALL 0000H CD 00 00
GOSUB to the driver code of $KI: the operand 54D8H, set at 544AH (0000H in the file). It returns the key in Register A, 00H with the Z FLAG for none.
54DA
POP HL E1
Restore Register Pair HL from the stack: the control bytes, +00H.
54DB
LD (HL),00H 36 00
Store 00H at +00H, the busy flag, at Register Pair HL.
54DD
RET C9
RETURN with the key from $KI in Register A and its flags.
54DEH - The Type Ahead Task
The task block is one word, the address of the routine just after it; 5477H sets it to the routine's address in memory and 547EH puts the block into task slot 10. On every tick (40 a second) the task, unless type ahead is off (bit 1 of DFLAG$) or the driver is busy, asks $KI for a key, without $KI's wait, and stores it in the buffer. CLEAR @ (C0H) empties the buffer. While keys wait, a repeat of the key held is not stored; a full buffer drops the key.
54DE-54DF
DEFW 54E0H E0 54
54DEH-54DFH: the task block: the address of the task routine, 54E0H in the file; 5477H-5479H store the routine's address in memory here.
54E0
LD A,(441FH) 3A 1F 44
Fetch DFLAG$ at 441FH into Register A, the device flags.
54E3
AND 02H E6 02
Keep only bit 1 of Register A (AND 02H): type ahead on.
54E5
RET Z C8
If the Z FLAG is set (type ahead off), RETURN to the task loop of the clock interrupt.
54E6
LD HL,0000H 21 00 00
Load Register Pair HL with the address of the control bytes: the operand 54E7H, set at 5432H (0000H in the file).
54E9
LD A,(HL) 7E
Fetch +00H, the busy flag, at Register Pair HL into Register A.
54EA
OR A B7
OR Register A with itself to set the flags: the NZ FLAG while the driver works on the buffer.
54EB
RET NZ C0
If the NZ FLAG is set (busy), RETURN to the task loop without a key.
54EC
INC HL 23
INCrement Register Pair HL to +01H, the place of the next key to store.
54ED
PUSH HL E5
Save Register Pair HL (+01H, the place of the next key to store) to the stack.
54EE
LD IX,4015H DD 21 15 40
Point Index Register IX to 4015H, KIDCB$, the device control block whose +03H and +04H the $KI driver uses.
54F2
LD HL,53BDH 21 BD 53
Load Register Pair HL with the address of the CALL 0060H of the $KI driver: the operand 54F3H, 53BDH in the file, moved with $KI (528CH).
54F5
LD (HL),01H 36 01
Store 01H at Register Pair HL: the CALL 0060H becomes LD BC,0060H, so the driver does not wait inside the interrupt.
54F7
PUSH HL E5
Save Register Pair HL (the CALL of $KI) to the stack.
54F8
CALL 0000H CD 00 00
GOSUB to the driver code of $KI: the operand 54F9H, set at 5447H (0000H in the file). It returns the key in Register A, 00H with the Z FLAG for none.
54FB
POP HL E1
Restore Register Pair HL from the stack: the CALL of $KI.
54FC
LD (HL),CDH 36 CD
Store CDH at Register Pair HL: the CALL 0060H of $KI is back.
54FE
POP HL E1
Restore Register Pair HL from the stack: +01H.
54FF
INC A 3C
INCrement Register A (the key): with the DEC below, this sets the Z FLAG for 00H and keeps the CARRY FLAG $KI returned.
5500
DEC A 3D
DECrement Register A back to the key: the Z FLAG for 00H.
5501
RET Z C8
If the Z FLAG is set (no key, or the key 00H), RETURN to the task loop.
5502
PUSH AF F5
Save Register Pair AF (the key and the flags of $KI) to the stack.
5503
POP BC C1
Restore Register Pair BC from the stack: Register B = the key, Register C = its flags.
5504
CP C0H FE C0
Compare Register A (the key) against C0H: CLEAR @.
5506
If the Z FLAG is set (CLEAR @), JUMP to 551FH to empty the buffer (Register Pair HL = +01H).
5508
LD E,(HL) 5E
Fetch +01H at Register Pair HL into Register E: the place of the next key to store.
5509
LD A,E 7B
Copy Register E (+01H, the place of the next key to store) into Register A.
550A
INC HL 23
INCrement Register Pair HL to +02H, the place of the next key to give.
550B
CP (HL) BE
Compare Register A (+01H) against +02H at Register Pair HL: the Z FLAG when the buffer is empty.
550C
If the Z FLAG is set (the buffer is empty), JUMP to 5535H to store the key.
550E
LD A,(4040H) 3A 40 40
Fetch TIMER$ at 4040H, the tick counter, into Register A.
5511
ADD A,02H C6 02
ADD the rate (the operand 5512H, set at 5237H; 02H in the file) to Register A: the tick $KI stores at +04H when it gives a repeat (534FH).
5513
CP (IX+04H) DD BE 04
Compare Register A against +04H of the device control block at Index Register IX: the Z FLAG when the key just given was a repeat.
5516
If the NZ FLAG is set (a key that went down), JUMP to 5530H to store it.
5518
ADD A,02H C6 02
ADD the rate (the operand 5519H, set at 523AH; 02H in the file) to Register A once more.
551A
LD (IX+04H),A DD 77 04
Store Register A at +04H of the device control block at Index Register IX: the next repeat comes one rate later. The repeat is not stored while keys wait.
551D
RET C9
RETURN to the task loop: the repeated key is not stored.
551E
INC HL 23
INCrement Register Pair HL from the control bytes (+00H) to +01H. The busy flag stays FFH until the next request (54CEH).
551F
LD (HL),02H 36 02
Store 02H at +01H at Register Pair HL: one key is in the buffer.
5521
INC HL 23
INCrement Register Pair HL to +02H, the place of the next key to give.
5522
LD (HL),00H 36 00
Store 00H at +02H at Register Pair HL: it is at the start of the buffer.
5524
INC HL 23
INCrement Register Pair HL to +03H, the first key of the buffer.
5525
LD (HL),00H 36 00
Store 00H, the code, at +03H at Register Pair HL.
5527
INC HL 23
INCrement Register Pair HL to +04H, the flags of the first key.
5528
LD (HL),40H 36 40
Store 40H, the Z FLAG, at +04H at Register Pair HL: the key left in the buffer reads as no key (00H with the Z FLAG).
552A
LD HL,4423H 21 23 44
Point Register Pair HL to 4423H, KFLAG$, the keyboard flags.
552D
RES 7,(HL) CB BE
Clear bit 7 of KFLAG$ at Register Pair HL (4423H): no keys wait.
552F
RET C9
RETURN to the caller (the driver's request, or the task loop).
5530
LD A,E 7B
Copy Register E (+01H, the place of the next key to store) into Register A.
5531
INC A 3C
INCrement Register A (the place of the next key to store) by 1.
5532
INC A 3C
INCrement Register A by 1 again: the place after the key to store.
5533
CP (HL) BE
Compare Register A against +02H at Register Pair HL: the Z FLAG when the buffer would be full.
5534
RET Z C8
If the Z FLAG is set (the buffer is full: 127 keys wait), RETURN and drop the key.
5535
PUSH HL E5
Save Register Pair HL (+02H, the place of the next key to give) to the stack.
5536
INC HL 23
INCrement Register Pair HL to +03H, the start of the buffer.
5537
LD D,00H 16 00
Load Register D with 00H: Register Pair DE = +01H, the place of the key to store.
5539
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the key's two bytes in the buffer.
553A
LD (HL),B 70
Store Register B (the code of the key) at Register Pair HL.
553B
INC HL 23
INCrement Register Pair HL to the key's second byte.
553C
LD (HL),C 71
Store Register C (the flags of the key) at Register Pair HL.
553D
LD HL,4423H 21 23 44
Point Register Pair HL to 4423H, KFLAG$, the keyboard flags.
5540
SET 7,(HL) CB FE
Set bit 7 of KFLAG$ at Register Pair HL (4423H): keys wait in the type ahead buffer.
5542
POP HL E1
Restore Register Pair HL from the stack: +02H.
5543
DEC HL 2B
DECrement Register Pair HL to +01H, the place of the next key to store.
5544
INC (HL) 34
INCrement +01H, the place of the next key to store, at Register Pair HL by 1.
5545
INC (HL) 34
INCrement +01H at Register Pair HL by 1 again: the place moves on by 2, 00H after FEH.
5546
RET C9
RETURN to the task loop. This is the last byte of $TA.
5547H - JKL: Install the Screen Print Module
With JKL given, the module $JKL (559FH-55F4H, 86 bytes) goes at the top of free memory: when an earlier SET put it there, 4DF4H holds the address of its last byte and that place is used again; otherwise HIGH$ is lowered by 56H and 4DF4H gets the old HIGH$. $JKL becomes the driver of the keyboard device in front of the driver it finds there ($TA or $KI), and the program ends at @EXIT. Bit 2 of DFLAG$ says that the screen print is on.
5547
LD BC,0000H 01 00 00
Load Register Pair BC with the JKL value: the operand 5548H-5549H, 0000H in the file, FFFFH when @PARAM found JKL (or J).
554A
LD A,B 78
Copy Register B (the high byte of the JKL value) into Register A.
554B
OR C B1
OR Register C (the low byte) into Register A: the Z FLAG when JKL was not given.
554C
If the Z FLAG is set (no JKL), JUMP to 559CH to end at @EXIT.
554F
LD HL,441FH 21 1F 44
Point Register Pair HL to 441FH, DFLAG$, the device flags.
5552
BIT 2,(HL) CB 56
Test bit 2 of DFLAG$ at Register Pair HL (441FH): set while the screen print module is on.
5554
If the NZ FLAG is set (it is already on), JUMP to 5617H to display JKL is already active! and end at @ABORT.
5557
SET 2,(HL) CB D6
Set bit 2 of DFLAG$ at Register Pair HL (441FH): the screen print module is on.
5559
LD DE,(4016H) ED 5B 16 40
Fetch the driver address of KIDCB$ at 4016H-4017H into Register Pair DE: the keyboard driver now ($TA or $KI).
555D
LD A,(430FH) 3A 0F 43
Fetch SFLAG$ at 430FH, the system flags, into Register A.
5560
BIT 5,A CB 6F
Test bit 5 of Register A (SFLAG$): set while a JCL job runs.
5562
If the Z FLAG is set (no JCL job), JUMP to 5568H with the driver from 4016H.
5564
LD DE,(43BEH) ED 5B BE 43
Fetch KIJCL$ at 43BEH-43BFH into Register Pair DE: the keyboard driver of a JCL job.
5568
LD (55A9H),DE ED 53 A9 55
Store Register Pair DE (the driver $JKL goes in front of) at 55A9H, the operand of CALL 0000H at 55A8H in $JKL.
556C
LD BC,0056H 01 56 00
Load Register Pair BC with 0056H, 86, the length of the module $JKL.
556F
LD HL,(4DF4H) 2A F4 4D
Fetch the word at 4DF4H-4DF5H into Register Pair HL: the address of the last byte of $JKL from an earlier SET, or 0000H.
5572
LD A,H 7C
Copy Register H (the high byte) into Register A.
5573
OR L B5
OR Register L (the low byte) into Register A: the Z FLAG when 4DF4H held 0000H.
5574
PUSH AF F5
Save Register Pair AF (the Z FLAG: no earlier place) to the stack, for 5583H.
5575
If the NZ FLAG is set (a place from an earlier SET), JUMP to 557DH to use it again.
5577
LD HL,(4049H) 2A 49 40
Fetch HIGH$ at 4049H-404AH into Register Pair HL: the last byte of the new place.
557A
LD (4DF4H),HL 22 F4 4D
Store Register Pair HL (the last byte of $JKL) at 4DF4H-4DF5H, for a later SET.
557D
LD (55A1H),HL 22 A1 55
Store Register Pair HL (the address of the last byte of $JKL) at 55A1H-55A2H, the link word of the header of $JKL.
5580
XOR A AF
Clear Register A and the CARRY FLAG for the subtraction below.
5581
SBC HL,BC ED 42
SUBtract Register Pair BC (0056H) from Register Pair HL: one below the first byte of $JKL.
5583
POP AF F1
Restore Register Pair AF from the stack: the Z FLAG when the place is new (5574H).
5584
If the NZ FLAG is set (a place used again), JUMP to 5589H and leave HIGH$ as it is.
5586
LD (4049H),HL 22 49 40
Store Register Pair HL (one below $JKL) at 4049H-404AH: the new HIGH$.
5589
INC HL 23
INCrement Register Pair HL to the first byte of $JKL in memory.
558A
PUSH HL E5
Save Register Pair HL (the first byte of $JKL) to the stack.
558B
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the first byte of $JKL.
558C
LD HL,0046H 21 46 00
Load Register Pair HL with 0046H, the distance from the first byte of $JKL to the byte at 55E5H.
558F
ADD HL,DE 19
ADD Register Pair DE to Register Pair HL: the address in memory of the byte at 55E5H.
5590
LD (55C1H),HL 22 C1 55
Store Register Pair HL (the address of the byte at 55E5H in memory) at 55C1H, the operand of LD (55E5H),A at 55C0H in $JKL.
5593
LD HL,559FH 21 9F 55
Point Register Pair HL to 559FH, the first byte of $JKL in the file.
5596
LDIR ED B0
Copy Register Pair BC (0056H) bytes from Register Pair HL (559FH) to Register Pair DE: the module $JKL goes into memory.
5598
POP HL E1
Restore Register Pair HL from the stack: the first byte of $JKL.
5599
GOSUB to 5484H to make Register Pair HL ($JKL) the driver of the device control block at Index Register IX, or the driver kept at KIJCL$ during a JCL job.
559C
JUMP to 402DH, @EXIT: KI/DVR is done and LDOS Ready comes back.
559FH - The Module $JKL: the Screen Print
The 86 bytes 559FH-55F4H are copied into memory (5596H). Every request to the keyboard device goes first to the driver $JKL found in place. The $KI driver returns a key with the CARRY FLAG only for SHIFT DOWN with a key that has no control code of its own, and for SHIFT DOWN @ (00H); for SHIFT DOWN with the asterisk (2AH) $JKL sends the 1024 characters of the screen (3C00H-3FFFH) to the printer through the ROM's printer routine (003BH), 0DH before each line of 64 and after the last, and gives no key. BREAK stops it. Characters 00H-1FH are sent as 40H-5FH; 80H and above (graphics) are sent as a period, or as they are when bit 7 of DFLAG$ (441FH) is set.
559F
JUMP to 55A8H, the driver: the device control block names the module's first byte, and this JR (18H) passes over the header.
55A1-55A2
DEFW 0000H 00 00
55A1H-55A2H: the link word of the header, 0000H in the file: 557DH stores the address of the module's last byte here before the copy.
55A3
DEFB 04H 04
55A3H: 04H, the length of the module's name, which follows it.
55A4-55A7
DEFM "$JKL" 24 4A 4B 4C
55A4H-55A7H: the name of the module, $JKL, by which a program can find it in the chain of modules above HIGH$.
55A8
CALL 0000H CD 00 00
GOSUB to the driver $JKL was put in front of: the operand 55A9H, set at 5568H (0000H in the file), with the flags and Register C of the request as they came.
55AB
RET NC D0
If the NC FLAG is set (no key with the CARRY FLAG), RETURN with the result of that driver.
55AC
PUSH AF F5
Save Register Pair AF (the key and its flags) to the stack.
55AD
CP 2AH FE 2A
Compare Register A (the key) against 2AH, the asterisk: SHIFT DOWN with the asterisk.
55AF
If the Z FLAG is set (the asterisk), JUMP to 55B3H to print the screen.
55B1
POP AF F1
Restore Register Pair AF from the stack: the key and its flags.
55B2
RET C9
RETURN with the key as the driver gave it: not the asterisk.
55B3
POP AF F1
Restore Register Pair AF from the stack, dropping the key.
55B4
PUSH BC C5
Save Register Pair BC to the stack, for the caller.
55B5
PUSH DE D5
Save Register Pair DE to the stack, for the caller.
55B6
LD A,(441FH) 3A 1F 44
Fetch DFLAG$ at 441FH into Register A, the device flags.
55B9
RLCA 07
Rotate Register A left: bit 7 of DFLAG$ into the CARRY FLAG, set to send graphics characters as they are.
55BA
LD A,3EH 3E 3E
Load Register A with 3EH, the opcode of LD A,n: 55E5H stays LD A,2EH, so graphics characters are sent as a period.
55BC
If the NC FLAG is set (bit 7 clear), JUMP to 55C0H with Register A = 3EH.
55BE
LD A,FEH 3E FE
Load Register A with FEH, the opcode of CP n: 55E5H becomes CP 2EH, which changes nothing, so graphics characters are sent as they are.
55C0
LD (55E5H),A 32 E5 55
Store Register A (3EH or FEH) at the byte 55E5H, the opcode of LD A,2EH. The operand 55C1H is set at 5590H to the address of that byte in memory.
55C3
LD HL,3C00H 21 00 3C
Point Register Pair HL to 3C00H, the first character of the screen.
55C6
LD A,(3840H) 3A 40 38
Fetch keyboard row 6 at 3840H into Register A: bit 2 BREAK.
55C9
AND 04H E6 04
Keep only bit 2 of Register A (AND 04H), BREAK.
55CB
If the NZ FLAG is set (BREAK held), JUMP to 55ECH to end the print with 0DH.
55CD
LD A,L 7D
Copy Register L (the low byte of the screen address) into Register A.
55CE
AND 3FH E6 3F
Keep only bits 5-0 of Register A (AND 3FH): the Z FLAG at the start of a line of 64 characters.
55D0
LD A,0DH 3E 0D
Load Register A with 0DH, the end of a line. LD does not change the flags.
55D2
If the Z FLAG is set (the start of a line), GOSUB to 003BH, the ROM's printer routine, to send 0DH in Register A to the printer.
55D5
BIT 6,H CB 74
Test bit 6 of Register H: set when Register Pair HL reaches 4000H, past the screen.
55D7
If the NZ FLAG is set (the whole screen is sent), JUMP to 55F1H.
55D9
LD A,(HL) 7E
Fetch the character of the screen at Register Pair HL into Register A.
55DA
INC HL 23
INCrement Register Pair HL to the next character of the screen.
55DB
CP 20H FE 20
Compare Register A (the character) against 20H, the space.
55DD
If the NC FLAG is set (20H or more), JUMP to 55E1H.
55DF
ADD A,40H C6 40
ADD 40H to Register A: a character 00H-1FH in the screen memory is sent as 40H-5FH.
55E1
CP 80H FE 80
Compare Register A (the character) against 80H, the first graphics character.
55E3
If the CARRY FLAG is set (below 80H), JUMP to 55E7H to send it.
55E5
LD A,2EH 3E 2E
Load Register A with 2EH, the period, for a graphics character. 55C0H stores the opcode here: 3EH (this LD) or FEH (CP 2EH, the character as it is).
55E7
GOSUB to 003BH, the ROM's printer routine, to send the character in Register A to the printer.
55EA
JUMP back to 55C6H for the next character of the screen.
55EC
LD A,0DH 3E 0D
Load Register A with 0DH, the end of a line, after BREAK.
55EE
GOSUB to 003BH, the ROM's printer routine, to send 0DH in Register A to the printer.
55F1
POP DE D1
Restore Register Pair DE from the stack, the caller's value.
55F2
POP BC C1
Restore Register Pair BC from the stack, the caller's value.
55F3
XOR A AF
Clear Register A to 00H with the Z FLAG and the NC FLAG: the asterisk gives no key.
55F4
RET C9
RETURN to the caller with no key. This is the last byte of $JKL.
55F5H - Move the Absolute Operands of a Module
Register Pair HL holds the address in the file of a module's last byte, Register Pair DE the address that byte will have in memory, Index Register IY the table of the operands to change (528CH). The distance is added to the word at each address of the table, until a word 0000H.
55F5
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the address in memory, Register Pair DE = the address in the file.
55F6
OR A B7
OR Register A with itself to clear the CARRY FLAG for the subtraction below.
55F7
SBC HL,DE ED 52
SUBtract Register Pair DE (the address in the file) from Register Pair HL (the address in memory): the distance.
55F9
LD B,H 44
Copy Register H (the high byte of the distance) into Register B.
55FA
LD C,L 4D
Copy Register L (the low byte of the distance) into Register C: Register Pair BC = the distance.
55FB
LD L,(IY+00H) FD 6E 00
Fetch +00H of the table at Index Register IY into Register L, the low byte of the address of an operand.
55FE
LD H,(IY+01H) FD 66 01
Fetch +01H of the table at Index Register IY into Register H: Register Pair HL = the address of the operand.
5601
LD A,L 7D
Copy Register L (the low byte of the address) into Register A.
5602
OR H B4
OR Register H (the high byte) into Register A: the Z FLAG at the word 0000H that ends the table.
5603
RET Z C8
If the Z FLAG is set (the end of the table), RETURN to the caller.
5604
LD E,(HL) 5E
Fetch the low byte of the operand at Register Pair HL into Register E.
5605
INC HL 23
INCrement Register Pair HL to the operand's high byte.
5606
LD D,(HL) 56
Fetch the high byte of the operand at Register Pair HL into Register D: Register Pair DE = the operand.
5607
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair HL = the operand, Register Pair DE = its address + 1.
5608
ADD HL,BC 09
ADD Register Pair BC (the distance) to Register Pair HL (the operand): the operand in memory.
5609
EX DE,HL EB
Exchange Register Pairs DE and HL: Register Pair DE = the new operand, Register Pair HL = its address + 1.
560A
LD (HL),D 72
Store Register D (the high byte of the new operand) at Register Pair HL.
560B
DEC HL 2B
DECrement Register Pair HL to the operand's low byte.
560C
LD (HL),E 73
Store Register E (the low byte of the new operand) at Register Pair HL.
560D
INC IY FD 23
INCrement Index Register IY by 1, toward the next word of the table.
560F
INC IY FD 23
INCrement Index Register IY by 1 again: the next word of the table. INC IY does not change the flags.
5611
If the NZ FLAG is set (always: the flags of 5602H), JUMP back to 55FBH for the next operand.
5613H - The Refusals
Four entries display a message through @LOGOT and end at @ABORT. Each entry is a LD HL with the message address; the entries before it run over its first byte, DDH, which turns the next LD HL into a LD IX that changes nothing the program uses. 5628H gives error 2CH, Parameter error.
5613
LD HL,5691H 21 91 56
Point Register Pair HL to 5691H, the message Must be installed via: SET! (5208H-520DH: KI/DVR was not run by SET).
5616
LD IX,56E5H DD 21 E5 56
Load Index Register IX with 56E5H: entered from 5613H, this only passes over the LD HL,56E5H that starts at 5617H, and Register Pair HL keeps its message. Entered at 5617H from 5554H (the screen print already on), the bytes 21H E5H 56H are LD HL,56E5H: Register Pair HL points to JKL is already active!.
561A
LD IX,56ADH DD 21 AD 56
Load Index Register IX with 56ADH: entered from above, this only passes over the LD HL,56ADH that starts at 561BH. Entered at 561BH from 5274H (the driver already in place), the bytes 21H ADH 56H are LD HL,56ADH: Register Pair HL points to KI/dvr is already active!.
561E
LD IX,56C7H DD 21 C7 56
Load Index Register IX with 56C7H: entered from above, this only passes over the LD HL,56C7H that starts at 561FH. Entered at 561FH from 5410H (type ahead already on), the bytes 21H C7H 56H are LD HL,56C7H: Register Pair HL points to Type-ahead is already active!.
5622
GOSUB to 447BH, @LOGOT, to display the message at Register Pair HL and write it to the job log.
5625
JUMP to 4030H, @ABORT: the program ends with an error. Whatever this run already put in place stays.
5628
LD A,6CH 3E 6C
Load Register A with 6CH: error 2CH, Parameter error, with bit 6 set for the short message and bit 7 clear, so @ERROR does not come back.
562A
GOSUB to 4409H, @ERROR, to display the message of the error in Register A; with bit 7 clear it ends the program at @ABORT.
562DH - The Texts and the Table of the Parameters
The banner, the four messages, each ended by 0DH, and the table @PARAM reads (5216H): for each parameter its name in 6 bytes, padded with spaces, and the address of the operand that takes its value; the one letter form of each name points at the same operand. 00H ends the table.
562D-565C
DEFM "KI - LDOS Keyboard Input Driver - Version 5.3.1 " 4B 49 20 2D 20 4C 44 4F 53 20 4B 65 79 62 6F 61 72 64 20 49 6E 70 75 74 20 44 72 69 76 65 72 20 2D 20 56 65 72 73 69 6F 6E 20 35 2E 33 2E 31 20
562DH-565CH: the first line of the banner, displayed by @DSPLY from 5205H: the name and the version of the driver, with a space at its end.
565D
DEFB 0AH 0A
565DH: 0AH, a line feed: the copyright goes on the next line within the same text.
565E-568E
DEFM "Copyright 1991 MISOSYS, Inc., All rights reserved" 43 6F 70 79 72 69 67 68 74 20 31 39 39 31 20 4D 49 53 4F 53 59 53 2C 20 49 6E 63 2E 2C 20 41 6C 6C 20 72 69 67 68 74 73 20 72 65 73 65 72 76 65 64
565EH-568EH: the second line of the banner, the copyright of the driver.
568F-5690
DEFB 0AH, 0DH 0A 0D
568FH-5690H: a line feed, then 0DH, the end of the banner: a blank line follows it on the screen.
5691-56AC
DEFM "Must be installed via: SET!" / DEFB 0DH 4D 75 73 74 20 62 65 20 69 6E 73 74 61 6C 6C 65 64 20 76 69 61 3A 20 53 45 54 21 0D
5691H-56ACH: the message of 5613H, for KI/DVR run as a command, ended by 0DH at 56ACH.
56AD-56C6
DEFM "KI/dvr is already active!" / DEFB 0DH 4B 49 2F 64 76 72 20 69 73 20 61 6C 72 65 61 64 79 20 61 63 74 69 76 65 21 0D
56ADH-56C6H: the message of 561BH, for a second SET while the driver is in place (bit 4 of DFLAG$), ended by 0DH at 56C6H.
56C7-56E4
DEFM "Type-ahead is already active!" / DEFB 0DH 54 79 70 65 2D 61 68 65 61 64 20 69 73 20 61 6C 72 65 61 64 79 20 61 63 74 69 76 65 21 0D
56C7H-56E4H: the message of 561FH, for TYPE while type ahead is on (bit 1 of DFLAG$), ended by 0DH at 56E4H.
56E5-56FB
DEFM "JKL is already active!" / DEFB 0DH 4A 4B 4C 20 69 73 20 61 6C 72 65 61 64 79 20 61 63 74 69 76 65 21 0D
56E5H-56FBH: the message of 5617H, for JKL while the screen print is on (bit 2 of DFLAG$), ended by 0DH at 56FBH.
56FC-5703
DEFM "TYPE " / DEFW 5404H 54 59 50 45 20 20 04 54
56FCH-5703H: the parameter TYPE, whose value goes to 5404H, the operand of LD BC,0000H at 5403H.
5704-570B
DEFM "T " / DEFW 5404H 54 20 20 20 20 20 04 54
5704H-570BH: the parameter T, the short form of TYPE, whose value goes to 5404H as well.
570C-5713
DEFM "JKL " / DEFW 5548H 4A 4B 4C 20 20 20 48 55
570CH-5713H: the parameter JKL, whose value goes to 5548H, the operand of LD BC,0000H at 5547H.
5714-571B
DEFM "J " / DEFW 5548H 4A 20 20 20 20 20 48 55
5714H-571BH: the parameter J, the short form of JKL, whose value goes to 5548H as well.
571C-5723
DEFM "RATE " / DEFW 522CH 52 41 54 45 20 20 2C 52
571CH-5723H: the parameter RATE, whose value goes to 522CH, the operand of LD BC,0002H at 522BH.
5724-572B
DEFM "R " / DEFW 522CH 52 20 20 20 20 20 2C 52
5724H-572BH: the parameter R, the short form of RATE, whose value goes to 522CH as well.
572C-5733
DEFM "DELAY " / DEFW 521DH 44 45 4C 41 59 20 1D 52
572CH-5733H: the parameter DELAY, whose value goes to 521DH, the operand of LD BC,0014H at 521CH.
5734-573B
DEFM "D " / DEFW 521DH 44 20 20 20 20 20 1D 52
5734H-573BH: the parameter D, the short form of DELAY, whose value goes to 521DH as well.
573C
DEFB 00H 00
573CH: 00H, the end of the table of the parameters, the last byte of the file.