mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-24 23:11:14 +01:00
Gamelist loading speedup: Be lazy about parsing the file system - it's not necessary for Wii games since the banners are external (in savegames). Also make it possible for the gamelist code to create cache entries for GC images without banners.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5595 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
49bbbe099d
commit
5539dd4e8b
@ -183,7 +183,6 @@ public:
|
||||
template<class T>
|
||||
static bool Load(const std::string& _rFilename, int _Revision, T& _class)
|
||||
{
|
||||
|
||||
INFO_LOG(COMMON, "ChunkReader: Loading %s" , _rFilename.c_str());
|
||||
|
||||
if (! File::Exists(_rFilename.c_str()))
|
||||
|
@ -128,15 +128,18 @@ bool IBannerLoader::CopyBeUnicodeToString( std::string& _rDestination, const u16
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
|
||||
IBannerLoader* CreateBannerLoader(DiscIO::IFileSystem& _rFileSystem, DiscIO::IVolume *pVolume)
|
||||
{
|
||||
if (IsVolumeWiiDisc(pVolume) || IsVolumeWadFile(pVolume))
|
||||
{
|
||||
return(new CBannerLoaderWii(pVolume));
|
||||
return new CBannerLoaderWii(pVolume);
|
||||
}
|
||||
if (_rFileSystem.IsValid())
|
||||
{
|
||||
return new CBannerLoaderGC(_rFileSystem);
|
||||
}
|
||||
|
||||
return(new CBannerLoaderGC(_rFileSystem));
|
||||
return NULL;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
} // namespace
|
||||
|
@ -29,26 +29,21 @@ namespace DiscIO
|
||||
CFileSystemGCWii::CFileSystemGCWii(const IVolume *_rVolume)
|
||||
: IFileSystem(_rVolume),
|
||||
m_Initialized(false),
|
||||
m_Valid(false),
|
||||
m_OffsetShift(0)
|
||||
{
|
||||
m_Initialized = InitFileSystem();
|
||||
m_Valid = DetectFileSystem();
|
||||
}
|
||||
|
||||
|
||||
CFileSystemGCWii::~CFileSystemGCWii()
|
||||
{
|
||||
m_FileInfoVector.clear();
|
||||
}
|
||||
|
||||
bool CFileSystemGCWii::IsInitialized() const
|
||||
{
|
||||
return m_Initialized;
|
||||
}
|
||||
|
||||
u64 CFileSystemGCWii::GetFileSize(const char* _rFullPath) const
|
||||
u64 CFileSystemGCWii::GetFileSize(const char* _rFullPath)
|
||||
{
|
||||
if (!m_Initialized)
|
||||
return 0;
|
||||
InitFileSystem();
|
||||
|
||||
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||
|
||||
@ -58,8 +53,11 @@ u64 CFileSystemGCWii::GetFileSize(const char* _rFullPath) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* CFileSystemGCWii::GetFileName(u64 _Address) const
|
||||
const char* CFileSystemGCWii::GetFileName(u64 _Address)
|
||||
{
|
||||
if (!m_Initialized)
|
||||
InitFileSystem();
|
||||
|
||||
for (size_t i = 0; i < m_FileInfoVector.size(); i++)
|
||||
{
|
||||
if ((m_FileInfoVector[i].m_Offset <= _Address) &&
|
||||
@ -72,10 +70,10 @@ const char* CFileSystemGCWii::GetFileName(u64 _Address) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
u64 CFileSystemGCWii::ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) const
|
||||
u64 CFileSystemGCWii::ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize)
|
||||
{
|
||||
if (!m_Initialized)
|
||||
return 0;
|
||||
InitFileSystem();
|
||||
|
||||
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||
if (pFileInfo == NULL)
|
||||
@ -90,8 +88,11 @@ u64 CFileSystemGCWii::ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _Max
|
||||
return pFileInfo->m_FileSize;
|
||||
}
|
||||
|
||||
bool CFileSystemGCWii::ExportFile(const char* _rFullPath, const char* _rExportFilename) const
|
||||
bool CFileSystemGCWii::ExportFile(const char* _rFullPath, const char* _rExportFilename)
|
||||
{
|
||||
if (!m_Initialized)
|
||||
InitFileSystem();
|
||||
|
||||
const SFileInfo* pFileInfo = FindFileInfo(_rFullPath);
|
||||
|
||||
if (!pFileInfo || pFileInfo->m_FileSize == 0)
|
||||
@ -214,8 +215,11 @@ void CFileSystemGCWii::GetStringFromOffset(u64 _Offset, char* Filename) const
|
||||
m_rVolume->Read(_Offset, 255, (u8*)Filename);
|
||||
}
|
||||
|
||||
size_t CFileSystemGCWii::GetFileList(std::vector<const SFileInfo *> &_rFilenames) const
|
||||
size_t CFileSystemGCWii::GetFileList(std::vector<const SFileInfo *> &_rFilenames)
|
||||
{
|
||||
if (!m_Initialized)
|
||||
InitFileSystem();
|
||||
|
||||
if (_rFilenames.size())
|
||||
PanicAlert("GetFileList : input list has contents?");
|
||||
_rFilenames.clear();
|
||||
@ -225,8 +229,11 @@ size_t CFileSystemGCWii::GetFileList(std::vector<const SFileInfo *> &_rFilenames
|
||||
return m_FileInfoVector.size();
|
||||
}
|
||||
|
||||
const SFileInfo* CFileSystemGCWii::FindFileInfo(const char* _rFullPath) const
|
||||
const SFileInfo* CFileSystemGCWii::FindFileInfo(const char* _rFullPath)
|
||||
{
|
||||
if (!m_Initialized)
|
||||
InitFileSystem();
|
||||
|
||||
for (size_t i = 0; i < m_FileInfoVector.size(); i++)
|
||||
{
|
||||
if (!strcasecmp(m_FileInfoVector[i].m_FullPath, _rFullPath))
|
||||
@ -236,7 +243,7 @@ const SFileInfo* CFileSystemGCWii::FindFileInfo(const char* _rFullPath) const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CFileSystemGCWii::InitFileSystem()
|
||||
bool CFileSystemGCWii::DetectFileSystem()
|
||||
{
|
||||
if (Read32(0x18) == 0x5D1C9EA3)
|
||||
{
|
||||
@ -250,6 +257,11 @@ bool CFileSystemGCWii::InitFileSystem()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void CFileSystemGCWii::InitFileSystem()
|
||||
{
|
||||
m_Initialized = true;
|
||||
|
||||
// read the whole FST
|
||||
u64 FSTOffset = (u64)Read32(0x424) << m_OffsetShift;
|
||||
@ -284,8 +296,6 @@ bool CFileSystemGCWii::InitFileSystem()
|
||||
|
||||
BuildFilenames(1, m_FileInfoVector.size(), NULL, NameTableOffset);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Changed this stuff from C++ string to C strings for speed in debug mode. Doesn't matter in release, but
|
||||
|
@ -30,24 +30,27 @@ class CFileSystemGCWii : public IFileSystem
|
||||
public:
|
||||
CFileSystemGCWii(const IVolume *_rVolume);
|
||||
virtual ~CFileSystemGCWii();
|
||||
virtual bool IsInitialized() const;
|
||||
virtual u64 GetFileSize(const char* _rFullPath) const;
|
||||
virtual size_t GetFileList(std::vector<const SFileInfo *> &_rFilenames) const;
|
||||
virtual const char* GetFileName(u64 _Address) const;
|
||||
virtual u64 ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) const;
|
||||
virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename) const;
|
||||
virtual bool IsValid() const { return m_Valid; }
|
||||
virtual u64 GetFileSize(const char* _rFullPath);
|
||||
virtual size_t GetFileList(std::vector<const SFileInfo *> &_rFilenames);
|
||||
virtual const char* GetFileName(u64 _Address);
|
||||
virtual u64 ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize);
|
||||
virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename);
|
||||
virtual bool ExportApploader(const char* _rExportFolder) const;
|
||||
virtual bool ExportDOL(const char* _rExportFolder) const;
|
||||
|
||||
private:
|
||||
|
||||
bool m_Valid;
|
||||
bool m_Initialized;
|
||||
|
||||
u32 m_OffsetShift; // WII offsets are all shifted
|
||||
std::vector <SFileInfo> m_FileInfoVector;
|
||||
u32 Read32(u64 _Offset) const;
|
||||
void GetStringFromOffset(u64 _Offset, char* Filename) const;
|
||||
const SFileInfo* FindFileInfo(const char* _rFullPath) const;
|
||||
bool InitFileSystem();
|
||||
const SFileInfo* FindFileInfo(const char* _rFullPath);
|
||||
bool DetectFileSystem();
|
||||
void InitFileSystem();
|
||||
size_t BuildFilenames(const size_t _FirstIndex, const size_t _LastIndex, const char* _szDirectory, u64 _NameTableOffset);
|
||||
};
|
||||
|
||||
|
@ -40,7 +40,7 @@ IFileSystem* CreateFileSystem(const IVolume* _rVolume)
|
||||
if (!pFileSystem)
|
||||
return 0;
|
||||
|
||||
if (!pFileSystem->IsInitialized())
|
||||
if (!pFileSystem->IsValid())
|
||||
{
|
||||
delete pFileSystem;
|
||||
pFileSystem = NULL;
|
||||
|
@ -49,14 +49,14 @@ public:
|
||||
IFileSystem(const IVolume *_rVolume);
|
||||
|
||||
virtual ~IFileSystem();
|
||||
virtual bool IsInitialized() const = 0;
|
||||
virtual size_t GetFileList(std::vector<const SFileInfo *> &_rFilenames) const = 0;
|
||||
virtual u64 GetFileSize(const char* _rFullPath) const = 0;
|
||||
virtual u64 ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) const = 0;
|
||||
virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename) const = 0;
|
||||
virtual bool IsValid() const = 0;
|
||||
virtual size_t GetFileList(std::vector<const SFileInfo *> &_rFilenames) = 0;
|
||||
virtual u64 GetFileSize(const char* _rFullPath) = 0;
|
||||
virtual u64 ReadFile(const char* _rFullPath, u8* _pBuffer, size_t _MaxBufferSize) = 0;
|
||||
virtual bool ExportFile(const char* _rFullPath, const char* _rExportFilename) = 0;
|
||||
virtual bool ExportApploader(const char* _rExportFolder) const = 0;
|
||||
virtual bool ExportDOL(const char* _rExportFolder) const = 0;
|
||||
virtual const char* GetFileName(u64 _Address) const = 0;
|
||||
virtual const char* GetFileName(u64 _Address) = 0;
|
||||
|
||||
virtual const IVolume *GetVolume() const { return m_rVolume; }
|
||||
protected:
|
||||
|
@ -46,7 +46,6 @@ GameListItem::GameListItem(const std::string& _rFileName)
|
||||
, m_pImage(NULL)
|
||||
, m_ImageSize(0)
|
||||
{
|
||||
|
||||
if (LoadFromCache())
|
||||
{
|
||||
m_Valid = true;
|
||||
@ -119,9 +118,9 @@ GameListItem::GameListItem(const std::string& _rFileName)
|
||||
|
||||
m_Valid = true;
|
||||
|
||||
// just if we have an image create a cache file
|
||||
// If not Gamecube, create a cache file only if we have an image.
|
||||
// Wii isos create their images after you have generated the first savegame
|
||||
if (m_pImage)
|
||||
if (m_Platform == GAMECUBE_DISC || m_pImage)
|
||||
SaveToCache();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user