CPCWiki forum

General Category => Programming => Topic started by: lmimmfn on 23:56, 06 August 20

Title: Simple Hardware Vertical Scroll
Post by: lmimmfn on 23:56, 06 August 20
Im trying to get my head around implementing a basic hardware scroll and erm its not going well :)
I tried in basic just using the CRTC registers, i.e. using register 5 for single scanline scroll coupled with r7 for 8 pixel/character scroll:

10 for vert=37 to 0 step -1
20 call &bc19
30 out &bc00,7:out &bd00,vert
40 for i=1 to 16 step 2
50 call &bc19
60 out &bc00,5:out &bd00,i
70 t=TIME+150*1:WHILE TIME<t AND INKEY$="":WEND
80 next i
90 next vert
100 goto 10

But this produces artifacts scrolling, i.e. scrolls relatively smoothly for a bit then the screen jumps and continues scrolling again relatively smoothly( its in jumps of 2 scan lines vs 1 as not sure if CRTC is presuming interlaced for that or not, i.e. 16 scanline scrolls = 1 8 character scroll vertically )


I also read - http://www.cpctech.org.uk/hwscroll.txt (http://www.cpctech.org.uk/hwscroll.txt) which says R9 can be used for smooth scroll? i dont understand that as it splits the display into multiple clones of same pixels?


Also tried arnoldemu's source from http://www.cpctech.org.uk/source/vscroll2.asm (http://www.cpctech.org.uk/source/vscroll2.asm) from https://www.cpcwiki.eu/forum/games/games-with-smooth-'1'-pixel-multi-directional-scrolling/msg44972/#msg44972 (https://www.cpcwiki.eu/forum/games/games-with-smooth-'1'-pixel-multi-directional-scrolling/msg44972/#msg44972) which i modified slightly( i.e. just changed the keys as no numpad and changed to mode 0 ) but this exhibits the same artifacts as the basic scroller above, i.e. jumping( scrolling up is smooth but down shows the artifacts ).


Im using WinApe but the 2 code listings above, is it an issue with the code or with WinApe?


Just trying to get it smooth looking before i even break down arnoldemu's code( which im guessing is split raster to not have to scroll the full screen, i.e. so screen location and border stays in place ), but thats something to investigate later :)
Title: Re: Simple Hardware Vertical Scroll
Post by: megachur on 05:38, 07 August 20
I've never done a basic hardware scrolling in basic, but :

Quote20 call &bc19
should be in basic20 call &BD19
or
20 FRAME
but for the second it isn't in BASIC 1.0 (464) : the first on is prefered then !


same for 50 call &bc19
Title: Re: Simple Hardware Vertical Scroll
Post by: lmimmfn on 20:06, 08 August 20
Thanks, yes mistake on my side( thought i remembered for '85 :) , but obviously not)
Still it glitches though, tried with Arnold and both basic and assembly versions glitch.
Ill play about with assembly version, maybe slowing it reduces glitching.


Also read up on use of r9 reg, makes sense but seems memory intensive/packing code in between visible mem locations is quite complex.
Title: Re: Simple Hardware Vertical Scroll
Post by: fgbrain on 21:39, 08 August 20
For vertical scrolling you create for each frame :
1. A screen split (rupture)  / which cannot be done in basic!!
2. The scrolling screen uses reg5 to scroll down per line up to 8 lines
3. For the 9th line, the reg5 is reset and reg12/13 are used now to move the screen a character line (8 lines)
4. The second screen seems not to move as we set reg5 the opposite way and of course other screen base too..
5. loop back to 1

Title: Re: Simple Hardware Vertical Scroll
Post by: lmimmfn on 22:28, 08 August 20
Quote from: fgbrain on 21:39, 08 August 20
For vertical scrolling you create for each frame :
1. A screen split (rupture)  / which cannot be done in basic!!
2. The scrolling screen uses reg5 to scroll down per line up to 8 lines
3. For the 9th line, the reg5 is reset and reg12/13 are used now to move the screen a character line (8 lines)
4. The second screen seems not to move as we set reg5 the opposite way and of course other screen base too..
5. loop back to 1
That makes sense( doesnt matter if it requires assembly :) ) , my understanding( which may be incorrect) is to use rupture to hide the redraw, is there any other reason its needed for vertical scroll? and again i may be misunderstanding but appreciate the clarification.
Or is rupture required to keep the same vertical screen location?

For example and just for testing, a full overscan screen where bottom of screen reaches wrap around for the top of the screen should work with r5 & r12/13 without rupture?
Title: Re: Simple Hardware Vertical Scroll
Post by: fgbrain on 09:10, 09 August 20

Somehow we "hide" the first split "behind" the second split but the whole screen adds up as stable.
I dont know exactly how else to describe it..


Its better to check this old artiicle by Logon system :
(French only but the source is great!)

https://cpcrulez.fr/coding_logon48-scroll_vertical.htm (https://cpcrulez.fr/coding_logon48-scroll_vertical.htm)

Powered by SMFPacks Menu Editor Mod