More CDVD and cdvdiso bugfixes: cd-rom images should work now (ie, the old school non-DVD sort!), and improved the error and async read handling (possibly affects people running games from dvdrom)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1697 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-08-28 14:57:51 +00:00
parent 9adf6858c1
commit 915d0c6953
6 changed files with 47 additions and 31 deletions

View File

@ -617,8 +617,22 @@ typedef s32 (CALLBACK* _CDVDinit)();
typedef s32 (CALLBACK* _CDVDopen)(const char* pTitleFilename); typedef s32 (CALLBACK* _CDVDopen)(const char* pTitleFilename);
typedef void (CALLBACK* _CDVDclose)(); typedef void (CALLBACK* _CDVDclose)();
typedef void (CALLBACK* _CDVDshutdown)(); typedef void (CALLBACK* _CDVDshutdown)();
// Initiates an asynchronous track read operation.
// Returns -1 on error (invalid track)
// Returns 0 on success.
typedef s32 (CALLBACK* _CDVDreadTrack)(u32 lsn, int mode); typedef s32 (CALLBACK* _CDVDreadTrack)(u32 lsn, int mode);
// *OBSOLETE* returns a pointer to the buffer, or NULL if data hasn't finished
// loading yet.
typedef u8* (CALLBACK* _CDVDgetBuffer)(); typedef u8* (CALLBACK* _CDVDgetBuffer)();
// Copies loaded data to the target buffer.
// Returns -2 if the asynchronous read is still pending.
// Returns 0 on success.
// This function is not allowed to return -1 (reserved for use by readTrack)
typedef s32 (CALLBACK* _CDVDgetBuffer2)(u8* buffer);
typedef s32 (CALLBACK* _CDVDreadSubQ)(u32 lsn, cdvdSubQ* subq); typedef s32 (CALLBACK* _CDVDreadSubQ)(u32 lsn, cdvdSubQ* subq);
typedef s32 (CALLBACK* _CDVDgetTN)(cdvdTN *Buffer); typedef s32 (CALLBACK* _CDVDgetTN)(cdvdTN *Buffer);
typedef s32 (CALLBACK* _CDVDgetTD)(u8 Track, cdvdTD *Buffer); typedef s32 (CALLBACK* _CDVDgetTD)(u8 Track, cdvdTD *Buffer);
@ -628,7 +642,6 @@ typedef s32 (CALLBACK* _CDVDgetTrayStatus)();
typedef s32 (CALLBACK* _CDVDctrlTrayOpen)(); typedef s32 (CALLBACK* _CDVDctrlTrayOpen)();
typedef s32 (CALLBACK* _CDVDctrlTrayClose)(); typedef s32 (CALLBACK* _CDVDctrlTrayClose)();
typedef s32 (CALLBACK* _CDVDreadSector)(u8* buffer, u32 lsn, int mode); typedef s32 (CALLBACK* _CDVDreadSector)(u8* buffer, u32 lsn, int mode);
typedef s32 (CALLBACK* _CDVDgetBuffer2)(u8* buffer);
typedef s32 (CALLBACK* _CDVDgetDualInfo)(s32* dualType, u32* _layer1start); typedef s32 (CALLBACK* _CDVDgetDualInfo)(s32* dualType, u32* _layer1start);
typedef void (CALLBACK* _CDVDconfigure)(); typedef void (CALLBACK* _CDVDconfigure)();

View File

@ -714,11 +714,9 @@ __forceinline void cdvdReadInterrupt()
} }
else else
{ {
if (cdvd.RErr == 0) // Read Error -1 is only returned by readTrack, so handle it first here.
{ // If readTrack failed it means we don't have any valid data to fetch.
cdr.RErr = DoCDVDgetBuffer(cdr.Transfer); if (cdvd.RErr == -1)
}
else if (cdr.RErr == -1)
{ {
cdvd.RetryCntP++; cdvd.RetryCntP++;
Console::Error("CDVD READ ERROR, sector=%d", params cdvd.Sector); Console::Error("CDVD READ ERROR, sector=%d", params cdvd.Sector);
@ -730,10 +728,13 @@ __forceinline void cdvdReadInterrupt()
return; return;
} }
} }
else if(cdr.RErr == -2)
cdvd.RErr = DoCDVDgetBuffer(cdr.Transfer);
if(cdvd.RErr == -2)
{ {
// not finished yet ... give it a bit more time // not finished yet ... give it a bit more time
CDVDREAD_INT(cdvd.ReadTime); CDVDREAD_INT(cdvd.ReadTime/4);
return; return;
} }
cdvd.Reading = false; cdvd.Reading = false;
@ -764,7 +765,7 @@ __forceinline void cdvdReadInterrupt()
cdvd.RetryCntP = 0; cdvd.RetryCntP = 0;
cdvd.Reading = 1; cdvd.Reading = 1;
cdr.RErr = DoCDVDreadTrack(cdvd.Sector, cdvd.ReadMode); cdvd.RErr = DoCDVDreadTrack(cdvd.Sector, cdvd.ReadMode);
CDVDREAD_INT(cdvd.ReadTime); CDVDREAD_INT(cdvd.ReadTime);
return; return;

