void gp_drawSpriteHT( u16 *sprite, short put_x, short put_y, u16 *framebuffer, u16 trans) {
int xx,yy,i=0;
SHEADER *sheader;
u16 color;
sheader = (SHEADER*) sprite;
// loop through every single pixel in the sprite
for (yy=0; yy<(sheader->size_y); yy++)
for (xx=0; xx<(sheader->size_x); xx++) {
color = sprite[6+i++];
if ( color != trans )
setpixel(put_x+xx,put_y+yy,color,framebuffer);
}
}
void setpixel(short x, short y, u16 color, u16 *framebuffer ) {
if ( !((x<0) || (x>319) || (y<0) || (y>239)) )
gp_drawPixel16(x,y,color,framebuffer);
}
1) I use 8 bit for YAFL because fxe icons are 8 bit and it makes things easier to just use a standard 8 bit display (I may change to 16 bit in the next version though - it's something I'm thinking about at the moment), and my games are 8 bit because I can't draw so it makes sense to only use about 5 colours .1) If the difference between 8 and 16 bit is not that great, why do many people still use 8 bit for their games and launchers etc?
2) Sorry for the newbie Q, but in which direction does the LCD data go? Bottom left as 0,0 in vertical rows?
The code is available from http://www.cs.helsinki.fi/u/jikorhon/condev/gp32/ (click download, then scroll down to the source code area)Mr.Spiv - is it possible to get the code for your sprites example? (stuff@_NO_SPAM_pixelthis.co.nz - remove _NO_SPAM_ )
/*
* Same as the Mirko SDK function but uses real screen coords
* and rotatet sprite data like the official SDK.
* You can create this format with dalto's Imageconverter
*/
void syn_drawSpriteHT(unsigned short *sprite, int put_x, int put_y, u16 *framebuffer,
unsigned short trans)
{
int xx, yy, tempx, tempy, offset, i = 0;
unsigned short color;
SHEADER *sprite_header = (SHEADER*) sprite;
for (xx=0; xx<(sprite_header->size_x); xx++)
{
tempx = put_x + xx;
// cut sprite on the left and right
if((tempx>319) || (tempx<0))
{
i += sprite_header->size_y;
continue;
}
offset = tempx * 240;
for (yy=0; yy<(sprite_header->size_y); yy++)
{
color = sprite[6+i++];
// check for transparency
if(!(color - trans))
continue;
tempy = put_y + yy;
// cut sprite on the top and bottom
if( !( ((tempy<0) || (tempy>239)) ))
*(framebuffer + tempy + offset) = color;
}
}
}
/*
* Anamorphic Sprite Scaling (synlib)
*
* Scales and draws a sprite with header, transparency
* STILL BUGGY! DOES NOT WORK WITH ALL SPRITES!
*
* u16* sprite sprite data with header
* short put_x [0-319] x-pos on screen
* short put_y [0-239] y-pos on screen
* short size_x [0-...] desired width in pixel
* short size_y [0-...] desired height in pixel
* u16* buffer sprite destination
* u16 trans transparent color, 16bit
*/
void syn_scaleSpriteH(unsigned short *sprite, short put_x, short put_y, short size_x,
short size_y, unsigned short *framebuffer)
{
SHEADER* sheader = (SHEADER*) sprite;
short src_x_size = sheader->size_x;
short src_y_size = sheader->size_y;
unsigned short color;
int sx, sy, dy, dx;
int temp_x, temp_y, offset;
for(dx=0; dx<size_x; dx++)
{
sx = ((dx*src_x_size) / size_x);
temp_x = dx + put_x;
// cut sprite on the left and right
if((temp_x>319) || (temp_x<0))
continue;
for(dy=0; dy<size_y; dy++)
{
sy = ((dy*src_y_size) / size_y);
color = sprite[6+(sx*src_x_size)+sy];
temp_y = dy + put_y;
offset = temp_x * 240;
if( !((temp_y<0) || (temp_y>239)) )
*(framebuffer + temp_y + offset) = color;
}
}
}
typedef struct tGPD_canvas{
int width; // width of sprite (actual width before rotation)
int height; // height of sprite data (actual height before rotation)
unsigned short *data; // pointer to rotated sprite data (should be width*height in length)
}tGPD_canvas;