I've run into a few issues while playing around with asm on an emulated C64 machine.
What I want to do is to check if the key "N" on the keyboard is being pressed, then the program should wait for a change to appear on address $D012. Now what I don't understand is how I can "wait" for a change to appear? Can anybody tell me what it's all about?
Checking if N button on the keyboard is pressed down is simple - just use the subroutines FFE4 (input) and FFD2 (output).
I don't really ask for anything to be done for me, but if I can get some quick info on how the D012 works and how I can "wait" for a change, I would be really thankful.
Thanks in advance!
$d012
contains the current raster line.
If you only need to wait until the the register changes, that is wait until the next raster line, you can do simple busy-waiting:
lda $d012 ;load the current raster line into the accumulator
cmp $d012 ;check if it has changed
beq *-3 ;if not, jump back and check again
edit:
If you want to wait for several rasterlines, for example 3:
lda $d012
clc ;make sure carry is clear
adc #$03 ;add lines to wait
cmp $d012
bne *-3 ;check *until* we're at the target raster line