Prev: C415 Up: Map Next: C45E
C41F: Get Keypress
Waits for the next frame and reads the key the Spectrum last reported.
Output
A Keypress value, or 00 for no keypress
GetKeypress C41F PUSH IY Save the schedule entry, the character record, the pointer, the source and the count.
C421 PUSH IX
C423 PUSH HL
C424 PUSH DE
C425 PUSH BC
C426 LD IY,$5C3A IY=ERR_NR.
C42A EI Let one frame interrupt through so the ROM can scan the keyboard, then turn interrupts off again.
C42B HALT
C42C DI
C42D LD A,($5C3B) Jump to GetKeypress_Process if bit 5 of *FLAGS is set, indicating that a key has been pressed.
C430 BIT 5,A
C432 JR NZ,GetKeypress_Process
No key has been pressed.
C434 XOR A Load A with 00 (no keypress).
C435 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 C437 RES 5,A Store it in the system variables.
C439 LD ($5C3B),A
C43C LD A,($5C08) Jump to GetKeypress_CheckDelete if *LAST_K (last key pressed) is not ASCII 5F ("_").
C43F CP $5F
C441 JR NZ,GetKeypress_CheckDelete
C443 LD A,$18 Use 18 for the key.
Did the player press "DELETE"?
GetKeypress_CheckDelete C445 CP $0C Jump to GetKeypress_CheckUp if *LAST_K (last key pressed) is not ASCII 0C ("DELETE").
C447 JR NZ,GetKeypress_CheckUp
C449 LD A,$08 Load A with 08 (delete was pressed).
Did the player press "UP"?
GetKeypress_CheckUp C44B CP $0B Jump to GetKeypress_Validate if *LAST_K (last key pressed) is not ASCII 0B ("UP").
C44D JR NZ,GetKeypress_Validate
C44F LD A,$5B Load A with 5B (up was pressed).
Validate keypress.
GetKeypress_Validate C451 CALL ValidateKeypress Call ValidateKeypress to accept the key if it is in range.
C454 SET 7,A Set the mark on this character.
GetKeypress_Return C456 POP BC Restore the saved count, the saved source, the saved pointer, the saved character record and the saved schedule entry from the stack.
C457 POP DE
C458 POP HL
C459 POP IX
C45B POP IY
C45D RET Return.
Prev: C415 Up: Map Next: C45E