This time i need something to scale the 16 bit image. I have absolutely no idea how to do this... and i've tried using google but cant seem to get any good results.
I am using pc.c/.h to blit my pictures (I would use the GU but i dont get it..) and i have already added alpha blending as an extra argument. Heres my function right now:
Code: Select all
#define rgb2col(r, g, b) ((((b>>3) & 0x1F)<<10)+(((g>>3) & 0x1F)<<5)+(((r>>3) & 0x1F)<<0)+0x8000)
#define getR( c ) ( (c & 0x1f) << 3 )
#define getG( c ) ( ((c >> 5) & 0x1f ) << 3 )
#define getB( c ) ( ((c >> 10) & 0x1f) << 3 )
...
void pgBitBlt(unsigned long x,unsigned long y,unsigned long w,unsigned long h,unsigned long mag,const unsigned short *d, int t)
{
unsigned char *vptr0; //pointer to vram
unsigned char *vptr; //pointer to vram
unsigned long xx,yy,mx,my;
const unsigned short *dd;
int rB, gB, bB, rS, gS, bS, new_r, new_g, new_b; //color thingys
vptr0=(unsigned)pgGetVramAddr(x,y);
for (yy=0; yy<h; yy++) {
for (my=0; my<mag; my++) {
vptr=vptr0;
dd=d;
for (xx=0; xx<w; xx++) {
for (mx=0; mx<mag; mx++) {
if (*dd != 0x3e0) {
if (t != 255) {
rB = getR(*(unsigned short *)vptr);
gB = getG(*(unsigned short *)vptr);
bB = getB(*(unsigned short *)vptr);
rS = getR(*dd);
gS = getG(*dd);
bS = getB(*dd);
new_r = rB + (((rS - rB) * t) / 256);
new_g = gB + (((gS - gB) * t) / 256);
new_b = bB + (((bS - bB) * t) / 256);
*(unsigned short *)vptr = rgb2col(new_r,new_g,new_b);
}
else {
*(unsigned short *)vptr = *dd;
}
}
vptr+=PIXELSIZE*2;
}
dd++;
}
vptr0+=LINESIZE*2;
}
d+=w;
}
}