Somebody did rastersplits in BASIC on the c64 with this WAIT command. That gave me the idea to use WAIT on the VDC-status register d600.
WAIT address,mask1,mask2 address = any memory address mask1 tests if bits are on: mem AND mask1(0-255) mask2 together with mask1 tests if bits are off: (mem XOR mask 2) AND mask1
s=dec(“d600”) wait s,32 waits for the vblank bit to turn on. wait s,32,32 waits for the vblank bit to turn off. wait s,32,32:wait s,32 waits for the start of vblank which is the end of the visible area. wait s,32:wait s,32,32 waits for the end of vblank which is the start of the visible area.
To see how much time the setting of a VDC register in BASIC takes (reg26 is screencolor): 10 v=dec(“cdcc”):s=dec(“d600”):fast 20 wait s,32:wait s,32,32:sysv,4,26:sysv,0,26:goto20
About 6 text lines, about 50 rasterlines in fast mode in VICE 3.2.
I know now a sys in BASIC takes about 50 rasterlines. For PAL with its 312 rasterlines/frame max 6 times a sys can be executed in the same frame. Take some jittering in account: max 5. For NTSC with its 262 rasterlines/frame it is less: max 4 with jitter.
I wanted to do some smooth scrolling. Vertical and Horizontal. Reg12/13 and 24 for vertical smooth scroll and reg12/13 and 25 for horizontal. In order for this to work, these regs have to be set in the same frame. Any flickering occurs in my opinion when reg12/13 and reg24or25 are set in different frames.
So with this newly discovered command WAIT I can sync in BASIC on the start of the visible screen. And do some experiments very easy. I don’t know where the VDC or Vice latch the regs 12/13 but I am sure not in the visible screen therefore I sync at the end of vblank. For vertical monochrome smooth scroll I have to change reg12, reg13 and reg24. That is 3 times a sys: that should work in PAL and NTSC: s=dec(“d600”):v=dec(“cdcc”) wait s,32:wait s,32,32:sysv,high,12:sysv,low,13:sysv,smooth,24
For horizontal monochrome smooth scroll I have to change reg12, reg13 and reg25: wait s,32:wait s,32,32:sysv,high,12:sysv,low,13:sysv,71-smooth,25. When I did that I got some jitter in the lower part of the screen. That was because reg25 was changed too early, still in the visible screen. And reg25 takes effect immediately on the screen. So I had to wait till the border was reached: wait s,32 and then set reg25: wait s,32:wait s,32,32:sysv,high,12:sysv,low,13:wait s,32:sysv,71-smooth,25. That worked. See prog:
Now I wanted color: two extra sys’s: sysv,high,20:sysv,low,21 for start attribute. No hope for NTSC with max 4 sys’s. And jitter for PAL. Let’s sync on start of vblank and hope to jump over the latching position of regs 12/13, I thought. In Vice3.2 that worked, can’t test it on a real C128.
I have color smooth scroll but only just and not for NTSC. Not good enough. I dumped the wait command and wrote a little ML-programm to sync on start of screen and set reg12/13 with one sys and set reg 20/21 with also one sys. sys4864,high,low:rem sync and set12/13 sys4884,high,low:rem set 20/21 sysv,smooth,24:rem or horizontal sysv,71-smooth,25