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 MASK_INT.
6630 SET 3,(IY+$30) Set bit 3 of FLAGS2 (CAPS LOCK).
6634 BIT 5,(IY+$01) Jump to WaitForKey until bit 5 of FLAGS is set.
6638 JR Z,WaitForKey
663A RES 5,(IY+$01) Clear that bit for the next wait.
663E LD A,R Read R.
6640 AND %00000111 Keep only bits 0-2.
6642 INC A Write R+01 into the signature at Signature.
6643 LD ($676E),A
6646 LD IX,$676E Point IX at Signature.
664A LD A,($676E) Plant that stirred byte over the displacement at 6655.
664D LD ($6655),A
6650 LD A,R Mix R in again.
6652 ADD A,A
6653 LD (IX+$00),A
6656 PUSH BC Stash BC on the stack.
6657 LD B,$05 Five passes.
6659 PUSH DE Save DE, HL and IX.
665A PUSH HL
665B PUSH IX
665D LD A,$1E Sound the key click with A equal to 1E.
665F CALL Beep
6662 POP IX Restore the caller's registers from the stack.
6664 POP HL
6665 POP DE
6666 POP BC
Cursor keys change the scroll delay.
WaitForKey_Cursor 6667 LD A,($5C08) A is LAST_K.
666A PUSH HL Stash HL on the stack.
666B CP $C7 Cursor key C7 stores no scroll delay.
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
Store the delay.
WaitForKey_Delay 6680 LD ($655A),HL Store the delay at RepeatTimer.
Ignore printer terminators.
WaitForKey_Ignore 6683 POP HL Restore the key from the stack.
6684 CP $5E Jump to WaitForKey if it is 5E.
6686 JR Z,WaitForKey
6688 CP $5F Jump to WaitForKey if it is 5F.
668A JR Z,WaitForKey
668C CP $7F Jump to WaitForKey if it is 7F.
668E JR Z,WaitForKey
6690 CP $7E Jump to WaitForKey if it is 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 Stash the registers around the redraw.
6698 PUSH DE
6699 PUSH HL
669A CALL ClearLowerRows Call ClearLowerRows.
669D LD HL,$66D6 Point HL at PicturesOn.
66A0 LD A,(HL) Call ClearPictureAttributes if pictures are currently on.
66A1 OR A
66A2 CALL NZ,ClearPictureAttributes
66A5 XOR %00000001 Flip bit 0.
66A7 LD (HL),A Write the new picture flag to *PicturesOn.
66A8 XOR A page RAM bank 00 in at C000, keeping the 48K ROM.
66A9 CALL PageBank
Redraw the room.
66AC CALL RedrawLocation Call RedrawLocation.
66AF LD A,$03 Page RAM bank 03 back in.
66B1 CALL RememberBank
66B4 POP HL Restore the registers from the stack.
66B5 POP DE
66B6 POP BC
Read the next key.
66B7 JP WaitForKey Jump to WaitForKey.
Prev: 6618 Up: Map Next: 66BA