Code: Select all
GET JSR SCNKEY
JSR GETIN
CMP #0
BEQ GET
JSR CHROUT
Code: Select all
LDA #0
STA $C6 ; To clear the keyboard buffer
DEB LDA $C5 ; Wait for all keys to be released before continuing
CMP #$40 ; ,,
BNE DEB ; ,,
JMP GET
I went to the IRQ service routine to get some tips. I thought, since the service routine is already calling SCNKEY, maybe it's a bad idea to do it again. I tried enclosing my KERNAL calls in SEI/CLI, but that didn't help. The thing that did help was getting rid of SCNKEY entirely, and just letting it happen through either the native service routine, or a replacement routine. This seems to be correct:
Code: Select all
JSR GETIN
CMP #0
BEQ ETC
JSR CHROUT
ETC ; do other things
However, for most purposes, I see myself continuing to just read $C5 when I care about keypresses.