From 170bcb967fbd8b3a1232477ac5a02e5bd4c8bc48 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Sun, 16 Feb 2014 20:52:14 +0100 Subject: [PATCH] (PSP) added RGB to BGR color conversion in psp_frame --- psp1/psp1_video.c | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/psp1/psp1_video.c b/psp1/psp1_video.c index 9c7f0491d5..438487e01c 100644 --- a/psp1/psp1_video.c +++ b/psp1/psp1_video.c @@ -53,6 +53,7 @@ typedef struct psp1_vertex static unsigned int __attribute__((aligned(16))) list[262144]; + static void init_texture(void *data, const video_info_t *video) { psp1_video_t *psp = (psp1_video_t*)data; @@ -130,30 +131,58 @@ static bool psp_frame(void *data, const void *frame, (void)height; (void)pitch; (void)msg; + int x,y; psp1_video_t *psp = (psp1_video_t*)data; - pitch= pitch/(psp->rgb32 ? 4 : 2); + if(!frame) return true; - + + void* g_texture = (void*) (0x44110000); // video memory after draw+display buffers + if (psp->rgb32){ + pitch/=4; + u32* out_p=(u32*)g_texture ; + u32* in_p=(u32*)frame; + for ( y=0;y>16); + in_p++; + out_p++; + } + in_p+=pitch-width; + } + }else{ + pitch/=2; + u16* out_p=(u16*)g_texture; + u16* in_p=(u16*)frame; + for ( y=0;y>11); + in_p++; + out_p++; + } + in_p+=pitch-width; + } + + } + + sceGuStart(GU_DIRECT, list); sceGuClear(GU_COLOR_BUFFER_BIT); psp1_vertex_t* v = sceGuGetMemory(2*sizeof(psp1_vertex_t)); v[0].x=(SCEGU_SCR_WIDTH-width*SCEGU_SCR_HEIGHT/height)/2; v[0].y=0; - v[0].u=2; + v[0].u=0; v[0].v=0; v[1].x=(SCEGU_SCR_WIDTH+width*SCEGU_SCR_HEIGHT/height)/2; v[1].y=(SCEGU_SCR_HEIGHT); - v[1].u=width+2; + v[1].u=width; v[1].v=height; - sceKernelDcacheWritebackInvalidateAll(); - //could be unsafe , TODO: replace with sceGuTexImage(0,next_POT(width),next_POT(height),pitch,frame); - sceGuTexImage(0,pitch,pitch,pitch,frame); + sceGuTexImage(0,256,256,width,g_texture); sceGuDrawArray(GU_SPRITES,GU_TEXTURE_16BIT|GU_COLOR_5650|GU_VERTEX_16BIT|GU_TRANSFORM_2D,2,NULL,v); sceGuFinish();