GP32 Scrolling Up By 8 Pixels


SvOlli

Certified Guru
Joined
May 4, 2004
Messages
161
Location
Hannover, Germany
Website
svolli.org
Hello!

I'm writing my own font library for a derivate of the official SDK, since the original one blows the code up too much, imho and I prefer using 8x8 pixel fonts (there are so much to choose from the C64 :) ). Right now I'm almost finished for the first release, there's just one thing missing. The lib includes a console for putting out debug messages. If you get past the "last" line on screen, I want to scroll the whole buffer up by 8 pixels to make room for the next message. With Mr.Mirko's SDK I'd do 320 DMAs to move the buffer, or copy the pixels `by hand'. But the official SDK hides the address of the framebuffer somewhere in the GPDRAWSURFACE structure, and I haven't found something like GpPixelGet(). So I'm rather clueless right now on how to do it. Could anyone provide me with a useful hint?

Thanks in advance,
SvOlli
 
I needed a similar function, but for a 10 pixel font with a 2 pixel gap between each line. After a lot of profiling and benchmarking, I found the following to be the fastest way of doing it:

void VScroll (unsigned char *screen)
{
int yp = 214;
int x;

while (yp > 0)
{
for (x = 0; x < 320; x ++)
{
unsigned short *d = (unsigned short *) &screen[(x*240)+yp+12];
unsigned short *s = (unsigned short *) &screen[(x*240)+yp+0];

*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
*d = *s;
}
if (yp < 12) break;
yp -= 12;
}
}

DMA for such a small amount of data is a really inefficient way of doing it. You'll spend more time setting up the registers than actually copying data.

This is how to call the above:

static GPDRAWSURFACE gpDraw;

GpLcdSurfaceGet(&gpDraw, 0);
VScroll(gpDraw.o_buffer);

You should be easily able to convert it to 8 pixel scrolling.
 
Thanks Squidge!

That did it. My code looks now rather different from yours, but the idea behind it is still the same. Why are you copying shorts instead of longs? Right from the feeling I'd say longs should be faster.

Anyway, the result is available at http://svolli.dynxs.de/gp32/

Thanks to you both,
SvOlli

P.S.: Does anyone know the difference between gpDraw.ptbuffer and gpDraw.o_buffer?
 
I think I had a problem with longs for some reason, so I used shorts. No idea what the problem was now.
 
Back
Top