optimized the cd-read algorithm by removing extra un-needed variables. it still does the same thing though :p

git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@126 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
cottonvibes 2008-09-16 20:17:04 +00:00 committed by Gregory Hainaut
parent c3b21e8af0
commit f5f27e83dc
3 changed files with 27 additions and 35 deletions

View File

@ -672,53 +672,41 @@ void cdvdReset()
}
void cdvdReadTimeRcnt(int mode){ // Mode 0 is DVD, Mode 1 is CD
if (SLOWDVD){
int readspeed = 0; // 1 Sector size
int amount = 0; // Total bytes transfered at 1x speed
#define PSX_CD_READSPEED (PSXCLK / 153600) // 1 Byte Time @ x1 (150KB = cd x 1)
#define PSX_DVD_READSPEED (PSXCLK / 1382400) // 1 Byte Time @ x1 (1350KB = dvd x 1)
void cdvdReadTimeRcnt(int mode) // Mode 0 is DVD, Mode 1 is CD
{
if (CHECK_SLOWDVD)
{
int readspeed; // 1 Sector size
static int last_sector = 0;
int start_sector = cdvd.Sector;
int sector_difference = abs(start_sector - last_sector);
amount = cdvd.BlockSize; // in Bytes
if(mode == 0)
readspeed = ((PSXCLK /1382400)/* 1 Byte Time @ x1 */ * amount) / cdvd.Speed; //1350KB = dvd x 1
else
readspeed = ((PSXCLK /153600)/* 1 Byte Time @ x1 */ * amount) / cdvd.Speed; //150KB = cd x 1
int sector_difference = abs(cdvd.Sector - last_sector);
readspeed = ( (mode ? PSX_CD_READSPEED : PSX_DVD_READSPEED) * cdvd.BlockSize ) / cdvd.Speed;
//add cycles due to access times, based on try and error
//fixes most of Tales of the Abyss crashes and some Digital Devil Saga videos
//slightly longer loading times now
if (sector_difference > 128 && sector_difference < 1000000){
readspeed += (sector_difference+sector_difference) / 32;
if (sector_difference > 128 && sector_difference < 1000000) {
readspeed += (sector_difference * 2) / 32;
}
else if (sector_difference >= 1000000){
readspeed += (sector_difference+sector_difference) / 4;
else if (sector_difference >= 1000000) {
readspeed += (sector_difference * 2) / 4;
}
//simulates spin-up time, fixes hdloader
if (cdvd.Sector == 16 /* DVD TOC */) readspeed = 30000;
cdvdReadTime = readspeed;
//SysPrintf("secdiff = %d cdvdReadTime = %d\n", sector_difference, cdvdReadTime);
last_sector = start_sector;
last_sector = cdvd.Sector;
}
else {
int readspeed = 0; // 1 Sector size
int amount = 0; // Total bytes transfered at 1x speed
amount = cdvd.BlockSize; // in Bytes
if(mode == 0)
readspeed = ((PSXCLK /1382400)/* 1 Byte Time @ x1 */ * amount) / cdvd.Speed; //1350KB = dvd x 1
else
{
if (cdvd.Sector == 16) //DVD TOC
cdvdReadTime = 30000; //simulates spin-up time, fixes hdloader
else
readspeed = ((PSXCLK /153600)/* 1 Byte Time @ x1 */ * amount) / cdvd.Speed; //150KB = cd x 1
//simulates spin-up time, fixes hdloader
if (cdvd.Sector == 16 /* DVD TOC */) readspeed = 30000;
cdvdReadTime = readspeed;
//SysPrintf("secdiff = %d cdvdReadTime = %d\n", sector_difference, cdvdReadTime);
cdvdReadTime = ( (mode ? PSX_CD_READSPEED : PSX_DVD_READSPEED) * cdvd.BlockSize ) / cdvd.Speed;
}
}
@ -746,6 +734,10 @@ void cdvdReadTimeRcnt(int mode){ // Mode 0 is DVD, Mode 1 is CD
// so at the outer edge, the speed is roughly 3x the speed at the inner edge.
//
// question: the 1x speed refers to the inner or the outer edge? I assume inner.
//
// (cottonvibes: i think this assumption is wrong, a cd's 1x speed is their theoretical fastest read-speed
// so you should assume the fastest value as the base speed. therfore you should start
// with the outer-edge, and base your calculations on that.)
//
// then:
// if the inner timing is 53333cycles/sector

View File

@ -65,7 +65,7 @@ typedef struct {
int Readed;
int Reading;
int ReadMode;
int BlockSize;
int BlockSize; // Total bytes transfered at 1x speed
int Speed;
int RetryCnt;
int RetryCntP;

View File

@ -67,7 +67,7 @@
#define CHECK_FPU_EXTRA_FLAGS (!(Config.Hacks & 0x200)) // Sets correct flags in the FPU recs
#define CHECK_ESCAPE_HACK (Config.Hacks & 0x400)
//------------ SPECIAL GAME FIXES!!! ---------------
#define SLOWDVD (Config.GameFixes & 0x1) // Slow DVD access times, for games that are strict about them (Tales of the Abyss)
#define CHECK_SLOWDVD (Config.GameFixes & 0x1) // Slow DVD access times, for games that are strict about them (Tales of the Abyss)
#define CHECK_FPUCLAMPHACK (Config.GameFixes & 0x4) // Special Fix for Tekken 5, different clamping for FPU (sets NaN to zero; doesn't clamp infinities)
#define CHECK_VUCLIPHACK (Config.GameFixes & 0x2) // Special Fix for GoW, updates the clipflag differently in recVUMI_CLIP() (note: turning this hack on, breaks Rockstar games)
//------------ DEFAULT sseMXCSR VALUES!!! ---------------