1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#define DIVIDED(v,n) (byte)SAFEDIV((double)v,(double)n)
#define AVGRGB(r,g,b,n) RGB(DIVIDED(r,n),DIVIDED(g,n),DIVIDED(b,n))
#define CONVERTREL(src,srcfac,dest) SAFEDIV((double)src,(double)srcfac)*(double)dest
void GPU_fullRenderer()
{
if (!(GPU.GPU_screenxsize|GPU.GPU_screenysize)) //Nothing to render?
{
memset(GPU.psp_screenbuffer,0,PSP_SCREENBUFFERSIZE*4); //Unknown resolution to buffer!
return; //Done rendering!
}
word x1,y1,x2,y2; //Buffer start&end!
word y,x; //X&Y in the emulated screen!
uint_32 r,g,b; //RGB seperated sum values!
uint_32 pixels; //Ammount of pixels to process
//Since we have something to render, render it!
int pspy,pspx; //psp x&y!
double xfactor = (1/PSP_SCREEN_COLUMNS)*GPU.GPU_screenxsize;
double yfactor = (1/PSP_SCREEN_ROWS)*GPU.GPU_screenysize;
byte *pixel; //Current pixel A, B, G, R data!
for (pspy=0;pspy<PSP_SCREEN_ROWS;pspy++) //Process row!
{
for (pspx=0;pspx<PSP_SCREEN_COLUMNS;pspx++) //Process column!
{
//Calculate our buffer min/max coordinates!
x1 = pspx*xfactor; //Current x
y1 = pspy*yfactor; //Current y
x2 = (pspx+1)*xfactor; //Next x
y2 = (pspy+1)*yfactor; //Next y
pixels = (y2-y1)*(x2-x1); //Ammount of pixels we count for!
r=g=b=0; //Reset RGB!
//Calculate total ammount of pixels!
for (y=y1;y<y2;) //Process all rows we represent in our pixel!
{
for (x=x1;x<x2;) //Loop for each pixel!
{
pixel = ((byte *)&EMU_BUFFER(x,y))+1; //Load our pixel, skip A!
b += *pixel++; //Add B!
g += *pixel++; //Add G!
r += *pixel; //Add R, don't increase, because we're the final byte!
++x; //Next pixel!
}
++y; //Next row!
}
PSP_BUFFER(pspx,pspy) = RGB(r/pixels,g/pixels,b/pixels); //RGB value of all pixels combined!
}
}
}
|