These techniques for scrolling may not be the fastest or easiest way to do scrolling, so if you have any better techniques or think you've got a good idea, mail me and I'll check it out.
Index :
Horizontal ScrollingFirst, I'll start with simple two way single-layered horizontal scrolling. Using this method, a bitmap can be scrolled from one end to another, or it can be wrapped around so that the player can go in a direction indefinitely. The method I know is to draw the bitmap on the screen in two halves, by keeping track of a split counter. This counter stores the width of the left half of the bitmap, so the width of the right half is equal to the total bitmap width minus the left half. The trick to use here is to draw the left half of the bitmap on the right half of the screen and similarly, the right half of the bitmap on the left half of the screen. The following diagram shows what I mean:

Ok. Now you'll see that if we decrease the split and so descrease the width of the left half, the image on the screen will move to the right by the amount the plit was decreased by. If you don't believe me, then try it for yourself.
Of course, you can make the bitmap dimensions bigger than the screen size, but I'll leave the coding up to you (I'm lazy). A simple function to draw a scrolling bitmap (not transparent) is as follows:
void draw_layer_opaque (char *image, int starty, int height, int split)
/* width of image must be same as screen (320 in this case) */
{
int count;
dest = video_buffer + starty*320;
for (count=0;count<height;count++) {
memcpy(dest,image+320-split,split);
image+=320;
dest+=320;
Now to use this function in a scrolling demo, simply decrease the split (width of the left half) if the right arrow is pressed and increase the split if the left arrow is pressed. There, you have scrolling.
Parallax scrolling is when multiple layers of graphics scrolling at different rates to give the impresion of distance and perspective. The simplest case is where the background is further away than the foreground (say the sky) and so moves alot slower than the foreground bitmap. This is achieved in exactly the same way as above, but there is two layers instead of one. Also, you need to be able to draw the second bitmap layer with transparent pixels if needed. This is what really slows it down, having to check for transparent pixels in the bitmap. Of course, to get any decent speed, you'll have to write the drawing functions in assembly. I guess I'll do that eventually (I avoid it as much as I can) and put them here as well as some sort of demo program.
A problem with the above repeated scrolling methods is that you need alot of memory to store the whole bitmap image. One approach to solving this is to use tiled bitmaps. So, these tiles are joined together in such a way as to produce one big bitmap, but should be designed so that the tiles are used in many different places (such as a tile showing some grass or a tile of water etc). I'm sure you know what I mean. If you don't go and have a close look at alot of games out there such as : Dune II, Command & Conquer, Red Alert, Warcraft I&II, and many more I can't think of. This way, the amount of memory needed is the total of all the DIFFERENT tiles and the tile look up table which would only be about one or two bytes for every tile in the big virtual bitmap.
For speed and simplicity reasons, the dimensions of the tiles should be a power of two and an integer fraction of the screen width. Now, to draw a segment of the big virtual bitmap, you should notice that at any stage there would be only two partial tiles in any given row (for two-way horizontal scrolling) - The tiles at the beginning and at the end of the row. These tiles could be partially clipped by the edge of the screen. However, some games (such as Dune II) never have to worry about this because it increments the positions of the screen by an amount equal to the dimensions of the tiles. This is faster and easier but doesn't look quite as nice (It doesn't really worry me though). So, to draw a row of tiles you have to draw the first (possibly partial) tile; draw the next several tiles and then draw the last (possible partial) tile.
I'll have some code and a demo program here sometime soon.
This is just an extension of the above methods. Everything I said about horizontal scrolling is used again to implement vertical scrolling. Then, for diagonal scrolling simply scroll a bit horizontally and a bit vertically.
Might have some code and a demo program if I get time, but I think if I do the above ones then that will be enough.