Merge pull request #2067 from xerpi/master

Update PSVita
This commit is contained in:
Twinaphex 2015-08-30 16:20:19 +02:00
commit 2fdaa89a81
7 changed files with 133 additions and 26 deletions

View File

@ -137,6 +137,22 @@ else ifeq ($(platform), psp1)
HAVE_LIBRETRO_MANAGEMENT := 1
HAVE_RPNG := 1
else ifeq ($(platform), vita)
CC = arm-vita-eabi-gcc$(EXE_EXT)
CXX = arm-vita-eabi-g++$(EXE_EXT)
LD = arm-vita-eabi-ld$(EXE_EXT)
INCLUDE +=
EXT_TARGET := $(TARGET_NAME).velf
EXT_INTER_TARGET := $(TARGET_NAME).elf
MACHDEP := -DVITA
PLATCFLAGS := -Wl,-q -Wall -O3
LIBS += -lSceKernel_stub -lSceDisplay_stub -lSceGxm_stub \
-lSceSysmodule_stub -lSceCtrl_stub -lScePgf_stub \
-lpng -ljpeg -lfreetype -lz -lm -lc
HAVE_LIBRETRO_MANAGEMENT := 1
HAVE_RPNG := 1
HAVE_VITA2D := 1
endif
CFLAGS += -Wall -std=gnu99 $(MACHDEP) $(INCLUDE)
@ -155,6 +171,10 @@ ifeq ($(platform), wii)
CFLAGS += -DHAVE_SOCKET_LEGACY
endif
ifeq ($(platform), vita)
CFLAGS += -DHAVE_SOCKET_LEGACY
endif
ifeq ($(HAVE_LIBRETRO_MANAGEMENT), 1)
CFLAGS += -DHAVE_LIBRETRO_MANAGEMENT
endif
@ -167,6 +187,10 @@ ifeq ($(HAVE_WIIUSB_HID), 1)
CFLAGS += -DHAVE_WIIUSB_HID -DHAVE_HID
endif
ifeq ($(HAVE_VITA2D), 1)
CFLAGS += -DHAVE_VITA2D
endif
ifeq ($(HAVE_LIBRETRODB), 1)
CFLAGS += -DHAVE_LIBRETRODB
endif
@ -225,6 +249,10 @@ LIBS += -lpthread-psp
endif
endif
ifeq ($(HAVE_VITA2D), 1)
LIBS += -lvita2d
endif
ifeq ($(HAVE_RSOUND), 1)
CFLAGS += -DHAVE_RSOUND
endif
@ -242,6 +270,10 @@ all: $(EXT_TARGET)
%.dol: %.elf
$(ELF2DOL) $< $@
%.velf: %.elf
arm-vita-eabi-strip -g $<
vita-elf-create $< $@ $(VITASDK)/bin/db.json
$(EXT_INTER_TARGET): $(OBJ)
$(CXX) -o $@ $(LDFLAGS) $(LIBDIRS) $(OBJ) $(LIBS)

View File

