Routines |
Prev: 63691 | Up: Map | Next: 63969 |
Used by the routine at 37764.
|
||||||||||||||||
63740 | CALL 63691 | Print current control keys to screen | ||||||||||||||
63743 | CALL 63668 | If key-press was enqueued then load A with index of last key pressed, otherwise wait for key-press and load A with index | ||||||||||||||
63746 | CP 13 | If key pressed was 13 (ENTER)... | ||||||||||||||
63748 | RET Z | ...then return | ||||||||||||||
63749 | LD (63669),A | Set enqueued key index to index of key pressed | ||||||||||||||
63752 | LD B,5 | Load B with 5 (as there are five controls) | ||||||||||||||
63754 | LD HL,63986 | Point HL at start of list of current keyboard control characters | ||||||||||||||
63757 | LD (HL),0 | Set current keyboard control character to zero | ||||||||||||||
63759 | INC HL | Advance to next keyboard control character | ||||||||||||||
63760 | DJNZ 63757 | Decrease B (remaining number of keyboard control characters to clear) and loop back to 63757 if not zero | ||||||||||||||
63762 | LD BC,1280 | Load B with 5 and C with zero | ||||||||||||||
63765 | LD HL,63986 | Point HL at start of list of current keyboard control characters | ||||||||||||||
63768 | PUSH BC | Store BC (B = remaining number of controls to define, C = number of controls defined) | ||||||||||||||
63769 | PUSH HL | Store HL (current position in list of keyboard control characters) | ||||||||||||||
63770 | LD A,C | Load number of controls defined (0, 1, 2, 3 or 4) into A | ||||||||||||||
63771 | AND 6 | Reset all but bits 1 and 2 (to give 0, 2 or 4) | ||||||||||||||
63773 | ADD A,14 | Add 14 (to give 14, 16 or 18, the y-coordinates in characters of displayed keyboard controls)... | ||||||||||||||
63775 | LD B,A | ...and load into B | ||||||||||||||
63776 | LD A,C | Load A with number of controls defined (0, 1, 2, 3 or 4) | ||||||||||||||
63777 | AND 1 | Reset all but bit 0 (to give 0 or 1) | ||||||||||||||
63779 | PUSH AF | Store AF (A = bit 0 of number of controls defined) | ||||||||||||||
63780 | ADD A,A | Double A (to give 0 or 2)... | ||||||||||||||
63781 | LD C,A | ...and load into C | ||||||||||||||
63782 | POP AF | Restore AF (A = bit 0 of number of controls defined) | ||||||||||||||
63783 | PUSH AF | Store AF (A = bit 0 of number of controls defined) | ||||||||||||||
63784 | ADD A,C | Add C to A (to give 0 or 3) | ||||||||||||||
63785 | ADD A,A | Multiply A by four... | ||||||||||||||
63786 | ADD A,A | ...to give 0 or 12... | ||||||||||||||
63787 | LD C,A | ...and load into C | ||||||||||||||
63788 | POP AF | Restore AF (A = bit 0 of number of controls defined) | ||||||||||||||
63789 | ADD A,C | Add value in C to A (to give 0 or 13) | ||||||||||||||
63790 | ADD A,5 | Add 5 (to give 5 or 18, the x-coordinates in characters of displayed keyboard controls)... | ||||||||||||||
63792 | LD C,A | ...and load into C | ||||||||||||||
63793 | PUSH BC | Store BC (coordinates in characters of current control being defined) | ||||||||||||||
63794 | CALL 63219 | Load HL with attribute file address for coordinates (C, B)... | ||||||||||||||
63797 | LD A,(HL) | ...and set the FLASH flag for this address... | ||||||||||||||
63798 | OR 128 | ... | ||||||||||||||
63800 | LD (HL),A | ... | ||||||||||||||
63801 | POP BC | Restore BC (coordinates in characters of current control being defined) | ||||||||||||||
63802 | PUSH BC | Store BC (coordinates in characters of current control being defined) | ||||||||||||||
63803 | CALL 63203 | Move virtual cursor (bitmap) to display file address for coordinates x=C, y=B and load address into HL | ||||||||||||||
63806 | CALL 63668 | If key-press was enqueued then load A with index of last key pressed, otherwise wait for key-press and load A with index | ||||||||||||||
63809 | CP 32 | If key pressed was SPACE... | ||||||||||||||
63811 | JP Z,63837 | ...then skip ahead to 63837 | ||||||||||||||
63814 | CP 48 | If index of key pressed is less than 48 (i.e. below "0")... | ||||||||||||||
63816 | JP M,63801 | ...then jump back to 63801 (i.e. wait for next key press and try again) | ||||||||||||||
63819 | CP 91 | If index of key pressed is 91 or higher (i.e. above "Z")... | ||||||||||||||
63821 | JP P,63801 | ...then jump back to 63801 (i.e. wait for next key press and try again) | ||||||||||||||
63824 | CP 58 | If index of key pressed is less than 58 (i.e. "9" or below)... | ||||||||||||||
63826 | JP M,63837 | ...then skip ahead to 63837 | ||||||||||||||
63829 | CP 65 | If index of key pressed is 65 or higher (i.e. "A" or above)... | ||||||||||||||
63831 | JP P,63837 | ...then skip ahead to 63837 | ||||||||||||||
63834 | JP 63801 | Jump back to 63801 (i.e. wait for next key press and try again) | ||||||||||||||
63837 | CALL 63969 | Set zero flag if key pressed is already assigned to a control, otherwise reset | ||||||||||||||
63840 | JP Z,63801 | If key pressed is already assigned then jump back to 63801 (i.e. wait for next key press and try again) | ||||||||||||||
63843 | LD (23711),A | Store pressed key index at 23711 | ||||||||||||||
63846 | CP 32 | If key was not SPACE... | ||||||||||||||
63848 | JR NZ,63852 | ...then skip ahead to 63852 | ||||||||||||||
63850 | LD A,127 | Load A with 127 (index in character set of COPYRIGHT UDG at 28496) | ||||||||||||||
63852 | CALL 63005 | Print text character in A and advance bitmap virtual text cursor | ||||||||||||||
63855 | POP BC | Restore BC (coordinates in characters of current control being defined) | ||||||||||||||
63856 | CALL 63219 | Load HL with attribute file address for coordinates (C, B)... | ||||||||||||||
63859 | LD A,(HL) | ...and reset the FLASH flag for this address... | ||||||||||||||
63860 | AND 127 | ... | ||||||||||||||
63862 | LD (HL),A | ... | ||||||||||||||
63863 | POP HL | Restore HL (current position in list of keyboard control characters) | ||||||||||||||
63864 | LD A,(23711) | Load A with index of previously defined key... | ||||||||||||||
63867 | LD (HL),A | ...and store in list of keyboard control characters | ||||||||||||||
63868 | INC HL | Advance HL to next entry in list of keyboard control characters | ||||||||||||||
63869 | POP BC | Restore BC (B = remaining number of controls to define, C = number of controls defined) | ||||||||||||||
63870 | INC C | Increase C (number of controls defined) | ||||||||||||||
63871 | DJNZ 63768 | Decrease B (remaining number of controls to define) and loop back to 63768 if not zero | ||||||||||||||
63873 | LD B,5 | Load B with 5 (as each keyboard half-row holds five keys) | ||||||||||||||
63875 | LD HL,64045 | Store address of operand of instruction at 64045 (MSB of "input address" for keyboard half-row reading for LEFT)... | ||||||||||||||
63878 | LD (23711),HL | ...at 23711 | ||||||||||||||
63881 | LD HL,63986 | Point HL at start of list of current keyboard control characters | ||||||||||||||
63884 | PUSH BC | Store BC (B = remaining number of control keys to check) | ||||||||||||||
63885 | PUSH HL | Store HL (pointer to current position in list of current keyboard control characters) | ||||||||||||||
63886 | LD IX,63994 | Point IX at lists of characters on each keyboard half-row | ||||||||||||||
63890 | LD A,(HL) | Load A with current keyboard control character index | ||||||||||||||
63891 | LD C,0 | Set C (index in list of half-rows) to zero | ||||||||||||||
63893 | CP (IX+0) | If current keyboard control character index is the same as the current character in keyboard half-row groups... | ||||||||||||||
63896 | JR Z,63903 | ...then skip ahead to 63903 | ||||||||||||||
63898 | INC C | Increase C (index in list of half-rows) | ||||||||||||||
63899 | INC IX | Advance to next entry in list of half-rows | ||||||||||||||
63901 | JR 63893 | Loop back to 63893 | ||||||||||||||
63903 | LD A,C | Load A with index of current control key in list of half-rows | ||||||||||||||
At this point we know the index of the current key in the list of half-rows. We now need to identify which half row it belongs to.
|
||||||||||||||||
63904 | LD B,0 | Set B (keyboard half-row index) to zero | ||||||||||||||
63906 | SUB 5 | If index of key in current half-row is less than 5 (i.e. key is in the current half-row)... | ||||||||||||||
63908 | JP M,63914 | ...then skip ahead to 63914 | ||||||||||||||
63911 | INC B | Increase B (keyboard half-row index) | ||||||||||||||
63912 | JR 63906 | Loop back to 63906 | ||||||||||||||
The MSB in the "input address" for the various keyboard half-rows obeys the progression (254, 253, 251, 247, 239, 223, 191, 127).
|
||||||||||||||||
63914 | LD A,B | Load A with index of keyboard half-row containing current key | ||||||||||||||
63915 | PUSH BC | Store BC (B = index of keyboard half-row, C = index of key in list of half-rows) | ||||||||||||||
63916 | INC B | Increase B | ||||||||||||||
63917 | LD HL,128 | Load HL with 128 | ||||||||||||||
63920 | ADD HL,HL | Double value in HL | ||||||||||||||
63921 | DJNZ 63920 | Decrease B (index of keyboard half-row) and loop back to 63920 if not zero | ||||||||||||||
HL now contains the value (128 × 2n) where n is the (1-based) index of the relevant half-row. H contains (2m), where m is the (zero-based) index of the relevant half-row.
|
||||||||||||||||
63923 | LD A,255 | Load A with 255 | ||||||||||||||
63925 | SUB H | Subtract H (2m) to give MSB of input address for relevant half-row | ||||||||||||||
63926 | LD HL,(23711) | Load HL with address of operand of instruction to modify (64045)... | ||||||||||||||
63929 | LD (HL),A | ...and set operand to value in A | ||||||||||||||
Next we need to modify the second part of the opcode for the instruction that checks the set bit in A to determine which key in the half-row was pressed. The range of opcode values are:
|
||||||||||||||||
63930 | INC HL | Advance HL by four bytes to operand of instruction at 64048... | ||||||||||||||
63931 | INC HL | ... | ||||||||||||||
63932 | INC HL | ... | ||||||||||||||
63933 | INC HL | ... | ||||||||||||||
63934 | LD (23711),HL | ...and store at 23711 | ||||||||||||||
63937 | POP BC | Restore BC (B = index of keyboard half-row, C = index of key in list of half-rows) | ||||||||||||||
63938 | LD A,B | Load B with five times index of keyboard half-row (value currently in B)... | ||||||||||||||
63939 | ADD A,A | ... | ||||||||||||||
63940 | ADD A,A | ... | ||||||||||||||
63941 | ADD A,B | ... | ||||||||||||||
63942 | LD B,A | ... (B is now 0, 5, 10, 15, 20, 25, 30 or 35) | ||||||||||||||
63943 | LD A,C | Load A with index of key in list of half-rows... | ||||||||||||||
63944 | SUB B | ...and subtract B (5 times index of half-row) to give index of key within current half-row | ||||||||||||||
63945 | ADD A,A | Multiply this index by 8 (opcode interval between successive BIT n,A and BIT n+1,A instructions)... | ||||||||||||||
63946 | ADD A,A | ... | ||||||||||||||
63947 | ADD A,A | ... | ||||||||||||||
63948 | ADD A,71 | ...and add 71 (opcode for BIT 0,A) | ||||||||||||||
63950 | LD HL,(23711) | Load HL with address of operand / opcode for BIT n,A instruction... | ||||||||||||||
63953 | LD (HL),A | ...and set "n" accordingly | ||||||||||||||
63954 | LD BC,5 | Advance HL by five bytes to operand of next LD B,x instruction (i.e. MSB of "input address" for next control)... | ||||||||||||||
63957 | ADD HL,BC | ... | ||||||||||||||
63958 | LD (23711),HL | ...and store at 23711 | ||||||||||||||
63961 | POP HL | Restore HL (pointer to current position in list of current keyboard control characters, PUSHed at 63885) | ||||||||||||||
63962 | INC HL | Advance HL to next keyboard control character | ||||||||||||||
63963 | POP BC | Store BC (B = remaining number of control keys to check, PUSHed at 63884) | ||||||||||||||
63964 | DJNZ 63884 | Decrease B (remaining number of control keys to check) and loop back to 63884 for next control key if not zero | ||||||||||||||
63966 | JP 64230 | Wait for interrupt then display "PRESS FIRE TO CONTINUE" window and wait for fire to be pressed and return |
Prev: 63691 | Up: Map | Next: 63969 |