Last modified on 30 October 2006, at 08:50

Programming:Hardware scrolling 2

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 that 1024 is exactly divisible by the width. 1024 is the maximum scroll offset which can be programmed to register 12 and 13 of the crtc.

One common screen size is 32 chars wide.

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 if you scroll every frame:

(224 * 2)/60 = 7 seconds

Otherwise you get 224/40 = 5 screens which can be scrolled