PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

fast custom blit question

I'm developing a tile-based, zoomable, and rotatable blitter for a game. I have it working, but I'm wondering if there may be a quicker way to blit my pixels.

Currently, I use the following pseudo code:

Code:
display->GetBackBuffer()->Lock( screen );

for(y=0...)
{
Pixel aline = &(screen.pixels[y]); //pointer to first pixel in row.
for(x=0...)
{
*(aline++) = PixelCalc(...) //set pixel value
...
}
}

display->GetBackBuffer()->Unlock();


This works well on a toshiba (30 fps), but gets really bad results (10 fps) on an older iPaq (seems like I saw something about the screen memory being laid out differently).

Any ideas on how to make the blitting quicker? The actual code is a bunch of pointer math using fixed point float code. I can post a demo at the file exchange if anyone is interested.

Jason
Have you checked if your bootleneck is really the pixel plotting? maybe a better focus for the optimization would be the calculations required for the zoom, rotation, etc.
fast_rx:

1. Check abs(xpitch) and abs(ypitch). if ypitch is less, swap x and y pitch (and width and height).
2. Check xpitch and ypitch. If negative, invert and adjust buffer pointer.

both gapidraw & pocketfrog does this internally before blitting.
I'm a little confused by the xpitch and ypitch items. At the level I'm at - using a locked surface - the only thing I can get to is the "Surface::LockInfo::pitch" value. This doesn't appear to be what you're talking about as it's only a single value that is 480 on both devices. I searched for xpitch and it is only used in the GAPILibrary functions as far as I can tell.
Your old iPAQ probably has a different screen orientation then your application. Ex: iPAQ 36xx has a "landscape" native orientation and your app is "normal".

PocketFrog currently will have to rotate the entire backbuffer each time you Lock() or Unlock() it. This is why you get a performance problem.

The next version of PF won't have this issue.

PF already has an efficient rotatable blitter built-in. It currently doesn't support zooming at the same time, but this can be easily added by adjusting the transform matrix inside Rasterizer::BlitRotated(). In fact, the low-level code is a really generic texture mapper.