GP32 Screen Layout


Arnout

Still Fresh
Joined
Feb 16, 2004
Messages
51
To optimize some code I though of writing my own "blit" routines.
But somehow I can't figure out how the physical screen is organised.

Code used, but doesn't look the same when I simply use GpBitBlt

Code:
dest=gpDraw[nflip].ptbuffer;
bg=background;
for(y=0;ymax<240;y++) {
  for(x=0;x<320;x++){
    /* formula to convert to physical screen layout */
    *(dest+x*240 + 240-1-y)=*(bg++);
  }
}

This is the screen you would expect, same layout as a 320x240 image
Code:
0,0              319,0
 +------------------+
 |                  |
 |                  |
 |                  |
 +------------------+
0,239            319,239
But it doesn't seem to be :unsure:

[edit]Corrected the image coordinates[/edit]
 
the physical screen acts like a 240 width by 320 length rotated left 90 degrees. cconfusing. so bottom left of the screen is pixel zero, going up to top left is 239, all the way to top right is the last pixel. is that what you mean? i have had a few problems with this...

oh and something else i found out is that it looks like if you use the API blitting the image must be a multiple of 4 bytes else each line needs padding with 0s. (no diferent if you are blitting a whole background tho)


sam
 
So this is the idea?:

Code:
0,0              319,0
 +------------------+
 |                  |
 |     IMAGE        |
 |                  |
 +------------------+
0,239            319,239


0,0              0,239
 +------------------+
 |                  |
 |   GP32 PHYSICAL  |
 |                  |
 +------------------+
319,0            319,239
 
Finally!

I was also using GP32Convert to convert my BMP to .h
It seems that GP32Convert also changes to dimensions of the image.

At the end I used this loop to copy a 320x240 BMP to the current screen:
Code:
dest=gpDraw[nflip].ptbuffer;
bg=background; /* from background.h */
for(x=0; x<320; x++, dest+=SCREEN_HEIGHT)
  for(y=0; y<240; y++)
    *(dest+y)=*(bg++);
 
Back
Top