Page 2 of 2

Horizontal scrolling tricks?

Posted: Thu Oct 12, 2017 4:02 am
by monzamess
Now I'm playing with scrolling.

Vertical scrolling is really fast if you have the memory, because you basically create a really long DFILE in memory and increment the DFILE pointer by 33 bytes for each line. Attached is the "vscroll" program which lets you push the O around the screen while random junk flies by vertically.
vscroll.c
(5.21 KiB) Downloaded 173 times
vscroll.P
(4.85 KiB) Downloaded 165 times
Horizontal scrolling... is there a trick? I'm currently doing it the naive way by just moving stuff right-to-left. Attached is "hscroll" where you can again push an O around the screen while stair steps scroll by at a very boring pace. This example is double-buffered for smoother animation, but I tested it with a single buffer and it wasn't significantly faster.
hscroll.c
(4.92 KiB) Downloaded 175 times
hscroll.P
(4.92 KiB) Downloaded 170 times
I am sure some of the hscroll slowness is due to my coding technique and use of C, but fundamentally what I'm doing is slow by any method. Any tricks?

Re: Explain this behavior

Posted: Thu Oct 12, 2017 5:07 pm
by Lardo Boffin
With the vertical scrolling you are in effect making use of hardware acceleration in low resolution mode as the screen is made up of horizontal layers. If you move the D_FILE start up or down a complete line at the next redraw the whole screen moves up or down a complete line.

ScreenMemory.JPG
(230.42 KiB) Downloaded 273 times

Scrolling left or right is way more complex. To scroll to the left (so as to simulate a space ship flying to the right such as in The Gauntlet/ Rocket Raid etc.) you could either: -
Move each character in each line one position to the left starting with the second character (so as to drop the first character off the end of the screen) and then insert the new character just before the terminating $76 (which over 30 operations per line * 24 lines)
or
And I'm thinking out loud here! Move each $76 one byte 'to the right' (i.e. increase the position in RAM by 1) and add in a new character where the $76 used to be. I suspect you would also have to move the start of D_FILE at the same time (increase it by 1). You would have to deal with the fact that eventually you will run out of RAM to move it into! :D

Hopefully that makes some measure of sense...

Re: Explain this behavior

Posted: Thu Oct 12, 2017 10:01 pm
by sirmorris
Fast horizontal scrolling will require a modified video routine, one which allows movement across a larger buffer. It's possible.

Re: Explain this behavior

Posted: Fri Oct 13, 2017 9:57 am
by siggi
Maybe Wilf's NOVA could be used for that?

http://www.user.dccnet.com/wrigter/inde ... va2005.htm
Wilf wrote: The most powerful feature of this program is the ability to create new Video
Display files located anywhere in memory. A variable number of character per
line, a variable number of lines per screen and the starting position (memory
address) of the screen are under program control.

The NOVA video routines create a window on the memory and this window can be
rapidly moved from one location to another by changing the OFFSET parameter.

Re: Explain this behavior

Posted: Fri Oct 13, 2017 3:12 pm
by monzamess
I'll check that out. I think I stumbled upon it earlier but maybe it will make more sense to me now. :)