WIP work towards adding support for non-trivial image files (multitrack cue+bin, ccd, nrg, ...).

This is only refactoring, there shouldn't be any behavior change.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2157 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gigaherz 2009-11-08 02:45:09 +00:00
parent 115d2b6f05
commit 3c54e2ba75
6 changed files with 133 additions and 79 deletions

View File

@ -164,7 +164,7 @@ s32 CALLBACK CDVDopen(const char* pTitleFilename)
printf(" * CDVD: Opening image '%s'...\n",source_file); printf(" * CDVD: Opening image '%s'...\n",source_file);
//open device file //open device file
src=new FileSrc(source_file); src= TryLoaders(source_file);
} }
else else
{ {

View File

@ -43,7 +43,6 @@ typedef struct _toc_data
extern toc_data cdtoc; extern toc_data cdtoc;
class Source //abstract class as base for source modules class Source //abstract class as base for source modules
{ {
public: public:
@ -117,56 +116,10 @@ public:
virtual s32 DiscChanged(); virtual s32 DiscChanged();
}; };
class FileSrc: public Source
{
private:
HANDLE fileSource;
bool OpenOK;
s32 sector_count;
char sectorbuffer[32*2048];
char fName[256];
DWORD sessID;
bool tocCached;
char tocCacheData[2048];
bool mediaTypeCached;
int mediaType;
bool discSizeCached;
s32 discSize;
bool layerBreakCached;
s32 layerBreak;
public:
FileSrc(const char* fileName);
//virtual destructor
virtual ~FileSrc();
//virtual members
virtual s32 GetSectorCount();
virtual s32 ReadTOC(char *toc,int size);
virtual s32 ReadSectors2048(u32 sector, u32 count, char *buffer);
virtual s32 ReadSectors2352(u32 sector, u32 count, char *buffer);
virtual s32 GetLayerBreakAddress();
virtual s32 GetMediaType();
virtual s32 IsOK();
virtual s32 Reopen();
virtual s32 DiscChanged();
};
extern Source *src; extern Source *src;
Source* TryLoaders(const char* fileName);
int FindDiskType(); int FindDiskType();
void configure(); void configure();

View File

@ -0,0 +1,12 @@
#include "CDVD.h"
#include "ReaderModules.h"
Source* TryLoaders(const char* fileName)
{
Source *src=NULL;
if((src=PlainIso::TryLoad(fileName))!=NULL) return src;
//if((src=CueSheet::TryLoad(fileName))!=NULL) return src;
//if((src=CloneCD::TryLoad(fileName))!=NULL) return src;
//error
return NULL;
}

View File

@ -0,0 +1,73 @@
#pragma once
class Reader: public Source //abstract class as base for Reader modules
{
public:
//virtual destructor
virtual ~Reader() {}
//virtual members
virtual s32 GetSectorCount()=0;
virtual s32 ReadTOC(char *toc,int size)=0;
virtual s32 ReadSectors2048(u32 sector, u32 count, char *buffer)=0;
virtual s32 ReadSectors2352(u32 sector, u32 count, char *buffer)=0;
virtual s32 GetLayerBreakAddress()=0;
virtual s32 GetMediaType()=0;
virtual s32 IsOK()=0;
virtual s32 Reopen()=0;
virtual s32 DiscChanged()=0;
//added members
static Reader* TryLoad(const char* fileName);
};
class PlainIso: public Reader
{
HANDLE fileSource;
bool OpenOK;
s32 sector_count;
char sectorbuffer[32*2048];
char fName[256];
DWORD sessID;
bool tocCached;
char tocCacheData[2048];
bool mediaTypeCached;
int mediaType;
bool discSizeCached;
s32 discSize;
bool layerBreakCached;
s32 layerBreak;
public:
PlainIso(const char* fileName);
virtual ~PlainIso();
//virtual members
virtual s32 GetSectorCount();
virtual s32 ReadTOC(char *toc,int size);
virtual s32 ReadSectors2048(u32 sector, u32 count, char *buffer);
virtual s32 ReadSectors2352(u32 sector, u32 count, char *buffer);
virtual s32 GetLayerBreakAddress();
virtual s32 GetMediaType();
virtual s32 IsOK();
virtual s32 Reopen();
virtual s32 DiscChanged();
static Reader* TryLoad(const char* fileName);
};

View File

@ -10,7 +10,11 @@
#pragma warning(default:4200) #pragma warning(default:4200)
#include <stddef.h> #include <stddef.h>
#include "../ReaderModules.h"
#include "../SectorConverters.h" #include "../SectorConverters.h"
#include <string>
template<class T> template<class T>
bool ApiErrorCheck(T t,T okValue,bool cmpEq) bool ApiErrorCheck(T t,T okValue,bool cmpEq)
{ {
@ -30,7 +34,7 @@ bool ApiErrorCheck(T t,T okValue,bool cmpEq)
#define RETURN(v) {OpenOK=v; return;} #define RETURN(v) {OpenOK=v; return;}
s32 FileSrc::Reopen() s32 PlainIso::Reopen()
{ {
if(fileSource!=INVALID_HANDLE_VALUE) if(fileSource!=INVALID_HANDLE_VALUE)
{ {
@ -53,7 +57,7 @@ s32 FileSrc::Reopen()
return 0; return 0;
} }
FileSrc::FileSrc(const char* fileName) PlainIso::PlainIso(const char* fileName)
{ {
fileSource=INVALID_HANDLE_VALUE; fileSource=INVALID_HANDLE_VALUE;
@ -62,7 +66,7 @@ FileSrc::FileSrc(const char* fileName)
Reopen(); Reopen();
} }
FileSrc::~FileSrc() PlainIso::~PlainIso()
{ {
if(OpenOK) if(OpenOK)
{ {
@ -70,7 +74,7 @@ FileSrc::~FileSrc()
} }
} }
s32 FileSrc::GetSectorCount() s32 PlainIso::GetSectorCount()
{ {
LARGE_INTEGER li; LARGE_INTEGER li;
int plain_sectors = 0; int plain_sectors = 0;
@ -88,12 +92,12 @@ s32 FileSrc::GetSectorCount()
return -1; return -1;
} }
s32 FileSrc::GetLayerBreakAddress() s32 PlainIso::GetLayerBreakAddress()
{ {
return 0; return 0;
} }
s32 FileSrc::GetMediaType() s32 PlainIso::GetMediaType()
{ {
if(mediaTypeCached) if(mediaTypeCached)
return mediaType; return mediaType;
@ -125,7 +129,7 @@ s32 FileSrc::GetMediaType()
f = ((l)%75); f = ((l)%75);
s32 FileSrc::ReadTOC(char *toc,int msize) s32 PlainIso::ReadTOC(char *toc,int msize)
{ {
DWORD size=0; DWORD size=0;
@ -162,7 +166,7 @@ s32 FileSrc::ReadTOC(char *toc,int msize)
return 0; return 0;
} }
s32 FileSrc::ReadSectors2048(u32 sector, u32 count, char *buffer) s32 PlainIso::ReadSectors2048(u32 sector, u32 count, char *buffer)
{ {
DWORD size=0; DWORD size=0;
LARGE_INTEGER Offset; LARGE_INTEGER Offset;
@ -192,7 +196,7 @@ s32 FileSrc::ReadSectors2048(u32 sector, u32 count, char *buffer)
} }
s32 FileSrc::ReadSectors2352(u32 sector, u32 count, char *buffer) s32 PlainIso::ReadSectors2352(u32 sector, u32 count, char *buffer)
{ {
DWORD size=0; DWORD size=0;
LARGE_INTEGER Offset; LARGE_INTEGER Offset;
@ -228,7 +232,7 @@ s32 FileSrc::ReadSectors2352(u32 sector, u32 count, char *buffer)
return 0; return 0;
} }
s32 FileSrc::DiscChanged() s32 PlainIso::DiscChanged()
{ {
DWORD size=0; DWORD size=0;
@ -237,7 +241,23 @@ s32 FileSrc::DiscChanged()
return 0; return 0;
} }
s32 FileSrc::IsOK() s32 PlainIso::IsOK()
{ {
return OpenOK; return OpenOK;
} }
Reader* PlainIso::TryLoad(const char* fName)
{
std::string fileName = fName;
std::string::size_type pos = fileName.find_last_of('.');
if(pos == std::string::npos) // no "." found, error.
return NULL;
std::string extension = fileName.substr(pos);
if(extension.compare(".iso")!=0) // assume valid
return NULL;
return new PlainIso(fName);
}

View File

@ -175,11 +175,11 @@
> >
</File> </File>
<File <File
RelativePath=".\FileSrc.cpp" RelativePath=".\IOCtlSrc.cpp"
> >
</File> </File>
<File <File
RelativePath=".\IOCtlSrc.cpp" RelativePath="..\ReaderModules.cpp"
> >
</File> </File>
<File <File
@ -190,6 +190,14 @@
RelativePath="..\TocStuff.cpp" RelativePath="..\TocStuff.cpp"
> >
</File> </File>
<Filter
Name="Reader Modules"
>
<File
RelativePath=".\PlainIso.cpp"
>
</File>
</Filter>
</Filter> </Filter>
<Filter <Filter
Name="Header Files" Name="Header Files"
@ -199,6 +207,10 @@
RelativePath="..\CDVD.h" RelativePath="..\CDVD.h"
> >
</File> </File>
<File
RelativePath="..\ReaderModules.h"
>
</File>
<File <File
RelativePath="resource.h" RelativePath="resource.h"
> >
@ -207,22 +219,6 @@
RelativePath="..\SectorConverters.h" RelativePath="..\SectorConverters.h"
> >
</File> </File>
<Filter
Name="isofs"
>
<File
RelativePath="..\isofs\CDVDiso.h"
>
</File>
<File
RelativePath="..\isofs\CDVDisodrv.h"
>
</File>
<File
RelativePath="..\isofs\CDVDlib.h"
>
</File>
</Filter>
<Filter <Filter
Name="rosddk" Name="rosddk"
> >