mirror of https://github.com/PCSX2/pcsx2.git
cdvdgigaherz: Reformat with clang-format
This commit is contained in:
parent
60da39712c
commit
2967d5d3f1
|
@ -72,15 +72,18 @@ BOOL WINAPI DllMain(
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
char* CALLBACK PS2EgetLibName() {
|
||||
char *CALLBACK PS2EgetLibName()
|
||||
{
|
||||
return LibName;
|
||||
}
|
||||
|
||||
u32 CALLBACK PS2EgetLibType() {
|
||||
u32 CALLBACK PS2EgetLibType()
|
||||
{
|
||||
return PS2E_LT_CDVD;
|
||||
}
|
||||
|
||||
u32 CALLBACK PS2EgetLibVersion2(u32 type) {
|
||||
u32 CALLBACK PS2EgetLibVersion2(u32 type)
|
||||
{
|
||||
return (version << 16) | (revision << 8) | build;
|
||||
}
|
||||
|
||||
|
@ -88,7 +91,8 @@ u32 CALLBACK PS2EgetLibVersion2(u32 type) {
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Utility Functions //
|
||||
|
||||
void SysMessage(char *fmt, ...) {
|
||||
void SysMessage(char *fmt, ...)
|
||||
{
|
||||
va_list list;
|
||||
char tmp[512];
|
||||
|
||||
|
@ -112,7 +116,8 @@ void __inline lsn_to_msf(u8* minute, u8* second, u8* frame, u32 lsn)
|
|||
*minute = dec_to_bcd(lsn % 100);
|
||||
}
|
||||
|
||||
void __inline lba_to_msf(s32 lba, u8* m, u8* s, u8* f) {
|
||||
void __inline lba_to_msf(s32 lba, u8 *m, u8 *s, u8 *f)
|
||||
{
|
||||
lba += 150;
|
||||
*m = (u8)(lba / (60 * 75));
|
||||
*s = (u8)((lba / 75) % 60);
|
||||
|
@ -144,10 +149,10 @@ DWORD CALLBACK keepAliveThread(PVOID param)
|
|||
{
|
||||
printf(" * CDVD: KeepAlive thread started...\n");
|
||||
|
||||
while (cdvdKeepAlive_is_open)
|
||||
{
|
||||
while (cdvdKeepAlive_is_open) {
|
||||
// Sleep 30 seconds with thread abort check
|
||||
if (WaitForSingleObject(hNotify_keepAlive, 30000) != WAIT_TIMEOUT) break;
|
||||
if (WaitForSingleObject(hNotify_keepAlive, 30000) != WAIT_TIMEOUT)
|
||||
break;
|
||||
if (!cdvdKeepAlive_is_open) {
|
||||
break;
|
||||
}
|
||||
|
@ -186,8 +191,7 @@ void StopKeepAliveThread()
|
|||
{
|
||||
cdvdKeepAlive_is_open = false;
|
||||
PulseEvent(hNotify_keepAlive);
|
||||
if (WaitForSingleObject(hThread_keepAlive, 5000) == WAIT_TIMEOUT)
|
||||
{
|
||||
if (WaitForSingleObject(hThread_keepAlive, 5000) == WAIT_TIMEOUT) {
|
||||
TerminateThread(hThread_keepAlive, 0);
|
||||
}
|
||||
CloseHandle(hThread_keepAlive);
|
||||
|
@ -212,25 +216,21 @@ s32 CALLBACK CDVDopen(const char* pTitleFilename)
|
|||
{
|
||||
ReadSettings();
|
||||
|
||||
if(source_drive=='-')
|
||||
{
|
||||
if (source_drive == '-') {
|
||||
// MSDN : Trailing backslash is required to ensure consistent behavior across
|
||||
// various versions of Windows and storage types.
|
||||
char temp[] = "A:\\";
|
||||
|
||||
for(char d='A';d<='Z';d++)
|
||||
{
|
||||
for (char d = 'A'; d <= 'Z'; d++) {
|
||||
temp[0] = d;
|
||||
if(GetDriveType(temp)==DRIVE_CDROM)
|
||||
{
|
||||
if (GetDriveType(temp) == DRIVE_CDROM) {
|
||||
source_drive = d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(source_drive=='@')
|
||||
{
|
||||
if (source_drive == '@') {
|
||||
curDiskType = CDVD_TYPE_NODISC;
|
||||
return 0;
|
||||
}
|
||||
|
@ -242,8 +242,7 @@ s32 CALLBACK CDVDopen(const char* pTitleFilename)
|
|||
// open device file
|
||||
src = new IOCtlSrc(csrc);
|
||||
|
||||
if(!src->IsOK())
|
||||
{
|
||||
if (!src->IsOK()) {
|
||||
printf(" * CDVD: Error opening source.\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -271,8 +270,7 @@ void CALLBACK CDVDshutdown()
|
|||
|
||||
s32 CALLBACK CDVDgetDualInfo(s32 *dualType, u32 *_layer1start)
|
||||
{
|
||||
switch(src->GetMediaType())
|
||||
{
|
||||
switch (src->GetMediaType()) {
|
||||
case 1:
|
||||
*dualType = 1;
|
||||
*_layer1start = src->GetLayerBreakAddress() + 1;
|
||||
|
@ -302,15 +300,14 @@ s32 CALLBACK CDVDreadTrack(u32 lsn, int mode)
|
|||
csector = lsn;
|
||||
cmode = mode;
|
||||
|
||||
if(weAreInNewDiskCB)
|
||||
{
|
||||
if (weAreInNewDiskCB) {
|
||||
int ret = cdvdDirectReadSector(lsn, mode, directReadSectorBuffer);
|
||||
if(ret==0) lastReadInNewDiskCB=1;
|
||||
if (ret == 0)
|
||||
lastReadInNewDiskCB = 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if(lsn>tracks[0].length) // track 0 is total disc.
|
||||
{
|
||||
if (lsn > tracks[0].length) { // track 0 is total disc.
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -320,8 +317,7 @@ s32 CALLBACK CDVDreadTrack(u32 lsn, int mode)
|
|||
// return can be NULL (for async modes)
|
||||
u8 *CALLBACK CDVDgetBuffer()
|
||||
{
|
||||
if(lastReadInNewDiskCB)
|
||||
{
|
||||
if (lastReadInNewDiskCB) {
|
||||
lastReadInNewDiskCB = 0;
|
||||
return (u8 *)directReadSectorBuffer;
|
||||
}
|
||||
|
@ -335,15 +331,19 @@ u8* CALLBACK CDVDgetBuffer()
|
|||
int CALLBACK CDVDgetBuffer2(u8 *dest)
|
||||
{
|
||||
int csize = 2352;
|
||||
switch(cmode)
|
||||
{
|
||||
case CDVD_MODE_2048: csize = 2048; break;
|
||||
case CDVD_MODE_2328: csize = 2328; break;
|
||||
case CDVD_MODE_2340: csize = 2340; break;
|
||||
switch (cmode) {
|
||||
case CDVD_MODE_2048:
|
||||
csize = 2048;
|
||||
break;
|
||||
case CDVD_MODE_2328:
|
||||
csize = 2328;
|
||||
break;
|
||||
case CDVD_MODE_2340:
|
||||
csize = 2340;
|
||||
break;
|
||||
}
|
||||
|
||||
if(lastReadInNewDiskCB)
|
||||
{
|
||||
if (lastReadInNewDiskCB) {
|
||||
lastReadInNewDiskCB = 0;
|
||||
|
||||
memcpy(dest, directReadSectorBuffer, csize);
|
||||
|
@ -368,8 +368,7 @@ s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq)
|
|||
lsn_to_msf(&subq->discM, &subq->discS, &subq->discF, lsn + 150);
|
||||
|
||||
i = strack;
|
||||
while(i<=etrack)
|
||||
{
|
||||
while (i <= etrack) {
|
||||
if (lsn <= tracks[i].length)
|
||||
break;
|
||||
lsn -= tracks[i].length;
|
||||
|
@ -398,15 +397,16 @@ s32 CALLBACK CDVDgetTN(cdvdTN *Buffer)
|
|||
|
||||
s32 CALLBACK CDVDgetTD(u8 Track, cdvdTD *Buffer)
|
||||
{
|
||||
if(Track==0)
|
||||
{
|
||||
if (Track == 0) {
|
||||
Buffer->lsn = tracks[0].length;
|
||||
Buffer->type = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(Track<strack) return -1;
|
||||
if(Track>etrack) return -1;
|
||||
if (Track < strack)
|
||||
return -1;
|
||||
if (Track > etrack)
|
||||
return -1;
|
||||
|
||||
Buffer->lsn = tracks[Track].start_lba;
|
||||
Buffer->type = tracks[Track].type;
|
||||
|
@ -421,8 +421,7 @@ s32 CALLBACK CDVDgetTOC(u8* tocBuff)
|
|||
if (curDiskType == CDVD_TYPE_NODISC)
|
||||
return -1;
|
||||
|
||||
if (curDiskType == CDVD_TYPE_DETCTDVDS || curDiskType == CDVD_TYPE_DETCTDVDD)
|
||||
{
|
||||
if (curDiskType == CDVD_TYPE_DETCTDVDS || curDiskType == CDVD_TYPE_DETCTDVDD) {
|
||||
memset(tocBuff, 0, 2048);
|
||||
|
||||
s32 mt = src->GetMediaType();
|
||||
|
@ -430,8 +429,7 @@ s32 CALLBACK CDVDgetTOC(u8* tocBuff)
|
|||
if (mt < 0)
|
||||
return -1;
|
||||
|
||||
if(mt==0) //single layer
|
||||
{
|
||||
if (mt == 0) { //single layer
|
||||
// fake it
|
||||
tocBuff[0] = 0x04;
|
||||
tocBuff[1] = 0x02;
|
||||
|
@ -444,9 +442,7 @@ s32 CALLBACK CDVDgetTOC(u8* tocBuff)
|
|||
tocBuff[17] = 0x03;
|
||||
tocBuff[18] = 0x00;
|
||||
tocBuff[19] = 0x00;
|
||||
}
|
||||
else if(mt==1) //PTP
|
||||
{
|
||||
} else if (mt == 1) { //PTP
|
||||
u32 layer1start = src->GetLayerBreakAddress() + 0x30000;
|
||||
|
||||
// dual sided
|
||||
|
@ -468,9 +464,7 @@ s32 CALLBACK CDVDgetTOC(u8* tocBuff)
|
|||
tocBuff[21] = (layer1start >> 16) & 0xff;
|
||||
tocBuff[22] = (layer1start >> 8) & 0xff;
|
||||
tocBuff[23] = (layer1start >> 0) & 0xff;
|
||||
}
|
||||
else //OTP
|
||||
{
|
||||
} else { //OTP
|
||||
u32 layer1start = src->GetLayerBreakAddress() + 0x30000;
|
||||
|
||||
// dual sided
|
||||
|
@ -493,9 +487,7 @@ s32 CALLBACK CDVDgetTOC(u8* tocBuff)
|
|||
tocBuff[26] = (layer1start >> 8) & 0xff;
|
||||
tocBuff[27] = (layer1start >> 0) & 0xff;
|
||||
}
|
||||
}
|
||||
else if (curDiskType == CDVD_TYPE_DETCTCD)
|
||||
{
|
||||
} else if (curDiskType == CDVD_TYPE_DETCTCD) {
|
||||
// cd toc
|
||||
// (could be replaced by 1 command that reads the full toc)
|
||||
u8 min, sec, frm, i;
|
||||
|
@ -503,8 +495,12 @@ s32 CALLBACK CDVDgetTOC(u8* tocBuff)
|
|||
cdvdTN diskInfo;
|
||||
cdvdTD trackInfo;
|
||||
memset(tocBuff, 0, 1024);
|
||||
if (CDVDgetTN(&diskInfo) == -1) { diskInfo.etrack = 0;diskInfo.strack = 1; }
|
||||
if (CDVDgetTD(0, &trackInfo) == -1) trackInfo.lsn = 0;
|
||||
if (CDVDgetTN(&diskInfo) == -1) {
|
||||
diskInfo.etrack = 0;
|
||||
diskInfo.strack = 1;
|
||||
}
|
||||
if (CDVDgetTD(0, &trackInfo) == -1)
|
||||
trackInfo.lsn = 0;
|
||||
|
||||
tocBuff[0] = 0x41;
|
||||
tocBuff[1] = 0x00;
|
||||
|
@ -528,8 +524,7 @@ s32 CALLBACK CDVDgetTOC(u8* tocBuff)
|
|||
|
||||
fprintf(stderr, "Track 0: %d mins %d secs %d frames\n", min, sec, frm);
|
||||
|
||||
for (i=diskInfo.strack; i<=diskInfo.etrack; i++)
|
||||
{
|
||||
for (i = diskInfo.strack; i <= diskInfo.etrack; i++) {
|
||||
err = CDVDgetTD(i, &trackInfo);
|
||||
lba_to_msf(trackInfo.lsn, &min, &sec, &frm);
|
||||
tocBuff[i * 10 + 30] = trackInfo.type;
|
||||
|
@ -539,8 +534,7 @@ s32 CALLBACK CDVDgetTOC(u8* tocBuff)
|
|||
tocBuff[i * 10 + 39] = itob(frm);
|
||||
fprintf(stderr, "Track %d: %d mins %d secs %d frames\n", i, min, sec, frm);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
@ -578,10 +572,12 @@ void CALLBACK CDVDconfigure()
|
|||
configure();
|
||||
}
|
||||
|
||||
void CALLBACK CDVDabout() {
|
||||
void CALLBACK CDVDabout()
|
||||
{
|
||||
SysMessage("%s %d.%d", LibName, revision, build);
|
||||
}
|
||||
|
||||
s32 CALLBACK CDVDtest() {
|
||||
s32 CALLBACK CDVDtest()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,8 @@ extern track tracks[100];
|
|||
extern int curDiskType;
|
||||
extern int curTrayStatus;
|
||||
|
||||
typedef struct _toc_entry {
|
||||
typedef struct _toc_entry
|
||||
{
|
||||
UCHAR SessionNumber;
|
||||
UCHAR Control : 4;
|
||||
UCHAR Adr : 4;
|
||||
|
@ -62,6 +63,7 @@ extern toc_data cdtoc;
|
|||
class Source //abstract class as base for source modules
|
||||
{
|
||||
Source(Source &);
|
||||
|
||||
public:
|
||||
Source(){};
|
||||
|
||||
|
|
|
@ -29,8 +29,7 @@ CRITICAL_SECTION CacheMutex;
|
|||
|
||||
DWORD pidThread = 0;
|
||||
|
||||
enum loadStatus
|
||||
{
|
||||
enum loadStatus {
|
||||
LoadIdle,
|
||||
LoadPending,
|
||||
LoadSuccess,
|
||||
|
@ -59,8 +58,7 @@ u32 cdvdSectorHash(int lsn, int mode)
|
|||
int i = 32;
|
||||
int m = CacheSize - 1;
|
||||
|
||||
while(i>=0)
|
||||
{
|
||||
while (i >= 0) {
|
||||
t ^= lsn & m;
|
||||
lsn >>= CACHE_SIZE;
|
||||
i -= CACHE_SIZE;
|
||||
|
@ -86,8 +84,7 @@ bool cdvdCacheFetch(int lsn, int mode, char* data)
|
|||
u32 entry = cdvdSectorHash(lsn, mode);
|
||||
|
||||
if ((Cache[entry].lsn == lsn) &&
|
||||
(Cache[entry].mode==mode))
|
||||
{
|
||||
(Cache[entry].mode == mode)) {
|
||||
memcpy(data, Cache[entry].data, 2352 * 16);
|
||||
LeaveCriticalSection(&CacheMutex);
|
||||
return true;
|
||||
|
@ -100,8 +97,7 @@ bool cdvdCacheFetch(int lsn, int mode, char* data)
|
|||
void cdvdCacheReset()
|
||||
{
|
||||
EnterCriticalSection(&CacheMutex);
|
||||
for(int i=0;i<CacheSize;i++)
|
||||
{
|
||||
for (int i = 0; i < CacheSize; i++) {
|
||||
Cache[i].lsn = -1;
|
||||
Cache[i].mode = -1;
|
||||
}
|
||||
|
@ -119,37 +115,28 @@ bool cdvdUpdateDiscStatus()
|
|||
{
|
||||
int change = src->DiscChanged();
|
||||
|
||||
if(change==-1) //error getting status (no disc in drive?)
|
||||
{
|
||||
if (change == -1) { //error getting status (no disc in drive?)
|
||||
//try to recreate the device
|
||||
src->Reopen();
|
||||
|
||||
if(src->IsOK())
|
||||
{
|
||||
if (src->IsOK()) {
|
||||
change = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
curDiskType = CDVD_TYPE_NODISC;
|
||||
curTrayStatus = CDVD_TRAY_OPEN;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(change==1)
|
||||
{
|
||||
if(!disc_has_changed)
|
||||
{
|
||||
if (change == 1) {
|
||||
if (!disc_has_changed) {
|
||||
disc_has_changed = true;
|
||||
curDiskType = CDVD_TYPE_NODISC;
|
||||
curTrayStatus = CDVD_TRAY_OPEN;
|
||||
cdvdCallNewDiscCB();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(disc_has_changed)
|
||||
{
|
||||
} else {
|
||||
if (disc_has_changed) {
|
||||
curDiskType = CDVD_TYPE_NODISC;
|
||||
curTrayStatus = CDVD_TRAY_CLOSE;
|
||||
|
||||
|
@ -168,12 +155,11 @@ DWORD CALLBACK cdvdThread(PVOID param)
|
|||
{
|
||||
printf(" * CDVD: IO thread started...\n");
|
||||
|
||||
while(cdvd_is_open)
|
||||
{
|
||||
if(!src) break;
|
||||
while (cdvd_is_open) {
|
||||
if (!src)
|
||||
break;
|
||||
|
||||
if(cdvdUpdateDiscStatus())
|
||||
{
|
||||
if (cdvdUpdateDiscStatus()) {
|
||||
// Need to sleep some to avoid an aggressive spin that sucks the cpu dry.
|
||||
Sleep(10);
|
||||
continue;
|
||||
|
@ -185,25 +171,22 @@ DWORD CALLBACK cdvdThread(PVOID param)
|
|||
WaitForSingleObject(hNotify, 250);
|
||||
|
||||
// check again to make sure we're not done here...
|
||||
if(!cdvd_is_open) break;
|
||||
if (!cdvd_is_open)
|
||||
break;
|
||||
|
||||
static SectorInfo info;
|
||||
|
||||
bool handlingRequest = false;
|
||||
|
||||
if(threadRequestPending)
|
||||
{
|
||||
if (threadRequestPending) {
|
||||
info = threadRequestInfo;
|
||||
handlingRequest = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
info.lsn = prefetch_last_lba;
|
||||
info.mode = prefetch_last_mode;
|
||||
}
|
||||
|
||||
if(threadRequestPending || prefetch_left)
|
||||
{
|
||||
if (threadRequestPending || prefetch_left) {
|
||||
s32 ret = -1;
|
||||
s32 tries = 5;
|
||||
|
||||
|
@ -211,7 +194,8 @@ DWORD CALLBACK cdvdThread(PVOID param)
|
|||
|
||||
s32 left = tracks[0].length - info.lsn;
|
||||
|
||||
if(left<count) count=left;
|
||||
if (left < count)
|
||||
count = left;
|
||||
|
||||
do {
|
||||
if (info.mode == CDVD_MODE_2048)
|
||||
|
@ -228,8 +212,7 @@ DWORD CALLBACK cdvdThread(PVOID param)
|
|||
|
||||
cdvdCacheUpdate(info.lsn, info.mode, info.data);
|
||||
|
||||
if(handlingRequest)
|
||||
{
|
||||
if (handlingRequest) {
|
||||
threadRequestInfo = info;
|
||||
|
||||
handlingRequest = false;
|
||||
|
@ -240,9 +223,7 @@ DWORD CALLBACK cdvdThread(PVOID param)
|
|||
prefetch_last_mode = info.mode;
|
||||
|
||||
prefetch_left = prefetch_max_blocks;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
prefetch_last_lba += 16;
|
||||
prefetch_left--;
|
||||
}
|
||||
|
@ -281,8 +262,7 @@ void cdvdStopThread()
|
|||
{
|
||||
cdvd_is_open = false;
|
||||
PulseEvent(hNotify);
|
||||
if(WaitForSingleObject(hThread,4000)==WAIT_TIMEOUT)
|
||||
{
|
||||
if (WaitForSingleObject(hThread, 4000) == WAIT_TIMEOUT) {
|
||||
TerminateThread(hThread, 0);
|
||||
}
|
||||
CloseHandle(hThread);
|
||||
|
@ -302,8 +282,7 @@ s32 cdvdRequestSector(u32 sector, s32 mode)
|
|||
threadRequestInfo.lsn = sector;
|
||||
threadRequestInfo.mode = mode;
|
||||
threadRequestPending = false;
|
||||
if(cdvdCacheFetch(sector,mode,threadRequestInfo.data))
|
||||
{
|
||||
if (cdvdCacheFetch(sector, mode, threadRequestInfo.data)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -321,15 +300,13 @@ s32 cdvdRequestComplete()
|
|||
|
||||
s8 *cdvdGetSector(s32 sector, s32 mode)
|
||||
{
|
||||
while(threadRequestPending)
|
||||
{
|
||||
while (threadRequestPending) {
|
||||
WaitForSingleObject(hRequestComplete, 10);
|
||||
}
|
||||
|
||||
s32 offset;
|
||||
|
||||
if(mode==CDVD_MODE_2048)
|
||||
{
|
||||
if (mode == CDVD_MODE_2048) {
|
||||
offset = 2048 * (sector - threadRequestInfo.lsn);
|
||||
return threadRequestInfo.data + offset;
|
||||
}
|
||||
|
@ -337,8 +314,7 @@ s8* cdvdGetSector(s32 sector, s32 mode)
|
|||
offset = 2352 * (sector - threadRequestInfo.lsn);
|
||||
s8 *data = threadRequestInfo.data + offset;
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case CDVD_MODE_2328:
|
||||
return data + 24;
|
||||
case CDVD_MODE_2340:
|
||||
|
@ -357,8 +333,7 @@ s32 cdvdDirectReadSector(s32 first, s32 mode, char *buffer)
|
|||
s32 sector = first & (~15); //align to 16-sector block
|
||||
|
||||
EnterCriticalSection(&CacheMutex);
|
||||
if(!cdvdCacheFetch(sector,mode,data))
|
||||
{
|
||||
if (!cdvdCacheFetch(sector, mode, data)) {
|
||||
s32 ret = -1;
|
||||
s32 tries = 5;
|
||||
|
||||
|
@ -366,7 +341,8 @@ s32 cdvdDirectReadSector(s32 first, s32 mode, char *buffer)
|
|||
|
||||
s32 left = tracks[0].length - sector;
|
||||
|
||||
if(left<count) count=left;
|
||||
if (left < count)
|
||||
count = left;
|
||||
|
||||
do {
|
||||
if (mode == CDVD_MODE_2048)
|
||||
|
@ -387,8 +363,7 @@ s32 cdvdDirectReadSector(s32 first, s32 mode, char *buffer)
|
|||
|
||||
s32 offset;
|
||||
|
||||
if(mode==CDVD_MODE_2048)
|
||||
{
|
||||
if (mode == CDVD_MODE_2048) {
|
||||
offset = 2048 * (first - sector);
|
||||
memcpy(buffer, data + offset, 2048);
|
||||
return 0;
|
||||
|
@ -397,8 +372,7 @@ s32 cdvdDirectReadSector(s32 first, s32 mode, char *buffer)
|
|||
offset = 2352 * (first - sector);
|
||||
s8 *bfr = data + offset;
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case CDVD_MODE_2328:
|
||||
memcpy(buffer, bfr + 24, 2328);
|
||||
return 0;
|
||||
|
@ -426,27 +400,34 @@ s32 cdvdRefreshData()
|
|||
//read TOC from device
|
||||
cdvdParseTOC();
|
||||
|
||||
if((etrack==0)||(strack>etrack))
|
||||
{
|
||||
if ((etrack == 0) || (strack > etrack)) {
|
||||
curDiskType = CDVD_TYPE_NODISC;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
s32 mt = cdvdGetMediaType();
|
||||
|
||||
if(mt<0) curDiskType = CDVD_TYPE_DETCTCD;
|
||||
else if(mt == 0) curDiskType = CDVD_TYPE_DETCTDVDS;
|
||||
else curDiskType = CDVD_TYPE_DETCTDVDD;
|
||||
if (mt < 0)
|
||||
curDiskType = CDVD_TYPE_DETCTCD;
|
||||
else if (mt == 0)
|
||||
curDiskType = CDVD_TYPE_DETCTDVDS;
|
||||
else
|
||||
curDiskType = CDVD_TYPE_DETCTDVDD;
|
||||
}
|
||||
|
||||
curTrayStatus = CDVD_TRAY_CLOSE;
|
||||
|
||||
switch(curDiskType)
|
||||
{
|
||||
case CDVD_TYPE_DETCTDVDD: diskTypeName="Double-Layer DVD"; break;
|
||||
case CDVD_TYPE_DETCTDVDS: diskTypeName="Single-Layer DVD"; break;
|
||||
case CDVD_TYPE_DETCTCD: diskTypeName="CD-ROM"; break;
|
||||
case CDVD_TYPE_NODISC: diskTypeName="No Disc"; break;
|
||||
switch (curDiskType) {
|
||||
case CDVD_TYPE_DETCTDVDD:
|
||||
diskTypeName = "Double-Layer DVD";
|
||||
break;
|
||||
case CDVD_TYPE_DETCTDVDS:
|
||||
diskTypeName = "Single-Layer DVD";
|
||||
break;
|
||||
case CDVD_TYPE_DETCTCD:
|
||||
diskTypeName = "CD-ROM";
|
||||
break;
|
||||
case CDVD_TYPE_NODISC:
|
||||
diskTypeName = "No Disc";
|
||||
break;
|
||||
}
|
||||
|
||||
printf(" * CDVD: Disk Type: %s\n", diskTypeName);
|
||||
|
|
|
@ -28,8 +28,7 @@ s32 cdvdParseTOC()
|
|||
tracks[0].type = 0;
|
||||
tracks[1].start_lba = 0;
|
||||
|
||||
if (len <= 0)
|
||||
{
|
||||
if (len <= 0) {
|
||||
curDiskType = CDVD_TYPE_NODISC;
|
||||
tracks[0].length = 0;
|
||||
strack = 1;
|
||||
|
@ -39,20 +38,16 @@ s32 cdvdParseTOC()
|
|||
|
||||
s32 mt = src->GetMediaType();
|
||||
|
||||
if (mt >= 0)
|
||||
{
|
||||
if (mt >= 0) {
|
||||
tracks[1].length = tracks[0].length;
|
||||
tracks[1].type = 0;
|
||||
|
||||
strack = 1;
|
||||
etrack = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
u8 min, sec, frm;
|
||||
|
||||
if(src->ReadTOC((char*)&cdtoc,sizeof(cdtoc))<0)
|
||||
{
|
||||
if (src->ReadTOC((char *)&cdtoc, sizeof(cdtoc)) < 0) {
|
||||
/*
|
||||
printf(" * CDVD: WARNING ReadTOC() failed, trying to use MCI instead...\n");
|
||||
delete src;
|
||||
|
@ -68,25 +63,20 @@ s32 cdvdParseTOC()
|
|||
|
||||
int length = (cdtoc.Length[0] << 8) | cdtoc.Length[1];
|
||||
int descriptors = length / sizeof(cdtoc.Descriptors[0]);
|
||||
for(int i=0;i<descriptors;i++)
|
||||
{
|
||||
switch(cdtoc.Descriptors[i].Point)
|
||||
{
|
||||
for (int i = 0; i < descriptors; i++) {
|
||||
switch (cdtoc.Descriptors[i].Point) {
|
||||
case 0xa0:
|
||||
if(cdtoc.Descriptors[i].SessionNumber==cdtoc.FirstCompleteSession)
|
||||
{
|
||||
if (cdtoc.Descriptors[i].SessionNumber == cdtoc.FirstCompleteSession) {
|
||||
strack = cdtoc.Descriptors[i].Msf[0];
|
||||
}
|
||||
break;
|
||||
case 0xa1:
|
||||
if(cdtoc.Descriptors[i].SessionNumber==cdtoc.LastCompleteSession)
|
||||
{
|
||||
if (cdtoc.Descriptors[i].SessionNumber == cdtoc.LastCompleteSession) {
|
||||
etrack = cdtoc.Descriptors[i].Msf[0];
|
||||
}
|
||||
break;
|
||||
case 0xa2: // session size
|
||||
if(cdtoc.Descriptors[i].SessionNumber==cdtoc.LastCompleteSession)
|
||||
{
|
||||
if (cdtoc.Descriptors[i].SessionNumber == cdtoc.LastCompleteSession) {
|
||||
min = cdtoc.Descriptors[i].Msf[0];
|
||||
sec = cdtoc.Descriptors[i].Msf[1];
|
||||
frm = cdtoc.Descriptors[i].Msf[2];
|
||||
|
@ -104,8 +94,7 @@ s32 cdvdParseTOC()
|
|||
case 0xc0:
|
||||
break;
|
||||
default:
|
||||
if((cdtoc.Descriptors[i].Point<100)&&(cdtoc.Descriptors[i].Point>0))
|
||||
{
|
||||
if ((cdtoc.Descriptors[i].Point < 100) && (cdtoc.Descriptors[i].Point > 0)) {
|
||||
int tn = cdtoc.Descriptors[i].Point;
|
||||
|
||||
min = cdtoc.Descriptors[i].Msf[0];
|
||||
|
@ -116,23 +105,16 @@ s32 cdvdParseTOC()
|
|||
if (tn > 1)
|
||||
tracks[tn - 1].length = tracks[tn].start_lba - tracks[tn - 1].start_lba;
|
||||
|
||||
if((cdtoc.Descriptors[i].Control&4)==0)
|
||||
{
|
||||
if ((cdtoc.Descriptors[i].Control & 4) == 0) {
|
||||
tracks[tn].type = CDVD_AUDIO_TRACK;
|
||||
}
|
||||
else if((cdtoc.Descriptors[i].Control&0xE)==4)
|
||||
{
|
||||
} else if ((cdtoc.Descriptors[i].Control & 0xE) == 4) {
|
||||
tracks[tn].type = CDVD_MODE1_TRACK;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
tracks[tn].type = CDVD_MODE1_TRACK;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Track %d: %d mins %d secs %d frames\n", tn, min, sec, frm);
|
||||
}
|
||||
else if(cdtoc.Descriptors[i].Point>0)
|
||||
{
|
||||
} else if (cdtoc.Descriptors[i].Point > 0) {
|
||||
printf("Found code 0x%02x\n", cdtoc.Descriptors[i].Point);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -29,8 +29,7 @@
|
|||
|
||||
s32 IOCtlSrc::Reopen()
|
||||
{
|
||||
if(device!=INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if (device != INVALID_HANDLE_VALUE) {
|
||||
DWORD size;
|
||||
DeviceIoControl(device, IOCTL_DVD_END_SESSION, &sessID, sizeof(DVD_SESSION_ID), NULL, 0, &size, NULL);
|
||||
CloseHandle(device);
|
||||
|
@ -44,8 +43,7 @@ s32 IOCtlSrc::Reopen()
|
|||
// SPTI only works if the device is opened with GENERIC_WRITE access.
|
||||
m_can_use_spti = true;
|
||||
device = CreateFile(fName, GENERIC_READ | GENERIC_WRITE | FILE_READ_ATTRIBUTES, share, NULL, OPEN_EXISTING, flags, 0);
|
||||
if(device==INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if (device == INVALID_HANDLE_VALUE) {
|
||||
device = CreateFile(fName, GENERIC_READ | FILE_READ_ATTRIBUTES, share, NULL, OPEN_EXISTING, flags, 0);
|
||||
if (device == INVALID_HANDLE_VALUE)
|
||||
return -1;
|
||||
|
@ -79,8 +77,7 @@ IOCtlSrc::IOCtlSrc(const char* fileName)
|
|||
|
||||
IOCtlSrc::~IOCtlSrc()
|
||||
{
|
||||
if(OpenOK)
|
||||
{
|
||||
if (OpenOK) {
|
||||
SetSpindleSpeed(true);
|
||||
DWORD size;
|
||||
DeviceIoControl(device, IOCTL_DVD_END_SESSION, &sessID, sizeof(DVD_SESSION_ID), NULL, 0, &size, NULL);
|
||||
|
@ -114,16 +111,14 @@ s32 IOCtlSrc::GetSectorCount()
|
|||
if (discSizeCached)
|
||||
return discSize;
|
||||
|
||||
if(GetFileSizeEx(device,&li))
|
||||
{
|
||||
if (GetFileSizeEx(device, &li)) {
|
||||
discSizeCached = true;
|
||||
discSize = (s32)(li.QuadPart / 2048);
|
||||
return discSize;
|
||||
}
|
||||
|
||||
GET_LENGTH_INFORMATION info;
|
||||
if(DeviceIoControl(device, IOCTL_DISK_GET_LENGTH_INFO, NULL, 0, &info, sizeof(info), &size, NULL))
|
||||
{
|
||||
if (DeviceIoControl(device, IOCTL_DISK_GET_LENGTH_INFO, NULL, 0, &info, sizeof(info), &size, NULL)) {
|
||||
discSizeCached = true;
|
||||
discSize = (s32)(info.Length.QuadPart / 2048);
|
||||
return discSize;
|
||||
|
@ -136,14 +131,10 @@ s32 IOCtlSrc::GetSectorCount()
|
|||
|
||||
CDROM_TOC_FULL_TOC_DATA *ftd = (CDROM_TOC_FULL_TOC_DATA *)sectorbuffer;
|
||||
|
||||
if(DeviceIoControl(device,IOCTL_CDROM_READ_TOC_EX,&tocrq,sizeof(tocrq),ftd, 2048, &size, NULL))
|
||||
{
|
||||
for(int i=0;i<101;i++)
|
||||
{
|
||||
if(ftd->Descriptors[i].Point==0xa2)
|
||||
{
|
||||
if(ftd->Descriptors[i].SessionNumber==ftd->LastCompleteSession)
|
||||
{
|
||||
if (DeviceIoControl(device, IOCTL_CDROM_READ_TOC_EX, &tocrq, sizeof(tocrq), ftd, 2048, &size, NULL)) {
|
||||
for (int i = 0; i < 101; i++) {
|
||||
if (ftd->Descriptors[i].Point == 0xa2) {
|
||||
if (ftd->Descriptors[i].SessionNumber == ftd->LastCompleteSession) {
|
||||
int min = ftd->Descriptors[i].Msf[0];
|
||||
int sec = ftd->Descriptors[i].Msf[1];
|
||||
int frm = ftd->Descriptors[i].Msf[2];
|
||||
|
@ -160,21 +151,15 @@ s32 IOCtlSrc::GetSectorCount()
|
|||
dvdrs.Format = DvdPhysicalDescriptor;
|
||||
dvdrs.SessionId = sessID;
|
||||
dvdrs.LayerNumber = 0;
|
||||
if(DeviceIoControl(device,IOCTL_DVD_READ_STRUCTURE,&dvdrs,sizeof(dvdrs),&dld, sizeof(dld), &size, NULL)!=0)
|
||||
{
|
||||
if (DeviceIoControl(device, IOCTL_DVD_READ_STRUCTURE, &dvdrs, sizeof(dvdrs), &dld, sizeof(dld), &size, NULL) != 0) {
|
||||
s32 sectors1 = _byteswap_ulong(dld.ld.EndDataSector) - _byteswap_ulong(dld.ld.StartingDataSector) + 1;
|
||||
if (dld.ld.NumberOfLayers == 1) // PTP, OTP
|
||||
{
|
||||
if (dld.ld.TrackPath == 0) // PTP
|
||||
{
|
||||
if (dld.ld.NumberOfLayers == 1) { // PTP, OTP
|
||||
if (dld.ld.TrackPath == 0) { // PTP
|
||||
dvdrs.LayerNumber = 1;
|
||||
if (DeviceIoControl(device, IOCTL_DVD_READ_STRUCTURE, &dvdrs, sizeof(dvdrs), &dld, sizeof(dld), &size, nullptr) != 0)
|
||||
{
|
||||
if (DeviceIoControl(device, IOCTL_DVD_READ_STRUCTURE, &dvdrs, sizeof(dvdrs), &dld, sizeof(dld), &size, nullptr) != 0) {
|
||||
sectors1 += _byteswap_ulong(dld.ld.EndDataSector) - _byteswap_ulong(dld.ld.StartingDataSector) + 1;
|
||||
}
|
||||
}
|
||||
else // OTP
|
||||
{
|
||||
} else { // OTP
|
||||
// sectors = end_sector - (~end_sector_l0 & 0xFFFFFF) + end_sector_l0 - start_sector
|
||||
dld.ld.EndLayerZeroSector = _byteswap_ulong(dld.ld.EndLayerZeroSector);
|
||||
sectors1 += dld.ld.EndLayerZeroSector - (~dld.ld.EndLayerZeroSector & 0x00FFFFFF) + 1;
|
||||
|
@ -203,18 +188,12 @@ s32 IOCtlSrc::GetLayerBreakAddress()
|
|||
dvdrs.Format = DvdPhysicalDescriptor;
|
||||
dvdrs.SessionId = sessID;
|
||||
dvdrs.LayerNumber = 0;
|
||||
if (DeviceIoControl(device, IOCTL_DVD_READ_STRUCTURE, &dvdrs, sizeof(dvdrs), &dld, sizeof(dld), &size, nullptr))
|
||||
{
|
||||
if (dld.ld.NumberOfLayers == 0) // Single layer
|
||||
{
|
||||
if (DeviceIoControl(device, IOCTL_DVD_READ_STRUCTURE, &dvdrs, sizeof(dvdrs), &dld, sizeof(dld), &size, nullptr)) {
|
||||
if (dld.ld.NumberOfLayers == 0) { // Single layer
|
||||
layerBreak = 0;
|
||||
}
|
||||
else if (dld.ld.TrackPath == 0) // PTP
|
||||
{
|
||||
} else if (dld.ld.TrackPath == 0) { // PTP
|
||||
layerBreak = _byteswap_ulong(dld.ld.EndDataSector) - _byteswap_ulong(dld.ld.StartingDataSector);
|
||||
}
|
||||
else // OTP
|
||||
{
|
||||
} else { // OTP
|
||||
layerBreak = _byteswap_ulong(dld.ld.EndLayerZeroSector) - _byteswap_ulong(dld.ld.StartingDataSector);
|
||||
}
|
||||
|
||||
|
@ -226,13 +205,16 @@ s32 IOCtlSrc::GetLayerBreakAddress()
|
|||
return 0;
|
||||
}
|
||||
|
||||
void IOCtlSrc::SetSpindleSpeed(bool restore_defaults) {
|
||||
void IOCtlSrc::SetSpindleSpeed(bool restore_defaults)
|
||||
{
|
||||
|
||||
DWORD dontcare;
|
||||
int speed = 0;
|
||||
|
||||
if (GetMediaType() < 0 ) speed = 4800; // CD-ROM to ~32x (PS2 has 24x (3600 KB/s))
|
||||
else speed = 11080; // DVD-ROM to ~8x (PS2 has 4x (5540 KB/s))
|
||||
if (GetMediaType() < 0)
|
||||
speed = 4800; // CD-ROM to ~32x (PS2 has 24x (3600 KB/s))
|
||||
else
|
||||
speed = 11080; // DVD-ROM to ~8x (PS2 has 4x (5540 KB/s))
|
||||
|
||||
if (!restore_defaults) {
|
||||
CDROM_SET_SPEED s;
|
||||
|
@ -249,13 +231,10 @@ void IOCtlSrc::SetSpindleSpeed(bool restore_defaults) {
|
|||
(LPOVERLAPPED)NULL)) //synchronous I/O == 0)
|
||||
{
|
||||
printf(" * CDVD: setSpindleSpeed success (%dKB/s)\n", speed);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
printf(" * CDVD: setSpindleSpeed failed! \n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
CDROM_SET_SPEED s;
|
||||
s.RequestType = CdromSetSpeed;
|
||||
s.RotationControl = CdromDefaultRotation;
|
||||
|
@ -285,8 +264,7 @@ s32 IOCtlSrc::GetMediaType()
|
|||
|
||||
CDROM_TOC_FULL_TOC_DATA *ftd = (CDROM_TOC_FULL_TOC_DATA *)sectorbuffer;
|
||||
|
||||
if(DeviceIoControl(device,IOCTL_CDROM_READ_TOC_EX,&tocrq,sizeof(tocrq),ftd, 2048, &size, NULL))
|
||||
{
|
||||
if (DeviceIoControl(device, IOCTL_CDROM_READ_TOC_EX, &tocrq, sizeof(tocrq), ftd, 2048, &size, NULL)) {
|
||||
mediaTypeCached = true;
|
||||
mediaType = -1;
|
||||
return mediaType;
|
||||
|
@ -296,18 +274,12 @@ s32 IOCtlSrc::GetMediaType()
|
|||
dvdrs.Format = DvdPhysicalDescriptor;
|
||||
dvdrs.SessionId = sessID;
|
||||
dvdrs.LayerNumber = 0;
|
||||
if (DeviceIoControl(device, IOCTL_DVD_READ_STRUCTURE, &dvdrs, sizeof(dvdrs), &dld, sizeof(dld), &size, nullptr))
|
||||
{
|
||||
if (dld.ld.NumberOfLayers == 0) // Single layer
|
||||
{
|
||||
if (DeviceIoControl(device, IOCTL_DVD_READ_STRUCTURE, &dvdrs, sizeof(dvdrs), &dld, sizeof(dld), &size, nullptr)) {
|
||||
if (dld.ld.NumberOfLayers == 0) { // Single layer
|
||||
mediaType = 0;
|
||||
}
|
||||
else if (dld.ld.TrackPath == 0) // PTP
|
||||
{
|
||||
} else if (dld.ld.TrackPath == 0) { // PTP
|
||||
mediaType = 1;
|
||||
}
|
||||
else // OTP
|
||||
{
|
||||
} else { // OTP
|
||||
mediaType = 2;
|
||||
}
|
||||
|
||||
|
@ -328,14 +300,14 @@ s32 IOCtlSrc::ReadTOC(char *toc,int msize)
|
|||
if (GetMediaType() >= 0)
|
||||
return -1;
|
||||
|
||||
if(!tocCached)
|
||||
{
|
||||
if (!tocCached) {
|
||||
memset(&tocrq, 0, sizeof(CDROM_READ_TOC_EX));
|
||||
tocrq.Format = CDROM_READ_TOC_EX_FORMAT_FULL_TOC;
|
||||
tocrq.Msf = 1;
|
||||
tocrq.SessionTrack = 1;
|
||||
|
||||
if(!OpenOK) return -1;
|
||||
if (!OpenOK)
|
||||
return -1;
|
||||
|
||||
int code = DeviceIoControl(device, IOCTL_CDROM_READ_TOC_EX, &tocrq, sizeof(tocrq), tocCacheData, 2048, &size, NULL);
|
||||
|
||||
|
@ -356,25 +328,23 @@ s32 IOCtlSrc::ReadSectors2048(u32 sector, u32 count, char *buffer)
|
|||
|
||||
DWORD size = 0;
|
||||
|
||||
if(!OpenOK) return -1;
|
||||
if (!OpenOK)
|
||||
return -1;
|
||||
|
||||
rri.DiskOffset.QuadPart = sector * (u64)2048;
|
||||
rri.SectorCount = count;
|
||||
|
||||
//fall back to standard reading
|
||||
if(SetFilePointer(device,rri.DiskOffset.LowPart,&rri.DiskOffset.HighPart,FILE_BEGIN)==-1)
|
||||
{
|
||||
if (SetFilePointer(device, rri.DiskOffset.LowPart, &rri.DiskOffset.HighPart, FILE_BEGIN) == -1) {
|
||||
if (GetLastError() != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(ReadFile(device,buffer,2048*count,&size,NULL)==0)
|
||||
{
|
||||
if (ReadFile(device, buffer, 2048 * count, &size, NULL) == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(size!=(2048*count))
|
||||
{
|
||||
if (size != (2048 * count)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -390,10 +360,10 @@ s32 IOCtlSrc::ReadSectors2352(u32 sector, u32 count, char *buffer)
|
|||
|
||||
DWORD size = 0;
|
||||
|
||||
if(!OpenOK) return -1;
|
||||
if (!OpenOK)
|
||||
return -1;
|
||||
|
||||
if (m_can_use_spti)
|
||||
{
|
||||
if (m_can_use_spti) {
|
||||
struct sptdinfo
|
||||
{
|
||||
SCSI_PASS_THROUGH_DIRECT info;
|
||||
|
@ -426,8 +396,7 @@ s32 IOCtlSrc::ReadSectors2352(u32 sector, u32 count, char *buffer)
|
|||
sptd.info.TimeOutValue = 5;
|
||||
|
||||
if (DeviceIoControl(device, IOCTL_SCSI_PASS_THROUGH_DIRECT, &sptd,
|
||||
sizeof(sptd), &sptd, sizeof(sptd), &size, nullptr))
|
||||
{
|
||||
sizeof(sptd), &sptd, sizeof(sptd), &size, nullptr)) {
|
||||
if (sptd.info.DataTransferLength == 2352 * count)
|
||||
return 0;
|
||||
}
|
||||
|
@ -438,21 +407,17 @@ s32 IOCtlSrc::ReadSectors2352(u32 sector, u32 count, char *buffer)
|
|||
rri.SectorCount = count;
|
||||
|
||||
rri.TrackMode = (TRACK_MODE_TYPE)last_read_mode;
|
||||
if(DeviceIoControl(device,IOCTL_CDROM_RAW_READ,&rri,sizeof(rri),buffer, 2352*count, &size, NULL)==0)
|
||||
{
|
||||
if (DeviceIoControl(device, IOCTL_CDROM_RAW_READ, &rri, sizeof(rri), buffer, 2352 * count, &size, NULL) == 0) {
|
||||
rri.TrackMode = XAForm2;
|
||||
printf(" * CDVD: CD-ROM read mode change\n");
|
||||
printf(" * CDVD: Trying XAForm2\n");
|
||||
if(DeviceIoControl(device,IOCTL_CDROM_RAW_READ,&rri,sizeof(rri),buffer, 2352*count, &size, NULL)==0)
|
||||
{
|
||||
if (DeviceIoControl(device, IOCTL_CDROM_RAW_READ, &rri, sizeof(rri), buffer, 2352 * count, &size, NULL) == 0) {
|
||||
rri.TrackMode = YellowMode2;
|
||||
printf(" * CDVD: Trying YellowMode2\n");
|
||||
if(DeviceIoControl(device,IOCTL_CDROM_RAW_READ,&rri,sizeof(rri),buffer, 2352*count, &size, NULL)==0)
|
||||
{
|
||||
if (DeviceIoControl(device, IOCTL_CDROM_RAW_READ, &rri, sizeof(rri), buffer, 2352 * count, &size, NULL) == 0) {
|
||||
rri.TrackMode = CDDA;
|
||||
printf(" * CDVD: Trying CDDA\n");
|
||||
if(DeviceIoControl(device,IOCTL_CDROM_RAW_READ,&rri,sizeof(rri),buffer, 2352*count, &size, NULL)==0)
|
||||
{
|
||||
if (DeviceIoControl(device, IOCTL_CDROM_RAW_READ, &rri, sizeof(rri), buffer, 2352 * count, &size, NULL) == 0) {
|
||||
printf(" * CDVD: Failed to read this CD-ROM with error code: %d\n", GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
@ -462,8 +427,7 @@ s32 IOCtlSrc::ReadSectors2352(u32 sector, u32 count, char *buffer)
|
|||
|
||||
last_read_mode = rri.TrackMode;
|
||||
|
||||
if(size!=(2352*count))
|
||||
{
|
||||
if (size != (2352 * count)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -474,27 +438,25 @@ s32 IOCtlSrc::DiscChanged()
|
|||
{
|
||||
DWORD size = 0;
|
||||
|
||||
if(!OpenOK) return -1;
|
||||
if (!OpenOK)
|
||||
return -1;
|
||||
|
||||
int ret = DeviceIoControl(device, IOCTL_STORAGE_CHECK_VERIFY, NULL, 0, NULL, 0, &size, NULL);
|
||||
|
||||
if(ret==0)
|
||||
{
|
||||
if (ret == 0) {
|
||||
tocCached = false;
|
||||
mediaTypeCached = false;
|
||||
discSizeCached = false;
|
||||
layerBreakCached = false;
|
||||
|
||||
if(sessID!=0)
|
||||
{
|
||||
if (sessID != 0) {
|
||||
DeviceIoControl(device, IOCTL_DVD_END_SESSION, &sessID, sizeof(DVD_SESSION_ID), NULL, 0, &size, NULL);
|
||||
sessID = 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(sessID==0)
|
||||
{
|
||||
if (sessID == 0) {
|
||||
DeviceIoControl(device, IOCTL_DVD_START_SESSION, NULL, 0, &sessID, sizeof(DVD_SESSION_ID), &size, NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,26 +54,30 @@ void CfgSetSettingsDir( const char* dir )
|
|||
\*_____________________________________________*/
|
||||
|
||||
|
||||
void CfgWriteBool(char *Section, char*Name, char Value) {
|
||||
void CfgWriteBool(char *Section, char *Name, char Value)
|
||||
{
|
||||
char *Data = Value ? "TRUE" : "FALSE";
|
||||
|
||||
WritePrivateProfileString(Section, Name, Data, CfgFile);
|
||||
}
|
||||
|
||||
void CfgWriteInt(char *Section, char*Name, int Value) {
|
||||
void CfgWriteInt(char *Section, char *Name, int Value)
|
||||
{
|
||||
char Data[255];
|
||||
_itoa(Value, Data, 10);
|
||||
|
||||
WritePrivateProfileString(Section, Name, Data, CfgFile);
|
||||
}
|
||||
|
||||
void CfgWriteStr(char *Section, char*Name,char *Data) {
|
||||
void CfgWriteStr(char *Section, char *Name, char *Data)
|
||||
{
|
||||
WritePrivateProfileString(Section, Name, Data, CfgFile);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
char CfgReadBool(char *Section,char *Name,char Default) {
|
||||
char CfgReadBool(char *Section, char *Name, char Default)
|
||||
{
|
||||
char Data[255] = "";
|
||||
GetPrivateProfileString(Section, Name, "", Data, 255, CfgFile);
|
||||
Data[254] = 0;
|
||||
|
@ -82,15 +86,21 @@ char CfgReadBool(char *Section,char *Name,char Default) {
|
|||
return Default;
|
||||
}
|
||||
|
||||
if(strcmp(Data,"1")==0) return -1;
|
||||
if(strcmp(Data,"Y")==0) return -1;
|
||||
if(strcmp(Data,"T")==0) return -1;
|
||||
if(strcmp(Data,"YES")==0) return -1;
|
||||
if(strcmp(Data,"TRUE")==0) return -1;
|
||||
if (strcmp(Data, "1") == 0)
|
||||
return -1;
|
||||
if (strcmp(Data, "Y") == 0)
|
||||
return -1;
|
||||
if (strcmp(Data, "T") == 0)
|
||||
return -1;
|
||||
if (strcmp(Data, "YES") == 0)
|
||||
return -1;
|
||||
if (strcmp(Data, "TRUE") == 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CfgReadInt(char *Section, char*Name,int Default) {
|
||||
int CfgReadInt(char *Section, char *Name, int Default)
|
||||
{
|
||||
char Data[255] = "";
|
||||
GetPrivateProfileString(Section, Name, "", Data, 255, CfgFile);
|
||||
Data[254] = 0;
|
||||
|
@ -103,7 +113,8 @@ int CfgReadInt(char *Section, char*Name,int Default) {
|
|||
return atoi(Data);
|
||||
}
|
||||
|
||||
void CfgReadStr(char *Section, char*Name,char *Data,int DataSize,char *Default) {
|
||||
void CfgReadStr(char *Section, char *Name, char *Data, int DataSize, char *Default)
|
||||
{
|
||||
int sl;
|
||||
GetPrivateProfileString(Section, Name, "", Data, DataSize, CfgFile);
|
||||
|
||||
|
@ -148,27 +159,24 @@ BOOL CALLBACK ConfigProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
|
|||
int wmId, wmEvent;
|
||||
char temp[20] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
switch(uMsg)
|
||||
{
|
||||
switch (uMsg) {
|
||||
|
||||
case WM_PAINT:
|
||||
return FALSE;
|
||||
case WM_INITDIALOG:
|
||||
|
||||
n=0;s=0;
|
||||
n = 0;
|
||||
s = 0;
|
||||
|
||||
SendMessage(GetDlgItem(hWnd, IDC_DRIVE), CB_RESETCONTENT, 0, 0);
|
||||
SendMessage(GetDlgItem(hWnd, IDC_DRIVE), CB_ADDSTRING, 0, (LPARAM) "@ (No disc)");
|
||||
for(char d='A';d<='Z';d++)
|
||||
{
|
||||
if(GetDriveType(path[d-'A'])==DRIVE_CDROM)
|
||||
{
|
||||
for (char d = 'A'; d <= 'Z'; d++) {
|
||||
if (GetDriveType(path[d - 'A']) == DRIVE_CDROM) {
|
||||
n++;
|
||||
|
||||
SendMessage(GetDlgItem(hWnd, IDC_DRIVE), CB_ADDSTRING, 0, (LPARAM)path[d - 'A']);
|
||||
|
||||
if(source_drive==d)
|
||||
{
|
||||
if (source_drive == d) {
|
||||
s = n;
|
||||
}
|
||||
}
|
||||
|
@ -181,8 +189,7 @@ BOOL CALLBACK ConfigProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
|
|||
wmId = LOWORD(wParam);
|
||||
wmEvent = HIWORD(wParam);
|
||||
// Parse the menu selections:
|
||||
switch (wmId)
|
||||
{
|
||||
switch (wmId) {
|
||||
case IDOK:
|
||||
GetDlgItemText(hWnd, IDC_DRIVE, temp, 20);
|
||||
temp[19] = 0;
|
||||
|
@ -210,8 +217,7 @@ void configure()
|
|||
INT_PTR ret;
|
||||
ReadSettings();
|
||||
ret = DialogBoxParam(hinst, MAKEINTRESOURCE(IDD_CONFIG), GetActiveWindow(), (DLGPROC)ConfigProc, 1);
|
||||
if(ret==-1)
|
||||
{
|
||||
if (ret == -1) {
|
||||
MessageBoxEx(GetActiveWindow(), "Error Opening the config dialog.", "OMG ERROR!", MB_OK, 0);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue