Difference between revisions of "Programming:Hardware scrolling 2"
(No difference)
|
Revision as of 07:34, 27 October 2006
Drawing sprites on a hardware scrolling screen can often be slower, because of the way the CPC hardware "wraps" the screen.
Here are some ways to avoid it, and so you can use faster sprite drawing routines:
The "problem" occurs when you scroll the screen, the following addressess are horizontally next together, but in really they are not a simple "inc" away :(
So you have to handle these as special cases. If you do this a lot your sprite routines will be much slower.
&C7FF->&C000 &CFFF->&C800 &D7FF->&D000
Vertical Scroll Only
Adjust the screen dimensions so that the problem happens on the left side of the screen. Now you can use fast sprite routines to draw.
For this to work you need to ensure the width and height of the screen, when multiplied together equal 1024.
width (in chars)*height (in chars) = 1024.
One common screen size is 32 chars wide, 32 chars tall.
Now if you only scroll vertically you can avoid the problem completely. Ideal for vertical shoot em ups.
Horizontal Scroll Only
Limit the scroll so that you never encounter the problem.
The maximum scroll offset is: (1024-(width*height))
so that problem is in bottom right corner at maximum scroll offset.
With a screen size of 40 chars x20 chars, the maximum scroll offset is 224 chars. If you combine this with the register 3 trick (to scroll in byte sized increments), then you get up to 7 seconds of scroll:
(224 * 2)/60 = 7 seconds