From 87cc59de47301ff0a2e71b5ece28447ec77b0153 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 9 Feb 2020 14:12:16 +0100 Subject: [PATCH] (Android) Aarch64/x86/x64 now has lightrec support --- Makefile | 1 + frontend/libretro.c | 15 +++++++++++- jni/Android.mk | 55 +++++++++++++++++++++++++++++++++++++------- libpcsxcore/misc.c | 2 +- libpcsxcore/psxmem.h | 4 +++- libpcsxcore/r3000a.c | 2 +- 6 files changed, 67 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index aff5c600..f633665e 100644 --- a/Makefile +++ b/Makefile @@ -103,6 +103,7 @@ CFLAGS += -Ideps/mman OBJS += deps/mman/mman.o endif else ifeq "$(DYNAREC)" "ari64" +CFLAGS += -DNEW_DYNAREC OBJS += libpcsxcore/new_dynarec/backends/psx/emu_if.o \ libpcsxcore/new_dynarec/new_dynarec.o \ libpcsxcore/new_dynarec/arm/linkage_arm.o \ diff --git a/frontend/libretro.c b/frontend/libretro.c index 6f543a95..3e2c64ae 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -59,6 +59,18 @@ #define INTERNAL_FPS_SAMPLE_PERIOD 64 +#ifdef DRC_DISABLE +int stop; +u32 next_interupt; +u32 event_cycles[PSXINT_COUNT]; +int cycle_multiplier; +int new_dynarec_hacks; + +void new_dyna_before_save(void) { } +void new_dyna_after_save(void) { } +void new_dyna_freeze(void *f, int i) { } +#endif + //hack to prevent retroarch freezing when reseting in the menu but not while running with the hot key static int rebootemu = 0; @@ -2142,7 +2154,8 @@ static void update_variables(bool in_flight) } } } -#ifndef DRC_DISABLE + +#if defined(LIGHTREC) || defined(NEW_DYNAREC) var.value = "NULL"; var.key = "pcsx_rearmed_psxclock"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) diff --git a/jni/Android.mk b/jni/Android.mk index 3ebdf97a..bf1c3c5a 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -18,6 +18,7 @@ UNAI_DIR := $(ROOT_DIR)/plugins/gpu_unai DYNAREC_DIR := $(ROOT_DIR)/libpcsxcore/new_dynarec DEPS_DIR := $(ROOT_DIR)/deps LIBRETRO_COMMON := $(ROOT_DIR)/libretro-common +EXTRA_INCLUDES := # core SOURCES_C := $(CORE_DIR)/cdriso.c \ @@ -114,31 +115,68 @@ SOURCES_C += \ $(DEPS_DIR)/libchdr/chd.c \ $(DEPS_DIR)/libchdr/flac.c \ $(DEPS_DIR)/libchdr/huffman.c - -# dynarec -SOURCES_C += $(DYNAREC_DIR)/backends/psx/emu_if.c +SOURCES_ASM := COREFLAGS := -ffast-math -funroll-loops -DHAVE_LIBRETRO -DNO_FRONTEND -DFRONTEND_SUPPORTS_RGB565 -DANDROID -DREARMED COREFLAGS += -DPACKAGE_VERSION=\"1.3.2\" -DFLAC__HAS_OGG=0 -DFLAC__NO_DLL -DHAVE_LROUND -DHAVE_STDINT_H -DHAVE_STDLIB_H -DFLAC__NO_DLL -D_7ZIP_ST -DHAVE_SYS_PARAM_H COREFLAGS += -DHAVE_CHD -ifeq ($(TARGET_ARCH),arm) - SOURCES_ASM := $(CORE_DIR)/gte_arm.S \ +HAVE_ARI64=0 +HAVE_LIGHTREC=0 +ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) + HAVE_ARI64=1 +else ifeq ($(TARGET_ARCH_ABI),armeabi) + HAVE_ARI64=1 +else ifeq ($(TARGET_ARCH_ABI),arm64-v8a) + HAVE_LIGHTREC=1 +else ifeq ($(TARGET_ARCH_ABI),x86_64) + HAVE_LIGHTREC=1 +else ifeq ($(TARGET_ARCH_ABI),x86) + HAVE_LIGHTREC=1 +else + COREFLAGS += -DDRC_DISABLE +endif + +ifeq ($(HAVE_ARI64),1) + COREFLAGS += -DNEW_DYNAREC + SOURCES_ASM += $(CORE_DIR)/gte_arm.S \ $(SPU_DIR)/arm_utils.S \ $(DYNAREC_DIR)/arm/linkage_arm.S SOURCES_C += $(DYNAREC_DIR)/new_dynarec.c \ $(DYNAREC_DIR)/backends/psx/pcsxmem.c -else - COREFLAGS += -DDRC_DISABLE - SOURCES_ASM := endif +ifeq ($(HAVE_LIGHTREC),1) + COREFLAGS += -DLIGHTREC -DLIGHTREC_STATIC + EXTRA_INCLUDES += $(DEPS_DIR)/lightning/include \ + $(DEPS_DIR)/lightrec + SOURCES_C += $(DEPS_DIR)/lightrec/blockcache.c \ + $(DEPS_DIR)/lightrec/disassembler.c \ + $(DEPS_DIR)/lightrec/emitter.c \ + $(DEPS_DIR)/lightrec/interpreter.c \ + $(DEPS_DIR)/lightrec/lightrec.c \ + $(DEPS_DIR)/lightrec/memmanager.c \ + $(DEPS_DIR)/lightrec/optimizer.c \ + $(DEPS_DIR)/lightrec/regcache.c \ + $(DEPS_DIR)/lightrec/recompiler.c + SOURCES_C += $(DEPS_DIR)/lightning/lib/jit_disasm.c \ + $(DEPS_DIR)/lightning/lib/jit_memory.c \ + $(DEPS_DIR)/lightning/lib/jit_names.c \ + $(DEPS_DIR)/lightning/lib/jit_note.c \ + $(DEPS_DIR)/lightning/lib/jit_print.c \ + $(DEPS_DIR)/lightning/lib/jit_size.c \ + $(DEPS_DIR)/lightning/lib/lightning.c + SOURCES_C += $(CORE_DIR)/lightrec/plugin.c +endif + + ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) COREFLAGS += -DNEON_BUILD -DTEXTURE_CACHE_4BPP -DTEXTURE_CACHE_8BPP SOURCES_ASM += $(CORE_DIR)/gte_neon.S \ $(NEON_DIR)/psx_gpu/psx_gpu_arm_neon.S \ $(FRONTEND_DIR)/cspace_neon.S SOURCES_C += $(NEON_DIR)/psx_gpu_if.c + SOURCES_C += $(DYNAREC_DIR)/backends/psx/emu_if.c else ifeq ($(TARGET_ARCH_ABI),armeabi) COREFLAGS += -DUSE_GPULIB=1 -DGPU_UNAI COREFLAGS += -DINLINE="static __inline__" -Dasm="__asm__ __volatile__" @@ -163,6 +201,7 @@ LOCAL_CFLAGS := $(COREFLAGS) LOCAL_C_INCLUDES := $(ROOT_DIR)/include LOCAL_C_INCLUDES += $(DEPS_DIR)/crypto $(DEPS_DIR)/flac-1.3.2/include $(DEPS_DIR)/flac-1.3.2/src/libFLAC/include $(DEPS_DIR)/lzma-16.04/C $(DEPS_DIR)/libchdr LOCAL_C_INCLUDES += $(LIBRETRO_COMMON)/include +LOCAL_C_INCLUDES += $(EXTRA_INCLUDES) LOCAL_LDFLAGS := -Wl,-version-script=$(FRONTEND_DIR)/link.T LOCAL_LDLIBS := -lz -llog LOCAL_ARM_MODE := arm diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c index 82e6b8b6..56b7552f 100644 --- a/libpcsxcore/misc.c +++ b/libpcsxcore/misc.c @@ -750,7 +750,7 @@ int RecvPcsxInfo() { NET_recvData(&Config.Cpu, sizeof(Config.Cpu), PSE_NET_BLOCKING); if (tmp != Config.Cpu) { psxCpu->Shutdown(); -#ifdef PSXREC +#if defined(NEW_DYNAREC) || defined(LIGHTREC) if (Config.Cpu == CPU_INTERPRETER) psxCpu = &psxInt; else psxCpu = &psxRec; #else diff --git a/libpcsxcore/psxmem.h b/libpcsxcore/psxmem.h index d9fee002..36b46936 100644 --- a/libpcsxcore/psxmem.h +++ b/libpcsxcore/psxmem.h @@ -122,9 +122,11 @@ extern u8 **psxMemRLUT; #define PSXMu32ref(mem) (*(u32 *)PSXM(mem)) -#if !defined(PSXREC) && (defined(__x86_64__) || defined(__i386__) || defined(__ppc__)) && !defined(NOPSXREC) +#ifndef PSXREC +#if defined(NEW_DYNAREC) || defined(LIGHTREC) #define PSXREC #endif +#endif int psxMemInit(); void psxMemReset(); diff --git a/libpcsxcore/r3000a.c b/libpcsxcore/r3000a.c index 0433c207..11181070 100644 --- a/libpcsxcore/r3000a.c +++ b/libpcsxcore/r3000a.c @@ -32,7 +32,7 @@ psxRegisters psxRegs; int psxInit() { SysPrintf(_("Running PCSX Version %s (%s).\n"), PCSX_VERSION, __DATE__); -#ifdef PSXREC +#if defined(NEW_DYNAREC) || defined(LIGHTREC) if (Config.Cpu == CPU_INTERPRETER) { psxCpu = &psxInt; } else psxCpu = &psxRec; -- 2.39.2