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
{
@ -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

@ -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

@ -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

@ -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>

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

@ -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__)
@ -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