Skip to content

Commit

Permalink
Merge branch 'master' into libretro
Browse files Browse the repository at this point in the history
  • Loading branch information
notaz committed Nov 8, 2024
2 parents 61745af + 397c3db commit cf0a1a1
Show file tree
Hide file tree
Showing 25 changed files with 358 additions and 218 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ OBJS += $(LCHDR)/src/libchdr_cdrom.o
OBJS += $(LCHDR)/src/libchdr_chd.o
OBJS += $(LCHDR)/src/libchdr_flac.o
OBJS += $(LCHDR)/src/libchdr_huffman.o
$(LCHDR)/src/%.o: CFLAGS += -Wno-unused -Wno-maybe-uninitialized -std=gnu11
$(LCHDR)/src/%.o: CFLAGS += -Wno-unused -Wno-maybe-uninitialized -Wno-format -std=gnu11
OBJS += $(LCHDR_LZMA)/src/Alloc.o
OBJS += $(LCHDR_LZMA)/src/CpuArch.o
OBJS += $(LCHDR_LZMA)/src/Delta.o
Expand Down
4 changes: 4 additions & 0 deletions Makefile.libretro
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ else ifeq ($(platform), vita)
LD = arm-vita-eabi-ld$(EXE_EXT)
OBJCOPY = arm-vita-eabi-objcopy$(EXE_EXT)
else ifeq ($(platform), ctr)
ifneq ($(strip $(DEVKITPRO)),)
DEVKITARM ?= $(DEVKITPRO)/devkitARM
CTRULIB ?= $(DEVKITPRO)/libctru
endif
ifeq ($(strip $(DEVKITARM)),)
$(error "DEVKITARM env var is not set")
endif
Expand Down
7 changes: 5 additions & 2 deletions frontend/libretro-rthreads.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@ void pcsxr_sthread_init(void)
SysPrintf("%d cpu core(s) detected\n", cpu_features_get_core_amount());
#ifdef _3DS
int64_t version = 0;
int fpscr = -1;

APT_CheckNew3DS(&is_new_3ds);
svcGetSystemInfo(&version, 0x10000, 0);

APT_SetAppCpuTimeLimit(35);
u32 percent = -1;
APT_GetAppCpuTimeLimit(&percent);

SysPrintf("%s3ds detected, v%d.%d, AppCpuTimeLimit=%ld\n",
__asm__ volatile("fmrx %0, fpscr" : "=r"(fpscr));
SysPrintf("%s3ds detected, v%d.%d, AppCpuTimeLimit=%ld fpscr=%08x\n",
is_new_3ds ? "new" : "old", (int)GET_VERSION_MAJOR(version),
(int)GET_VERSION_MINOR(version), percent);
(int)GET_VERSION_MINOR(version), percent, fpscr);
#endif
}

Expand Down
12 changes: 4 additions & 8 deletions frontend/libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -2297,7 +2297,10 @@ static void update_variables(bool in_flight)
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
int psxclock = atoi(var.value);
Config.cycle_multiplier = 10000 / psxclock;
if (strcmp(var.value, "auto") == 0 || psxclock == 0)
Config.cycle_multiplier = CYCLE_MULT_DEFAULT;
else
Config.cycle_multiplier = 10000 / psxclock;
}

#if !defined(DRC_DISABLE) && !defined(LIGHTREC)
Expand Down Expand Up @@ -3612,13 +3615,6 @@ void retro_init(void)
if (environ_cb(RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE, &rumble))
rumble_cb = rumble.set_rumble_state;

/* Set how much slower PSX CPU runs * 100 (so that 200 is 2 times)
* we have to do this because cache misses and some IO penalties
* are not emulated. Warning: changing this may break compatibility. */
Config.cycle_multiplier = CYCLE_MULT_DEFAULT;
#if defined(HAVE_PRE_ARMV7) && !defined(_3DS)
Config.cycle_multiplier = 200;
#endif
pl_rearmed_cbs.gpu_peops.iUseDither = 1;
pl_rearmed_cbs.gpu_peops.dwActFixes = GPU_PEOPS_OLD_FRAME_SKIP;

