From db57cbb83e573e115ca60f3855b28c264cf2159a Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 14 Jul 2023 01:20:43 +0300 Subject: [PATCH] handle more GP0 status bits should help openbios --- libpcsxcore/gpu.h | 13 +++++++------ libpcsxcore/misc.c | 2 ++ libpcsxcore/psxcounters.c | 12 +++++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/libpcsxcore/gpu.h b/libpcsxcore/gpu.h index c924b67b..21384e58 100644 --- a/libpcsxcore/gpu.h +++ b/libpcsxcore/gpu.h @@ -24,18 +24,19 @@ #ifndef __GPU_H__ #define __GPU_H__ -#define PSXGPU_LCF (1<<31) -#define PSXGPU_nBUSY (1<<26) -#define PSXGPU_ILACE (1<<22) -#define PSXGPU_DHEIGHT (1<<19) +#define PSXGPU_LCF (1u<<31) +#define PSXGPU_nBUSY (1u<<26) +#define PSXGPU_ILACE (1u<<22) +#define PSXGPU_DHEIGHT (1u<<19) +#define PSXGPU_FIELD (1u<<13) // both must be set for interlace to work -#define PSXGPU_ILACE_BITS (PSXGPU_ILACE | PSXGPU_DHEIGHT) +#define PSXGPU_ILACE_BITS (PSXGPU_ILACE | PSXGPU_DHEIGHT | PSXGPU_FIELD) #define HW_GPU_STATUS psxHu32ref(0x1814) // TODO: handle com too -#define PSXGPU_TIMING_BITS (PSXGPU_LCF | PSXGPU_nBUSY) +#define PSXGPU_TIMING_BITS (PSXGPU_LCF | PSXGPU_nBUSY | PSXGPU_FIELD) #define gpuSyncPluginSR() { \ HW_GPU_STATUS &= SWAP32(PSXGPU_TIMING_BITS); \ diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c index 022ad6d9..678f2dbf 100644 --- a/libpcsxcore/misc.c +++ b/libpcsxcore/misc.c @@ -164,6 +164,8 @@ void BiosLikeGPUSetup() for (i = 0; i < sizeof(gpu_data_def) / sizeof(gpu_data_def[0]); i++) GPU_writeData(gpu_data_def[i]); + + HW_GPU_STATUS |= SWAP32(PSXGPU_nBUSY); } static void SetBootRegs(u32 pc, u32 gp, u32 sp) diff --git a/libpcsxcore/psxcounters.c b/libpcsxcore/psxcounters.c index e19b7819..18bd6a4e 100644 --- a/libpcsxcore/psxcounters.c +++ b/libpcsxcore/psxcounters.c @@ -361,14 +361,20 @@ void psxRcntUpdate() // Update lace. if( hSyncCount >= HSyncTotal[Config.PsxType] ) { + u32 status, field = 0; rcnts[3].cycleStart += Config.PsxType ? PSXCLK / 50 : PSXCLK / 60; hSyncCount = 0; frame_counter++; gpuSyncPluginSR(); - if ((HW_GPU_STATUS & SWAP32(PSXGPU_ILACE_BITS)) == SWAP32(PSXGPU_ILACE_BITS)) - HW_GPU_STATUS |= SWAP32(frame_counter << 31); - GPU_vBlank(0, SWAP32(HW_GPU_STATUS) >> 31); + status = SWAP32(HW_GPU_STATUS) | PSXGPU_FIELD; + if ((status & PSXGPU_ILACE_BITS) == PSXGPU_ILACE_BITS) { + field = frame_counter & 1; + status |= field << 31; + status ^= field << 13; + } + HW_GPU_STATUS = SWAP32(status); + GPU_vBlank(0, field); } scheduleRcntBase(); -- 2.39.2