Prev: 50197 Up: Map Next: 50270
50207: Get Keypress
Waits for the next frame and reads the key the Spectrum last reported.
Output
A Keypress value, or 0 for no keypress
GetKeypress 50207 PUSH IY Save the schedule entry, the character record, the pointer, the source and the count.
50209 PUSH IX
50211 PUSH HL
50212 PUSH DE
50213 PUSH BC
50214 LD IY,23610 IY=ERR_NR.
50218 EI Let one frame interrupt through so the ROM can scan the keyboard, then turn interrupts off again.
50219 HALT
50220 DI
50221 LD A,(23611) Jump to GetKeypress_Process if bit 5 of *FLAGS is set, indicating that a key has been pressed.
50224 BIT 5,A
50226 JR NZ,GetKeypress_Process
No key has been pressed.
50228 XOR A Load A with 0 (no keypress).
50229 JR GetKeypress_Return Carry on and wait for a key once the mode flags are stored.
Clear the mark on this character, then store the result in the working byte, then read the working value.
A key has been pressed, so process it.
GetKeypress_Process 50231 RES 5,A Store it in the system variables.
50233 LD (23611),A
50236 LD A,(23560) Jump to GetKeypress_CheckDelete if *LAST_K (last key pressed) is not ASCII 95 ("_").
50239 CP 95
50241 JR NZ,GetKeypress_CheckDelete
50243 LD A,24 Use 24 for the key.
Did the player press "DELETE"?
GetKeypress_CheckDelete 50245 CP 12 Jump to GetKeypress_CheckUp if *LAST_K (last key pressed) is not ASCII 12 ("DELETE").
50247 JR NZ,GetKeypress_CheckUp
50249 LD A,8 Load A with 8 (delete was pressed).
Did the player press "UP"?
GetKeypress_CheckUp 50251 CP 11 Jump to GetKeypress_Validate if *LAST_K (last key pressed) is not ASCII 11 ("UP").
50253 JR NZ,GetKeypress_Validate
50255 LD A,91 Load A with 91 (up was pressed).
Validate keypress.
GetKeypress_Validate 50257 CALL ValidateKeypress Call ValidateKeypress to accept the key if it is in range.
50260 SET 7,A Set the mark on this character.
GetKeypress_Return 50262 POP BC Restore the saved count, the saved source, the saved pointer, the saved character record and the saved schedule entry from the stack.
50263 POP DE
50264 POP HL
50265 POP IX
50267 POP IY
50269 RET Return.
Prev: 50197 Up: Map Next: 50270