View File

@ -497,19 +497,22 @@ void cdrReadInterrupt() {
cdr.StatP|= 0x22; cdr.StatP|= 0x22;
cdr.Result[0] = cdr.StatP; cdr.Result[0] = cdr.StatP;
Console::Status("Reading From CDR"); // Read Error -1 is only returned by readTrack, so handle it first here.
cdr.RErr = DoCDVDgetBuffer(cdr.Transfer); // If readTrack failed it means we don't have any valid data to fetch.
if (cdr.RErr == -1) if (cdr.RErr == -1)
{ {
CDR_LOG(" err\n"); CDR_LOG(" err\n");
memzero_ptr<2340>(cdr.Transfer); memzero_obj(cdr.Transfer);
cdr.Stat = DiskError; cdr.Stat = DiskError;
cdr.Result[0]|= 0x01; cdr.Result[0]|= 0x01;
ReadTrack(); ReadTrack();
CDREAD_INT((cdr.Mode & 0x80) ? (cdReadTime / 2) : cdReadTime); CDREAD_INT((cdr.Mode & 0x80) ? (cdReadTime / 2) : cdReadTime);
return; return;
} }
else if(cdr.RErr == -2)
cdr.RErr = DoCDVDgetBuffer(cdr.Transfer);
if(cdr.RErr == -2)
{ {
// async mode is not finished yet ... give it a bit more time // async mode is not finished yet ... give it a bit more time
CDREAD_INT(cdReadTime / 4); CDREAD_INT(cdReadTime / 4);

View File

@ -362,8 +362,13 @@ int isoReadBlock(isoFile *iso, u8 *dst, int lsn)
if (iso->type == ISOTYPE_CD) if (iso->type == ISOTYPE_CD)
{ {
LSNtoMSF(dst + 12, lsn); // This is weird voodoo mess that does some kind of time adjustment on the
dst[15] = 2; // block headers of CD-Rom images. hackfixed it to work with 24 byte block
// offsets... no idea if it'll work with others.
DevAssert( iso->blockofs == 24, "Undocumented CD-Rom checkpoint." );
LSNtoMSF(dst - iso->blockofs + 12, lsn);
dst[15-iso->blockofs] = 2;
} }
return 0; return 0;

View File

@ -33,10 +33,10 @@ enum isoType
enum isoFlags enum isoFlags
{ {
ISOFLAGS_Z = 0x0001, ISOFLAGS_Z = 0x0001,
ISOFLAGS_Z2 = 0x0002, ISOFLAGS_Z2 = 0x0002,
ISOFLAGS_BLOCKDUMP = 0x0004, ISOFLAGS_BLOCKDUMP = 0x0004,
ISOFLAGS_MULTI = 0x0008, ISOFLAGS_MULTI = 0x0008,
ISOFLAGS_BZ2 = 0x0010 ISOFLAGS_BZ2 = 0x0010
}; };
@ -46,17 +46,17 @@ enum isoFlags
//#define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */ //#define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */
//#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */ //#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */
typedef struct struct _multih
{ {
u32 slsn; u32 slsn;
u32 elsn; u32 elsn;
void *handle; void *handle;
} _multih; };
typedef struct struct isoFile
{ {
char filename[256]; char filename[256];
u32 type; isoType type;
u32 flags; u32 flags;
u32 offset; u32 offset;
u32 blockofs; u32 blockofs;
@ -70,7 +70,7 @@ typedef struct
_multih multih[8]; _multih multih[8];
int buflsn; int buflsn;
u8 *buffer; u8 *buffer;
} isoFile; };
isoFile *isoOpen(const char *filename); isoFile *isoOpen(const char *filename);

View File

@ -488,18 +488,12 @@ static void CALLBACK CDVD_newDiskCB(void (*callback)()) {}
extern int lastReadSize; extern int lastReadSize;
static s32 CALLBACK CDVD_getBuffer2(u8* buffer) static s32 CALLBACK CDVD_getBuffer2(u8* buffer)
{ {
int ret;
// TEMP: until I fix all the plugins to use this function style // TEMP: until I fix all the plugins to use this function style
u8* pb = CDVD->getBuffer(); u8* pb = CDVD->getBuffer();
if(pb != NULL) if(pb == NULL) return -2;
{
memcpy(buffer,pb,lastReadSize);
ret = 0;
}
else ret = -2;
return ret; memcpy_fast( buffer, pb, lastReadSize );
return 0;
} }
static s32 CALLBACK CDVD_readSector(u8* buffer, u32 lsn, int mode) static s32 CALLBACK CDVD_readSector(u8* buffer, u32 lsn, int mode)