Prev: 26136 Up: Map Next: 26298
26157: 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 26157 CALL 82 Call the RET at the end of MASKABLE INTERRUPT, then wait for bit 5 of FLAGS.
26160 SET 3,(IY+48)
26164 BIT 5,(IY+1)
26168 JR Z,WaitForKey
26170 RES 5,(IY+1)
26174 LD A,R Stir R into the signature byte at Signature.
26176 AND 7
26178 INC A
26179 LD (26478),A
26182 LD IX,26478 Read that stirred byte back.
26186 LD A,(26478)
26189 LD (26197),A
26192 LD A,R Mix R in again.
26194 ADD A,A
26195 LD (IX+0),A
26198 PUSH BC Save BC.
26199 LD B,5
26201 PUSH DE Save DE, HL and IX.
26202 PUSH HL
26203 PUSH IX
26205 LD A,30 Sound the key click. A is 30.
26207 CALL Beep
26210 POP IX Restore the caller's registers from the stack.
26212 POP HL
26213 POP DE
26214 POP BC
WaitForKey_Cursor 26215 LD A,(23560) A is LAST_K.
26218 PUSH HL Cursor key 199 stores no scroll delay.
26219 CP 199
26221 LD HL,0
26224 JR Z,WaitForKey_Delay
26226 CP 201 Cursor key 201 stores a long delay, 400.
26228 LD HL,400
26231 JR Z,WaitForKey_Delay
26233 CP 200 Cursor key 200 stores a short delay, 0200.
26235 LD HL,200
26238 JR NZ,WaitForKey_Ignore
WaitForKey_Delay 26240 LD (25946),HL Store the delay at RepeatTimer.
WaitForKey_Ignore 26243 POP HL Restore the key from the stack.
26244 CP 94 94 and 95 are ignored.
26246 JR Z,WaitForKey
26248 CP 95
26250 JR Z,WaitForKey
26252 CP 127 127 and 126 are ignored.
26254 JR Z,WaitForKey
26256 CP 126
26258 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 26260 CP 14 EDIT is 14. Any other key returns.
26262 RET NZ
26263 PUSH BC Save the registers around the redraw.
26264 PUSH DE
26265 PUSH HL
26266 CALL ClearLowerRows Call ClearLowerRows to clear the lower rows.
26269 LD HL,26326 Pictures turning off clear the illustration colours.
26272 LD A,(HL)
26273 OR A
26274 CALL NZ,ClearPictureAttributes
26277 XOR 1 Toggle PicturesOn.
26279 LD (HL),A
26280 XOR A page RAM bank 0 in at 49152, keeping the 48K ROM.
26281 CALL PageBank
26284 CALL RedrawLocation Call RedrawLocation to redraw the room.
26287 LD A,3 Remember bank 3 and page it back in.
26289 CALL RememberBank
26292 POP HL Restore the registers from the stack.
26293 POP DE
26294 POP BC
26295 JP WaitForKey Jump to WaitForKey to read the next key.
Prev: 26136 Up: Map Next: 26298