Expand Down
7 changes: 2 additions & 5 deletions frontend/libretro_core_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
NULL,
"system",
{
{ "auto", "Auto" },
{ "30", NULL },
{ "31", NULL },
{ "32", NULL },
Expand Down Expand Up @@ -312,11 +313,7 @@ struct retro_core_option_v2_definition option_defs_us[] = {
{ "100", NULL },
{ NULL, NULL },
},
#if defined(HAVE_PRE_ARMV7) && !defined(_3DS)
"50",
#else
"57",
#endif
"auto",
},
{
"pcsx_rearmed_dithering",
Expand Down
2 changes: 1 addition & 1 deletion libpcsxcore/cdriso.c
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,7 @@ int ISOreadTrack(const unsigned char *time, void *buf)

ret = cdimg_read_func(cdHandle, 0, buf, sector);
if (ret < 12*2 + 2048) {
if (multifile && sector >= msf2sec(ti[1].length)) {
if (buf && multifile && sector >= msf2sec(ti[1].length)) {
// assume a gap not backed by a file
memset(buf, 0, CD_FRAMESIZE_RAW);
return 0;
Expand Down
7 changes: 4 additions & 3 deletions libpcsxcore/cdrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ static int ReadTrack(const u8 *time)
return 1;

ret = cdra_readTrack(time);
if (ret != 0)
if (ret == 0)
memcpy(cdr.Prev, time, 3);
return ret == 0;
}
Expand Down Expand Up @@ -1793,8 +1793,9 @@ int cdrFreeze(void *f, int Mode) {
tmpp[1] = btoi(tmpp[1]);
tmpp[2] = btoi(tmpp[2]);
}
cdr.Prev[0]++;
ReadTrack(tmpp);
cdr.Prev[0] = 0xff;
if (tmpp[0] != 0xff)
ReadTrack(tmpp);

if (cdr.Play) {
if (cdr.freeze_ver < 0x63647202)
Expand Down
2 changes: 2 additions & 0 deletions libpcsxcore/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ cycle_multiplier_overrides[] =
{ 200, { "SCES02873" } },
/* Zero Divide - sometimes too fast */
{ 200, { "SLUS00183", "SLES00159", "SLPS00083", "SLPM80008" } },
/* Eagle One: Harrier Attack - hangs (but not in standalone build?) */
{ 153, { "SLUS00943" } },
};

static const struct
Expand Down
4 changes: 2 additions & 2 deletions libpcsxcore/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,6 @@ int LoadState(const char *file) {
CdromFrontendId = misc->CdromFrontendId;
}

psxCpu->Notify(R3000ACPU_NOTIFY_AFTER_LOAD, NULL);

if (Config.HLE)
psxBiosFreeze(0);

Expand Down Expand Up @@ -828,6 +826,8 @@ int LoadState(const char *file) {
if (Config.HLE)
psxBiosCheckExe(biosBranchCheckOld, 0x60, 1);

psxCpu->Notify(R3000ACPU_NOTIFY_AFTER_LOAD, NULL);

result = 0;
cleanup:
memset(misc, 0, sizeof(*misc));
Expand Down
4 changes: 4 additions & 0 deletions libpcsxcore/new_dynarec/emu_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,10 @@ static void ari64_thread_init(void)
else {
u32 cpu_count = cpu_features_get_core_amount();
enable = cpu_count > 1;
#ifdef _3DS
// bad for old3ds, reprotedly no improvement for new3ds
enable = 0;
#endif
}

if (!ndrc_g.thread.handle == !enable)
Expand Down
2 changes: 2 additions & 0 deletions libpcsxcore/psxcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ extern int Log;

void __Log(char *fmt, ...);

// lots of timing depends on this and makes or breaks compatibility,
// don't change unless you're going to retest hundreds of games
#define CYCLE_MULT_DEFAULT 175

typedef struct {
Expand Down
13 changes: 7 additions & 6 deletions plugins/gpu_neon/psx_gpu/psx_gpu_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const u8 command_lengths[256] =
};
#endif

void update_texture_ptr(psx_gpu_struct *psx_gpu)
static void update_texture_ptr(psx_gpu_struct *psx_gpu)
{
u8 *texture_base;
u8 *texture_ptr;
Expand Down Expand Up @@ -91,7 +91,7 @@ void update_texture_ptr(psx_gpu_struct *psx_gpu)
psx_gpu->texture_page_ptr = texture_ptr;
}

void set_texture(psx_gpu_struct *psx_gpu, u32 texture_settings)
static void set_texture(psx_gpu_struct *psx_gpu, u32 texture_settings)
{
texture_settings &= 0x1FF;
if(psx_gpu->texture_settings != texture_settings)
Expand Down Expand Up @@ -135,17 +135,18 @@ void set_texture(psx_gpu_struct *psx_gpu, u32 texture_settings)
}
}

void set_clut(psx_gpu_struct *psx_gpu, u32 clut_settings)
static void set_clut(psx_gpu_struct *psx_gpu, u32 clut_settings)
{
if(psx_gpu->clut_settings != clut_settings)
clut_settings &= 0x7FFF;
if (psx_gpu->clut_settings != clut_settings)
{
flush_render_block_buffer(psx_gpu);
psx_gpu->clut_settings = clut_settings;
psx_gpu->clut_ptr = psx_gpu->vram_ptr + ((clut_settings & 0x7FFF) * 16);
psx_gpu->clut_ptr = psx_gpu->vram_ptr + clut_settings * 16;
}
}

void set_triangle_color(psx_gpu_struct *psx_gpu, u32 triangle_color)
static void set_triangle_color(psx_gpu_struct *psx_gpu, u32 triangle_color)
{
if(psx_gpu->triangle_color != triangle_color)
{
Expand Down
Loading

0 comments on commit cf0a1a1

Please sign in to comment.