X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=frontend%2Flibretro.c;h=66175afa20b9f5f51ec6de000a6c086dfeb3cb19;hb=65a0505f57d57ddedb89e3c66734fb3b0a69e1e8;hp=559406286deb0fbb6829ea1cdc66b5af76c6bf03;hpb=73081f238a4d80891cf9df5aebeebe3d13c84144;p=pcsx_rearmed.git diff --git a/frontend/libretro.c b/frontend/libretro.c index 55940628..66175afa 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -47,6 +47,7 @@ static retro_audio_sample_batch_t audio_batch_cb; static struct retro_rumble_interface rumble; static void *vout_buf; +static void * vout_buf_ptr; static int vout_width, vout_height; static int vout_doffs_old, vout_fb_dirty; static bool vout_can_dupe; @@ -133,14 +134,14 @@ static void convert(void *buf, size_t bytes) static void vout_flip(const void *vram, int stride, int bgr24, int w, int h) { - unsigned short *dest = vout_buf; + unsigned short *dest = vout_buf_ptr; const unsigned short *src = vram; int dstride = vout_width, h1 = h; int doffs; if (vram == NULL) { // blanking - memset(vout_buf, 0, dstride * h * 2); + memset(vout_buf_ptr, 0, dstride * h * 2); goto out; } @@ -148,7 +149,7 @@ static void vout_flip(const void *vram, int stride, int bgr24, int w, int h) doffs += (dstride - w) / 2 & ~1; if (doffs != vout_doffs_old) { // clear borders - memset(vout_buf, 0, dstride * h * 2); + memset(vout_buf_ptr, 0, dstride * h * 2); vout_doffs_old = doffs; } dest += doffs; @@ -171,7 +172,7 @@ static void vout_flip(const void *vram, int stride, int bgr24, int w, int h) out: #ifndef FRONTEND_SUPPORTS_RGB565 - convert(vout_buf, vout_width * vout_height * 2); + convert(vout_buf_ptr, vout_width * vout_height * 2); #endif vout_fb_dirty = 1; pl_rearmed_cbs.flip_cnt++; @@ -281,15 +282,16 @@ psx_map_t custom_psx_maps[] = { int init_vita_mmap(){ int n; + void * tmpaddr; addr = malloc(64*1024*1024); if(addr==NULL) return -1; - addr = ((u32)(addr+0xFFFFFF))&~0xFFFFFF; - custom_psx_maps[0].buffer=addr+0x2000000; - custom_psx_maps[1].buffer=addr+0x1800000; - custom_psx_maps[2].buffer=addr+0x1c00000; - custom_psx_maps[3].buffer=addr+0x0000000; - custom_psx_maps[4].buffer=addr+0x1000000; + tmpaddr = ((u32)(addr+0xFFFFFF))&~0xFFFFFF; + custom_psx_maps[0].buffer=tmpaddr+0x2000000; + custom_psx_maps[1].buffer=tmpaddr+0x1800000; + custom_psx_maps[2].buffer=tmpaddr+0x1c00000; + custom_psx_maps[3].buffer=tmpaddr+0x0000000; + custom_psx_maps[4].buffer=tmpaddr+0x1000000; #if 0 for(n = 0; n < 5; n++){ sceClibPrintf("addr reserved %x\n",custom_psx_maps[n].buffer); @@ -1482,8 +1484,21 @@ void retro_run(void) stop = 0; psxCpu->Execute(); + + struct retro_framebuffer fb = {0}; + + fb.width = vout_width; + fb.height = vout_height; + fb.access_flags = RETRO_MEMORY_ACCESS_WRITE; + + vout_buf_ptr = vout_buf; + + if (environ_cb(RETRO_ENVIRONMENT_GET_CURRENT_SOFTWARE_FRAMEBUFFER, &fb) && fb.format == RETRO_PIXEL_FORMAT_RGB565) + { + vout_buf_ptr = (uint16_t*)fb.data; + } - video_cb((vout_fb_dirty || !vout_can_dupe || !duping_enable) ? vout_buf : NULL, + video_cb((vout_fb_dirty || !vout_can_dupe || !duping_enable) ? vout_buf_ptr : NULL, vout_width, vout_height, vout_width * 2); vout_fb_dirty = 0; } @@ -1592,7 +1607,9 @@ void retro_init(void) #else vout_buf = malloc(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2); #endif - + + vout_buf_ptr = vout_buf; + if (environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &dir) && dir) { snprintf(Config.BiosDir, sizeof(Config.BiosDir), "%s", dir); @@ -1658,8 +1675,10 @@ void retro_deinit(void) free(vout_buf); #endif vout_buf = NULL; - + +#ifdef VITA deinit_vita_mmap(); +#endif } #ifdef VITA