X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=frontend%2Flibretro.c;h=444719a5ed4fdff1d24dea8f76af4747a16b0ebc;hb=5dd01cbd4e93fdcaf8daeef76e79bfeab0b5b678;hp=b13f9c79acaed4b63271d302f69a82cf32f2cd14;hpb=15504ca8fb3d4dbcb1822f2aafb4797e88f88175;p=pcsx_rearmed.git diff --git a/frontend/libretro.c b/frontend/libretro.c index b13f9c79..444719a5 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -256,6 +256,85 @@ void pl_3ds_munmap(void *ptr, size_t size, enum psxMapTag tag) } #endif +#ifdef VITA +typedef struct +{ + void* buffer; + uint32_t target_map; + size_t size; + enum psxMapTag tag; +}psx_map_t; + +psx_map_t custom_psx_maps[] = { + {NULL, NULL, 0x210000, MAP_TAG_RAM}, // 0x80000000 + {NULL, NULL, 0x010000, MAP_TAG_OTHER}, // 0x1f800000 + {NULL, NULL, 0x080000, MAP_TAG_OTHER}, // 0x1fc00000 + {NULL, NULL, 0x800000, MAP_TAG_LUTS}, // 0x08000000 + {NULL, NULL, 0x200000, MAP_TAG_VRAM}, // 0x00000000 +}; + +void* pl_vita_mmap(unsigned long addr, size_t size, int is_fixed, + enum psxMapTag tag) +{ + (void)is_fixed; + (void)addr; + + + psx_map_t* custom_map = custom_psx_maps; + + for (; custom_map->size; custom_map++) + { + if ((custom_map->size == size) && (custom_map->tag == tag)) + { + int block, ret; + char blockname[32]; + sprintf(blockname, "CODE 0x%08X",tag); + + block = sceKernelAllocMemBlock(blockname, size + 0x1000); + if(block<=0){ + sceClibPrintf("could not alloc mem block @0x%08X 0x%08X \n", block, tag); + exit(1); + } + + // get base address + ret = sceKernelGetMemBlockBase(block, &custom_map->buffer); + if (ret < 0) + { + sceClibPrintf("could get address @0x%08X 0x%08X 0x%08X \n", block, ret, tag); + exit(1); + } + custom_map->buffer = (((u32)custom_map->buffer) + 0xFFF) & ~0xFFF; + custom_map->target_map = block; + + return custom_map->buffer; + } + } + + + return malloc(size); +} + +void pl_vita_munmap(void *ptr, size_t size, enum psxMapTag tag) +{ + (void)tag; + + psx_map_t* custom_map = custom_psx_maps; + + for (; custom_map->size; custom_map++) + { + if ((custom_map->buffer == ptr)) + { + sceKernelFreeMemBlock(custom_map->target_map); + custom_map->buffer = NULL; + custom_map->target_map = NULL; + return; + } + } + + free(ptr); +} +#endif + static void *pl_mmap(unsigned int size) { return psxMap(0, size, 0, MAP_TAG_VRAM); @@ -473,7 +552,7 @@ static void update_controller_port_device(unsigned port, unsigned device) static void update_multitap() { struct retro_variable var; - int auto_case; + int auto_case, port; var.value = NULL; var.key = "pcsx_rearmed_multitap1"; @@ -494,7 +573,7 @@ static void update_multitap() { // If a gamepad is plugged after port 2, we need a first multitap. multitap1 = 0; - for (int port = 2; port < PORTS_NUMBER; port++) + for (port = 2; port < PORTS_NUMBER; port++) multitap1 |= in_type[port] != PSE_PAD_TYPE_NONE; } @@ -517,7 +596,7 @@ static void update_multitap() { // If a gamepad is plugged after port 4, we need a second multitap. multitap2 = 0; - for (int port = 4; port < PORTS_NUMBER; port++) + for (port = 4; port < PORTS_NUMBER; port++) multitap2 |= in_type[port] != PSE_PAD_TYPE_NONE; } } @@ -1204,6 +1283,7 @@ static const unsigned short retro_psx_map[] = { static void update_variables(bool in_flight) { struct retro_variable var; + int i; var.value = NULL; var.key = "pcsx_rearmed_frameskip"; @@ -1223,7 +1303,7 @@ static void update_variables(bool in_flight) Config.PsxType = 1; } - for (int i = 0; i < PORTS_NUMBER; i++) + for (i = 0; i < PORTS_NUMBER; i++) update_controller_port_variable(i); update_multitap(); @@ -1473,6 +1553,10 @@ void retro_init(void) #ifdef _3DS psxMapHook = pl_3ds_mmap; psxUnmapHook = pl_3ds_munmap; +#endif +#ifdef VITA + psxMapHook = pl_vita_mmap; + psxUnmapHook = pl_vita_munmap; #endif ret = emu_core_preinit(); #ifdef _3DS