* = $1000 start lda $d011 ;loads raster register bpl start ;is bit 7 set? if not, wait ;now we are on a non visible area ;so we can change background colour ;with no flicker ldx #$00 ;starting background colour black stx $d021 loop1 jsr pause inx loop2 lda $d011 ;loads raster register bpl loop2 ;is bit 7 set? if not, wait stx $d021 ;sets colour bne loop1 ;x register is 0? if not, go to loop1 jmp start ;start again from the beginning pause ldy #$00 sty delay loop iny bne loop inc delay lda delay cmp #150 bne loop ;note that the branch goes directly to the "iny" ;instruction. no need to clear the y register as ;it has already wrapped around to 0 (the first ;"loop" is exited when y register = 0). rts delay byte 0