/*
* 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;
}
}
}