The comments are clear enough, I think.
Sample code to change the color of each frame (1/50 second)
sei ; enable interrupts
loop1: lda
loop2: cmp $d012 ; until it reaches 251th raster line ($fb)
bne loop2 ; which is out of the inner screen area
inc $d021 ; increase background color
lda $d012 ; make sure we reached
loop3: cmp $d012 ; the next raster line so next time we
beq loop3 ; should catch the same line next frame
jmp loop1 ; jump to main loop
Sample code to change color per second
counter = $fa ; a zeropage address to be used as a counter
lda
sta counter ; counter
sei ; enable interrupts
loop1: lda
loop2: cmp $d012 ; until it reaches 251th raster line ($fb)
bne loop2 ; which is out of the inner screen area
inc counter ; increase frame counter
lda counter ; check if counter
cmp
bne out ; if not, pass the color changing routine
lda
sta counter ; counter
inc $d021 ; increase background color
out:
lda $d012 ; make sure we reached
loop3: cmp $d012 ; the next raster line so next time we
beq loop3 ; should catch the same line next frame
jmp loop1 ; jump to main loop
source
share