From ab88daca6f1367543d88b35e04a7999f3e36a0ff Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 16 Sep 2023 02:41:06 +0300 Subject: [PATCH] attempt to improve guncon defaults The previous change wrongly introduced resolution into the calculation which is unneeded because input is not pixel coordinates. --- frontend/libretro.c | 6 ------ frontend/plugin.c | 2 ++ frontend/plugin_lib.c | 6 ------ libpcsxcore/plugins.c | 16 +++++++++++----- libpcsxcore/plugins.h | 2 ++ plugins/gpulib/gpu.c | 8 ++++++++ plugins/gpulib/gpu.h | 1 + 7 files changed, 24 insertions(+), 17 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 965f9308..a26d4662 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -504,12 +504,6 @@ void pl_timing_prepare(int is_pal) is_pal_mode = is_pal; } -void plat_get_psx_resolution(int *xres, int *yres) -{ - *xres = psx_w; - *yres = psx_h; -} - void plat_trigger_vibrate(int pad, int low, int high) { if (!rumble_cb) diff --git a/frontend/plugin.c b/frontend/plugin.c index 3a0710a5..3374141e 100644 --- a/frontend/plugin.c +++ b/frontend/plugin.c @@ -139,6 +139,7 @@ extern long GPUdmaChain(uint32_t *,uint32_t); extern void GPUupdateLace(void); extern long GPUfreeze(uint32_t, void *); extern void GPUvBlank(int, int); +extern void GPUgetScreenInfo(int *y, int *base_hres); extern void GPUrearmedCallbacks(const struct rearmed_cbs *cbs); @@ -222,6 +223,7 @@ static const struct { DIRECT_GPU(GPUdmaChain), DIRECT_GPU(GPUfreeze), DIRECT_GPU(GPUvBlank), + DIRECT_GPU(GPUgetScreenInfo), DIRECT_GPU(GPUrearmedCallbacks), DIRECT_GPU(GPUdisplayText), diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c index 0f023123..8a6b6adb 100644 --- a/frontend/plugin_lib.c +++ b/frontend/plugin_lib.c @@ -633,12 +633,6 @@ void pl_gun_byte2(int port, unsigned char byte) { } -void plat_get_psx_resolution(int *xres, int *yres) -{ - *xres = psx_w; - *yres = psx_h; -} - #define MAX_LAG_FRAMES 3 #define tvdiff(tv, tv_old) \ diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index 93af3d02..2dacfd5a 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -49,6 +49,7 @@ GPUfreeze GPU_freeze; GPUgetScreenPic GPU_getScreenPic; GPUshowScreenPic GPU_showScreenPic; GPUvBlank GPU_vBlank; +GPUgetScreenInfo GPU_getScreenInfo; CDRinit CDR_init; CDRshutdown CDR_shutdown; @@ -194,6 +195,7 @@ void CALLBACK GPU__keypressed(int key) {} long CALLBACK GPU__getScreenPic(unsigned char *pMem) { return -1; } long CALLBACK GPU__showScreenPic(unsigned char *pMem) { return -1; } void CALLBACK GPU__vBlank(int val) {} +void CALLBACK GPU__getScreenInfo(int *y, int *base_hres) {} #define LoadGpuSym1(dest, name) \ LoadSym(GPU_##dest, GPU##dest, name, TRUE); @@ -233,6 +235,7 @@ static int LoadGPUplugin(const char *GPUdll) { LoadGpuSym0(getScreenPic, "GPUgetScreenPic"); LoadGpuSym0(showScreenPic, "GPUshowScreenPic"); LoadGpuSym0(vBlank, "GPUvBlank"); + LoadGpuSym0(getScreenInfo, "GPUgetScreenInfo"); LoadGpuSym0(configure, "GPUconfigure"); LoadGpuSym0(test, "GPUtest"); LoadGpuSym0(about, "GPUabout"); @@ -613,9 +616,8 @@ static void PADstartPoll_(PadDataS *pad) { stdpar[2] = pad->buttonStatus & 0xff; stdpar[3] = pad->buttonStatus >> 8; - int absX = pad->absoluteX; + int absX = pad->absoluteX; // 0-1023 int absY = pad->absoluteY; - int xres = 256, yres = 240; if (absX == 65536 || absY == 65536) { stdpar[4] = 0x01; @@ -624,9 +626,13 @@ static void PADstartPoll_(PadDataS *pad) { stdpar[7] = 0x00; } else { - plat_get_psx_resolution(&xres, &yres); - int x = 0x5a - (xres - 256) / 3 + (((xres - 256) / 3 + 356) * absX >> 10); - int y = 0x20 + (yres * absY >> 10); + int y_ofs = 0, yres = 240; + GPU_getScreenInfo(&y_ofs, &yres); + int y_top = (Config.PsxType ? 0x30 : 0x19) + y_ofs; + int w = Config.PsxType ? 385 : 378; + int x = 0x40 + (w * absX >> 10); + int y = y_top + (yres * absY >> 10); + //printf("%3d %3d %4x %4x\n", absX, absY, x, y); stdpar[4] = x; stdpar[5] = x >> 8; diff --git a/libpcsxcore/plugins.h b/libpcsxcore/plugins.h index b7af7c3a..c563470b 100644 --- a/libpcsxcore/plugins.h +++ b/libpcsxcore/plugins.h @@ -76,6 +76,7 @@ typedef long (CALLBACK* GPUfreeze)(uint32_t, GPUFreeze_t *); typedef long (CALLBACK* GPUgetScreenPic)(unsigned char *); typedef long (CALLBACK* GPUshowScreenPic)(unsigned char *); typedef void (CALLBACK* GPUvBlank)(int, int); +typedef void (CALLBACK* GPUgetScreenInfo)(int *, int *); // GPU function pointers extern GPUupdateLace GPU_updateLace; @@ -100,6 +101,7 @@ extern GPUfreeze GPU_freeze; extern GPUgetScreenPic GPU_getScreenPic; extern GPUshowScreenPic GPU_showScreenPic; extern GPUvBlank GPU_vBlank; +extern GPUgetScreenInfo GPU_getScreenInfo; // CD-ROM Functions typedef long (CALLBACK* CDRinit)(void); diff --git a/plugins/gpulib/gpu.c b/plugins/gpulib/gpu.c index dfaff58e..c8441441 100644 --- a/plugins/gpulib/gpu.c +++ b/plugins/gpulib/gpu.c @@ -879,6 +879,14 @@ void GPUvBlank(int is_vblank, int lcf) } } +void GPUgetScreenInfo(int *y, int *base_hres) +{ + *y = gpu.screen.y; + *base_hres = gpu.screen.vres; + if (gpu.status & PSX_GPU_STATUS_DHEIGHT) + *base_hres >>= 1; +} + #include "../../frontend/plugin_lib.h" void GPUrearmedCallbacks(const struct rearmed_cbs *cbs) diff --git a/plugins/gpulib/gpu.h b/plugins/gpulib/gpu.h index 1582ee15..dbca8081 100644 --- a/plugins/gpulib/gpu.h +++ b/plugins/gpulib/gpu.h @@ -150,6 +150,7 @@ void GPUupdateLace(void); long GPUopen(unsigned long *disp, char *cap, char *cfg); long GPUclose(void); void GPUvBlank(int is_vblank, int lcf); +void GPUgetScreenInfo(int *y, int *base_hres); void GPUrearmedCallbacks(const struct rearmed_cbs *cbs_); #ifdef __cplusplus -- 2.39.2