Below a test program that uses an USR.
It writes the low byte first, and it makes click when going from 255 to 256, but the other direction is no click.
It is clicking only in cases that match the theory that it is a phase reset
The other direction, the error tone is an octave down (and one can nicely hear this tone when in BASIC one adds a = sin(a) for a some more delay)
BUT with an asm update in ~10 microseconds, the error tone is inable to EXIST! it has too long wavelength
10 clear 200,&hbf00 100 restore 9200 : read a : defusr = a : gosub 9000 200 screen ,,0 : sound 8,8 210 f = 255 : ?"use cursor up/down" 220 defusr1 = f : rem passing the parameter in usr1 0xf3c9 225 x = usr(0) 230 a = stick(0) 240 if a = 1 then f = f + 1 250 if a = 5 then f = f - 1 260 ?f 300 goto 220 999 end 9000 a$ = "" 9020 if a$="" then read a$ 9032 if left$(a$,1)="$" then a$=mid$(a$,2) : return 9034 if left$(a$,1)="_" then a$=mid$(a$,2) : goto 9020 9040 if left$(a$,2)="1>" then a$=mid$(a$,3) : l1 = a : goto 9020 9042 if left$(a$,2)="2>" then a$=mid$(a$,3) : l2 = a : goto 9020 9050 if left$(a$,2)="<1" then a$=mid$(a$,3) : b$ = hex$((l1-a-1)AND255) : goto 9110 9052 if left$(a$,2)="<2" then a$=mid$(a$,3) : b$ = hex$((l2-a-1)AND255) : goto 9110 9100 b$=left$(a$,2) : a$=mid$(a$,3) 9110 poke a,val("&h"+b$) : a = a + 1 9120 goto 9020 9200 data &hc000 9210 data 3e00_d3a0_3a9CF3_d3a1__3e01_d3a0_3a9DF3_d3a1__C9$
Alright, tried the later approach and that also seems to work. There is a little less overhead as no comparison with last written value is required.
so always write 255 to low part then update high part and then update low part?
Wow this is cool I thought one will have to compare the new value with the register contents. But to write 255 to the low byte does fullfill the requirements "never write a too low value, while a too high value is harmless".
Yes, I think I will adapt this approach for now. Thanks all for sparring with me!
Thanks to you too, I will keep this simple solution in mind for future projects!
Great find guys!