Prev: 6618 Up: Map Next: 66BA
662D: Wait For Key
Waits until the interrupt routine has seen a new key, ignores the characters the printer uses as terminators, and treats EDIT as the picture switch. The cursor keys change how long a scroll waits.
Output
A The key, with letters as typed.
Bit 5 of FLAGS is set by the maskable interrupt when a new key is ready. Calling the RET at the end of that routine lets one interrupt through.
WaitForKey 662D CALL $0052 Call the RET at the end of MASKABLE INTERRUPT, then wait for bit 5 of FLAGS.
6630 SET 3,(IY+$30)
6634 BIT 5,(IY+$01)
6638 JR Z,WaitForKey
663A RES 5,(IY+$01)
663E LD A,R Stir R into the signature byte at Signature.
6640 AND $07
6642 INC A
6643 LD ($676E),A
6646 LD IX,$676E Read that stirred byte back.
664A LD A,($676E)
664D LD ($6655),A
6650 LD A,R Mix R in again.
6652 ADD A,A
6653 LD (IX+$00),A
6656 PUSH BC Save BC.
6657 LD B,$05
6659 PUSH DE Save DE, HL and IX.
665A PUSH HL
665B PUSH IX
665D LD A,$1E Sound the key click. A is 1E.
665F CALL Beep
6662 POP IX Restore the caller's registers from the stack.
6664 POP HL
6665 POP DE
6666 POP BC
WaitForKey_Cursor 6667 LD A,($5C08) A is LAST_K.
666A PUSH HL Cursor key C7 stores no scroll delay.
666B CP $C7
666D LD HL,$0000
6670 JR Z,WaitForKey_Delay
6672 CP $C9 Cursor key C9 stores a long delay, 0190.
6674 LD HL,$0190
6677 JR Z,WaitForKey_Delay
6679 CP $C8 Cursor key C8 stores a short delay, 00C8.
667B LD HL,$00C8
667E JR NZ,WaitForKey_Ignore
WaitForKey_Delay 6680 LD ($655A),HL Store the delay at RepeatTimer.
WaitForKey_Ignore 6683 POP HL Restore the key from the stack.
6684 CP $5E 5E and 5F are ignored.
6686 JR Z,WaitForKey
6688 CP $5F
668A JR Z,WaitForKey
668C CP $7F 7F and 7E are ignored.
668E JR Z,WaitForKey
6690 CP $7E
6692 JR Z,WaitForKey
EDIT toggles the picture. The illustration attributes are cleared when pictures turn off, and the room is redrawn from bank 0.
WaitForKey_Pictures 6694 CP $0E EDIT is 0E. Any other key returns.
6696 RET NZ
6697 PUSH BC Save the registers around the redraw.
6698 PUSH DE
6699 PUSH HL
669A CALL ClearLowerRows Call ClearLowerRows to clear the lower rows.
669D LD HL,$66D6 Pictures turning off clear the illustration colours.
66A0 LD A,(HL)
66A1 OR A
66A2 CALL NZ,ClearPictureAttributes
66A5 XOR $01 Toggle PicturesOn.
66A7 LD (HL),A
66A8 XOR A page RAM bank 00 in at C000, keeping the 48K ROM.
66A9 CALL PageBank
66AC CALL RedrawLocation Call RedrawLocation to redraw the room.
66AF LD A,$03 Remember bank 3 and page it back in.
66B1 CALL RememberBank
66B4 POP HL Restore the registers from the stack.
66B5 POP DE
66B6 POP BC
66B7 JP WaitForKey Jump to WaitForKey to read the next key.
Prev: 6618 Up: Map Next: 66BA