mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-25 12:46:03 +00:00
PS2 Timing Improvement
This commit is contained in:
parent
74c8c13102
commit
d5a8c30dfe
13
Makefile.ps2
13
Makefile.ps2
@ -5,6 +5,7 @@ HAVE_LOGGER = 0
|
||||
HAVE_FILE_LOGGER = 0
|
||||
HAVE_THREADS = 0
|
||||
BIG_STACK = 0
|
||||
MUTE_WARNINGS = 0
|
||||
PS2_IP = 192.168.1.150
|
||||
|
||||
#Configuration for IRX
|
||||
@ -19,20 +20,26 @@ ifeq ($(DEBUG), 1)
|
||||
RARCH_DEFINES += -DDEBUG
|
||||
else
|
||||
OPTIMIZE_LV := -O2
|
||||
LDFLAGS := -s
|
||||
endif
|
||||
|
||||
ifeq ($(MUTE_WARNINGS), 1)
|
||||
DISABLE_WARNINGS := -Wno-sign-compare -Wno-unused -Wno-parentheses
|
||||
endif
|
||||
|
||||
|
||||
INCDIR = -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ports/include
|
||||
INCDIR += -Ips2 -Ips2/include -Ilibretro-common/include
|
||||
INCDIR += -Ideps -Ideps/stb -Ideps/libz -Ideps/7zip -Ideps/pthreads -Ideps/pthreads/platform/ps2 -Ideps/pthreads/platform/helper
|
||||
GPVAL = -G0
|
||||
CFLAGS = $(OPTIMIZE_LV) -ffast-math -fsingle-precision-constant
|
||||
CFLAGS = $(OPTIMIZE_LV) $(DISABLE_WARNINGS) -ffast-math -fsingle-precision-constant
|
||||
ASFLAGS = $(CFLAGS)
|
||||
|
||||
RARCH_DEFINES += -DPS2 -DUSE_IOP_CTYPE_MACRO -D_MIPS_ARCH_R5900 -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DWANT_ZLIB
|
||||
RARCH_DEFINES += -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DRARCH_CONSOLE -DHAVE_MENU -DHAVE_RGUI -DHAVE_FILTERS_BUILTIN -DHAVE_7ZIP -DHAVE_CC_RESAMPLER
|
||||
|
||||
LIBDIR =
|
||||
LDFLAGS = -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ee/lib -L. -s
|
||||
LDFLAGS += -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ee/lib -L.
|
||||
LIBS += -lretro_ps2 -lgskit -ldmakit -laudsrv -lpad -lmc -lhdd -lsdl -lfileXio -lpatches -lpoweroff
|
||||
|
||||
#IRX modules
|
||||
@ -60,7 +67,7 @@ endif
|
||||
CFLAGS += $(RARCH_DEFINES)
|
||||
|
||||
# Missing objecst on the PS2SDK
|
||||
EE_OBJS += ps2/compat_ctype.o
|
||||
EE_OBJS += ps2/compat_files/compat_ctype.o ps2/compat_files/time.o
|
||||
|
||||
#EE_OBJS = griffin/griffin.o bootstrap/ps2/kernel_functions.o
|
||||
EE_OBJS += griffin/griffin.o
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <sifrpc.h>
|
||||
#include <iopcontrol.h>
|
||||
#include <libpwroff.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <audsrv.h>
|
||||
|
||||
|
||||
@ -361,8 +360,6 @@ static void frontend_ps2_init(void *data)
|
||||
SifExecModuleBuffer(freesd_irx_start, freesd_irx_size, 0, NULL, NULL);
|
||||
SifExecModuleBuffer(audsrv_irx_start, audsrv_irx_size, 0, NULL, NULL);
|
||||
|
||||
SDL_Init(SDL_INIT_TIMER);
|
||||
|
||||
/* Initializes audsrv library */
|
||||
if (audsrv_init())
|
||||
{
|
||||
|
@ -230,7 +230,7 @@ static bool ps2_gfx_frame(void *data, const void *frame,
|
||||
return false;
|
||||
|
||||
if (frame_count%120==0) {
|
||||
printf("ps2_gfx_frame %i\n", frame_count);
|
||||
printf("ps2_gfx_frame %d\n", frame_count);
|
||||
}
|
||||
gsKit_vram_clear(ps2->gsGlobal);
|
||||
|
||||
|
@ -68,7 +68,6 @@
|
||||
#if defined(PS2)
|
||||
#include <kernel.h>
|
||||
#include <timer.h>
|
||||
#include <SDL/SDL.h>
|
||||
#endif
|
||||
|
||||
#if defined(__PSL1GHT__)
|
||||
@ -191,7 +190,7 @@ retro_perf_tick_t cpu_features_get_perf_counter(void)
|
||||
#elif defined(VITA)
|
||||
sceRtcGetCurrentTick((SceRtcTick*)&time_ticks);
|
||||
#elif defined(PS2)
|
||||
time_ticks = SDL_GetTicks()*294912; // 294,912MHZ / 1000 msecs
|
||||
time_ticks = clock()*294912; // 294,912MHZ / 1000 msecs
|
||||
#elif defined(_3DS)
|
||||
time_ticks = svcGetSystemTick();
|
||||
#elif defined(WIIU)
|
||||
@ -241,7 +240,7 @@ retro_time_t cpu_features_get_time_usec(void)
|
||||
#elif defined(EMSCRIPTEN)
|
||||
return emscripten_get_now() * 1000;
|
||||
#elif defined(PS2)
|
||||
return SDL_GetTicks()*1000;
|
||||
return clock()*1000;
|
||||
#elif defined(__mips__) || defined(DJGPP)
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv,NULL);
|
||||
|
@ -853,9 +853,9 @@ bool scond_wait_timeout(scond_t *cond, slock_t *lock, int64_t timeout_us)
|
||||
now.tv_sec = s;
|
||||
now.tv_nsec = n;
|
||||
#elif defined(PS2)
|
||||
int tickUS = cpu_ticks()/295.0;
|
||||
now.tv_sec = tickUS/1000000;
|
||||
now.tv_nsec = tickUS * 1000;
|
||||
int tickms = clock();
|
||||
now.tv_sec = tickms/1000;
|
||||
now.tv_nsec = tickms * 1000;
|
||||
#elif defined(__mips__) || defined(VITA) || defined(_3DS)
|
||||
struct timeval tm;
|
||||
|
||||
|
@ -20,7 +20,13 @@
|
||||
|
||||
#define ULLONG_MAX UINT64_C(0xffffffffffffffff)
|
||||
|
||||
/* Do not link from libc */
|
||||
/* All the functions included in this file either could be:
|
||||
- Because the PS2SDK doesn't contains this specific functionality
|
||||
- Because the PS2SDK implementation is wrong
|
||||
|
||||
Overrriding these methods here, make that the RetroArch will execute this code
|
||||
rather than the code in the linked libraries
|
||||
*/
|
||||
|
||||
int islower(int c)
|
||||
{
|
108
ps2/compat_files/time.c
Executable file
108
ps2/compat_files/time.c
Executable file
@ -0,0 +1,108 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2019 - Francisco Javier Trujillo Mata - fjtrujy
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
* * You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* This file improve the content of the original time.c file that belong to the PS2SDK.
|
||||
The original time.c contains 4 non-static methods
|
||||
|
||||
void _ps2sdk_time_init(void);
|
||||
void _ps2sdk_time_deinit(void);
|
||||
clock_t clock(void);
|
||||
time_t time(time_t *t);
|
||||
|
||||
So we need to duplicate all the method because this way the compiler will avoid to import
|
||||
the code that belong to the PS2SDK */
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <libcdvd-common.h>
|
||||
#include <osd_config.h>
|
||||
|
||||
#define STARTING_YEAR 2000
|
||||
#define MIN_SUPPORTED_YEAR 1970
|
||||
#define MAX_SUPPORTED_YEAR 2108
|
||||
#define SECS_MIN 60L
|
||||
#define MINS_HOUR 60L
|
||||
#define HOURS_DAY 24L
|
||||
#define DAYS_YEAR 365L
|
||||
#define DEC(x) (10*(x/16)+(x%16))
|
||||
int _days[] = {-1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364};
|
||||
|
||||
static time_t _gmtotime_t (
|
||||
int yr, /* 0 based */
|
||||
int mo, /* 1 based */
|
||||
int dy, /* 1 based */
|
||||
int hr,
|
||||
int mn,
|
||||
int sc
|
||||
)
|
||||
{
|
||||
int passed_years;
|
||||
long passed_days;
|
||||
long passed_seconds_current_day;
|
||||
time_t seconds_from_1970 = -1;
|
||||
|
||||
if ((yr >= MIN_SUPPORTED_YEAR) || (yr <= MAX_SUPPORTED_YEAR)) {
|
||||
passed_years = (long)yr - MIN_SUPPORTED_YEAR; /* Years after 1970 */
|
||||
/* Calculate days for these years */
|
||||
passed_days = passed_years * DAYS_YEAR;
|
||||
passed_days += (passed_years >> 2) * (DAYS_YEAR + 1); /* passed leap years */
|
||||
passed_days += dy + _days[mo - 1]; /* passed days in the year */
|
||||
if ( !(yr & 3) && (mo > 2) ) {
|
||||
passed_days++; /* if current year, is a leap year */
|
||||
}
|
||||
passed_seconds_current_day = (((hr * MINS_HOUR) + mn) * SECS_MIN) + sc;
|
||||
seconds_from_1970 = (passed_days * HOURS_DAY * MINS_HOUR * SECS_MIN) + passed_seconds_current_day;
|
||||
}
|
||||
|
||||
return seconds_from_1970;
|
||||
}
|
||||
|
||||
/* Protected methods in libc */
|
||||
void _ps2sdk_time_init(void)
|
||||
{
|
||||
SDL_Init(SDL_INIT_TIMER);
|
||||
}
|
||||
|
||||
/* Protected methods in libc */
|
||||
void _ps2sdk_time_deinit(void)
|
||||
{
|
||||
SDL_QuitSubSystem(SDL_INIT_TIMER);
|
||||
}
|
||||
|
||||
clock_t clock(void)
|
||||
{
|
||||
return SDL_GetTicks();
|
||||
}
|
||||
|
||||
time_t time(time_t *t) {
|
||||
time_t tim;
|
||||
sceCdCLOCK clocktime; /* defined in libcdvd.h */
|
||||
|
||||
sceCdReadClock(&clocktime); /* libcdvd.a */
|
||||
configConvertToLocalTime(&clocktime);
|
||||
|
||||
tim = _gmtotime_t (DEC(clocktime.year)+ STARTING_YEAR,
|
||||
DEC(clocktime.month),
|
||||
DEC(clocktime.day),
|
||||
DEC(clocktime.hour),
|
||||
DEC(clocktime.minute),
|
||||
DEC(clocktime.second));
|
||||
|
||||
if(t)
|
||||
*t = tim;
|
||||
|
||||
return tim;
|
||||
}
|
@ -27,7 +27,7 @@ typedef unsigned short uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned long uint64_t;
|
||||
|
||||
#define STDIN_FILENO 0 /* standard input file descriptor */
|
||||
#define STDIN_FILENO 0 /* standard input file descriptor */
|
||||
#define STDOUT_FILENO 1 /* standard output file descriptor */
|
||||
#define STDERR_FILENO 2 /* standard error file descriptor */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user