mirror of https://github.com/PCSX2/pcsx2.git
Start improving the CDVD interface. Change the internal ISO interface to use it.
I will later work on getting the typical plugins to support these new functions. I have tried to also update the linux side, but I can't compile or test it so it might not work properly. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1511 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
eda0b1ab13
commit
3f28c12fe7
|
@ -393,6 +393,17 @@ void CALLBACK CDVDabout();
|
||||||
s32 CALLBACK CDVDtest();
|
s32 CALLBACK CDVDtest();
|
||||||
void CALLBACK CDVDnewDiskCB(void (*callback)());
|
void CALLBACK CDVDnewDiskCB(void (*callback)());
|
||||||
|
|
||||||
|
// new funcs
|
||||||
|
|
||||||
|
// read a track directly
|
||||||
|
s32 CALLBACK CDVDreadSector(u8* buffer, s32 lsn, int mode);
|
||||||
|
|
||||||
|
// improved getBuffer
|
||||||
|
s32 CALLBACK CDVDgetBuffer2(u8* buffer);
|
||||||
|
|
||||||
|
// tool function
|
||||||
|
s32 CALLBACK CDVDgetDualInfo(s32* dualType, u32* _layer1start);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* DEV9 plugin API */
|
/* DEV9 plugin API */
|
||||||
|
@ -615,12 +626,16 @@ typedef s32 (CALLBACK* _CDVDgetDiskType)();
|
||||||
typedef s32 (CALLBACK* _CDVDgetTrayStatus)();
|
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* _CDVDgetBuffer2)(u8* buffer);
|
||||||
|
typedef s32 (CALLBACK* _CDVDgetDualInfo)(s32* dualType, u32* _layer1start);
|
||||||
|
|
||||||
typedef void (CALLBACK* _CDVDconfigure)();
|
typedef void (CALLBACK* _CDVDconfigure)();
|
||||||
typedef s32 (CALLBACK* _CDVDtest)();
|
typedef s32 (CALLBACK* _CDVDtest)();
|
||||||
typedef void (CALLBACK* _CDVDabout)();
|
typedef void (CALLBACK* _CDVDabout)();
|
||||||
typedef void (CALLBACK* _CDVDnewDiskCB)(void (*callback)());
|
typedef void (CALLBACK* _CDVDnewDiskCB)(void (*callback)());
|
||||||
|
|
||||||
|
|
||||||
// DEV9
|
// DEV9
|
||||||
// NOTE: The read/write functions CANNOT use XMM/MMX regs
|
// NOTE: The read/write functions CANNOT use XMM/MMX regs
|
||||||
// If you want to use them, need to save and restore current ones
|
// If you want to use them, need to save and restore current ones
|
||||||
|
@ -802,25 +817,37 @@ extern _SPU2test SPU2test;
|
||||||
extern _SPU2about SPU2about;
|
extern _SPU2about SPU2about;
|
||||||
|
|
||||||
// CDVD
|
// CDVD
|
||||||
extern _CDVDinit CDVDinit;
|
struct CDVDplugin {
|
||||||
extern _CDVDopen CDVDopen;
|
_CDVDinit init;
|
||||||
extern _CDVDclose CDVDclose;
|
_CDVDopen open;
|
||||||
extern _CDVDshutdown CDVDshutdown;
|
_CDVDclose close;
|
||||||
extern _CDVDreadTrack CDVDreadTrack;
|
_CDVDshutdown shutdown;
|
||||||
extern _CDVDgetBuffer CDVDgetBuffer;
|
_CDVDreadTrack readTrack;
|
||||||
extern _CDVDreadSubQ CDVDreadSubQ;
|
_CDVDgetBuffer getBuffer;
|
||||||
extern _CDVDgetTN CDVDgetTN;
|
_CDVDreadSubQ readSubQ;
|
||||||
extern _CDVDgetTD CDVDgetTD;
|
_CDVDgetTN getTN;
|
||||||
extern _CDVDgetTOC CDVDgetTOC;
|
_CDVDgetTD getTD;
|
||||||
extern _CDVDgetDiskType CDVDgetDiskType;
|
_CDVDgetTOC getTOC;
|
||||||
extern _CDVDgetTrayStatus CDVDgetTrayStatus;
|
_CDVDgetDiskType getDiskType;
|
||||||
extern _CDVDctrlTrayOpen CDVDctrlTrayOpen;
|
_CDVDgetTrayStatus getTrayStatus;
|
||||||
extern _CDVDctrlTrayClose CDVDctrlTrayClose;
|
_CDVDctrlTrayOpen ctrlTrayOpen;
|
||||||
|
_CDVDctrlTrayClose ctrlTrayClose;
|
||||||
|
|
||||||
extern _CDVDconfigure CDVDconfigure;
|
_CDVDconfigure configure;
|
||||||
extern _CDVDtest CDVDtest;
|
_CDVDtest test;
|
||||||
extern _CDVDabout CDVDabout;
|
_CDVDabout about;
|
||||||
extern _CDVDnewDiskCB CDVDnewDiskCB;
|
_CDVDnewDiskCB newDiskCB;
|
||||||
|
|
||||||
|
// special functions, not in external interface yet
|
||||||
|
_CDVDreadSector readSector;
|
||||||
|
_CDVDgetBuffer2 getBuffer2;
|
||||||
|
_CDVDgetDualInfo getDualInfo;
|
||||||
|
|
||||||
|
int* initCount;
|
||||||
|
};
|
||||||
|
extern CDVDplugin CDVD_plugin; // _plugin because of
|
||||||
|
extern CDVDplugin CDVD;
|
||||||
|
extern CDVDplugin ISO;
|
||||||
|
|
||||||
// DEV9
|
// DEV9
|
||||||
extern _DEV9init DEV9init;
|
extern _DEV9init DEV9init;
|
||||||
|
|
|
@ -403,28 +403,28 @@ void cdvdReadKey(u8 arg0, u16 arg1, u32 arg2, u8* key) {
|
||||||
|
|
||||||
s32 cdvdGetToc(void* toc)
|
s32 cdvdGetToc(void* toc)
|
||||||
{
|
{
|
||||||
s32 ret = DoCDVDgetTOC(toc);
|
s32 ret = CDVD.getTOC(toc);
|
||||||
if (ret == -1) ret = 0x80;
|
if (ret == -1) ret = 0x80;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 cdvdReadSubQ(s32 lsn, cdvdSubQ* subq)
|
s32 cdvdReadSubQ(s32 lsn, cdvdSubQ* subq)
|
||||||
{
|
{
|
||||||
s32 ret = DoCDVDreadSubQ(lsn, subq);
|
s32 ret = CDVD.readSubQ(lsn, subq);
|
||||||
if (ret == -1) ret = 0x80;
|
if (ret == -1) ret = 0x80;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 cdvdCtrlTrayOpen()
|
s32 cdvdCtrlTrayOpen()
|
||||||
{
|
{
|
||||||
s32 ret = DoCDVDctrlTrayOpen();
|
s32 ret = CDVD.ctrlTrayOpen();
|
||||||
if (ret == -1) ret = 0x80;
|
if (ret == -1) ret = 0x80;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 cdvdCtrlTrayClose()
|
s32 cdvdCtrlTrayClose()
|
||||||
{
|
{
|
||||||
s32 ret = DoCDVDctrlTrayClose();
|
s32 ret = CDVD.ctrlTrayClose();
|
||||||
if (ret == -1) ret = 0x80;
|
if (ret == -1) ret = 0x80;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -433,7 +433,7 @@ s32 cdvdCtrlTrayClose()
|
||||||
// checks if tray was opened since last call to this func
|
// checks if tray was opened since last call to this func
|
||||||
s32 cdvdGetTrayStatus()
|
s32 cdvdGetTrayStatus()
|
||||||
{
|
{
|
||||||
s32 ret = DoCDVDgetTrayStatus();
|
s32 ret = CDVD.getTrayStatus();
|
||||||
|
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
return(CDVD_TRAY_CLOSE);
|
return(CDVD_TRAY_CLOSE);
|
||||||
|
@ -460,41 +460,10 @@ static __forceinline void cdvdGetDiskType()
|
||||||
// 0 if not on dual layer disc
|
// 0 if not on dual layer disc
|
||||||
static s32 cdvdReadDvdDualInfo(s32* dualType, u32* layer1Start)
|
static s32 cdvdReadDvdDualInfo(s32* dualType, u32* layer1Start)
|
||||||
{
|
{
|
||||||
u8 toc[2064];
|
|
||||||
*dualType = 0;
|
*dualType = 0;
|
||||||
*layer1Start = 0;
|
*layer1Start = 0;
|
||||||
|
|
||||||
if(loadFromISO)
|
CDVD.getDualInfo(dualType,layer1Start);
|
||||||
{
|
|
||||||
return ISOgetDualInfo(dualType,layer1Start);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// if error getting toc, settle for single layer disc ;)
|
|
||||||
if(cdvdGetToc(toc))
|
|
||||||
return 0;
|
|
||||||
if(toc[14] & 0x60)
|
|
||||||
{
|
|
||||||
if(toc[14] & 0x10)
|
|
||||||
{
|
|
||||||
// otp dvd
|
|
||||||
*dualType = 2;
|
|
||||||
*layer1Start = (toc[25]<<16) + (toc[26]<<8) + (toc[27]) - 0x30000 + 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// ptp dvd
|
|
||||||
*dualType = 1;
|
|
||||||
*layer1Start = (toc[21]<<16) + (toc[22]<<8) + (toc[23]) - 0x30000 + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// single layer dvd
|
|
||||||
*dualType = 0;
|
|
||||||
*layer1Start = (toc[21]<<16) + (toc[22]<<8) + (toc[23]) - 0x30000 + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -554,7 +523,7 @@ void SaveState::cdvdFreeze()
|
||||||
void cdvdNewDiskCB()
|
void cdvdNewDiskCB()
|
||||||
{
|
{
|
||||||
DoCDVDresetDiskTypeCache();
|
DoCDVDresetDiskTypeCache();
|
||||||
cdvd.Type = CDVDgetDiskType();
|
cdvd.Type = CDVD.getDiskType();
|
||||||
|
|
||||||
|
|
||||||
char str[g_MaxPath];
|
char str[g_MaxPath];
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include "IopCommon.h"
|
#include "IopCommon.h"
|
||||||
#include "CDVD/CDVDaccess.h"
|
#include "CDVD/CDVDaccess.h"
|
||||||
|
|
||||||
extern bool loadFromISO;
|
|
||||||
extern char isoFileName[];
|
extern char isoFileName[];
|
||||||
|
|
||||||
#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */
|
#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
static int diskTypeCached=-1;
|
static int diskTypeCached=-1;
|
||||||
|
|
||||||
static int psize;
|
int lastReadSize;
|
||||||
static int plsn=0;
|
static int plsn=0;
|
||||||
|
|
||||||
static isoFile *blockDumpFile;
|
static isoFile *blockDumpFile;
|
||||||
|
@ -100,12 +100,12 @@ int FindDiskType(int mType)
|
||||||
|
|
||||||
cdvdTN tn;
|
cdvdTN tn;
|
||||||
|
|
||||||
DoCDVDgetTN(&tn);
|
CDVD.getTN(&tn);
|
||||||
|
|
||||||
if((mt<0) || ((mt == CDVD_TYPE_DETCTDVDS) && (tn.strack != tn.etrack)))
|
if((mt<0) || ((mt == CDVD_TYPE_DETCTDVDS) && (tn.strack != tn.etrack)))
|
||||||
{
|
{
|
||||||
cdvdTD td;
|
cdvdTD td;
|
||||||
DoCDVDgetTD(0,&td);
|
CDVD.getTD(0,&td);
|
||||||
if(td.lsn>452849)
|
if(td.lsn>452849)
|
||||||
{
|
{
|
||||||
iCDType = CDVD_TYPE_DETCTDVDS;
|
iCDType = CDVD_TYPE_DETCTDVDS;
|
||||||
|
@ -127,12 +127,12 @@ int FindDiskType(int mType)
|
||||||
for(int i=tn.strack;i<=tn.etrack;i++)
|
for(int i=tn.strack;i<=tn.etrack;i++)
|
||||||
{
|
{
|
||||||
cdvdTD td,td2;
|
cdvdTD td,td2;
|
||||||
DoCDVDgetTD(i,&td);
|
CDVD.getTD(i,&td);
|
||||||
|
|
||||||
if(tn.etrack>i)
|
if(tn.etrack>i)
|
||||||
DoCDVDgetTD(i+1,&td2);
|
CDVD.getTD(i+1,&td2);
|
||||||
else
|
else
|
||||||
DoCDVDgetTD(0,&td2);
|
CDVD.getTD(0,&td2);
|
||||||
|
|
||||||
int tlength = td2.lsn - td.lsn;
|
int tlength = td2.lsn - td.lsn;
|
||||||
|
|
||||||
|
@ -174,13 +174,13 @@ int FindDiskType(int mType)
|
||||||
|
|
||||||
void DetectDiskType()
|
void DetectDiskType()
|
||||||
{
|
{
|
||||||
if (DoCDVDgetTrayStatus() == CDVD_TRAY_OPEN)
|
if (CDVD.getTrayStatus() == CDVD_TRAY_OPEN)
|
||||||
{
|
{
|
||||||
diskTypeCached = CDVD_TYPE_NODISC;
|
diskTypeCached = CDVD_TYPE_NODISC;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int baseMediaType = DoCDVDgetDiskType();
|
int baseMediaType = CDVD.getDiskType();
|
||||||
int mType = -1;
|
int mType = -1;
|
||||||
|
|
||||||
switch(baseMediaType) // Paranoid mode: do not trust the plugin's detection system to work correctly.
|
switch(baseMediaType) // Paranoid mode: do not trust the plugin's detection system to work correctly.
|
||||||
|
@ -212,31 +212,25 @@ void DetectDiskType()
|
||||||
//
|
//
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
|
|
||||||
int cdvdInitCount=0;
|
|
||||||
|
|
||||||
s32 DoCDVDinit()
|
s32 DoCDVDinit()
|
||||||
{
|
{
|
||||||
// called even when not used
|
|
||||||
ISOinit();
|
|
||||||
|
|
||||||
if(!loadFromISO)
|
|
||||||
{
|
|
||||||
cdvdInitCount++; // used to handle the case where the plugin was inited at boot, but then iso takes over
|
|
||||||
return CDVDinit();
|
|
||||||
}
|
|
||||||
|
|
||||||
diskTypeCached=-1;
|
diskTypeCached=-1;
|
||||||
|
|
||||||
return 0;
|
if(CDVD.initCount) *CDVD.initCount++; // used to handle the case where the plugin was inited at boot, but then iso takes over
|
||||||
|
return CDVD.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoCDVDshutdown()
|
||||||
|
{
|
||||||
|
if(CDVD.initCount) *CDVD.initCount--;
|
||||||
|
CDVD.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 DoCDVDopen(const char* pTitleFilename)
|
s32 DoCDVDopen(const char* pTitleFilename)
|
||||||
{
|
{
|
||||||
int ret=0;
|
int ret=0;
|
||||||
if(loadFromISO)
|
|
||||||
ret = ISOopen(pTitleFilename);
|
ret = CDVD.open(pTitleFilename);
|
||||||
else
|
|
||||||
ret = CDVDopen(pTitleFilename);
|
|
||||||
|
|
||||||
int cdtype = DoCDVDdetectDiskType();
|
int cdtype = DoCDVDdetectDiskType();
|
||||||
|
|
||||||
|
@ -244,7 +238,7 @@ s32 DoCDVDopen(const char* pTitleFilename)
|
||||||
{
|
{
|
||||||
char fname_only[MAX_PATH];
|
char fname_only[MAX_PATH];
|
||||||
|
|
||||||
if(loadFromISO)
|
if(CDVD.init == ISO.init)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
char fname[MAX_PATH], ext[MAX_PATH];
|
char fname[MAX_PATH], ext[MAX_PATH];
|
||||||
|
@ -298,7 +292,7 @@ s32 DoCDVDopen(const char* pTitleFilename)
|
||||||
strcat(fname_only, ".dump");
|
strcat(fname_only, ".dump");
|
||||||
#endif
|
#endif
|
||||||
cdvdTD td;
|
cdvdTD td;
|
||||||
DoCDVDgetTD(0, &td);
|
CDVD.getTD(0, &td);
|
||||||
|
|
||||||
int blockofs=0;
|
int blockofs=0;
|
||||||
int blocksize=0;
|
int blocksize=0;
|
||||||
|
@ -330,58 +324,9 @@ s32 DoCDVDopen(const char* pTitleFilename)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoCDVDclose()
|
|
||||||
{
|
|
||||||
if(loadFromISO)
|
|
||||||
ISOclose();
|
|
||||||
else
|
|
||||||
CDVDclose();
|
|
||||||
|
|
||||||
if (blockDumpFile != NULL) isoClose(blockDumpFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DoCDVDshutdown()
|
|
||||||
{
|
|
||||||
if((!loadFromISO)||(cdvdInitCount>0)) // handle the case where the plugin was inited at boot, but then iso takes over
|
|
||||||
{
|
|
||||||
cdvdInitCount--;
|
|
||||||
if (CDVDshutdown != NULL) CDVDshutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
ISOshutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 DoCDVDreadSector(u8* buffer, u32 lsn, int mode)
|
s32 DoCDVDreadSector(u8* buffer, u32 lsn, int mode)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret = CDVD.readSector(buffer,lsn,mode);
|
||||||
|
|
||||||
if(loadFromISO)
|
|
||||||
ret = ISOreadSector(buffer,lsn,mode);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CDVDreadTrack(lsn,mode);
|
|
||||||
void* pbuffer = CDVDgetBuffer();
|
|
||||||
if(pbuffer!=NULL)
|
|
||||||
{
|
|
||||||
switch(mode)
|
|
||||||
{
|
|
||||||
case CDVD_MODE_2048:
|
|
||||||
memcpy(buffer,pbuffer,2048);
|
|
||||||
break;
|
|
||||||
case CDVD_MODE_2328:
|
|
||||||
memcpy(buffer,pbuffer,2328);
|
|
||||||
break;
|
|
||||||
case CDVD_MODE_2340:
|
|
||||||
memcpy(buffer,pbuffer,2340);
|
|
||||||
break;
|
|
||||||
case CDVD_MODE_2352:
|
|
||||||
memcpy(buffer,pbuffer,2352);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
else ret = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ret==0)
|
if(ret==0)
|
||||||
{
|
{
|
||||||
|
@ -395,48 +340,31 @@ s32 DoCDVDreadSector(u8* buffer, u32 lsn, int mode)
|
||||||
|
|
||||||
s32 DoCDVDreadTrack(u32 lsn, int mode)
|
s32 DoCDVDreadTrack(u32 lsn, int mode)
|
||||||
{
|
{
|
||||||
if(loadFromISO)
|
// TEMP: until all the plugins use the new CDVDgetBuffer style
|
||||||
return ISOreadTrack(lsn, mode);
|
switch (mode)
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// TEMP: until I fix all the plugins to use the new CDVDgetBuffer style
|
case CDVD_MODE_2352:
|
||||||
switch (mode)
|
lastReadSize = 2352;
|
||||||
{
|
break;
|
||||||
case CDVD_MODE_2352:
|
case CDVD_MODE_2340:
|
||||||
psize = 2352;
|
lastReadSize = 2340;
|
||||||
break;
|
break;
|
||||||
case CDVD_MODE_2340:
|
case CDVD_MODE_2328:
|
||||||
psize = 2340;
|
lastReadSize = 2328;
|
||||||
break;
|
break;
|
||||||
case CDVD_MODE_2328:
|
case CDVD_MODE_2048:
|
||||||
psize = 2328;
|
lastReadSize = 2048;
|
||||||
break;
|
break;
|
||||||
case CDVD_MODE_2048:
|
|
||||||
psize = 2048;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return CDVDreadTrack(lsn, mode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return CDVD.readTrack(lsn,mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return can be NULL (for async modes)
|
// return can be NULL (for async modes)
|
||||||
|
|
||||||
s32 DoCDVDgetBuffer(u8* buffer)
|
s32 DoCDVDgetBuffer(u8* buffer)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret = CDVD.getBuffer2(buffer);
|
||||||
|
|
||||||
if(loadFromISO)
|
|
||||||
ret = ISOgetBuffer(buffer);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TEMP: until I fix all the plugins to use this function style
|
|
||||||
u8* pb = CDVDgetBuffer();
|
|
||||||
if(pb!=NULL)
|
|
||||||
{
|
|
||||||
memcpy(buffer,pb,psize);
|
|
||||||
ret=0;
|
|
||||||
}
|
|
||||||
else ret= -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ret==0)
|
if(ret==0)
|
||||||
{
|
{
|
||||||
|
@ -445,49 +373,10 @@ s32 DoCDVDgetBuffer(u8* buffer)
|
||||||
isoWriteBlock(blockDumpFile, buffer, plsn);
|
isoWriteBlock(blockDumpFile, buffer, plsn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 DoCDVDreadSubQ(u32 lsn, cdvdSubQ* subq)
|
|
||||||
{
|
|
||||||
if(loadFromISO)
|
|
||||||
return ISOreadSubQ(lsn,subq);
|
|
||||||
else
|
|
||||||
return CDVDreadSubQ(lsn,subq);
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 DoCDVDgetTN(cdvdTN *Buffer)
|
|
||||||
{
|
|
||||||
if(loadFromISO)
|
|
||||||
return ISOgetTN(Buffer);
|
|
||||||
else
|
|
||||||
return CDVDgetTN(Buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 DoCDVDgetTD(u8 Track, cdvdTD *Buffer)
|
|
||||||
{
|
|
||||||
if(loadFromISO)
|
|
||||||
return ISOgetTD(Track,Buffer);
|
|
||||||
else
|
|
||||||
return CDVDgetTD(Track,Buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 DoCDVDgetTOC(void* toc)
|
|
||||||
{
|
|
||||||
if(loadFromISO)
|
|
||||||
return ISOgetTOC(toc);
|
|
||||||
else
|
|
||||||
return CDVDgetTOC(toc);
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 DoCDVDgetDiskType()
|
|
||||||
{
|
|
||||||
if(loadFromISO)
|
|
||||||
return ISOgetDiskType();
|
|
||||||
else
|
|
||||||
return CDVDgetDiskType();
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 DoCDVDdetectDiskType()
|
s32 DoCDVDdetectDiskType()
|
||||||
{
|
{
|
||||||
if(diskTypeCached<0)
|
if(diskTypeCached<0)
|
||||||
|
@ -498,38 +387,5 @@ s32 DoCDVDdetectDiskType()
|
||||||
|
|
||||||
void DoCDVDresetDiskTypeCache()
|
void DoCDVDresetDiskTypeCache()
|
||||||
{
|
{
|
||||||
diskTypeCached=-1;
|
diskTypeCached = -1;
|
||||||
}
|
|
||||||
|
|
||||||
s32 DoCDVDgetTrayStatus()
|
|
||||||
{
|
|
||||||
if(loadFromISO)
|
|
||||||
return ISOgetTrayStatus();
|
|
||||||
else
|
|
||||||
return CDVDgetTrayStatus();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 DoCDVDctrlTrayOpen()
|
|
||||||
{
|
|
||||||
if(loadFromISO)
|
|
||||||
return ISOctrlTrayOpen();
|
|
||||||
else
|
|
||||||
return CDVDctrlTrayOpen();
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 DoCDVDctrlTrayClose()
|
|
||||||
{
|
|
||||||
if(loadFromISO)
|
|
||||||
return ISOctrlTrayClose();
|
|
||||||
else
|
|
||||||
return CDVDctrlTrayClose();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DoCDVDnewDiskCB(void (*callback)())
|
|
||||||
{
|
|
||||||
if(!loadFromISO)
|
|
||||||
{
|
|
||||||
if (CDVDnewDiskCB) CDVDnewDiskCB(callback);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,13 +27,6 @@ extern s32 DoCDVDreadSector(u8* buffer, u32 lsn, int mode);
|
||||||
extern s32 DoCDVDreadTrack(u32 lsn, int mode);
|
extern s32 DoCDVDreadTrack(u32 lsn, int mode);
|
||||||
extern s32 DoCDVDgetBuffer(u8* buffer);
|
extern s32 DoCDVDgetBuffer(u8* buffer);
|
||||||
extern s32 DoCDVDreadSubQ(u32 lsn, cdvdSubQ* subq);
|
extern s32 DoCDVDreadSubQ(u32 lsn, cdvdSubQ* subq);
|
||||||
extern s32 DoCDVDgetTN(cdvdTN *Buffer);
|
|
||||||
extern s32 DoCDVDgetTD(u8 Track, cdvdTD *Buffer);
|
|
||||||
extern s32 DoCDVDgetTOC(void* toc);
|
|
||||||
extern s32 DoCDVDgetDiskType();
|
|
||||||
extern s32 DoCDVDgetTrayStatus();
|
|
||||||
extern s32 DoCDVDctrlTrayOpen();
|
|
||||||
extern s32 DoCDVDctrlTrayClose();
|
|
||||||
extern void DoCDVDnewDiskCB(void (*callback)());
|
extern void DoCDVDnewDiskCB(void (*callback)());
|
||||||
extern s32 DoCDVDdetectDiskType();
|
extern s32 DoCDVDdetectDiskType();
|
||||||
extern void DoCDVDresetDiskTypeCache();
|
extern void DoCDVDresetDiskTypeCache();
|
||||||
|
|
|
@ -27,14 +27,12 @@
|
||||||
|
|
||||||
#include "CDVDisoReader.h"
|
#include "CDVDisoReader.h"
|
||||||
|
|
||||||
bool loadFromISO=false;
|
|
||||||
|
|
||||||
char isoFileName[256];
|
char isoFileName[256];
|
||||||
|
|
||||||
u8 *pbuffer;
|
u8 *pbuffer;
|
||||||
int cdtype;
|
int cdtype;
|
||||||
|
|
||||||
int psize;
|
static int psize;
|
||||||
|
|
||||||
isoFile *iso;
|
isoFile *iso;
|
||||||
|
|
||||||
|
@ -78,8 +76,7 @@ void __Log(char *fmt, ...)
|
||||||
#define __Log 0&&
|
#define __Log 0&&
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
s32 CALLBACK ISOinit()
|
||||||
s32 ISOinit()
|
|
||||||
{
|
{
|
||||||
#ifdef PCSX2_DEBUG
|
#ifdef PCSX2_DEBUG
|
||||||
cdvdLog = fopen("logs/cdvdLog.txt", "w");
|
cdvdLog = fopen("logs/cdvdLog.txt", "w");
|
||||||
|
@ -99,14 +96,14 @@ s32 ISOinit()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ISOshutdown()
|
void CALLBACK ISOshutdown()
|
||||||
{
|
{
|
||||||
#ifdef CDVD_LOG
|
#ifdef CDVD_LOG
|
||||||
if (cdvdLog != NULL) fclose(cdvdLog);
|
if (cdvdLog != NULL) fclose(cdvdLog);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 ISOopen(const char* pTitle)
|
s32 CALLBACK ISOopen(const char* pTitle)
|
||||||
{
|
{
|
||||||
//if (pTitle != NULL) strcpy(isoFileName, pTitle);
|
//if (pTitle != NULL) strcpy(isoFileName, pTitle);
|
||||||
|
|
||||||
|
@ -127,12 +124,12 @@ s32 ISOopen(const char* pTitle)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ISOclose()
|
void CALLBACK ISOclose()
|
||||||
{
|
{
|
||||||
isoClose(iso);
|
isoClose(iso);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 ISOreadSubQ(u32 lsn, cdvdSubQ* subq)
|
s32 CALLBACK ISOreadSubQ(u32 lsn, cdvdSubQ* subq)
|
||||||
{
|
{
|
||||||
// fake it
|
// fake it
|
||||||
u8 min, sec, frm;
|
u8 min, sec, frm;
|
||||||
|
@ -155,7 +152,7 @@ s32 ISOreadSubQ(u32 lsn, cdvdSubQ* subq)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 ISOgetTN(cdvdTN *Buffer)
|
s32 CALLBACK ISOgetTN(cdvdTN *Buffer)
|
||||||
{
|
{
|
||||||
Buffer->strack = 1;
|
Buffer->strack = 1;
|
||||||
Buffer->etrack = 1;
|
Buffer->etrack = 1;
|
||||||
|
@ -163,7 +160,7 @@ s32 ISOgetTN(cdvdTN *Buffer)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 ISOgetTD(u8 Track, cdvdTD *Buffer)
|
s32 CALLBACK ISOgetTD(u8 Track, cdvdTD *Buffer)
|
||||||
{
|
{
|
||||||
if (Track == 0)
|
if (Track == 0)
|
||||||
{
|
{
|
||||||
|
@ -209,7 +206,7 @@ static void FindLayer1Start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 ISOgetDualInfo(s32* dualType, u32* _layer1start)
|
s32 CALLBACK ISOgetDualInfo(s32* dualType, u32* _layer1start)
|
||||||
{
|
{
|
||||||
FindLayer1Start();
|
FindLayer1Start();
|
||||||
|
|
||||||
|
@ -226,9 +223,14 @@ s32 ISOgetDualInfo(s32* dualType, u32* _layer1start)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 ISOgetTOC(void* toc)
|
s32 CALLBACK ISOgetDiskType()
|
||||||
{
|
{
|
||||||
u8 type = CDVDgetDiskType();
|
return cdtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 CALLBACK ISOgetTOC(void* toc)
|
||||||
|
{
|
||||||
|
u8 type = ISOgetDiskType();
|
||||||
u8* tocBuff = (u8*)toc;
|
u8* tocBuff = (u8*)toc;
|
||||||
|
|
||||||
//__Log("CDVDgetTOC\n");
|
//__Log("CDVDgetTOC\n");
|
||||||
|
@ -291,12 +293,12 @@ s32 ISOgetTOC(void* toc)
|
||||||
cdvdTN diskInfo;
|
cdvdTN diskInfo;
|
||||||
cdvdTD trackInfo;
|
cdvdTD trackInfo;
|
||||||
memset(tocBuff, 0, 1024);
|
memset(tocBuff, 0, 1024);
|
||||||
if (CDVDgetTN(&diskInfo) == -1)
|
if (ISOgetTN(&diskInfo) == -1)
|
||||||
{
|
{
|
||||||
diskInfo.etrack = 0;
|
diskInfo.etrack = 0;
|
||||||
diskInfo.strack = 1;
|
diskInfo.strack = 1;
|
||||||
}
|
}
|
||||||
if (CDVDgetTD(0, &trackInfo) == -1) trackInfo.lsn = 0;
|
if (ISOgetTD(0, &trackInfo) == -1) trackInfo.lsn = 0;
|
||||||
|
|
||||||
tocBuff[0] = 0x41;
|
tocBuff[0] = 0x41;
|
||||||
tocBuff[1] = 0x00;
|
tocBuff[1] = 0x00;
|
||||||
|
@ -317,7 +319,7 @@ s32 ISOgetTOC(void* toc)
|
||||||
|
|
||||||
for (i = diskInfo.strack; i <= diskInfo.etrack; i++)
|
for (i = diskInfo.strack; i <= diskInfo.etrack; i++)
|
||||||
{
|
{
|
||||||
err = CDVDgetTD(i, &trackInfo);
|
err = ISOgetTD(i, &trackInfo);
|
||||||
lba_to_msf(trackInfo.lsn, &min, &sec, &frm);
|
lba_to_msf(trackInfo.lsn, &min, &sec, &frm);
|
||||||
tocBuff[i*10+30] = trackInfo.type;
|
tocBuff[i*10+30] = trackInfo.type;
|
||||||
tocBuff[i*10+32] = err == -1 ? 0 : itob(i); //number
|
tocBuff[i*10+32] = err == -1 ? 0 : itob(i); //number
|
||||||
|
@ -332,7 +334,7 @@ s32 ISOgetTOC(void* toc)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 ISOreadSector(u8* tempbuffer, u32 lsn, int mode)
|
s32 CALLBACK ISOreadSector(u8* tempbuffer, u32 lsn, int mode)
|
||||||
{
|
{
|
||||||
int _lsn = lsn;
|
int _lsn = lsn;
|
||||||
|
|
||||||
|
@ -375,7 +377,7 @@ s32 ISOreadSector(u8* tempbuffer, u32 lsn, int mode)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 ISOreadTrack(u32 lsn, int mode)
|
s32 CALLBACK ISOreadTrack(u32 lsn, int mode)
|
||||||
{
|
{
|
||||||
int _lsn = lsn;
|
int _lsn = lsn;
|
||||||
|
|
||||||
|
@ -410,28 +412,63 @@ s32 ISOreadTrack(u32 lsn, int mode)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 ISOgetBuffer(u8* buffer)
|
s32 CALLBACK ISOgetBuffer2(u8* buffer)
|
||||||
{
|
{
|
||||||
memcpy_fast(buffer,pbuffer,psize);
|
memcpy_fast(buffer,pbuffer,psize);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 ISOgetDiskType()
|
s32 CALLBACK ISOgetTrayStatus()
|
||||||
{
|
|
||||||
return cdtype;
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 ISOgetTrayStatus()
|
|
||||||
{
|
{
|
||||||
return CDVD_TRAY_CLOSE;
|
return CDVD_TRAY_CLOSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 ISOctrlTrayOpen()
|
s32 CALLBACK ISOctrlTrayOpen()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
s32 ISOctrlTrayClose()
|
s32 CALLBACK ISOctrlTrayClose()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s32 CALLBACK ISOdummyS32()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CALLBACK ISOdummyVOID()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CALLBACK ISOnewDiskCB(void(CALLBACK*)())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CDVDplugin ISO = {
|
||||||
|
ISOinit,
|
||||||
|
ISOopen,
|
||||||
|
ISOclose,
|
||||||
|
ISOshutdown,
|
||||||
|
ISOreadTrack,
|
||||||
|
NULL, // emu shouldn't try to use this one.
|
||||||
|
ISOreadSubQ,
|
||||||
|
ISOgetTN,
|
||||||
|
ISOgetTD,
|
||||||
|
ISOgetTOC,
|
||||||
|
ISOgetDiskType,
|
||||||
|
ISOdummyS32,
|
||||||
|
ISOdummyS32,
|
||||||
|
ISOdummyS32,
|
||||||
|
|
||||||
|
ISOdummyVOID,
|
||||||
|
ISOdummyS32,
|
||||||
|
ISOdummyVOID,
|
||||||
|
ISOnewDiskCB,
|
||||||
|
|
||||||
|
ISOreadSector,
|
||||||
|
ISOgetBuffer2,
|
||||||
|
ISOgetDualInfo,
|
||||||
|
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
|
@ -45,21 +45,4 @@ void __Log(char *fmt, ...);
|
||||||
extern char isoFileName[256];
|
extern char isoFileName[256];
|
||||||
extern isoFile *iso;
|
extern isoFile *iso;
|
||||||
|
|
||||||
extern s32 ISOinit();
|
|
||||||
extern void ISOshutdown();
|
|
||||||
extern s32 ISOopen(const char* pTitle);
|
|
||||||
extern void ISOclose();
|
|
||||||
extern s32 ISOreadSubQ(u32 lsn, cdvdSubQ* subq);
|
|
||||||
extern s32 ISOgetTN(cdvdTN *Buffer);
|
|
||||||
extern s32 ISOgetTD(u8 tn, cdvdTD *Buffer);
|
|
||||||
extern s32 ISOgetDiskType();
|
|
||||||
extern s32 ISOgetTrayStatus();
|
|
||||||
extern s32 ISOctrlTrayOpen();
|
|
||||||
extern s32 ISOctrlTrayClose();
|
|
||||||
extern s32 ISOreadSector(u8* tempbuffer, u32 lsn, int mode);
|
|
||||||
extern s32 ISOgetTOC(void* toc);
|
|
||||||
extern s32 ISOreadTrack(u32 lsn, int mode);
|
|
||||||
extern s32 ISOgetBuffer(u8* buffer);
|
|
||||||
extern s32 ISOgetDualInfo(s32* dualType, u32* _layer1start);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -332,7 +332,7 @@ void cdrInterrupt() {
|
||||||
SetResultSize(3);
|
SetResultSize(3);
|
||||||
cdr.StatP|= 0x2;
|
cdr.StatP|= 0x2;
|
||||||
cdr.Result[0] = cdr.StatP;
|
cdr.Result[0] = cdr.StatP;
|
||||||
if (DoCDVDgetTN(&cdr.ResultTN) == -1) {
|
if (CDVD.getTN(&cdr.ResultTN) == -1) {
|
||||||
cdr.Stat = DiskError;
|
cdr.Stat = DiskError;
|
||||||
cdr.Result[0]|= 0x01;
|
cdr.Result[0]|= 0x01;
|
||||||
} else {
|
} else {
|
||||||
|
@ -347,7 +347,7 @@ void cdrInterrupt() {
|
||||||
cdr.Track = btoi(cdr.Param[0]);
|
cdr.Track = btoi(cdr.Param[0]);
|
||||||
SetResultSize(4);
|
SetResultSize(4);
|
||||||
cdr.StatP|= 0x2;
|
cdr.StatP|= 0x2;
|
||||||
if (DoCDVDgetTD(cdr.Track, &trackInfo) == -1) {
|
if (CDVD.getTD(cdr.Track, &trackInfo) == -1) {
|
||||||
cdr.Stat = DiskError;
|
cdr.Stat = DiskError;
|
||||||
cdr.Result[0]|= 0x01;
|
cdr.Result[0]|= 0x01;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -335,7 +335,7 @@ void OnLanguage(GtkMenuItem *menuitem, gpointer user_data)
|
||||||
|
|
||||||
void OnFile_RunCD(GtkMenuItem *menuitem, gpointer user_data)
|
void OnFile_RunCD(GtkMenuItem *menuitem, gpointer user_data)
|
||||||
{
|
{
|
||||||
loadFromISO = false;
|
CDVD = CDVD_plugin;
|
||||||
SysReset();
|
SysReset();
|
||||||
SysPrepareExecution(NULL);
|
SysPrepareExecution(NULL);
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ void OnFile_RunCD(GtkMenuItem *menuitem, gpointer user_data)
|
||||||
void OnRunIso_Ok(GtkButton* button, gpointer user_data)
|
void OnRunIso_Ok(GtkButton* button, gpointer user_data)
|
||||||
{
|
{
|
||||||
gchar *File;
|
gchar *File;
|
||||||
loadFromISO = true;
|
CDVD = ISO;
|
||||||
|
|
||||||
File = (gchar*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel));
|
File = (gchar*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(FileSel));
|
||||||
strcpy(isoFileName, File);
|
strcpy(isoFileName, File);
|
||||||
|
|
|
@ -138,25 +138,8 @@ _SPU2test SPU2test;
|
||||||
_SPU2about SPU2about;
|
_SPU2about SPU2about;
|
||||||
|
|
||||||
// CDVD
|
// CDVD
|
||||||
_CDVDinit CDVDinit;
|
CDVDplugin CDVD_plugin = {0};
|
||||||
_CDVDopen CDVDopen;
|
CDVDplugin CDVD = {0};
|
||||||
_CDVDclose CDVDclose;
|
|
||||||
_CDVDshutdown CDVDshutdown;
|
|
||||||
_CDVDreadTrack CDVDreadTrack;
|
|
||||||
_CDVDgetBuffer CDVDgetBuffer;
|
|
||||||
_CDVDreadSubQ CDVDreadSubQ;
|
|
||||||
_CDVDgetTN CDVDgetTN;
|
|
||||||
_CDVDgetTD CDVDgetTD;
|
|
||||||
_CDVDgetTOC CDVDgetTOC;
|
|
||||||
_CDVDgetDiskType CDVDgetDiskType;
|
|
||||||
_CDVDgetTrayStatus CDVDgetTrayStatus;
|
|
||||||
_CDVDctrlTrayOpen CDVDctrlTrayOpen;
|
|
||||||
_CDVDctrlTrayClose CDVDctrlTrayClose;
|
|
||||||
|
|
||||||
_CDVDconfigure CDVDconfigure;
|
|
||||||
_CDVDtest CDVDtest;
|
|
||||||
_CDVDabout CDVDabout;
|
|
||||||
_CDVDnewDiskCB CDVDnewDiskCB;
|
|
||||||
|
|
||||||
// DEV9
|
// DEV9
|
||||||
_DEV9init DEV9init;
|
_DEV9init DEV9init;
|
||||||
|
@ -218,18 +201,21 @@ _FWabout FWabout;
|
||||||
DEV9handler dev9Handler;
|
DEV9handler dev9Handler;
|
||||||
USBhandler usbHandler;
|
USBhandler usbHandler;
|
||||||
|
|
||||||
enum PluginTypes
|
namespace PluginTypes
|
||||||
{
|
{
|
||||||
GS = 0,
|
enum PluginTypes
|
||||||
PAD,
|
{
|
||||||
PAD1,
|
GS = 0,
|
||||||
PAD2,
|
PAD,
|
||||||
SPU2,
|
PAD1,
|
||||||
CDVD,
|
PAD2,
|
||||||
DEV9,
|
SPU2,
|
||||||
USB,
|
CDVD,
|
||||||
FW
|
DEV9,
|
||||||
};
|
USB,
|
||||||
|
FW
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
int PS2E_LT[9] = {
|
int PS2E_LT[9] = {
|
||||||
PS2E_LT_GS,
|
PS2E_LT_GS,
|
||||||
|
@ -265,6 +251,10 @@ PS2E_FW_VERSION};
|
||||||
#define MapSymbol_Fallback(name,fallback) MapSymbolVar_Fallback(name,name,fallback)
|
#define MapSymbol_Fallback(name,fallback) MapSymbolVar_Fallback(name,name,fallback)
|
||||||
#define MapSymbol_Error(name) MapSymbolVar_Error(name,name)
|
#define MapSymbol_Error(name) MapSymbolVar_Error(name,name)
|
||||||
|
|
||||||
|
#define MapSymbol2(base,name) MapSymbolVar(base##_plugin.name,base##name)
|
||||||
|
#define MapSymbol2_Fallback(base,name,fallback) MapSymbolVar_Fallback(base##_plugin.name,base##name,fallback)
|
||||||
|
#define MapSymbol2_Error(base,name) MapSymbolVar_Error(base##_plugin.name,base##name)
|
||||||
|
|
||||||
// for pad1/2
|
// for pad1/2
|
||||||
#define MapSymbolPAD(var,name) MapSymbolVar(var##name,PAD##name)
|
#define MapSymbolPAD(var,name) MapSymbolVar(var##name,PAD##name)
|
||||||
#define MapSymbolPAD_Fallback(var,name) if((MapSymbolVarType(var##name,_PAD##name,PAD##name))==NULL) var##name = var##_##name
|
#define MapSymbolPAD_Fallback(var,name) if((MapSymbolVarType(var##name,_PAD##name,PAD##name))==NULL) var##name = var##_##name
|
||||||
|
@ -292,7 +282,7 @@ static int _TestPS2Esyms(void* drv, int type, int expected_version, const string
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __forceinline bool TestPS2Esyms(void* &drv, PluginTypes type, const string& filename)
|
static __forceinline bool TestPS2Esyms(void* &drv, PluginTypes::PluginTypes type, const string& filename)
|
||||||
{
|
{
|
||||||
if (_TestPS2Esyms(drv, PS2E_LT[type],PS2E_VERSION[type],filename) < 0) return false;
|
if (_TestPS2Esyms(drv, PS2E_LT[type],PS2E_VERSION[type],filename) < 0) return false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -324,7 +314,7 @@ int LoadGSplugin(const string& filename)
|
||||||
GSplugin = SysLoadLibrary(filename.c_str());
|
GSplugin = SysLoadLibrary(filename.c_str());
|
||||||
if (GSplugin == NULL) { Msgbox::Alert ("Could Not Load GS Plugin '%hs': %s", params &filename, SysLibError()); return -1; }
|
if (GSplugin == NULL) { Msgbox::Alert ("Could Not Load GS Plugin '%hs': %s", params &filename, SysLibError()); return -1; }
|
||||||
drv = GSplugin;
|
drv = GSplugin;
|
||||||
if (!TestPS2Esyms(drv, GS, filename)) return -1;
|
if (!TestPS2Esyms(drv, PluginTypes::GS, filename)) return -1;
|
||||||
MapSymbol_Error(GSinit);
|
MapSymbol_Error(GSinit);
|
||||||
MapSymbol_Error(GSshutdown);
|
MapSymbol_Error(GSshutdown);
|
||||||
MapSymbol_Error(GSopen);
|
MapSymbol_Error(GSopen);
|
||||||
|
@ -379,7 +369,7 @@ int LoadPAD1plugin(const string& filename) {
|
||||||
PAD1plugin = SysLoadLibrary(filename.c_str());
|
PAD1plugin = SysLoadLibrary(filename.c_str());
|
||||||
if (PAD1plugin == NULL) { Msgbox::Alert("Could Not Load PAD1 Plugin '%hs': %s", params &filename, SysLibError()); return -1; }
|
if (PAD1plugin == NULL) { Msgbox::Alert("Could Not Load PAD1 Plugin '%hs': %s", params &filename, SysLibError()); return -1; }
|
||||||
drv = PAD1plugin;
|
drv = PAD1plugin;
|
||||||
if (!TestPS2Esyms(drv, PAD, filename)) return -1;
|
if (!TestPS2Esyms(drv, PluginTypes::PAD, filename)) return -1;
|
||||||
MapSymbolPAD_Error(PAD1,init);
|
MapSymbolPAD_Error(PAD1,init);
|
||||||
MapSymbolPAD_Error(PAD1,shutdown);
|
MapSymbolPAD_Error(PAD1,shutdown);
|
||||||
MapSymbolPAD_Error(PAD1,open);
|
MapSymbolPAD_Error(PAD1,open);
|
||||||
|
@ -416,7 +406,7 @@ int LoadPAD2plugin(const string& filename) {
|
||||||
PAD2plugin = SysLoadLibrary(filename.c_str());
|
PAD2plugin = SysLoadLibrary(filename.c_str());
|
||||||
if (PAD2plugin == NULL) { Msgbox::Alert("Could Not Load PAD2 Plugin '%hs': %s", params &filename, SysLibError()); return -1; }
|
if (PAD2plugin == NULL) { Msgbox::Alert("Could Not Load PAD2 Plugin '%hs': %s", params &filename, SysLibError()); return -1; }
|
||||||
drv = PAD2plugin;
|
drv = PAD2plugin;
|
||||||
if (!TestPS2Esyms(drv, PAD, filename)) return -1;
|
if (!TestPS2Esyms(drv, PluginTypes::PAD, filename)) return -1;
|
||||||
MapSymbolPAD_Error(PAD2,init);
|
MapSymbolPAD_Error(PAD2,init);
|
||||||
MapSymbolPAD_Error(PAD2,shutdown);
|
MapSymbolPAD_Error(PAD2,shutdown);
|
||||||
MapSymbolPAD_Error(PAD2,open);
|
MapSymbolPAD_Error(PAD2,open);
|
||||||
|
@ -451,7 +441,7 @@ int LoadSPU2plugin(const string& filename) {
|
||||||
SPU2plugin = SysLoadLibrary(filename.c_str());
|
SPU2plugin = SysLoadLibrary(filename.c_str());
|
||||||
if (SPU2plugin == NULL) { Msgbox::Alert("Could Not Load SPU2 Plugin '%hs': %s", params &filename, SysLibError()); return -1; }
|
if (SPU2plugin == NULL) { Msgbox::Alert("Could Not Load SPU2 Plugin '%hs': %s", params &filename, SysLibError()); return -1; }
|
||||||
drv = SPU2plugin;
|
drv = SPU2plugin;
|
||||||
if (!TestPS2Esyms(drv, SPU2, filename)) return -1;
|
if (!TestPS2Esyms(drv, PluginTypes::SPU2, filename)) return -1;
|
||||||
MapSymbol_Error(SPU2init);
|
MapSymbol_Error(SPU2init);
|
||||||
MapSymbol_Error(SPU2shutdown);
|
MapSymbol_Error(SPU2shutdown);
|
||||||
MapSymbol_Error(SPU2open);
|
MapSymbol_Error(SPU2open);
|
||||||
|
@ -489,32 +479,119 @@ void CALLBACK CDVD_about() {}
|
||||||
s32 CALLBACK CDVD_test() { return 0; }
|
s32 CALLBACK CDVD_test() { return 0; }
|
||||||
void CALLBACK CDVD_newDiskCB(void (*callback)()) {}
|
void CALLBACK CDVD_newDiskCB(void (*callback)()) {}
|
||||||
|
|
||||||
|
s32 CALLBACK CDVD_getBuffer2(u8* buffer)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
extern int lastReadSize;
|
||||||
|
|
||||||
|
// 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= -1;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
s32 CALLBACK CDVD_readSector(u8* buffer, u32 lsn, int mode)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
CDVD.readTrack(lsn,mode);
|
||||||
|
void* pbuffer = CDVD.getBuffer();
|
||||||
|
if(pbuffer!=NULL)
|
||||||
|
{
|
||||||
|
switch(mode)
|
||||||
|
{
|
||||||
|
case CDVD_MODE_2048:
|
||||||
|
memcpy(buffer,pbuffer,2048);
|
||||||
|
break;
|
||||||
|
case CDVD_MODE_2328:
|
||||||
|
memcpy(buffer,pbuffer,2328);
|
||||||
|
break;
|
||||||
|
case CDVD_MODE_2340:
|
||||||
|
memcpy(buffer,pbuffer,2340);
|
||||||
|
break;
|
||||||
|
case CDVD_MODE_2352:
|
||||||
|
memcpy(buffer,pbuffer,2352);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
else ret = -1;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 CALLBACK CDVD_getDualInfo(s32* dualType, u32* layer1Start)
|
||||||
|
{
|
||||||
|
u8 toc[2064];
|
||||||
|
|
||||||
|
// if error getting toc, settle for single layer disc ;)
|
||||||
|
if(CDVD.getTOC(toc))
|
||||||
|
return 0;
|
||||||
|
if(toc[14] & 0x60)
|
||||||
|
{
|
||||||
|
if(toc[14] & 0x10)
|
||||||
|
{
|
||||||
|
// otp dvd
|
||||||
|
*dualType = 2;
|
||||||
|
*layer1Start = (toc[25]<<16) + (toc[26]<<8) + (toc[27]) - 0x30000 + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// ptp dvd
|
||||||
|
*dualType = 1;
|
||||||
|
*layer1Start = (toc[21]<<16) + (toc[22]<<8) + (toc[23]) - 0x30000 + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// single layer dvd
|
||||||
|
*dualType = 0;
|
||||||
|
*layer1Start = (toc[21]<<16) + (toc[22]<<8) + (toc[23]) - 0x30000 + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int cdvdInitCount;
|
||||||
int LoadCDVDplugin(const string& filename) {
|
int LoadCDVDplugin(const string& filename) {
|
||||||
void *drv;
|
void *drv;
|
||||||
|
|
||||||
CDVDplugin = SysLoadLibrary(filename.c_str());
|
CDVDplugin = SysLoadLibrary(filename.c_str());
|
||||||
if (CDVDplugin == NULL) { Msgbox::Alert("Could Not Load CDVD Plugin '%hs': %s", params &filename, SysLibError()); return -1; }
|
if (CDVDplugin == NULL) { Msgbox::Alert("Could Not Load CDVD Plugin '%hs': %s", params &filename, SysLibError()); return -1; }
|
||||||
drv = CDVDplugin;
|
drv = CDVDplugin;
|
||||||
if (!TestPS2Esyms(drv, CDVD, filename)) return -1;
|
if (!TestPS2Esyms(drv, PluginTypes::CDVD, filename)) return -1;
|
||||||
MapSymbol_Error(CDVDinit);
|
MapSymbol2_Error(CDVD,init);
|
||||||
MapSymbol_Error(CDVDshutdown);
|
MapSymbol2_Error(CDVD,shutdown);
|
||||||
MapSymbol_Error(CDVDopen);
|
MapSymbol2_Error(CDVD,open);
|
||||||
MapSymbol_Error(CDVDclose);
|
MapSymbol2_Error(CDVD,close);
|
||||||
MapSymbol_Error(CDVDreadTrack);
|
MapSymbol2_Error(CDVD,readTrack);
|
||||||
MapSymbol_Error(CDVDgetBuffer);
|
MapSymbol2_Error(CDVD,getBuffer);
|
||||||
MapSymbol_Error(CDVDreadSubQ);
|
MapSymbol2_Error(CDVD,readSubQ);
|
||||||
MapSymbol_Error(CDVDgetTN);
|
MapSymbol2_Error(CDVD,getTN);
|
||||||
MapSymbol_Error(CDVDgetTD);
|
MapSymbol2_Error(CDVD,getTD);
|
||||||
MapSymbol_Error(CDVDgetTOC);
|
MapSymbol2_Error(CDVD,getTOC);
|
||||||
MapSymbol_Error(CDVDgetDiskType);
|
MapSymbol2_Error(CDVD,getDiskType);
|
||||||
MapSymbol_Error(CDVDgetTrayStatus);
|
MapSymbol2_Error(CDVD,getTrayStatus);
|
||||||
MapSymbol_Error(CDVDctrlTrayOpen);
|
MapSymbol2_Error(CDVD,ctrlTrayOpen);
|
||||||
MapSymbol_Error(CDVDctrlTrayClose);
|
MapSymbol2_Error(CDVD,ctrlTrayClose);
|
||||||
|
|
||||||
MapSymbol_Fallback(CDVDconfigure,CDVD_configure);
|
MapSymbol2_Fallback(CDVD,configure,CDVD_configure);
|
||||||
MapSymbol_Fallback(CDVDabout,CDVD_about);
|
MapSymbol2_Fallback(CDVD,about,CDVD_about);
|
||||||
MapSymbol_Fallback(CDVDtest,CDVD_test);
|
MapSymbol2_Fallback(CDVD,test,CDVD_test);
|
||||||
MapSymbol(CDVDnewDiskCB);
|
MapSymbol2_Fallback(CDVD,newDiskCB,CDVD_newDiskCB);
|
||||||
|
|
||||||
|
MapSymbol2_Fallback(CDVD,readSector,CDVD_readSector);
|
||||||
|
MapSymbol2_Fallback(CDVD,getBuffer2,CDVD_getBuffer2);
|
||||||
|
MapSymbol2_Fallback(CDVD,getDualInfo,CDVD_getDualInfo);
|
||||||
|
|
||||||
|
CDVD.initCount = &cdvdInitCount;
|
||||||
|
cdvdInitCount=0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -532,7 +609,7 @@ int LoadDEV9plugin(const string& filename) {
|
||||||
DEV9plugin = SysLoadLibrary(filename.c_str());
|
DEV9plugin = SysLoadLibrary(filename.c_str());
|
||||||
if (DEV9plugin == NULL) { Msgbox::Alert("Could Not Load DEV9 Plugin '%hs': %s", params &filename, SysLibError()); return -1; }
|
if (DEV9plugin == NULL) { Msgbox::Alert("Could Not Load DEV9 Plugin '%hs': %s", params &filename, SysLibError()); return -1; }
|
||||||
drv = DEV9plugin;
|
drv = DEV9plugin;
|
||||||
if (!TestPS2Esyms(drv, DEV9, filename)) return -1;
|
if (!TestPS2Esyms(drv, PluginTypes::DEV9, filename)) return -1;
|
||||||
MapSymbol_Error(DEV9init);
|
MapSymbol_Error(DEV9init);
|
||||||
MapSymbol_Error(DEV9shutdown);
|
MapSymbol_Error(DEV9shutdown);
|
||||||
MapSymbol_Error(DEV9open);
|
MapSymbol_Error(DEV9open);
|
||||||
|
@ -569,7 +646,7 @@ int LoadUSBplugin(const string& filename) {
|
||||||
USBplugin = SysLoadLibrary(filename.c_str());
|
USBplugin = SysLoadLibrary(filename.c_str());
|
||||||
if (USBplugin == NULL) { Msgbox::Alert("Could Not Load USB Plugin '%hs': %s", params &filename, SysLibError()); return -1; }
|
if (USBplugin == NULL) { Msgbox::Alert("Could Not Load USB Plugin '%hs': %s", params &filename, SysLibError()); return -1; }
|
||||||
drv = USBplugin;
|
drv = USBplugin;
|
||||||
if (!TestPS2Esyms(drv, USB, filename)) return -1;
|
if (!TestPS2Esyms(drv, PluginTypes::USB, filename)) return -1;
|
||||||
MapSymbol_Error(USBinit);
|
MapSymbol_Error(USBinit);
|
||||||
MapSymbol_Error(USBshutdown);
|
MapSymbol_Error(USBshutdown);
|
||||||
MapSymbol_Error(USBopen);
|
MapSymbol_Error(USBopen);
|
||||||
|
@ -606,7 +683,7 @@ int LoadFWplugin(const string& filename) {
|
||||||
FWplugin = SysLoadLibrary(filename.c_str());
|
FWplugin = SysLoadLibrary(filename.c_str());
|
||||||
if (FWplugin == NULL) { Msgbox::Alert("Could Not Load FW Plugin '%hs': %s", params &filename, SysLibError()); return -1; }
|
if (FWplugin == NULL) { Msgbox::Alert("Could Not Load FW Plugin '%hs': %s", params &filename, SysLibError()); return -1; }
|
||||||
drv = FWplugin;
|
drv = FWplugin;
|
||||||
if (!TestPS2Esyms(drv, FW, filename)) return -1;
|
if (!TestPS2Esyms(drv, PluginTypes::FW, filename)) return -1;
|
||||||
MapSymbol_Error(FWinit);
|
MapSymbol_Error(FWinit);
|
||||||
MapSymbol_Error(FWshutdown);
|
MapSymbol_Error(FWshutdown);
|
||||||
MapSymbol_Error(FWopen);
|
MapSymbol_Error(FWopen);
|
||||||
|
@ -721,6 +798,10 @@ void ShutdownPlugins()
|
||||||
|
|
||||||
//if (CDVDshutdown != NULL) CDVDshutdown();
|
//if (CDVDshutdown != NULL) CDVDshutdown();
|
||||||
DoCDVDshutdown();
|
DoCDVDshutdown();
|
||||||
|
|
||||||
|
// safety measures, in case ISO is currently loaded.
|
||||||
|
if(cdvdInitCount>0)
|
||||||
|
CDVD_plugin.shutdown();
|
||||||
|
|
||||||
if (DEV9shutdown != NULL) DEV9shutdown();
|
if (DEV9shutdown != NULL) DEV9shutdown();
|
||||||
if (USBshutdown != NULL) USBshutdown();
|
if (USBshutdown != NULL) USBshutdown();
|
||||||
|
@ -764,9 +845,9 @@ bool OpenCDVD(const char* pTitleFilename)
|
||||||
if (!OpenStatus.CDVD && !only_loading_elf)
|
if (!OpenStatus.CDVD && !only_loading_elf)
|
||||||
{
|
{
|
||||||
//First, we need the data.
|
//First, we need the data.
|
||||||
DoCDVDnewDiskCB(cdvdNewDiskCB);
|
CDVD.newDiskCB(cdvdNewDiskCB);
|
||||||
|
|
||||||
if (DoCDVDopen(pTitleFilename) != 0)
|
if (CDVD.open(pTitleFilename) != 0)
|
||||||
{
|
{
|
||||||
if (g_Startup.BootMode != BootMode_Elf)
|
if (g_Startup.BootMode != BootMode_Elf)
|
||||||
{
|
{
|
||||||
|
@ -904,6 +985,12 @@ int OpenPlugins(const char* pTitleFilename)
|
||||||
OpenStatus.name = false; \
|
OpenStatus.name = false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CLOSE_PLUGIN2( name ) \
|
||||||
|
if( OpenStatus.name ) { \
|
||||||
|
name.close(); \
|
||||||
|
OpenStatus.name = false; \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ClosePlugins( bool closegs )
|
void ClosePlugins( bool closegs )
|
||||||
{
|
{
|
||||||
|
@ -929,12 +1016,7 @@ void ClosePlugins( bool closegs )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//CLOSE_PLUGIN( CDVD );
|
CLOSE_PLUGIN2( CDVD );
|
||||||
if( OpenStatus.CDVD )
|
|
||||||
{
|
|
||||||
DoCDVDclose();
|
|
||||||
OpenStatus.CDVD = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CLOSE_PLUGIN( DEV9 );
|
CLOSE_PLUGIN( DEV9 );
|
||||||
CLOSE_PLUGIN( USB );
|
CLOSE_PLUGIN( USB );
|
||||||
|
|
|
@ -388,6 +388,10 @@ void SysEndExecution()
|
||||||
// use_bios - forces the game to boot through the PS2 bios, instead of bypassing it.
|
// use_bios - forces the game to boot through the PS2 bios, instead of bypassing it.
|
||||||
void SysPrepareExecution( const char* elf_file, bool use_bios )
|
void SysPrepareExecution( const char* elf_file, bool use_bios )
|
||||||
{
|
{
|
||||||
|
// solve a little crash
|
||||||
|
if(CDVD.init == NULL)
|
||||||
|
CDVD = CDVD_plugin;
|
||||||
|
|
||||||
if( !g_EmulationInProgress )
|
if( !g_EmulationInProgress )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -676,7 +676,7 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
string outstr;
|
string outstr;
|
||||||
if( Open_Iso_File_Proc( outstr ) )
|
if( Open_Iso_File_Proc( outstr ) )
|
||||||
{
|
{
|
||||||
loadFromISO = true;
|
CDVD = ISO;
|
||||||
|
|
||||||
strcpy(isoFileName,outstr.c_str());
|
strcpy(isoFileName,outstr.c_str());
|
||||||
|
|
||||||
|
@ -693,7 +693,7 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_FILE_RUNCD:
|
case ID_FILE_RUNCD:
|
||||||
loadFromISO = false;
|
CDVD = CDVD_plugin;
|
||||||
SysReset();
|
SysReset();
|
||||||
SysPrepareExecution( NULL );
|
SysPrepareExecution( NULL );
|
||||||
break;
|
break;
|
||||||
|
@ -738,7 +738,7 @@ LRESULT WINAPI MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_CONFIG_CDVDROM:
|
case ID_CONFIG_CDVDROM:
|
||||||
if (CDVDconfigure) CDVDconfigure();
|
if (CDVD.configure) CDVD.configure();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_CONFIG_DEV9:
|
case ID_CONFIG_DEV9:
|
||||||
|
|
Loading…
Reference in New Issue