typedef struct {
u16 *source_img;
short source_x;
short source_y;
u16 width;
u16 height;
u16 trans;
} tSprite;
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);
}
void SetSprite(tSprite *sprite,u16 *source_img,u16 trans,short source_x,short source_y,short width,short height)
{
sprite->source_img=source_img;
sprite->source_x=source_x;
sprite->source_y=source_y;
sprite->width=width;
sprite->height=height;
sprite->trans=trans;
}
void PutSprite(tSprite sprite,float plotx, float ploty,u16 *framebuffer)
{
int y,x;
for (y=sprite.source_y;y<sprite.height+sprite.source_y;y++)
for (x=sprite.source_x;x<sprite.width+sprite.source_x;x++)
{
if (sprite.source_img[6+x+(y*320)] != sprite.trans) setpixel(x-sprite.source_x+plotx,y-sprite.source_y+ploty, sprite.source_img[6+x+(y*320)], framebuffer);
}
}