GP2X Hardware Acceleration in Allegro

Credits

The hardware acceleration in GP2X Allegro is heavily based on paeryn's code for SDL. He did all the hard work!

What is accelerated

Acceleration is only supported in 8bpp and 16bpp modes; GP2X Allegro only supports those modes anyway, so that's OK.

Allegro uses 5Mb for video memory, and you can set a graphics mode with any virtual size you like subject to available memory.

To take advantage of hardware accelerated blitting, it's easiest to use video bitmaps. First create one the size of the visible screen (SCREEN_W x SCREEN_H), then use show_video_bitmap to ensure the screen is scrolled properly, and do all your drawing there. Then create additional video bitmaps for your sprites, etc, and use blit or draw_sprite as normal to draw them to your primary video bitmap.

You can combine that with page flipping by creating two screen-sized video bitmaps, and drawing to one while the other is visible, swapping which is which each frame.

Hardware Scrolling

If you're not using video bitmaps, you can scroll the visible screen around the virtual screen, but there's a 32-bit granularity so you're restricted to even X coordinates in 16bpp or multiples of 4 in 8bpp.

It's not trivial to combine this with using video bitmaps, though it can be done.

Example - Parallax Demo

I've uploaded an example which uses page flipped video bitmaps to take advantage of the hardware acceleration. It draws lots of layers of random pipe-like tiles, using accelerated masked blits or sprites or something, I don't totally remember!