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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
//Give the pixel from our rendering!
#define GPU_GETPIXEL(x,y) GPU.emu_screenbuffer[(y*1024)+x]
int single_refresh = 0; //Single refresh?
void int10_preparescreenpixels(); //Prototype for refreshscreen!
//Pull apart!
#define GETRED(fullcolor) (fullcolor&0xFF)
#define GETGREEN(fullcolor) ((fullcolor&0xFF00)>>8)
#define GETBLUE(fullcolor) ((fullcolor&0xFF0000)>>16)
#define GETTRANS(fullcolor) ((fullcolor&0xFF000000)>>24)
//Or together!
#define RGBRED(red) (red)
#define RGBGREEN(green) (green<<8)
#define RGBBLUE(blue) (blue<<16)
#define RGBTRANS(trans) (trans<<24)
//So simple: RGBA
#define RGBA(trans,red,green,blue) (RGBTRANS(trans)|RGBRED(red)|RGBGREEN(green)|RGBBLUE(blue))
inline uint_32 fuse_pixelarea(word x1, word y1, word x2, word y2) //Fuse an area together into 1 pixel!
{
word x,y; //Current coordinates!
uint_32 numpixels = (((x2-x1)+1)*((y2-y1)+1)); //Ammount of pixels!
float pixelfactor = (256/numpixels); //Factor for each pixel!
float r=0;
float g=0;
float b=0; //Our total rgb value!
float a=0; //Transparency!
uint_32 buffer;
for (x=x1;x<=x2;x++)
{
for (y=y1;y<=y2;y++)
{
buffer = GPU_GETPIXEL(x,y); //The pixel!
r += GETRED(buffer)*pixelfactor; //Add red!
g += GETGREEN(buffer)*pixelfactor; //Add green!
b += GETBLUE(buffer)*pixelfactor; //Add blue!
a += GETTRANS(buffer)*pixelfactor; //Add transparency!
}
}
byte r2,g2,b2,a2;
r2 = (((int)(r)>>8)&0xFF); //R
g2 = (((int)(g)>>8)&0xFF); //G
b2 = (((int)(b)>>8)&0xFF); //B
a2 = (((int)(a)>>8)&0xFF); //A
return RGBA(a2,r2,g2,b2); //RGB value of all pixels combined!
}
inline void GPU_defaultRenderer() //Default renderer (original, written by me)!
{
uint_32 pixel;
int bufferxend; //Buffer's x!
int bufferyend; //Buffer's y!
int bufferxstart; //Buffer's x start!
int bufferystart; //Buffer's y start!
int pspx;
int pspy; //psp x&y!
for (pspy=0; pspy<PSP_SCREEN_ROWS; pspy++) //Process row!
{
for (pspx=0; pspx<PSP_SCREEN_COLUMNS; pspx++) //Process column!
{
bufferystart = convertrel(pspy,PSP_SCREEN_ROWS,GPU.GPU_screenysize); //Convert (upper left)!
bufferxstart = convertrel(pspx,PSP_SCREEN_COLUMNS,GPU.GPU_screenxsize); //Convert (upper left)!
bufferyend = convertrel(pspy+1,PSP_SCREEN_ROWS,GPU.GPU_screenysize)-1; //Convert (bottom right)!
bufferxend = convertrel(pspx+1,PSP_SCREEN_COLUMNS,GPU.GPU_screenxsize)-1; //Convert (bottom right)!
//pixel = GPU_GETPIXEL(bufferxend,bufferyend); //Get pixel from buffer: bottom right!
pixel = fuse_pixelarea(bufferxstart,bufferystart,bufferxend,bufferyend); //TODO: Combine pixels from upper left to bottom right together!
psp_graphics_putpixel(pspx,pspy,pixel); //Plot to screen!
}
}
}
|