Buffered image to screen dynamically?

I have written some code to convert (in this case) some VGA-rendered graphics for my emulator to the PSP's screen (sizes stored in PSP_SCREEN_ROWS and PSP_SCREEN_COLUMNS constants).

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
void psp_graphics_putpixel(int x, int y, uint_32 color) //Putpixel directly on screen!
{
  //if (GPU.showpixels) //We have stuff to see (valid video mode) and video is ON?
  //{
    //if (GPU.vram!=NULL) //Set?
    //{
      GPU.vram[(512*y)+x]=color; //Plot pixel to screen!
    //}
  //}
}

int convertrel(int src, int fromres, int tores)
{
gotoxy(0,4); //4th row debugging!
return (int)((((float)src/(float)fromres)*(float)tores)); //All res!
}

int single_refresh = 0; //Single refresh?

void int10_preparescreenpixels(); //Prototype for refreshscreen!

inline void GPU_defaultRenderer() //Default renderer (original, written by me)!
{
	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!
		{
			buffery = convertrel(pspy+1,PSP_SCREEN_ROWS,GPU.GPU_screenysize)-1; //Convert (bottom right)!
			bufferx = convertrel(pspx+1,PSP_SCREEN_COLUMNS,GPU.GPU_screenxsize)-1; //Convert (bottom right)!
			pixel = GPU.emu_screenbuffer[(buffery*1024)+bufferx]; //Get pixel from buffer!
			psp_graphics_putpixel(pspx,pspy,pixel); //Plot to screen!
		}
	}
}


The GPU.emu_screenbuffer is an array, which contains 1024 virtual pixels per row (less may be used, see GPU.screenxsize) and a maximum of 768 lines (ammount used stored in GPU.screenysize). (the definition of the GPU.emu screenbuffer:
uint_32 emu_screenbuffer[1024*768]; //All pixels! )

The default renderer is called every 1/60th second (@60Hz).

Is there a better way to do this (faster or more precise)?

I do notice that the screen may get a little pixellated when running on fullscreen with a higher resolution than the psp (stored in PSP_SCREEN_ROWS and PSP_SCREEN_COLUMNS) or it looks like somethings missing?

Or is there a better formula for doing this?

Btw the virtual width of the psp's vram (stored in a pointer in GPU.vram) is 512 pixels per row, if you're wondering; see psp_graphics_putpixel())
Last edited on
Topic archived. No new replies allowed.