(PSP1) Correct video_init function so that it is no longer reentrant

This commit is contained in:
twinaphex 2014-05-29 22:51:52 +02:00
parent 622ac28995
commit 94fbb99410

View File

@ -111,54 +111,41 @@ static void *psp_init(const video_info_t *video,
{
// to-do : add ASSERT() checks or use main RAM if VRAM is too low for desired video->input_scale
void *pspinput;
psp1_video_t *psp=driver.video_data;
if (!psp)
{
// first time init
psp = (psp1_video_t*)calloc(1, sizeof(psp1_video_t));
if (!psp)
goto error;
}
if(!psp->main_dList) // either first time init or psp_free was called
{
sceGuInit();
psp->main_dList = memalign(16, 256); // make sure to allocate more space if bigger display lists are needed.
psp->frame_dList = memalign(16, 256);
psp->rgui.dList = memalign(16, 256);
psp->rgui.frame = memalign(16, 2 * 480 * 272);
psp->frame_coords = memalign(64, 1 * sizeof(psp1_sprite_t));
psp->rgui.frame_coords = memalign(64, 16 * sizeof(psp1_sprite_t));
memset(psp->frame_coords , 0, 1 * sizeof(psp1_sprite_t));
memset(psp->rgui.frame_coords , 0, 16 * sizeof(psp1_sprite_t));
sceKernelDcacheWritebackInvalidateAll();
psp->frame_coords = TO_UNCACHED_PTR(psp->frame_coords);
psp->rgui.frame_coords = TO_UNCACHED_PTR(psp->rgui.frame_coords);;
psp->frame_coords->v0.x = 60;
psp->frame_coords->v0.y = 0;
psp->frame_coords->v0.u = 0;
psp->frame_coords->v0.v = 0;
psp->frame_coords->v1.x = 420;
psp->frame_coords->v1.y = SCEGU_SCR_HEIGHT;
psp->frame_coords->v1.u = 256;
psp->frame_coords->v1.v = 240;
}
psp->vsync = video->vsync;
psp->rgb32 = video->rgb32;
int pixel_format, lut_pixel_format, lut_block_count;
unsigned int red_shift, color_mask;
void *displayBuffer, *LUT_r, *LUT_b;
psp1_video_t *psp = (psp1_video_t*)calloc(1, sizeof(psp1_video_t));
if (!psp)
return NULL;
sceGuInit();
psp->main_dList = memalign(16, 256); // make sure to allocate more space if bigger display lists are needed.
psp->frame_dList = memalign(16, 256);
psp->rgui.dList = memalign(16, 256);
psp->rgui.frame = memalign(16, 2 * 480 * 272);
psp->frame_coords = memalign(64, 1 * sizeof(psp1_sprite_t));
psp->rgui.frame_coords = memalign(64, 16 * sizeof(psp1_sprite_t));
memset(psp->frame_coords , 0, 1 * sizeof(psp1_sprite_t));
memset(psp->rgui.frame_coords , 0, 16 * sizeof(psp1_sprite_t));
sceKernelDcacheWritebackInvalidateAll();
psp->frame_coords = TO_UNCACHED_PTR(psp->frame_coords);
psp->rgui.frame_coords = TO_UNCACHED_PTR(psp->rgui.frame_coords);;
psp->frame_coords->v0.x = 60;
psp->frame_coords->v0.y = 0;
psp->frame_coords->v0.u = 0;
psp->frame_coords->v0.v = 0;
psp->frame_coords->v1.x = 420;
psp->frame_coords->v1.y = SCEGU_SCR_HEIGHT;
psp->frame_coords->v1.u = 256;
psp->frame_coords->v1.v = 240;
psp->vsync = video->vsync;
psp->rgb32 = video->rgb32;
if(psp->rgb32)
{
@ -215,7 +202,6 @@ static void *psp_init(const video_info_t *video,
}
sceDisplayWaitVblankStart(); // TODO : check if necessary
sceGuDisplay(GU_FALSE);
@ -241,8 +227,6 @@ static void *psp_init(const video_info_t *video,
pspDebugScreenSetColorMode(pixel_format);
pspDebugScreenSetBase(psp->draw_buffer);
// fill frame_dList :
sceGuStart(GU_CALL, psp->frame_dList);
@ -275,7 +259,6 @@ static void *psp_init(const video_info_t *video,
*input_data = pspinput;
}
return psp;
error:
RARCH_ERR("PSP1 video could not be initialized.\n");