: What's the fastest way to do parallax scrolling in a 16-bit 640x480 graphics mode, using Allegro (DOS)? The game that I'm writing (a platform game) uses two parallax scrolling layers plus 3 "normal" layers, and it's too slow to redraw the whole screen using a double buffer every frame (I only get 20 fps on my P2-233 MMX with a cheap Cirrus Logic 5446 video card, with 2MB of VRAM, without music or even enemies.) The only way to get my game to run at a decent speed right now is to drop frames (it's choppy, but at least it's playable). I could try to use 8-bit mode instead, but I designed my graphics to work in 16-bit, and I don't really want to deal with the inevitable pallete problems - together, some of the background and foreground graphics use as much as 27,000 colors. I will if I absolutely have to, though, because I care more about the gameplay than what the graphics look like... but part of the reason I used 16-bit in the first place was to make my game engine more flexible (and forward compatible with future games I might write) - it's designed to be added onto in just about every respect including levels, graphics, and music. It's easier to do this without having to deal with palletes. I could also just live with the choppy framerate, but imagine what it would be like on a slower system. I could also drop the parallax backgrounds, but I want to do that even less than converting my game to 8-bit (they add a lot of feel to the game). Any ideas to make this run faster (40-60 fps)? Or is this really just too much for the computer (and video card) to handle? Dirty rectangles probably wouldn't work too well, since everything on the screen scrolls. Hardware acceleration might, but the VBE/AF drivers don't work right with my card (I can get into the mode, but blitting doesn't work right), and not everybody has hardware accelerated drivers anyway.<p>
That type of game is very difficult to pull off without hardware acceleration. I'd suggest jumping to Windows (bleh), which does support hardware accel, because I can't imagine more than 2% of DOS users have VBE/AF drivers. Faster CPUs don't do much since they still have to wait for memory, and the ever-so-slow video memory. An average video card software throughput is probably around 40MB/sec, but I've seen between 8MB/sec and 96MB/sec. Just calc how much time it takes to copy the double buffer alone (614KB). On average (40MB/sec), just doing that will already be limited to about 70FPS. High color action games are not feasable without hardware accel(or some really good tricks). I'd suggest trying to draw directly to a back video surface, and using page flipping. In your scenario it may not be better because you're re-drawing alot of the frame, but in general its faster than double buffering.<p>
One thing to try if you have a PPro or PII, is to get the FastVid utility from www.fastgraphics.com. It can GREATLY speed up software access to video buffers by optimizing the cache writes, and also some write posting stuff. These systems can actually run SLOWER than Pentium systems by default. Speeds up older PPro systems mainly. (My game runs great on my P200, but was horrible on my friend's PII450. Finally, after quite a long time, I found that was the problem. My video card wrote about 45MB/sec, and his only did 13MB/sec. With the utility, his now does around 45MB/sec also. It is a kick-butt little program)<p>
Also, Allegro is not going to cut it for this type of performance. The Win version may be OK, since it uses DirectX, but the software DOS version just isn't fast enough. Ideally, you should allow the user the choice of 8 or 16 bit color too. But 8 bit color is not that bad. If you want software drawing, you're going to have to accept it, or put LOTS of time trying to create a drawing scheme that will work front-to-back so as not to keep redrawing over background layers with foreground layers.<p>
If you're a glutton for punishment, and your foreground layers aren't terribly large, you may want to look into hardware scrolling. It isn't really supported by Allegro (it is, but but its somewhat different and limited), so you'll have to write your own VESA graphics driver to do this. NOT an easy thing to do. <p>
Bottom line is, your trying to make a very professional game, but you've said that you're basically a beginner. To get this to run well in your described system, you must use some advanced techniques, some of which will require assembly. It will be FAR from easy.<p>
Rock