X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=frontend%2Flibretro.c;h=2efccfac653960bceef0bdc73baf0a2eeea21055;hb=d8f2e2d88a0f951388b894e3edea0d44a54727dd;hp=75f9b98381bb50c65eeadb86a456fe1d52e3ec5a;hpb=1a5fd79401ac52789fad34c6b852b947200a6334;p=pcsx_rearmed.git diff --git a/frontend/libretro.c b/frontend/libretro.c index 75f9b983..2efccfac 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -10,6 +10,10 @@ #include #include #include +#ifdef __MACH__ +#include +#include +#endif #include "../libpcsxcore/misc.h" #include "../libpcsxcore/psxcounters.h" @@ -265,6 +269,8 @@ typedef struct enum psxMapTag tag; }psx_map_t; +void* addr = NULL; + psx_map_t custom_psx_maps[] = { {NULL, NULL, 0x210000, MAP_TAG_RAM}, // 0x80000000 {NULL, NULL, 0x010000, MAP_TAG_OTHER}, // 0x1f800000 @@ -273,6 +279,29 @@ psx_map_t custom_psx_maps[] = { {NULL, NULL, 0x200000, MAP_TAG_VRAM}, // 0x00000000 }; +int init_vita_mmap(){ + int n; + 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; +#if 0 + for(n = 0; n < 5; n++){ + sceClibPrintf("addr reserved %x\n",custom_psx_maps[n].buffer); + } +#endif + return 0; +} + +void deinit_vita_mmap(){ + free(addr); +} + void* pl_vita_mmap(unsigned long addr, size_t size, int is_fixed, enum psxMapTag tag) { @@ -286,26 +315,6 @@ void* pl_vita_mmap(unsigned long addr, size_t size, int is_fixed, { if ((custom_map->size == size) && (custom_map->tag == tag)) { - int block, ret; - char blockname[32]; - sprintf(blockname, "CODE 0x%08X",tag); - - block = sceKernelAllocMemBlockForVM(blockname, size); - 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->target_map = block; - return custom_map->buffer; } } @@ -324,9 +333,6 @@ void pl_vita_munmap(void *ptr, size_t size, enum psxMapTag tag) { if ((custom_map->buffer == ptr)) { - sceKernelFreeMemBlock(custom_map->target_map); - custom_map->buffer = NULL; - custom_map->target_map = NULL; return; } } @@ -1550,20 +1556,29 @@ void retro_init(void) int i, ret; bool found_bios = false; +#ifdef __MACH__ + // magic sauce to make the dynarec work on iOS + syscall(SYS_ptrace, 0 /*PTRACE_TRACEME*/, 0, 0, 0); +#endif + #ifdef _3DS psxMapHook = pl_3ds_mmap; psxUnmapHook = pl_3ds_munmap; #endif #ifdef VITA + if(init_vita_mmap()<0) + abort(); psxMapHook = pl_vita_mmap; psxUnmapHook = pl_vita_munmap; #endif ret = emu_core_preinit(); -#ifdef _3DS +#ifdef _3DS /* emu_core_preinit sets the cpu to dynarec */ if(!__ctr_svchax) Config.Cpu = CPU_INTERPRETER; #endif + Config.Cpu = CPU_INTERPRETER; + ret |= emu_core_init(); if (ret != 0) { SysPrintf("PCSX init failed.\n"); @@ -1643,6 +1658,10 @@ void retro_deinit(void) free(vout_buf); #endif vout_buf = NULL; + +#ifdef VITA + deinit_vita_mmap(); +#endif } #ifdef VITA