Use SDL timer for counters and sleep the thread

This commit is contained in:
Francisco Javier Trujillo Mata 2018-10-19 00:56:14 +02:00
parent 5ba2509e7c
commit 17d30f9dd5
4 changed files with 12 additions and 19 deletions

View File

@ -15,7 +15,7 @@ IRX_DIR = $(PS2SDK)/iop/irx
TARGET = retroarchps2.elf
ifeq ($(DEBUG), 1)
OPTIMIZE_LV := -O2 -g
OPTIMIZE_LV := -O0 -g
RARCH_DEFINES += -DDEBUG
else
OPTIMIZE_LV := -O2
@ -41,7 +41,7 @@ LDFLAGS = -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ee/lib -L.
#LIBS = $(WHOLE_START) -lretro_ps2 $(WHOLE_END) -lstdc++ -lm -lz -lgskit -ldmakit -lpng -laudsrv -lpad -lcdvd -lmad -lfileXio -lpatches
LIBS = -Xlinker --start-group
LIBS += $(WHOLE_START) -lretro_ps2 $(WHOLE_END)
LIBS += -lfileXio -lm -lg -lz -ldebug -lfileXio -laudsrv -lpatches -lpoweroff -ldma -lgskit -ldmakit -lpad
LIBS += -lm -lg -lz -ldebug -lfileXio -laudsrv -lpatches -lpoweroff -ldma -lgskit -ldmakit -lpad -lsdl
#IRX modules
# IRX modules - modules have to be in IRX_DIR

View File

@ -26,6 +26,7 @@
#include <sifrpc.h>
#include <iopcontrol.h>
#include <libpwroff.h>
#include <SDL/SDL.h>
enum BootDeviceIDs{
@ -329,6 +330,8 @@ static void frontend_ps2_init(void *data)
fileXioInit();
audsrv_init();
SDL_Init(SDL_INIT_TIMER);
}
static void frontend_ps2_deinit(void *data)

View File

@ -68,6 +68,7 @@
#if defined(PS2)
#include <kernel.h>
#include <timer.h>
#include <SDL/SDL.h>
#endif
#if defined(__PSL1GHT__)
@ -190,7 +191,7 @@ retro_perf_tick_t cpu_features_get_perf_counter(void)
#elif defined(VITA)
sceRtcGetCurrentTick((SceRtcTick*)&time_ticks);
#elif defined(PS2)
time_ticks = ((uint64_t)cpu_ticks());
time_ticks = SDL_GetTicks()*294912; // 294,912MHZ / 1000 msecs
#elif defined(_3DS)
time_ticks = svcGetSystemTick();
#elif defined(WIIU)
@ -240,7 +241,7 @@ retro_time_t cpu_features_get_time_usec(void)
#elif defined(EMSCRIPTEN)
return emscripten_get_now() * 1000;
#elif defined(PS2)
return cpu_ticks()/295.0;
return SDL_GetTicks()*1000;
#elif defined(__mips__) || defined(DJGPP)
struct timeval tv;
gettimeofday(&tv,NULL);
@ -802,6 +803,8 @@ uint64_t cpu_features_get(void)
cpu |= RETRO_SIMD_PS;
#endif
printf("CPU is %i\n", cpu);
if (cpu & RETRO_SIMD_MMX) strlcat(buf, " MMX", sizeof(buf));
if (cpu & RETRO_SIMD_MMXEXT) strlcat(buf, " MMXEXT", sizeof(buf));
if (cpu & RETRO_SIMD_SSE) strlcat(buf, " SSE", sizeof(buf));

View File

@ -38,7 +38,7 @@
#elif defined(VITA)
#include <psp2/kernel/threadmgr.h>
#elif defined(PS2)
#include <kernel.h>
#include <SDL/SDL_timer.h>
#elif defined(_3DS)
#include <3ds.h>
#else
@ -79,13 +79,6 @@ static int nanosleepDOS(const struct timespec *rqtp, struct timespec *rmtp)
#define nanosleep nanosleepDOS
#endif
#if defined(PS2)
static void threadWakeupCB(s32 alarm_id, u16 time, void *common)
{
iWakeupThread(*(int*)common);
}
#endif
/**
* retro_sleep:
* @msec : amount in milliseconds to sleep
@ -99,13 +92,7 @@ static INLINE void retro_sleep(unsigned msec)
#elif defined(PSP) || defined(VITA)
sceKernelDelayThread(1000 * msec);
#elif defined(PS2)
int ThreadID;
if(msec>0){
ThreadID=GetThreadId();
SetAlarm(msec * 16, &threadWakeupCB, &ThreadID);
SleepThread();
}
SDL_Delay(msec);
#elif defined(_3DS)
svcSleepThread(1000000 * (s64)msec);
#elif defined(__WINRT__)