From: notaz Date: Tue, 24 Oct 2023 22:36:42 +0000 (+0300) Subject: gpulib: trust game's centering based on a database X-Git-Tag: r24l~102 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3ff74bacffbd393e3eef8f1a4251988d81d0ede;p=pcsx_rearmed.git gpulib: trust game's centering based on a database libretro/pcsx_rearmed#160 --- diff --git a/frontend/plugin.c b/frontend/plugin.c index 3683b500..88d756eb 100644 --- a/frontend/plugin.c +++ b/frontend/plugin.c @@ -264,6 +264,9 @@ void plugin_call_rearmed_cbs(void) extern void *hGPUDriver; void (*rearmed_set_cbs)(const struct rearmed_cbs *cbs); + pl_rearmed_cbs.screen_centering_type_default = + Config.hacks.gpu_centering ? C_INGAME : C_AUTO; + rearmed_set_cbs = SysLoadSym(hGPUDriver, "GPUrearmedCallbacks"); if (rearmed_set_cbs != NULL) rearmed_set_cbs(&pl_rearmed_cbs); diff --git a/frontend/plugin_lib.h b/frontend/plugin_lib.h index bafcb6c8..67313bda 100644 --- a/frontend/plugin_lib.h +++ b/frontend/plugin_lib.h @@ -115,6 +115,7 @@ struct rearmed_cbs { // misc int gpu_caps; int screen_centering_type; + int screen_centering_type_default; int screen_centering_x; int screen_centering_y; }; diff --git a/libpcsxcore/database.c b/libpcsxcore/database.c index 4c986702..5cdd78b8 100644 --- a/libpcsxcore/database.c +++ b/libpcsxcore/database.c @@ -45,6 +45,14 @@ static const char * const gpu_busy_hack_db[] = "SLPS01919", "SLPS01920", }; +static const char * const gpu_centering_hack_db[] = +{ + /* Gradius Gaiden */ + "SLPM86042", "SLPM86103", "SLPM87323", + /* Sexy Parodius */ + "SLPM86009", +}; + #define HACK_ENTRY(var, list) \ { #var, &Config.hacks.var, list, ARRAY_SIZE(list) } @@ -59,7 +67,8 @@ hack_db[] = { HACK_ENTRY(cdr_read_timing, cdr_read_hack_db), HACK_ENTRY(gpu_slow_list_walking, gpu_slow_llist_db), - HACK_ENTRY(gpu_busy_hack, gpu_busy_hack_db), + HACK_ENTRY(gpu_busy, gpu_busy_hack_db), + HACK_ENTRY(gpu_centering, gpu_centering_hack_db), }; static const struct diff --git a/libpcsxcore/psxcommon.h b/libpcsxcore/psxcommon.h index f978a583..09fb39a4 100644 --- a/libpcsxcore/psxcommon.h +++ b/libpcsxcore/psxcommon.h @@ -150,7 +150,8 @@ typedef struct { struct { boolean cdr_read_timing; boolean gpu_slow_list_walking; - boolean gpu_busy_hack; + boolean gpu_busy; + boolean gpu_centering; } hacks; } PcsxConfig; diff --git a/libpcsxcore/psxhw.c b/libpcsxcore/psxhw.c index 832e6d7d..b8ca1996 100644 --- a/libpcsxcore/psxhw.c +++ b/libpcsxcore/psxhw.c @@ -42,7 +42,7 @@ void psxHwReset() { cdrReset(); psxRcntInit(); HW_GPU_STATUS = SWAP32(0x10802000); - psxHwReadGpuSRptr = Config.hacks.gpu_busy_hack + psxHwReadGpuSRptr = Config.hacks.gpu_busy ? psxHwReadGpuSRbusyHack : psxHwReadGpuSR; } diff --git a/plugins/gpulib/gpu.c b/plugins/gpulib/gpu.c index 22571fa2..65958062 100644 --- a/plugins/gpulib/gpu.c +++ b/plugins/gpulib/gpu.c @@ -78,7 +78,10 @@ static noinline void update_width(void) int hres = hres_all[(gpu.status >> 16) & 7]; int pal = gpu.status & PSX_GPU_STATUS_PAL; int sw = gpu.screen.x2 - gpu.screen.x1; + int type = gpu.state.screen_centering_type; int x = 0, x_auto; + if (type == C_AUTO) + type = gpu.state.screen_centering_type_default; if (sw <= 0) /* nothing displayed? */; else { @@ -87,7 +90,7 @@ static noinline void update_width(void) x = (x + 1) & ~1; // blitter limitation sw /= hdiv; sw = (sw + 2) & ~3; // according to nocash - switch (gpu.state.screen_centering_type) { + switch (type) { case C_INGAME: break; case C_MANUAL: @@ -968,6 +971,7 @@ void GPUrearmedCallbacks(const struct rearmed_cbs *cbs) gpu.state.frame_count = cbs->gpu_frame_count; gpu.state.allow_interlace = cbs->gpu_neon.allow_interlace; gpu.state.enhancement_enable = cbs->gpu_neon.enhancement_enable; + gpu.state.screen_centering_type_default = cbs->screen_centering_type_default; if (gpu.state.screen_centering_type != cbs->screen_centering_type || gpu.state.screen_centering_x != cbs->screen_centering_x || gpu.state.screen_centering_y != cbs->screen_centering_y) { diff --git a/plugins/gpulib/gpu.h b/plugins/gpulib/gpu.h index 82fbe945..553afbdb 100644 --- a/plugins/gpulib/gpu.h +++ b/plugins/gpulib/gpu.h @@ -91,7 +91,8 @@ struct psx_gpu { } last_list; uint32_t last_vram_read_frame; uint32_t w_out_old, h_out_old, status_vo_old; - int screen_centering_type; // 0 - auto, 1 - game conrolled, 2 - manual + short screen_centering_type; + short screen_centering_type_default; int screen_centering_x; int screen_centering_y; } state;