initstabilise lda $d012 ldx #10 ; 2 - dex ; (10 * 5) + 4 bpl - ; 54 nop ; 2 eor $d012 - $ff,x; 5 = 63 bne initstabilise; 7 = 70 [...]; timer setup
lda #$08 sta zp_val ldx #$fe loop: wait_startline: cpx $d012 bne wait_startline inx bmi wait_startline //at cycle 6..12 of line $ff ldy zp_val waste_cycles: dey bpl waste_cycles cpx $d012 bne loop //leaves at cycle 2 of the first line in which raster is stable ($100..$106) done:
sync: lda $dc04 sec sta ZP ;RMW instruction sbc $dc04 cmp #51 bne sync:
[...] But back to your INC-based solution: why does it take 9 frames at most?[...]
waitline: inc $d012 bne waitline ...
waitline: lda $d012 bne waitline ...