(PSP) add missing screenshot function.

This commit is contained in:
aliaspider 2015-03-06 22:27:06 +01:00
parent 9eb2c8725f
commit c708453f06

View File

@ -871,6 +871,81 @@ static bool psp_read_viewport(void *data, uint8_t *buffer)
{
(void)data;
(void)buffer;
psp1_video_t *psp = (psp1_video_t*)data;
uint8_t* dst = buffer;
void* src_buffer;
int i, j, src_bufferwidth, src_pixelformat, src_x, src_y, src_x_max, src_y_max;
sceDisplayGetFrameBuf(&src_buffer, &src_bufferwidth, &src_pixelformat, PSP_DISPLAY_SETBUF_NEXTFRAME);
src_x = (psp->vp.x > 0)? psp->vp.x : 0;
src_y = (psp->vp.y > 0)? psp->vp.y : 0;
src_x_max = ((psp->vp.x + psp->vp.width) < src_bufferwidth)? (psp->vp.x + psp->vp.width): src_bufferwidth;
src_y_max = ((psp->vp.y + psp->vp.height) < SCEGU_SCR_HEIGHT)? (psp->vp.y + psp->vp.height): SCEGU_SCR_HEIGHT;
switch(src_pixelformat)
{
case PSP_DISPLAY_PIXEL_FORMAT_565:
for (j = (src_y_max - 1); j >= src_y ; j--)
{
uint16_t* src = (uint16_t*)src_buffer + src_bufferwidth * j + src_x;
for (i = src_x; i < src_x_max; i++)
{
*(dst++) = ((*src) >> 11) << 3;
*(dst++) = (((*src) >> 5) << 2) &0xFF;
*(dst++) = ((*src) & 0x1F) << 3;
src++;
}
}
return true;
case PSP_DISPLAY_PIXEL_FORMAT_5551:
for (j = (src_y_max - 1); j >= src_y ; j--)
{
uint16_t* src = (uint16_t*)src_buffer + src_bufferwidth * j + src_x;
for (i = src_x; i < src_x_max; i++)
{
*(dst++) = (((*src) >> 10) << 3) &0xFF;
*(dst++) = (((*src) >> 5) << 3) &0xFF;
*(dst++) = ((*src) & 0x1F) << 3;
src++;
}
}
return true;
case PSP_DISPLAY_PIXEL_FORMAT_4444:
for (j = (src_y_max - 1); j >= src_y ; j--)
{
uint16_t* src = (uint16_t*)src_buffer + src_bufferwidth * j + src_x;
for (i = src_x; i < src_x_max; i++)
{
*(dst++) = ((*src) >> 4) & 0xF0;
*(dst++) = (*src) & 0xF0;
*(dst++) = ((*src) << 4) & 0xF0;
src++;
}
}
return true;
case PSP_DISPLAY_PIXEL_FORMAT_8888:
for (j = (src_y_max - 1); j >= src_y ; j--)
{
uint32_t* src = (uint32_t*)src_buffer + src_bufferwidth * j + src_x;
for (i = src_x; i < src_x_max; i++)
{
*(dst++) = ((*src) >> 16) & 0xFF;
*(dst++) = ((*src) >> 8 ) & 0xFF;
*(dst++) = (*src) & 0xFF;
src++;
}
}
return true;
}
return false;
}