C64 Coding: stabilizing raster with cia timer reference /Copyfault

Written on 09/11/2026
By Copyfault

I give it a last shot. When this mini-dejittering is used "inline", it probably means we know the rasterline we're in and that the code is not in a subroutine but rather "thrown in" some rastercode. This'd make the overhead I had in mind when tracing that val-value more or less obsolete. The cmp#val *can* be used when the rasterline is know beforehand; we only have to invert the timer-value:
lda $dd04
eor #$ff
cmp #<(($4cc7-57-line*63)^$ff)
sbc $d012
and #$3f

The EOR#$FF beams us into yet another interval, but the sub will know work consistently: either we are before the critical cycle and the cmp#... gives a clear carry (effectively substrating one more than needed), or the carry is set, exactly when the [SBC raster] will be done one line later than needed. Either case, we end up with "one digit off" in the substraction, which only affects the interval of the resulting values.

I'll leave it for now... hopefully :)=)