From 4a90499ec93f0b3b5ff89021d7cf72201e36cad7 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Sat, 31 Oct 2020 17:21:09 +0000 Subject: [PATCH] CDVD: Adjust read speed depending on if in inner/outer edge Fixes Shadowman 2 Second Coming textures Fixes Arctic Thunder loading problems --- pcsx2/CDVD/CDVD.cpp | 30 +++++++++++++++++++++++++++++- pcsx2/CDVD/CDVD_internal.h | 9 ++------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/pcsx2/CDVD/CDVD.cpp b/pcsx2/CDVD/CDVD.cpp index 3f38342762..0d98f0f438 100644 --- a/pcsx2/CDVD/CDVD.cpp +++ b/pcsx2/CDVD/CDVD.cpp @@ -600,7 +600,35 @@ static s32 cdvdReadDvdDualInfo(s32* dualType, u32* layer1Start) static uint cdvdBlockReadTime(CDVD_MODE_TYPE mode) { - return (PSXCLK * cdvd.BlockSize) / (((mode == MODE_CDROM) ? PSX_CD_READSPEED : PSX_DVD_READSPEED) * cdvd.Speed); + int numSectors = 0; + int offset = 0; + // Sector counts are taken from google for Single layer, Dual layer DVD's and for 700MB CD's + switch (cdvd.Type) + { + case CDVD_TYPE_DETCTDVDS: + case CDVD_TYPE_PS2DVD: + numSectors = 2298496; + break; + case CDVD_TYPE_DETCTDVDD: + numSectors = 4173824 / 2; // Total sectors for both layers, assume half per layer + u32 layer1Start; + s32 dualType; + + // Layer 1 needs an offset as it goes back to the middle of the disc + cdvdReadDvdDualInfo(&dualType, &layer1Start); + if (cdvd.Sector >= layer1Start) + offset = layer1Start; + break; + default: // Pretty much every CD format + numSectors = 360000; + break; + } + // Read speed is roughly 37% at lowest and full speed on outer edge. I imagine it's more logarithmic than this + // Required for Shadowman to work + // Use SeekToSector as Sector hasn't been updated yet + const float sectorSpeed = (((float)(cdvd.SeekToSector-offset) / numSectors) * 0.63f) + 0.37f; + //DevCon.Warning("Read speed %f sector %d\n", sectorSpeed, cdvd.Sector); + return ((PSXCLK * cdvd.BlockSize) / ((float)(((mode == MODE_CDROM) ? PSX_CD_READSPEED : PSX_DVD_READSPEED) * cdvd.Speed) * sectorSpeed)); } void cdvdReset() diff --git a/pcsx2/CDVD/CDVD_internal.h b/pcsx2/CDVD/CDVD_internal.h index 6d3731263e..a748d2f61d 100644 --- a/pcsx2/CDVD/CDVD_internal.h +++ b/pcsx2/CDVD/CDVD_internal.h @@ -123,13 +123,8 @@ static const uint tbl_ContigiousSeekDelta[3] = // concerned with accurate(ish) seek delays and less concerned with actual block read speeds. // Translation: it's a minor speedhack :D -//Fixme ( voodoocycles ): -//The current CD mode gives a too low transfer rate. HDloader reports 900kb/s, while the theoretical max is 3600kb/s -//Silent Hill 2 videos starve of data and stall. -//So let's double that until the cause of the slow data rate is known. - -static const uint PSX_CD_READSPEED = 153600 * 2; // 1 Byte Time @ x1 (150KB = cd x 1) -static const uint PSX_DVD_READSPEED = 1382400 + 256000; // normal is 1 Byte Time @ x1 (1350KB = dvd x 1). +static const uint PSX_CD_READSPEED = 153600; // 1 Byte Time @ x1 (150KB = cd x 1) +static const uint PSX_DVD_READSPEED = 1382400; // 1 Byte Time @ x1 (1350KB = dvd x 1). // Legacy Note: FullSeek timing causes many games to load very slow, but it likely not the real problem. // Games breaking with it set to PSXCLK*40 : "wrath unleashed" and "Shijou Saikyou no Deshi Kenichi".