From 6466329a0d060b92eb181a2aef8bf2b7449101bc Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 15 Dec 2024 22:45:44 +0200 Subject: [PATCH 1/4] libretro: drop remnants of _async_cd there is pcsx_rearmed_cd_readahead now --- frontend/libretro.c | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 07b108c6..e01c80ab 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -2457,31 +2457,6 @@ static void update_variables(bool in_flight) } #endif -#if 0 // currently disabled, see USE_READ_THREAD in libpcsxcore/cdriso.c - if (P_HAVE_PTHREAD) { - var.value = NULL; - var.key = "pcsx_rearmed_async_cd"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - if (strcmp(var.value, "async") == 0) - { - Config.AsyncCD = 1; - Config.CHD_Precache = 0; - } - else if (strcmp(var.value, "sync") == 0) - { - Config.AsyncCD = 0; - Config.CHD_Precache = 0; - } - else if (strcmp(var.value, "precache") == 0) - { - Config.AsyncCD = 0; - Config.CHD_Precache = 1; - } - } - } -#endif - var.value = NULL; var.key = "pcsx_rearmed_noxadecoding"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) From c50a1845bb20259206f2fd26bc638b7d5be9f3ba Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 15 Dec 2024 23:28:39 +0200 Subject: [PATCH 2/4] vita: cleanup --- Makefile.libretro | 7 ++++--- frontend/libretro.c | 10 +--------- frontend/vita/sys/mman.h | 5 +++-- libpcsxcore/new_dynarec/new_dynarec.c | 3 +-- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index 7ea7addb..dc9aefa5 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -330,8 +330,9 @@ else ifeq ($(platform), vita) CFLAGS += -DVITA CFLAGS += -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -marm CFLAGS += -fsingle-precision-constant -mword-relocations -fno-unwind-tables - CFLAGS += -fno-asynchronous-unwind-tables -ftree-vectorize -funroll-loops - CFLAGS += -fno-optimize-sibling-calls + CFLAGS += -fno-asynchronous-unwind-tables -ftree-vectorize + #CFLAGS += -funroll-loops # ~280K bloat + #CFLAGS += -fno-optimize-sibling-calls # debug? CFLAGS += -I$(VITASDK)/include -Ifrontend/vita CFLAGS += -DNO_DYLIB CFLAGS_LAST += -O3 @@ -344,7 +345,7 @@ else ifeq ($(platform), vita) DYNAREC = ari64 ARCH = arm PARTIAL_LINKING = 1 - NO_PTHREAD=1 + NO_MMAP := 1 NO_POSIX_MEMALIGN := 1 HAVE_PHYSICAL_CDROM = 0 diff --git a/frontend/libretro.c b/frontend/libretro.c index e01c80ab..7f953a5f 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -573,7 +573,6 @@ static psx_map_t custom_psx_maps[] = { static int init_vita_mmap() { - int n; void *tmpaddr; addr = malloc(64 * 1024 * 1024); if (addr == NULL) @@ -587,6 +586,7 @@ static int init_vita_mmap() custom_psx_maps[5].buffer = tmpaddr + 0x2000000; memset(tmpaddr, 0, 0x2210000); #if 0 + int n; for(n = 0; n < 5; n++){ sceClibPrintf("addr reserved %x\n",custom_psx_maps[n].buffer); } @@ -3678,14 +3678,6 @@ void retro_deinit(void) update_audio_latency = false; } -#ifdef VITA -#include -int usleep(unsigned long us) -{ - sceKernelDelayThread(us); -} -#endif - void SysPrintf(const char *fmt, ...) { va_list list; diff --git a/frontend/vita/sys/mman.h b/frontend/vita/sys/mman.h index d2634836..e112bd03 100644 --- a/frontend/vita/sys/mman.h +++ b/frontend/vita/sys/mman.h @@ -2,8 +2,7 @@ #define MMAN_H #include -#include -#include +//#include #ifdef __cplusplus extern "C" { @@ -17,6 +16,7 @@ extern "C" { #define MAP_FAILED ((void *)-1) +#if 0 // not used static inline void* mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) { (void)prot; @@ -62,6 +62,7 @@ static inline int munmap(void *addr, size_t len) return sceKernelFreeMemBlock(uid); } +#endif #ifdef __cplusplus }; diff --git a/libpcsxcore/new_dynarec/new_dynarec.c b/libpcsxcore/new_dynarec/new_dynarec.c index e247faf2..6f64e961 100644 --- a/libpcsxcore/new_dynarec/new_dynarec.c +++ b/libpcsxcore/new_dynarec/new_dynarec.c @@ -6322,12 +6322,11 @@ void new_dynarec_init(void) #ifdef VITA sceBlock = getVMBlock(); //sceKernelAllocMemBlockForVM("code", sizeof(*ndrc)); if (sceBlock <= 0) - SysPrintf("sceKernelAllocMemBlockForVM failed: %x\n", sceBlock); + SysPrintf("getVMBlock failed: %x\n", sceBlock); int ret = sceKernelGetMemBlockBase(sceBlock, (void **)&ndrc); if (ret < 0) SysPrintf("sceKernelGetMemBlockBase failed: %x\n", ret); sceKernelOpenVMDomain(); - sceClibPrintf("translation_cache = 0x%08lx\n ", (long)ndrc->translation_cache); #elif defined(_MSC_VER) ndrc = VirtualAlloc(NULL, sizeof(*ndrc), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); From a5aec8730ae678f47fa71559b8f3a3aea066161a Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 16 Dec 2024 00:35:53 +0200 Subject: [PATCH 3/4] vita: try to fix alloc libretro/pcsx_rearmed#856 --- Makefile | 8 ++++++-- Makefile.libretro | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 52275723..e0c69350 100644 --- a/Makefile +++ b/Makefile @@ -475,8 +475,12 @@ target_: $(TARGET) $(TARGET): $(OBJS) ifeq ($(PARTIAL_LINKING), 1) - $(LD) -o $(basename $(TARGET))1.o -r --gc-sections $(addprefix -u , $(shell cat frontend/libretro-extern)) $^ - $(OBJCOPY) --keep-global-symbols=frontend/libretro-extern $(basename $(TARGET))1.o $(basename $(TARGET)).o + $(LD) -o $(basename $(TARGET))1.o -r --gc-sections \ + $(addprefix -u ,$(shell cat frontend/libretro-extern)) \ + $(addprefix -u ,$(EXTRA_EXTERN_SYMS)) $^ + $(OBJCOPY) --keep-global-symbols=frontend/libretro-extern \ + $(addprefix -G ,$(EXTRA_EXTERN_SYMS)) \ + $(basename $(TARGET))1.o $(basename $(TARGET)).o $(AR) rcs $@ $(basename $(TARGET)).o else ifeq ($(STATIC_LINKING), 1) $(AR) rcs $@ $^ diff --git a/Makefile.libretro b/Makefile.libretro index dc9aefa5..c8f99f93 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -348,6 +348,7 @@ else ifeq ($(platform), vita) NO_MMAP := 1 NO_POSIX_MEMALIGN := 1 HAVE_PHYSICAL_CDROM = 0 + EXTRA_EXTERN_SYMS += _newlib_vm_size_user # CTR(3DS) else ifeq ($(platform), ctr) From 9cbce417ea1e62570fb749c934806ed55c1dcbb3 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 16 Dec 2024 01:39:42 +0200 Subject: [PATCH 4/4] mdec: timing hacks libretro/pcsx_rearmed#846 --- libpcsxcore/database.c | 6 ++++-- libpcsxcore/mdec.c | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/libpcsxcore/database.c b/libpcsxcore/database.c index a393ee92..8e2a31ad 100644 --- a/libpcsxcore/database.c +++ b/libpcsxcore/database.c @@ -145,14 +145,16 @@ cycle_multiplier_overrides[] = /* Syphon Filter - reportedly hangs under unknown conditions */ { 169, { "SCUS94240" } }, /* Psychic Detective - some weird race condition in the game's cdrom code */ - { 222, { "SLUS00165", "SLUS00166", "SLUS00167" } }, - { 222, { "SLES00070", "SLES10070", "SLES20070" } }, + { 200, { "SLUS00165", "SLUS00166", "SLUS00167" } }, + { 200, { "SLES00070", "SLES10070", "SLES20070" } }, /* Vib-Ribbon - cd timing issues (PAL+ari64drc only?) */ { 200, { "SCES02873" } }, /* Zero Divide - sometimes too fast */ { 200, { "SLUS00183", "SLES00159", "SLPS00083", "SLPM80008" } }, /* Eagle One: Harrier Attack - hangs (but not in standalone build?) */ { 153, { "SLUS00943" } }, + /* Sol Divide: FMV timing */ + { 200, { "SLUS01519", "SCPS45260", "SLPS01463" } }, }; /* Function for automatic patching according to GameID. */ diff --git a/libpcsxcore/mdec.c b/libpcsxcore/mdec.c index d02a419a..f42e67bf 100644 --- a/libpcsxcore/mdec.c +++ b/libpcsxcore/mdec.c @@ -34,10 +34,12 @@ */ /* - * >= 10 for Galerians + * >= 14 for Sol Divide * <= 18 for "Disney's Treasure Planet" + * Psychic Detective may break on *any* change */ -#define MDEC_BIAS 10 +#define MDEC_BIAS 14 +#define MDEC_DELAY 1024 #define DSIZE 8 #define DSIZE2 (DSIZE * DSIZE) @@ -654,9 +656,9 @@ void psxDma1(u32 adr, u32 bcr, u32 chcr) { log_unhandled("mdec: bork\n"); /* define the power of mdec */ - set_event(PSXINT_MDECOUTDMA, words * MDEC_BIAS); + set_event(PSXINT_MDECOUTDMA, words * MDEC_BIAS + MDEC_DELAY); /* some CPU stalling */ - psxRegs.cycle += words; + psxRegs.cycle += words * MDEC_BIAS / 4; } void mdec1Interrupt() {