| Routines

86C3: Display the code entry screen

Used by the routine at 869F. Displays the code entry screen and waits for a code to be entered. Returns with the zero flag set if the code entered is correct.
Input
IX | Address of the message to print (858B or 85AB)
86C3 | LD DE,$4800 | Print the message pointed to by IX at (8,0)
86C6 | LD C,$20
86C8 | CALL $9680
86CB | LD HL,$4842 | Print the graphic for the '1' key at (10,2)
86CE | LD DE,$9B00
86D1 | LD C,$00
86D3 | CALL $9456
86D6 | LD HL,$4845 | Print the graphic for the '2' key at (10,5)
86D9 | CALL $9456
86DC | LD HL,$4848 | Print the graphic for the '3' key at (10,8)
86DF | CALL $9456
86E2 | LD HL,$484B | Print the graphic for the '4' key at (10,11)
86E5 | CALL $9456
86E8 | LD HL,$9B80 | Copy the 128 attribute bytes from 9B80 to the screen (lines 8, 9, 10 and 11)
86EB | LD DE,$5900
86EE | LD BC,$0080
86F1 | LDIR
86F3 | LD A,($5C78) | Collect the LSB of the system variable FRAMES
86F6 | ADD A,$25 | Add 0x25 to this value and replace it; this ensures that the value collected on the second pass through this routine is different from the value collected on the first pass
86F8 | LD ($5C78),A
86FB | CP $B3 | Is the value between 0x00 and 0xB2?
86FD | JR C,$8701 | Jump if so
86FF | SUB $B4 | Otherwise subtract 0xB4; note that if the original value of the LSB of the system variable FRAMES was 0x8E, this leaves A holding 0xFF, which is a bug
8701 | LD L,A | Now L holds either 0xFF or some number between 0x00 and 0xB2
8702 | LD H,$9E | Point HL at one of the entries in the table at 9E00 (or at 9EFF if L=0xFF)
8704 | LD A,(HL) | Pick up the table entry
8705 | ADD A,L | Add L to obtain the actual code
8706 | LD ($85E4),A | Store the code at 85E4
8709 | LD C,L | Copy the code index to C; this will be used to compute the grid location
870A | LD E,$2F | Calculate the ASCII code of the grid location number (0-9) in E
870C | INC E
870D | LD A,C
870E | CP $12
8710 | JR C,$8717
8712 | SUB $12
8714 | LD C,A
8715 | JR $870C
8717 | LD A,E | Print the grid location number at (8,30)
8718 | LD DE,$481E
871B | CALL $9691
871E | LD A,C | Calculate the ASCII code of the grid location letter (A-R) in A
871F | ADD A,$41
8721 | LD DE,$481D | Print the grid location letter at (8,29)
8724 | CALL $9691
Here we enter a loop that prints a 2x2 coloured block at (10,16), (10,19), (10,22) or (10,25) whenever '1', '2', '3' or '4' is pressed, or returns to the calling routine at 869F if ENTER is pressed.
8727 | LD IX,$5950 | Point IX at the attribute file location of the first coloured block at (10,16)
872B | CALL $873C | Print a coloured block when '1', '2', '3' or '4' is pressed, or return to 869F if ENTER is pressed
872E | INC IX | Move IX along to the location of the next coloured block
8730 | INC IX
8732 | INC IX
8734 | LD A,IXl | Have we just printed the fourth coloured block at (10,25)?
8736 | CP $5C
8738 | JR NZ,$872B | If not, jump back to print the next one
873A | JR $8727 | Otherwise rewind IX to the location of the first coloured block