From 6cdf212f2cbb240dfbe3a8af23bebf0960ba5574 Mon Sep 17 00:00:00 2001 From: vanfanel Date: Wed, 3 Aug 2016 02:27:58 +0200 Subject: Please, don't use for loop initial declarations because it forces us to use higher C std --- frontend/libretro.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'frontend') diff --git a/frontend/libretro.c b/frontend/libretro.c index b13f9c7..5bf737f 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -473,7 +473,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 +494,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 +517,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 +1204,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 +1224,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(); -- cgit v1.2.3 From 1a5fd79401ac52789fad34c6b852b947200a6334 Mon Sep 17 00:00:00 2001 From: frangarcj Date: Tue, 6 Sep 2016 13:49:55 +0200 Subject: (VITA) Some dynarec --- frontend/libretro.c | 83 +++++++++++++++++++++++++ frontend/vita/pthread.h | 156 +++++++++++++++++++++++++++++++++++++++-------- frontend/vita/sys/mman.h | 29 ++++++--- 3 files changed, 236 insertions(+), 32 deletions(-) (limited to 'frontend') diff --git a/frontend/libretro.c b/frontend/libretro.c index 5bf737f..75f9b98 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 = 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; + } + } + + + 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); @@ -1474,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 diff --git a/frontend/vita/pthread.h b/frontend/vita/pthread.h index c18b20b..e1afdc5 100644 --- a/frontend/vita/pthread.h +++ b/frontend/vita/pthread.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2015 The RetroArch team +/* Copyright (C) 2010-2016 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (psp_pthread.h). @@ -26,6 +26,7 @@ #ifdef VITA #include +#include #else #include #include @@ -34,13 +35,20 @@ #include #include -#define STACKSIZE (64 * 1024) +#define STACKSIZE (8 * 1024) typedef SceUID pthread_t; typedef SceUID pthread_mutex_t; typedef void* pthread_mutexattr_t; typedef int pthread_attr_t; -typedef SceUID pthread_cond_t; + +typedef struct +{ + SceUID mutex; + SceUID sema; + int waiting; +} pthread_cond_t; + typedef SceUID pthread_condattr_t; /* Use pointer values to create unique names for threads/mutexes */ @@ -65,14 +73,15 @@ static int psp_thread_wrap(SceSize args, void *argp) static INLINE int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg) { - sprintf(name_buffer, "0x%08X", (uint32_t) thread); + sprintf(name_buffer, "0x%08X", (unsigned int) thread); - *thread = sceKernelCreateThread(name_buffer, - psp_thread_wrap, 0x20, STACKSIZE, 0, #ifdef VITA - 0, + *thread = sceKernelCreateThread(name_buffer, psp_thread_wrap, + 0x10000100, 0x10000, 0, 0, NULL); +#else + *thread = sceKernelCreateThread(name_buffer, + psp_thread_wrap, 0x20, STACKSIZE, 0, NULL); #endif - NULL); sthread_args_struct sthread_args; sthread_args.arg = arg; @@ -84,10 +93,13 @@ static INLINE int pthread_create(pthread_t *thread, static INLINE int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) { - sprintf(name_buffer, "0x%08X", (uint32_t) mutex); + sprintf(name_buffer, "0x%08X", (unsigned int) mutex); #ifdef VITA - return *mutex = sceKernelCreateMutex(name_buffer, 0, 0, 0); + *mutex = sceKernelCreateMutex(name_buffer, 0, 0, 0); + if(*mutex<0) + return *mutex; + return 0; #else return *mutex = sceKernelCreateSema(name_buffer, 0, 1, 1, NULL); #endif @@ -105,7 +117,9 @@ static INLINE int pthread_mutex_destroy(pthread_mutex_t *mutex) static INLINE int pthread_mutex_lock(pthread_mutex_t *mutex) { #ifdef VITA - return sceKernelLockMutex(*mutex, 1, 0); + int ret = sceKernelLockMutex(*mutex, 1, 0); + return ret; + #else /* FIXME: stub */ return 1; @@ -115,7 +129,8 @@ static INLINE int pthread_mutex_lock(pthread_mutex_t *mutex) static INLINE int pthread_mutex_unlock(pthread_mutex_t *mutex) { #ifdef VITA - return sceKernelUnlockMutex(*mutex, 1); + int ret = sceKernelUnlockMutex(*mutex, 1); + return ret; #else /* FIXME: stub */ return 1; @@ -125,16 +140,18 @@ static INLINE int pthread_mutex_unlock(pthread_mutex_t *mutex) static INLINE int pthread_join(pthread_t thread, void **retval) { - int exit_status; - SceUInt timeout = (SceUInt)-1; #ifdef VITA - sceKernelWaitThreadEnd(thread, &exit_status, &timeout); + int res = sceKernelWaitThreadEnd(thread, 0, 0); + if (res < 0) + return res; + return sceKernelDeleteThread(thread); #else + SceUInt timeout = (SceUInt)-1; sceKernelWaitThreadEnd(thread, &timeout); exit_status = sceKernelGetThreadExitStatus(thread); -#endif sceKernelDeleteThread(thread); return exit_status; +#endif } static INLINE int pthread_mutex_trylock(pthread_mutex_t *mutex) @@ -150,51 +167,142 @@ static INLINE int pthread_mutex_trylock(pthread_mutex_t *mutex) static INLINE int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) { +#ifdef VITA + int ret = pthread_mutex_lock(&cond->mutex); + if (ret < 0) + return ret; + ++cond->waiting; + pthread_mutex_unlock(mutex); + pthread_mutex_unlock(&cond->mutex); + + ret = sceKernelWaitSema(cond->sema, 1, 0); + if (ret < 0) + sceClibPrintf("Premature wakeup: %08X", ret); + pthread_mutex_lock(mutex); + return ret; +#else + /* FIXME: stub */ sceKernelDelayThread(10000); return 1; +#endif } static INLINE int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime) { - //FIXME: stub +#ifdef VITA + int ret = pthread_mutex_lock(&cond->mutex); + if (ret < 0) + return ret; + ++cond->waiting; + pthread_mutex_unlock(mutex); + pthread_mutex_unlock(&cond->mutex); + + SceUInt timeout = 0; + + timeout = abstime->tv_sec; + timeout += abstime->tv_nsec / 1.0e6; + + ret = sceKernelWaitSema(cond->sema, 1, &timeout); + if (ret < 0) + sceClibPrintf("Premature wakeup: %08X", ret); + pthread_mutex_lock(mutex); + return ret; + +#else + /* FIXME: stub */ return 1; +#endif } static INLINE int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) { - //FIXME: stub +#ifdef VITA + + pthread_mutex_init(&cond->mutex,NULL); + if(cond->mutex<0){ + return cond->mutex; + } + sprintf(name_buffer, "0x%08X", (unsigned int) cond); + //cond->sema = sceKernelCreateCond(name_buffer, 0, cond->mutex, 0); + cond->sema = sceKernelCreateSema(name_buffer, 0, 0, 1, 0); + if(cond->sema<0){ + pthread_mutex_destroy(&cond->mutex); + return cond->sema; + } + + cond->waiting = 0; + + + return 0; + + +#else + /* FIXME: stub */ return 1; +#endif } static INLINE int pthread_cond_signal(pthread_cond_t *cond) { - //FIXME: stub +#ifdef VITA + pthread_mutex_lock(&cond->mutex); + if (cond->waiting) + { + --cond->waiting; + sceKernelSignalSema(cond->sema, 1); + } + pthread_mutex_unlock(&cond->mutex); + return 0; +#else + /* FIXME: stub */ return 1; +#endif } static INLINE int pthread_cond_broadcast(pthread_cond_t *cond) { - //FIXME: stub + /* FIXME: stub */ return 1; } static INLINE int pthread_cond_destroy(pthread_cond_t *cond) { - //FIXME: stub - return 1; +#ifdef VITA + int ret = sceKernelDeleteSema(cond->sema); + if(ret < 0) + return ret; + + return sceKernelDeleteMutex(cond->mutex); +#else + /* FIXME: stub */ + return 1; +#endif } static INLINE int pthread_detach(pthread_t thread) { - return 1; + return 0; } static INLINE void pthread_exit(void *retval) { - (void)retval; +#ifdef VITA + sceKernelExitDeleteThread(sceKernelGetThreadId()); +#endif +} + +static INLINE pthread_t pthread_self(void) +{ + /* zero 20-mar-2016: untested */ + return sceKernelGetThreadId(); +} + +static INLINE int pthread_equal(pthread_t t1, pthread_t t2) +{ + return t1 == t2; } #endif //_PSP_PTHREAD_WRAP__ diff --git a/frontend/vita/sys/mman.h b/frontend/vita/sys/mman.h index 66467f4..89da513 100644 --- a/frontend/vita/sys/mman.h +++ b/frontend/vita/sys/mman.h @@ -18,19 +18,32 @@ extern "C" { static inline void* mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) { - (void)addr; (void)prot; (void)flags; (void)fd; (void)offset; - void* addr_out; + int block, ret; + + block = sceKernelAllocMemBlockForVM("code", len); + if(block<=0){ + sceClibPrintf("could not alloc mem block @0x%08X 0x%08X \n", block, len); + exit(1); + } + + // get base address + ret = sceKernelGetMemBlockBase(block, &addr); + if (ret < 0) + { + sceClibPrintf("could get address @0x%08X 0x%08X \n", block, addr); + exit(1); + } + - addr_out = malloc(len); - if(!addr_out) + if(!addr) return MAP_FAILED; - return addr_out; + return addr; } static inline int mprotect(void *addr, size_t len, int prot) @@ -43,8 +56,9 @@ static inline int mprotect(void *addr, size_t len, int prot) static inline int munmap(void *addr, size_t len) { - free(addr); - return 0; + int uid = sceKernelFindMemBlockByAddr(addr, len); + + return sceKernelFreeMemBlock(uid); } @@ -53,4 +67,3 @@ static inline int munmap(void *addr, size_t len) #endif #endif // MMAN_H - -- cgit v1.2.3 From 9facb65b76d846175f3ef9fbeafd1c590a0e0630 Mon Sep 17 00:00:00 2001 From: frangarcj Date: Tue, 6 Sep 2016 17:50:57 +0200 Subject: (VITA) I think that is not VM Memory and do some alignment --- frontend/libretro.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'frontend') diff --git a/frontend/libretro.c b/frontend/libretro.c index 75f9b98..444719a 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -290,7 +290,7 @@ void* pl_vita_mmap(unsigned long addr, size_t size, int is_fixed, char blockname[32]; sprintf(blockname, "CODE 0x%08X",tag); - block = sceKernelAllocMemBlockForVM(blockname, size); + block = sceKernelAllocMemBlock(blockname, size + 0x1000); if(block<=0){ sceClibPrintf("could not alloc mem block @0x%08X 0x%08X \n", block, tag); exit(1); @@ -303,7 +303,7 @@ void* pl_vita_mmap(unsigned long addr, size_t size, int is_fixed, 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; -- cgit v1.2.3 From d148d26560527efdd71685df8eac0497827ca766 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 19 Sep 2016 02:40:17 +0300 Subject: drc: try to support w^x platforms like iOS untested... --- frontend/libretro.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'frontend') diff --git a/frontend/libretro.c b/frontend/libretro.c index 37cccc4..940ff05 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" @@ -1202,6 +1206,11 @@ 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 + ret = emu_core_preinit(); ret |= emu_core_init(); if (ret != 0) { -- cgit v1.2.3 From ed0896e7140a650debd06cac664896b43c093738 Mon Sep 17 00:00:00 2001 From: Francisco José García García Date: Wed, 21 Sep 2016 23:52:38 +0200 Subject: Update libretro.c --- frontend/libretro.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'frontend') diff --git a/frontend/libretro.c b/frontend/libretro.c index 1e86509..17b57d9 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -294,7 +294,7 @@ void* pl_vita_mmap(unsigned long addr, size_t size, int is_fixed, char blockname[32]; sprintf(blockname, "CODE 0x%08X",tag); - block = sceKernelAllocMemBlock(blockname, size + 0x1000); + block = sceKernelAllocMemBlock(blockname, 0x0c20d060, size + 0x1000, 0); if(block<=0){ sceClibPrintf("could not alloc mem block @0x%08X 0x%08X \n", block, tag); exit(1); -- cgit v1.2.3 From 73081f238a4d80891cf9df5aebeebe3d13c84144 Mon Sep 17 00:00:00 2001 From: Francisco José García García Date: Mon, 26 Sep 2016 01:03:14 +0200 Subject: (VITA) Dynarec working --- frontend/libretro.c | 56 +++++---- frontend/vita/pthread.h | 308 ------------------------------------------------ 2 files changed, 32 insertions(+), 332 deletions(-) delete mode 100644 frontend/vita/pthread.h (limited to 'frontend') diff --git a/frontend/libretro.c b/frontend/libretro.c index 17b57d9..5594062 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -269,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 @@ -277,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) { @@ -290,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 = sceKernelAllocMemBlock(blockname, 0x0c20d060, size + 0x1000, 0); - 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; } } @@ -328,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; } } @@ -1564,15 +1566,19 @@ void retro_init(void) 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"); @@ -1652,6 +1658,8 @@ void retro_deinit(void) free(vout_buf); #endif vout_buf = NULL; + + deinit_vita_mmap(); } #ifdef VITA diff --git a/frontend/vita/pthread.h b/frontend/vita/pthread.h deleted file mode 100644 index e1afdc5..0000000 --- a/frontend/vita/pthread.h +++ /dev/null @@ -1,308 +0,0 @@ -/* Copyright (C) 2010-2016 The RetroArch team - * - * --------------------------------------------------------------------------------------- - * The following license statement only applies to this file (psp_pthread.h). - * --------------------------------------------------------------------------------------- - * - * Permission is hereby granted, free of charge, - * to any person obtaining a copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* FIXME: unfinished on PSP, mutexes and condition variables basically a stub. */ -#ifndef _PSP_PTHREAD_WRAP__ -#define _PSP_PTHREAD_WRAP__ - -#ifdef VITA -#include -#include -#else -#include -#include -#include -#endif -#include -#include - -#define STACKSIZE (8 * 1024) - -typedef SceUID pthread_t; -typedef SceUID pthread_mutex_t; -typedef void* pthread_mutexattr_t; -typedef int pthread_attr_t; - -typedef struct -{ - SceUID mutex; - SceUID sema; - int waiting; -} pthread_cond_t; - -typedef SceUID pthread_condattr_t; - -/* Use pointer values to create unique names for threads/mutexes */ -char name_buffer[256]; - -typedef void* (*sthreadEntry)(void *argp); - -typedef struct -{ - void* arg; - sthreadEntry start_routine; -} sthread_args_struct; - - -static int psp_thread_wrap(SceSize args, void *argp) -{ - sthread_args_struct* sthread_args = (sthread_args_struct*)argp; - - return (int)sthread_args->start_routine(sthread_args->arg); -} - -static INLINE int pthread_create(pthread_t *thread, - const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg) -{ - sprintf(name_buffer, "0x%08X", (unsigned int) thread); - -#ifdef VITA - *thread = sceKernelCreateThread(name_buffer, psp_thread_wrap, - 0x10000100, 0x10000, 0, 0, NULL); -#else - *thread = sceKernelCreateThread(name_buffer, - psp_thread_wrap, 0x20, STACKSIZE, 0, NULL); -#endif - - sthread_args_struct sthread_args; - sthread_args.arg = arg; - sthread_args.start_routine = start_routine; - - return sceKernelStartThread(*thread, sizeof(sthread_args), &sthread_args); -} - -static INLINE int pthread_mutex_init(pthread_mutex_t *mutex, - const pthread_mutexattr_t *attr) -{ - sprintf(name_buffer, "0x%08X", (unsigned int) mutex); - -#ifdef VITA - *mutex = sceKernelCreateMutex(name_buffer, 0, 0, 0); - if(*mutex<0) - return *mutex; - return 0; -#else - return *mutex = sceKernelCreateSema(name_buffer, 0, 1, 1, NULL); -#endif -} - -static INLINE int pthread_mutex_destroy(pthread_mutex_t *mutex) -{ -#ifdef VITA - return sceKernelDeleteMutex(*mutex); -#else - return sceKernelDeleteSema(*mutex); -#endif -} - -static INLINE int pthread_mutex_lock(pthread_mutex_t *mutex) -{ -#ifdef VITA - int ret = sceKernelLockMutex(*mutex, 1, 0); - return ret; - -#else - /* FIXME: stub */ - return 1; -#endif -} - -static INLINE int pthread_mutex_unlock(pthread_mutex_t *mutex) -{ -#ifdef VITA - int ret = sceKernelUnlockMutex(*mutex, 1); - return ret; -#else - /* FIXME: stub */ - return 1; -#endif -} - - -static INLINE int pthread_join(pthread_t thread, void **retval) -{ -#ifdef VITA - int res = sceKernelWaitThreadEnd(thread, 0, 0); - if (res < 0) - return res; - return sceKernelDeleteThread(thread); -#else - SceUInt timeout = (SceUInt)-1; - sceKernelWaitThreadEnd(thread, &timeout); - exit_status = sceKernelGetThreadExitStatus(thread); - sceKernelDeleteThread(thread); - return exit_status; -#endif -} - -static INLINE int pthread_mutex_trylock(pthread_mutex_t *mutex) -{ -#ifdef VITA - return sceKernelTryLockMutex(*mutex, 1 /* not sure about this last param */); -#else - /* FIXME: stub */ - return 1; -#endif -} - -static INLINE int pthread_cond_wait(pthread_cond_t *cond, - pthread_mutex_t *mutex) -{ -#ifdef VITA - int ret = pthread_mutex_lock(&cond->mutex); - if (ret < 0) - return ret; - ++cond->waiting; - pthread_mutex_unlock(mutex); - pthread_mutex_unlock(&cond->mutex); - - ret = sceKernelWaitSema(cond->sema, 1, 0); - if (ret < 0) - sceClibPrintf("Premature wakeup: %08X", ret); - pthread_mutex_lock(mutex); - return ret; -#else - /* FIXME: stub */ - sceKernelDelayThread(10000); - return 1; -#endif -} - -static INLINE int pthread_cond_timedwait(pthread_cond_t *cond, - pthread_mutex_t *mutex, const struct timespec *abstime) -{ -#ifdef VITA - int ret = pthread_mutex_lock(&cond->mutex); - if (ret < 0) - return ret; - ++cond->waiting; - pthread_mutex_unlock(mutex); - pthread_mutex_unlock(&cond->mutex); - - SceUInt timeout = 0; - - timeout = abstime->tv_sec; - timeout += abstime->tv_nsec / 1.0e6; - - ret = sceKernelWaitSema(cond->sema, 1, &timeout); - if (ret < 0) - sceClibPrintf("Premature wakeup: %08X", ret); - pthread_mutex_lock(mutex); - return ret; - -#else - /* FIXME: stub */ - return 1; -#endif -} - -static INLINE int pthread_cond_init(pthread_cond_t *cond, - const pthread_condattr_t *attr) -{ -#ifdef VITA - - pthread_mutex_init(&cond->mutex,NULL); - if(cond->mutex<0){ - return cond->mutex; - } - sprintf(name_buffer, "0x%08X", (unsigned int) cond); - //cond->sema = sceKernelCreateCond(name_buffer, 0, cond->mutex, 0); - cond->sema = sceKernelCreateSema(name_buffer, 0, 0, 1, 0); - if(cond->sema<0){ - pthread_mutex_destroy(&cond->mutex); - return cond->sema; - } - - cond->waiting = 0; - - - return 0; - - -#else - /* FIXME: stub */ - return 1; -#endif -} - -static INLINE int pthread_cond_signal(pthread_cond_t *cond) -{ -#ifdef VITA - pthread_mutex_lock(&cond->mutex); - if (cond->waiting) - { - --cond->waiting; - sceKernelSignalSema(cond->sema, 1); - } - pthread_mutex_unlock(&cond->mutex); - return 0; -#else - /* FIXME: stub */ - return 1; -#endif -} - -static INLINE int pthread_cond_broadcast(pthread_cond_t *cond) -{ - /* FIXME: stub */ - return 1; -} - -static INLINE int pthread_cond_destroy(pthread_cond_t *cond) -{ -#ifdef VITA - int ret = sceKernelDeleteSema(cond->sema); - if(ret < 0) - return ret; - - return sceKernelDeleteMutex(cond->mutex); -#else - /* FIXME: stub */ - return 1; -#endif -} - - -static INLINE int pthread_detach(pthread_t thread) -{ - return 0; -} - -static INLINE void pthread_exit(void *retval) -{ -#ifdef VITA - sceKernelExitDeleteThread(sceKernelGetThreadId()); -#endif -} - -static INLINE pthread_t pthread_self(void) -{ - /* zero 20-mar-2016: untested */ - return sceKernelGetThreadId(); -} - -static INLINE int pthread_equal(pthread_t t1, pthread_t t2) -{ - return t1 == t2; -} - -#endif //_PSP_PTHREAD_WRAP__ -- cgit v1.2.3 From d8f2e2d88a0f951388b894e3edea0d44a54727dd Mon Sep 17 00:00:00 2001 From: Sunguk Lee Date: Mon, 26 Sep 2016 14:39:36 +0900 Subject: Fix build error about undefined reference to `deinit_vita_mmap' ``` frontend/libretro.o: In function `retro_deinit': libretro.c:(.text+0x3769): undefined reference to `deinit_vita_mmap' collect2: error: ld returned 1 exit status make: *** [pcsx_rearmed_libretro.so] Error 1 ``` Introduced #68 --- frontend/libretro.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'frontend') diff --git a/frontend/libretro.c b/frontend/libretro.c index 5594062..2efccfa 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -1658,8 +1658,10 @@ void retro_deinit(void) free(vout_buf); #endif vout_buf = NULL; - + +#ifdef VITA deinit_vita_mmap(); +#endif } #ifdef VITA -- cgit v1.2.3 From 848b806c5597cd13b250812f32c4848f74599ab0 Mon Sep 17 00:00:00 2001 From: Francisco José García García Date: Tue, 27 Sep 2016 00:59:38 +0200 Subject: (Vita) Fix deinit bug --- frontend/libretro.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'frontend') diff --git a/frontend/libretro.c b/frontend/libretro.c index 2efccfa..81afc30 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -281,15 +281,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); -- cgit v1.2.3 From 65a0505f57d57ddedb89e3c66734fb3b0a69e1e8 Mon Sep 17 00:00:00 2001 From: Francisco José García García Date: Wed, 28 Sep 2016 00:44:37 +0200 Subject: Add support for software framebuffer --- frontend/libretro.c | 28 +++++-- frontend/libretro.h | 215 ++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 198 insertions(+), 45 deletions(-) (limited to 'frontend') diff --git a/frontend/libretro.c b/frontend/libretro.c index 81afc30..66175af 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++; @@ -1483,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; } @@ -1593,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); diff --git a/frontend/libretro.h b/frontend/libretro.h index 16c274a..a231548 100755 --- a/frontend/libretro.h +++ b/frontend/libretro.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2014 The RetroArch team +/* Copyright (C) 2010-2016 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this libretro API header (libretro.h). @@ -43,6 +43,40 @@ extern "C" { #endif #endif +#ifndef RETRO_CALLCONV +# if defined(__GNUC__) && defined(__i386__) && !defined(__x86_64__) +# define RETRO_CALLCONV __attribute__((cdecl)) +# elif defined(_MSC_VER) && defined(_M_X86) && !defined(_M_X64) +# define RETRO_CALLCONV __cdecl +# else +# define RETRO_CALLCONV /* all other platforms only have one calling convention each */ +# endif +#endif + +#ifndef RETRO_API +# if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) +# ifdef RETRO_IMPORT_SYMBOLS +# ifdef __GNUC__ +# define RETRO_API RETRO_CALLCONV __attribute__((__dllimport__)) +# else +# define RETRO_API RETRO_CALLCONV __declspec(dllimport) +# endif +# else +# ifdef __GNUC__ +# define RETRO_API RETRO_CALLCONV __attribute__((__dllexport__)) +# else +# define RETRO_API RETRO_CALLCONV __declspec(dllexport) +# endif +# endif +# else +# if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__CELLOS_LV2__) +# define RETRO_API RETRO_CALLCONV __attribute__((__visibility__("default"))) +# else +# define RETRO_API RETRO_CALLCONV +# endif +# endif +#endif + /* Used for checking API/ABI mismatches that can break libretro * implementations. * It is not incremented for compatible changes to the API. @@ -165,13 +199,15 @@ extern "C" { #define RETRO_DEVICE_ID_ANALOG_Y 1 /* Id values for MOUSE. */ -#define RETRO_DEVICE_ID_MOUSE_X 0 -#define RETRO_DEVICE_ID_MOUSE_Y 1 -#define RETRO_DEVICE_ID_MOUSE_LEFT 2 -#define RETRO_DEVICE_ID_MOUSE_RIGHT 3 -#define RETRO_DEVICE_ID_MOUSE_WHEELUP 4 -#define RETRO_DEVICE_ID_MOUSE_WHEELDOWN 5 -#define RETRO_DEVICE_ID_MOUSE_MIDDLE 6 +#define RETRO_DEVICE_ID_MOUSE_X 0 +#define RETRO_DEVICE_ID_MOUSE_Y 1 +#define RETRO_DEVICE_ID_MOUSE_LEFT 2 +#define RETRO_DEVICE_ID_MOUSE_RIGHT 3 +#define RETRO_DEVICE_ID_MOUSE_WHEELUP 4 +#define RETRO_DEVICE_ID_MOUSE_WHEELDOWN 5 +#define RETRO_DEVICE_ID_MOUSE_MIDDLE 6 +#define RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP 7 +#define RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN 8 /* Id values for LIGHTGUN types. */ #define RETRO_DEVICE_ID_LIGHTGUN_X 0 @@ -206,6 +242,8 @@ enum retro_language RETRO_LANGUAGE_KOREAN = 9, RETRO_LANGUAGE_CHINESE_TRADITIONAL = 10, RETRO_LANGUAGE_CHINESE_SIMPLIFIED = 11, + RETRO_LANGUAGE_ESPERANTO = 12, + RETRO_LANGUAGE_POLISH = 13, RETRO_LANGUAGE_LAST, /* Ensure sizeof(enum) == sizeof(int) */ @@ -693,9 +731,10 @@ enum retro_mod * location-based information from the host device, * such as current latitude / longitude. */ -#define RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY 30 +#define RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY 30 /* Old name, kept for compatibility. */ +#define RETRO_ENVIRONMENT_GET_CORE_ASSETS_DIRECTORY 30 /* const char ** -- - * Returns the "content" directory of the frontend. + * Returns the "core assets" directory of the frontend. * This directory can be used to store specific assets that the * core relies upon, such as art assets, * input data, etc etc. @@ -851,6 +890,61 @@ enum retro_mod * Returns the specified language of the frontend, if specified by the user. * It can be used by the core for localization purposes. */ +#define RETRO_ENVIRONMENT_GET_CURRENT_SOFTWARE_FRAMEBUFFER (40 | RETRO_ENVIRONMENT_EXPERIMENTAL) + /* struct retro_framebuffer * -- + * Returns a preallocated framebuffer which the core can use for rendering + * the frame into when not using SET_HW_RENDER. + * The framebuffer returned from this call must not be used + * after the current call to retro_run() returns. + * + * The goal of this call is to allow zero-copy behavior where a core + * can render directly into video memory, avoiding extra bandwidth cost by copying + * memory from core to video memory. + * + * If this call succeeds and the core renders into it, + * the framebuffer pointer and pitch can be passed to retro_video_refresh_t. + * If the buffer from GET_CURRENT_SOFTWARE_FRAMEBUFFER is to be used, + * the core must pass the exact + * same pointer as returned by GET_CURRENT_SOFTWARE_FRAMEBUFFER; + * i.e. passing a pointer which is offset from the + * buffer is undefined. The width, height and pitch parameters + * must also match exactly to the values obtained from GET_CURRENT_SOFTWARE_FRAMEBUFFER. + * + * It is possible for a frontend to return a different pixel format + * than the one used in SET_PIXEL_FORMAT. This can happen if the frontend + * needs to perform conversion. + * + * It is still valid for a core to render to a different buffer + * even if GET_CURRENT_SOFTWARE_FRAMEBUFFER succeeds. + * + * A frontend must make sure that the pointer obtained from this function is + * writeable (and readable). + */ + +enum retro_hw_render_interface_type +{ + RETRO_HW_RENDER_INTERFACE_VULKAN = 0, + RETRO_HW_RENDER_INTERFACE_DUMMY = INT_MAX +}; + +/* Base struct. All retro_hw_render_interface_* types + * contain at least these fields. */ +struct retro_hw_render_interface +{ + enum retro_hw_render_interface_type interface_type; + unsigned interface_version; +}; +#define RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE (41 | RETRO_ENVIRONMENT_EXPERIMENTAL) + /* const struct retro_hw_render_interface ** -- + * Returns an API specific rendering interface for accessing API specific data. + * Not all HW rendering APIs support or need this. + * The contents of the returned pointer is specific to the rendering API + * being used. See the various headers like libretro_vulkan.h, etc. + * + * GET_HW_RENDER_INTERFACE cannot be called before context_reset has been called. + * Similarly, after context_destroyed callback returns, + * the contents of the HW_RENDER_INTERFACE are invalidated. + */ #define RETRO_MEMDESC_CONST (1 << 0) /* The frontend will never change this memory area once retro_load_game has returned. */ #define RETRO_MEMDESC_BIGENDIAN (1 << 1) /* The memory area contains big endian data. Default is little endian. */ @@ -1125,6 +1219,10 @@ struct retro_log_callback #define RETRO_SIMD_VFPU (1 << 13) #define RETRO_SIMD_PS (1 << 14) #define RETRO_SIMD_AES (1 << 15) +#define RETRO_SIMD_VFPV3 (1 << 16) +#define RETRO_SIMD_VFPV4 (1 << 17) +#define RETRO_SIMD_POPCNT (1 << 18) +#define RETRO_SIMD_MOVBE (1 << 19) typedef uint64_t retro_perf_tick_t; typedef int64_t retro_time_t; @@ -1464,6 +1562,9 @@ enum retro_hw_context_type * use the corresponding enums directly. */ RETRO_HW_CONTEXT_OPENGLES_VERSION = 5, + /* Vulkan, see RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE. */ + RETRO_HW_CONTEXT_VULKAN = 6, + RETRO_HW_CONTEXT_DUMMY = INT_MAX }; @@ -1486,23 +1587,28 @@ struct retro_hw_render_callback */ retro_hw_context_reset_t context_reset; - /* Set by frontend. */ + /* Set by frontend. + * TODO: This is rather obsolete. The frontend should not + * be providing preallocated framebuffers. */ retro_hw_get_current_framebuffer_t get_current_framebuffer; /* Set by frontend. */ retro_hw_get_proc_address_t get_proc_address; - /* Set if render buffers should have depth component attached. */ + /* Set if render buffers should have depth component attached. + * TODO: Obsolete. */ bool depth; - /* Set if stencil buffers should be attached. */ + /* Set if stencil buffers should be attached. + * TODO: Obsolete. */ bool stencil; /* If depth and stencil are true, a packed 24/8 buffer will be added. * Only attaching stencil is invalid and will be ignored. */ /* Use conventional bottom-left origin convention. If false, - * standard libretro top-left origin semantics are used. */ + * standard libretro top-left origin semantics are used. + * TODO: Move to GL specific interface. */ bool bottom_left_origin; /* Major version number for core GL context or GLES 3.1+. */ @@ -1513,6 +1619,7 @@ struct retro_hw_render_callback /* If this is true, the frontend will go very far to avoid * resetting context in scenarios like toggling fullscreen, etc. + * TODO: Obsolete? Maybe frontend should just always assume this ... */ bool cache_context; @@ -1779,6 +1886,36 @@ struct retro_game_info const char *meta; /* String of implementation specific meta-data. */ }; +#define RETRO_MEMORY_ACCESS_WRITE (1 << 0) + /* The core will write to the buffer provided by retro_framebuffer::data. */ +#define RETRO_MEMORY_ACCESS_READ (1 << 1) + /* The core will read from retro_framebuffer::data. */ +#define RETRO_MEMORY_TYPE_CACHED (1 << 0) + /* The memory in data is cached. + * If not cached, random writes and/or reading from the buffer is expected to be very slow. */ +struct retro_framebuffer +{ + void *data; /* The framebuffer which the core can render into. + Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. + The initial contents of data are unspecified. */ + unsigned width; /* The framebuffer width used by the core. Set by core. */ + unsigned height; /* The framebuffer height used by the core. Set by core. */ + size_t pitch; /* The number of bytes between the beginning of a scanline, + and beginning of the next scanline. + Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */ + enum retro_pixel_format format; /* The pixel format the core must use to render into data. + This format could differ from the format used in + SET_PIXEL_FORMAT. + Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */ + + unsigned access_flags; /* How the core will access the memory in the framebuffer. + RETRO_MEMORY_ACCESS_* flags. + Set by core. */ + unsigned memory_flags; /* Flags telling core how the memory has been mapped. + RETRO_MEMORY_TYPE_* flags. + Set by frontend in GET_CURRENT_SOFTWARE_FRAMEBUFFER. */ +}; + /* Callbacks */ /* Environment callback. Gives implementations a way of performing @@ -1832,25 +1969,25 @@ typedef int16_t (*retro_input_state_t)(unsigned port, unsigned device, * * The rest of the set_* functions are guaranteed to have been called * before the first call to retro_run() is made. */ -void retro_set_environment(retro_environment_t); -void retro_set_video_refresh(retro_video_refresh_t); -void retro_set_audio_sample(retro_audio_sample_t); -void retro_set_audio_sample_batch(retro_audio_sample_batch_t); -void retro_set_input_poll(retro_input_poll_t); -void retro_set_input_state(retro_input_state_t); +RETRO_API void retro_set_environment(retro_environment_t); +RETRO_API void retro_set_video_refresh(retro_video_refresh_t); +RETRO_API void retro_set_audio_sample(retro_audio_sample_t); +RETRO_API void retro_set_audio_sample_batch(retro_audio_sample_batch_t); +RETRO_API void retro_set_input_poll(retro_input_poll_t); +RETRO_API void retro_set_input_state(retro_input_state_t); /* Library global initialization/deinitialization. */ -void retro_init(void); -void retro_deinit(void); +RETRO_API void retro_init(void); +RETRO_API void retro_deinit(void); /* Must return RETRO_API_VERSION. Used to validate ABI compatibility * when the API is revised. */ -unsigned retro_api_version(void); +RETRO_API unsigned retro_api_version(void); /* Gets statically known system info. Pointers provided in *info * must be statically allocated. * Can be called at any time, even before retro_init(). */ -void retro_get_system_info(struct retro_system_info *info); +RETRO_API void retro_get_system_info(struct retro_system_info *info); /* Gets information about system audio/video timings and geometry. * Can be called only after retro_load_game() has successfully completed. @@ -1858,7 +1995,7 @@ void retro_get_system_info(struct retro_system_info *info); * variable if needed. * E.g. geom.aspect_ratio might not be initialized if core doesn't * desire a particular aspect ratio. */ -void retro_get_system_av_info(struct retro_system_av_info *info); +RETRO_API void retro_get_system_av_info(struct retro_system_av_info *info); /* Sets device to be used for player 'port'. * By default, RETRO_DEVICE_JOYPAD is assumed to be plugged into all @@ -1868,10 +2005,10 @@ void retro_get_system_av_info(struct retro_system_av_info *info); * hint to the libretro core when a core cannot automatically detect the * appropriate input device type on its own. It is also relevant when a * core can change its behavior depending on device type. */ -void retro_set_controller_port_device(unsigned port, unsigned device); +RETRO_API void retro_set_controller_port_device(unsigned port, unsigned device); /* Resets the current game. */ -void retro_reset(void); +RETRO_API void retro_reset(void); /* Runs the game for one video frame. * During retro_run(), input_poll callback must be called at least once. @@ -1881,7 +2018,7 @@ void retro_reset(void); * a frame if GET_CAN_DUPE returns true. * In this case, the video callback can take a NULL argument for data. */ -void retro_run(void); +RETRO_API void retro_run(void); /* Returns the amount of data the implementation requires to serialize * internal state (save states). @@ -1889,35 +2026,35 @@ void retro_run(void); * returned size is never allowed to be larger than a previous returned * value, to ensure that the frontend can allocate a save state buffer once. */ -size_t retro_serialize_size(void); +RETRO_API size_t retro_serialize_size(void); /* Serializes internal state. If failed, or size is lower than * retro_serialize_size(), it should return false, true otherwise. */ -bool retro_serialize(void *data, size_t size); -bool retro_unserialize(const void *data, size_t size); +RETRO_API bool retro_serialize(void *data, size_t size); +RETRO_API bool retro_unserialize(const void *data, size_t size); -void retro_cheat_reset(void); -void retro_cheat_set(unsigned index, bool enabled, const char *code); +RETRO_API void retro_cheat_reset(void); +RETRO_API void retro_cheat_set(unsigned index, bool enabled, const char *code); /* Loads a game. */ -bool retro_load_game(const struct retro_game_info *game); +RETRO_API bool retro_load_game(const struct retro_game_info *game); /* Loads a "special" kind of game. Should not be used, * except in extreme cases. */ -bool retro_load_game_special( +RETRO_API bool retro_load_game_special( unsigned game_type, const struct retro_game_info *info, size_t num_info ); /* Unloads a currently loaded game. */ -void retro_unload_game(void); +RETRO_API void retro_unload_game(void); /* Gets region of game. */ -unsigned retro_get_region(void); +RETRO_API unsigned retro_get_region(void); /* Gets region of memory. */ -void *retro_get_memory_data(unsigned id); -size_t retro_get_memory_size(unsigned id); +RETRO_API void *retro_get_memory_data(unsigned id); +RETRO_API size_t retro_get_memory_size(unsigned id); #ifdef __cplusplus } -- cgit v1.2.3 From 6558949c1701e47344da56a03cc3e4b475d55fe8 Mon Sep 17 00:00:00 2001 From: Francisco José García García Date: Wed, 28 Sep 2016 13:28:16 +0200 Subject: Fix software buffer --- frontend/libretro.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'frontend') diff --git a/frontend/libretro.c b/frontend/libretro.c index 66175af..bab3060 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -118,6 +118,20 @@ static void vout_set_mode(int w, int h, int raw_w, int raw_h, int bpp) { vout_width = w; vout_height = h; + + 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; + } + } #ifndef FRONTEND_SUPPORTS_RGB565 @@ -1484,19 +1498,6 @@ 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_ptr : NULL, vout_width, vout_height, vout_width * 2); -- cgit v1.2.3 From ce098e12475cfe0a40c5be4c3c0913501cb02ecc Mon Sep 17 00:00:00 2001 From: Nick Rivera Date: Mon, 10 Oct 2016 23:28:37 -0700 Subject: Fixed analog stick ranges to be [0, 255] --- frontend/libretro.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'frontend') diff --git a/frontend/libretro.c b/frontend/libretro.c index bab3060..f9be756 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -1464,6 +1464,11 @@ static void update_variables(bool in_flight) } } +static int min(int a, int b) +{ + return a < b ? a : b; +} + void retro_run(void) { int i; @@ -1489,10 +1494,10 @@ void retro_run(void) if (in_type[i] == PSE_PAD_TYPE_ANALOGPAD) { - in_analog_left[i][0] = (input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; - in_analog_left[i][1] = (input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; - in_analog_right[i][0] = (input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; - in_analog_right[i][1] = (input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; + in_analog_left[i][0] = min((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 255) + 128, 255); + in_analog_left[i][1] = min((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 255) + 128, 255); + in_analog_right[i][0] = min((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 255) + 128, 255); + in_analog_right[i][1] = min((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 255) + 128, 255); } } -- cgit v1.2.3 From 65e1ed6336087968fa9e7631f1a653210c2ce564 Mon Sep 17 00:00:00 2001 From: Jools Wills Date: Sat, 26 Nov 2016 04:25:15 +0000 Subject: enable dynarec core - was hardcoded to off - fixes #78 --- frontend/libretro.c | 1 - 1 file changed, 1 deletion(-) (limited to 'frontend') diff --git a/frontend/libretro.c b/frontend/libretro.c index f9be756..44cb974 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -1598,7 +1598,6 @@ void retro_init(void) if(!__ctr_svchax) Config.Cpu = CPU_INTERPRETER; #endif - Config.Cpu = CPU_INTERPRETER; ret |= emu_core_init(); if (ret != 0) { -- cgit v1.2.3 From 8fc5171a4c53b6f0e7ef7247d36ee5e05eaf0a07 Mon Sep 17 00:00:00 2001 From: Gregor Richards Date: Fri, 9 Dec 2016 19:56:33 -0500 Subject: Report git version with library_version --- frontend/libretro.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'frontend') diff --git a/frontend/libretro.c b/frontend/libretro.c index 44cb974..589f07c 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -638,7 +638,10 @@ void retro_get_system_info(struct retro_system_info *info) { memset(info, 0, sizeof(*info)); info->library_name = "PCSX-ReARMed"; - info->library_version = "r22"; +#ifndef GIT_VERSION +#define GIT_VERSION "" +#endif + info->library_version = "r22" GIT_VERSION; info->valid_extensions = "bin|cue|img|mdf|pbp|toc|cbn|m3u"; info->need_fullpath = true; } -- cgit v1.2.3