More iso work. Timestamps work in Linux now (and use Paths.h). Worked on getting rid of other redundant code, moving the logging to the standard pcsx2 log functions, and misc cleanup.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1550 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2009-07-22 12:06:32 +00:00
parent 83b15dbac0
commit 6aacb2899c
8 changed files with 149 additions and 154 deletions

View File

@ -36,7 +36,7 @@
static int diskTypeCached=-1;
int lastReadSize;
static int plsn=0;
static int plsn=0; // This never gets set, so it's always 0.
static isoFile *blockDumpFile;
@ -62,15 +62,14 @@ int CheckDiskTypeFS(int baseType)
buffer[size]='\0';
pos=strstr(buffer, "BOOT2");
if (pos==NULL){
pos=strstr(buffer, "BOOT");
if (pos==NULL) {
return CDVD_TYPE_ILLEGAL;
}
pos = strstr(buffer, "BOOT2");
if (pos == NULL)
{
pos = strstr(buffer, "BOOT");
if (pos == NULL) return CDVD_TYPE_ILLEGAL;
return CDVD_TYPE_PSCD;
}
return (baseType==CDVD_TYPE_DETCTCD)?CDVD_TYPE_PS2CD:CDVD_TYPE_PS2DVD;
return (baseType==CDVD_TYPE_DETCTCD) ? CDVD_TYPE_PS2CD : CDVD_TYPE_PS2DVD;
}
if (IsoFS_findFile("PSX.EXE;1", &tocEntry) == TRUE)
@ -90,8 +89,8 @@ static char bleh[2352];
int FindDiskType(int mType)
{
int dataTracks=0;
int audioTracks=0;
int dataTracks = 0;
int audioTracks = 0;
int iCDType = mType;
@ -99,69 +98,71 @@ int FindDiskType(int mType)
CDVD.getTN(&tn);
if(tn.strack != tn.etrack) // multitrack == CD.
if (tn.strack != tn.etrack) // multitrack == CD.
{
iCDType = CDVD_TYPE_DETCTCD;
}
else if(mType<0)
else if (mType < 0)
{
cdvdTD td;
CDVD.getTD(0,&td);
if(td.lsn>452849)
if (td.lsn > 452849)
{
iCDType = CDVD_TYPE_DETCTDVDS;
}
else if(DoCDVDreadSector((u8*)bleh,16,CDVD_MODE_2048)==0)
else if (DoCDVDreadSector((u8*)bleh,16,CDVD_MODE_2048) == 0)
{
struct cdVolDesc* volDesc=(struct cdVolDesc *)bleh;
if(volDesc)
if (volDesc)
{
if(volDesc->rootToc.tocSize==2048) iCDType = CDVD_TYPE_DETCTCD;
else iCDType = CDVD_TYPE_DETCTDVDS;
if(volDesc->rootToc.tocSize==2048)
iCDType = CDVD_TYPE_DETCTCD;
else
iCDType = CDVD_TYPE_DETCTDVDS;
}
}
}
if(iCDType == CDVD_TYPE_DETCTDVDS)
if (iCDType == CDVD_TYPE_DETCTDVDS)
{
s32 dlt=0;
u32 l1s=0;
s32 dlt = 0;
u32 l1s = 0;
if(CDVD.getDualInfo(&dlt,&l1s)==0)
{
if(dlt>0)
iCDType = CDVD_TYPE_DETCTDVDD;
if (dlt > 0) iCDType = CDVD_TYPE_DETCTDVDD;
}
}
switch(iCDType)
{
case CDVD_TYPE_DETCTCD:
Console::Status(" * CDVD Disk Open: CD, %d tracks (%d to %d):", params tn.etrack-tn.strack+1,tn.strack,tn.etrack);
break;
case CDVD_TYPE_DETCTDVDS:
Console::Status(" * CDVD Disk Open: DVD, Single layer or unknown:");
break;
case CDVD_TYPE_DETCTDVDD:
Console::Status(" * CDVD Disk Open: DVD, Double layer:");
break;
case CDVD_TYPE_DETCTCD:
Console::Status(" * CDVD Disk Open: CD, %d tracks (%d to %d):", params tn.etrack-tn.strack+1,tn.strack,tn.etrack);
break;
case CDVD_TYPE_DETCTDVDS:
Console::Status(" * CDVD Disk Open: DVD, Single layer or unknown:");
break;
case CDVD_TYPE_DETCTDVDD:
Console::Status(" * CDVD Disk Open: DVD, Double layer:");
break;
}
audioTracks=dataTracks=0;
for(int i=tn.strack;i<=tn.etrack;i++)
audioTracks = dataTracks = 0;
for(int i = tn.strack; i <= tn.etrack; i++)
{
cdvdTD td,td2;
CDVD.getTD(i,&td);
if(tn.etrack>i)
if (tn.etrack > i)
CDVD.getTD(i+1,&td2);
else
CDVD.getTD(0,&td2);
int tlength = td2.lsn - td.lsn;
if(td.type==CDVD_AUDIO_TRACK)
if (td.type == CDVD_AUDIO_TRACK)
{
audioTracks++;
Console::Status(" * * Track %d: Audio (%d sectors)", params i,tlength);
@ -173,24 +174,24 @@ int FindDiskType(int mType)
}
}
if(dataTracks>0)
if (dataTracks > 0)
{
iCDType=CheckDiskTypeFS(iCDType);
}
if(audioTracks>0)
if (audioTracks > 0)
{
if(iCDType==CDVD_TYPE_PS2CD)
switch (iCDType)
{
iCDType=CDVD_TYPE_PS2CDDA;
}
else if(iCDType==CDVD_TYPE_PSCD)
{
iCDType=CDVD_TYPE_PSCDDA;
}
else
{
iCDType=CDVD_TYPE_CDDA;
case CDVD_TYPE_PS2CD:
iCDType=CDVD_TYPE_PS2CDDA;
break;
case CDVD_TYPE_PSCD:
iCDType=CDVD_TYPE_PSCDDA;
break;
default:
iCDType=CDVD_TYPE_CDDA;
break;
}
}
@ -210,25 +211,28 @@ void DetectDiskType()
switch(baseMediaType) // Paranoid mode: do not trust the plugin's detection system to work correctly.
{
case CDVD_TYPE_CDDA:
case CDVD_TYPE_PSCD:
case CDVD_TYPE_PS2CD:
case CDVD_TYPE_PSCDDA:
case CDVD_TYPE_PS2CDDA:
mType=CDVD_TYPE_DETCTCD;
break;
case CDVD_TYPE_DVDV:
case CDVD_TYPE_PS2DVD:
mType=CDVD_TYPE_DETCTDVDS;
break;
case CDVD_TYPE_DETCTDVDS:
case CDVD_TYPE_DETCTDVDD:
case CDVD_TYPE_DETCTCD:
mType=baseMediaType;
break;
case CDVD_TYPE_NODISC:
diskTypeCached = CDVD_TYPE_NODISC;
return;
case CDVD_TYPE_CDDA:
case CDVD_TYPE_PSCD:
case CDVD_TYPE_PS2CD:
case CDVD_TYPE_PSCDDA:
case CDVD_TYPE_PS2CDDA:
mType = CDVD_TYPE_DETCTCD;
break;
case CDVD_TYPE_DVDV:
case CDVD_TYPE_PS2DVD:
mType = CDVD_TYPE_DETCTDVDS;
break;
case CDVD_TYPE_DETCTDVDS:
case CDVD_TYPE_DETCTDVDD:
case CDVD_TYPE_DETCTCD:
mType = baseMediaType;
break;
case CDVD_TYPE_NODISC:
diskTypeCached = CDVD_TYPE_NODISC;
return;
}
diskTypeCached = FindDiskType(mType);
@ -239,7 +243,7 @@ void DetectDiskType()
s32 DoCDVDinit()
{
diskTypeCached=-1;
diskTypeCached = -1;
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();
@ -253,48 +257,22 @@ void DoCDVDshutdown()
s32 DoCDVDopen(const char* pTitleFilename)
{
int ret=0;
ret = CDVD.open(pTitleFilename);
int ret = CDVD.open(pTitleFilename);
int cdtype = DoCDVDdetectDiskType();
if((Config.Blockdump)&&(cdtype != CDVD_TYPE_NODISC))
{
char fname_only[MAX_PATH];
char fname_only[g_MaxPath];
if(CDVD.init == ISO.init)
{
#ifdef _WIN32
char fname[MAX_PATH], ext[MAX_PATH];
char fname[MAX_PATH], ext[g_MaxPath];
_splitpath(isoFileName, NULL, NULL, fname, ext);
_makepath(fname_only, NULL, NULL, fname, NULL);
#else
char* p, *plast;
plast = p = strchr(isoFileName, '/');
while (p != NULL)
{
plast = p;
p = strchr(p + 1, '/');
}
// Lets not create dumps in the plugin directory.
strcpy(fname_only, "../");
if (plast != NULL)
strcat(fname_only, plast + 1);
else
strcat(fname_only, isoFileName);
plast = p = strchr(fname_only, '.');
while (p != NULL)
{
plast = p;
p = strchr(p + 1, '.');
}
if (plast != NULL) *plast = 0;
getcwd(fname_only, ArraySize(fname_only)); // Base it out of the current directory for now.
strcat(fname_only, Path::GetFilenameWithoutExt(isoFileName).c_str());
#endif
}
else
@ -302,7 +280,8 @@ s32 DoCDVDopen(const char* pTitleFilename)
strcpy(fname_only, "Untitled");
}
#if defined(_WIN32) && defined(ENABLE_TIMESTAMPS)
#ifdef ENABLE_TIMESTAMPS
#ifdef _WIN32
SYSTEMTIME time;
GetLocalTime(&time);
@ -311,16 +290,27 @@ s32 DoCDVDopen(const char* pTitleFilename)
" (%04d-%02d-%02d %02d-%02d-%02d).dump",
time.wYear, time.wMonth, time.wDay,
time.wHour, time.wMinute, time.wSecond);
// TODO: implement this for linux
#else
time_t rawtime;
struct tm * timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
sprintf(
fname_only+strlen(fname_only),
" (%04d-%02d-%02d %02d-%02d-%02d).dump",
timeinfo->tm_year + 1900, timeinfo->tm_mon, timeinfo->tm_mday,
timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
#endif
#else
strcat(fname_only, ".dump");
#endif
cdvdTD td;
CDVD.getTD(0, &td);
int blockofs=0;
int blocksize=0;
int blockofs = 0;
int blocksize = 0;
int blocks = td.lsn;
switch(cdtype)
@ -332,6 +322,7 @@ s32 DoCDVDopen(const char* pTitleFilename)
blockofs = 24;
blocksize = 2048;
break;
default:
blockofs = 0;
blocksize= 2352;
@ -399,7 +390,7 @@ s32 DoCDVDgetBuffer(u8* buffer)
{
int ret = CDVD.getBuffer2(buffer);
if(ret==0)
if (ret == 0)
{
if (blockDumpFile != NULL)
{
@ -412,8 +403,7 @@ s32 DoCDVDgetBuffer(u8* buffer)
s32 DoCDVDdetectDiskType()
{
if(diskTypeCached<0)
DetectDiskType();
if(diskTypeCached<0) DetectDiskType();
return diskTypeCached;
}

View File

@ -29,7 +29,7 @@
#include "CDVDisoReader.h"
char isoFileName[256];
char isoFileName[g_MaxPath];
u8 *pbuffer;
int cdtype;
@ -59,11 +59,11 @@ void lba_to_msf(s32 lba, u8* m, u8* s, u8* f)
*f = lba % 75;
}
#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */
#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 itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */
#ifdef PCSX2_DEBUG
/*#ifdef PCSX2_DEBUG
void __Log(char *fmt, ...)
{
va_list list;
@ -76,11 +76,11 @@ void __Log(char *fmt, ...)
}
#else
#define __Log 0&&
#endif
#endif*/
s32 CALLBACK ISOinit()
{
#ifdef PCSX2_DEBUG
/*#ifdef PCSX2_DEBUG
cdvdLog = fopen("logs/cdvdLog.txt", "w");
if (cdvdLog == NULL)
{
@ -91,18 +91,18 @@ s32 CALLBACK ISOinit()
return -1;
}
}
setvbuf(cdvdLog, NULL, _IONBF, 0);
setvbuf(cdvdLog, NULL, _IONBF, 0);*/
CDVD_LOG("CDVDinit\n");
#endif
/*#endif*/
return 0;
}
void CALLBACK ISOshutdown()
{
#ifdef CDVD_LOG
/*#ifdef CDVD_LOG
if (cdvdLog != NULL) fclose(cdvdLog);
#endif
#endif*/
}
s32 CALLBACK ISOopen(const char* pTitle)
@ -116,12 +116,18 @@ s32 CALLBACK ISOopen(const char* pTitle)
return -1;
}
if (iso->type == ISOTYPE_DVD)
cdtype = CDVD_TYPE_PS2DVD;
else if (iso->type == ISOTYPE_AUDIO)
cdtype = CDVD_TYPE_CDDA;
else
cdtype = CDVD_TYPE_PS2CD;
switch (iso->type)
{
case ISOTYPE_DVD:
cdtype = CDVD_TYPE_PS2DVD;
break;
case ISOTYPE_AUDIO:
cdtype = CDVD_TYPE_CDDA;
break;
default:
cdtype = CDVD_TYPE_PS2CD;
break;
}
return 0;
}
@ -209,8 +215,7 @@ static void FindLayer1Start()
layer1start=-2;
}
if(layer1start>=0)
Console::Status("found at 0x%8.8x\n", params layer1start);
if(layer1start>=0) Console::Status("found at 0x%8.8x\n", params layer1start);
}
}
@ -346,11 +351,8 @@ s32 CALLBACK ISOreadSector(u8* tempbuffer, u32 lsn, int mode)
{
int _lsn = lsn;
if (_lsn < 0)
lsn = iso->blocks + _lsn;
if(lsn > iso->blocks)
return -1;
if (_lsn < 0) lsn = iso->blocks + _lsn;
if (lsn > iso->blocks) return -1;
if(mode == CDVD_MODE_2352)
{
@ -389,11 +391,8 @@ s32 CALLBACK ISOreadTrack(u32 lsn, int mode)
{
int _lsn = lsn;
if (_lsn < 0)
lsn = iso->blocks + _lsn;
if(lsn > iso->blocks)
return -1;
if (_lsn < 0) lsn = iso->blocks + _lsn;
if (lsn > iso->blocks) return -1;
isoReadBlock(iso, cdbuffer + iso->blockofs, lsn);

View File

@ -29,20 +29,20 @@
#include "IsoFStools.h"
#include "IsoFileFormats.h"
#define CDVD_LOG __Log
//#define CDVD_LOG __Log
#ifndef MAX_PATH
#define MAX_PATH 255
#endif
//#ifndef MAX_PATH
//#define MAX_PATH 255
//#endif
extern FILE *cdvdLog;
//extern FILE *cdvdLog;
void __Log(char *fmt, ...);
//void __Log(char *fmt, ...);
#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 itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */
//#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */
extern char isoFileName[256];
extern char isoFileName[g_MaxPath];
extern isoFile *iso;
#endif

View File

@ -183,7 +183,7 @@ int _isoReadDtable(isoFile *iso)
for (int i = 0; i < iso->dtablesize; i++)
{
_seekfile(iso->handle, 16 + (iso->blocksize + 4)*i, SEEK_SET);
_seekfile(iso->handle, 16 + (iso->blocksize + 4) * i, SEEK_SET);
ret = _readfile(iso->handle, &iso->dtable[i], 4);
if (ret < 4) return -1;
}
@ -220,7 +220,7 @@ int isoDetect(isoFile *iso) // based on florin's CDVDbin detection code :)
_readfile(iso->handle, &iso->blocks, 4);
_readfile(iso->handle, &iso->blockofs, 4);
_isoReadDtable(iso);
return detect(iso) == 1 ? 0 : -1;
return (detect(iso) == 1) ? 0 : -1;
}
else
{
@ -266,7 +266,7 @@ isoFile *isoOpen(const char *filename)
Console::WriteLn("detected blocksize = %d", params iso->blocksize);
if (strlen(iso->filename) > 3 && strncmp(iso->filename + (strlen(iso->filename) - 3), "I00", 3) == 0)
if ((strlen(iso->filename) > 3) && strncmp(iso->filename + (strlen(iso->filename) - 3), "I00", 3) == 0)
{
int i;
@ -299,8 +299,7 @@ isoFile *isoOpen(const char *filename)
if (iso->flags == 0)
{
_seekfile(iso->handle, 0, SEEK_END);
iso->blocks = (u32)((_tellfile(iso->handle) - iso->offset) /
(iso->blocksize));
iso->blocks = (u32)((_tellfile(iso->handle) - iso->offset) / (iso->blocksize));
}
Console::WriteLn("isoOpen: %s ok", params iso->filename);
@ -327,7 +326,6 @@ isoFile *isoCreate(const char *filename, int flags)
iso->flags = flags;
iso->offset = 0;
iso->blockofs = 24;
iso->blocksize = CD_FRAMESIZE_RAW;
iso->blocksize = 2048;
if (iso->flags & (ISOFLAGS_Z | ISOFLAGS_Z2 | ISOFLAGS_BZ2))
@ -430,7 +428,7 @@ int _isoReadBlockD(isoFile *iso, u8 *dst, int lsn)
{
if (iso->dtable[i] != lsn) continue;
_seekfile(iso->handle, 16 + i*(iso->blocksize + 4) + 4, SEEK_SET);
_seekfile(iso->handle, 16 + i * (iso->blocksize + 4) + 4, SEEK_SET);
ret = _readfile(iso->handle, dst, iso->blocksize);
if (ret < iso->blocksize) return -1;
@ -449,7 +447,7 @@ int _isoReadBlockM(isoFile *iso, u8 *dst, int lsn)
for (i = 0; i < 8; i++)
{
if (lsn >= iso->multih[i].slsn && lsn <= iso->multih[i].elsn)
if ((lsn >= iso->multih[i].slsn) && (lsn <= iso->multih[i].elsn))
{
break;
}

View File

@ -38,6 +38,8 @@
#pragma warning(disable:4018)
#endif
#include "CDVD.h"
enum isoType
{
ISOTYPE_ILLEGAL = 0,
@ -59,8 +61,8 @@ enum isoFlags
#define CD_FRAMESIZE_RAW 2352
#define DATA_SIZE (CD_FRAMESIZE_RAW-12)
#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 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
{

View File

@ -112,6 +112,7 @@ extern bool SrcLog_MEMCARDS( const char* fmt, ... );
extern bool SrcLog_PAD( const char* fmt, ... );
extern bool SrcLog_GTE( const char* fmt, ... );
extern bool SrcLog_CDR( const char* fmt, ... );
extern bool SrcLog_CDVD( const char* fmt, ... );
extern bool SrcLog_GPU( const char* fmt, ... );
#define CPU_LOG (varLog & 0x00000001) && SrcLog_CPU
@ -146,6 +147,7 @@ extern bool SrcLog_GPU( const char* fmt, ... );
#define GTE_LOG (varLog & 0x04000000) && SrcLog_GTE
#define CDR_LOG (varLog & 0x08000000) && SrcLog_CDR
#define GPU_LOG (varLog & 0x10000000) && SrcLog_GPU
#define CDVD_LOG SrcLog_CDVD
// fixme - currently we don't log cache
#define CACHE_LOG 0&&
@ -181,6 +183,7 @@ extern bool SrcLog_GPU( const char* fmt, ... );
#define PAD_LOG 0&&
#define GTE_LOG 0&&
#define CDR_LOG 0&&
#define CDVD_LOG 0&&
#define GPU_LOG 0&&
#define PSXCNT_LOG 0&&
#define EECNT_LOG 0&&

View File

@ -111,6 +111,7 @@ int LoadConfig()
GetValuel("vuFlagHack", Config.Hacks.vuFlagHack);
GetValuel("vuMinMax", Config.Hacks.vuMinMax);
GetValuel("IdleLoopFF", Config.Hacks.IdleLoopFF);
//GetValuel("BlockDump", Config.Blockdump);
GetValuel("ESCExits", Config.Hacks.ESCExits);
if (Config.Hacks.VUCycleSteal < 0 || Config.Hacks.VUCycleSteal > 4)
@ -182,6 +183,7 @@ void SaveConfig()
SetValuel("INTCSTATSlow", Config.Hacks.INTCSTATSlow);
SetValuel("VUCycleSteal", Config.Hacks.VUCycleSteal);
SetValuel("IdleLoopFF", Config.Hacks.IdleLoopFF);
//SetValuel("BlockDump", Config.Blockdump);
SetValuel("ESCExits", Config.Hacks.ESCExits);
SetValuel("Fixes", Config.GameFixes);

View File

@ -180,6 +180,7 @@ IMPLEMENT_SOURCE_LOG( MEMCARDS, 'I', 7 )
IMPLEMENT_SOURCE_LOG( PAD, 'I', 7 )
IMPLEMENT_SOURCE_LOG( GTE, 'I', 3 )
IMPLEMENT_SOURCE_LOG( CDR, 'I', 8 )
IMPLEMENT_SOURCE_LOG( CDVD, 'I', 8 )