How to "sync" scroll horizontally ?
Completing the answer above here is a "picture"
Each normal line is made of 320 pixels or 160 bytes. Each group of 16 pixels are 8 bytes or more precisely 4 words one for each bitplane. Let's call each group of 16 pixels Wxx.
So you start with:
W00 W01 W02 W03 W04 W05 W06 W07 W08 W09 W10 W11 W12 W13 W14 W15 W16 W17 W18 W19
W20 W21 W22 ...
If you add 8 bytes to the screen offset, you will get:
W01 W02 W03 W04 W05 W06 W07 W08 W09 W10 W11 W12 W13 W14 W15 W16 W17 W18 W19 W20
W21 W22 W23 ...
If you then correct the column of W20/W40/W60 ... with the new group of 16 pixels that comes from the right you will get an horizontal scroll of 16 pixels to the left.
If you substract 8 bytes to the original screen offset, you will get:
W99 W00 W01 W02 W03 W04 W05 W06 W07 W08 W09 W10 W11 W12 W13 W14 W15 W16 W17 W18
W19 W20 W21 W22 ...
If you then correct the column of W99/W19/W39 ... with the new group of 16 pixels that comes from the left you will get an horizontal scroll of 16 pixels to the right.
Now, how to do a 8 pixels scroll ?
Simple, you use 2 screen buffers that you show once every 2 frames.
The first screen buffer is used like above.
The second screen buffer uses other sets of 16 pixels where each one contains 8 pixels of one Wxx and 8 pixels of the adjacent Wxx.
Now, how to do a 4 pixel scroll like in most main menus of well know demos ?
Again, you increase the number of screen buffers to 4:
Wxx like 1st case
Xxx with 4 pixels of Wxx and 12 pixels of the adjacent Wxx
Yxx with 8 pixels of Wxx and 8 pixels of the adjacent Wxx
Zxx with 12 pixels of Wxx and 4 pixels of the adjacent Wxx
2 pixel scroll => 8 screen buffers
1 pixel scroll => 16 screen buffers
Beware that if your screen does not move horizontally you are working on the same screen that is displayed to the user so you can only modify the screen in line with the place where the electron is to avoid flickering effects when clearing and drawing sprites. That is one of the main credits to Nick in Enchanted Land because we are talking about a game and not a demo.
1 screen buffer for 200 lines = 32KB minimum + the memory space required to scroll horizontally to the extremes left, right, top and bottom.
16 screen buffers for 200 lines = 512 KB minimum so many of the STFs are out ...
I hope this helped in explaining this "sync" scroll and turned clear some of my previous statements.