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 MASK_INT.
26160 SET 3,(IY+48) Set bit 3 of FLAGS2 (CAPS LOCK).
26164 BIT 5,(IY+1) Jump to WaitForKey until bit 5 of FLAGS is set.
26168 JR Z,WaitForKey
26170 RES 5,(IY+1) Clear that bit for the next wait.
26174 LD A,R Read R.
26176 AND %00000111 Keep only bits 0-2.
26178 INC A Write R+1 into the signature at Signature.
26179 LD (26478),A
26182 LD IX,26478 Point IX at Signature.
26186 LD A,(26478) Plant that stirred byte over the displacement at 26197.
26189 LD (26197),A
26192 LD A,R Mix R in again.
26194 ADD A,A
26195 LD (IX+0),A
26198 PUSH BC Stash BC on the stack.
26199 LD B,5 Five passes.
26201 PUSH DE Save DE, HL and IX.
26202 PUSH HL
26203 PUSH IX
26205 LD A,30 Sound the key click with A equal to 30.
26207 CALL Beep
26210 POP IX Restore the caller's registers from the stack.
26212 POP HL
26213 POP DE
26214 POP BC
Cursor keys change the scroll delay.
WaitForKey_Cursor 26215 LD A,(23560) A is LAST_K.
26218 PUSH HL Stash HL on the stack.
26219 CP 199 Cursor key 199 stores no scroll delay.
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
Store the delay.
WaitForKey_Delay 26240 LD (25946),HL Store the delay at RepeatTimer.
Ignore printer terminators.
WaitForKey_Ignore 26243 POP HL Restore the key from the stack.
26244 CP 94 Jump to WaitForKey if it is 94.
26246 JR Z,WaitForKey
26248 CP 95 Jump to WaitForKey if it is 95.
26250 JR Z,WaitForKey
26252 CP 127 Jump to WaitForKey if it is 127.
26254 JR Z,WaitForKey
26256 CP 126 Jump to WaitForKey if it is 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 Stash the registers around the redraw.
26264 PUSH DE
26265 PUSH HL
26266 CALL ClearLowerRows Call ClearLowerRows.
26269 LD HL,26326 Point HL at PicturesOn.
26272 LD A,(HL) Call ClearPictureAttributes if pictures are currently on.
26273 OR A
26274 CALL NZ,ClearPictureAttributes
26277 XOR %00000001 Flip bit 0.
26279 LD (HL),A Write the new picture flag to *PicturesOn.
26280 XOR A page RAM bank 0 in at 49152, keeping the 48K ROM.
26281 CALL PageBank
Redraw the room.
26284 CALL RedrawLocation Call RedrawLocation.
26287 LD A,3 Page RAM bank 3 back in.
26289 CALL RememberBank
26292 POP HL Restore the registers from the stack.
26293 POP DE
26294 POP BC
Read the next key.
26295 JP WaitForKey Jump to WaitForKey.
Prev: 26136 Up: Map Next: 26298