@ -28,6 +28,7 @@
#include <pspaudio.h>
#endif
#include <stdint.h>
#include <malloc.h>
typedef struct psp_audio
{
@ -64,10 +65,10 @@ static int audioMainLoop(SceSize args, void* argp)
< (AUDIO_OUT_COUNT * 2);
#ifdef VITA
sceAudioOutOutput(0,
sceAudioOutOutput(0,
cond ? psp->zeroBuffer : (psp->buffer + readPos));
#else
sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, cond ? (psp->zeroBuffer)
sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, cond ? (psp->zeroBuffer)
: (psp->buffer + readPos));
#endif
@ -111,8 +112,13 @@ static void *psp_audio_init(const char *device,
psp->readPos = 0;
psp->writePos = 0;
psp->rate = rate;
#if defined(VITA)
psp->thread = sceKernelCreateThread
("audioMainLoop", audioMainLoop, 0x10000100, 0x10000, 0, 0, NULL);
#else
psp->thread = sceKernelCreateThread
("audioMainLoop", audioMainLoop, 0x08, 0x10000, 0, NULL);
#endif
psp->nonblocking = false;
psp->running = true;
@ -129,8 +135,11 @@ static void psp_audio_free(void *data)
return;
psp->running = false;
#if defined(VITA)
sceKernelWaitThreadEnd(psp->thread, NULL, &timeout);
#else
sceKernelWaitThreadEnd(psp->thread, &timeout);
#endif
sceKernelDeleteThread(psp->thread);
free(psp->buffer);
@ -181,29 +190,64 @@ static bool psp_audio_alive(void *data)
static bool psp_audio_stop(void *data)
{
SceKernelThreadRunStatus runStatus;
SceUInt timeout = 100000;
psp_audio_t* psp = (psp_audio_t*)data;
#if defined(VITA)
SceKernelThreadInfo info;
info.size = sizeof(SceKernelThreadInfo);
if (sceKernelGetThreadInfo(
psp->thread, &info) < 0) /* Error */
return false;
if (info.status == PSP2_THREAD_STOPPED)
return false;
#else
SceKernelThreadRunStatus runStatus;
runStatus.size = sizeof(SceKernelThreadRunStatus);
if (sceKernelReferThreadRunStatus(
psp->thread, &runStatus) < 0) /* Error */
return false;
if (runStatus.status == PSP_THREAD_STOPPED)
return false;
#endif
psp->running = false;
#if defined(VITA)
sceKernelWaitThreadEnd(psp->thread, NULL, &timeout);
#else
sceKernelWaitThreadEnd(psp->thread, &timeout);
#endif
return true;
}
static bool psp_audio_start(void *data)
{
SceKernelThreadRunStatus runStatus;
psp_audio_t* psp = (psp_audio_t*)data;
#if defined(VITA)
SceKernelThreadInfo info;
info.size = sizeof(SceKernelThreadInfo);
if (sceKernelGetThreadInfo(
psp->thread, &info) < 0) /* Error */
return false;
if (info.status != PSP2_THREAD_STOPPED)
return false;
#else
SceKernelThreadRunStatus runStatus;
runStatus.size = sizeof(SceKernelThreadRunStatus);
if (sceKernelReferThreadRunStatus(
@ -212,6 +256,8 @@ static bool psp_audio_start(void *data)
if (runStatus.status != PSP_THREAD_STOPPED)
return false;
#endif
psp->running = true;
sceKernelStartThread(psp->thread, sizeof(psp_audio_t*), &psp);

View File

@ -1,7 +1,7 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis
*
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
@ -79,8 +79,8 @@
#define PSP_CTRL_SQUARE PSP2_CTRL_SQUARE
#define PSP_CTRL_CROSS PSP2_CTRL_CROSS
#define PSP_CTRL_CIRCLE PSP2_CTRL_CIRCLE
#define PSP_CTRL_L PSP2_CTRL_L
#define PSP_CTRL_R PSP2_CTRL_R
#define PSP_CTRL_L PSP2_CTRL_LTRIGGER
#define PSP_CTRL_R PSP2_CTRL_RTRIGGER
#else
#define DEFAULT_SAMPLING_MODE (SCE_CTRL_MODE_DIGITALANALOG)

View File

@ -1,7 +1,7 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis
*
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
@ -32,6 +32,9 @@
#elif defined(PSP)
#define EXT_EXECUTABLES "pbp"
#define SALAMANDER_FILE "EBOOT.PBP"
#elif defined(VITA)
#define EXT_EXECUTABLES "velf"
#define SALAMANDER_FILE "default.velf"
#elif defined(_XBOX1)
#define EXT_EXECUTABLES "xbe"
#define SALAMANDER_FILE "default.xbe"

View File

@ -1,7 +1,7 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis
*
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
@ -51,6 +51,16 @@
#include <network.h>
#elif defined(VITA)
#include <psp2/net/net.h>
#include <psp2/net/netctl.h>
#define sockaddr_in SceNetSockaddrIn
#define sockaddr SceNetSockaddr
#define sendto sceNetSendto
#define MSG_DONTWAIT PSP2_NET_MSG_DONTWAIT
#else
#include <sys/select.h>
#include <sys/types.h>
@ -112,7 +122,7 @@ static INLINE bool isagain(int bytes)
#ifdef _XBOX
#define socklen_t int
#ifndef h_addr
#ifndef h_addr
#define h_addr h_addr_list[0] /* for backward compatibility */
#endif

View File

@ -44,11 +44,20 @@ static char sendbuf[4096];
static int network_interface_up(struct sockaddr_in *target, int index,
const char *ip_address, unsigned udp_port, int *s)
{
int ret = 0;
(void)index;
#if defined(VITA)
*s = sceNetSocket("RA_netlogger", PSP2_NET_AF_INET, PSP2_NET_SOCK_DGRAM, 0);
target->sin_family = PSP2_NET_AF_INET;
target->sin_port = sceNetHtons(udp_port);
target->sin_len = 8;
sceNetInetPton(PSP2_NET_AF_INET, ip_address, &target->sin_addr);
#else
#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)
int ret = 0;
int state, timeout_count = 10;
ret = cellNetCtlInit();
if (ret < 0)
@ -85,7 +94,7 @@ static int network_interface_up(struct sockaddr_in *target, int index,
#endif
inet_pton(AF_INET, ip_address, &target->sin_addr);
#endif
return 0;
}

View File

@ -1,7 +1,7 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis
*
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
@ -53,6 +53,11 @@
#include <psprtc.h>
#endif
#if defined(VITA)
#include <psp2/kernel/processmgr.h>
#include <psp2/rtc.h>
#endif
#if defined(__PSL1GHT__)
#include <sys/time.h>
#elif defined(__CELLOS_LV2__)
@ -106,7 +111,7 @@ void rarch_perf_register(struct retro_perf_counter *perf)
{
global_t *global = global_get_ptr();
if (!global->perfcnt_enable || perf->registered
if (!global->perfcnt_enable || perf->registered
|| perf_ptr_rarch >= MAX_COUNTERS)
return;
@ -139,7 +144,7 @@ static void log_counters(
{
RARCH_LOG(PERF_LOG_FMT,
counters[i]->ident,
(unsigned long long)counters[i]->total /
(unsigned long long)counters[i]->total /
(unsigned long long)counters[i]->call_cnt,
(unsigned long long)counters[i]->call_cnt);
}
@ -176,10 +181,10 @@ retro_perf_tick_t rarch_get_perf_counter(void)
#if defined(__linux__) || defined(__QNX__) || defined(__MACH__)
struct timespec tv;
if (clock_gettime(CLOCK_MONOTONIC, &tv) == 0)
time_ticks = (retro_perf_tick_t)tv.tv_sec * 1000000000 +
time_ticks = (retro_perf_tick_t)tv.tv_sec * 1000000000 +
(retro_perf_tick_t)tv.tv_nsec;
#elif defined(__GNUC__) && !defined(RARCH_CONSOLE)
#elif defined(__GNUC__) && !defined(RARCH_CONSOLE)
#if defined(__i386__) || defined(__i486__) || defined(__i686__)
__asm__ volatile ("rdtsc" : "=A" (time_ticks));
@ -193,7 +198,7 @@ retro_perf_tick_t rarch_get_perf_counter(void)
__asm__ volatile( "mrc p15, 0, %0, c9, c13, 0" : "=r"(time_ticks) );
#elif defined(__CELLOS_LV2__) || defined(GEKKO) || defined(_XBOX360) || defined(__powerpc__) || defined(__ppc__) || defined(__POWERPC__)
time_ticks = __mftb();
#elif defined(PSP)
#elif defined(PSP) || defined(VITA)
sceRtcGetCurrentTick(&time_ticks);
#elif defined(_3DS)
time_ticks = svcGetSystemTick();
@ -259,6 +264,8 @@ retro_time_t rarch_get_time_usec(void)
return (1000000 * tv.tv_sec + tv.tv_usec);
#elif defined(_3DS)
return osGetTime() * 1000;
#elif defined(VITA)
return sceKernelGetProcessTimeWide();
#else
#error "Your platform does not have a timer function implemented in rarch_get_time_usec(). Cannot continue."
#endif
@ -275,7 +282,7 @@ retro_time_t rarch_get_time_usec(void)
#ifdef CPU_X86
static void x86_cpuid(int func, int flags[4])
{
/* On Android, we compile RetroArch with PIC, and we
/* On Android, we compile RetroArch with PIC, and we
* are not allowed to clobber the ebx register. */
#ifdef __x86_64__
#define REG_b "rbx"
@ -306,7 +313,7 @@ static uint64_t xgetbv_x86(uint32_t idx)
#if defined(__GNUC__)
uint32_t eax, edx;
__asm__ volatile (
/* Older GCC versions (Apple's GCC for example) do
/* Older GCC versions (Apple's GCC for example) do
* not understand xgetbv instruction.
* Stamp out the machine code directly.
*/
@ -326,7 +333,7 @@ static uint64_t xgetbv_x86(uint32_t idx)
#if defined(__ARM_NEON__)
static void arm_enable_runfast_mode(void)
{
/* RunFast mode. Enables flush-to-zero and some
/* RunFast mode. Enables flush-to-zero and some
* floating point optimizations. */
static const unsigned x = 0x04086060;
static const unsigned y = 0x03000000;
@ -418,7 +425,7 @@ uint64_t rarch_get_cpu_features(void)
char buf[sizeof(" MMX MMXEXT SSE SSE2 SSE3 SSSE3 SS4 SSE4.2 AES AVX AVX2 NEON VMX VMX128 VFPU PS")];
memset(buf, 0, sizeof(buf));
(void)cpu_flags;
(void)flags;
(void)max_flag;
@ -471,9 +478,9 @@ uint64_t rarch_get_cpu_features(void)
cpu |= RETRO_SIMD_AES;
/* Must only perform xgetbv check if we have
/* Must only perform xgetbv check if we have
* AVX CPU support (guaranteed to have at least i686). */
if (((flags[2] & avx_flags) == avx_flags)
if (((flags[2] & avx_flags) == avx_flags)
&& ((xgetbv_x86(0) & 0x6) == 0x6))
cpu |= RETRO_SIMD_AVX;