mirror of
https://github.com/libretro/pcsx2.git
synced 2024-12-21 01:08:14 +00:00
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:
parent
9adf6858c1
commit
915d0c6953
@ -617,8 +617,22 @@ typedef s32 (CALLBACK* _CDVDinit)();
|
||||
typedef s32 (CALLBACK* _CDVDopen)(const char* pTitleFilename);
|
||||
typedef void (CALLBACK* _CDVDclose)();
|
||||
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);
|
||||
|
||||
// *OBSOLETE* returns a pointer to the buffer, or NULL if data hasn't finished
|
||||
// loading yet.
|
||||
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* _CDVDgetTN)(cdvdTN *Buffer);
|
||||
typedef s32 (CALLBACK* _CDVDgetTD)(u8 Track, cdvdTD *Buffer);
|
||||
@ -628,7 +642,6 @@ typedef s32 (CALLBACK* _CDVDgetTrayStatus)();
|
||||
typedef s32 (CALLBACK* _CDVDctrlTrayOpen)();
|
||||
typedef s32 (CALLBACK* _CDVDctrlTrayClose)();
|
||||
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 void (CALLBACK* _CDVDconfigure)();
|
||||
|
@ -714,11 +714,9 @@ __forceinline void cdvdReadInterrupt()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cdvd.RErr == 0)
|
||||
{
|
||||
cdr.RErr = DoCDVDgetBuffer(cdr.Transfer);
|
||||
}
|
||||
else if (cdr.RErr == -1)
|
||||
// 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.
|
||||
if (cdvd.RErr == -1)
|
||||
{
|
||||
cdvd.RetryCntP++;
|
||||
Console::Error("CDVD READ ERROR, sector=%d", params cdvd.Sector);
|
||||
@ -730,10 +728,13 @@ __forceinline void cdvdReadInterrupt()
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(cdr.RErr == -2)
|
||||
|
||||
cdvd.RErr = DoCDVDgetBuffer(cdr.Transfer);
|
||||
|
||||
if(cdvd.RErr == -2)
|
||||
{
|
||||
// not finished yet ... give it a bit more time
|
||||
CDVDREAD_INT(cdvd.ReadTime);
|
||||
CDVDREAD_INT(cdvd.ReadTime/4);
|
||||
return;
|
||||
}
|
||||
cdvd.Reading = false;
|
||||
@ -764,7 +765,7 @@ __forceinline void cdvdReadInterrupt()
|
||||
|
||||
cdvd.RetryCntP = 0;
|
||||
cdvd.Reading = 1;
|
||||
cdr.RErr = DoCDVDreadTrack(cdvd.Sector, cdvd.ReadMode);
|
||||
cdvd.RErr = DoCDVDreadTrack(cdvd.Sector, cdvd.ReadMode);
|
||||
CDVDREAD_INT(cdvd.ReadTime);
|
||||
|
||||
return;
|
||||
|
@ -497,19 +497,22 @@ void cdrReadInterrupt() {
|
||||
cdr.StatP|= 0x22;
|
||||
cdr.Result[0] = cdr.StatP;
|
||||
|
||||
Console::Status("Reading From CDR");
|
||||
cdr.RErr = DoCDVDgetBuffer(cdr.Transfer);
|
||||
// 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.
|
||||
if (cdr.RErr == -1)
|
||||
{
|
||||
CDR_LOG(" err\n");
|
||||
memzero_ptr<2340>(cdr.Transfer);
|
||||
memzero_obj(cdr.Transfer);
|
||||
cdr.Stat = DiskError;
|
||||
cdr.Result[0]|= 0x01;
|
||||
ReadTrack();
|
||||
CDREAD_INT((cdr.Mode & 0x80) ? (cdReadTime / 2) : cdReadTime);
|
||||
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
|
||||
CDREAD_INT(cdReadTime / 4);
|
||||
|
@ -362,8 +362,13 @@ int isoReadBlock(isoFile *iso, u8 *dst, int lsn)
|
||||
|
||||
if (iso->type == ISOTYPE_CD)
|
||||
{
|
||||
LSNtoMSF(dst + 12, lsn);
|
||||
dst[15] = 2;
|
||||
// This is weird voodoo mess that does some kind of time adjustment on the
|
||||
// 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;
|
||||
|
@ -33,10 +33,10 @@ enum isoType
|
||||
|
||||
enum isoFlags
|
||||
{
|
||||
ISOFLAGS_Z = 0x0001,
|
||||
ISOFLAGS_Z = 0x0001,
|
||||
ISOFLAGS_Z2 = 0x0002,
|
||||
ISOFLAGS_BLOCKDUMP = 0x0004,
|
||||
ISOFLAGS_MULTI = 0x0008,
|
||||
ISOFLAGS_MULTI = 0x0008,
|
||||
ISOFLAGS_BZ2 = 0x0010
|
||||
};
|
||||
|
||||
@ -46,17 +46,17 @@ enum isoFlags
|
||||
//#define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */
|
||||
//#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */
|
||||
|
||||
typedef struct
|
||||
struct _multih
|
||||
{
|
||||
u32 slsn;
|
||||
u32 elsn;
|
||||
void *handle;
|
||||
} _multih;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
struct isoFile
|
||||
{
|
||||
char filename[256];
|
||||
u32 type;
|
||||
isoType type;
|
||||
u32 flags;
|
||||
u32 offset;
|
||||
u32 blockofs;
|
||||
@ -70,7 +70,7 @@ typedef struct
|
||||
_multih multih[8];
|
||||
int buflsn;
|
||||
u8 *buffer;
|
||||
} isoFile;
|
||||
};
|
||||
|
||||
|
||||
isoFile *isoOpen(const char *filename);
|
||||
|
@ -488,18 +488,12 @@ static void CALLBACK CDVD_newDiskCB(void (*callback)()) {}
|
||||
extern int lastReadSize;
|
||||
static s32 CALLBACK CDVD_getBuffer2(u8* buffer)
|
||||
{
|
||||
int ret;
|
||||
|
||||
// TEMP: until I fix all the plugins to use this function style
|
||||
u8* pb = CDVD->getBuffer();
|
||||
if(pb != NULL)
|
||||
{
|
||||
memcpy(buffer,pb,lastReadSize);
|
||||
ret = 0;
|
||||
}
|
||||
else ret = -2;
|
||||
if(pb == NULL) return -2;
|
||||
|
||||
return ret;
|
||||
memcpy_fast( buffer, pb, lastReadSize );
|
||||
return 0;
|
||||
}
|
||||
|
||||
static s32 CALLBACK CDVD_readSector(u8* buffer, u32 lsn, int mode)
|
||||
|
Loading…
Reference in New Issue
Block a user